Skip to content

noahbean33/embedded_linux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BeagleBone Black — Custom Embedded Linux Image

C · ARM Cortex-A8 · Linux Kernel 6.18 · U-Boot · systemd · Buildroot · Cross-Compilation Toolchains · Shell Scripting

A fully custom embedded Linux image built from scratch using Buildroot for the BeagleBone Black (TI AM335x). This project demonstrates end-to-end BSP (Board Support Package) development: bootloader configuration, kernel selection, root filesystem generation, custom package creation, and systemd service integration — the core workflow for embedded Linux product bring-up and IoT device development.

Boot Chain

This image implements the full BeagleBone Black boot sequence:

ROM → MLO (SPL) → U-Boot 2026.04 → Linux Kernel 6.18.21 → systemd → custom services
  1. MLO/SPL — TI AM335x ROM loads the Secondary Program Loader from the SD card FAT partition
  2. U-Boot 2026.04 — Full bootloader (am335x_evm defconfig), loads kernel + device tree
  3. Linux Kernel 6.18.21 — Built with omap2plus defconfig, multi-board Device Tree support
  4. systemd — Init system managing service startup and logging
  5. sysinfo services — Custom oneshot services printing hardware diagnostics at boot

Hardware

  • Board: BeagleBone Black (TI AM335x ARM Cortex-A8, 32-bit ARMv7)
  • RAM: 512MB DDR3
  • Storage: Bootable microSD card (120MB ext4 root + FAT boot partition)
  • Toolchain: Bootlin external toolchain (ARMv7 EABI hard-float, glibc)
  • Host: Ubuntu 22.04 x86-64

What This Does

At every boot, two systemd oneshot services run automatically and print system diagnostics to both the serial console and the systemd journal:

  • sysinfo (C binary) — reads directly from kernel via sysinfo() syscall and /proc

    • Exact memory in bytes (total, used, free, shared, buffers)
    • Uptime in days/hours/minutes/seconds
    • Load averages (1, 5, 15 min) — decoded from fixed-point kernel format
    • Running process count
    • CPU hardware and core count from /proc/cpuinfo
    • Root block device from /proc/mounts
    • Network interface detection from /proc/net/dev
  • sysinfo-sh (shell script) — uses standard userspace tools (free, df, ip, uname)

    • Hostname, kernel version, CPU, memory, uptime, disk usage, network addresses

Both are cross-compiled for ARM and packaged as a proper Buildroot package with build rules, install targets, and systemd integration.

Key Skills Demonstrated

  • Bootloader configuration — U-Boot 2026.04 with SPL, img format, DTC and OpenSSL dependencies
  • Kernel configuration — Custom version selection, Device Tree compilation for multiple AM335x boards
  • Cross-compilation — Building ARM hard-float binaries on x86-64 using Bootlin external toolchain
  • Custom Buildroot package — Full package structure (Config.in + .mk), local site method, generic-package infrastructure
  • C systems programming — Direct kernel interface via sysinfo() syscall, /proc filesystem parsing, utsname structs
  • systemd service design — Oneshot units with journal+console output, multi-user.target integration, journald configuration
  • Image generation — genimage-based partitioned SD card image (FAT boot + ext4 root)
  • Reproducible builds — Defconfig workflow for consistent, version-controlled image generation

Build Instructions

Requirements

  • Ubuntu 22.04 host (or compatible Linux distribution)
  • Git, build-essential, and standard Buildroot dependencies
  • microSD card (4GB+) and card reader

Steps

# Clone Buildroot
git clone https://github.com/buildroot/buildroot.git
cd buildroot

# Copy custom package into Buildroot tree
cp -r ../embedded_linux/package/sysinfo package/
echo 'source "package/sysinfo/Config.in"' >> package/Config.in

# Apply defconfig
cp ../embedded_linux/configs/beaglebone_defconfig configs/
make beaglebone_defconfig

# Build entire image (takes 1-2 hours first time)
make -j$(nproc)

# Flash to microSD (replace sdX with your device)
sudo dd if=output/images/sdcard.img of=/dev/sdX bs=4M status=progress

Project Structure

embedded_linux/
├── configs/
│   └── beaglebone_defconfig       # Full Buildroot configuration (kernel, U-Boot, packages)
├── package/
│   └── sysinfo/
│       ├── Config.in              # Registers package in Buildroot menuconfig
│       ├── sysinfo.mk            # Build rules, install targets, systemd integration
│       └── files/
│           ├── sysinfo.c         # C binary — sysinfo() syscall + /proc parsing
│           ├── sysinfo.sh        # Shell script — userspace tool approach
│           ├── Makefile          # Cross-compilation build rules
│           ├── sysinfo.service   # systemd oneshot unit (C binary)
│           ├── sysinfo-sh.service # systemd oneshot unit (shell script)
│           └── etc/systemd/
│               └── journald.conf # Persistent journal configuration
├── LICENSE
└── README.md

Sample Boot Output

Serial console output after boot (via journalctl -u sysinfo --no-pager):

============================================
      BeagleBone Black System Info
         [ C BINARY VERSION ]
============================================

[Hostname]
buildroot

[Kernel]
6.18.21

[CPU]
Hardware	: Generic AM33XX (Flattened Device Tree)
Cores: 1

[Memory — Exact]
Total:   519438336 bytes  (495 MB)
Used:    38281216 bytes  (36 MB)
Free:    481157120 bytes  (458 MB)
Shared:  0 bytes  (0 MB)
Buffers: 3145728 bytes  (3 MB)

[Uptime]
0 days, 00:00:12

[Load Averages]
1 min:  0.48
5 min:  0.12
15 min: 0.04

[Processes]
Running: 47

[Disk]
Root device: /dev/mmcblk0p2

[Network]
Interface found: eth0

============================================

Viewing Output on Target

Both services run automatically and output is visible on the serial console and readable anytime via journalctl:

journalctl -u sysinfo --no-pager
journalctl -u sysinfo-sh --no-pager

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors