Skip to content

About

build kernel/rootfs/bootloader for rt-smart

Resources

Contributing

Stars

1 star

Watchers

2 watching

Forks

Repository files navigation

English | 中文

smart-build

smart-build is a standalone build system for RT-Thread Smart. It provides one command-line interface for machine configuration, package selection, kernel and root filesystem builds, incremental task execution, build manifests, and QEMU smoke checks.

The project runs from its source tree. Build outputs, downloaded archives, toolchains, and the RT-Thread source tree are kept outside version control.

Supported machines

Machine Architecture RT-Thread BSP QEMU profile
qemu-virt-aarch64 AArch64 qemu-virt64-aarch64 virt-aarch64
qemu-virt-riscv64 RISC-V 64 qemu-virt64-riscv virt-riscv64
qemu-vexpress-a9 Arm qemu-vexpress-a9 vexpress-a9
k230 RISC-V 64 k230 physical board

The AArch64 and RISC-V virt boards enable the device model and OFW by default, using the device tree supplied by QEMU rather than a built-in DTB.

The currently implemented root filesystem image format is ext4. FAT and romfs appear in the configuration interface but are not yet buildable.

Prerequisites

  • Python 3.10 or newer.
  • A compatible toolchain from Env SDK, a configured TOOLCHAIN_PATH, or the repository's downloads/toolchains/ cache. Missing downloadable versions can be installed with smart-build toolchain install.
  • The K230D board uses the Env SDK riscv64-linux-musleabi-gcc-latest toolchain, or a custom TOOLCHAIN_PATH.
  • The K230 board keeps its verified boot components under boards/k230/firmware/; the SD-card image stage does not require a K230 SDK checkout, vendor scripts, or a separate firmware download.
  • RT-Thread Env package scripts under ~/.env/tools/scripts and a package index under ~/.env/packages/packages.
  • An RT-Thread source tree available as the repository-root rt-thread path, usually as a symbolic link.
  • Host build tools reported by smart-build doctor.
  • The QEMU system binary declared by the selected board for smoke tests, when the board provides a QEMU profile.

Install the Python package in editable mode:

python -m pip install -e .

Quick start

./smart-build doctor
./smart-build toolchain list
./smart-build menuconfig
./smart-build build all
./smart-build qemu-smoke

To select a machine without changing the workspace configuration:

./smart-build --machine qemu-virt-riscv64 doctor
./smart-build build kernel --machine qemu-virt-riscv64
./smart-build --machine k230 doctor
./smart-build build kernel --machine k230
./smart-build build all --machine k230

qemu-smoke is not available for K230 because the board has no QEMU profile. An external K230 QEMU model is not a substitute: it stops during early kernel initialization and has no SDHCI controller for the ext4 rootfs. The K230D firmware also uses a physical load address that differs from QEMU's direct-boot address. See the board guide for the observed boot limit.

With a RISC-V rootfs profile that selects tmux, run build/qemu-virt-riscv64/run_qemu_nographic.sh rootfs.img and enter tmux at the / # prompt to check the interactive pane. qemu-smoke checks boot, but does not exercise tmux. The tmux build enables its pipe2 workaround only for target musl 1.2.5 and earlier; musl 1.2.6 and later use the libc implementation. Normal tmux sessions do not create debug log files; use tmux -v to request them. After building a RISC-V rootfs with tmux, mc, and QuickJS, run the external package runtime checks with python tests/qemu/package_smoke.py. They cover BusyBox shell/file operations, tmux sessions and panes, mc navigation, mcedit saving, and QuickJS scripts/modules. Checks use a disposable rootfs copy; see the command reference for case selection and prerequisites.

For the K230 board, build all combines the board-owned SPL, U-Boot, environment, and OpenSBI components with the common kernel and rootfs using the in-tree K230 image backend into build/k230/images/k230-sdcard.img. The board defconfig selects the basic BusyBox rootfs and builds no additional application packages by default; switch it to full or minimal when packages such as mc or tmux are needed. Set no K230-specific menuconfig value. The image is a whole-device image and must be written to the whole TF/SD device. Its configured rootfs is an ext4 partition at 16 MiB; the K230D kernel enables lwext4 and mounts sd0p0 at /. Dynamic or mixed rootfs builds also install the matching soft-float musl loader, libc, GCC runtime libraries, and all declared package .so variants into the rootfs. The kernel enables procfs and AF_UNIX local sockets for RT-Thread Smart POSIX IPC, so /proc is mounted during filesystem initialization and BusyBox mount can report the mount table. BusyBox rcS owns the /dev/shm tmpfs mount. When lwIP and netdev are enabled, RT-Thread Smart also enables the common IPv4 loopback interface lo through RT_LWIP_USING_LOOPBACK; this provides local 127.0.0.1 networking but does not provide external Ethernet connectivity. The K230D time CSR runs at 25 MHz and the kernel uses a 1 kHz OS tick. Kernel MSH remains enabled, so its normal interactive tshell startup may print msh />. This is the RT-Thread kernel shell prompt, not a rootfs mount or network error. The LWP init debug countdown is disabled; BusyBox ash is also started by the rootfs init script and may share the serial console.

