feat: Add zellij qemu runner with serial emulation
This commit is contained in:
parent
d706b2edac
commit
e6ddbb76e7
5
Justfile
5
Justfile
|
@ -1,3 +1,8 @@
|
|||
zellij:
|
||||
# Build and run kernel in QEMU with serial port emulation
|
||||
cargo make zellij-config
|
||||
zellij --layout-path emulation/layout.zellij
|
||||
|
||||
qemu:
|
||||
# Build and run kernel in QEMU
|
||||
cargo make qemu
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
zellij-config.sh
|
|
@ -0,0 +1,12 @@
|
|||
#########################################################
|
||||
# Welcome to the Raspi3 Emulation with #
|
||||
# MiniUart and PL011UART #
|
||||
# #
|
||||
# #
|
||||
# 1. Use the mouse to select different panes #
|
||||
# and interact with the UARTS. #
|
||||
# #
|
||||
# 2. To quit the emulation: #
|
||||
# 2.1 Select the pane in which QEMU runs (this one). #
|
||||
# 2.2 CTRL-C to close qemu. #
|
||||
#########################################################
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
template:
|
||||
direction: Horizontal
|
||||
parts:
|
||||
- direction: Vertical
|
||||
borderless: true
|
||||
split_size:
|
||||
Fixed: 1
|
||||
run:
|
||||
plugin:
|
||||
location: "zellij:tab-bar"
|
||||
- direction: Vertical
|
||||
body: true
|
||||
|
||||
tabs:
|
||||
- direction: Vertical
|
||||
parts:
|
||||
- direction: Horizontal
|
||||
borderless: true
|
||||
run:
|
||||
command:
|
||||
cmd: "bash"
|
||||
args: ["-c", "bash emulation/qemu_multi_uart.sh"]
|
||||
- direction: Horizontal
|
||||
parts:
|
||||
- direction: Vertical
|
||||
split_size:
|
||||
Percent: 30
|
||||
run:
|
||||
command:
|
||||
cmd: "bash"
|
||||
args: ["-c", "clear; echo -e \"\\033]0;MiniUart\\007\"; bash /dev/ptmx FIRST=1"]
|
||||
- direction: Vertical
|
||||
split_size:
|
||||
Percent: 70
|
||||
run:
|
||||
command:
|
||||
cmd: "bash"
|
||||
args: ["-c", "clear; echo -e \"\\033]0;PL011 Uart\\007\"; bash /dev/ptmx SECOND=1"]
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2018-2019 Berkus Decker <berkus+vesper@metta.systems>
|
||||
# Based on QEMU runner example by Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
echo -e "\033]0;QEMU\007"
|
||||
|
||||
clear
|
||||
cat emulation/instructions.txt
|
||||
|
||||
# Generated by `cargo make zellij-config`
|
||||
source emulation/zellij-config.sh
|
||||
|
||||
# Let the two other serials boot up
|
||||
sleep 1
|
||||
|
||||
FIRST_TTY=$(ps a | grep -e [F]IRST | awk '{ print $2 }')
|
||||
SECOND_TTY=$(ps a | grep -e [S]ECOND | awk '{ print $2 }')
|
||||
|
||||
FIRST_PID=$(ps a | grep -e [F]IRST | awk '{ print $1 }')
|
||||
SECOND_PID=$(ps a | grep -e [S]ECOND | awk '{ print $1 }')
|
||||
|
||||
function cleanup() {
|
||||
# Drop ptmx shells
|
||||
kill $FIRST_PID
|
||||
kill $SECOND_PID
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "=== Running QEMU with MiniUart ${FIRST_TTY} and PL011 Uart ${SECOND_TTY} ==="
|
||||
|
||||
${QEMU} ${QEMU_OPTS} ${QEMU_RUNNER_OPTS} -dtb ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/targets/bcm2710-rpi-3-b-plus.dtb -kernel ${KERNEL_BIN} -serial /dev/tty${SECOND_TTY} -serial /dev/tty${FIRST_TTY}
|
|
@ -0,0 +1,5 @@
|
|||
QEMU=
|
||||
QEMU_OPTS=
|
||||
QEMU_RUNNER_OPTS=
|
||||
CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=
|
||||
KERNEL_BIN=
|
|
@ -65,6 +65,21 @@ dependencies = ["build-qemu", "kernel-binary"]
|
|||
extend = "qemu-runner"
|
||||
env = { "QEMU_RUNNER_OPTS" = "${QEMU_SERIAL_OPTS}" }
|
||||
|
||||
[tasks.zellij-config]
|
||||
extend = "qemu-runner"
|
||||
script_runner = "@duckscript"
|
||||
env = { "ZELLIJ_CONFIG_FILE" = "../emulation/zellij-config.sh" }
|
||||
script = [
|
||||
'''
|
||||
writefile ${ZELLIJ_CONFIG_FILE} "QEMU=${QEMU}\n"
|
||||
appendfile ${ZELLIJ_CONFIG_FILE} "QEMU_OPTS=\"${QEMU_OPTS}\"\n"
|
||||
appendfile ${ZELLIJ_CONFIG_FILE} "QEMU_RUNNER_OPTS=${QEMU_RUNNER_OPTS}\n"
|
||||
appendfile ${ZELLIJ_CONFIG_FILE} "CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}\n"
|
||||
appendfile ${ZELLIJ_CONFIG_FILE} "KERNEL_BIN=${KERNEL_BIN}\n"
|
||||
'''
|
||||
]
|
||||
install_crate = { crate_name = "zellij", binary = "zellij", test_arg = ["--help"] }
|
||||
|
||||
[tasks.qemu-gdb]
|
||||
extend = "qemu-runner"
|
||||
env = { "QEMU_RUNNER_OPTS" = "${QEMU_SERIAL_OPTS} ${QEMU_GDB_OPTS}" }
|
||||
|
|
Loading…
Reference in New Issue