Changes between Version 11 and Version 12 of buildroot

11/28/2019 12:31:03 AM (3 years ago)
Cale Collins

Created 'Building .ext4 filesystem and compressed disk image' for Newport.


  • buildroot

    v11 v12  
    145145 * disk partitioning tools
     148=== Building .ext4 filesystem and compressed disk image
     150In the event you choose to use Buildroot but wish to avoid the drawbacks of a ramdisk you can install it to a block storage device. For this you will need to create a .ext4 filesystem image.  This example will utilize the Linux-Newport branch of the mainline 4.14.4 kernel.
     152Prerequisite for this procedure you will need to have:
     154* Downloaded and configured the [wiki:/newport/bsp Newport BSP], many of the tools used will be provided by it.
     155* The [ linux-newport.tar.xz] kernel tarball. 
     156* The latest [ firmware-newport.img] boot firmware if you would like to create a compressed disk image.
     158With the Newport BSP installed, and Buildroot cloned, configure Buildroot in make menuconfig with the two following options:
     160cd buildroot
     161make menuconfig
     163* Target options -> Target Architecture -> AArch64 (little endian) (BR2_aarch64)
     164* Filesystem images -> tar the root filesystem -> Compression method (xz) (BR2_TARGET_ROOTFS_CPIO_XZ)
     166Save the .config and exit. 
     170make -j8
     173After the build completes:
     174* Export the location of the rootfs.tar located in your buildroot/output/images folder.
     178* Create a tmp_mnt directory at a location of your discression, this is your temporary mounting point for compiling the filesystem.
     180mkdir tmp_mnt
     183* Create a filesystem of a specific size. It will be expandable later using resize2fs, make it large enough to fit what you have in your current build.   
     186SIZEMB=1536 # 1.5GB
     187truncate -s ${SIZEMB}M ${OUT}
     188mkfs.ext4 -q -F -L rootfs ${OUT}
     190* Mount this file to your 'tmp_mnt' directory
     192sudo mount ${OUT} ${TMP_MNT}
     194* Extract the Buildroot rootfs.tar and linux-newport.tar.xz which was downloaded to this mount point.
     196sudo tar -C ${TMP_MNT} -xf ${ROOTFS}
     197sudo tar -C ${TMP_MNT} -xf linux-newport.tar.xz
     199* Convert the kernel 'Image' (uncompressed Kernel) to a fit image.  For this you will need a tool from your Newport BSP directory, in this example the path to the BSP directory is named ${NEWPORT_BSP}.
     201mv ${TMP_MNT}/boot/Image vmlinux
     202gzip -f vmlinux
     203${NEWPORT_BSP}/newport/ -o kernel.its -k vmlinux.gz -C gzip -v "buldroot-newport"
     204mkimage -f kernel.its tmp_mnt/boot/kernel.itb #adds header
     206* Create U-Boot bootscript using the existing Ubuntu one from the Newport BSP, use mkimage to add the u-boot header.
     208mkimage -A arm64 -T script -C none -d ${NEWPORT_BSP}/newport/ubuntu.scr ${TMP_MNT}/boot/newport.scr
     210* Unmount temporary mount point, and compress the .ext4 file to be used with the u-boot command 'gzwrite'.
     212umount ${TMP_MNT}
     214gzip -k -f ${OUT}
     217To load this root file system without disturbing the existing boot firmware tftpboot can be used:
     219* Boot your Newport SBC, at the prompt "Hit any key to stop autoboot" press a key.
     220* Execute the following commands.
     222setenv ipaddr <your boards IP>
     223setenv serverip <your TFTP server IP>
     224setenv dev 0
     225setenv image buildroot-newport.ext4.gz
     226run update_rootfs
     229To create a disk image from the .ext4 file:
     231* Creating a disk image is useful if you would like to overwrite the existing boot firmware when the image is flashed. 
     234cp firmware-newport.img buildroot-newport.img
     235# copy buildroot rootfs .ext4 filesystem to image with an offset
     236dd if=buildroot-newport.ext4 of=buildroot-newport.img bs=16M seek=1
     237# compress it
     238gzip -k -f buildroot-newport.img
    148243== Ventana (IMX6)