3. Building Debian Images¶
3.1. Introduction¶
Building a Debian Image requires:
Generating a chroot environment for the target architecture (Arm), if the host environment is on x86.
Installing all the necessary packages
Customizing configuration scripts if needed
Building Bootloader
Flashing the generated RootFS and Boot binaries to SD Card
There are several opensource tools available for generating the RootFS in a chroot environment. Such as debootstrap (now deprecated), mmdebstrap (complex), bdebstrap (simple wrapper on top of mmdebstrap).
ti-bdebstrap is a set of scripts that builds upon the bdebstrap
tool to create custom Debian images for TI platforms. This includes creating the bdebstrap
chroot environment itself, installing essential and useful TI and non-TI packages, setting up the configuations, Building the U-Boot etc.
In other words, ti-bdebstrap
offers users an easy way to create a full-fledged Debian image for supported TI platforms, using a single command. Once the image is built, the user can directly flash it onto a SD card.
TI currently supports building Debian Bookworm Images for AM62Px, AM62x and AM64x platforms.
3.2. Usage¶
3.2.1. Get Scripts¶
The scripts are hosted at https://github.com/TexasInstruments/ti-bdebstrap
To clone the repository, run:
git clone https://github.com/TexasInstruments/ti-bdebstrap.git
3.2.2. Repository Structure¶
ti-bdebstrap
├── build.sh
├── builds.toml
├── configs
│ ├── bdebstrap_configs
│ │ ├── am62-bookworm.yaml
│ │ ├── am62p-bookworm.yaml
│ │ ├── am64-bookworm.yaml
│ ├── bsp_sources.toml
│ └── machines.toml
├── LICENSE
├── README.md
├── scripts
│ ├── build_bsp.sh
│ ├── build_distro.sh
│ ├── common.sh
│ └── setup.sh
├── target
│ └── files for target configs
build.sh
: the “main” script that the user should run to generate Debian images.
configs/
: contains details, configuration options and values for machines, bsp_sources and distro-variants (see below for details).
scripts/
: contains helper scripts for build.sh
.
target/
: contains files for target configs, like weston.service
for the weston target.
builds.toml
: contains list of all valid builds along with their definitions (see below for details).
3.2.3. Build Configurations¶
A build config
represents an image with certain values for the machine
, bsp_version
and distro_variant
parameters.
The builds.toml
file contains a list of all valid builds in the builds[]
list. Each build
is then defined underneath.
Values of machine
, bsp_version
and distro-variant
must be defined in configs/machines.toml
, configs/bsp_sources.toml
and configs/bdebstrap_configs/<distro-variant>.yaml
files. If any of these is missing, the build will fail.
So long as you conform to the rule above, you may also define your own builds.
3.2.4. Building Images¶
All valid builds are listed in the builds.toml
file. To build an image, one of these must be chosen and supplied to the build.sh
command. build.sh
commences the build process.
The images are finally stored in the build/
directory. Each build also produces a log file inside log/
.
Building images using ti-bdebstrap
involves the following steps:
install the pre-requisite packages
get the scripts using
git clone
run the
build.sh
script and with required build config as argument.flashing the image into a SD card
3.2.5. Install Pre-requisite Packages¶
First, ensure that your repositories are up-to-date:
sudo apt update
Then, install packages as follows:
sudo apt install -y \
pigz expect pv \
binfmtc binfmt-support \
qemu-user qemu-user-static qemu-system-arm \
debian-archive-keyring bdebstrap \
build-essential autoconf automake \
bison flex libssl-dev \
bc u-boot-tools swig python3-pyelftools
Ensure that all packages were correctly installed using:
sudo apt install --fix-broken
Finally, install toml-cli
:
pip3 install toml-cli
Note
Since the build script is run as root user, toml-cli should also be installed with sudo for root user to be able to access it.
Note
The scripts internally handle toolchain downloads based on Host architecture. So the same steps can be followed on both arm and x86_64 hosts.
3.2.6. Building the Image¶
To build an image, you need to run the build.sh
script:
sudo ./build.sh <build-name>
The <build-name>
must be one present inside builds.toml
file.
Example: to build for am62-bookworm-09.01.00.008
, run:
sudo ./build.sh am62-bookworm-09.01.00.008
Output is then stored in build/am62-bookworm-09.01.00.008
. The logs are in logs/am62-bookworm-09.01.00.008.log
.
3.2.7. Flash Image to SD Card¶
To flash the image to the SD card, use the create-sdcard.sh
script.
Syntax:
sudo ./create-sdcard.sh <build-name>
For example, if the image is am62-bookworm-09.01.00.008, type:
sudo ./create-sdcard.sh am62-bookworm-09.01.00.008
Doing this will flash the am62-bookworm-09.01.00.008 image to the SD card.