SAM9X60-Curiosity – Writing MPLAB® Harmony v3 Application and at91bootstrap to NAND Flash Memory using SAM-BA® ISP

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

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), to NAND Flash Memory on the SAM9X60-Curiosity Development Board using the SAM-BA® In-System Programmer (ISP). Once these steps are completed, and upon reset, the SAM9X60-Curiosity will boot and run the MPLAB Harmony v3 Software Framework application. 

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

Prerequisites

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

Hardware

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

SAM9X60-Curiosity Development Board

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

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

Jumpers

Ensure jumper J4, NAND Boot, is closed to enable booting from NAND Flash memory. 

SD Memory Cards

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

USB-A Port (J1)

  • Connect a USB micro-B cable to the USB-A port connector (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 SAM9X60 (also known as the target).  

Power

  • The SAM9X60-Curiosity will power-on when a USB micro-B cable is plugged into USB-A port (J1) and the host computer. 

4 Gb NAND Flash Memory (U3)

The SAM9X60-Curiosity has a 4 Gb (512M x 8) NAND Flash memory (U3) (Macronix MX30LF4G28AD-XKI). It is connected to the NAND Flash controller of the SAM9X60D1G. 

Setup Console Serial Communications

To view the target console, connect the host computer running a terminal emulation program in accordance with “SAM9X60-Curiosity – Console Serial Communications.” 

Setup SAM-BA Host to Monitor Communications

In this section, you will establish SAM-BA Host Application communications with the target’s 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: 

  • Installed the SAM-BA Host on a Host Computer, and  
  • Connect a Micro-B USB cable to USB-A port (J1) on the SAM9X60-Curiosity.

The USB-A port (J1) also functions as a source to power the SAMA7G54-Curiosity.  


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

Ensure jumper the NAND Boot (J4) jumper is closed.  

This will enable communications with the onboard NAND Flash memory. 


Press the START (SW3) push button to wake up the MPU. 

The SAM9X60-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 there exists an executable binary file in the NAND Flash memory, power down the SAM9X60-Curiosity, remove Jumper J4, NAND Boot, and apply power. Press the START (SW3) push button and observe that RomBOOT is displayed on the Console. Finally, close jumper J4 to enable communications with the NAND Flash memory. 

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 NAND PMECC Parameters

In the next sections, you will use the SAM-BA Applet nandflash to set the PMECC parameters to the NAND Flash header. The main reason for this is because, as of SAM-BA ISP version 3.7, there is no board support for the SAM9X60-Curiosity. Therefore, we will use the nandflash applet initialization command to configure communications with the onboard NAND Flash Memory. We will use this initialization command in conjunction with the erase, writeboot, and write commands.  

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

The syntax for the nandflash initialization command is shown below. Documentation of the nandflash applet is in the directory <sam-ba_directory>/doc/nandflash.html

Syntax: nandflash:[<ioset>]:[<bus_width>]:[<header>] 
Parameters: 
    ioset      I/O set 
    bus_width  NAND bus width (8/16) 
    header     NAND header value 
Examples: 
    nandflash                 use default board settings 
    nandflash:2:8:0xc0098da5  use fully custom settings (IOSET2, 8-bit bus, header is 0xc0098da5) 
    nandflash:::0xc0098da5    use default board settings but force header to 0xc0098da5 
For information on the NAND header values, please refer to Boot Strategies chapter from SAM9X60 datasheet. 

The SAM-BA Applet command to initialize the SAM9X60 to communicate with the NAND Flash memory is: 

$ sam-ba -p serial -b sam9x60 -a nandflash:1:8: 0xc2605007 

  • Ioset: 1 
  • Bus width: 8 
  • Header: 0xc2605007 

We will use this syntax in conjunction with the erase, writeboot, and write commands as shown in the sections below. 

Back to Top

Erase NAND Flash Memory

In this section, you will use the SAM-BA Applet nandflash to erase the contents of the NAND Flash Memory. This is a necessary step before writing data. 

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

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

$ sam-ba -p serial -d sam9x60 -a nandflash:1:8: 0xc2605007 -c erase 

This will take a while.

Command window: nandflash erase part 1 of 2

Command window: nandflash erase part 2 of 2

Back to Top

Write boot.bin to NAND Flash Memory

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

Change directory to the location of boot.bin: 

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

Back to Top


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

$ sam-ba -p serial -d sam9x60 -a nandflash:1:8:0xc2605007 -c writeboot:boot.bin 

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

Command Window: nandflash writeboot

Back to Top

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 directory to the location of harmony.bin: 

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

Back to Top


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

$ sam-ba -p serial -d sam9x60 -a nandflash:1:8:0xc2605007 -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 accompanying image). In this instance, the value is 0x40000; this value you took note of in the "SAM9X60-Curiosity – Configure and Build at91bootstrap to Load a MPLAB Harmony v3 Application from NAND Flash Memory" training.

Project Properties: kconfig

Command Window: nandflash write

Back to Top

Run MPLAB Harmony v3 Software Framework Application on the Target

To run the application, press the RESET (SW1) push button. It will take a moment for the SAM9X60 to boot. Observe the RGB LED (D1) lights green momentarily (during boot) and then turns off.

Once the application has booted, observe the RGB LED (D1) flashes blue at a 1 Hz rate. 

The rtt_periodic_timeout application blinks the RGB LED once per second when an RTT timer interrupt occurs. 

We can see the application booting up from the console: 

Console application running

Congratulations! You successfully written boot.bin and harmony.bin to NAND Flash Memory and run a Harmony v3 Software Framework application. 

Back to Top

Summary

In this training topic, after you established console and SAM-BA Host to Monitor communications, you first erased and then wrote boot.bin and harmony.bin to NAND Flash Memory. Finally, upon reset, the SAM9X60-Curiosity boots the MPLAB Harmony v3 Software Framework application. 

Back to Top

Learn More

Back to Top