SAMA5D29-Curiosity – Writing MPLAB® Harmony v3 Application and at91bootstrap to SQI™ Flash Memory Using SAM-BA® ISP

Last modified by Microchip on 2024/06/20 12:44

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:

Prerequisites

This training was developed with SAM-BA ISP v3.7.1.

Hardware

For this training, you will use the SAMA5D29-Curiosity Development Board (P/N: EV07R15A) 

SAMA5D29-Curiosity Development Board

For more information, see the “SAMA5D29-Curiosity – Features” page. 

Set up the SAMA5D29-Curiosity as listed below to the host computer running the SAM-BA ISP Host Application

Jumpers

Jumper J10, QSPI BOOT, must be closed (default). 

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. 

An EUI-48 MAC address for the 10BaseT/100Base-TX Ethernet Reduced Media-Independent Interface (RMII) has been programmed into the SQI Flash Memory.   

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. 

For more information on establishing serial communications with the target console see the "SAMA5D29-Curiosity – Console Serial Communications" page.

Back to Top

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.  

Be certain that the SAM-BA Host application has been added to the path. 

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. 

The USB-A port (J1) also functions as a source of power for the SAMA5D29-Curiosity. The port is limited to 500 mA. If greater current is required, the SAMA5D29-curiosity should be powered via J21 (see the “Power Options” section on the “SAMA5D29-Curiosity – Features” page.). 

Back to Top


Ensure there are no SD Memory Cards inserted in slots J6 or J7.

Back to Top


Ensure jumper the QSPI BOOT (J10) jumper is closed (default).  

This will allow booting from the onboard SQI Flash Memory.  

Back to Top


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).  

For the SAM-BA Host to be able to communicate with the target Monitor, the target must be in Monitor mode. 

If a bootable image resides in the SQI Flash Memory, you can remove the jumper (J10), press the reset button (SW2), and observe RomBoot on the Console. Then replace (close) the jumper (J10). 

Back to Top


Observe RomBOOT on the Console (terminal emulator) indicating the SAM-BA Monitor is running on the target device.

Back to Top

Configure qspiflash Applet

In this section, you will edit a Qt Modeling Language (QML) script to add configuration information for the qspiflash applet. 

For more information on the SAM-BA Applet qspiflash, see the "SAM-BA In-System Programmer - Applets" page.

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.  

Edit qml file

Back to Top

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. 

For more information on the SAM-BA Applet qspiflash, see the "SAM-BA In-System Programmer - Applets" page.

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 

This will take a while.

Command Window: Erase 1 of 2

Command Window: Erase 2 of 2

Back to Top

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\ 

Back to Top


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 

The writeboot command is used to write a bootstrap file into an external NVM memory boot partition. 

Command Window: writeboot boot.bin

Back to Top

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> 

Back to Top


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.

Project Properties: kconfig

Command Window: write harmony.bin

Back to Top

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.  

The application uses the PIO Peripheral library to generate callback on switch press and release and drives the GPIO pin connected to the RGB LED to indicate the switch status. 

Console: application running

Back to Top

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. 

Back to Top

Learn More

For training topics on configuring at91boostrap for other Non-Volatile Memories (NVM), see: 

Back to Top