SAMA7D65-Curiosity – Writing MPLAB® Harmony v3 Application and at91bootstrap to NOR Flash (QSPI) Memory Using SAM-BA® ISP

Last modified by Microchip on 2024/12/11 15:27

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) generated with a header, to NOR Flash (Quad SPI Interface (QSPI)) memory on the SAMA7D65-Curiosity Kit using the SAM-BA® In-System Programmer (ISP). Once the images are written, and upon reset, the SAMA7D65 will boot and run the application.

For this exercise, you will write the binaries that were created in the training topics:

Prerequisites

The following are prerequisites to complete this training:

​This training was developed with SAM-BA ISP v3.8.1.

Hardware

For this training, you will use the SAMA7D65-Curiosity Kit.

SAMA7D65-Curiosity Kit

Set up the SAMA7D65-Curiosity as listed below to the host computer running the SAM-BA host application.

Warning

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

Warning

​Be sure to observe RomBOOT on the console. Otherwise, the SAM-BA host application cannot talk to the monitor on the target.

​For more information on SAM-BA host applets, see "SAM-BA In-System Programmer - Applets" page.

Back to Top

NOR Flash (QSPI) Memory

The SAMA7D65-Curiosity has a 64-Mbit Serial Quad I/O™ (SQI™) Flash memory (U9) (Microchip Technology SST26VF064B) that can be used for booting the system.

The at91bootstrap (boot.bin) binary will be written to locations 0x0 to 0x0003FFFF. The MPLAB Harmony v3 software framework application (harmony.bin) binary will be written to locations 0x00040000 to 0x000FFFFF.

NOR Flash Memory Map

Back to Top

Set Up SAM-BA Host to Monitor Communications

In this section, you will establish SAM-BA host application communications with the target’s (SAMA7D65) SAM-BA monitor. Then you will use the SAM-BA host applet (qspiflash) to erase and then write the boot.bin (at91bootstrap) and harmony.bin (MPLAB Harmony v3 software framework application) binary images to NOR Flash (QSPI) memory.

To communicate with the SAM-BA monitor on the target, you must have installed the SAM-BA host on a host computer and connect a Type-C USB cable to the USB A port (J3) on the SAMA7D65-Curiosity.

Back to Top


Ensure there is no SD memory card inserted in slot J10.

Back to Top


Open the NAND BOOT (J36) and QSPI BOOT (J39) jumpers.

This will disable booting from the onboard memories (NAND and NOR (QSPI) Flash memory).

Back to Top


Press START (SW3) and then press the RESET (SW4) push button.

Back to Top


Connect the QSPI BOOT (J39).

The SAMA7D65-Curiosity will boot to the SAM-BA monitor and start communications with the SAM-BA host application.

If you have the Console Serial Communications established, you can observe ROMBoot on the Console (terminal emulator) indicating the SAM-BA monitor is running.

Back to Top


Erase NOR Flash (QSPI) Memory

In this section, you will erase the contents of the NOR Flash memory. This is a necessary step before writing data to NOR Flash memory.

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

​Ensure that no other bootable NVMs on the SAMA7D65-Curiosity contain a bootable image. Ensure that there is no SD memory card plugged into J10 and no bootable image in NAND Flash (U8). For information on the default boot sequence of the SAMA7D65, see Section 21, "Boot Strategies" in the SAMA7D65 datasheet.

Erase the contents of the NOR Flash memory using the following SAM-BA host applet command:

$ sam-ba -p serial -b sama7d65-curiosity -a qspiflash -c erase

SAM-BA: qspiflash erase beginning

SAM-BA: qspiflash erase ending

Console: qspiflash erase

Back to Top

Generate boot.bin with header

Ensure you have built at91bootstrap as mentioned in the "SAMA7D65-Curiosity – Configure and Build at91bootstrap to Load an MPLAB® Harmony 3 Application from NOR Flash (QSPI) Memory" page.

In this section, you will generate at91bootstrap binary image boot.bin with header from the following commands.

Open command prompt and change the directory to the location of boot.bin:

<project_directory>\at91bootstrap\build\binaries\boot.bin

Back to Top


Now generate a bootable sama7d65 bootstrap image file named boot_img.bin from a bootstrap binary file named boot.bin with SAM-BA:

$ sam-ba -u gen_image:sama7d65:boot.bin:::

Back to Top


Display the data stored in the header of a bootstrap image file:

$ sam-ba -u parse_image:boot_img.bin

Back to Top

Rename and write boot.bin to NOR Flash (QSPI) Memory

In this section, you will rename and write the at91bootstrap binary image, boot.bin, to NOR Flash memory.

Change the directory to the location of boot_img.bin:

<project_directory>\at91bootstrap\build\binaries\boot_img.bin

Back to Top


Rename boot_img.bin to boot.bin.

Back to Top


Write boot.bin to NOR Flash memory using the following SAM-BA applet command:

$ sam-ba -p serial -b sama7d65-curiosity -a qspiflash -c write:boot.bin

The write command is used when programming a bootstrap file into an external NOR Flash memory boot partition.

SAM-BA: qspiflash writeboot

Console: qspiflash writeboot

Back to Top

Write harmony.bin to NOR Flash (QSPI) Memory

In this section, you will write the MPLAB Harmony v3 software framework application binary image, harmony.bin, to NOR Flash memory.

Change the directory to the location of harmony.bin:

C:\Users\<user>\Harmony3\csp_apps_sama7d65\apps\pio\pio_led_on_off_interrupt\sam_a7d65_curiosity.X\dist\default\production\

Back to Top


Write harmony.bin to NOR Flash memory using the following sam-ba applet command:

$ sam-ba -p serial -b sama7d65-curiosity -a qspiflash -c write:harmony.bin:0x40000

The write command is write:<filename>:[<addr>] where <addr> is the Flash Offset for Demo App value in the at91bootstrap configuration (Kconfig). The value 0x40000 you took note of in the training: "SAMA7D65-Curisoity – Configure and Build at91bootstrap to Load an MPLAB® Harmony 3 Application from NOR Flash (QSPI) Memory"

Linker for Production: ddram

SAM-BA: qspiflash write

Console: qspiflash write

Back to Top

Run the MPLAB Harmony v3 Application on the Target

To run the application, press the RESET (SW4) push button. Observe that the Red, Green, and Blue (RGB) Light-emitting Diode (LED) (D11) flashes blue. You can also observe the at91bootstrap reading from the QSPI Flash memory on the console.

Console run

Back to Top

Summary

In this training, you wrote the binary files harmony.bin and boot.bin to NOR Flash (QSPI) memory on the SAMA7D65-Curiosity and ran the application on the target.

Back to Top

Learn More

Back to Top