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 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 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
│ │ ├── bookworm-default.yaml
│ │ └── bullseye-default.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 supply it a build nameflashing the image into a SD card
installing ti-img-rogue-driver (and any other dkms-built out-of-tree kernel modules) after booting
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
3.2.6. Running the Scripts¶
To run the scripts, you must run the build.sh
script:
sudo ./build.sh <build-name>
The <build-name>
must be one present inside builds.toml
file.
Example: to build am62x_bookworm_09.00.00.006
, run:
sudo ./build.sh am62x_bookworm_09.00.00.006
Output is then stored in build/am62x_bookworm_09.00.00.006
. The logs are in logs/am62x_bookworm_09.00.00.006.log
.
Note: Use the above config only if you are building on the Target which is already running Debian. If you are building on any other target, use configs which has no-km
. This ensures to not install any Out of tree kernel modules.
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 am62x_bookworm_09.00.00.006, type:
sudo ./create-sdcard.sh am62x_bookworm_09.00.00.006
Doing this will flash the am62x_bookworm_09.00.00.006 image to the SD card.
3.2.8. Post-Build:¶
Untar the build/<build>.tar.gz file and flash the rootfs and boot partitions into a SD card.
Following that, you should have a basic Debian system set up. However, this system does not yet contain any out-of-tree kernel modules. Therefore they need to be installed after booting in.
At the very least, you should install the ti-img-rogue-driver to enable display. Use the following command:
apt install ti-img-rogue-driver
To load the driver, reboot.
Once rebooted, the driver should work. To verify that it is loaded, type:
lsmod | grep pvr
If you see output of pvrsrvkm driver, it means that the driver has loaded correctly.