Skip to content

Bootloader Documentation

ghil edited this page Aug 5, 2011 · 29 revisions

Bootloader Documentation


Important: In order the bootloader to function, the BOOTRST Fuse-Bit hast to be set.


###Starting the bootloader:

  • If Contiki is running, press the button 5 sec long
  • By holding the button pressed, while plugging the socket In both cases the EEPROM-Flag will be set, which, after the successful flashing, will be again disabled.

###Integrity check of the Flash-memory:

When starting the bootloader, a CRC value over the total memory (except for the boot sector) will be computed and compared with a CRC-value that is already in the EEPROM. The later one is computed and written in the EEPROM after its successful flashing. In case the CRC-values don’t match, the program stays in the bootloader.

###Displaying the bootloader mode:

A blinking red LED will show if the bootloader is running.

###Leaving the bootloader:

If in 30 sec. there is no command to flash the bootloader, it will exit. Thereby, the program will start running at position 0x0000 in the flash memory.

##Flashing:

The flashing can be made through the Linux console application „BootloaderFlasher“. An explanation of the various parameters can be shown by using the parameter “-h”.

###Flashing the USB stick:

The USB stick that has to be flashed, has to be in a bootloader mode. The application “BootloaderFlasher”, with the hex file used for flashing as an input parameter, has to be started on the device, to which the USB stick is connected. The flashing should now follow automatically.

###Flashing the socket:

The socket that has to be flashed has to be shifted to a Bootloader mode. The application “BootloaderFlasher”, has to be started with the parameter “-f”, as well as with the hex file used for flashing. The application should run on the device, to which the USB stick is connected. The USB stick, in return, has to be connected to the socket. The flashing should then follow automatically.

##Setting up the bootloader firmware:

In case the bootloader is not functioning, it has to be rewritten via JTAG. This is done by using a AVR JTAGMKII and invoking:

make

make program

in the respective folder firmware/bootloader/Socket/ for the socket and firmware/bootloader/USB/ for the USB stick.

If while writing the bootloader, the EEPROM is accidentally deleted, it can be rewritten by using the command:

avrdude -p atmega1284p -P usb -c jtagmkII -U eeprom:w:Bootloader.eep

or respectively, for the USB stick:

avrdude -p at90usb1287 -P usb -c jtagmkII -U eeprom:w:Bootloader.eep

Thereby, it is important, the original MAC address of the device to be again written in the EEPROM.

Further Information

###Communication protocol USB-bootloader:

A serial communication with the USB-bootloader will be setup through a virtual serial port. After the startup, the bootloader waits for a command on the serial port: the commands “e” (end bootloader) and ”p” (program bootloader) will be accepted.

If the command “e” is used, the bootloader acknowledges it with the hex value 0x06. Afterwards the bootloader will be exited. If the command “p” is used, the bootloader acknowledges this with a hex value 0x01. The bootloader waits now, line after line, for the data of an Intel hex file. Every line has to begin with the value ‘:’. If the line does not begin with this value, the program mode will be exited and the hex value 0x00 will be returned. At the end of the transfer, every line has to undergo a test sum, which is checked from the bootloader. If this sum is correct, the line data will be written in the flash memory and the hex value 0x05 will be returned. After that, the next line can be further transferred. If the test sum is incorrect, the hex value 0x06 is returned. In that case, the line has to be transferred again. The last line of each Intel hex file contains the „End of Record“. As soon as this line will be transferred, the programming mode will be left and assumed, that a valid image was written.

###Communication protocol Socket-bootloader:

If the socket is flashed, the communication over the serial connection with the USB stick runs the same way, as if the USB stick would have been in a bootloader mode. However, the flashing won’t be initiated with the command “-p”. Instead, the USB stick will be set in the flash mode in the running Contiki by using the command “-f’. The USB stick will further remain in Contiki, but, during the flashing, it ignores the packets from the transceiver that don’t originate from the socket that has to be flashed. Moreover, there will be no status announcements through the serial connection from Contiki. The USB stick sends the lines from the hex files through the transceiver to the socket. The socket, in return, sends an acknowledgment packet to confirm the correctly received line or to ask for resending. The packet contains the hex value 0x06 if the line should be retransmitted or 0x05 if the next line should be sent. At the beginning, the socket generates in the bootloader a 2-Byte random value, which, while flashing, will be send in every packet to the USB stick. After the USB stick has received the value for the first time, it also sends this value in every packet. In this way, it is assured, that no other flashing process, that runs simultaneously, will disturb the existing one.

Clone this wiki locally