Skip to content

Commands

Martin Olejar edited this page Nov 8, 2017 · 31 revisions

This section is describing the collection of bash scripts targeted for embedded Linux development. Every script is from user side accessible as standard shell command with an optional arguments. The common arguments are:

  • -h/--help  Show help message for command usage
  • -x     Use XDialog instead of cli for wizard
  • -v     Verbose (print debug info)

The usage of all commands is user friendly thanks to clear and intuitive selection wizard.

build_toolchain

The build_toolchain command is managing the install procedure of cross-compiler needed for building bootloader (U-Boot or Barebox) and kernel images.

Supported Compilations:

  • Debian - gcc-arm-none-eabi, gcc-arm-linux-gnueabi, gcc-arm-linux-gnueabihf
  • Linaro - gcc-arm-eabi, gcc-arm-linux-gnueabi, gcc-arm-linux-gnueabihf
  • Crostool-NG - custom build

As default select Debian and gcc-arm-none-eabi

build_uboot

The build_uboot command compiles the U-Boot image for selected i.MX board. When executing for the first time in a new directory, you will need to select the source repository. NXP is covering the first two repositories (internal - private and external - public). The last repository is covered by the NXP community. After cloning of the selected repository into your disk you will be asked to select a working branch from all existing branches in this repository. You need to know which branch contains sources that you want. In the next step you can select the target board for which the U-Boot image will be compiled. The last step is compilation itself. If compilation finishes successfully, the created image will be locate in build/<board_name> directory.

Extra arguments for build_uboot command:

  • -u/--updt  Clean sources and update your local branch. Also remove the configurations
  • -c/--clean  Just clean sources (remove all uncommitted changes)
  • -p/--patch  Create patch from working sources if compilation finishes successfully
  • -m/--mcfg  Run menuconfig
  • -s/--surl   Set external GitRepo URL for U-Boot sources (optional)
  • -t/--btool  Set the path for external toolchain (optional)

For applying own patches, configs or sources use mydata directory inside the working directory:

  • mydata/config - here put your configs usable for cloned u-boot sources
  • mydata/patch - here put your patches which will be applied to cloned u-boot sources
  • mydata/source - here put your sources which will be copied into u-boot sources

Example:

  $ mkdir uboot && cd uboot
  $ 
  $ build_uboot
  $ ...

build_kernel

The build_kernel command compiles the Linux Kernel image, modules and Device Tree Blob (*.dtb) for selected i.MX board. Its usage is similar like in build_uboot command.

Extra arguments for build_kernel command:

  • -u/--updt  Clean sources and update your local branch. Also remove the configurations
  • -c/--clean  Just clean sources (remove all uncommitted changes)
  • -p/--patch  Create patch from working sources if compilation finishes successfully
  • -z/--zip   Compress build data into zip archive
  • -m/--mcfg  Run menuconfig
  • -i/--img   Set Image Type (Image, uImage or zImage )
  • -a/--laddr  Set target LOADADDR as "0x........" (optional)
  • -s/--surl   Set external GitRepo URL for Kernel sources (optional)
  • -t/--btool  Set the path for external toolchain (optional)

For applying own patches, configs or sources use mydata directory similar way as in build_uboot command

Example:

  $ mkdir kernel && cd kernel
  $ 
  $ build_kernel
  $ ...

build_rootfs

This command must be run with root privileges: sudo build_rootfs.

The build_rootfs command generates the Debian or Ubuntu based rootfs for selected i.MX board. If operation finish successfully, the generated rootfs archive will be locate inside build directory.

Extra arguments for build_rootfs command:

  • -i  Create initial config and exit
  • -n  New build, ignore initial config
  • -o  Extract rootfs into specified directory

The content of rootfs can be modified by editing build.cfg if will used -i argument.

