SAMA7D65-Curiosity – Writing MPLAB® Harmony v3 Application and at91bootstrap to NAND Flash Memory Using SAM-BA® ISP
Introduction
In this training topic, you will write two binary images, harmony.bin (an MPLAB® Harmony v3 Software Framework Application) and boot.bin (second-stage bootloader, at91bootstrap) generated with header, to NAND Flash memory on the SAMA7D65-Curioisty 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 and from the sample application:
- SAMA7D65-Curiosity – Getting Started with MPLAB® Harmony v3 Development: CSP Application: pio_led_on_off_interrupt
- SAMA7D65-Curiosity – Configure and Build at91bootstrap to Load an MPLAB® Harmony v3 Application from NAND Flash Memory
Prerequisites
The following are prerequisites to complete this training:
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.
Jumpers
- Set the jumpers to their default positions as shown in the "Jumper Summary" section in the "SAMA7D65-Curiosity — Features" page.
SD Memory Cards
- Ensure no SD memory cards are plugged into SD card (J10) connector.
Power
- Apply power as shown in the "Power Options" section in the "SAMA7D65-Curiosity — Features" page.
Console Serial Communications
- To view the target console, connect the host computer running a terminal emulation program in accordance with the "SAMA7D65-Curiosity – Console Serial Communications" page.
SAM-BA Host to Monitor Serial Communications
- Connect the host computer running the SAM-BA host application to the SAMA7D65-Curiosity in accordance with the "SAM-BA Host to Monitor Serial Communications" page.
NAND Flash Memory
The SAMA7D65-Curiosity has a 4 Gbit SLC NAND Flash memory (U8) (macronix MX30LF4G28AD) that can be used for booting the system.
The at91bootstrap (boot.bin) binary will be written to location 0x0 to 0x0003FFFF. The MPLAB Harmony v3 Software Framework application (harmony.bin) binary will be written to location 0x00040000 to 0x000FFFFF.
Setup SAM-BA Host to Monitor Communications
In this section, you will establish SAM-BA host application communications with the target’s (SAMA7D65-Curiosity) SAM-BA monitor. Then you will use the SAM-BA host applet (nandflash) to erase and then write the boot.bin (at91bootstrap) and harmony.bin (MPLAB Harmony v3 Software Framework application) binary images to NAND Flash 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.
Ensure there is no SD memory card inserted in slot J10.
Open the jumpers NAND BOOT (J36) and QSPI BOOT (J39).
This will disable booting from the onboard memories (NAND and NOR (QSPI) Flash memory).
Press START (SW3) and then press the RESET (SW4) push button.
Connect the NAND BOOT (J36)
Erase NAND Flash Memory
In this section, you will erase the contents of the NAND Flash Memory. This is a necessary step before writing data to NAND Flash memory.
Erase the contents of the NAND Flash memory using the following SAM-BA host applet command:
$ sam-ba -p serial -b sama7d65-curiosity -a nandflash:::0xc2605007 -c erase
Generate boot.bin with header
Ensure you have build at91bootstrap as mentioned in SAMA7D65-Curiosity – Configure and Build at91bootstrap to Load an MPLAB® Harmony v3 Application from NAND Flash Memory
In this section, you will generate at91bootstrap binary image boot.bin with header from below commands,
Open command prompt and change directory to the location of boot.bin:
<project_directory>\at91bootstrap\build\binaries\boot.bin
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:::
To display the data stored in the header of a bootstrap image file 'boot_img.bin'.
$ sam-ba -u parse_image:boot_img.bin
Rename and write boot.bin to NAND Flash Memory
In this section, you will rename and write the at91bootstrap binary image, boot.bin, to NAND Flash memory.
Change the directory to the location of boot_img.bin:
<project_directory>\at91bootstrap\build\binaries\boot_img.bin
Rename boot_img.bin to boot.bin
Write boot.bin to NAND Flash memory using the following SAM-BA applet command:
$ sam-ba -p serial -b sama7d65-curiosity -a nandflash:::0xc2605007 -c write:boot.bin
Write harmony.bin to NAND Flash Memory
In this section, you will write the MPLAB Harmony v3 Software Framework application binary image, harmony.bin, to NAND Flash memory.
Change the directory to the location of harmony.bin:
C:\Users\<user>\HarmonyProjects\csp_apps_sama7d65\apps\pio\pio_led_on_off_interrupt\sam_a7d65_curiosity.X\dist\default\production
Write harmony.bin to NAND Flash memory using the following sam-ba applet command:
$ sam-ba -p serial -b sama7d65-curiosity -a nandflash:::0xc2605007 -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 SAM9X60-EK – Configure and Build at91bootstrap to Load an MPLAB® Harmony v3 Application from NAND Flash Memory training page.
Run MPLAB Harmony v3 Application on the Target
To run the application, press the RESET (SW4) push button. Observe the RGB LED (D11) flashes blue. You can also observe the at91bootstrap reading from the NAND Flash memory on the console.
Summary
In this training, you wrote the binary files harmony.bin and boot.bin to NAND Flash memory on the SAMA7D65-Curiosity and ran the application on the target.
Learn More
- SAMA7D65-Curiosity – Configure and Build at91bootstrap to Load an MPLAB® Harmony v3 Application from NOR Flash (QSPI) Memory
- SAMA7D65-Curiosity – Configure and Build at91bootstrap to Load an MPLAB® Harmony v3 Application from SD Memory Card
- SAMA7D65-Curiosity – Writing MPLAB Harmony v3 Application and at91bootstrap to NOR Flash (QSPI) Memory using SAM-BA ISP
- SAMA7D65-Curiosity – Copy MPLAB Harmony v3 Application and at91bootstrap to SD Memory Card