December 08, 2019, 06:25:57 pm

News:

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


Nuking the NAND with a premade image.

Started by lawrence, February 03, 2013, 09:55:57 pm

Previous topic - Next topic

lawrence

February 03, 2013, 09:55:57 pm Last Edit: February 17, 2013, 09:50:10 pm by lawrence
This is different to the previous post, in that its premade, and ready to go.
Image created  by theSeven from IRC.


If you want to make your own uboot, he has a repo with a NAND capable uBoot here -
https://github.com/TheSeven/u-boot-sunxi/



This *will* nuke your nand completely, and make 2 partitions.

/dev/nanda - uboot files
/dev/nandb - kernel + rootfs (stick your uImage in /boot/uImage in the /dev/nandb partition)

Its empty except for the files needed to boot (so you need to add a kernel and rootfs)

---

You'll need a working SD card.

Boot off of SD.

Grab the nand partition image, and write to nand flash.
axel http://dl.cubieforums.com/loz/boot_partition/bootloader/cubie_nand_uboot_partition_image.bin
dd if=cubie_nand_uboot_partition_image.bin of=/dev/nand
sync


wait about a minute just in case nand hasn't finished writing yet.
reboot (with SD still in)

#format the nandb partition as ext4
mkfs.ext4 /dev/nandb
mount /dev/nandb /mnt
mkdir /tmp/boot
mount /dev/mmc0blk1 /tmp/boot

#make a boot folder on our nandb
mkdir /mnt/boot
cp /tmp/boot/uImage /mnt/boot/uImage


Copy over a rootfs also to /mnt
(not documented, I can make a separate doc if necessary)

umount /mnt
umount /tmp/boot
sync

wait 30 seconds just in case.
reboot, eject nand, and you should have a working NAND booting.


Say thank you to TheSeven now :)

patwood

February 04, 2013, 12:55:12 am #1 Last Edit: February 04, 2013, 03:20:50 pm by patwood
After mount /dev/nandb, just do a

cp -r {everything but /dev /proc /mnt and /sys} /mnt

to copy the current linux system on SD over to nand, where {everything but /dev /proc /mnt and /sys} should be replaced by everything in / but those directories (do "ls /" to see what "everything" is).

Update: you should create empty directories for /dev, /proc, /mnt, and /sys so the kernel can mount to them when it starts up. 

Personally, I prefer to use rsync, which lets me specify an exclude file with --exclude-from=FILE.  Here's what I put in mine:

