microSD card boot vs NAND memory boot
The most important question first: should I boot Debian from the microSD card or from the NAND memory?
Generally, booting from microSD card is faster and safer. However, in specific cases booting from NAND might be the better decision. Consider the below comparison when deciding where to boot from.
Using NAND is better than using microSD card:
- if you are aiming for minimal power consumption;
- if you want faster read and write
- when there is no microSD card connector, no external connections are allowed, or microSD card is not a preferred storage medium;
- for academic reasons;
- Since it is harder to compromise the security of the system physically (as opposed to just stealing the microSD card).
Using NAND is worse than using microSD card because:
- you need more software knowledge, especially regarding file systems;
- it is harder to make a backup;
- in case of a problem with the file system – the device would not boot and the recovery (of your data) would be nearly impossible.
How to install Debian to the NAND memory
It is possible to install the official Debian Jessie images to the NAND memory of your A20 board.
Note that currently only the Debian Jessie images for the A20 boards contain such a NAND installation option.
How to do it?
1. Download and extract the latest official Debian Jessie image from the wiki article for your board. Note that the procedure below is not possible with the Wheezy releases, only with the Jessie ones.
The script would not work with custom images.
2. Write the image to a micro SD card using your favorite software (like Win32 Disc Imager or dd).
3. Insert the prepared card in your board and boot the board.
4. Establish connection to the command line interface of the board.
5. Execute nandinstall script (type nandinstall and press enter).
6. Wait until Debian installs on the NAND memory (it takes around 10 minutes).
7. Shut down the board and remove the microSD card.
8. Now you can boot from the NAND memory.
Q: I did everything like you explained above and when I boot from the NAND I receive only black screen. Nothing on the console. What did I do wrong???
A: You did nothing wrong. The script above was written and tested on board that already had Android installed on the NAND memory. The problem might be related to the fact that we didn't load Android to the NAND memory of A20 boards for some time. No Android on the NAND = script not working.
It seems that the problem is caused by boot0 and boot1 code on the device, boot0 and boot1 code is located at a special area, which only the tools released by Allwinner (PhoenixSuit) can access. The problem is that the tools are not open-source and no one knows what happens exactly.
At the current moment we are uploading proper boot codes during production and this issue should no longer appear, but in case you are affected there are two workarounds:
1) Install Android to the NAND first using PhoenixSuit or LiveSuit (depending on the board) and then perform the nandinstall script again. The wiki of each board has instructions and images for Android install via the USB.
2) If you prefer to use Linux computer:
You can use CT_NandBoot software - you need a Linux computer to set the proper boot0 and boot1 in the NAND. It is faster than using PhoenixSuit and loading Android images (it takes one command and ~20 seconds to set the NAND correct under Linux). Then you can use the nandinstall script mentioned in the beginning of the article.
How to do it:
- Get the sources of the program on your Linux computer:
# git clone https://github.com/phelum/CT_NandBoot
# sudo apt-get install libusb-1.0-0-dev
# cd CT_NandBoot
- Put the board into bootloader mode (press recovery button; apply power, apply mini USB; release button) and execute:
- Wait around 20 seconds process to finish
Now the board should be able to operate with the nandinstall script as usual.
Q: Everything worked fine when using the image from the card, but when I install to the NAND, the Ethernet stopped working. What went wrong?
A: If after installation to the NAND you have problems with the Ethernet, check the value of address 0x01c20164 in the memory, if it is 0x0 then change the value to 0x1006. Then test again. Do the following:
Check the value with:
# devmem 0x01c20164
Change the value with:
# devmem 0x01c20164 w 0x1006
Q: Can I use mainline kernel Armbian-based images with my A20 NAND board?
A: If you wish to use the NAND memory, then it is not recommended. The NAND driver support had been poor. Check first if the NAND driver support in the mainline had been improved. For mainline kernel, consider boards with eMMC flash memory instead of NAND, since the driver support is better.