SAM9X60-EK – Writing MPLAB® Harmony 3 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 3 Software Framework Application) and boot.bin (second-stage bootloader, at91bootstrap), to NAND Flash memory on the SAM9X60-EK Evaluation Kit using the SAM-BA® In-System Programmer (ISP). Once the images are written, and upon reset, the SAM9X60 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 topic was developed with SAM-BA ISP v3.7.


Hardware

For this training, you will use the SAM9X60-EK Evaluation Kit.

SAM9X60-EK Evaluation Kit

Set up the SAM9X60-EK as listed below to the host computer running SAM-BA host application.

Jumpers

  • Set the jumpers to their default positions as shown in the "Jumper Summary" section in the "SAM9X60-EK — Features" page.

SD Memory Cards

  • Ensure no SD memory cards are plugged into SD card (J4) connector.

Power

  • Apply power as shown in "Power Options" section in the "SAM9X60-EK — Features" page.

Console Serial Communications

SAM-BA Host to Monitor Serial Communications

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

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 ISP - Applets" page.


NAND Flash Memory

The SAM9X60-EK has a 4 Gb (512M x 8) NAND Flash memory (U9) (Micron MT29F4G08ABAEA) that can be used for booting the system.

The at91bootstrap (boot.bin) binary will be written to location 0x0 to 0x0003FFFF. The MPLAB Harmony 3 Software Framework application (harmony.bin) binary will be written to location 0x00040000 to 0x000FFFFF.

sam9x60_ek_nf_harmony_memory_map.png

Setup SAM-BA Host to Monitor Communications

In this section, you will establish SAM-BA host application communications with the target’s (SAM9X60) 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 3 Software Framework application) binary images to NAND Flash memory.

1

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 Micro-B USB cable to the USB Type-A port (J7) on the SAM9X60-EK.

2

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

3

Open jumper the DISABLE_BOOT (J13).

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

4

Press both the DIS_BOOT (SW4) and nRST (Reset) (SW3) push buttons.

Pressing the DIS_BOOT (SW4) push button disables booting from the onboard memories.

5

Continue pressing DIS_BOOT (SW4) while releasing the nRST (Reset) (SW3) push button.

6

Release the DIS_BOOT (SW4) push button.

The SAM9X60-EK 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.


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.

For more information on the SAM-BA applet nandflash, see the "SAM-BA ISP - Applets: Program External NAND Flash Memory" page.

Ensure that no other bootable NVMs on the SAM9X60-EK contain a bootable image. Ensure there is no SD memory card plugged into J4 and no bootable image in NOR (QSPI) Flash (U8). For information on the default boot sequence of the SAM9X60, see Section 12, "Boot Strategies" in the SAM9X60 datasheet.

1

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

$ sam-ba -p serial -b sam9x60-ek -a nandflash -c erase

cmd_nandflash_erase_1.png
cmd_nandflash_erase_2.png
console_nandflash_erase.png

NAND Flash boot procedures use Programmable Multi-bit Error Correcting Code (PMECC) to detect and correct errors during NAND Flash read operations. Note the PMECC value (listed as NAND header value above) for the SAM9X60-EK is 0xc1e04e07. For more information, refer to Section 12.4.7, "Detailed Memory Boot Procedures" and Section 35, "Programmable Multibit Error Correction Code Controller (PMECC)" in the SAM9X60 datasheet.


Write boot.bin to NAND Flash Memory

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

1

Change directory to the location of boot.bin:

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

2

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

$ sam-ba -p serial -b sam9x60-ek -a nandflash -c writeboot:boot.bin

The writeboot command modifies the relevant unused Arm® exception vector to store the size of the bootstrap binary, as required by the ROM Boot code during the boot process.

cmd_nandflash_writeboot_boot_bin.png
console_nandflash_writeboot_boot_bin.png

Write harmony.bin to NAND Flash Memory

In this section, you will write the MPLAB Harmony 3 Software Framework application binary image, harmony.bin, to NAND Flash memory.

1

Change directory to the location of harmony.bin:

C:\Users\<user>\Harmony3\csp_apps_sam_9x60\apps\rtt\rtt_periodic_timeout\firmware\sam_9x60_ek.X\dist\sam_9x60_ek\production\

2

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

$ sam-ba -p serial -b sam9x60-ek -a nandflash -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 a MPLAB® Harmony 3 Application from NAND Flash Memory" training page.

ide_at91_kconfig_nand.png
cmd_nandflash_write_harmony_bin.png
console_nandflash_write_harmony_bin.png

Run MPLAB Harmony 3 Application on the Target

To run the application, press the nRST (Reset) (SW3) push button. Observe the RGB LED (LD1) flashes blue. You can also observe the at91bootstrap reading from the NAND Flash memory on the console.

console_harmony_bin_run_nand_rtt_periodic_timeout.png

Summary

In this training topic, you wrote the binary files harmony.bin and boot.bin to NAND Flash memory on the SAM9X60-EK and ran the application on the target.


What’s Next?

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

Second-Stage Bootloader at91bootstrap

Writing to Non-Volatile Memory (NVM)

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.