/dev/*
/proc/*
/sys/*
/media/*
/mnt/*
/run/*
/tmp/*


This creates the top-level directories, but doesn't copy over the contents.

patwood

I see this guy merged the Allwinner nand drivers from the lychee u-boot into the mainline (well, his fork).  Very nice.  Which allows u-boot to load the uImage kernel from the ext4 partition's /boot directory more like grub does.  Even nicer.

If you know this guy, give him a high five from me!

nightflier

Success on installing Debian to nand on my Cubieboard.  ;D

Took me a couple of tries, not quite sure if I did something wrong when writing /dev/nand using dd from within the system, but it started working after scp'ing the image over from another Linux box as outlined here: http://linux-sunxi.org/Cubieboard/Installing_on_NAND

Question: I'm running Roman's server image. In /boot, in addition to uImage, there is a vmlinuz image and corresponding config and System.map files. I'm confused about how this works. Is uImage the kernel used, or is it vmlinuz? Or are both files in use?

holdfun

Hi, I bought a CubieBoard several days ago and boot it successfully to shell from uSD card by following the link http://linux-sunxi.org/Building_on_Debian.  After I downloaded a 3.7G+ premake image, I found a problem before writing the image to internal NAND.

---------------------
root@A10:~# fdisk -l /dev/nand

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          // No partition table
---------------------

Could I write the premade image as this?
- Ignore the "no partion table" message and setup my partition tables by fdisk
        a) fdisk /dev/nand
        b) in fdisk command, create primary partions at first sector starting at 2048 (this offset is big enough for the bootloader in NAND untoughed, right?)
        c) write the partion table to NAND (I need only one partition table currently)
- format the new created partition
        mkfs.ext2 /dev/nanda         // format the 4G partition to ext2 (does bootloader in NAND support ext2?)
- write the premade image to that partition
        dd if=/mnt/remote/xxx-4G.img of=/dev/nanda
- remove uSD card and reboot CubieBoard
- will CubieBoad boot from the OS of xxx-4G.img?


Another two questions:
- If I broke the bootloader in NAND, could I recover it via TTL_USB(USB-to-serial)? I know some chips has this functionality but I couldn't find any swith on CubieBoard. Could the software win32diskimager recover a broken bootloader in NAND? If there is some recovery method, I will try bravely.
- Are there any resources about how to build a compiling system on the CubieBoard? The method provided in http://linux-sunxi.org/Building_on_Debian(setup debian apt-get environment for arm) can't fulfill my requirement, because the arm apt-get sources miss many important packages to build up a compiling environment. I have a 2.5' SATA disk, so if I can build many packages from source code in my SATA disk connected to CubieBoard, that will be wonderful!

Thank you.

patwood

The nand device isn't partitioned via fdisk.  You need to use nand-part and read the other posts on flashing the nand.  Also, look at the posts on this topic on the miniand forums.

If you break the boot loader on nand, just boot from the usd card and try again.  The cubie's boot sequence loads from micro SD before nand.

I have had no problems setting up a build system using arm Ubuntu distributions on the cubie.

blades

Quote from: patwood on February 04, 2013, 12:55:12 am
After mount /dev/nandb, just do a

cp -r {everything but /dev /proc /mnt and /sys} /mnt

to copy the current linux system on SD over to nand, where {everything but /dev /proc /mnt and /sys} should be replaced by everything in / but those directories (do "ls /" to see what "everything" is).

Update: you should create empty directories for /dev, /proc, /mnt, and /sys so the kernel can mount to them when it starts up. 

Personally, I prefer to use rsync, which lets me specify an exclude file with --exclude-from=FILE.  Here's what I put in mine:

/dev/*
/proc/*
/sys/*
/media/*
/mnt/*
/run/*
/tmp/*


This creates the top-level directories, but doesn't copy over the contents.
nice instructions, I managed to write to NAND


darth_llamah

Can I ask what was modified/removed from nanda? Or is a dump of original contents available (as I don't have a backup)?

I'm working on running Cubieez on Pentagram Tab 8.4 (clone of Onda vi30v- 1Ghz A10, 1GB ram, 4GB flash), system is already in nand, boots fine.
Problem- shutting down the system (either from gui or "sudo poweroff") results in reboot. I'm quite sure it's related to battery charging by bootloader- Lubuntu (Livesuit image for cubieboard1) doesn't have this problem.

tuxedomasc

any idea, whether this will also work for Cubietruck?

darth_llamah

December 13, 2013, 02:38:37 am #10 Last Edit: December 13, 2013, 07:59:24 am by darth_llamah
Quote from: tuxedomasc on December 12, 2013, 10:15:14 pm
any idea, whether this will also work for Cubietruck?

No- image is made for cubiebaord 1/a10 devices.

EDIT:
Got nanda files and system running of nand, shutdown works fine :)

Hopefully usefull update about boot behaviour:
Case: battery is connected to the PMIC (tablet hardware, possibly also Olimex a10/a20 boards with LiPo connectors)
Behaviuor after dd-ing premade image to the nand- system boots and works fine but shutdown is impossible- system reboots; no splashscreen displayed
Behaviour when using default files nanda contents with linux/u-boot.bin replaced with nand capable one (grabbed from minimal image)- system boots fine from nand with kernel is in nandb/boot/, shutdown works fine; splashscreen and battery loading animation are displayed

It seems that boot.axf or BROM changes behaviour when battery is detected- it looks for drv_de.drv in nanda (not present in the minimal image),if file is not present- launches u-boot.bin (or boot.axf if BROM is involved) which results in booting the system.

Judging by readable messages found in files:
-sprite.axf seems to be a kind of update binary, possibly for PhoenixCard SD cards (I had card_burn_para section in script.fex btw)
-drv_de.drv seems to be responsible for splashscreen, battery charging animation (maybe also for actual offline charging); battery charging animation is also triggered by plugging in power cable.

EDIT2:
sprite.axf is not triggered, it's definitely drv_de.drv which was missing.

MapHtH

February 12, 2015, 07:38:24 am #11 Last Edit: February 13, 2015, 03:13:36 am by MapHtH
I'm trying to install tiny core to nand and load it's files.

Now, I know that I need to modify boot.scr.
The problem is that if I use the following settings:


setenv bootargs console=${console} init=/init rootwait panic=${panic} loglevel=${loglevel} ${extraargs}
ext4load nand 0:2 0x43000000 boot/script.bin
ext4load nand 0:2 0x48000000 boot/uImage
ext4load nand 0:2 0x43100000 boot/uCore
bootm 0x48000000 0x43100000


and the image is set so that u-boot and other nand bootable files are on the fat partition 1 (nanda) and the kernel uImage, uCore, script.bin, uEnv.txt and boot.scr are on an ext4 partition (nandb)
However, whenever I use the posted boot.scr, it says something like wrong partition and it can't load any of the files, so it loads the kernel instead (and loads it from ext4 partition which means that it can read it), but nothing else which leads to a constant reboot.

Now, a question, does ext4load load partitions which need to be named linux way (nand1, nand2...) or can it read the android partition names (nanda, nandb...)?
How could I make this work? Do I need to use a different command to load the files?

Thanks

EDIT:
Nevermind, I figured it all out.