Dumping/uploading flash contents on EFM32, EFR32, and EZR32
08/213/2017 | 10:53 PM
Question
Is there a way to dump the entire contents of flash on an EFM32 or EFR32 device to a single hex file? I'm using the EFM32 Jade Gecko device, and it has a 256-Kbyte main flash and a 10-Kbyte bootloader partition at two completely separate locations in memory. I would like to combine these into a single file, if possible.
Answer
Simplicity Commander (or just Commander, for short) is a tool for EFM32, EFR32, and EZR32 families that can be used to program the on-chip flash, unlock debug access, and update the firmware on Starter Kits for these devices. It is cross-platform (Windows, Macintosh, and Linux) and has both GUI and command line interfaces. One of the things it can do from the command line is upload the contents of flash on a connected device.
Flash upload is performed using the readmem command and appropriate options to specify the memory range to upload and the output file. It's easy to find out about the options available for readmem by adding the --help flag when invoked from the command line, like so:
There are two ways to tell Commander what to upload from flash. One is simply to specify the address range desired with the --range flag and appropriate start and end addresses:
It's also possible to upload flash using names for the different regions with the --region flag, but this requires knowing the regions that can be uploaded. Fortunately, it's simple to find out what named regions are available by invoking Commander with readmem and --region followed by the --help flag:
So, uploading the complete contents of the main flash array on a Pearl Gecko 12 (or really any EFM32/EFR32/EZR32) device can be done with:
Finally, getting to the question at hand, dumping the entire contents of flash is simply a matter of adding a --region flag for each named region on the command line. The Device Information (DI) page, which is the @devinfo named region, is skipped in this case since it is write-protected and not intended to be reprogrammed by the user:
Verifying that all of these regions were written to the designated output file would be painful if it were necessary to manually interpret the hex file by loading it into a text editor. Instead, the attached hexinfo utility for Windows (built from the cross-platform source found here) parses a given hex file and outputs the byte count of data in each referenced address range. As shown below, the allflash.hex file created in the previous step includes the 1 MB main, 2 KB user data, 2 KB lock bits, and 38 KB bootloader regions of flash on the Pearl Gecko 12 device.
Dumping/uploading flash contents on EFM32, EFR32, and EZR32