nd100x

# 🛠️ Risc-V linux Build Setup

This project supports building to Risc-V for running in Linux on a tiny Risc-V device.

This is tested on the $5 Milk-V Duo product: https://milkv.io/

✅ Prerequisites

The build requires the Milk-V Duo toolchain.

Follow this description to download and install the toolchain.

You need to manually download the toolchain host-tools and extract it to the SDK root directory:

cd ~
wget https://sophon-file.sophon.cn/sophon-prod-s3/drive/23/03/07/16/host-tools.tar.gz
tar xvf host-tools.tar.gz
cd host tools
export PATH=$PATH:$(pwd)/gcc/riscv64-linux-musl-x86_64/bin

export PATH=$PATH:/home/<your-home>/milkv/host-tools/gcc/riscv64-linux-musl-x86_64/bin

✅ Build

To build for RISC-V:

make riscv

This will use the toolchain file riscv64-toolchain.cmake which is configured to use:

✅ Build Configurations

By default, the build uses these compiler flags:

Other compiler toolchains that has been tested to compile but is not the correct for the Milk-V Duo board (but maybe a better choice for other devices)

✅ DAP Support

The RISC-V build includes DAP (Debug Adapter Protocol) support, enabling debugging with compatible tools. The build automatically:

✅ Custom Build

For a custom build with different compiler flags or configuration:

# Example: Build with optimization level 2
mkdir -p build_riscv_opt
cd build_riscv_opt
PATH="$PATH:/home/ronny/milkv/host-tools/gcc/riscv64-linux-musl-x86_64/bin" \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_RISCV=ON \
      -DCMAKE_TOOLCHAIN_FILE=../riscv64-toolchain.cmake \
      -DCMAKE_C_FLAGS="-march=rv64gc -mabi=lp64d -O2" ..
make -j$(nproc)

📱 Milk-V Duo Deployment

Getting started: https://milkv.io/docs/duo/getting-started
Documentation: https://milkv.io/docs
GitHub: https://github.com/milkv-duo
Example environment setup: https://github.com/milkv-duo/duo-examples/blob/main/envsetup.sh

Deploying to the Device

Connect to the device:

ssh root@192.168.42.1
mkdir -p nd

Copy the executable and disk images:

scp build_riscv/bin/nd100x images/SMD0.IMG FLOPPY.IMG root@192.168.42.1:/root/nd

Or just update the executable:

scp build_riscv/bin/nd100x root@192.168.42.1:/root/nd

Memory Limits

The Milk-V Duo with 64MB RAM seems to not like that I compiled nd100x using 16MB of RAM. It was killed of withing a few seconds.

The solution was to recompile the emulator to use only 8MB of RAM.

Debugging tips

Check DMSG

Look for lines like

Actual log: