
Example Applications
After this program is built, the binary file (usb_stick_demo.bin), should be renamed to the filename
expected by usb_stick_update ("FIRMWARE.BIN" by default) and copied to the root directory of a
USB memory stick. Then, when the memory stick is plugged into the eval board that is running
the usb_stick_update program, this example program will be loaded into flash and then run on the
microcontroller.
This program simply displays a message on the screen and prompts the user to press the select
button. Once the button is pressed, control is passed back to the usb_stick_update program which
is still is flash, and it will attempt to load another program from the memory stick. This shows how
a user application can force a new firmware update from the memory stick.
2.27
USB Memory Stick Updater (usb_stick_update)
This example application behaves the same way as a boot loader. It resides at the beginning of
flash, and will read a binary file from a USB memory stick and program it into another location in
flash. Once the user application has been programmed into flash, this program will always start the
user application until requested to load a new application.
When
this
application
starts,
if
there
is
a
user
application
already
in
flash
(at
APP_START_ADDRESS
), then it will just run the user application.
It will attempt to load a
new application from a USB memory stick under the following conditions:
no user application is present at
APP_START_ADDRESS
the user application has requested an update by transferring control to the updater
the user holds down the eval board push button when the board is reset
When this application is attempting to perform an update, it will wait forever for a USB memory stick
to be plugged in. Once a USB memory stick is found, it will search the root directory for a specific
file name, which is
FIRMWARE.BIN
by default. This file must be a binary image of the program you
want to load (the .bin file), linked to run from the correct address, at
APP_START_ADDRESS
.
The USB memory stick must be formatted as a FAT16 or FAT32 file system (the normal case), and
the binary file must be located in the root directory. Other files can exist on the memory stick but
they will be ignored.
2.28
Watchdog (watchdog)
This example application demonstrates the use of the watchdog as a simple heartbeat for the
system. If the watchdog is not periodically fed, it will reset the system. Each time the watchdog is
fed, the LED is inverted so that it is easy to see that it is being fed, which occurs once every second.
To stop the watchdog being fed and, hence, cause a system reset, press the select button.
February 22, 2017
15