September 20, 2019, 04:25:12 pm

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


Using the NAND - how to install to it.

Started by lawrence, February 03, 2013, 02:12:27 pm

Previous topic - Next topic

lawrence

February 03, 2013, 02:12:27 pm Last Edit: February 03, 2013, 09:22:31 pm by lawrence
The shipped boards have Android on them.

Lots of people have asked about wiping that off, and sticking Linux on.
This can be done, although currently its a bit hacky, as we re-use the current boot partition for our own nefarious needs, as we don't have access to the boot0/boot1 stuff just yet on raw filesystem, as the NAND filesystem abstracts that away from us.

So, with that caveat, what can you do.

NAND has:

/dev/nanda
With bootable bits.

/dev/nandb ... nandg - Android partitions.


What pre-req's do you need.

1) A working bootable SD card.
2) sunxi tools.
3) A ttl -> rs232 or USB cable.

I'll assume you have a bootable SD card, so lets start.

boot off that.

#get the sunxi-tools and compile up
cd /home
git clone git://github.com/linux-sunxi/sunxi-tools
cd sunxi-tools

#get usb library if not installed, and compile.
apt-get install libusb-1.0-0-dev
make clean
make


Now we have a working nand-part we can use to repartition our NAND.

Lets nuke it


nand_part /dev/nand 'linux 8000000'


reboot (with the SD card in)

Now, we should have only 2 partitions on the NAND

/dev/nanda - the current bootloader
/dev/nandb - denada

Lets change that and format /dev/nandb to ext4

mkfs.ext4 /dev/nandb


Next up, lets mount /dev/nanda and copy our bits and bobs on there.

#Mount the nand boot
mkdir /mnt/nanda
mount /dev/nanda /mnt/nanda

#Mount our SD boot
mkdir /mnt/boot
mount /dev/mmcblk0p1 /mnt/boot

#Go to NAND boot linux folder
cd /mnt/nanda/linux
#backup current kernel. _just_in_case_  If you don't have one, don't worry.
mv uImage uImage.orig
#copy SD kernel here
cp /mnt/boot/uImage .

#We now need to stick a working uBoot here that gets chainloaded from the boot.axf
# First backup the old uboot
mv u-boot.bin u-boot.bin.orig
#get a working nand uboot off here
axel http://dl.cubieforums.com/loz/boot_partition/bootloader/cubie_nand_uboot_image.bin
mv cubie_nand_uboot_image.bin u-boot.bin


#rename script.bin and replace with one from SD, as its correct for ours.
cd /mnt/nanda
mv script.bin script.bin.orig
cp /mnt/boot/script.bin

cd /
umount /mnt/nanda
umount /mnt/boot
sync



Reboot. (with SD unplugged)

You should get a kernel bootup and it should crash at no init.

If so, GOOD.

Power off, plug in the SD again.
Power up.
Boot..

Now we need to stick a working FS on /dev/nandb

mkdir /mnt/nandb
mount /dev/nandb /mnt/nandb


You can grab one from debian or dl.cubieboard.com, or reuse your current one.

Blat that over /mnt/nandb and you're good!





lawrence

February 03, 2013, 02:30:25 pm #1 Last Edit: February 03, 2013, 09:06:38 pm by lawrence
Proof -

HELLO! BOOT0 is starting!
boot0 version : 1.5.1
dram size =1024
Succeed in opening nand flash.
Succeed in reading Boot1 file head.
The size of Boot1 is 0x0003c000.
The file stored in 0X00000000 of block 2 is perfect.
Check is correct.
Ready to disable icache.
Succeed in loading Boot1.
Jump to Boot1.
[       0.133] boot1 version : 1.4.0
[       0.133] pmu type = 3
[       0.134] bat vol = 0
[       0.161] axi:ahb:apb=3:2:2
[       0.161] set dcdc2=1400, clock=1008 successed
[       0.163] key
[       0.175] no key found
[       0.175] flash init start
[       2.796] flash init finish
[       2.797] fs init ok
[       2.798] fattype FAT16
[       2.798] fs mount ok
[       2.807] script finish
[       2.808] power finish
[       2.816] BootMain start
[       2.816] 0
[       2.834] key value = 0
[       2.834] recovery key high 6, low 4
[       2.835] unable to find fastboot_key key_max value
[       2.842] test for multi os boot with display
[       2.845] show pic finish
[       2.847] load kernel start
[       2.868] load kernel successed
[       2.868] start address = 0x4a0000

