- Using Interfaces (GPIO, UART, SPI, ...)
- Building an initial ramdisk without root permission
- Creating a JFFS2 image from a directory structure
- SAM-BA : Flashing taskit's ARM-based boards
- Flashing new u-boot on Portux920T / Portux Panel-PC
- Implementing an own boot-logo for Panel-Card
- Nano-X with tslib support
- Using Watchdog on Stamp9G20 or PortuxG20
- Development with Eclipse
- Installing Debian/GNU Linux on Stamp9G20 and PortuxG20
- Using Xenomai on PortuxG20/Stamp9G20
- Installing a rootfs on SD card
- Using Power Management Features
- Using the NAND flash on NanosG20
- Using the buzzer on PortuxG20 rev. 2 and NanosG20
Using the NAND flash on NanosG20
Last edited by cglindkamp on Mon, 01/23/2012 - 13:00
Creating and using an UBI flash partition
The following steps are needed to use the internal flash:
- Boot into the Debian system.
- Attach mtd device 2 with ubi:
ubiattach /dev/ubictrl -m 2
You have now a new device called /dev/ubi0.
- Create a new ubi volume
ubimkvol /dev/ubi0 -N data -m
This create a volume with the name "data" which uses the complete flash space. If you want to create multiple volumes, replace "-m" with "-s size". See "ubimkvol --help" for more information. After that, you will have a new device call /dev/ubi0_0.
- Mount this device:
mount /dev/ubi0_0 /mnt -t ubifs
or by using the volume name
mount ubi0:data /mnt -t ubifs
Now you can write to /mnt or another path you use to mount the device to write files on the flash.
Repeat steps 2 and 4 on every boot to get access to the files. You can automate both steps:
- Add " ubi.mtd=2" to the end of the line in /boot/cmdline.
- Add the line
/dev/ubi0_0 /mnt ubifs defaults 0 0
or by using the volume name
ubi0:data /mnt ubifs defaults 0 0
to /etc/fstab
If you want to completely erase a volume run the following command:
ubiupdatevol device -t -
where device could again be the direct device file (e.g. /dev/ubi0_0) or the volume name description (e.g. ubi0:data).
It might make sense to use a different name and/or mount point, but that is your decision.
Using the flash as the root filesystem
It is possible to use the NAND partition just created as the root filesystem. First you have to copy the rootfs contents to partition. If you have a tar archive with the contents, it should be as easy as the following command (assumed the filesystem is mounted on /mnt and the tarball is called rootfs.tar):
tar xvf rootfs.tar -C /mnt
If you want to use the current content of your SD card, you have two options:
- Create a tarball on a different Linux computer (make sure that you are root so that every file is accessible during the creation of the archive)
- Directly copy the contents from the SD card to the flash. This should be done from the bootloader shell and not from the running system as there multiple (virtual) filesystems mounted on top of the rootfs which make it difficult to produce an correct copy. To do that, hold the power on button down while booting. A menu should appear on the serial console. Choose "4 - Drop to shell". Now you can mount both the NAND partition and the SD card and copy the contents. You might need to created new mount point. The following commands should do the trick:
mkdir /mnt/flash mkdir /mnt/sd mount /dev/ubi0_0 /mnt/flash -t ubifs mount /dev/mmcblk0p1 /mnt/sd cp -a /mnt/sd/* /mnt/flash
Before this partition is really used as the root filesystem, make sure the boot parameters have been adjusted. Edit the file boot/cmdline in the flash partition. It should look like this if you named your partition "rootfs":
console=ttyS1,115200 mmc_core.removable=0 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs
Now unmount the flash and the SD card if you are currently in the bootloader exit the shell and choose "0 - Continue with autoboot". If you have done the procedure in the Debian system, just reboot. If everything is correct, the system should now boot only from flash.
One additional note: You should try to strip down the system before puttin it to flash. Unneeded software, man pages and other documentation just waste memory, especially on the NanosG20 with only 128MB flash.