Build results are written below build/<machine>/. Downloaded source archives and installed toolchains are stored below downloads/.

When a root-level buildroot/ checkout is available, buildroot menuconfig and buildroot import can create best-effort smart-build packages. If the checkout is missing, buildroot menuconfig asks whether to shallow-clone the latest Buildroot repository first. Existing packages are skipped and failures do not stop later imports. Imported package metadata keeps upstream network URLs; source archives are downloaded only by the normal smart-build package build. Import success means metadata was generated, not that cross-compilation has been verified.

Before compiling the kernel, smart-build synchronizes its defconfig to the RT-Thread BSP and runs ~/.env/tools/scripts/pkgs --force-update. Kernel packages and their versions are selected by the RT-Thread kernel configuration, not by smart-build package metadata. Unrecorded package directories that would participate in the kernel build are removed with a warning.

Common commands

Opt-in terminal integration tests provide UART keyboard/mouse input, VT screen evidence, and exact file checks for tmux/MC. Use python tests/runtime/run.py --list to inspect implementation coverage; listed cases are not necessarily implemented or validated.

./smart-build --help
./smart-build doctor
./smart-build toolchain list
./smart-build toolchain install --yes
./smart-build menuconfig
./smart-build configure kernel
./smart-build configure package:curl
./smart-build configure package:webclient
./smart-build buildroot menuconfig
./smart-build buildroot import
./smart-build build all
./smart-build build kernel
./smart-build build kernel --verbose
./smart-build build rootfs
./smart-build build devicetree
./smart-build graph
./smart-build qemu-smoke
./smart-build clean
./smart-build download-clean

QEMU virt machines use an automatic device tree by default. Custom board devicetree.source entries can be .dts or .dtb; smart-build preprocesses and compiles DTS files, validates DTBs, and exposes devicetree dump and devicetree decompile. Launchers and qemu-smoke accept --auto-dtb, --dtb FILE, and --append TEXT. The AArch64 and RISC-V virt kernels also expose the active OFW tree read-only at /proc/device-tree; property files contain the raw device-tree bytes.

Independent RT-Thread SCons packages with native Kconfig, such as webclient, use the package configure command to open their RT-Thread package options.

Before tasks run, build analyzes the machine, toolchain, selected packages, and task graph. Interactive terminals show a live plan: progress bar while package metadata is loaded; redirected output prints each planning phase. Planning ends with plan: ready N tasks. Normal builds then show a colored progress bar in interactive terminals and report completed tasks above it, for example build: [2/12] toolchain:check: skipped. Redirected output uses the same status format without colors or terminal control sequences. Successful and skipped tasks do not print log paths or log contents. build --verbose prints planning items, task context, task logs, and log paths to the terminal. When the target includes the RT-Thread kernel, smart-build runs its compile step with scons --verbose to show the complete compiler and linker commands.

build --dry-run currently prints a placeholder task plan. It is useful for a high-level preview, but it is not guaranteed to match every task in a real build.

Incremental builds validate input/recipe signatures, dependency result metadata, and output contents. Failed retries invalidate old success records, and cache hits restore execution metadata in the manifest. Older cache formats rebuild automatically. See compatibility for preparation-tree exceptions and the distinction between filesystem fingerprints and raw SHA256. Package dependencies must exist or resolve to an unambiguous provider. Backend and target authoring is described in extension contracts.

Full rootfs assembly starts from the BusyBox base. An explicitly selected package may replace an applet link that points to that base's /bin/busybox; other existing symlinks and conflicting files remain errors.

The checked-in BusyBox configuration is trimmed for the RT-Smart capability floor used by qemu-virt-riscv64 and K230. Linux virtual-console, module, namespace, swap/loop, inotify, hardware-ioctl, and Linux identity-management applets are disabled, so their applet symlinks are not installed. Supported applets continue to use CONFIG_INSTALL_APPLET_SYMLINKS.

Documentation

License

No project license has been selected in this repository yet. A license must be added before distributing the project for general third-party use.

About

build kernel/rootfs/bootloader for rt-smart

Resources

Contributing

Stars

1 star

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages