Changes between Version 11 and Version 12 of buildroot


Ignore:
Timestamp:
11/28/2019 12:31:03 AM (5 years ago)
Author:
Cale Collins
Comment:

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

Legend:

Unmodified
Added
Removed
Modified
  • buildroot

    v11 v12  
    145145 * disk partitioning tools
    146146
     147
     148=== Building .ext4 filesystem and compressed disk image
     149
     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.
     151
     152Prerequisite for this procedure you will need to have:
     153
     154* Downloaded and configured the [wiki:/newport/bsp Newport BSP], many of the tools used will be provided by it.
     155* The [http://dev.gateworks.com/newport/kernel/linux-newport.tar.xz linux-newport.tar.xz] kernel tarball. 
     156* The latest [http://dev.gateworks.com/newport/boot_firmware/firmware-newport.img firmware-newport.img] boot firmware if you would like to create a compressed disk image.
     157
     158With the Newport BSP installed, and Buildroot cloned, configure Buildroot in make menuconfig with the two following options:
     159{{{#!bash
     160cd buildroot
     161make menuconfig
     162}}}
     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)
     165
     166Save the .config and exit. 
     167
     168Now:
     169{{{#!bash
     170make -j8
     171}}}
     172
     173After the build completes:
     174* Export the location of the rootfs.tar located in your buildroot/output/images folder.
     175{{{#!bash
     176ROOTFS=${PWD}/output/images/rootfs.tar
     177}}}
     178* Create a tmp_mnt directory at a location of your discression, this is your temporary mounting point for compiling the filesystem.
     179{{{#!bash
     180mkdir tmp_mnt
     181TMP_MNT=${PWD}/tmp_mnt 
     182}}}
     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.   
     184{{{#!bash
     185OUT=buildroot-newport.ext4
     186SIZEMB=1536 # 1.5GB
     187truncate -s ${SIZEMB}M ${OUT}
     188mkfs.ext4 -q -F -L rootfs ${OUT}
     189}}}
     190* Mount this file to your 'tmp_mnt' directory
     191{{{#!bash
     192sudo mount ${OUT} ${TMP_MNT}
     193}}}
     194* Extract the Buildroot rootfs.tar and linux-newport.tar.xz which was downloaded to this mount point.
     195{{{#!bash
     196sudo tar -C ${TMP_MNT} -xf ${ROOTFS}
     197sudo tar -C ${TMP_MNT} -xf linux-newport.tar.xz
     198}}}
     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}.
     200{{{#!bash
     201mv ${TMP_MNT}/boot/Image vmlinux
     202gzip -f vmlinux
     203${NEWPORT_BSP}/newport/mkits.sh -o kernel.its -k vmlinux.gz -C gzip -v "buldroot-newport"
     204mkimage -f kernel.its tmp_mnt/boot/kernel.itb #adds header
     205}}}
     206* Create U-Boot bootscript using the existing Ubuntu one from the Newport BSP, use mkimage to add the u-boot header.
     207{{{#!bash
     208mkimage -A arm64 -T script -C none -d ${NEWPORT_BSP}/newport/ubuntu.scr ${TMP_MNT}/boot/newport.scr
     209}}}
     210* Unmount temporary mount point, and compress the .ext4 file to be used with the u-boot command 'gzwrite'.
     211{{{#!bash
     212umount ${TMP_MNT}
     213sync
     214gzip -k -f ${OUT}
     215}}}
     216
     217To load this root file system without disturbing the existing boot firmware tftpboot can be used:
     218
     219* Boot your Newport SBC, at the prompt "Hit any key to stop autoboot" press a key.
     220* Execute the following commands.
     221{{{#!bash
     222setenv ipaddr <your boards IP>
     223setenv serverip <your TFTP server IP>
     224setenv dev 0
     225setenv image buildroot-newport.ext4.gz
     226run update_rootfs
     227}}}
     228
     229To create a disk image from the .ext4 file:
     230
     231* Creating a disk image is useful if you would like to overwrite the existing boot firmware when the image is flashed. 
     232{{{#!bash
     233# http://dev.gateworks.com/newport/boot_firmware/firmware-newport.img
     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
     239}}}
     240
     241
    147242[=#ventana]
    148243== Ventana (IMX6)