Skip to content

Commit 963e36f

Browse files
Merge pull request #297 from smartobjectoriented/feat/st-display-flag
scripts: fold stg.sh into st.sh via a -d (display) flag
2 parents 32953c8 + bf39da6 commit 963e36f

11 files changed

Lines changed: 63 additions & 172 deletions

File tree

doc/source/build_system.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ Everything is anchored on the repository root. Source ``env.sh`` once per shell:
7171
7272
This exports ``IB_ROOT_DIR``, sets ``BBPATH``/``BUILDDIR`` to ``build/``, and
7373
prepends ``scripts/`` and the bundled ``bitbake`` to ``PATH`` so the active tree
74-
wins. From then on the ``build.sh`` / ``deploy.sh`` / ``st.sh`` / ``stg.sh``
75-
commands are on the path. See :ref:`user_guide` for the end-to-end walkthrough.
74+
wins. From then on the ``build.sh`` / ``deploy.sh`` / ``st.sh`` commands are on
75+
the path. See :ref:`user_guide` for the end-to-end walkthrough.
7676

7777
Meta-layers
7878
===========

doc/source/display_input.rst

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,23 @@ it once per refresh through the ``GET_STATE`` ioctl, and the driver scales the r
143143
relative PL050 mouse (``kmi1.c``) is kept in the tree but its dts node is
144144
``status = "disabled"`` so there is a single ``/dev/mouse``.
145145

146-
The host GTK window (``stg.sh``)
147-
================================
146+
The host GTK window (``st.sh -d``)
147+
==================================
148148

149-
The graphical launcher ``stg.sh`` starts QEMU with the **GTK** display
150-
backend (``-display gtk,zoom-to-fit=off``):
149+
By default ``st.sh`` is headless (``-display none``): no window, serial console
150+
only, used for non-graphical work and CI. Pass **-d** to open the QEMU **GTK**
151+
window that presents the guest PL111 CLCD (``-display gtk,zoom-to-fit=off``):
151152

152153
* **GTK, not SDL** — the SDL backend does not present the PL111 console surface
153154
(the window stays black even though the framebuffer is rendered correctly);
154155
GTK shows it, and its *View* menu lists every console.
155-
* **XWayland for HiDPI** — ``stg.sh`` exports ``GDK_BACKEND=x11`` (plus
156-
``GDK_SCALE=1``). On a fractionally-scaled HiDPI **Wayland** panel, GTK reports
157-
pointer coordinates in a different scale than the framebuffer surface, so the
158-
absolute mapping comes out *offset* (host and guest cursors shifted) — fine on a
159-
1× external monitor, wrong on the laptop panel. Routing GTK through XWayland
160-
gives a uniform pointer-to-surface mapping, so the cursors coincide on every
161-
monitor. It is harmless on a native X11 session.
162-
163-
``st.sh`` is the headless sibling (``-display none``): no window, console
164-
only, used for non-graphical work and CI.
156+
* **XWayland for HiDPI** — with ``-d``, ``st.sh`` exports ``GDK_BACKEND=x11``
157+
(plus ``GDK_SCALE=1``). On a fractionally-scaled HiDPI **Wayland** panel, GTK
158+
reports pointer coordinates in a different scale than the framebuffer surface,
159+
so the absolute mapping comes out *offset* (host and guest cursors shifted) —
160+
fine on a 1× external monitor, wrong on the laptop panel. Routing GTK through
161+
XWayland gives a uniform pointer-to-surface mapping, so the cursors coincide on
162+
every monitor. It is harmless on a native X11 session.
165163

166164
.. _console_sigint:
167165

doc/source/img/gen_so3_diagrams.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def xml(self):
348348
dep = p.box(420, 420, 250, 64,
349349
"scripts/deploy.sh bsp-so3\n→ sdcard FAT (+ flash0.img)", WHITE, 10)
350350
run = p.box(770, 420, 270, 64,
351-
"scripts/st.sh / stg.sh\n→ QEMU (EL1 / EL2 / ATF)", WHITE, 10)
351+
"scripts/st.sh [-d]\n→ QEMU (EL1 / EL2 / ATF)", WHITE, 10)
352352
# the band feeds do_itb: drop from the band's lower-left border straight down.
353353
p.edge(rec, itb, "", ARR + "exitX=0.15;exitY=1;entryX=0.5;entryY=0;")
354354
p.edge(itb, dep, "", ARR + "exitX=1;exitY=0.5;entryX=0;entryY=0.5;")
@@ -379,7 +379,7 @@ def xml(self):
379379
qmsd = p.box(430, 320, 280, 44, "pl050 mouse @ 0x08802000 (disabled)", NONE, 9)
380380
quart= p.box(430, 380, 280, 46, "pl011 UART @ 0x09000000 (SPI 1)", HW, 9)
381381
# Host column
382-
p.box(780, 60, 300, 470, "Host (scripts/stg.sh)", CONT, 12, 1)
382+
p.box(780, 60, 300, 470, "Host (scripts/st.sh -d)", CONT, 12, 1)
383383
hwin = p.box(810, 110, 240, 80, "GTK window\n-display gtk,zoom-to-fit=off\nGDK_BACKEND=x11 (HiDPI/Wayland)", NEUTRAL, 9)
384384
hptr = p.box(810, 250, 240, 64, "host pointer → absolute\n1:1 mapping, no grab / no warp", NEUTRAL, 9)
385385
hterm= p.box(810, 380, 240, 46, "terminal (-serial mon:stdio)", NEUTRAL, 9)

doc/source/img/so3.drawio

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

doc/source/img/so3_build.png

3.21 KB
Loading

doc/source/img/so3_io.png

402 Bytes
Loading

doc/source/lvgl.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ Running LVGL under QEMU
8383
=======================
8484

8585
Build the user space with the LVGL applications and a framebuffer-enabled kernel
86-
configuration, then launch the **graphical** emulator (the framebuffer needs a
87-
real window):
86+
configuration, then launch the emulator in **graphical** mode with ``-d`` (the
87+
framebuffer needs a real window):
8888

8989
.. code-block:: bash
9090
91-
stg.sh
91+
st.sh -d
9292
9393
QEMU opens a GTK window that shows the PL111 framebuffer; launch an LVGL
9494
application from the ``so3%`` prompt to draw into it, for example::

doc/source/user_guide.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The most relevant top-level directories are::
3434

3535
so3/ # the SO3 kernel (so3/so3) and user space (so3/usr), plus dts
3636
build/ # the Infrabase build: meta-* layers, conf/local.conf, bitbake work tree
37-
scripts/ # build.sh, deploy.sh, st.sh, stg.sh, updiff.sh, …
37+
scripts/ # build.sh, deploy.sh, st.sh, updiff.sh, …
3838
filesystem/ # the virtual SD-card image used by QEMU
3939
u-boot/ # fetched U-Boot (patched)
4040
qemu/ # fetched QEMU (patched) -> qemu/build/qemu-system-*
@@ -105,12 +105,12 @@ Launch scripts
105105
:header-rows: 1
106106
:widths: 16 84
107107

108-
* - Script
108+
* - Command
109109
- Use
110110
* - ``st.sh``
111111
- **headless** run (``-display none``) — serial console only. The default for
112112
non-graphical work and CI.
113-
* - ``stg.sh``
113+
* - ``st.sh -d``
114114
- **graphical** run — a GTK window for the PL111 framebuffer (LVGL, ``fb_test``).
115115
See :ref:`display_input`.
116116

docker/scripts/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ fi
4040

