target/armsr: istoreos patches

This commit is contained in:
Liangbin Lian 2025-01-17 11:48:27 +08:00
parent 2751fd1f92
commit 46cd8e40eb
5 changed files with 66 additions and 28 deletions

View File

@ -181,7 +181,7 @@ define Package/grub2-efi-arm/install
-c $(PKG_BUILD_DIR)/grub-early.cfg \
-o $(STAGING_DIR_IMAGE)/grub2/boot$(if $(CONFIG_aarch64),aa64,arm).efi \
boot chain configfile fat linux ls part_gpt part_msdos reboot search \
search_fs_uuid search_label serial efi_gop lsefi minicmd ext2
search_fs_uuid search_label serial test efi_gop lsefi minicmd ext2
$(STAGING_DIR_HOST)/bin/grub-mkimage \
-d $(PKG_BUILD_DIR)/grub-core \
-p /boot/grub \

View File

@ -0,0 +1,29 @@
#!/bin/sh
#
# Copyright (C) 2013-2015 OpenWrt.org
#
. /lib/functions/uci-defaults.sh
board_config_update
json_is_a network object && exit 0
ETHNUM=$(ls /sys/class/net/ | grep eth | wc -l)
[ $ETHNUM == 0 ] && exit 0
if [ $ETHNUM == 1 ]; then
ucidef_set_interface_lan 'eth0' 'dhcp'
else
[ -d /sys/class/net/eth0 ] && ucidef_set_interface_wan 'eth0'
interface=""
for eth_interface in /sys/class/net/eth*
do
[ "$eth_interface" != "/sys/class/net/eth0" ] && interface=$interface" "${eth_interface##*/}
done
[ -n "$interface" ] && ucidef_set_interface_lan "$interface"
fi
board_config_flush
exit 0

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-or-later
RAMFS_COPY_BIN="/usr/sbin/blkid"
RAMFS_COPY_BIN="/usr/sbin/blkid readlink"
platform_check_image() {
local board=$(board_name)
@ -33,21 +33,6 @@ platform_check_image() {
fi
}
platform_copy_config() {
local partdev parttype=ext4
if export_partdevice partdev 1; then
part_magic_fat "/dev/$partdev" && parttype=vfat
mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt
else
v "ERROR: Unable to find partition to copy config data to"
fi
sleep 5
}
# To avoid writing over any firmware
# files (e.g ubootefi.var or firmware/X/ aka EBBR)
# Copy efi/openwrt and efi/boot from the new image
@ -97,16 +82,20 @@ platform_do_upgrade() {
sync
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
get_partitions "/dev/$diskdev" bootdisk
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" -o -n "$UPGRADE_BACKUP" ]; then
[ -n "$UPGRADE_BACKUP" ] || get_partitions "/dev/$diskdev" bootdisk
v "Extract boot sector from the image"
get_image_dd "$1" of=/tmp/image.bs count=63 bs=512b
get_partitions /tmp/image.bs image
#compare tables
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
if [ -n "$UPGRADE_BACKUP" ]; then
#keep overlay partition when upgrade
diff=
else
#compare tables
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
fi
else
diff=1
fi
@ -131,11 +120,17 @@ platform_do_upgrade() {
#iterate over each partition from the image and write it to the boot disk
while read part start size; do
if [ -n "$UPGRADE_BACKUP" -a "$part" -ge 3 ]; then
v "Skip partition $part >= 3 when upgrading"
continue
fi
if export_partdevice partdev $part; then
v "Writing image to /dev/$partdev..."
if [ "$part" = "1" ]; then
platform_do_upgrade_efi_system_partition \
$1 $partdev $start $size || return 1
elif [ "$part" -eq 3 ]; then
echo "RESET000" | dd of="/dev/$partdev" bs=512 count=1 conv=sync,fsync 2>/dev/null
else
v "Normal partition, doing DD"
get_image_dd "$1" of="/dev/$partdev" ibs=512 obs=1M skip="$start" \

View File

@ -18,10 +18,10 @@ endif
GRUB_SERIAL:=$(call qstrip,$(CONFIG_TARGET_SERIAL))
GRUB_CONSOLE_CMDLINE += console=$(GRUB_SERIAL),$(CONFIG_GRUB_BAUDRATE)n8$(if $(CONFIG_GRUB_FLOWCONTROL),r,)
GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1 --rtscts=$(if $(CONFIG_GRUB_FLOWCONTROL),on,off)
GRUB_TERMINALS += serial
GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS) $(if $(GRUB_SERIAL),serial,)
ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_SIGNATURE)-02)
@ -58,6 +58,7 @@ define Build/grub-config
-e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
-e 's#@ROOTPART@#root=$(ROOTPART) rootwait#g' \
-e 's#@GPT_ROOTPART@#root=$(GPT_ROOTPART) rootwait#g' \
-e 's#@BOOTOPTS@#$(BOOTOPTS)#g' \
-e 's#@CMDLINE@#$(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE)#g' \
-e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
-e 's#@TITLE@#$(GRUB_TITLE)#g' \

View File

@ -3,12 +3,25 @@
set default="0"
set timeout="@TIMEOUT@"
set rompart="@GPT_ROOTPART@"
set kernel="/efi/openwrt/@KERNEL_NAME@"
if [ ! -e $kernel ]; then
search --set=root --label kernel
fi
menuentry "@TITLE@" {
search --set=root --label kernel
linux /efi/openwrt/@KERNEL_NAME@ @GPT_ROOTPART@ @CMDLINE@ noinitrd
linux $kernel $rompart @BOOTOPTS@ noinitrd
}
menuentry "@TITLE@ (failsafe)" {
search --set=root --label kernel
linux /efi/openwrt/@KERNEL_NAME@ failsafe=true @GPT_ROOTPART@ @CMDLINE@ noinitrd
linux $kernel failsafe=true $rompart @BOOTOPTS@ noinitrd
}
menuentry "@TITLE@ (ttyS0)" {
linux $kernel $rompart @CMDLINE@ noinitrd
}
menuentry "@TITLE@ (ttyAMA0)" {
linux $kernel $rompart @BOOTOPTS@ console=ttyAMA0,115200n8 noinitrd $cmdline_ext
}
menuentry "@TITLE@ (ttyUSB0)" {
linux $kernel $rompart @BOOTOPTS@ console=ttyUSB0,115200n8 noinitrd $cmdline_ext
}