Skip to content

Commit 8c4bacd

Browse files
committed
debug-boot-mode
Update batocera-boot.conf Update batocera-save-overlay update update Update batocera-version update Update S02resize Update init Update S01bootdebug debug-mode-update Restore buildroot submodule Delete buildroot
1 parent 1395de7 commit 8c4bacd

8 files changed

Lines changed: 99 additions & 14 deletions

File tree

board/batocera/fsoverlay/etc/init.d/S02resize

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ if grep -qE '^[ ]*autoresize[ ]*=[ ]*true[ ]*$' "${BOOTCONF}"; then
128128
)
129129

130130
# --- BEGIN RESIZE ---
131-
131+
132132
# Get /userdata partition details
133133
PART=$(batocera-part "share_internal")
134134
PARTNUM=$(batocera-part "share_internal_num")
135135
echo "Partition name: $PART & number: $PARTNUM" >> "$LOG"
136-
136+
137137
# Check the initial partition size
138138
PARTSIZE=$(get_partition_size_mb "$PART")
139139
echo "Initial partition size: ${PARTSIZE} MB" >> "$LOG"
140-
140+
141141
# Determine if we should format based on initial size
142142
FORMAT_ALLOWED=false
143143
if [ "$PARTSIZE" -eq 256 ] || [ "$PARTSIZE" -eq 512 ]; then
@@ -146,7 +146,7 @@ if grep -qE '^[ ]*autoresize[ ]*=[ ]*true[ ]*$' "${BOOTCONF}"; then
146146
else
147147
echo "Initial partition size is ${PARTSIZE}MB, formatting will be skipped" >> "$LOG"
148148
fi
149-
149+
150150
# boot disk
151151
DISK=$(batocera-part prefix "${PART}")
152152
echo "Disk = $DISK" >> "$LOG"
@@ -158,8 +158,8 @@ if grep -qE '^[ ]*autoresize[ ]*=[ ]*true[ ]*$' "${BOOTCONF}"; then
158158
PARTTYPE=$(blkid "${PART}" | sed -e s+'^.* TYPE="\([^"]*\)\".*'+'\1'+)
159159
test "${PARTTYPE}" != "ext4" && exit 0
160160
echo "Partition type = ${PARTTYPE}" >> "$LOG"
161-
162-
# textoutput "Message" "percentage" "command call"
161+
162+
# textoutput "Message" "percentage" "command call"
163163
for i in 1 3 5 7 9 11 13; do
164164
case $i in
165165
1)