4141
# This launcher boots a STANDALONE SO3 image at EL1 (plain -M virt). It cannot
4242
# boot an AVZ (EL2 hypervisor) or an ATF/flash0 (EL3) deployment — those need
43-
# QEMU started with virtualization=on / secure=on, which scripts/st.sh and
44-
# scripts/stg.sh select from the deployed ITS. The lv_perf images deploy a
43+
# QEMU started with virtualization=on / secure=on, which scripts/st.sh selects
44+
# from the deployed ITS. The lv_perf images deploy a
4545
# standalone ITS, so this guard only ever trips when run by hand on a host tree
4646
# configured for AVZ/ATF.
4747
SO3_ITS=$(grep -E "^IB_TARGET_ITS:so3:${PLATFORM}\b" build/conf/local.conf 2>/dev/null \
@@ -55,7 +55,7 @@ if [ -n "$why" ]; then
5555
echo "Error: the deployment is not standalone — $why." >&2
5656
echo " run.sh boots SO3 standalone at EL1 only. For an AVZ (EL2) or ATF" >&2
5757
echo " (EL3) build, use the host launchers instead, which select the EL" >&2
58-
echo " from the ITS: scripts/st.sh (headless) / scripts/stg.sh (GTK)." >&2
58+
echo " from the ITS: scripts/st.sh (headless) / scripts/st.sh -d (GTK)." >&2
5959
exit 1
6060
fi
6161

scripts/st.sh

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212

1313
QEMU_AUDIO_DRV="none"
1414
GDB_PORT_BASE=1234
15+
16+
# Parse our own options (currently just -d) out of the argument list before
17+
# what's left is forwarded to QEMU as USR_OPTION.
18+
WITH_DISPLAY=0
19+
POSARGS=()
20+
for _a in "$@"; do
21+
case "$_a" in
22+
-d) WITH_DISPLAY=1 ;;
23+
-h|--help)
24+
echo "Usage: $(basename "$0") [-d] [qemu-option]"
25+
echo " -d graphical: open the QEMU GTK window showing the guest PL111/LVGL screen"
26+
echo " (default: headless, serial console only)"
27+
exit 0 ;;
28+
*) POSARGS+=("$_a") ;;
29+
esac
30+
done
31+
set -- "${POSARGS[@]}"
1532
USR_OPTION=$1
1633
# QEMU_BIN is selected per IB_PLATFORM below (qemu-system-aarch64 for
1734
# virt64, qemu-system-arm for virt32).
@@ -46,6 +63,24 @@ launch_qemu() {
4663
SO3_ITS=$(grep -E "^IB_TARGET_ITS:so3:${IB_PLATFORM}\b" build/conf/local.conf | awk -F'"' '{print $2}' | tail -1)
4764
LINUX_ITS=$(grep -E "^IB_TARGET_ITS:linux:${IB_PLATFORM}\b" build/conf/local.conf | awk -F'"' '{print $2}' | tail -1)
4865

66+
# Display mode. Default: headless (serial console only, -display none). With
67+
# -d: open the QEMU GTK window that presents the guest PL111 CLCD (the LVGL
68+
# screen). SO3 drives PL111 + PL050 (wired unconditionally into '-M virt' by
69+
# the so3 QEMU patch) and has no virtio-gpu, so no extra device flags are
70+
# needed — just switch the display backend. Use GTK, not SDL: SDL leaves the
71+
# PL111 console black, GTK presents it (and its View menu lists every
72+
# console). On a fractionally-scaled HiDPI Wayland panel, route GTK through
73+
# XWayland (GDK_BACKEND=x11) so the so3,absmouse absolute pointer maps 1:1
74+
# onto the guest surface; harmless on a real X11 session.
75+
if [ "$WITH_DISPLAY" == "1" ]; then
76+
DISPLAY_OPT="-display gtk,zoom-to-fit=off"
77+
export GDK_BACKEND=x11
78+
export GDK_SCALE=1
79+
export GDK_DPI_SCALE=1
80+
else
81+
DISPLAY_OPT="-display none"
82+
fi
83+
4984
if [ "$IB_PLATFORM" == "virt64" ]; then
5085
QEMU_BIN="$IB_ROOT_DIR/qemu/build/qemu-system-aarch64"
5186
echo Starting on virt64
@@ -97,7 +132,7 @@ launch_qemu() {
97132
-device virtio-blk-device,drive=hd0 \
98133
-drive if=none,file=filesystem/sdcard.img.virt64,id=hd0,format=raw,file.locking=off \
99134
-m 1024 \
100-
-display none \
135+
${DISPLAY_OPT} \
101136
-netdev user,id=n1,hostfwd=tcp::2222-:22 \
102137
-device virtio-net-device,netdev=n1,mac=${QEMU_MAC_ADDR} \
103138
-gdb tcp::${GDB_PORT}
@@ -120,7 +155,7 @@ launch_qemu() {
120155
-device virtio-blk-device,drive=hd0 \
121156
-drive if=none,file=filesystem/sdcard.img.virt32,id=hd0,format=raw,file.locking=off \
122157
-m 1024 \
123-
-display none \
158+
${DISPLAY_OPT} \
124159
-netdev user,id=n1,hostfwd=tcp::2222-:22 \
125160
-device virtio-net-device,netdev=n1,mac=${QEMU_MAC_ADDR} \
126161
-gdb tcp::${GDB_PORT}

0 commit comments

Comments
 (0)