4.2 Python™ Scripts Operation
The provided Python scripts convert the .hex
file into a
.bin
file that contains the application information about the
application image (start address and size). Before writing the information area, the
script rounds the file size to the multiple of page size (multiple of 512 bytes), by
filling the additional area with 0xFF
. After that, the information area
is completed according to structure described in Application Code Format and
inserted at the beginning of .bin
file.
The Python script execution continues by uploading the generated
.bin
file using the communication interface. For this example, the
embedded debugger on the Curiosity Nano board is used as a bridge between the
microcontroller and the PC. For each byte sent, the same value is expected in return to
confirm that the data transfer was successful.
The Python script has the following flowchart:
- Hex file to be uploaded. Include the path if the file is not in the same folder.
- Maximum Flash size of the microcontroller.
- Virtual COM port used for UART
communication.
- This is listed in the Device Manager on a Windows® PC. For an AVR128DA48 Curiosity Nano it is listed as CuriosityVirtual COM Port (COMxxx). For the current example, COM10 port is used.
Note: The Virtual COM port is connected to the UART pins (PC0-TxD and PC1-RxD) on the AVR128DA48 device on the board. - Baud rate used. The default baud rate used by this example bootloader is 9600.
To run the script for an AVR128DA48 Curiosity Nano connected to port COM10 and of a 128 KB Flash size, the following format must be used:
python AVR-DA_uploader.py AVR_Dx_app_example.hex 0x20000 COM10 9600