PROJECT=ROOTFS
# Architecture
ROOTFS_ARCH=armhf
# Distribution Specific
ROOTFS_DISTRO=debian
ROOTFS_CODENAME=jessie
ROOTFS_MIRROR=http://ftp.debian.org/debian/
ROOTFS_VARIANT=
ROOTFS_COMPONENTS=main,contrib,non-free
ROOTFS_INCLUDE=ca-certificates,openssh-server,locales,dialog,apt-utils,sudo,
ROOTFS_EXCLUDE=eject,fdutils
# Board Specific
ROOTFS_BOARD=imx7d-sdb
ROOTFS_DUART=ttymxc0
ROOTFS_SDCARD=mmcblk0
ROOTFS_ETHDEV=eth0
# root password (if empty... disabled)
ROOTFS_PASSWD=root
ROOTFS_LANG=en_US.UTF-8
ROOTFS_HOSTNAME=debian-imx

For copy additional files into rootfs use mydata directory inside the working directory

Required kernel configuration for rootfs running systemd (Debian, Ubuntu, ...)

Linux Kernel version >= 3.7

Kernel Config Options:

  • CONFIG_DEVTMPFS
  • CONFIG_CGROUPS (it is OK to disable all controllers)
  • CONFIG_INOTIFY_USER
  • CONFIG_SIGNALFD
  • CONFIG_TIMERFD
  • CONFIG_EPOLL
  • CONFIG_NET
  • CONFIG_SYSFS
  • CONFIG_PROC_FS
  • CONFIG_FHANDLE (libudev, mount and bind mount handling)

udev will fail to work with the legacy sysfs layout:

  • CONFIG_SYSFS_DEPRECATED=n

Legacy hotplug slows down the system and confuses udev:

  • CONFIG_UEVENT_HELPER_PATH=""

Userspace firmware loading is not supported and should be disabled in the kernel:

  • CONFIG_FW_LOADER_USER_HELPER=n

Some udev rules and virtualization detection relies on it:

  • CONFIG_DMIID

More details about systemd requirements are here: cgit.freedesktop.org

Example: i.MX7D SABRE board

  $ mkdir rootfs && cd rootfs
  $ 
  $ sudo build_rootfs
  $ ...
  $ ------------------------------------------------------------
  $ Select Board 
  $ ------------------------------------------------------------
  $ ...
  $  12) imx7d-sdb
  $
  $  x) Exit
  $ ------------------------------------------------------------
  $ Enter: 12
  $
  $ ------------------------------------------------------------
  $ Select Distribution 
  $ ------------------------------------------------------------
  $ 0) debian-jessie
  $ ...
  $ x) Exit
  $ ------------------------------------------------------------
  $ Enter: 0
  $
  $ ==> Installing debian into /home/rootfs/temp
  $ I: Retrieving InRelease 
  $ ...

build_image

This command must be run with root privileges: sudo build_image.

The build_image command generate the SD-Card image from U-Boot, Kernel and RootFS.

Extra arguments for build_image command:

  • -i/--init  Create required dirs and exit
  • -e/--extr  Extract SD Card Image
  • -s/--sfatp  Set FAT16 partition size in MB (default: 20)
  • -f/--sfree  Set RootFS free space in MB (default: 200)
  • -c     Compress SD image: zip or gzip (default: zip)

SD-Card Image Format (2GB)

2GB SD-Cart Image Format

Example: How to create SD-Card image for i.MX7D SABRE board

  $ mkdir imx7d_image && cd imx7d_image
  $ 
  $ build_image -i
  $
  $ cp ../uboot/build/imx7sabresd/u-boot.imx uboot
  $ cp ../kernel/build/imx7d-sdb/zImage kernel
  $ cp ../kernel/build/imx7d-sdb/imx7d-sdb.dtb kernel
  $ cp -R ../kernel/build/imx7d-sdb/lib rootfs/mydata
  $ cp ../rootfs/debian_jessie_imx_rootfs.tar.gz rootfs
  $
  $ sudo build_image -f 1000 -c

Example: How to extract SD-Card image

  $ sudo build_image -e sdcard.img