Alpha : Visual Tour    Switching Between Bootloader and Target Firmware  

Here is how we do the switchover from target device to bootloader in the sample program, AryTst5_2550.hex.

This sample program is a HIDmaker project, so we expect that this device will be connected to a PC.  We further expect that a special program is running on the PC that can send data to this device, and read data from it.  This particular device expects the PC to occasionally send it an array of bytes called Data1[ ].

The arrow points to a small "if" statement we have added to the source code, where the firmware has just received a complete Output Report of data from the PC.  This code says:

IF the first two elements of the array we just received from the PC are 101 (decimal) and 102 (decimal) respectively,

THEN go into assembly language and perform a far jump to the start of the bootloader code, which in this case is located at absolute address 0x6800.

This causes the device to switch to running the bootloader.  If the target device was a USB device, the previous device will appear to electrically detach itself from the USB, and the bootloader will electrically attach itself and present itself to the PC.

 

open full sized image

3 of 11
Copyright Notice and Author Information