further work in progress

This commit is contained in:
2025-04-18 12:39:26 +02:00
parent f9a590a5a0
commit 442f0de5fd
8 changed files with 66 additions and 42 deletions
+1 -1
View File
@@ -1 +1 @@
console=ttyS0,115200 rootwait
console=ttyAMA1,115200 rootwait
+3 -3
View File
@@ -3,9 +3,8 @@ arm_64bit=1
# configure the uart
enable_uart=1
dtoverlay=disable-bt
core_freq=250
init_uart_clock=48000000
init_uart_baud=115200
uart_2ndstage=1
# Disable HDMI to reduce noise
@@ -19,6 +18,7 @@ gpu_mem=32
# start the bootloader which then selects system A or B
kernel=u-boot.bin
# dt overlays
# dt overlays Note: dt overlays must also be added in genimage-raspberrypi3_swupdate.cfg
dtdebug=1
dtoverlay=disable-bt
#dtoverlay=disable-wifi
@@ -0,0 +1,8 @@
# Disable kernel tracing and function tracing to avoid boot panic on RPi3 aarch64
CONFIG_FTRACE=n
CONFIG_FUNCTION_TRACER=n
CONFIG_DYNAMIC_FTRACE=n
CONFIG_FUNCTION_GRAPH_TRACER=n
CONFIG_STACK_TRACER=n
CONFIG_BRANCH_PROFILE_NONE=n
CONFIG_KPROBES=n
@@ -14,8 +14,8 @@ image boot.vfat {
file uboot.env {
image = "uboot-env.img"
}
file overlays/README {
image = "rpi-firmware/overlays/README"
file overlays/disable-bt.dtbo {
image = "rpi-firmware/overlays/disable-bt.dtbo"
}
file bootcode.bin {
image = "rpi-firmware/bootcode.bin"
@@ -0,0 +1 @@
/lib/systemd/system/getty@.service
+8 -30
View File
@@ -2,38 +2,16 @@
# Default variables for first boot - these will be modified during operation
# Active partition (A or B)
kernel_addr_r=0x01000000
fdt_addr_r=0x03000000
active_part=A
active_root=/dev/mmcblk0p2
inactive_part=B
inactive_root=/dev/mmcblk0p3
# Boot attempt counters
bootcount=0
bootlimit=3
# Default bootcmd
bootcmd=run bootcmd_${active_part}
# Kernel boot arguments
bootargs=console=ttyS0,115200 root=${active_root} rootwait
# Commands for booting from A or B partitions
bootcmd_A=setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait; load mmc 0:1 ${kernel_addr_r} Image; load mmc 0:1 0x03000000 bcm2710-rpi-3-b.dtb; booti ${kernel_addr_r} - 0x03000000
bootcmd_B=setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p3 rootwait; load mmc 0:1 ${kernel_addr_r} Image; load mmc 0:1 0x03000000 bcm2710-rpi-3-b.dtb; booti ${kernel_addr_r} - 0x03000000
# Fallback logic for failed boots
altbootcmd=if test ${active_part} = A; then setenv active_part B; setenv active_root /dev/mmcblk0p3; setenv inactive_part A; setenv inactive_root /dev/mmcblk0p2; else setenv active_part A; setenv active_root /dev/mmcblk0p2; setenv inactive_part B; setenv inactive_root /dev/mmcblk0p3; fi; setenv bootcount 0; saveenv; run bootcmd
# Memory addresses
kernel_addr_r=0x01000000
fdt_addr_r=0x02000000
fdt_addr_r=0x03000000
# Board name
board_name=rpi3
# Always boot partition A using PL011 UART for console and earlycon
bootcmd=setenv bootargs console=ttyAMA1,115200 earlycon=pl011,0x3f201000,115200 root=/dev/mmcblk0p2 rootwait net.ifnames=0; \
load mmc 0:1 ${kernel_addr_r} Image; \
load mmc 0:1 ${fdt_addr_r} bcm2710-rpi-3-b.dtb; \
booti ${kernel_addr_r} - ${fdt_addr_r}
# Network configuration (DHCP)
autoload=no
ethact=smi
ethaddr_sdio0=00:44:55:66:77:88
# No network, no A/B switching, no fallback logic
# Only the essential commands are included for clarity
+8 -2
View File
@@ -34,6 +34,9 @@ BR2_TARGET_UBOOT_NEEDS_PYTHON3=y
BR2_TARGET_UBOOT_NEEDS_PYLIBFDT=y
BR2_TARGET_UBOOT_FORMAT_BIN=y
BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_AURACASTER_SYSTEM_PATH)/board/raspberrypi3_swupdate/uboot.config"
# Disable kernel tracing (ftrace) to avoid boot panic on RPi3 aarch64
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_AURACASTER_SYSTEM_PATH)/board/raspberrypi3_swupdate/disable-ftrace.fragment"
BR2_PACKAGE_UBOOT_TOOLS=y
BR2_PACKAGE_UBOOT_TOOLS_MKIMAGE=y
BR2_PACKAGE_UBOOT_TOOLS_MKENVIMAGE=y
@@ -71,6 +74,11 @@ BR2_PACKAGE_JSON_C=y
BR2_PACKAGE_LIBUBOOTENV=y
BR2_PACKAGE_LIBUBOOTENV_TARGET=y
# Enable a getty (login prompt) on the serial console matching the kernel command line
BR2_TARGET_GENERIC_GETTY=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA1"
BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
# Utilities
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_XZ=y
@@ -95,8 +103,6 @@ BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin"
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_AURACASTER_SYSTEM_PATH)/board/raspberrypi3_swupdate/rootfs_overlay"
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL_AURACASTER_SYSTEM_PATH)/board/raspberrypi3_swupdate/users.txt"
# No duplicate needed - already defined above
# Host tools
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
+35 -4
View File
@@ -130,19 +130,40 @@ else
fi
fi
# Unmount any partitions on the device
# Unmount any partitions on the device, reporting failures
echo "Unmounting any mounted partitions on $DEV_PATH..."
UNMOUNT_FAILED=0
if [[ "$DEVICE" == mmcblk* ]]; then
for partition in $(lsblk -n -o NAME | grep "^$DEVICE"); do
if [ "$partition" != "$DEVICE" ]; then
umount "/dev/$partition" 2>/dev/null || true
if mount | grep -q "/dev/$partition"; then
umount "/dev/$partition" 2>/dev/null || {
echo "Warning: Failed to unmount /dev/$partition" >&2
UNMOUNT_FAILED=1
}
fi
fi
done
else
for partition in $(lsblk -n -o NAME /dev/$DEVICE | grep -v "^$DEVICE$"); do
umount "/dev/$partition" 2>/dev/null || true
if mount | grep -q "/dev/$partition"; then
umount "/dev/$partition" 2>/dev/null || {
echo "Warning: Failed to unmount /dev/$partition" >&2
UNMOUNT_FAILED=1
}
fi
done
fi
if [ $UNMOUNT_FAILED -eq 1 ]; then
echo "Some partitions could not be unmounted. Please close any open files or applications using the SD card and try again." >&2
exit 1
fi
# Check for open files on the device
if lsof | grep -q "/dev/$DEVICE"; then
echo "Warning: Open files detected on /dev/$DEVICE. Please close them before flashing to avoid corruption." >&2
lsof | grep "/dev/$DEVICE"
exit 1
fi
# Flash the image
echo "Flashing image to $DEV_PATH..."
@@ -160,7 +181,17 @@ echo "Flash complete!"
echo
# Remind user to eject the card safely
echo "You can now safely remove the SD card."
echo "Flash complete!"
echo
# Re-read the partition table to ensure the system recognizes the new layout
echo "Running partprobe to re-read the partition table on $DEV_PATH..."
if partprobe "$DEV_PATH"; then
echo "Partition table re-read successfully. The SD card is ready for use."
else
echo "Warning: partprobe failed. If partitions do not show up, try reinserting the SD card."
fi
echo
# Instructions for next steps
echo "1. Insert the SD card into your Raspberry Pi 3"
echo "2. Power on the device"
echo "3. Access the SWUpdate web interface at http://<raspberry-pi-ip>:8080"