board/batocera/fsoverlay/etc/init.d/S11share

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ mountDevicesOrNetwork() {
147147
do
148148
XWAIT=4 # N seconds between each try
149149
XTRY=$((MAXTRY / XWAIT)) # X tries and give up
150-
150+
151151
while [ "${XTRY}" -gt 0 ]
152152
do
153153
XTRY=$((XTRY-1))
@@ -394,6 +394,28 @@ case "${MODE}" in
394394
;;
395395
esac
396396

397+
# Debug boot mode
398+
# We wait for userdata to be mounted normally so we can move and bind mount roms and bios later
399+
DEBUG_FLAG="/boot/boot/bootmode.debug"
400+
if [ -f "$DEBUG_FLAG" ]; then
401+
echo "[DEBUG BOOT] Checking userdata..."
402+
403+
FSTYPE="$(awk '$2=="/userdata"{print $3}' /proc/mounts)"
404+
405+
if [ "$FSTYPE" = "tmpfs" ]; then
406+
echo "[DEBUG BOOT] /userdata is already tmpfs. Nothing to do..."
407+
else
408+
mkdir -p /userdata.real
409+
410+
echo "[DEBUG BOOT] Moving /userdata to /userdata.real"
411+
mount --move /userdata /userdata.real
412+
413+
echo "[DEBUG BOOT] Mounting new tmpfs as /userdata"
414+
415+
mountRAMDisk
416+
fi
417+
fi
418+
397419
# filesystem compression
398420
compressenabled="$(/usr/bin/batocera-settings-get system.fscompression.enabled)"
399421
if [ "$compressenabled" = "1" ]

board/batocera/fsoverlay/etc/init.d/S12populateshare

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ then
6969
do
7070
RELATIVE_PATH="${FILE#$IN/}"
7171
DEST_FILE="$OUT/$RELATIVE_PATH"
72-
72+
7373
# Check if the source file is newer than the destination file
7474
if [ "$FILE" -nt "$DEST_FILE" ]; then
7575
echo "Updating $DEST_FILE"
@@ -152,6 +152,23 @@ ln -sf /userdata/system/machine-id /etc/machine-id
152152
# save to avoid to redo that all the times
153153
cp /usr/share/batocera/batocera.version /userdata/system/data.version
154154

155+
# Debug boot mode:
156+
# Bind mount userdata.real/bios and userdata.real/roms to tmpfs userdata
157+
DEBUG_FLAG="/boot/boot/bootmode.debug"
158+
if [ -f "$DEBUG_FLAG" ]; then
159+
if [ -d /userdata.real/roms ]; then
160+
mkdir -p "${OUT}/roms"
161+
mount --bind /userdata.real/roms "${OUT}/roms"
162+
echo "[DEBUG BOOT] Binding /userdata.real/roms -> ${OUT}/roms"
163+
fi
164+
165+
if [ -d /userdata.real/bios ]; then
166+
mkdir -p "${OUT}/bios"
167+
mount --bind /userdata.real/bios "${OUT}/bios"
168+
echo "[DEBUG BOOT] Binding /userdata.real/bios -> ${OUT}/bios"
169+
fi
170+
fi
171+
155172
# call user script with start condition
156173
test -e /boot/postshare.sh && bash /boot/postshare.sh start
157174

package/batocera/boot/batocera-initramfs/init

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,18 @@ do_root() {
105105
# fill the overlay with the stored one
106106
if test -f /boot_root/boot/overlay
107107
then
108-
# the mount can fail if the fs was open in write and not correctly closed
109-
if mount -o ro /boot_root/boot/overlay /overlay_root/saved
110-
then
111-
cp -pr /overlay_root/saved/* /overlay_root/overlay || return 1
112-
umount /overlay_root/saved || return 1
113-
fi
108+
# check if debug boot is enabled, if so do not use saved overlay
109+
if test -f /boot_root/boot/bootmode.debug
110+
then
111+
echo "[DEBUG BOOT] Skipping saved overlay restore" > /dev/kmsg
112+
else
113+
# the mount can fail if the fs was open in write and not correctly closed
114+
if mount -o ro /boot_root/boot/overlay /overlay_root/saved
115+
then
116+
cp -pr /overlay_root/saved/* /overlay_root/overlay || return 1
117+
umount /overlay_root/saved || return 1
118+
fi
119+
fi
114120
fi
115121

116122
# mount the squashfs

package/batocera/core/batocera-scripts/batocera-scripts.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ define BATOCERA_SCRIPTS_INSTALL_TARGET_CMDS
8888
install -m 0755 $(BATOCERA_SCRIPTS_PATH)/scripts/batocera-storage-manager $(TARGET_DIR)/usr/bin/
8989
install -m 0755 $(BATOCERA_SCRIPTS_PATH)/scripts/batocera-storage-udev $(TARGET_DIR)/usr/bin/
9090
install -m 0755 $(BATOCERA_SCRIPTS_PATH)/scripts/batocera-keyboard $(TARGET_DIR)/usr/bin/
91+
install -m 0755 $(BATOCERA_SCRIPTS_PATH)/scripts/batocera-boot-debug $(TARGET_DIR)/usr/bin/
9192
endef
9293

9394
define BATOCERA_SCRIPTS_INSTALL_MOUSE
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
# Debug flag file needed for initramfs, and anything else that might need to know if debug mode is active.
4+
5+
DEBUG_FLAG="/boot/boot/bootmode.debug"
6+
7+
case "$1" in
8+
enable)
9+
mount -o remount,rw /boot 2>/dev/null
10+
touch "$DEBUG_FLAG"
11+
echo "[DEBUG BOOT] enabled"
12+
mount -o remount,ro /boot 2>/dev/null
13+
exit 0
14+
;;
15+
disable)
16+
mount -o remount,rw /boot 2>/dev/null
17+
rm -f "$DEBUG_FLAG"
18+
echo "[DEBUG BOOT] disabled"
19+
mount -o remount,ro /boot 2>/dev/null
20+
exit 0
21+
;;
22+
esac
23+
24+
exit 0

package/batocera/core/batocera-scripts/scripts/batocera-save-overlay

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ OVERLAYMOUNT="/overlay/saved"
88
OVERLAYRAM="/overlay/overlay"
99
OVERLAYSIZE=100 # M
1010

11+
DEBUG_FLAG="/boot/boot/bootmode.debug"
12+
13+
if [ -f "$DEBUGFLAG" ]; then
14+
echo "[DEBUG BOOT] Overlay save disabled while in debug boot mode."
15+
exit 0
16+
fi
17+
1118
# fix for winscp running bash and then not sourcing /etc/profile
1219
PATH=$PATH:/sbin
1320

package/batocera/core/batocera-scripts/scripts/batocera-version

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ test -n "${FIND_CUSTOMESSYSTEMS}" && EXTRA=${EXTRA}s
3636
test -n "${FIND_CUSTOMSERVICES}" && EXTRA=${EXTRA}u
3737
test -n "${FIND_USERSCRIPTS}" && EXTRA=${EXTRA}v
3838

39+
40+
# Override EXTRA if debug boot mode
41+
DEBUG_FLAG="/boot/boot/bootmode.debug"
42+
43+
if [ -f "${DEBUGFLAG}" ]; then
44+
EXTRA="debug"
45+
fi
46+
3947
if test "${1}" = "--extra"
4048
then
4149
if test -z "${EXTRA}"

0 commit comments

Comments
 (0)