Files
2026-06-15 19:20:24 +02:00

155 lines
3.0 KiB
Markdown

# Building Linux for ReviveSparc
This guide covers building and booting a Linux kernel on the ReviveSparc emulator.
## Supported Kernels
| Kernel Version | Status | Notes |
|----------------|--------|-------|
| 6.12+ | Full | All features working |
| 6.6 LTS | Full | Recommended for production |
| 6.1 LTS | Full | Older but stable |
| 5.15 LTS | Partial | No SMP support |
## Cross-Compilation Setup
Install a SPARC64 cross-compiler:
```bash
# Debian/Ubuntu
sudo apt install gcc-sparc64-linux-gnu
# Fedora
sudo dnf install cross-gcc-sparc64-linux-gnu
# Build from source (see toolchain guide)
./tools/build-toolchain.sh --target=sparc64-linux-gnu
```
## Building the Kernel
### Get the Source
```bash
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux
git checkout v6.12
```
### Apply ReviveSparc Patches
```bash
# From the ReviveSparc repository
./tools/apply-kernel-patches.sh /path/to/linux
```
### Configure
```bash
make ARCH=sparc64 CROSS_COMPILE=sparc64-linux-gnu- revivesparc_defconfig
```
Or customize:
```bash
make ARCH=sparc64 CROSS_COMPILE=sparc64-linux-gnu- menuconfig
```
### Build
```bash
make ARCH=sparc64 CROSS_COMPILE=sparc64-linux-gnu- -j$(nproc)
```
The kernel image is at `arch/sparc64/boot/image` and `vmlinux` (ELF).
## Building an Initramfs
Create a minimal root filesystem:
```bash
# Create a simple init script
cat > init << 'EOF'
#!/bin/busybox
/bin/busybox --install -s
mount -t proc proc /proc
mount -t sysfs sysfs /sys
echo "Welcome to ReviveSparc Linux!"
exec /bin/sh
EOF
# Create the initramfs
mkdir -p rootfs/{bin,proc,sys,dev,etc}
cp init rootfs/
cp /path/to/busybox rootfs/bin/
# Package it
cd rootfs
find . | cpio -H newc -o | gzip > ../initramfs.gz
```
## Booting
```bash
./sparc-emu \
-kernel vmlinux \
-initrd initramfs.gz \
-append "console=ttyS0,115200 root=/dev/ram rdinit=/init" \
-nographic
```
### Command-Line Options
| Option | Description |
|--------|-------------|
| `-kernel` | Path to the kernel vmlinux |
| `-initrd` | Path to the initramfs image |
| `-append` | Kernel command line |
| `-nographic` | No graphical output (serial console) |
| `-m` | Memory size (e.g., `-m 512M`) |
| `-smp` | Number of cores (e.g., `-smp 4`) |
| `-net` | Network backend (e.g., `-net user`) |
### Booting with Device Tree
ReviveSparc provides a device tree blob (DTB) for the emulated platform:
```bash
./sparc-emu \
-kernel vmlinux \
-dtb revivesparc.dtb \
-initrd initramfs.gz \
-append "console=ttyS0,115200" \
-nographic
```
## Building for NetBSD
```bash
# Build a SPARC64 NetBSD kernel
cd /usr/src
./build.sh -m sparc64 -U kernel=GENERIC
# Run under ReviveSparc
./sparc-emu \
-kernel netbsd-sparc64 \
-append "console=com0" \
-nographic
```
## Building for OpenBSD
```bash
# Build a SPARC64 OpenBSD kernel
cd /usr/src
make -C sys/arch/sparc64/conf GENERIC
config GENERIC
cd ../compile/GENERIC
make
# Run under ReviveSparc
./sparc-emu \
-kernel bsd.sparc64 \
-nographic
```