BuildRoot : use the demo root filesystem

Flash the rootfs image

Note Note that the root file system is installed at offset 0x800000 in the nand flash. From a Linux kernel point of view, this corresponds to the index 1 of the MTD subsystem device (/dev/mtd1 and /dev/mtdblock1).

Using u-boot commands

Following commands documentation is available in the u-boot doc/README.nand documentation file.

    1. erase the nand flash root file system partition (in our case nand flash size is about 256 MB)

U-Boot> nand erase 0x800000 0xF800000

NAND erase: device 0 offset 0x800000, size 0xf800000
Erasing at 0xffe0000 -- 100% complete.
OK

    2. download the UBI file system from TFTP to the board RAM (address 0x20000000)

U-Boot> tftp 0x20000000 buildroot_2012.11.1-at91_sama5d3_linux4sam_4.0.ubi
gmacb0: PHY present at 7
gmacb0: link up, 1000Mbps full-duplex (lpa: 0x0300)
Using gmacb0 device
TFTP from server 10.159.245.147; our IP address is 10.159.245.199
Filename 'rootfs.ubi'.
Load address: 0x20000000
Loading: #################################################################
         #################################################################
         [...]
         #################################################################
         #
done
Bytes transferred = xxxxxxxx (yyyyyyy hex)
    Note remember the number of Bytes transferred just indicated above. It will be useful for the nand write.trimffs command.

    3. write the filesystem from ram at offset 0x20000000 to nand flash at offset 0x800000 (Linux /dev/mtdblock1). Note the last parameter: it is the number of Bytes transferred indicated in the previous command.

U-Boot> nand write.trimffs 0x20000000 0x800000 0xyyyyyyy

NAND write: device 0 offset 0x800000, size 0x1c40000
 29622272 bytes written: OK

Using SAM-BA

There are several steps to follow:

- Connecting to the board,

- Enabling the nand flash,

- Erasing the rootfs partition,

- Flashing the rootfs.

Create a bootable SD card

Once the sdcard.img is generated, it is easy to create the bootable SD card. The procedure is explained in board/atmel/readme.txt or in Create a SD card with the demo section.

Note The SD card image generated by Buildroot is not compressed. It doesn't change the Windows procedure but uncompressing the image for the Linux procedure is no longer needed.

Boot to the installed rootfs

To mount the root file system correctly, several items should be selected in the Linux Kernel's configuration:

  • Device Drivers -> Memory Technology Device (MTD) support -> Support for NAND Flash / SmartMedia on AT91 and AVR32
  • Device Drivers -> Memory Technology Device (MTD) support -> Enable UBI - Unsorted block images
  • File systems -> Miscellaneous filesystems -> UBIFS file system support

You may have to update the boot args passed to the kernel, type this command in U-Boot:

U-Boot> setenv bootargs 'console=ttyS0,115200 mtdparts=atmel_nand:8M(bootstrap/uboot/kernel)ro,-(rootfs) rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs'
U-Boot> saveenv

  • mdtparts defines the nand flash partition map, from the kernel point of view, we are not interested in the first 8MB so we don't need to provide a detailed partition map for this part.
  • rootfstype simply defines which kind of rootfs we are using.
  • ubi.mtd indicates on which mtd partition is the rootfs
  • root indicates the ubi device and the volume name which is by default rootfs when generated by Buildroot.
I Attachment Action Size Date Who Comment
PNGpng sam-ba_pmecc_sama5d3.png manage 16.3 K 2013-02-01 - 15:34 LudovicDesroches sam-ba pmecc conf for sama5d3 screenshot
PNGpng sam-ba_rootfs.png manage 71.0 K 2013-02-01 - 15:17 LudovicDesroches sam-ba programming rootfs screenshot