How to install Debian on NAND in A20-MICRO?

Started by iso9660, October 17, 2013, 06:58:28 PM

Previous topic - Next topic

Alex293

Hi !

Thank a lot for your files ! Everything is now working !

mickours

Quote from: Mad Demus on October 22, 2013, 12:47:16 PM
Today I successfully installed the official Debian Image into A20-OLinuXino's flash.

First, download and uncompress this file which contains the bootloader and an image of the flash partition scheme:

http://dtmh.de/files/olinuxino-a20-flashinstall.zip

After that, change into the folder which contains the uncompressed files.

Now, here is the quick recipe:

#############################################################################
# HOWTO install a running SD-card image to A20-OLinuXino NAND flash
#
# The following steps must be executed as root and on a running SD-card image!
#
# Sunxi kernel 3.4.43 or later is required.
# Tested with official Olimex Debian Wheezy image with kernel 3.4.61+
#
# The flash partition scheme will looks like follow:
# /dev/nanda is BOOT device
# /dev/nandc is ROOT device
# /dev/nandb is MAGIC device
#
#############################################################################

# First of all, make sure that all nand devices /dev/nand* are unmounted
# (check output of mount if you are not sure)

# Copy A20 flash partition image to NAND flash
tar -xzOf nand_part.gz | dd of=/dev/nand
sync


# reboot to make new partitions available
reboot

# after reboot: create filesystems
mkfs.vfat /dev/nanda
mkfs.ext4 /dev/nandc
echo -e 'ANDROID!\0\0\0\0\0\0\0\0\c' > /dev/nandb


# mount new filesystems
mkdir /mnt/nanda
mkdir /mnt/nandc
mount /dev/nanda /mnt/nanda
mount /dev/nandc /mnt/nandc


