Home · |
The nandflash applet drives the Static Memory Controller (SMC) or the NAND Flash Controller (NFC) to program an external raw NAND flash memory embedded on the board and connected to the SAM MPU device.
The list of parameters to initialize the nandflash applet can be displayed with the following command:
sam-ba -p <port> -d <device> -a nandflash:help $ 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
The ioset parameter is an index that represents a group of I/O pins muxed to the SMC/NFC. The I/O set values are device specific; please refer to the nandflash section of the device configuration:
The bus_width parameter represents the number of data pins of the NAND flash. Supported values are either 8 (8-bit NAND flash) or 16 (16-bit NAND flash).
The header parameter is a 32-bit word descirbed below:
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 |
key | - | eccOffset | |||||
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
eccOffset | sectorSize | ||||||
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 |
eccBitReq | spareSize | ||||||
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
spareSize | nbSectorPerPage | usePmecc |
Number of Sectors per Page
Size of the spare zone in bytes
Number of ECC bits required
Size of the Sector
Offset of the first ECC byte in the spare zone. A value below 2 is not allowed and is considred as 2.
Value 0xC must be written here to validate the content of the whole word.
The list of commands supported by the nandflash applet can be displayed with the following commands:
sam-ba -p <port> -d <device> -a nandflash -c help $ sam-ba -p serial -d sama5d2 -a nandflash -c help
The erase command resets to 0xFF a range of erase blocks. The size of those erase blocks depends on the manufacturer and memory part. Typical erase block sizes are 128KiB or 256KiB of data, not including their associated spare.
$ 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
The write and writeboot commands program data from a binary file into the NAND flash pages. The blocks containing the pages to be programmed 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. Prior to what both comamnds do, the writeboot command also 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 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 $ 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
The read command loads data from the 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
The verify and verifyboot compare the data programmed in the NAND flash with the content of a given binary file. Unlike the verify command, the verifyboot command ignores the actual value of the relevant unused ARM exception vector in the binary file and does as if the value were the size of the 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 $ 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
Copyright © 2018 Microchip Technology | SAM-BA Documentation |