On 29/08/13 09:05 AM, Frank Agius wrote:
> On 8/28/2013 10:12 AM, rogecol wrote:
>> Has anyone been successful in flashing the kernel and root file system to
>> NAND by using USB?
> Haven't updated NAND, but I have updated the kernel and root file system
> on the MMC from a USB memory stick. From Linux, the inserted memory
> stick is auto mounted and then scanned for the update script. The first
> phase of the update script replaces the kernel with a new kernel with an
> initramfs. The boot parameters are modified to start this kernel. The
> system is rebooted and starts with a minimal file system running in RAM.
> The second phase of the update is then run. In this phase the MMC
> card is formatted and partitioned. This may sound drastic, but it can
> fix file system errors and corruptions. The normal kernel and boot
> parameters are restored to the first partition on the MMC. The
> filesystem is then restored to the second partition. The system is then
> In a similar fashion, NAND instead of the MMC could be updated in the
> second phase of this scheme.
I've done something similar to update NAND from a USB flash stick. The
stick contained a root file system image, and I used pivot_root to
switch from the onboard NAND root fs to the USB flash root fs image.
Once the root fs was "pivoted" out of the way, I used mount with the
--move option to move the mount points (e.g. /tmp, /sys, /proc, /dev,
etc.) to the USB root fs. Then, the NAND can be wiped and updated. My
scripts are a too bit ugly to share here, but here is a brief outline of
- take down network interfaces and stop all services
- mount file system image from USB:
mount -o loop /mnt/sdc/fs.img /mnt/newroot)
- unmount anything you don't need
- pivot root file systems:
pivot_root . mnt/oldroot
- move all mount points you need to new root:
mount --move /mnt/oldroot/proc /proc
- restart init so it "releases" its hold on the old root fs
- restart dbus and syslog
- kill anything that is still "holding on to" the old root fs
killall getty # they will be restarted by init
- bring network and up any services you'd like (eg. ssh)
- run install script in background and exit. This is necessary because
this script is still holding on to the old root fs.
Then, in the install script, kill any remaining processes that are still
using the old root fs and umount the old root. Now, you can reformat
the NAND fs to your hearts content.
Hope this helps.