Device Flashing Commands#

The commands in this section all require a working debug connection for communicating with the device. You would normally always use one of the J-Link connection options when running the flash command, but it is intentionally left out of most of the examples to keep them short and concise.

Flash Image File#

Flashes the image in the specified filename to the target device, starting at the specified address. The address value is interpreted as a hexadecimal number. The affected bytes will be erased before writing. If the image contains any partial flash pages, these pages will be read from the device and patched with the image contents before erasing the page and writing back. After writing, the affected flash areas are read back and compared. Finally, the chip is reset using a pin reset, making code execution start. The debugger to connect to is indicated by the J-Link serial number (--serialno option). The --binary option can be used to interpret all file types as flat binaries, bypassing any parsing of GBL, S-record, or Intel Hex files. For example, you can use this to test firmware upgrade using an internal storage bootloader. The --include-section and --exclude-section options can be used when flashing an Elf file.

Command Line Syntax

$ commander flash <filename> --address <address> --serialno <serial number> [--binary --include-section <section> --exclude-section <section>]

Command Line Input Example

$ commander flash blink.bin --address 0x0 --serialno 440012345

Connects to the J-Link debugger with serial number 440012345 and flashes the image in blink.bin to the target device, starting at address 0.

Command Line Output Example

Flashing blink.s37.
Flashing 2812 bytes, starting at address 0x00000000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Verifying written data...
Resetting...
Finished!
DONE

Flash Using IP Address without Verification and Reset#

Flashes the image in the specified filename to the target device, using the IP address specified. The data in flash is not verified after flashing, and the device is left halted after flashing.

Command Line Syntax

$ commander flash <filename> --ip <IP> --halt --noverify>

Command Line Input Example

$ commander flash blink.s37 --ip 10.7.1.27 --halt --noverify

Flashes the image in blink.s37 to the target device, using the IP address 10.7.1.27. The data in flash is not verified after flashing, and the device is left halted after flashing.

Command Line Output Example

Flashing blink.s37.
Flashing 2812 bytes, starting at address 0x00000000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Finished!
DONE

Flash Several Files#

Flashes the images to the target device. Any overlapping data is considered an error.

Command Line Syntax

$ commander flash <filename> <filename>

Command Line Input Example

$ commander flash blink.s37 userpage.hex

Flashes the images in blink.s37 and userpage.hex to the target device.

Command Line Output Example

Adding file blink.s37...
Adding file userpage.hex...
Flashing 2812 bytes, starting at address 0x00000000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Verifying written data...
Finished!
Flashing 2048 bytes, starting at address 0x0fe00000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Verifying written data...
Resetting...
Finished!
DONE

Patch Flash#

Writes the specified byte(s) to the flash. The affected pages will be read from the device and patched with this data before erasing the page and writing back. When you use the --patch option, the patch memory data is interpreted as an unsigned integer. The optional length argument can be used to define the number of bytes, up to 8 bytes. If no length is specified, the default is to patch 1 byte.

Command Line Syntax

$ commander flash --patch <address>:<data>[:length]

Command Line Input Example

$ commander flash --patch 0x120:0xAB --patch 0x3200:0xA5A5:2

Writes the specified bytes 0xAB to address 0x120 and 0xA5A5 to address 0x3200. The affected pages will be read from the device and patched with this data before erasing the page and writing back.

Command Line Output Example

Patching 0x00000120 = 0xAB...
Patching 0x00003200 = 0xA5A5...
Flashing 2048 bytes, starting at address 0x00000000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Verifying written data...
Finished!
Flashing 2048 bytes, starting at address 0x00003000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Verifying written data...
Resetting...
Finished!
DONE

Patch Using Input File#

Flashes the specified application while simultaneously patching the image file and the flash of the device. If a filename is inside the file, these bytes are patched before writing the image.

Command Line Syntax

$ commander flash <filename> --patch <address>:<data>[:length] --patch <address>:<data>[:length]

Command Line Input Example

$ commander flash blink.s37 --patch 0x123:0x00FF0001:4 --patch 0x0FE00004:0x00

Flashes the blink application while simultaneously patching the image file and the flash of the device. Because 0x123 is inside the file, these bytes are patched before writing the image. Additionally, the user page will be read from the device and patched with this data before erasing the page and writing back.

Command Line Output Example

Flashing blink.s37.
Patching 0x00000123 = 00FF0001...
Patching 0x0FE00004 = 00...
Flashing 4096 bytes, starting at address 0x00000000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Verifying written data...
Finished!
Flashing 2048 bytes, starting at address 0x0fe00000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Verifying written data...
Finished!
DONE

Flash Tokens#

This section describes how to flash one or more tokens from text file(s) and/or command line options with their new values. Manufacturing tokens are the only token type supported by Simplicity Commander; simulated EEPROM tokens are not supported. For more information on manufacturing tokens, see AN961: Bringing Up Custom Nodes 'for the EFR32MG and EFR32FG Families.

The --tokengroup option defines which group of tokens is used. Simplicity Commander currently has built-in support for the znet token group.

Silicon Labs recommends generating a token file from a device or image file using the tokendump command and then making modifications to this file for use with the --tokenfile option.

Command Line Syntax

$ commander flash --tokengroup <token group> -–token <TOKEN_NAME:value> –-tokenfile <filename>

Command Line Input Example

$ commander flash --tokengroup znet --token TOKEN_MFG_STRING:"IoT Inc"

Set the token MFG_STRING to have the value IoT Inc. The TOKEN_ prefix is optional, that is, TOKEN_MFG_STRING and MFG_STRING are equivalent.

Command Line Input Example

$ commander flash --tokengroup znet --tokenfile tokens.txt

Sets the tokens specified in tokens.txt. All tokens in the file are processed, and if a duplicate is found, it will be treated as an error.

Command Line Input Example

$ commander flash --tokengroup znet --tokenfile tokens.txt --token TOKEN_MFG_STRING:"IoT Inc"

Sets the tokens specified in tokens.txt. Additionally, sets the MFG_STRINGto the value given. All files and tokens specified on the command line are processed, and if a duplicate is found, it will be treated as an error.

Depending on the operating system and shell being used, some escapes may be needed to correctly specify a string. For example, on the command line in a Windows 7 Professional Command Prompt window, execute the following command:

$ commander flash --tokengroup znet --token "TOKEN_MFG_STRING:\"IoT Inc\""

Command Line Output Example

Flashing 2048 bytes to 0x0fe00000
Resetting...
Uploading flash loader...
Waiting for flashloader to become ready...
Erasing flash...
Flashing...
Verifying written data...
Resetting...
Finished!
DONE