Tutorial: using the built-in library

SBXG provides a built-in library, that can be extended by the users. This allows SBXG to provide users an out-of-the-box experience.

First, to observe the contents of the built-in library, just run:

sbxg show

and something like this will appear:

List of toolchains:
  - local
  - armv7-eabihf

List of sources:
  - linux: linux-4.14.35
  - linux: linux-4.12.0
  - uboot: uboot-2017.07
  - xen: xen-4.8.3
  - genimage: genimage-v11

List of configurations:
  - linux: linux-4.12-sunxi
  - linux: linux-4.14-sunxi-xen-dom0
  - linux: linux-4.14-xen-domu
  - uboot: uboot-2017.07-minimal
  - xen: xen-4.8-sunxi

List of bootscripts:
 - boot-sunxi-default.j2
 - boot-sunxi-xen.j2

List of images:
 - sdcard-simple.j2
 - guest-simple.j2

List of boards:
 - cubietruck-standalone

Now, imagine that you want to build a Linux kernel for a sunxi <https://linux-sunxi.org/Main_Page> board from your x86 PC. You can see that SBXG provides a configuration for a 4.12 Linux kernel. Granted, this is quite old, but let’s say you have an old version of SBXG ;)

So you are interested in the following elements:

  • the toolchain (armv7-eabihf);
  • the linux source (linux-4.12.0); and
  • the linux configuration (linux-4.12-sunxi).

Just tell that to SBXG:

sbxg gen -L linux-4.12.0 -l linux-4.12-sunxi -t armv7-eabihf build

SBXG will work a bit, and if everything went right, it should end with exit code 0. In the build/ directory, you now have a generated standalone Makefile. You can build everything by running make in this directory. You can even pass to make the number of jobs to be used for building. It will be used to build the different components:

make -C build -j 3

Upon successful completion of this command, you will see the following directories:

build/
├── armv7-eabihf--glibc--stable-2018.02-2/
├── build_linux_4_12_sunxi/
├── downloads/
├── linux-4.12/
├── Makefile
└── stamps/

Let’s go through them one by one:

  • armv7-eabihf--glibc--stable-2018.02-2/: this is where the toolchain was extracted.
  • linux-4.12/: this is where the sources of the kernel were extracted.
  • downloads/: you will find here compressed archives that were downloaded.
  • stamps/: this contains files generated by the Makefile that allows make to only download the archives when needed. Each file contains the URL from which the component was downloaded.
  • build_linux_4_12_sunxi/: this is where the linux kernel was built. Note that SBXG performs builds out-of-tree when possible.

Now that your kernel has been built, and now that you known where it was built, you can freely dispose of them. For instance, the zImage resides in build/build_linux_4_12_sunxi/arch/arm/boot/.