U-Boot 2011.09-rc1-00000-g40b4fba-dirty (Oct 12 2012 - 00:23:19) Allwinner Technology

CPU:   SUNXI Family
Board: A10-EVB
DRAM:  512 MiB
NAND:  3896 MiB
Using default environment

In:    serial
Out:   serial
Err:   serial
--------fastboot partitions--------
-total partitions:2-
-name-        -start-       -size-
bootloader  : 1000000       1000000
linux       : 2000000       f4240000
-----------------------------------
no misc partition is found
Hit any key to stop autoboot:  0
reading linux/env.txt

** Unable to read "linux/env.txt" from nand 0:1 **
## Warning: defaulting to text format
reading linux/uImage

4147616 bytes read
## Booting kernel from Legacy Image at 42000000 ...
   Image Name:   Linux-3.4.24
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4147552 Bytes = 4 MiB
   Load Address: 40008000
   Entry Point:  40008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

<6>Booting Linux on physical CPU 0
<6>Initializing cgroup subsys cpuset
<5>Linux version 3.4.24 (amery@builder) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #13 PREEMPT Mon Jan 28 16:36:23 UTC 2013
CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: sun4i
<6>Memory cut off:
<6>     MALI : 0x5c000000 - 0x5fffffff  (  64 MB)
<4>Ignoring unrecognised tag 0x00000000
<6>Memory Reserved:
<6>     SYS  : 0x43000000 - 0x4300ffff  (  64 kB)
<6>     VE   : 0x44000000 - 0x48ffffff  (  80 MB)
<6>     G2D  : 0x58000000 - 0x58ffffff  (  16 MB)
<6>     LCD  : 0x5a000000 - 0x5bffffff  (  32 MB)
Memory policy: ECC disabled, Data cache writeback
<6>chip-id: A10 (AW1623 revision C)
<7>On node 0 totalpages: 114688
<7>free_area_init_node: node 0, pgdat c07e4750, node_mem_map c09a2000
<7>  Normal zone: 896 pages used for memmap
<7>  Normal zone: 0 pages reserved
<7>  Normal zone: 113792 pages, LIFO batch:31
<7>pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768<c>
<7>pcpu-alloc: <c>[0] <c>0 <c>
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113792
<5>Kernel command line: console=ttyS0,115200 root=/dev/nandb init=/init loglevel=8
<6>PID hash table entries: 2048 (order: 1, 8192 bytes)
<6>Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
<6>Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
...


mount
/dev/root on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=156860k,nr_inodes=39215,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=31392k,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=62780k)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
root@arm:~# fdisk -l

Disk /dev/nand: 4085 MB, 4085252096 bytes
255 heads, 63 sectors/track, 496 cylinders, total 7979008 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/nand doesn't contain a valid partition table

Disk /dev/nanda: 16 MB, 16777216 bytes
255 heads, 63 sectors/track, 2 cylinders, total 32768 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

     Device Boot      Start         End      Blocks   Id  System

Disk /dev/nandb: 4051 MB, 4051697664 bytes
255 heads, 63 sectors/track, 492 cylinders, total 7913472 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/nandb doesn't contain a valid partition table



Notes.

The uBoot used has the incorrect RAM size.  We need to compile a 1G version.
Will get to that tomorrow probably..  Does work though (for now).



patwood

Here's the 1G version; only change is:

