diff --git a/board/raspberrypi3_swupdate/cmdline.txt b/board/raspberrypi3_swupdate/cmdline.txt index 81758e3..63e0165 100644 --- a/board/raspberrypi3_swupdate/cmdline.txt +++ b/board/raspberrypi3_swupdate/cmdline.txt @@ -1 +1 @@ -console=ttyS0,115200 rootwait \ No newline at end of file +console=ttyAMA1,115200 rootwait \ No newline at end of file diff --git a/board/raspberrypi3_swupdate/config.txt b/board/raspberrypi3_swupdate/config.txt index 173aef2..160789c 100644 --- a/board/raspberrypi3_swupdate/config.txt +++ b/board/raspberrypi3_swupdate/config.txt @@ -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 \ No newline at end of file diff --git a/board/raspberrypi3_swupdate/disable-ftrace.fragment b/board/raspberrypi3_swupdate/disable-ftrace.fragment new file mode 100644 index 0000000..0c3be6b --- /dev/null +++ b/board/raspberrypi3_swupdate/disable-ftrace.fragment @@ -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 diff --git a/board/raspberrypi3_swupdate/genimage-raspberrypi3_swupdate.cfg b/board/raspberrypi3_swupdate/genimage-raspberrypi3_swupdate.cfg index 4703b74..9738700 100644 --- a/board/raspberrypi3_swupdate/genimage-raspberrypi3_swupdate.cfg +++ b/board/raspberrypi3_swupdate/genimage-raspberrypi3_swupdate.cfg @@ -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" diff --git a/board/raspberrypi3_swupdate/rootfs_overlay/etc/systemd/system/getty.target.wants/getty@ttyAMA1.service b/board/raspberrypi3_swupdate/rootfs_overlay/etc/systemd/system/getty.target.wants/getty@ttyAMA1.service new file mode 120000 index 0000000..facee85 --- /dev/null +++ b/board/raspberrypi3_swupdate/rootfs_overlay/etc/systemd/system/getty.target.wants/getty@ttyAMA1.service @@ -0,0 +1 @@ +/lib/systemd/system/getty@.service \ No newline at end of file diff --git a/board/raspberrypi3_swupdate/uboot-env.txt b/board/raspberrypi3_swupdate/uboot-env.txt index 39f2972..aa23f68 100644 --- a/board/raspberrypi3_swupdate/uboot-env.txt +++ b/board/raspberrypi3_swupdate/uboot-env.txt @@ -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 newline at end of file +# No network, no A/B switching, no fallback logic +# Only the essential commands are included for clarity \ No newline at end of file diff --git a/configs/raspberrypi3_swupdate_defconfig b/configs/raspberrypi3_swupdate_defconfig index 3ba6baf..8471bb9 100644 --- a/configs/raspberrypi3_swupdate_defconfig +++ b/configs/raspberrypi3_swupdate_defconfig @@ -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 diff --git a/flash_sdcard.sh b/flash_sdcard.sh index 81d543d..0d28481 100755 --- a/flash_sdcard.sh +++ b/flash_sdcard.sh @@ -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://:8080"