# install bootloader to /dev/nanda
rm -rf /mnt/nanda/*
rsync -avc bootloader/* /mnt/nanda


# copy script.bin and uImage into new root device under /boot
mount /dev/mmcblk0p1 /boot
rsync -avc /boot/script.bin /boot/uImage /mnt/nandc/boot/


# if you need additional kernel arguments, you can create a uEnv.txt file under
# /mnt/nandc/boot/ wich contains the following line:
Quoteextraargs=<your extra kernel args here>

# copy rootfs
rsync -avc --exclude-from=exclude.txt / /mnt/nandc
sync


# shutdown and remove SD card
shutdown -h now

# now power on the device and it should boot from NAND!

Enjoy!
Thank you really much for this.

I'm trying to modify this to makes it boot on the SATA. I found out how to do it manually:
First, generate an Initrd with mkintramfs and mkimage
Then copy the root filsystem to a the SATA disk (here in /dev/sda2)
then stop the boot and type:

setenv root=/dev/sda2                                                 
setenv machid 10bb                                                     
setenv extraargs rootfstype=ext4 rootwait                             
setenv bootargs console=${console} root=${root} loglevel=${loglevel} ${panicarg} ${extraargs}
ext4load nand 2:0 0x43000000 /boot/script.bin                         
ext4load nand 2:0 0x41000000 /boot/uImage                             
ext4load nand 2:0 0x45000000 /boot/uInitrd                             
bootm 0x41000000 0x45000000               


The problem is that I can't do this automatically with the uEnv.txt because the way it is loaded
the uenvcmd do not run. And the memory is override after the load.

Here is the u-boot env:

sun7i#printenv
baudrate=115200
boot_fastboot=fastboot
boot_normal=bootm 48000000
boot_recovery=sunxi_flash read 40007800 recovery;boota 40007800
bootcmd=run setargs_nand boot_normal
bootdelay=1
bootenv=/uEnv.txt
console=ttyS0,115200
kernel=/uImage
kerneladdr=0x48000000
loadbootenv=mw 41000000 0 10000;ext4load nand 2:0 $scriptaddr /boot${bootenv} || fatload nand 0:0 $scriptaddr ${bootenv};env import 41000000 10000;setenv bootargs console=${console} root=${nand_root} loglevel=${loglevel} ${extraargs}
loadkernel=ext4load nand 2:0 $kerneladdr /boot${kernel} || fatload nand 0:0 $kerneladdr ${kernel}
loadscriptbin=ext4load nand 2:0 $scriptbinaddr /boot${scriptbin} || fatload nand 0:0 $scriptbinaddr ${scriptbin}
loglevel=8
nand_root=/dev/nand3
partitions=bootloader@nanda:boot@nandb:linux@nandc
scriptaddr=0x41000000
scriptbin=/script.bin
scriptbinaddr=0x43000000
setargs_nand=run loadbootenv loadscriptbin loadkernel setmachid
setmachid=setenv machid 10bb
stderr=serial
stdin=serial
stdout=serial



Can you provide the way of generating the bootloader files provided on the zip, so I can customize it?

ric.rug


Alex293



joost0405

#50
Hey guys,

Tried this on a A20-OLinuXino-LIME-4GB, but during boot i got:

VFS: Cannot open root device "nand3" or unknown-block(0,0): error -6

It's booting the kernel just fine

Linux version 3.4.90+ (root@debian) (gcc version 4.7.1 (Debian 4.7.1-7) ) #9 SMP PREEMPT Mon Jul 14 13:58:39 EEST 2014

But it can't find the rootfs installed to /mnt/nandc of the guide.

For clarity: I chose to install a debian wheezy debootstrapped rootfs here, but it also didn't work with the stock olimex debian image that came preinstalled on the SD card, so my guess is that it is something else.

My gut says I need to have a uEnv.txt with proper boot arguments. Any pointers?

Cheers,
Joost.


Nevermind, I was using a kernel that had nand support as a kernel module instead of having it built in. Therefore it could not find /dev/nand3 as the nand support was not loaded. Classic chicken-egg problem. Quick workaround: use the 3.4.67+ kernel posted in this thread. Better workaround: roll your own A20 kernel with nand built in instead of as a kernel module.

Thanks,
Joost.

mlg

I tried it on an A20 Lime but always get the error:

[  ] load kernel successed
[  ] start address = 0x4a000000
[  ] boot1: bad boot image magic, maybe not a boot.img


Any hints?

mlg

 :)

Solved it. Partition table was wrong, because I omitted the O option from tar. Seems to work now.

Great

otolizz

Hi,

I tried to install debian release 8 on the nand, but it freeze on the boot screen...
Anyone to help??

Thx.

gippy73

Thanks for the tutorial!!!

It works like a charm ;)

For everyone's convenience I want to remark some detail that may sound obvious to skilled people:
+ on my debian Olimex's image gzip is at version 1.5, while many files like also "olinuxino-a20-flashinstall" need at least v. 2.0 (from "file" command's output). Instead of trying to update gzip I've preferred to install p7zip (sudo apt-get install p7zip) and use it (7z x olinuxino-a20-flashinstall.zip) to decompress that file
+ in order to (find and) run mkfs.vfat You'll need to install dosfstools package (sudo apt-get install dosfstools)
+ in order to (find and) run rsync You'll need to install rsync package (sudo apt-get install rsync)

As said it's obvious for skilled people, but may still be useful for those who aren't.

Leonardo

Quote from: otolizz on October 08, 2014, 05:53:36 PM
Hi,

I tried to install debian release 8 on the nand, but it freeze on the boot screen...
Anyone to help??

Thx.

Hi! I have the same problem, may some .ini file need a fix?

Leo

AzHofi

Hi,
I followed this tutorial, my debian works well. I filled the rootfs with stuff to about 90% capacity, and suddenly my new files started to fill wit FFs. For example if I compile a program, works well, but after a reboot (or maybe enough to clear the linux file caches - i dont know how to do this) my files are unusable, they contain only FF bytes.
Did someone experienced same issue?
Could someone test this on an a20 som?
Thanks in advance.

AzHofi

Can happen if the partitioning schema points over the physical boundaries of the nand and linux tries to write over the end of the available space? How can I test it?

Leonardo

Hello, i think the onboard NAND flash is interesting with a UBIFS formatted root partition on it. I tried to compile the u-boot taken from the lichee-dev-a20 branch and manually install it to /dev/nanda vfat partition with the kernel of Debian release 8 and it doesn't work. i could keep trying but from a working branch, anyone tried the rgwan/linux-sunxi and rgwan/u-boot-sunxi branches? As stated here https://linux-sunxi.org/NAND they should be the unstable version of kernel and u-boot with MTD-driver support.

Leo

edualfaia

Hi Guys,
I've installed Debian on NAND, but I have a sata hdd with Debian too, How could I booting from NAND and mount rootfs from hdd?

Thanks guys