#How to mount the NAND FLASH on Acqua A5

<abstract>
This article illustrates how to mount and test the NAND FLASH mounted on Acqua A5 board
</abstract>

To try this article we need a bootable Linux microSD for Acqua A5. Create one by following this article 
in case you haven't it: 

* @article='download_acqua'

Boot Linux on your Acqua A5 and access to its command line as __acme__ user via SSH or debug port:

	login: acme
	password: acmesystems

Launch a package index update:

	sudo apt update

then install the __mtd-utils__ package

	sudo apt install mtd-utils


Create a 200MB lenght file of random numbers to use as sample for the test by typing:

	dd if=/dev/urandom of=sample bs=1M count=200

Check its lenght by typing:

	ls -al sample

Create a new directory and mount on it the NAND FLASH 

	sudo ubiformat /dev/mtd0
	sudo ubiattach -p /dev/mtd0
	sudo ubimkvol /dev/ubi0 -N rootfs -m
	sudo mount -t ubifs /dev/ubi0_0 /mnt/ubifs

Save the ramdom sample file on the NAND FLASH partition and check if the copy 
is correct by typing:

	md5sum sample 
	ff46a364e90d22ba6d218bf20511d55b  sample

	md5 /mnt/ubifs/sample 
	ff46a364e90d22ba6d218bf20511d55b  /mnt/ubifs/sample

Umount the NAND FLASH

	sudo umount /mnt/ubifs

## Device tree definition

Place this definition under __ahb__ section inside the device tree

	ahb {
		ebi@10000000 {
			pinctrl-0 = <&pinctrl_ebi_addr &pinctrl_ebi_cs0>;
			pinctr-name = "default";
			status = "okay";

			nand_controller: nand-controller {
				status = "okay";

				nand@3 {
					reg = <0x3 0x0 0x2>;
					atmel,rb = <0>;
					nand-ecc-mode = "hw";
					nand-ecc-strength = <4>;
					nand-ecc-step-size = <512>;
					nand-on-flash-bbt;
					label = "atmel_nand";
				};
			};
		};
	}

## Ready-to-use files

Device tree source used on Kernel 4.19.x

* [acme-acqua-nand.dts](./acme-acqua-nand.dts)

Device tree blob used on Kernel 4.19.x

Save the old version of __at91-sama5d3_acqua.dtb__ saved in the first partition of microSD
and replace with this file renamed in __at91-sama5d3_acqua.dtb__.

* [acme-acqua-nand.dtb](./acme-acqua-nand.dtb)


@include='bio_alessia_tocci'

## Links

Older version of this article:

* @article='testnand'
