Skip to content

Commit 22b8a83

Browse files
committed
basic configuration and documentation
1 parent 65c927b commit 22b8a83

File tree

7 files changed

+4596
-0
lines changed

7 files changed

+4596
-0
lines changed

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Buildroot for TinyEMU
2+
3+
This repo is a quick getting started guide on how to build kernel and rootfs using Buildroot for TinyEMU
4+
5+
The current configuration is a minimal kernel with no networking, though it should be easy to change.
6+
7+
If you're not ready to build your own, you can start get a ready made kernel, rootfs and bbl from [TinyEMU](https://bellard.org/tinyemu/), at the bottom there's [diskimage-linux-riscv-2018-09-23.tar.gz](https://bellard.org/tinyemu/diskimage-linux-riscv-2018-09-23.tar.gz).
8+
9+
# BBL - Berkely boot loader
10+
To build BBL, you'll find the patches needed for [RISC-V Proxy Kernel](https://github.com/riscv-software-src/riscv-pk) in [diskimage-linux-riscv-2018-09-23.tar.gz](https://bellard.org/tinyemu/diskimage-linux-riscv-2018-09-23.tar.gz).
11+
12+
# Getting Started
13+
14+
## Building the docker image
15+
```
16+
docker build -t buildroot .
17+
```
18+
19+
## Running the docker image
20+
```
21+
docker run -it buildroot
22+
```
23+
24+
At this point you have a ready made machine to start building your rootfs and kernel:
25+
```
26+
make -j 5
27+
```
28+
29+
Once its done, you'll find 2 files in output/images:
30+
```
31+
~/buildroot-2022.05# ls -l output/images
32+
total 10252
33+
-rw-r--r-- 1 root root 2172016 Jul 12 11:36 Image
34+
-rw-r--r-- 1 root root 20971520 Jul 12 11:36 rootfs.ext2
35+
```
36+
37+
Now we want to copy them into our virtual riscv machine:
38+
```
39+
docker cp <container id>:/root/buildroot-2022.05/output/images/Image kernel32.bin
40+
docker cp <container id>:/root/buildroot-2022.05/output/images/rootfs.ext2 rootfs32.bin
41+
```
42+
43+
Make sure you have bbl32.bin and TinyEMU configuration file:
44+
```
45+
/* VM configuration file */
46+
{
47+
version: 1,
48+
machine: "riscv32",
49+
memory_size: 12,
50+
bios: "bbl32.bin",
51+
kernel: "kernel32.bin",
52+
cmdline: "console=hvc0 debug ignore_loglevel earlycon=sbi root=/dev/vda rw",
53+
drive0: { file: "rootfs32.bin" }
54+
}
55+
```
56+
57+
And you're ready to go, either copy it to your SD card under /emu or run tinyemu from the command line
58+
```
59+
<tinyemu executable> riscv32.cfg
60+
```
61+
62+
If you choose to run it on ESP32 through my [esp32-tinyemu](https://github.com/drorgl/esp32-tinyemu), you'll see something very similar to this:
63+
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/f3a3xeTRj_A/0.jpg)](https://www.youtube.com/watch?v=f3a3xeTRj_A)
64+
65+
# Quick Cheat Sheet for Buildroot
66+
configure buildroot:
67+
```
68+
make menuconfig
69+
```
70+
71+
configure busybox:
72+
```
73+
make busybox-menuconfig
74+
```
75+
76+
configure kernel:
77+
```
78+
make linux-menuconfig
79+
```
80+
81+
rebuild whole system:
82+
```
83+
make clean all -j 5
84+
```
85+
86+
persist your buildroot configuration:
87+
```
88+
make savedefconfig
89+
docker cp <container id>:/root/buildroot-2022.05/buildroot_rv32_config buildroot_config/buildroot_rv32_config
90+
```
91+
92+
persist your kernel configuration:
93+
```
94+
make linux-update-defconfig
95+
docker cp <container id>:/root/buildroot-2022.05/linux_rv32_config buildroot_config/linux_rv32_config
96+
```
97+
98+
persist your busybox configuration:
99+
```
100+
make busybox-update-config
101+
docker cp <container id>:/root/buildroot-2022.05/busybox_config buildroot_config/busybox_config
102+
```
103+
104+
# Notes
105+
* This docker image was customized to use axel to download each dependency with multiple connections, you might not need it on your network.
106+
* The configured overlay skips init and goes straight to bash, you'll need to remove it to work with getty (BR2_ROOTFS_OVERLAY and BR2_TARGET_GENERIC_GETTY_OPTIONS)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
BR2_riscv=y
2+
BR2_RISCV_32=y
3+
BR2_WGET="axel -n 10 "
4+
BR2_TOOLCHAIN_EXTERNAL=y
5+
BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
6+
BR2_TARGET_GENERIC_GETTY_OPTIONS="-n -L -l /bin/sh"
7+
BR2_ROOTFS_OVERLAY="rootfs_overlay"
8+
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh"
9+
BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)"
10+
BR2_LINUX_KERNEL=y
11+
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
12+
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.18.7"
13+
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
14+
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="linux_rv32_config"
15+
BR2_PACKAGE_BUSYBOX_CONFIG="busybox_config"
16+
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
17+
# BR2_PACKAGE_URANDOM_SCRIPTS is not set
18+
BR2_PACKAGE_NANO=y
19+
BR2_TARGET_ROOTFS_EXT2=y
20+
BR2_TARGET_ROOTFS_EXT2_SIZE="20M"
21+
# BR2_TARGET_ROOTFS_TAR is not set
22+
BR2_TARGET_OPENSBI=y
23+
BR2_TARGET_OPENSBI_PLAT="generic"
24+
# BR2_TARGET_OPENSBI_INSTALL_DYNAMIC_IMG is not set
25+
# BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set
26+
BR2_PACKAGE_HOST_MKPASSWD=y

0 commit comments

Comments
 (0)