The forum was quiet this week, so we published a complete hands-on tutorial instead: compiling OpenWrt 23.05 from source for the SpacemiT K1 and flashing it to SD card and eMMC, covering build-host setup, menuconfig, fastboot partition maps, and first-boot verification.
Prebuilt images get you started, but compiling your own firmware is where real product development begins:
The SpacemiT K1 is an ideal target: eight X60 RISC-V cores at 1.6 GHz (50K DMIPS), a 2 TOPS NPU, and two Gigabit RGMII MACs - a serious platform for industrial gateways running OpenWrt 23.05, which defaults to nftables and ships with mwan3, tc, and tcpdump support.
Use an x86_64 Linux host (Ubuntu 22.04 is well tested) with at least 50 GB of free disk space, 8 GB of RAM, and a reasonably fast internet connection. Install the standard OpenWrt build dependencies:
sudo apt update sudo apt install -y build-essential clang flex bison g++ gawk gcc-multilib \ gettext git libncurses5-dev libssl-dev rsync unzip zlib1g-dev \ file wget curl swig python3-devCross-compiling for RISC-V happens entirely on the host CPU, so even a modest machine works - it is just slower. A first build takes roughly 30-60 minutes on an 8-core machine; incremental rebuilds after small changes finish in 1-2 minutes.
Obtain the K1 OpenWrt 23.05 SDK from your vendor repository (the URL ships with the K1 SoM or development-board SDK package):
git clone <vendor-openwrt-sdk-url> k1-openwrt cd k1-openwrtThen refresh the package feeds:
./scripts/feeds update -a ./scripts/feeds install -aThe vendor SDK already carries the SpacemiT target definitions, K1 device trees, and board-specific integration patches (FSBL, OpenSBI, and U-Boot), which is what makes the K1 a first-class OpenWrt citizen rather than a porting project.
Launch the menu-based configurator:
make menuconfig Navigate to Target System, select SpacemiT, then pick the K1 subtarget and the profile matching your board. While you are there:Save your configuration as .config, and keep a copy in version control. It is the single most important build artifact for reproducibility.
make -j$(nproc) V=s
The V=s flag streams every command so you can see exactly where a failure happens. On the first run the build system downloads and compiles the RISC-V GCC toolchain, then the kernel, then packages, and finally assembles the firmware images. Everything lands in:bin/targets/spacemit/k1/
You will find the combined SD-card image plus the individual eMMC partition images (FSBL, U-Boot, boot, and rootfs).Insert a microSD card (8 GB or larger), identify its device node, and write the combined image:
# identify the card - assume /dev/sdX, double-check before running lsblk gunzip openwrt-spacemit-k1-*.img.gz sudo dd if=openwrt-spacemit-k1-*.img of=/dev/sdX bs=4M conv=fsync status=progressInsert the card, power the board, and connect the debug serial console (3.3 V TTL, 115200 baud, 8N1). Within seconds you should see U-Boot hand off to the kernel and OpenWrt boot to a shell. Plug into the LAN port and reach LuCI or SSH at 192.168.1.1.
For production units you want firmware in the onboard eMMC. Put the board into USB download mode (hold the BOOT button while applying power - the K1 enumerates in MaskROM/fastboot mode), then flash partition by partition:
fastboot flash fsbl fsbl.bin fastboot flash env env.bin fastboot flash opensbi opensbi.bin fastboot flash uboot u-boot.itb fastboot flash boot boot.ext4 fastboot flash rootfs rootfs.ext4 fastboot rebootPartition names follow the vendor partition table; check the SDK flashing script for your board's exact map. eMMC flashing is what you want for vibration-prone industrial deployments, where an SD card socket is a reliability liability.
Run through this checklist on every new build:
Note the dual-RGMII topology: each K1 MAC typically hangs off its own PHY or switch (for example a YT9152S), giving you two physically isolated Ethernet domains - the foundation for the mwan3 multi-WAN load-balancing setup we published in Week 37.
| Symptom | Likely cause | Fix |
|---|---|---|
| No serial output | Wrong baud or TX/RX swapped | 115200 8N1, swap RX/TX |
| make menuconfig errors | Missing host deps | Re-run the apt install line |
| Build fails in toolchain | Out of disk or RAM | 50 GB free, add swap, lower -j |
| fastboot: no device | Not in download mode | Hold BOOT during power-up |
| No rootfs after flash | Wrong partition map | Match the SDK flashing script |
| Both ports on same LAN | Device-tree port roles | Check DTS wan/lan assignment |
Got a topic you want covered? Post it on the Open RISC-V forum - the best threads become the next digest.