@@ -18,7 +18,7 @@ fixed_rustflags := '-D warnings -Z macro-backtrace'
1818
1919qemu := env (' QEMU' , ' qemu-system-aarch64' )
2020qemu_machine := env (' QEMU_MACHINE' , ' raspi3b' )
21- gdb := env (' GDB' , ' aarch64-elf-gdb' )
21+ gdb := env (' GDB' , ' aarch64-elf-gdb' ) # An aarch64-enabled GDB (brew install aarch64-elf-gdb)
2222objcopy := ' rust-objcopy'
2323nm := ' rust-nm'
2424volume := env (' VOLUME' , ' /Volumes/BOOT' )
@@ -42,6 +42,9 @@ gdb_connect := justfile_directory() / 'target' / target / 'gdb-connect'
4242
4343openocd_bin := env (' OPENOCD' , ' /usr/local/opt/openocd/4d6519593-rtt/bin/openocd' )
4444
45+ ok_label := ' ✅'
46+ copy_label := ' 🔄'
47+
4548_ default :
4649 @ just --list
4750
@@ -58,11 +61,12 @@ _cross-build crate board='rpi4' linker_script='' features='':
5861
5962# === Kernel (nucleus + init_thread -> kernel.bin) ===
6063
61- # Build kernel for hardware (features: '' for hw, 'qemu' for emulation)
64+ # Build kernel (features: '' for hw, 'qemu' for emulation)
6265[group (" hw" )]
6366build board = ' rpi4' features = ' ': (_cross-build ' nucleus' board nucleus_link features) (_cross-build ' init_thread' board init_link features)
6467 {{ objcopy }} --strip-all -O binary {{ kernel_elf }} {{ kernel_bin }}
65- @ echo " kernel built for {{ board }}{{ if features != ' ' { ' [' + features + ' ]' } else { ' ' } }} "
68+ @ # TODO: print final binary size!
69+ @ echo " {{ ok_label}} kernel built for {{ board }}{{ if features != ' ' { ' [' + features + ' ]' } else { ' ' } }} "
6670
6771alias b := build
6872
@@ -72,14 +76,14 @@ alias b := build
7276[group (" hw" )]
7377build-chainboot board = ' rpi4' features = ' ': (_cross-build ' chainboot' board chainboot_link features)
7478 {{ objcopy }} --strip-all -O binary {{ chainboot_elf }} {{ chainboot_bin }}
75- @ echo " chainboot built for {{ board }}{{ if features != ' ' { ' [' + features + ' ]' } else { ' ' } }} "
79+ @ echo " {{ ok_label }} chainboot built for {{ board }}{{ if features != ' ' { ' [' + features + ' ]' } else { ' ' } }} "
7680
7781# === Chainofcommand (host tool) ===
7882
7983# Build chainofcommand serial loader
8084[group (" hw" )]
8185chainofcommand :
82- cargo build -p chainofcommand
86+ @ cargo build -p chainofcommand
8387
8488alias coc := chainofcommand
8589
@@ -88,21 +92,33 @@ alias coc := chainofcommand
8892# Build and run kernel in QEMU
8993[group (" emu" )]
9094qemu : (build ' rpi3' ' qemu' )
95+ @ echo 🚜 Run QEMU {{ qemu_base_opts }} with {{ kernel_bin }}
96+ @ echo 🚜 .. on {{ rpi3_dtb }}
97+ @ rm -f qemu.log
9198 {{ qemu }} {{ qemu_base_opts }} -dtb " {{ rpi3_dtb }} " -kernel " {{ kernel_bin }} "
9299
93100# Build and run kernel in QEMU with GDB port
94101[group (" emu" )]
95102qemu-gdb : (build ' rpi3' ' qemu' )
103+ @ echo 🚜 Run QEMU {{ qemu_base_opts }} {{ qemu_disasm_gdb }} with {{ kernel_bin }}
104+ @ echo 🚜 .. on {{ rpi3_dtb }}
105+ @ rm -f qemu.log
96106 {{ qemu }} {{ qemu_base_opts }} {{ qemu_disasm_gdb }} -dtb " {{ rpi3_dtb }} " -kernel " {{ kernel_bin }} "
97107
98108# Build and run chainboot in QEMU
99109[group (" emu" )]
100110cb-qemu : (build-chainboot ' rpi3' ' qemu' )
111+ @ echo 🚜 Run QEMU {{ qemu_base_opts }} {{ qemu_disasm }} with {{ chainboot_bin }}
112+ @ echo 🚜 .. on {{ rpi3_dtb }}
113+ @ rm -f qemu.log
101114 {{ qemu }} {{ qemu_base_opts }} {{ qemu_disasm }} -serial pty -dtb " {{ rpi3_dtb }} " -kernel " {{ chainboot_bin }} "
102115
103116# Build and run chainboot in QEMU with GDB port
104117[group (" emu" )]
105118cb-qemu-gdb : (build-chainboot ' rpi3' ' qemu' )
119+ @ echo 🚜 Run QEMU {{ qemu_base_opts }} {{ qemu_disasm_gdb }} with {{ chainboot_bin }}
120+ @ echo 🚜 .. on {{ rpi3_dtb }}
121+ @ rm -f qemu.log
106122 {{ qemu }} {{ qemu_base_opts }} {{ qemu_disasm_gdb }} -serial pty -dtb " {{ rpi3_dtb }} " -kernel " {{ chainboot_bin }} "
107123
108124# === Zellij (QEMU in split terminal) ===
@@ -145,14 +161,16 @@ _write-gdb-config:
145161 cat > " {{ gdb_connect }} " <<EOF
146162 target extended-remote :5555
147163 break *0x80000
148- break kernel_init
149- break kernel_main
164+ break main
165+ break init_thread_run
166+ break cap_invoke_handler
150167 EOF
168+ @ echo 🖌️ Generated GDB config file {{ gdb_connect }}
151169
152170# Build and run kernel in GDB (connect to openocd or QEMU on port 5555)
153171[group (" debug" )]
154172gdb : build _write-gdb-config
155- pipx run gdbgui -g " {{ gdb }} -x {{ gdb_connect }} {{ kernel_elf }} "
173+ @ pipx run gdbgui -g " {{ gdb }} -x {{ gdb_connect }} {{ kernel_elf }} "
156174
157175# Build and run chainboot in GDB
158176[group (" debug" )]
@@ -165,7 +183,7 @@ cb-gdb: build-chainboot _write-gdb-config
165183[group (" hw" )]
166184device : build
167185 cp {{ kernel_bin }} {{ volume }} / kernel8.img
168- @ echo " Copied kernel to {{ volume }} /kernel8.img"
186+ @ echo " {{ copy_label }} copied kernel to {{ volume }} /kernel8.img"
169187
170188# Build and write kernel to SD Card, then eject
171189[group (" hw" )]
@@ -176,13 +194,13 @@ device-eject: device
176194[group (" hw" )]
177195cb-eject : build-chainboot
178196 cp {{ chainboot_bin }} {{ volume }} / chain_boot_rpi4.img
179- @ echo " Copied chainboot to {{ volume }} /chain_boot_rpi4.img"
197+ @ echo " {{ copy_label }} copied chainboot to {{ volume }} /chain_boot_rpi4.img"
180198 diskutil ejectAll {{ volume }}
181199
182200# Build and boot via chainofcommand
183201[group (" hw" )]
184202boot : build chainofcommand
185- @ echo " Run: target/debug/chainofcommand {{ chainboot_serial }} {{ chainboot_baud }} --kernel target/kernel.bin"
203+ target/ debug/ chainofcommand {{ chainboot_serial }} {{ chainboot_baud }} --kernel target/ kernel.bin
186204
187205# === Openocd ===
188206
@@ -199,7 +217,8 @@ alias ocd := openocd
199217[group (" emu" )]
200218test :
201219 RUSTFLAGS=" {{ fixed_rustflags }} {{ board_rpi3_flags }} " \
202- cargo test {{ target_json }} --features=qemu {{ rust_std }}
220+ cargo test --verbose {{ target_json }} --features=qemu {{ rust_std }}
221+ # ^ coc tests should be with std...
203222
204223# Test runner invoked by .cargo/config.toml runner
205224[private ]
@@ -209,9 +228,8 @@ _test-runner binary_path:
209228 name=$(basename " {{ binary_path }} " )
210229 bin=" {{ justfile_directory () }} /target/${name}.bin"
211230 {{ objcopy }} --strip-all -O binary " {{ binary_path }} " " ${bin}"
212- echo " Running test: ${name}"
213- {{ qemu }} {{ qemu_base_opts }} {{ qemu_test_opts }} \
214- - dtb " {{ rpi3_dtb }} " -kernel " ${bin}"
231+ @ echo " 🚨 Running test: ${name}"
232+ {{ qemu }} {{ qemu_base_opts }} {{ qemu_test_opts }} -dtb " {{ rpi3_dtb }} " -kernel " ${bin}"
215233
216234# === Clippy ===
217235
@@ -259,7 +277,7 @@ expand:
259277# Generate and open documentation
260278[group (" maintenance" )]
261279doc :
262- cargo doc --open --no-deps {{ target_json }}
280+ cargo doc --open --no-deps {{ target_json }} {{ rust_std }}
263281
264282# Clean project
265283[group (" maintenance" )]
@@ -336,6 +354,9 @@ orphans mod:
336354# Prepare local dev tools and set-up git hooks
337355[group (" maintenance" )]
338356setup-local-dev :
339- commit-emoji --help || cargo install commit-emoji
357+ which cargo-binstall || cargo install cargo-binstall
358+ commit-emoji --help || cargo binstall -y commit-emoji
340359 commit-emoji -i
341- cp .hooks/ pre-push .git/ hooks/ pre-push
360+ cargo binstall -y cargo-binutils
361+ # todo install rustfilt, what else?
362+ # install pre-push git hook with `just pre-push`
0 commit comments