-#define PHYS_SDRAM_1_SIZE                      (512 << 20)                         
+#define PHYS_SDRAM_1_SIZE                      (1024 << 20)             

Had problems uploading to this board, so you can get it at https://sites.google.com/site/patandlesliewood/mk802 (u-boot.bin.gz).

lawrence

February 03, 2013, 09:07:50 pm #3 Last Edit: February 03, 2013, 09:46:49 pm by lawrence
Thanks.

Got one off of TheSeven via IRC (as I was sleeping, and he did that part, so I could enjoy my 4 hours of sleep a day)  :o

Used yours, and amended the instructions.

ikeeki

Hi, me again.
When you say "I assume you have a booteable sd card" you mean that a working (on the cubieboard) linux operating system is already flashed on the sd card like, for example, lubuntu and that sd card is plugged on the cubie, not the pc, correct?

So, all these steps must be followed AFTER you already have the operating system on sd card, isn't it?

So the pre-req "A ttl -> rs232 or USB cable" is just for give the cubieboard power, 'cause neither of the steps in this precise topic are to be followed on a PC. No?

So I need a hdmi cable, a keyboard and a maybe a mouse, so I can see my linux on the cubieboard on my HDMI screen, and I can work with it, correct ?

I work with linux everyday, and I have followed many other tutorials on how to install linux on wii, how to use linux to make partitions on multimedia hard drives, or how to install red hat on ps3, but these steps are very strange to me. Be patient, please.

patwood

Quote from: ikeeki on April 13, 2013, 06:22:45 am
Hi, me again.
When you say "I assume you have a booteable sd card" you mean that a working (on the cubieboard) linux operating system is already flashed on the sd card like, for example, lubuntu and that sd card is plugged on the cubie, not the pc, correct?

Boot able on the cubie.
Quote

So, all these steps must be followed AFTER you already have the operating system on sd card, isn't it?

Yes.
Quote
So the pre-req "A ttl -> rs232 or USB cable" is just for give the cubieboard power, 'cause neither of the steps in this precise topic are to be followed on a PC. No?

No.  You don't need the rs232 cable if you can log in some other way.  HOWEVER if you do anything wrong, you probably won't be able to diagnose it without a serial cable.
Quote

So I need a hdmi cable, a keyboard and a maybe a mouse, so I can see my linux on the cubieboard on my HDMI screen, and I can work with it, correct ?

Yes.



ikeeki


T3X

Howdy,

I used this :
#get the sunxi-tools and compile up
cd /home
git clone git://github.com/linux-sunxi/sunxi-tools
cd sunxi-tools

#get usb library if not installed, and compile.
apt-get install libusb-1.0-0-dev
make clean
make


And after i say to do nand_part /dev/nand 'linux 8000000', it says command not found...
What did i do wrong?

In the dir of sunxi-tools there is a nand-part, nand-part.c and nand-part.h all with the minus and not the underscore...

Andries

T3X

It's working, stupid me ???
Forgot to chmod +x .....mmm mmm m
Now i can go on.


QUBY1

T3X

what files did you chmod?  i still get nand_part command not found.

patwood

Quote from: QUBY1 on August 19, 2013, 09:50:22 pm
T3X

what files did you chmod?  i still get nand_part command not found.

Try

./nand-part

pancio

Hi,
Is the same procedure for CB2? In cubieez I have two partitions nand's:

# fdisk -l
Disk /dev/nand: 3959 MB, 3959422976 bytes
255 heads, 63 sectors/track, 481 cylinders, total 7733248 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/nand doesn't contain a valid partition table

Disk /dev/nand:: 2231 MB, 2231369728 bytes
255 heads, 63 sectors/track, 271 cylinders, total 4358144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000



Why I have two part 4GB and 2GB?

If I'll change/delete/format/whatever wrong nand partition... can I'll start system from SD?
Everything what you may do on RPi, you should do on Cubie!
Try: https://cubieboard.org.pl

patwood

Quote from: pancio on August 22, 2013, 05:26:55 pm
Hi,
Is the same procedure for CB2? In cubieez I have two partitions nand's:

# fdisk -l
Disk /dev/nand: 3959 MB, 3959422976 bytes
255 heads, 63 sectors/track, 481 cylinders, total 7733248 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/nand doesn't contain a valid partition table

Disk /dev/nand:: 2231 MB, 2231369728 bytes
255 heads, 63 sectors/track, 271 cylinders, total 4358144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000



Why I have two part 4GB and 2GB?

If I'll change/delete/format/whatever wrong nand partition... can I'll start system from SD?

Don't use fdisk on /dev/nand.  The partition table on /dev/nand is in a special allwinner format and cannot be used by fdisk.  That's probably why it's reporting weird data.  Read this: http://www.cubieforums.com/index.php/topic,597.msg3134.html#msg3134

pancio

August 23, 2013, 04:01:23 am #13 Last Edit: August 23, 2013, 06:51:44 am by pancio
Ok, my habit from Debian :-). I don't use fdisk to modify nand, only for read. This tutorial shows how to modify /dev/nanda and /dev/nandb. I have'nt it! My nand partitions:

root@cubieez:~# ls -al /dev/nan*
brw-rw---T 1 root disk 93,  0 sie 22 23:47 /dev/nand
brw-rw---T 1 root disk 93, 80 sie 22 23:47 /dev/nand:
brw-rw---T 1 root disk 93,  8 sie 22 23:47 /dev/nand1
brw-rw---T 1 root disk 93, 16 sie 22 23:47 /dev/nand2
brw-rw---T 1 root disk 93, 24 sie 22 23:47 /dev/nand3
brw-rw---T 1 root disk 93, 32 sie 22 23:47 /dev/nand4
brw-rw---T 1 root disk 93, 40 sie 22 23:47 /dev/nand5
brw-rw---T 1 root disk 93, 48 sie 22 23:47 /dev/nand6
brw-rw---T 1 root disk 93, 56 sie 22 23:47 /dev/nand7
brw-rw---T 1 root disk 93, 64 sie 22 23:47 /dev/nand8
brw-rw---T 1 root disk 93, 72 sie 22 23:47 /dev/nand9
root@cubieez:~#


How should I do make partition for CB2(A20)?




Everything what you may do on RPi, you should do on Cubie!
Try: https://cubieboard.org.pl

patwood

Quote from: pancio on August 23, 2013, 04:01:23 am
Ok, my habit from Debian :-). I don't use fdisk to modify nand, only for read. This tutorial shows how to modify /dev/nanda and /dev/nandb. I have'nt it! My nand partitions:

root@cubieez:~# ls -al /dev/nan*
brw-rw---T 1 root disk 93,  0 sie 22 23:47 /dev/nand
brw-rw---T 1 root disk 93, 80 sie 22 23:47 /dev/nand:
brw-rw---T 1 root disk 93,  8 sie 22 23:47 /dev/nand1
brw-rw---T 1 root disk 93, 16 sie 22 23:47 /dev/nand2
brw-rw---T 1 root disk 93, 24 sie 22 23:47 /dev/nand3
brw-rw---T 1 root disk 93, 32 sie 22 23:47 /dev/nand4
brw-rw---T 1 root disk 93, 40 sie 22 23:47 /dev/nand5
brw-rw---T 1 root disk 93, 48 sie 22 23:47 /dev/nand6
brw-rw---T 1 root disk 93, 56 sie 22 23:47 /dev/nand7
brw-rw---T 1 root disk 93, 64 sie 22 23:47 /dev/nand8
brw-rw---T 1 root disk 93, 72 sie 22 23:47 /dev/nand9
root@cubieez:~#


How should I do make partition for CB2(A20)?

Read this or search the forum for "nand-part".  Note that the A20 uses a different partition format from the A10:

http://www.cubieforums.com/index.php/topic,511.0.html