第7章 Build Procedure

This chapter describes the procedure for creating an image the same as the factory default image.

We recommend latest version of sources because of troubleshooting, function addition and updating.

[警告]

The development process involves working with basic libraries, applications and system configuration files. While all files are altered only under the working directory, in order to ensure the PC operating system is not inadvertently damaged from any mistakes made during development please perform all work as a general user and not a root user.

7.1. Building the Bootloader

This section explains the procedure for creating an image file from the source code of the bootloader "U-Boot".

[ティップ]

Default configurations for SPI flash memory and SD/eMMC ware merged since u-boot-x1-at16.

手順7.1 Building the Bootloader

  1. Preparing Source Code

    Prepare and extract the U-Boot source code archive.

    [PC ~]$ ls
    uboot_2016.07-at[version].tar.gz
    [PC ~]$ tar xf uboot_2016.07-at[version].tar.gz
    [PC ~]$ ls
    uboot_2016.07-at[version]  uboot_2016.07-at[version].tar.gz
  2. Applying Default Configuration

    Enter the U-Boot directory and apply the default configuration for Armadillo-IoT Gateway G3. Specify x1_config as the default config.

    [PC ~]$ cd uboot_2016.07-at[version]
    [PC ~/uboot_2016.07-at[version]]$ make ARCH=arm x1_config
  3. Building

    The make command is used to perform the build.

    [PC ~/uboot_2016.07-at[version]]$ make CROSS_COMPILE=arm-linux-gnueabihf-
  4. Confirming the creation of the Image File

    When the build finishes an image file is created in the U-Boot directory.

    [PC ~/uboot_2016.07-at[version]]$ ls u-boot-x1.bin
    u-boot-x1.bin

7.2. Building the Linux Kernel

This section explains the procedure for creating an image file from the Linux kernel source code and initramfs archive.

Files required for the build

linux-4.9-x1-at[version].tar.gz
initramfs_x1-[version].cpio.gz

手順7.2 Building the Linux Kernel

  1. Extracting the Archive

    Extract the Linux kernel source code archive.

    [PC ~]$ls
    initramfs_x1-[version].cpio.gz linux-4.9-x1-at[version].tar.gz
    [PC ~]$tar xf linux-4.9-x1-at[version].tar.gz
    [PC ~]$ls
    initramfs_x1-[version].cpio.gz linux-4.9-x1-at[version]  linux-4.9-x1-at[version].tar.gz
  2. Creating a Symbolic Link to the Initramfs Archive

    Move to the Linux kernel directory and create a symbolic link to the initramfs archive.

    [PC ~]$cd linux-4.9-x1-at[version]
    [PC ~/linux-4.9-x1-at[version]]$ ln -s ../initramfs_x1-[version].cpio.gz initramfs_x1.cpio.gz
  3. Configuration

    Perform the configuration.

    [PC ~/linux-4.9-x1-at[version]]$ make ARCH=arm x1_defconfig
  4. Building

    To do the build, run the following commands.

    [PC ~/linux-4.9-x1-at[version]]$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
    [PC ~/linux-4.9-x1-at[version]]$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x80008000 uImage
            
  5. Confirming the creation of the Image File

    When the build finishes, image files (the Linux kernel and DTB) are created under the arch/arm/boot/directory and arch/arm/boot/dts/ directory.

    [PC ~/linux-4.9-x1-at[version]]$ ls arch/arm/boot/uImage
    uImage
    [PC ~/linux-4.9-x1-at[version]]$ ls arch/arm/boot/dts/armadillo_iotg_g3.dtb
    armadillo_iotg_g3.dtb
    [PC ~/linux-4.9-x1-at[version]]$ ls arch/arm/boot/dts/armadillo_iotg_g3_w2.dtb
    armadillo_iotg_g3_w2.dtb

7.3. Building a Debian GNU/Linux Root File System

The following shows how to build a Debian GNU/Linux root file system using x1-debian-builder.

x1-debuan-builder is a tool that can be used on Linux running on a PC such as ATDE to build armhf architecture Debian GNU/Linux root file systems for Armadillo-IoTG3.

Depending on how it is used, after starting Armadillo-IoT G3 the first time the ssh secret key, operation log, shell command history, the configuration files associated with the hardware UUID and so on are generated on the root file system. If the root file system is then copied as-is to another Armadillo-IoT G3 , there is a possibility that behavior differences may occur due to key leakage or UUID mismatch. Therefore it is recommended to use x1-debuan-builder and build a new root file system for use in mass production etc.

7.3.1. Creating the Factory Default Root File System Archive

The procedure for building the root file system archive of the factory default state is as follows. As packages are obtained over the internet it will depending on the connection speed, but will generally take around 40 minutes.

[ATDE ~]$sudo apt-get update && sudo apt-get install qemu-user-static
[ATDE ~]$tar xf x1-debian-builder-[VERSION].tar.gz
[ATDE ~]$cd x1-debian-builder-[VERSION]
[ATDE ~]$sudo ./build.sh aiotg3

図7.1 Procedure for Creating the Factory Default Root File System Archive


7.3.2. Creating a Customized Root File System Archive

The root file system can be modified by altering the files under x1-debian-builder-[VERSION]/aiotg3_resources and executing the build.sh script.

7.3.2.1. Adding Files and Directories

All files and directories under aiotg3_resources except for the resources directory are copied directly to the root file system. Both the UID and GID of the files become "root".

7.3.2.2. Changing Packages

The packages to be installed on the root file system can be customized by altering aiotg3_resources/resources/packages.

One package name is written per line. Please use package names in the form that can be correctly used as the argument to "apt-get install" on Armadillo-IoT G3.

If an incorrect package name is specified, the following error message is displayed in the build log and the archive is generated without the package.

E: Unable to locate package XXXXX

図7.2 Error Message when Incorrect Package Name Specified


[ティップ]

Other packages that the package depends on are automatically installed by the apt command without needing to specify them. Also, packages that form the base of Debian GNU/Linux such as apt and dpkg are also automatically installed.

[ティップ]

The packages include the lua and ruby interpreters and a web server (lighttpd). If they are not required just delete each package's line.

[警告]

For packages such as openssh-server that automatically generate private keys when installed, as a general rule do not add them to the packages and instead use "apt-get install" to install them separately after starting Armadillo.

If openssh-server is added to packages, it will be possible to log in to all Armadillo which the built root file system archive is written to using a single public key. If intentionally using the same secret key for multiple Armadillo, understand that it can lead to vulnerabilities and take appropriate measures before using it.