EFM8 bootloader flash tool – efm8load.py

Disclosure: This post may contain affiliate links, meaning I get a commission if you decide to make a purchase through my links, at no cost to you.

By | October 15, 2016

I am working on a custom 4in1 blheli_s ESC for micro brushless setups. I wouldn’t like to reveal too much at this point, except it is going to be tinytiny (20x20mm) as you have seen with my version of a Frsky compatible tiny rx (see my uSKY project).
UPDATE: you can find more about the tinyPEPPER ESC here.

I was unable to find a good and easy to use command line flash tool for the Silabs Toolstick i bought. The newer EFM8 CPUs come pre-flashed with a serial bootloader – yay! Unfortunately there was no linux toolchain available. Or at least I did not find any. Anyway, here you go:

EFM8load – python edition

In order to program the EFM8BB10 CPU I am using on my ESC project, i wrote this small python utility that talks to the efm8 bootloader. You can find it at my github repo: https://github.com/fishpepper/efm8load.

This small python code snippet allows you to:

  • identify the chip
  • upload and verify any firmware in hex fileformat
  • download (!) the content of the efm8 flash

The downloading feature is something special, the bootloader does not allow downloading of flash contents. However it allows to verify the flash by using a crc16 checksum over a given region. This can be exploited to read back the flash by issuing many many verify operations. Due to this the whole operation takes a long time. But it works 😉

Usage

Connect the RX and TX lines of a serial2usb converter (3.3V level!) to the RX and TX pins of your MCU uart0. On the EFM8BB10 i used these pins are P0.5 (RX, connect to serial TX), and P0.4 (TX, connect to serial RX). Empty chips will enter the bootloader on every start. Once they have a firmware flashed the bootloader needs to be activated by pulling C2D low (on this chip it is P2.0). Once the chip is in bootloader mode you can identify the chip by:

user@machine :~/src/efm8load> ./efm8load.py -i
########################################
# efm8load.py - (c) 2016 fishpepper.de #
########################################

> opening port '/dev/ttyUSB0' (115200 baud)
> checking for device
> success, detected EFM8BB1 cpu (variant EFM8BB10F8G_QFN20)
> detected EFM8BB1 cpu (variant EFM8BB10F8G_QFN20, flash_size=8192, pagesize=512)

Or upload a given firmware by running

user@machine :~/src/efm8load> ./efm8load.py -w blheli_s_A_L_90_REV16_4.HEX 
########################################
# efm8load.py - (c) 2016 fishpepper.de #
########################################

> opening port '/dev/ttyUSB0' (115200 baud)
> uploading file 'blheli_s_A_L_90_REV16_4.HEX'
> checking for device
> success, detected EFM8BB1 cpu (variant EFM8BB10F8G_QFN20)
> detected EFM8BB1 cpu (variant EFM8BB10F8G_QFN20, flash_size=8192, pagesize=512)
> will erase page 0 (0x0000-0x01FF)
..snip..
> writing segment 0x0000-0x0005
> delaying write of flash[0] = 0x02 to the end
> write at 0x0001 ( 5): 0x19 0xfd 0x02 0x00 0xb3
> verifying segment... OK
..snip..
> write at 0x1D80 (118): 0x85 0xb1 0xdb 0xc3 ... 0xe8 0xb1 0x06 0x01
> verifying segment... OK
> will now write flash[0] = 0x02
> write at 0x0000 ( 1): 0x02
> verifying segment 0x0000-0x0005... OK
..snip..
> verifying segment 0x1A40-0x1A6F... OK

Or even dump the flash contents to a file (takes very long):

user@machine :~/src/efm8load> ./efm8load.py -r dump.hex
########################################
# efm8load.py - (c) 2016 fishpepper.de #
########################################

> opening port '/dev/ttyUSB0' (115200 baud)
> dumping flash content to 'dump.hex'
> please note that this will take long
> checking for device
> success, detected EFM8BB1 cpu (variant EFM8BB10F8G_QFN20)
> detected EFM8BB1 cpu (variant EFM8BB10F8G_QFN20, flash_size=8192, pagesize=512)
> flash[0x0D17] = 0x86....

Enjoy 😉

Leave a Reply

Your email address will not be published. Required fields are marked *