SAMA5D29-Curiosity – Writing MPLAB® Harmony v3 Application and at91bootstrap to SQI™ Flash Memory Using SAM-BA® ISP
Introduction
In this training, you will write two binary images, harmony.bin (an MPLAB® Harmony v3 Software Framework application) and boot.bin (second-stage bootloader, at91bootstrap), to SQI™ Flash Memory on the SAMA5D29-Curiosity Development Board using the SAM-BA® In-System Programmer (ISP). Once these steps are completed, and upon reset, the SAMA5D29 will boot and run the MPLAB Harmony v3 Software Framework application.
For this exercise, you will write the binaries that were created in the training topics:
- SAMA5D29-Curiosity – Getting Started with MPLAB® Harmony v3 Development: CSP Application: pio_led_on_off_interrupt
- SAMA5D29-Curiosity – Configure and Build at91bootstrap to Load a MPLAB® Harmony v3 Application from SQI™ Flash Memory
Prerequisites
- Knowledgeable of the SAMA5D2 Series Boot Process
- SAMA5D29 Datasheet – Section 17. Standard Boot Strategies
- Familiarity with the features of the SAMA5D29-Curiosity Development Board.
- Knowledgeable of the SAM-BA In-System Programmer (ISP)
- SAM-BA In-System Programmer (ISP) Host Application installed on the host computer
Hardware
For this training, you will use the SAMA5D29-Curiosity Development Board (P/N: EV07R15A)
SAMA5D29-Curiosity Development Board
Set up the SAMA5D29-Curiosity as listed below to the host computer running the SAM-BA ISP Host Application.
Jumpers
Set the jumpers to their default positions as shown in the “Jumper Summary” section of the “SAMA5D29-Curiosity - Features” page.
SD Memory Cards
Ensure no SD Memory Cards are plugged into SD Memory Card slots (J6 or J7).
USB-A Port (J1)
Connect a USB Type-C cable to the USB-A port (J1) and the host computer running the SAM-BA Host Application.
- This will be the serial communications path for the SAM-BA Host to communicate with the SAM-BA Monitor on the SAMA5D29-Curiosity (otherwise known as the target).
Power
The SAMA5D29-Curiosity will power on when a USB Type-C cable is plugged into the USB-A port (J1) and the host computer.
- If extra current is required, beyond the 500 mA supplied by USB, an external +5 VDC can be applied to the coaxial power connector (J2).
64 Mb Serial Quad I/O™ (SQI™) Flash Memory with EUI-48 and EUI-64
The SAMA5D29-Curiosity has a 64 Mb Serial Quad I/O (SQI) Flash Memory with EUI-48 and EUI-64 memory (U9) (Microchip SST26VF064BEUI). It is connected to the Quad SPI Interface 1 (QSPI1) peripheral of the SAMA5D29.
Setup Console Serial Communications
Connect a USB-to-Serial 3.3 or 5.0 VDC TTL Level adapter with a 6-pin single-in-line 0.1” pitch connector to the Serial Debug connector (J28) and establish serial communications with the host computer running a terminal emulation program.
This connection will allow you to observe that the SAMA5D29 is in monitor mode waiting for commands from the SAM-BA Host Application.
Setup SAM-BA Host to Monitor Communications
In this section, you will establish SAM-BA Host Application communications with the target’s (SAMA5D29) SAM-BA Monitor.
To communicate with the SAM-BA Monitor on the target, you must
- Install the SAM-BA Host on a Host Computer, and
- Connect a USB Type-C cable to the USB-A port (J1) on the SAMA5D29-Curiosity.
Ensure jumper the QSPI BOOT (J10) jumper is closed (default).
This will allow booting from the onboard SQI Flash Memory.
Press the START (SW3) push button to wake up the MPU.
If the SQI Flash Memory is empty (erased), the SAMA5D29-Curiosity will boot to the SAM-BA Monitor. This action will also activate the USB-A port (J1).
Configure qspiflash Applet
In this section, you will edit a Qt Modeling Language (QML) script to add configuration information for the qspiflash applet.
Using a text editor, add the following configuration information for the instance [QSPI controller, I/O Set, and clock frequency in MHz] to the C:\sam-ba_v3.7.1_win32\qml\SAMBA\Device\SAMA5D29\SAMA5D29.qml text file.
Erase SQI Flash Memory
In this section, you will erase the contents of the SQI Flash Memory. This is a necessary step before writing data.
Erase the contents of the SQI Flash memory using the following SAM-BA Host Applet command:
$ sam-ba -p serial -d sama5d29 -a qspiflash -c erase
Write boot.bin to SQI Flash Memory
In this section, you will write the at91bootstrap binary image, boot.bin, to SQI Flash Memory.
Change the directory to the location of boot.bin:
<project_directory>\at91bootstrap\build\binaries\
Write boot.bin to SQI Flash Memory using the following SAM-BA Host Applet command:
$ sam-ba -p serial -d sama5d29 -a qspiflash -c writeboot:boot.bin
Write harmony.bin to SQI Flash Memory
In this section, you will write the MPLAB Harmony v3 Software Framework application binary image, harmony.bin, to SQI Flash Memory.
Change the directory to the location of harmony.bin:
C:\Users\<user>\Harmony3\csp_apps_sam_a5d2\apps\pio\pio_led_on_off_interrupt\firmware\sam_a5d2_curiosity.X\dist\sam_a5d2_curiosity\production>
Write harmony.bin to SQI Flash Memory using the following SAM-BA Host Applet command:
$ sam-ba -p serial -d sama5d29 -a qspiflash -c write:harmony.bin:0x40000
The write command syntax is write:<filename>:[<addr>] where <addr> is the Flash Offset for Demo App value in the at91bootstrap Kconfig configuration (see figure below). In this instance, the <addr> value is value 0x40000; this is value you took note of in the "SAMA5D29-Curiosity – Configure and Build at91bootstrap to Load a MPLAB® Harmony v3 Application from SQI Flash Memory" training.
Run MPLAB Harmony v3 Application on the Target
To run the application, press the RESET (SW2) push button. It will take a moment for the SAMA5D29 to boot. Observe the RGB LED (D7) lights green (during boot).
Press the USER (SW1) push button and observe the RGB LED (D7) lights green. Release the USER push button and the RGB LED will turn off.
Summary
In this training topic, after you established SAM-BA Host to target Monitor communications, you first erased and then wrote boot.bin and harmony.bin to SQI Flash Memory. Upon reset, the SAMA5D29-Curiosity boots the MPLAB Harmony v3 Software Framework application.
Learn More
For training topics on configuring at91boostrap for other Non-Volatile Memories (NVM), see: