u-boot A20 NAND capable

1,443 views
Skip to first unread message

sophi...@gmail.com

unread,
Jul 14, 2013, 12:40:08 PM7/14/13
to linux...@googlegroups.com
Hi All,

I'm looking for u-boot which supports A20 on NAND.


without success

The logging message is

HELLO! BOOT0 is starting!
boot0 version : 2.0.0�
read dram para.
dram driver version: 1.14
dram size =1024MB
0x00022822
super_standby_flag = 0
Succeed in opening nand flash.
block from 2 to 6
deal block 2
Succeed in reading Boot1 file head.
The size of Boot1 is 0x00068000.
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.145] boot1 version : 2.0.0
[       0.154] script installed early ok
[       0.154] pmu type = 3
[       0.156] bat vol = 0 mv
[       0.172] axi:ahb:apb=4:2:2
[       0.172] set dcdc2=1400mv, clock=912M successed
[       0.174] key
[       0.186] no key found
[       0.186] flash init start
[       0.186] NB1 : enter NFB_Init
[       0.189] NB1 : enter phy init
[       0.192] [NAND] nand driver(b) version: 0x0x00000002, 0x0x00000012, data: 0x20130325
[       0.202] get the good blk ratio from hwscan : 944
[       0.205] NB1 : nand phy init ok
[       4.111] _RepairLogBlkTbl start
[       4.115] Log Block Index 0x00000000, LogicBlockNum: 0x000000b9, LogBlockType: 0x00000000
[       4.117] log0: 0x0000007b, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.124] datablock: 0x00000098, lastusedpage: 0x00000004
[       4.132] Log Block Index 0x00000001, LogicBlockNum: 0x000000c8, LogBlockType: 0x00000000
[       4.138] log0: 0x000000b0, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.145] datablock: 0x0000001a, lastusedpage: 0x00000079
[       4.153] Log Block Index 0x00000002, LogicBlockNum: 0x00000013, LogBlockType: 0x00000000
[       4.159] log0: 0x000000bd, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.165] datablock: 0x000000d8, lastusedpage: 0x00000033
[       4.175] Log Block Index 0x00000003, LogicBlockNum: 0x000000c3, LogBlockType: 0x00000000
[       4.179] log0: 0x0000008d, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.186] datablock: 0x000000e3, lastusedpage: 0x00000001
[       4.195] Log Block Index 0x00000004, LogicBlockNum: 0x000000dc, LogBlockType: 0x00000000
[       4.200] log0: 0x000000e2, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.207] datablock: 0x000003b6, lastusedpage: 0x00000001
[       4.216] Log Block Index 0x00000005, LogicBlockNum: 0x000000c4, LogBlockType: 0x00000000
[       4.221] log0: 0x0000008a, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.227] datablock: 0x0000074b, lastusedpage: 0x00000001
[       4.236] Log Block Index 0x00000006, LogicBlockNum: 0x000000df, LogBlockType: 0x00000000
[       4.241] log0: 0x000000cd, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.248] datablock: 0x0000074d, lastusedpage: 0x00000077
[       4.256] Log Block Index 0x00000007, LogicBlockNum: 0x000000c0, LogBlockType: 0x00000000
[       4.262] log0: 0x000000c4, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.268] datablock: 0x00000762, lastusedpage: 0x00000046
[       4.278] Log Block Index 0x00000008, LogicBlockNum: 0x00000007, LogBlockType: 0x00000000
[       4.282] log0: 0x00000774, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.289] datablock: 0x0000008c, lastusedpage: 0x00000003
[       4.297] Log Block Index 0x00000009, LogicBlockNum: 0x00000008, LogBlockType: 0x00000000
[       4.303] log0: 0x000000b4, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.310] datablock: 0x0000077d, lastusedpage: 0x00000075
[       4.319] Log Block Index 0x0000000a, LogicBlockNum: 0x00000010, LogBlockType: 0x00000000
[       4.324] log0: 0x000000bb, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.330] datablock: 0x0000077e, lastusedpage: 0x00000001
[       4.339] Log Block Index 0x0000000b, LogicBlockNum: 0x000000c2, LogBlockType: 0x00000000
[       4.344] log0: 0x000007b0, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.351] datablock: 0x000000c5, lastusedpage: 0x00000002

[       4.537] datablock: 0x00000765, lastusedpage: 0x00000001
[       4.546] Log Block Index 0x00000005, LogicBlockNum: 0x00000042, LogBlockType: 0x00000000
[       4.551] log0: 0x00000766, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.557] datablock: 0x000003d5, lastusedpage: 0x00000009
[       4.566] Log Block Index 0x00000006, LogicBlockNum: 0x00000033, LogBlockType: 0x00000000
[       4.571] log0: 0x0000076a, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.578] datablock: 0x000003c6, lastusedpage: 0x0000001d
[       4.587] Log Block Index 0x00000007, LogicBlockNum: 0x00000076, LogBlockType: 0x00000000
[       4.592] log0: 0x00000776, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.598] datablock: 0x0000077b, lastusedpage: 0x00000007
[       4.607] Log Block Index 0x00000008, LogicBlockNum: 0x00000032, LogBlockType: 0x00000000
[       4.612] log0: 0x00000786, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.619] datablock: 0x00000761, lastusedpage: 0x0000003c
[       4.627] Log Block Index 0x00000009, LogicBlockNum: 0x00000080, LogBlockType: 0x00000000
[       4.633] log0: 0x0000079e, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.640] datablock: 0x0000079a, lastusedpage: 0x00000072
[       4.649] Log Block Index 0x0000000a, LogicBlockNum: 0x00000075, LogBlockType: 0x00000000
[       4.654] log0: 0x0000079c, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.660] datablock: 0x000007aa, lastusedpage: 0x00000004
[       4.670] Log Block Index 0x0000000b, LogicBlockNum: 0x0000007d, LogBlockType: 0x00000000
[       4.674] log0: 0x000007c2, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.681] datablock: 0x0000075d, lastusedpage: 0x00000001
[       4.690] Log Block Index 0x0000000c, LogicBlockNum: 0x00000073, LogBlockType: 0x00000000
[       4.695] log0: 0x000007ca, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.702] datablock: 0x000007ce, lastusedpage: 0x0000000a
[       4.711] Log Block Index 0x0000000d, LogicBlockNum: 0x000002f2, LogBlockType: 0x00000000
[       4.716] log0: 0x000007f2, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.722] datablock: 0x00000685, lastusedpage: 0x00000005
[       4.731] Log Block Index 0x0000000e, LogicBlockNum: 0x00000272, LogBlockType: 0x00000000
[       4.736] log0: 0x000007f6, Log1: 0x0000ffff, WriteIndex: 0x00000000
[       4.743] datablock: 0x00000605, lastusedpage: 0x00000005
[       4.748] _RepairLogBlkTbl end
[       4.906] get mbr error
[       4.906] NB1 : init ok
[       4.906] flash init finish
[       4.933] fs init fail
[       4.933] fs init fail, jump to fel

Patrick Wood

unread,
Jul 14, 2013, 12:57:07 PM7/14/13
to linux...@googlegroups.com
Those are both A10 uboots; since the nand MBR headers changed on the A20, they won't work (even if there weren't a whole bunch of other A20 things that won't work with them).

Henrik Nordström

unread,
Jul 14, 2013, 2:07:39 PM7/14/13
to linux...@googlegroups.com
sön 2013-07-14 klockan 09:57 -0700 skrev Patrick Wood:
> Those are both A10 uboots; since the nand MBR headers changed on the
> A20, they won't work (even if there weren't a whole bunch of other A20
> things that won't work with them).


I do have slightly cleaned up alwinner/lichee A20 u-boot sources with
nand-driver here:

https://github.com/hno/u-boot/tree/lichee-dev-a20

It's not yet tested beyond compiling and is why it's not pushed to
linux-sunxi u-boot repository.

The exact version of u-boot used in the cubieboard2 images should be
found somewhere in the cubieboard repos I hope. If not complain to
cubeboard and ask them to push out the u-boot sources used in their
images.

