adafruit / Adafruit_Adalink

Python wrapper for Segger's J-Link Commander & STMicro STLink V2 to flash various ARM MCUs
MIT License
125 stars 33 forks source link

Added .bin file support #5

Closed microbuilder closed 9 years ago

microbuilder commented 9 years ago

AdaLink currently accepts .hex files, which we generate with objcopy and other tools, but it might be useful to add support for .bin files to AdaLink as well since these are sometimes easier to generate and work with, although we need to specify a second 'address' parameter to know where to start writing the file in flash memory.

The JLink supports this via two commands:

loadfile   Load data file into target memory.
           Syntax: loadfile <filename>, [<addr>]
           Supported extensions: *.bin, *.mot, *.hex, *.srec
           <addr> is needed for bin files only.

loadbin    Load *.bin file into target memory.
           Syntax: loadbin <filename>, <addr>

I'd propose a new optional parameter set as follows:

adalink nrf51822 --binfile filename.bin --binaddress 0x80001000

Alternatively, we can simplify this by detecting file extensions on the current --program argument, and if we detect a .bin file, we can use a mandatory --address | -a field to write that file, though we'll have to throw an error when more than one file is provided to the program argument.

Perhaps the latter is easier to keep the number of parameters in check?

tdicola commented 9 years ago

This is implemented now with the --program-bin or -b option. For example --program-bin foo.bin 0x80001000 (hex address), --program-bin foo.bin 1234567890 (decimal address), or even --program-bin foo.bin 0777654 (octal address, has a preceding 0).