SAM-BA® ISP - Applets: Program External NAND Flash Memory

Program External NAND Flash Memory (nandflash)

The nandflash applet initializes the Static Memory Controller (SMC) or the NAND Flash Controller (NFC) and can perform read, write, erase, and verify functions.

The nandflash applet applies to the following devices. Documentation is available in the ../sam-ba/doc/ directory.

Device Documentation
SAM9X60 ../doc/sam9x60.html
SAM9XX5 ../doc/sam9xx5.html
SAMA5D2 Series ../doc/sama5d2.html
SAMA5D3 ../doc/sama5d3.html
SAMA5D4 ../doc/sama5d4.html
SAMV71 ../doc/samv71.html

Additional documentation is located in the document directory: ../doc/nandflash.html.

nandflash Command Structure

The nandflash applet has the following command structure:

$ sam-ba -p <port> -d <device> -a nandflash -c <command>

Initialize Controller

Initialization of the nandflash applet has the following command structure:

$ sam-ba -p <port> -d <device> -a nandflash

A list of parameters to initialize the nandflash applet can be displayed with the following command (using the SAMA5D2 Series device as an example):

$ sam-ba -p serial -d sama5d2 -a nandflash:help

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

A list of parameters is located in the document directory: ../doc/nandflash.html.

Supported Commands

A list of commands supported by the nandflash controller can be displayed with the following command:

$ sam-ba -p <port> -d <device> -a nandflash -c help

read Command

The read command reads data from NAND flash into a binary file.

$ sam-ba -p serial -b sam9x60-ek -a nandflash -c read:help

* read - read from memory to a file
Syntax:
    read:<filename>:[<addr>]:[<length>]
Examples:
    read:firmware.bin              read all to firmware.bin
    read:firmware.bin:0x1000       read from 0x1000 to end into firmware.bin
    read:firmware.bin:0x1000:1024  read 1024 bytes from 0x1000 into firmware.bin
    read:firmware.bin::1024        read 1024 bytes from start of memory into firmware.bin

erase Command

The erase command erases (resets to 0xFF) a range of data blocks in the NAND flash. The size of the data block depends on the target device (manufacturer and part number).

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

* erase - erase all or part of the memory
Syntax:
    erase:[<addr>]:[<length>]
Examples:
    erase                 erase all
    erase:4096            erase from 4096 to end
    erase:0x1000:0x10000  erase from 0x1000 to 0x11000
    erase::0x1000         erase from 0 to 0x1000

write and writeboot Command

The write and writeboot commands writes data from a binary file into the NAND flash.

The blocks containing the pages to be written should be erased first with the erase command.

Padding bytes are added to align programmed data to the page boundary. The page size is computed from the PMECC header.

$ sam-ba -p serial -b sam9x60-ek -a nandflash -c write:help

* write - write to memory from a file
Syntax:
    write:<filename>:[<addr>]
Examples:
    write:bootstrap.bin         write bootstrap.bin to start of memory
    write:u-boot.bin:0x10000    write u-boot.bin at offset 0x10000

The writeboot command should only be used when programming a bootstrap file into an external NAND Flash memory boot partition.

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

$ sam-ba -p serial -b sam9x60-ek -a nandflash -c writeboot:help

Syntax:
    writeboot:<filename>
Example:
    writeboot:bootstrap.bin     write bootstrap.bin as boot program at start of memory

verify and verifyboot Command

The verify and verifyboot commands compare the data written into the NAND flash with the contents of a binary file.

$ sam-ba -p serial -b sam9x60-ek -a nandflash -c verify:help

* verify - verify memory from a file
Syntax:
    verify:<filename>:[<addr>]
Examples:
    verify:firmware.bin         verify that start of memory matches firmware.bin
    verify:firmware.bin:0x1000  verify that memory at offset 0x1000 matches firmware.bin

The verifyboot command ignores the relevant unused ARM exception vector in the binary file.

$ sam-ba -p serial -b sam9x60-ek -a nandflash -c verifyboot:help

* verifyboot - verify boot program from a file
Syntax:
    verifyboot:<filename>
Example:
    verifyboot:bootstrap.bin    verify that start of memory matches boot program bootstrap.bin
© 2020 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.