SAM9X60-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), 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:
- SAM9X60-Curiosity – Getting Started with MPLAB Harmony 3 Development: CSP Application: rtt_periodic_timeout
- SAM9X60-Curiosity – Configure and Build at91bootstrap to Load a MPLAB Harmony v3 Application from NAND Flash Memory
Prerequisites
- Knowledgeable of the SAM9X60 Boot Process
- SAM9X60 Data Sheet – Section 12. Boot Strategies
- Knowledgeable of the SAM-BA In-System Programmer (ISP)
- SAM-BA In-System Programmer (ISP) Host Application installed on the host computer
Hardware
For this training, you will use the SAM9X60-Curiosity Development Board (P/N: EV40E67A).
SAM9X60-Curiosity Development Board
Set up the SAM9X60-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 of the “SAM9X60-Curiosity - Features” page.
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.
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.
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.
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).
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.
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.
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.
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.
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
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
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
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>
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.
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.
We can see the application booting up from the console:
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.
Learn More
- SAM9X60-Curiosity Development Board – Introduction
- SAM9X60-Curiosity Development Board – Console Serial Port
- SAM9X60-Curiosity Development Board – Booting Demo Linux® Image
- SAM9X60-Curiosity Development Board – Comparison
- Developing with Embedded Linux
- Developing Applications with MPLAB Harmony 3 Software Framework for MPUs
- SAM9X60-Curiosity - Migrating a MPLAB Harmony 3 Software Framework Application from the SAM9X60-EK to SAM9X60-Curiosity: rtt_periodic_timeout