Regards
Henrik

Henrik Nordström

unread,
Jul 14, 2013, 2:16:10 PM7/14/13
to linux...@googlegroups.com, sup...@cubietech.com
A quick scan of the cubieboard2 repos show only an u-boot binary in the
tools repository, no sign of u-boot sources.

Cubietech, please correct this omission in the Cubieboard2 source
repositories.

Regards
Henrik

Tom Cubie

unread,
Jul 14, 2013, 11:22:30 PM7/14/13
to linux...@googlegroups.com, support

We are asking Allwinner's permission to put it publicly.

>
> Regards
> Henrik
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Patrick Wood

unread,
Jul 15, 2013, 10:04:50 AM7/15/13
to linux...@googlegroups.com
I built this and it boots the c2 linaro nand install (with the kernel/initrd on a raw partition a la android) just fine. Pulls the dram config from the script.bin file... Not a bad feature, actually, but not compatible with other uboots.

Patrick Wood

unread,
Jul 16, 2013, 12:00:47 AM7/16/13
to linux...@googlegroups.com
I've uploaded a u-boot.bin that allows booting standard A20 kernel builds (uImage) from NAND here: http://dl.cubieforums.com/patwood/uboot-nand-a20.tar.gz]http://dl.cubieforums.com/patwood/uboot-nand-a20.tar.gz.

This file contains a compiled u-boot.bin and the patches I used on Henrik's git repository (URL: https://github.com/hno/u-boot, branch: lichee-dev-a20, commit: bcea3de6672241ad1fb21d8921722572569854dc) and a sample uEnv.txt.

This u-boot.bin understands the following env settings from uEnv.txt:

kernel=your-kernel-name                (ex: uImage, default: none)
root=your-root-partition-name          (ex: /dev/nand4, default: none)
console=some-device                    (ex: /dev/tty0, default: ttyS0,115200)
loglevel=log-level                           (ex: 4, default: 8)
extraargs=other arguments             (ex: init=/init, default: none)

This build of u-boot does *not* support env setting via boot.scr; you must use uEnv.txt, and you must set the kernel and root env values in uEnv.txt to get the kernel to boot.

The default boot setup in the linaro NAND install requires you to put u-boot.bin in the <nand1-partition/linux directory.

Important note: the A20 boot1 code requires you to have a "boot" partition with an Android-style kernel+initrd (or at least the proper magic numbers at the start of the partition).  Don't get rid of the partition named "boot" if you use nand-part-A20 to change your partition layout.

Many thanks to Henrik Nordstrom for putting this up.

Patrick Wood

unread,
Jul 17, 2013, 1:01:35 AM7/17/13
to linux...@googlegroups.com
Just a quick FYI on the A20 BOOT1: it is looking for an Android boot partition with the "ANDROID!" magic header and the address/size combo in the next 8 bytes. I was unable to get it to proceed without having at least a small partition named "boot" with "ANDRIOD!\0\0\0\0\0\0\0\0" in the first 16 bytes; the rest of the boot partition is ignored.  Making the partition smaller than 4096 blocks (2M) produces warnings from BOOT1, but everything proceeds to boot just fine anyway.

This appears to be just some sort of annoying Allwinner (in)sanity check that wasn't in the A10's boot code.


On Monday, July 15, 2013 10:04:50 AM UTC-4, Patrick Wood wrote:

sophi...@gmail.com

unread,
Jul 17, 2013, 11:18:31 PM7/17/13
to linux...@googlegroups.com
I hate the unnecessary boot partition, is it possible we create a hidden partition?

Oliver Schinagl

unread,
Jul 18, 2013, 9:48:38 AM7/18/13
to linux...@googlegroups.com
On 18-07-13 05:18, sophi...@gmail.com wrote:
> I hate the unnecessary boot partition, is it possible we create a hidden
> partition?
I would think you can use any partition label you want, I doubt it
checks for that.

That said, you can't really hide a partition, I think hidden partition
types simple won't show up in some file managers if they honor that at all.

