The example Python script uploads an application hex file to a device running the bootloader example. This is achieved using the Xplained Pro Embedded Debugger as a bridge between the device and the PC. For each byte sent, the same value is expected in return to confirm that the data transfer was successful. The bootloader expects enough data to fill APPCODE. If the hex file does not contain enough data to do so, 0xff will be sent until APPCODE is filled. Figure 1 shows how this works.
To run the script, the following arguments are required:
python tiny_uploader.py ./App/Release/App.hex 8192 COM130 115200
c:\[your_path]>python tiny_uploader.py ./App/Release/App.hex 0x2000 COM130 115200 Uploading 7936 bytes... 100.00% OKThe following type of message appears if the upload fails. In this example, it is due to the Virtual COM port returning 0x00 after a communication timeout:
Uploading 7936 bytes... Failed at address 0x0100 Value 0x00 echoed, expected 0x19
The script is written to support Python 2.7.13 and 3.5.2, and it will most likely run without error on later versions as well. Download Python from https://www.python.org/downloads/ or use your favorite Python distribution.
python -m pip install -U future pyserial intelhexThis command can also be used to upgrade the modules to the latest version.