Cheat Sheet#
pw_kernel: Kernel experiments
rust_analyzer#
Generating rust-project.json#
For a given $CONFIG
in:
k_host
k_qemu_mps2_an505
k_rp2350
bazelisk run @rules_rust//tools/rust_analyzer:gen_rust_project -- --config $CONFIG //pw_kernel/...
Errors and warnings in VSCode#
Add this to Pigweed’s .vscode/settings.json
. Note that it only builds the
kernel targets to limit the amount of time that it takes to run. Substitute
$CONFIG
for the config chosen above.
"rust-analyzer.check.overrideCommand": [
"bazelisk",
"build",
"--config=$CONFIG",
"--@rules_rust//:error_format=json",
"//pw_kernel/..."
],
Build and Test#
Host#
Test#
bazelisk test --config k_host //pw_kernel/...
QEMU#
Supported QEMU platforms:
* k_qemu_mps2_an505
- a cortex-m33 based system
* k_qemu_virt_riscv32
- a riscv32 based system
Test#
bazelisk test --config k_qemu_mps2_an505 //pw_kernel/...
bazelisk test --config k_qemu_virt_riscv32 //pw_kernel/...
Run#
^A-x to exit qemu
bazelisk run --config k_qemu_mps2_an505 //pw_kernel:console
bazelisk run --config k_qemu_virt_riscv32 //pw_kernel:console
RP2350 Target Board#
Build#
bazelisk build --config k_rp2350 //pw_kernel/entry:kernel
Console —
bazelisk run --config k_rp2350 //pw_kernel:console -- -d <SERIAL_DEVICE>
Running the console will trigger a build of the kernel if required.
Flash#
probe-rs download --chip rp2350 bazel-bin/pw_kernel/entry/kernel && probe-rs reset
Note that any logging messages between boot and connecting a console to the device will be missed, so it’s best to start the console in one terminal first, before flashing the device. This will also ensure that the image that’s flashed to the device matches the image that’s being used to detokenize the logs.