Beyond uploading single files using, MegunoLink Pro’s Programming Visualizer supports multi-step programming using AVRDude and an upload specification file. This is particularly useful for loading bootloaders onto the micro.
The upload specification file is an xml file with .musx
extension.
Here is an example that can be used to upload a bootloader:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<?xml version="1.0" encoding="utf-8" ?> <upload-specification> <upload part="atmega328p" > <memory type="lock">0x3F</memory><!-- Enable updating bootloader --> <memory type="hfuse">0xD8</memory><!-- Select 2k boot size, reset vector jumps to bootloader, enable serial programming & data download. --> <memory type="flash" format="i">|bootloader_atmega328_pro_8MHz.hex</memory> <memory type="eeprom" format="r">|AppId.bin</memory> <memory type="lock">0x0f</memory><!-- Disable bootloader update, enable user program update. --> </upload> <upload part="atmega644p" > <!-- Enable updating bootloader --> <memory type="lock">0x3F</memory> <!-- Bit Description Default Select 7 Enable OCD 1 (OCD disabled) 1 6 Enable JTAG 0 (JTAG enabled) 1 5 Enable SPI program 0 (SPI prog enabled) 0 4 Enable watchdog always on 1 (not always on) 1 3 EEPROM preserved through chip erase 1 (1=>not preserved) 1 2 BootsizeSZ1 0 0 1 BootsizeSZ0 0 1 0 Select reset 1 (1=>don't use bootloader) 0 Select 2k words (4k bytes) boot size, reset vector jumps to bootloader, enable serial programming & data download. --> <memory type="hfuse">0xDA</memory> <memory type="flash" format="i">|bootloader_atmega644_pro_8MHz.hex</memory> <memory type="eeprom" format="i">|AppId.hex</memory> <memory type="lock">0x0f</memory><!-- Disable bootloader update, enable user program update. --> </upload> </upload-specification> |
The file supports multiple devices with each part placed in its own upload
section and identified by a part name. The part number is used for the AVRDude -p
parameter.
Within each upload
section are the programming instructions, a set of memory writes, for AVRDude. Each memory node requires a type
, specifying the memory operation to perform. The content of the memory node is used as the value for the operation. The following types are supported:
lock
: update the lock byte. Content gives the value to write.hfuse
: update the lock byte. Content gives the value to write.lfuse
: update the lock byte. Content gives the value to write.flash
: write a file to the flash memory. Content gives the filename, which may be any format supported by AVRDudeeeprom
: write a file to the device’s eeprom. Content gives the filename, which may be any format supported by AVRDude
The lock
, hfuse
and lfuse
types all update the respective fuses on the Arduino. The flash
writes a file to the devices flash memory while eeprom
writes a file to the device’s eeprom. Both file operations require the file-format to be specified using a format
attribute. Any format supported by AVRDude may be used including Intel hex format (format="i"
) and binary files (format="b"
). Refer to the AVRDude documentation for more information.
Filenames are automatically quoted when passed to AVRDude (so they may contain spaces). Paths are relative to the AVRDude installation folder, which normally isn’t that useful. If you prefix the path with a pipe character (‘|’), the folder containing the upload specification file will be added to the path. This makes it easy to provide relative paths to source files.
Finally, xml comments, such as <!-- this is a comment -->
, are fully supported.