[Arm-netbook] Flashing the NAND

luke.leighton luke.leighton at gmail.com
Thu Dec 5 23:04:45 GMT 2013


hi marco, welcome to the list, and thanks for agreeing to post these
questions publicly so that others can help answer them, and more can
benefit from everyone's replies.

On Thu, Dec 5, 2013 at 10:35 PM, Marco Martin <notmart at gmail.com> wrote:
> Hi all,
> I have an A20 based eoma68 card.
> I have now an image based on the Mer distribution that can boot and runs fine
> from the microSD card (following http://rhombus-tech.net/allwinner/a20/boot/
> and http://www.gplsquared.com/eoma_boot/eoma_boot.html)
>
> but the next necessary step is to flash a booting image to the internal NAND
> of the eoma68 (and in the end make an image that can be installed by default
> from the factory).

 ok.  right.  this was last discussed.... over 4-5 months ago, here on
arm-netbooks, so i'm a little rusty as it's not in my immediate
short-term memory.

> I understand there have been some progress (I see drivers for it in
> https://github.com/linux-sunxi/linux-sunxi/tree/wip/linux-sunxi-3.4/cubieboard/drivers/block/sunxi_nand but nothing that looks like it
> shows up in /dev?)

 ok - the cubieboard2 3.4 kernel which you can likely find here:
https://github.com/cubieboard2/linux-sunxi/tree/sunxi-3.4-cb2-dev
 or i *may* have a copy here: http://git.rhombus-tech.net/?p=linux.git
- i believe almost certainly has libnand committed.

 https://github.com/cubieboard2/linux-sunxi/tree/sunxi-3.4-cb2-dev/drivers/block/sun7i_nand

 yep, there you go.  that's what i recall using [over 4 months ago]
and i remember it working correctly.


> I was wondering what is the procedure for it? did anybody managed to obtain a
> booting linux distribution from the nand? (seems a proprietary windows
> application is needed for the flashing?)

 the key critical procedure behind that proprietary tool - the fel
booting - has long since been reverse-engineered and put into u-boot.

 what *hasn't* yet been done is what allwinner did, which was to set
up a small short non-OS-based "boot" system (which they split into two
halves, boot0 and boot1, alongside some "apps" which go onto a
DOS-formatted partition: these "apps" can be loaded at startup time by
pressing keys - 1, 2 etc. etc).  it's all horribly complicated yet
amazingly the source code is actually available, it was accidentally
included in the last allwinner-a20 3.3 SDK code-drop.  they also
compiled up u-boot with libnand attached to it, so that it could load
the linux kernel from NAND.

 so there are several pieces to the puzzle:

 1) boot0 and boot1.  the GPL-compliant source for this has been
tracked down.  it should be easy to find, let me know if you have any
difficulties.

 2) libnand-aware u-boot released by allwinner  this, again, should be
easy to find, on hno's github u-boot repo and in several other places.
 *quick search*... https://github.com/linux-sunxi/u-boot-sunxi/wiki  -
ah, there you go - lichee-a20-dev branch.  that'll do.

 3) libnand-aware sunxi 3.4 kernel.  see above: that's at least one
version that i know of which works (and i've tested on EOMA68-A20 CPU
Cards).

 4) allwinner's nand tools (equivalent to mtd-tools).
https://github.com/linux-sunxi/sunxi-tools - you want nand-part.  i
recommend compiling this up natively (boot over fel or SD) - why waste
time cross-compiling? you have a perfectly good OS and a fast enough
processor with plenty of RAM!

 once you have all those pieces you can then bootstrap up from:

 a) a FEL boot
 b) to a MicroSD card
 c) use nand-part to create partitions
 d) write boot0 and boot1 directly to the 1st NAND partition (with dd)
 e) check it works (press 1 or 2 etc. etc.)
 f) repeat until success.
 g) put u-boot on as well
 h) repeat until success
 i) put OS files (linux kernel etc.) on the other NAND partitions
 j) repeat until success

 at any point along this path, there is absolutely nothing to be
concerned about if you screw up: you can always go back to FEL boot.
so the whole system is basically "unbrickable".

i'd recommend using the proprietary GPL-violating versions of (d) and
(g) first, in order to minimise the number of unknowns.  in fact, what
i'd recommend is that if you happen to already have android on the
EOMA68-A20 card, to fire it up with adb (apt-get install
android-tools) then take a copy of the entire /dev/system/nanda
partition and anything else you can find (nandb for example), then
play with that.

 the alternative would be to hack the sunxi version of u-boot's SPL
loader, to link in with libnand.  what that would give you would be a
free-software community alternative to boot0/boot1.  given that the
lichee-a20-dev version of u-boot already has libnand support this
should not be too hard to achieve: the only thing to watch out for
though is the extremely limited amount of space available for that
first boot phase.

 does anyone else have any other recommendations or strategies? henrik
i know you've wanted to have proper sunxi nand support in u-boot for
some time.

l.



More information about the arm-netbook mailing list