#NAND test for Acqua board

<abstract>
This procedure can be used to test the NAND FLASH onboard the Acqua board
</abstract>

<h2>Prepare a microSD</h2>
Use gparted as described here:

* [How to format a bootable microSD](/microsd_format)

to prepare a blank microSD.

<h2>Fill the microSD with data</h2>
Follow this article in the Kernel Linux 4.4.13 part:

* [Acqua](/download_acqua)

in order to fill the microSD with the two partitions needed:<br>
<b>boot.tar.bz2</b> in the first partition<br>
<b>rootfs.tar.bz2</b> in the second partition<br>

<h2>Change the bootloader with another NAND enabled</h2>
Download the following file:
<ul>
<li><a href="https://www.acmesystems.it/www/at91bootstrap_3_7/acqua-256m-boot.bin">acqua-256m-boot.bin download file</a></li>
</ul>
and put it in the first partition of the microSD.<br>
Rename it as boot.bin<br>

<h2>Update the Linux distribution</h2>
<pre>
root@acqua:~# apt-get update
</pre>

<h2>Install the mtd-utils package</h2>
<pre>
root@acqua:~# apt-get install mtd-utils
</pre>

<h2>Install unzip package</h2>
<pre>
root@acqua:~# apt-get install unzip
</pre>

<h2>Download the NAND test program</h2>
<ul>
<li><a href="./testnand.sh">test NAND shell script download file</a></li>
</ul>
then copy the <b>testnand.sh</b> script on the /root directory of the microSD filesystem and make it executable with:
<pre>
root@acqua:~# chmod +x testnand.sh 
root@acqua:~# 
</pre>

<h2>Download the example directory tree to write on the NAND filesystem</h2>
<ul>
<li><a href="./sam-ba_3.2.1.zip">example directory tree for testing download file</a></li>
</ul>
copy it on the /root directory of the microSD filesystem and unzip it with:
<pre>
root@acqua:~# unzip sam-ba_3.2.1.zip 
</pre>
In order to be able to write on the microSD in ssh you need to enable the ssh login for root superuser in /etc/ssh/sshd_config.<br>




<h2>Make a mount point for the NAND filesystem</h2>
<pre>
root@acqua:~# mkdir /mnt/ubifs
</pre>


<h2>Launch the NAND test script</h2>
<pre>
root@acqua:~# ./testnand.sh
</pre>

<h2>Example Log files</h2
Here are the log messages you can see on the first time you switch on a NAND enabled Acqua board:
<ul>
<li><a href="./bootlog_first.txt">Boot Log Messages First boot</a></li>
</ul>
You can see there was no bad block table:
<pre>
nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xda
nand: Micron MT29F2G08ABAEAWP
nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
atmel_nand 60000000.nand: minimum ECC: 4 bits in 512 bytes
atmel_nand 60000000.nand: Initialize PMECC params, cap: 4, sector: 512
atmel_nand 60000000.nand: Using NFC Sram read 
Bad block table not found for chip 0
Bad block table not found for chip 0
Scanning device for bad blocks
random: nonblocking pool is initialized
Bad block table written to 0x00000ffe0000, version 0x01
Bad block table written to 0x00000ffc0000, version 0x01
6 ofpart partitions found on MTD device atmel_nand
Creating 6 MTD partitions on "atmel_nand":
0x000000000000-0x000000040000 : "at91bootstrap"
0x000000040000-0x0000000c0000 : "bootloader"
0x0000000c0000-0x000000180000 : "bootloader env"
0x000000180000-0x000000200000 : "device tree"
0x000000200000-0x000000800000 : "kernel"
0x000000800000-0x000010000000 : "rootfs"
</pre>

The second boot will present some differences:
<ul>
<li><a href="./bootlog_second.txt">Boot Log Messages Second boot</a></li>
</ul>

<pre>
atmel_nand_nfc 70000000.nfc: NFC is probed.
atmel_nand 60000000.nand: Use On Flash BBT
atmel_nand 60000000.nand: Using dma0chan0 for DMA transfers.
nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xda
nand: Micron MT29F2G08ABAEAWP
nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
atmel_nand 60000000.nand: minimum ECC: 4 bits in 512 bytes
atmel_nand 60000000.nand: Initialize PMECC params, cap: 4, sector: 512
atmel_nand 60000000.nand: Using NFC Sram read 
Bad block table found at page 131008, version 0x01
Bad block table found at page 130944, version 0x01
6 ofpart partitions found on MTD device atmel_nand
Creating 6 MTD partitions on "atmel_nand":
0x000000000000-0x000000040000 : "at91bootstrap"
0x000000040000-0x0000000c0000 : "bootloader"
0x0000000c0000-0x000000180000 : "bootloader env"
0x000000180000-0x000000200000 : "device tree"
0x000000200000-0x000000800000 : "kernel"
0x000000800000-0x000010000000 : "rootfs"
</pre>

Here is instead the printout of the NAND test script for reference:
<ul>
<li><a href="./testnand_log.txt">Test NAND Log Messages</a></li>
</ul>

@include='bio_asquini'