Tuesday, January 8, 2019

Updating the tomu bootloader on the tomu.im EFM32HG


I got a tomu tiny EFM32 that fits in a USB port at lca 2018. More information on Tomu.

Mine came with the serial bootloader (it presents a USB CDC ACM device). I didn't manage to get to the update booth to reflash it at LCA.

I had some difficulty getting the new bootloader on it when I pulled out recently to try to play with it, but since I got it working, here's a short runthrough of how I got it updated.

I use Fedora 28 but this info should apply for any Linux really.



I cut a small piece of a business card to use as a wedge to hold the device in the USB port. Insert it with the large contact pads facing up / toward the centre of the USB port, and with the rounded end with the small contacts on the outside edge of the port.

If you're on the new DFU firmware it'll blink some lights and you're done, you can skip reading this now.

If you're on the old firmware, it won't blink any lights, but you'll see the new USB device reported in dmesg:

[14275.148309] usb 1-2: New USB device found, idVendor=10c4, idProduct=0003, bcdDevice= 0.00
[14275.148321] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[14275.148329] usb 1-2: Product: EFM32 USB CDC serial port device
[14275.148336] usb 1-2: Manufacturer: Silicon Laboratories Inc.
[14275.155055] cdc_acm 1-2:1.0: ttyACM0: USB ACM device

which confirms it has connected and presented a serial device.

The device is /dev/ttyACM0. ls -l /dev/ttyACM0 showed it's owned by root with group dialout. I wasn't in the group per my id command's output. So I added myself with usermod -a -G dialout craig. Then instead of logging in and out I just ran sudo -u craig -i to make a new session with the new gid enabled.

I tried to connect with screen /dev/ttyACM0 but got a wall of "?" migrating across the display and it didn't respond to commands. Perhaps a baud rate mismatch or failure to initialize. I don't know screen well enough.

If I was doing this again I'd probably use PuTTY, but I already had minicom so I used that. It connected with default settings:

$ minicom -D /dev/ttyACM0

and got a prompt.

I could query the bootloader version:

553E891F
B                                                                                                                            
?                                                                                                                            
i                                                                                                                            
BOOTLOADER version EFM32HG bootloader v1.a, Chip ID 24617301553E891F                                                         

Now I downloaded the latest tomuboot for serial upload: prebuilt/toboot-boosted.bin from the tomu-bootloader repository per the instructions.

Back to minicom, I initiated the firmare upload process. This is a bit temperamental and I had to try it a few times, but the general idea is to press "u" (lower case) in minicom then promptly press control-Zzs to get the file-send dialog. Choose xmodem (not zmodem!). The dialog is ... not user friendly - I couldn't work out how to navigate the file tree. I used arrow keys to navigate to "go to" button and press enter. Enter directory path containing file, like Downloads and press enter. Use arrow keys to navigate to the toboot-boosted.bin file, press space to tag it, then navigate to the go button and press enter again.

It should show a progress dialog and after a few moments, show that the file upload completed successfully.

If so, press "b" to start the new bootloader. (I'm not sure this is actually necessary, you might just be able to power cycle the device).

You should see blinking LEDs on the tomu.

Remove it from the port. Then insert it again.

If the bootloader flashed correctly you should still see blinking lights. Yay! The USB info should have changed, per dmesg

[14449.575667] usb 1-2: new full-speed USB device number 48 using xhci_hcd
[14449.703836] usb 1-2: New USB device found, idVendor=1209, idProduct=70b1, bcdDevice= 1.01
[14449.703844] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[14449.703850] usb 1-2: Product: Tomu Bootloader (5) v2.0-rc7
[14449.703855] usb 1-2: Manufacturer: Kosagi

Now you can install dfu-util:

$ dnf install dfu-util

and interact with the device over the DFU protocol:

$ sudo dfu-util -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1209:70b1] ver=0101, devnum=49, cfg=1, intf=0, path="1-2", alt=0, name="Tomu Bootloader (5) v2.0-rc7", serial="UNKNOWN"

Hooray! We can now update it with simple programs:

$ sudo dfu-util -D ~/Downloads/blinky1.bin 
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 1209:70b1
Run-time device DFU version 0101
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0101
Device returned transfer size 1024
Copying data from PC to DFU device
Download [=========================] 100%         5128 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!

Yay, blinky lights!

No comments:

Post a Comment

Captchas suck. Bots suck more. Sorry.