Linux tip: How to reset device connected to USB port

Sometimes devices connected to USB ports need to be re-set. It’s not unusual GSM modems and WiFi dongles to freeze and the only way to bring them back to life is to remove and re-attach.

OLinuXino USB ports has power switches and current limiters which can be controller by Linux drivers.

After some experimenting we found that it’s not so easy actually to do it with the standard file system and shell.

A friend suggested to try this code. It worked very well, so here is how to use it. First you need to download and compile it, then to make it executable:

$ mkdir usbreset
$ cd usbreset
$ wget $ https://raw.githubusercontent.com/jkulesza/usbreset/master/usbreset.c
$ cc usbreset.c -o usbreset
$ chmod +x usbreset

Then you need to see where your USB device is. In our case I connected MOD-WIFI-R5370 WiFi USB dongle:

$ lsusb

you will see something like:

Bus 002 Device 039: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

to reset this device use the command:

./usbreset /dev/bus/usb/002/039

The device USB port will be power off for a second then power on again.

All above is tested and work with official Olimex Linux images from images.olimex.com, but should work on other Linux distributions too.

Experimenting with low power modes and Arduino

Image

Tero Koskinen recently did interesting experiments exploring how low power he can go with Arduino. http://arduino.ada-language.com/saving-power-with-avr-ada.html

He made setup with 5 boards to test:

  • original Arduino Duemilanove
  • original Arduino UNO
  • Olimexino-328 clone
  • Arduino DIY PTH kit from Sparkfun
  • Diavolino from Evil Mad Scientist

He correctly shut down all not used peripherials, Brown-Out-Detection, slowed down the CPU speed and used Power Saving modes.

the results were:

Device Current
Duemilanove 7.50mA
UNOr3 18.10mA
Olimexino-328 4.00mA
Sparkfun PTH Kit 7.60mA
Diavolino 0.50mA

 

Diavolino have nothing but the AVR so obviously is winner with this setup with only 0.5mA consumption.

Wait if there is no power regulator where these 0.5mA go when AVR is put in low power mode?

Looking at the schematic  you can see R1 RESET pullup 10K resistor which is connected to 5V -> 5V/10K = 0.5mA the whole consumption is taken by R1!!!

 

Then let’s see OLIMEXINO-328 the second place with 4mA (outch!) this board is promoted by OLIMEX as SUPER DUPER LOW POWER BOARD then why these bad results? Where these  4mA go?

The answer is obvious: Tero is powering OLIMEXINO-328 by the POWER JACK.

In our design we assume if the power come from the power jack it’s unlimited and we can waste it as much as we need – charging Lipo (if attached) etc.

So these 4mA are taken from the DCDC in the input.

If Tero wanted to see how OLIMEXINO-328 shines in low power he should have powered the board by the battery connector. When the power is applied to battery OLIMEXINO-328 is very humble and will need less 20 micro ampers 0.02 mA to operate!

How this is done? If we look at the schematic we will see that there is no RESET pull-up, but the RESET is done by tricky circuit with R12/R13/SD5/C7/C8 this schematic have zero consumption but still perform RESET functionality.

Also unltra-low-power LDO which needs just 3 micro amps to operate MCP1700T-3302E/MB is used for power regulator.

This makes possible complete Arduino to may keep working while consuming less 20 micro amps.

What 20 micro amps consumption means? If you use our standard LiPo 1400 mAh battery your board can work 70 000 hours or 3 years!

The other boards: Sparkfun kit 7.6 mA, Duemilanove 7.5mA and UNO 18.1 mA just use cheap voltage regulators which take this current, but it’s OK they have not been designed to be low power.

What is the conclusion: with right setup (powering from battery) OLIMEXINO-328 is the lowest power Arduino solution on the market! When we add to the low power the industrial temperature operation range -25+85C and the possibility to work with any input voltages from 9 to 30VDC, OLIMEXINO-328 is the most sophisticated board with many features while keeping the price reasonable.

Device Tree for Dummies LinuxCon presentation from Free Electrons

Image

Free Electrons put online their presentation at LinuxCon “Device Tree for Dummies”.

You can access it at http://free-electrons.com/pub/conferences/2013/elce/petazzoni-device-tree-dummies/petazzoni-device-tree-dummies.pdf

Embedded Linux Conference 2013 – Free Electrons Slides

Image

Thomas Petazzoni published his slides for Linux Con 2013, for these who want to learn more about Device Tree and how new SOC support is add to Linux Kernel this will be interesting reading: http://elinux.org/images/5/5e/Elc2013_Petazzoni.pdf