oliver
Message has been deleted

Patrick Wood

unread,
Jul 18, 2013, 10:12:32 AM7/18/13
to linux...@googlegroups.com
The partition doesn't need a Linux or dos label (it's an android boot partition, so it's not formatted). It does need an MBR label, so it's hidden from blkid, but not from fdisk, /dev/nandX or /proc/partitions.

Oliver Schinagl

unread,
Jul 18, 2013, 10:28:46 AM7/18/13
to linux...@googlegroups.com
On 18-07-13 16:08, Patrick Wood wrote:
> It does, in fact check the partition name from the MBR. I checked this before posting my FYI. Boot1 hangs if it can't find a partition specifically named 'boot'. Then it checks the first 8 bytes of that partition for the string 'ANDROID!' and the next 4 for a valid address (I get an error message and boot1 hangs if I put a random number in this field; zero is accepted though).
>
> I suggest you actually try this out like I did.
>
I ment to say partition TYPE of course, though I'm sure that that came
from the content. Yes many different terms to consue, partition label,
partition type, fs label, fs type etc etc.

No need to be so harsh for using a wrong term.

sophi...@gmail.com

unread,
Jul 18, 2013, 11:24:29 AM7/18/13
to linux...@googlegroups.com
Hi, Pat

Seems there is no chance let u-boot read the script.bin, Could you add it thanks.

Patrick Wood

unread,
Jul 18, 2013, 11:29:39 AM7/18/13
to linux...@googlegroups.com
Well, not fdisk, but nand-part....

Patrick Wood

unread,
Jul 18, 2013, 11:32:47 AM7/18/13
to linux...@googlegroups.com, olive...@schinagl.nl
Sorry about that; I did misunderstand what you meant.  Since we're not dealing with fdisk, the "type" that we think of with normal partition tables for other types of devices (e.g., 83 for linux) doesn't really apply.  There are some bits that hint at whether a partition should be mounted read-only, but most of the "type" meaning is gleaned from the partition name (e.g., "boot", "env", "system").

Patrick Wood

unread,
Jul 18, 2013, 11:33:47 AM7/18/13
to linux...@googlegroups.com
Do you mean boot.scr?  I believe script.bin is read by this u-boot.

Pat

sophi...@gmail.com

unread,
Jul 18, 2013, 12:04:21 PM7/18/13
to linux...@googlegroups.com
No, I mean script.bin, There is no sign the script.bin will be loaded. The output of pri is attached.

Hit any key to stop autoboot:  0
sun7i#pri
baudrate=115200
boot_fastboot=fastboot
boot_normal=fatload nand 0 42000000 ${kernel}; bootm 42000000
boot_recovery=sunxi_flash read 40007800 recovery;boota 40007800
bootcmd=run setargs_nand boot_normal
bootdelay=1
console=ttyS0,115200
init=/init
loglevel=8
mmc_root=/dev/mmcblk0p7
nand_root=/dev/system
partitions=bootloader@nanda:boot@nandb:linux@nandc
setargs_mmc=setenv bootargs console=${console} root=${mmc_root} init=${init} loglevel=${loglevel} partitions=${partitions}
setargs_nand=mw 41000000 0 10000; fatload nand 0 41000000 uEnv.txt; env import 41000000 10000; setenv bootargs console=${console} root=${root} loglevel=${loglevel} ${extraargs}
stderr=serial
stdin=serial
stdout=serial

Environment size: 730/131068 bytes

sophi...@gmail.com

unread,
Jul 18, 2013, 1:01:15 PM7/18/13
to linux...@googlegroups.com
Hi, Pat


It's almost perfect now, except the ext file system driver.
u-boot.bin.gz

Patrick Wood

unread,
Jul 18, 2013, 4:01:49 PM7/18/13
to linux...@googlegroups.com
Thanks.  It's a good idea to load it anyway, but it looks like boot.axf already does that for us:

