Bootloader
Overview
The EFM32GG330F1024 comes with a preprogrammed bootloader from Silicon Labs. Depending on the version of the MCU we have: UART bootloader (AN0003) and UART+USB bootloader (AN0042).
The code of both versions of the bootloader is available within the respective Application Note that you can easily find with simplicity studio. There is not a particular license for this code, the only restrictions are:
- The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
- Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
- This notice may not be removed or altered from any source distribution.
It is also possible to boot from an USB storage device (AN0060). Write your application, put it on an USB drive, connect the driver to the board and then reset the board. The bootloader will load the application from the USB drive.
Other bootloaders
For what I see, the vendor's bootloader is most used for this MCU. Obviously, we can spend days on other bootloaders without practical worth.
Vendor's Bootloader Modes
The bootloader has two main modes: interactive and direct. In the interactive mode the user can use the serial interface to perform some simple command (read the application note for the commands description). In the direct mode, the bootloader just look for the application and run it immediately.
Hardware constraints
The bootloader use the GPIO E10 (TX) and E11 (RX) for the serial communication.
To enter the interactive mode the SWDCLK
signal must be pulled high on
reset. If, on reset, the SDWCLK
signal is low the bootloader runs in
the direct mode.
On the hardware we should use a special button for this purpose, it
could be hidden on the back side and pressed with a clip. Alternatively,
a combination of the user buttons (e.g. pressing all buttons for
interactive mode).
> These are the constraints of the Silicon Labs version. Of course, we can modify these constraints and re-compile our version.
Bootloader Source Code
By using Simplicity Studio you can download the Application Notes AN0003 and AN0042 with the source code. Everything is thought to be compiled on a windows system with the IAR workbench; Silicon Labs says that the reason is that IAR compiler guarantees the smallest binary. Fortunately, someone wrote a Makefile for the AN0042 by copying and adjusting the Silicon Labs examples' Makefiles. You can find all the necessary files on the repository.
> NOTE I also copied the liker scripts but maybe they are not necessary
How to compile an Application to Use with the Bootloader
For applications to work with the bootloader they must be created with a starting address of 0x4000.
How to Upload an Application Using the Bootloader
To upload your application to the EFM32 you have to:
- connect the serial interface (USB) to the board
- enter interactive mode by pulling DBG_SWCLK high
- reset the MCU
- send command to enter application upload mode
- transfer your application with XMODEM-CRC protocol
- remove the pull up on DBG_SWCLK
- reset the MCU
You can use the sx
command to upload you application. Configure the
serial port to be used:
stty -F /dev/ttyUSB0
and transfer your file:
sx -vv application.bin
> NOTE: The sx
has not been tested!
Alternatively, you can use the minicom
interface (which internally use
sx
):
minicom -D /dev/ttyUSB0
[on minicom] u
[on minicom] ctrl-a s
[on minicom] select xmodem
[on minicom] choose your file
How to Compile the Bootloader
This code does not compile with all toolchain versions. For example, it doesn't compile with gcc-arm-none-eabi-4_8-2014q1 and gcc-arm-none-eabi-4_7-2012q4.But, it compiles with the Mentor Graphics toolchain arm-2012-09.
> NOTE: at the moment it also require wine
to complete the build
process because of the Windows program bin2h.exe
. It will be replaced
with something that runs on Linux as soon as possible, I found some
alternatives but I was looking for the source code of the same program
but it is pretty old.
To compile the bootloader follow these steps:
cd freewatch/sw/bootloader-an0042/make-dir
make LINUXCS=/path/to/toolchain/root/directory INCLUDEBASE=/path/to/enerymicro/root/directory
> NOTE: you can edit the Makefile with the path to your toolchain and energymicro directory
What to Do On Operating System Boot
> TODO (sorry) : I wrote some notes but I have to re-think about them and look deeper