sun7i#md 43000000
43000000: 00000050 00000000 00000001 00000002    P...............
43000010: 646f7270 00746375 00000000 00000000    product.........
43000020: 00000000 00000000 00000000 00000000    ................
43000030: 00000002 00000324 74616c70 6d726f66    ....$...platform
43000040: 00000000 00000000 00000000 00000000    ................
43000050: 00000000 00000000 00000001 00000338    ............8...
43000060: 67726174 00007465 00000000 00000000    target..........
43000070: 00000000 00000000 00000000 00000000    ................
43000080: 00000007 00000342 636f6c63 0000006b    ....B...clock...
43000090: 00000000 00000000 00000000 00000000    ................
430000a0: 00000000 00000000 00000005 00000388    ................
430000b0: 64726163 6f6f625f 00000074 00000000    card_boot.......
430000c0: 00000000 00000000 00000000 00000000    ................
430000d0: 00000002 000003ba 64726163 6f625f30    ........card0_bo
430000e0: 705f746f 00617261 00000000 00000000    ot_para.........
430000f0: 00000000 00000000 00000009 000003ce    ................

Henrik Nordström

unread,
Jul 30, 2013, 8:03:45 PM7/30/13
to linux...@googlegroups.com, support
mån 2013-07-15 klockan 11:22 +0800 skrev Tom Cubie:
> > A quick scan of the cubieboard2 repos show only an u-boot binary in
> the
> > tools repository, no sign of u-boot sources.
> >
> > Cubietech, please correct this omission in the Cubieboard2 source
> > repositories.
>
> We are asking Allwinner's permission to put it publicly.

Any answer?

Regards
Henrik

Matson Hall

unread,
Jul 30, 2013, 11:51:54 PM7/30/13
to linux...@googlegroups.com, support
hi, u-boot source code is contained at the android4.2 sdk. and the sdk is open. at lease we can get it at http://cubiebook.org/index.php?title=Cubieboard2/Building_your_own_Android_image


2013/7/31 Henrik Nordström <hen...@henriknordstrom.net>

Regards
Henrik

Henrik Nordström

unread,
Jul 31, 2013, 2:34:05 AM7/31/13
to linux...@googlegroups.com, support
ons 2013-07-31 klockan 11:51 +0800 skrev Matson Hall:
> hi, u-boot source code is contained at the android4.2 sdk. and the sdk
> is open. at lease we can get it at
> http://cubiebook.org/index.php?title=Cubieboard2/Building_your_own_Android_image

Thanks.

Regards
Henrik


hunter hu

unread,
May 28, 2014, 9:01:50 PM5/28/14
to linux...@googlegroups.com
Hi Patrick,

I am trying to follow this thread to boot from NAND for a20 Olimex Micro board.   I have built hno's lichee-dev sun7i u-boot.bin and follow sunxi wiki "Install to NAND", and I am only missing the ANDROID magic you mentioned here.

I tried to dd the 16 bytes magic to "boot" partition, which was trashed after that, so I went ahead to create "boot"(no format, only dd the 16 bytes),"bootloader"(vfat), and "root"(ext4), like the following

3 partitions
partition  1: class =         DISK, name =         boot, partition start =    32768, partition size =     2048 user_type=0
partition  2: class =         DISK, name =   bootloader, partition start =    34816, partition size =    32768 user_type=0
partition  3: class =         DISK, name =         root, partition start =    67584, partition size =  3864576 user_type=0

 boot1 complains:

[       1.444] can't find c:\boot.axf

I feel like I am almost there, just missing something on the magic and partitions stuff.

Where did I do wrong? do you have any more detailed instructions available somewhere?

Thanks in advance,
-Hunter

hunter hu

unread,
May 29, 2014, 12:18:47 PM5/29/14
to linux...@googlegroups.com
OK, getting progress, according to original Android NAND partitions layout, bootloader partition comes before boot partition,so I went ahead to redo the partition again and put bootloader first and boot after it, it works, boot1 loads correctly and all the way up to u-boot.bin and kernel.

Great, A20 NAND boot works. Thanks for all the information in this thread.

Cheers,
-Hunter
Reply all
Reply to author
Forward
0 new messages