summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mk/image.mk27
-rwxr-xr-xpackage/base-files/files/init.d/rcS1
-rw-r--r--package/fwupdate/Makefile6
-rw-r--r--package/fwupdate/files/fwupdate.postinst3
-rwxr-xr-xpackage/fwupdate/src/fwupdate45
-rwxr-xr-xpackage/fwupdate/src/fwvalidate50
-rw-r--r--package/u-boot/files/fw_env.config2
-rw-r--r--package/u-boot/patches/patch-configs_bananapi_m2_p2_zero_defconfig18
-rw-r--r--package/u-boot/patches/patch-configs_rock-pi-4-rk3399_defconfig14
9 files changed, 134 insertions, 32 deletions
diff --git a/mk/image.mk b/mk/image.mk
index f17d2cb09..34822895c 100644
--- a/mk/image.mk
+++ b/mk/image.mk
@@ -354,18 +354,41 @@ ifeq ($(ADK_RUNTIME_FIX_PERMISSION),y)
PATH='$(HOST_PATH)' $(FAKEROOT) $(ADK_TOPDIR)/scripts/fakeroot.sh
rm $(ADK_TOPDIR)/scripts/fakeroot.sh $(STAGING_TARGET_DIR)/scripts/permissions.sh
endif
+ifeq ($(ADK_TARGET_DUAL_BOOT),y)
+ $(CP) $(FW_DIR)/kernel $(TARGET_DIR)
+ $(CP) $(FW_DIR)/*.dtb $(TARGET_DIR)
+ mkdir $(TARGET_DIR)/extlinux
+ $(CP) $(EXTLINUX) $(TARGET_DIR)/extlinux
+ $(SED) "s#root=.*#root=/dev/$(ADK_TARGET_ROOTDEV)p1#" $(TARGET_DIR)/extlinux/extlinux.conf
+ PATH='${HOST_PATH}' $(FAKEROOT) mkfs.ext2 \
+ -d "$(TARGET_DIR)" \
+ -r 1 -N 0 -m 5 -L "rootfs1" \
+ $(FW_DIR)/rootfs1.ext "64M" $(MAKE_TRACE)
+ $(SED) "s#root=.*#root=/dev/$(ADK_TARGET_ROOTDEV)p2#" $(TARGET_DIR)/extlinux/extlinux.conf
+ PATH='${HOST_PATH}' $(FAKEROOT) mkfs.ext2 \
+ -d "$(TARGET_DIR)" \
+ -r 1 -N 0 -m 5 -L "rootfs2" \
+ $(FW_DIR)/rootfs2.ext "64M" $(MAKE_TRACE)
+ PATH='${HOST_PATH}' genimage \
+ --config "$(GENCFG)" \
+ --tmppath "${FW_DIR}/temp" \
+ --rootpath "$(TARGET_DIR)" \
+ --inputpath "$(FW_DIR)" \
+ --outputpath "$(FW_DIR)" $(MAKE_TRACE)
+else
PATH='${HOST_PATH}' $(FAKEROOT) mkfs.ext2 \
-d "$(TARGET_DIR)" \
-r 1 -N 0 -m 5 -L "rootfs" \
- $(FW_DIR)/rootfs.ext "48M" $(MAKE_TRACE)
+ $(FW_DIR)/rootfs.ext "64M" $(MAKE_TRACE)
PATH='${HOST_PATH}' genimage \
--config "$(GENCFG)" \
--tmppath "${FW_DIR}/temp" \
--rootpath "$(TARGET_DIR)" \
--inputpath "$(FW_DIR)" \
--outputpath "$(FW_DIR)" $(MAKE_TRACE)
+endif
ifeq ($(ADK_TARGET_DUAL_BOOT),y)
- (cd ${TARGET_DIR}; find . | grep -v ./boot/ | sed -n '/^\.\//s///p' | sort | \
+ (cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
PATH='${HOST_PATH}' $(CPIO) -o --quiet -Hustar --owner=0:0 | \
${XZ} -c > ${FW_DIR}/openadk.tar.xz)
(cd ${FW_DIR}; PATH='${HOST_PATH}' sha256sum openadk.tar.xz \
diff --git a/package/base-files/files/init.d/rcS b/package/base-files/files/init.d/rcS
index db03a76e5..9015a71ac 100755
--- a/package/base-files/files/init.d/rcS
+++ b/package/base-files/files/init.d/rcS
@@ -17,6 +17,7 @@ fi
mkdir -p /var/log
mkdir -p /var/run
mkdir -p /var/tmp
+mkdir -p /var/lock
touch /var/log/lastlog
touch /var/log/wtmp
diff --git a/package/fwupdate/Makefile b/package/fwupdate/Makefile
index 8cf897ed4..738185fd9 100644
--- a/package/fwupdate/Makefile
+++ b/package/fwupdate/Makefile
@@ -5,7 +5,7 @@ include $(ADK_TOPDIR)/rules.mk
PKG_NAME:= fwupdate
PKG_VERSION:= 1.0
-PKG_RELEASE:= 1
+PKG_RELEASE:= 2
PKG_DESCR:= update firmware
PKG_SECTION:= base/adk
PKG_DEPENDS:= mke2fs
@@ -27,5 +27,9 @@ fwupdate-install:
$(INSTALL_DIR) $(IDIR_FWUPDATE)/usr/sbin
$(INSTALL_BIN) $(WRKBUILD)/fwupdate $(IDIR_FWUPDATE)/usr/sbin
$(INSTALL_BIN) $(WRKBUILD)/fwvalidate $(IDIR_FWUPDATE)/usr/sbin
+ $(SED) "s/@@DISK@@/$(ADK_TARGET_ROOTDEV)/g" \
+ $(IDIR_FWUPDATE)/usr/sbin/fwupdate
+ $(SED) "s/@@DISK@@/$(ADK_TARGET_ROOTDEV)/g" \
+ $(IDIR_FWUPDATE)/usr/sbin/fwvalidate
include ${ADK_TOPDIR}/mk/pkg-bottom.mk
diff --git a/package/fwupdate/files/fwupdate.postinst b/package/fwupdate/files/fwupdate.postinst
new file mode 100644
index 000000000..17871ff30
--- /dev/null
+++ b/package/fwupdate/files/fwupdate.postinst
@@ -0,0 +1,3 @@
+#!/bin/sh
+. $IPKG_INSTROOT/etc/functions.sh
+add_rcconf fwupdate NO
diff --git a/package/fwupdate/src/fwupdate b/package/fwupdate/src/fwupdate
index 1efe08339..68796d7bd 100755
--- a/package/fwupdate/src/fwupdate
+++ b/package/fwupdate/src/fwupdate
@@ -2,8 +2,22 @@
# This file is part of the OpenADK project.
# Do update.
-PART0="/dev/sda2"
-PART1="/dev/sda3"
+GRUB=$(which grub-reboot)
+if [ "${GRUB}" = "/usr/sbin/grub-reboot" ]; then
+ REVERSE=0
+else
+ REVERSE=1
+fi
+
+DISK=@@DISK@@
+
+if [ $REVERSE -eq 1 ]; then
+ PART0="/dev/${DISK}p1"
+ PART1="/dev/${DISK}p2"
+else
+ PART0="/dev/${DISK}2"
+ PART1="/dev/${DISK}3"
+fi
# Name of the archive, which is the firmware. For this file is the checksum calculated and
# checked against the one from the tar archive.
@@ -59,10 +73,12 @@ CURRENT_SYS="$(rdev /|awk '{ print $1 }')"
case "$CURRENT_SYS" in
"$PART0")
MOUNTPART="$PART1"
+ PARTNUM=2
OS=OpenADK2
;;
"$PART1")
MOUNTPART="$PART0"
+ PARTNUM=1
OS=OpenADK1
;;
*)
@@ -130,18 +146,23 @@ fi
cd /
umount $MOUNTPART
-grep /boot /proc/mounts 2>/dev/null
-if [ $? -eq 0 ]; then
- mount -o remount,rw /boot
+if [ $REVERSE -eq 1 ]; then
+ echo "Switch bootable partition to new system"
+ sfdisk -A /dev/$DISK $PARTNUM >/dev/null 2>&1
else
- mount /dev/sda1 /boot
-fi
-grub-reboot $OS
grep /boot /proc/mounts 2>/dev/null
-if [ $? -eq 0 ]; then
- mount -o remount,ro /boot
-else
- umount /boot
+ if [ $? -eq 0 ]; then
+ mount -o remount,rw /boot
+ else
+ mount /dev/sda1 /boot
+ fi
+ grub-reboot $OS
+ grep /boot /proc/mounts 2>/dev/null
+ if [ $? -eq 0 ]; then
+ mount -o remount,ro /boot
+ else
+ umount /boot
+ fi
fi
sync
echo "Reboot now to the updated system $OS"
diff --git a/package/fwupdate/src/fwvalidate b/package/fwupdate/src/fwvalidate
index e87c5beed..f388da784 100755
--- a/package/fwupdate/src/fwvalidate
+++ b/package/fwupdate/src/fwvalidate
@@ -2,8 +2,22 @@
# This file is part of the OpenADK project.
# Validate update.
-PART0="/dev/sda2"
-PART1="/dev/sda3"
+GRUB=$(which grub-reboot)
+if [ "${GRUB}" = "/usr/sbin/grub-reboot" ]; then
+ REVERSE=0
+else
+ REVERSE=1
+fi
+
+DISK=@@DISK@@
+
+if [ $REVERSE -eq 1 ]; then
+ PART0="/dev/${DISK}p1"
+ PART1="/dev/${DISK}p2"
+else
+ PART0="/dev/${DISK}2"
+ PART1="/dev/${DISK}3"
+fi
APPLIANCE_NAME=OpenADK
@@ -43,6 +57,24 @@ chk_initial_save(){
echo "please save configuration"
fi
}
+
+updatebootflag(){
+
+ case "$CURRENT_SYS" in
+ "$PART1")
+ sfdisk -A /dev/$DISK 1
+ ;;
+ "$PART0")
+ sfdisk -A /dev/$DISK 2
+ ;;
+ *)
+ echo "Current partition $CURRENT_SYS not recognized"
+ exit 1
+ ;;
+ esac
+
+}
+
updategrub(){
mount -o remount,rw /boot
@@ -120,12 +152,22 @@ if [ $TESTS -eq $TESTSUM ]; then
logger -t update "All Tests passed."
if [ "x$1" = "x" ]; then
logger -t update "Set default boot partition for bootloader."
+ mount -o remount,rw /
rm /firmware_check
+ mount -o remount,ro /
echo "System check was successful" >> $STAT_FILE
- updategrub
+ if [ $REVERSE -eq 1 ]; then
+ echo "Nothing todo. All fine."
+ logger -t update "Nothing todo. All fine."
+ else
+ updategrub
+ fi
fi
else
- logger -t update "Not all tests passed. The the default system remains on the current partition."
+ if [ $REVERSE -eq 1 ]; then
+ updatebootflag
+ fi
+ logger -t update "Not all tests passed. The default system remains on the current partition."
logger -t update "Please try to reboot the system and repeat the update."
echo "ERROR last system update failed, please reboot and try again." >> $STAT_FILE
exit 1
diff --git a/package/u-boot/files/fw_env.config b/package/u-boot/files/fw_env.config
index 7b798416e..8fd738b4e 100644
--- a/package/u-boot/files/fw_env.config
+++ b/package/u-boot/files/fw_env.config
@@ -1 +1 @@
-/dev/mmcblk0 -0x20000 0x20000
+/dev/mmcblk1 0x3F8000 0x8000
diff --git a/package/u-boot/patches/patch-configs_bananapi_m2_p2_zero_defconfig b/package/u-boot/patches/patch-configs_bananapi_m2_p2_zero_defconfig
new file mode 100644
index 000000000..c9761d409
--- /dev/null
+++ b/package/u-boot/patches/patch-configs_bananapi_m2_p2_zero_defconfig
@@ -0,0 +1,18 @@
+--- u-boot-2022.10.orig/configs/bananapi_m2_p2_zero_defconfig 1970-01-01 00:00:00.000000000 +0100
++++ u-boot-2022.10/configs/bananapi_m2_p2_zero_defconfig 2022-12-25 07:59:45.852731211 +0100
+@@ -0,0 +1,15 @@
++CONFIG_ARM=y
++CONFIG_ARCH_SUNXI=y
++# CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-bananapi-m2-plus-v1.2"
++CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-bananapi-m2-zero"
++CONFIG_SPL=y
++CONFIG_MACH_SUN8I_H3=y
++CONFIG_DRAM_CLK=408
++CONFIG_MMC0_CD_PIN=""
++CONFIG_MMC_SUNXI_SLOT_EXTRA=2
++# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
++CONFIG_PREBOOT=""
++# CONFIG_SYS_DEVICE_NULLDEV is not set
++CONFIG_SPL_STACK=0x8000
++CONFIG_SYS_PBSIZE=1024
++CONFIG_SUN8I_EMAC=y
diff --git a/package/u-boot/patches/patch-configs_rock-pi-4-rk3399_defconfig b/package/u-boot/patches/patch-configs_rock-pi-4-rk3399_defconfig
index 575ddfbe6..93307dc60 100644
--- a/package/u-boot/patches/patch-configs_rock-pi-4-rk3399_defconfig
+++ b/package/u-boot/patches/patch-configs_rock-pi-4-rk3399_defconfig
@@ -1,16 +1,6 @@
--- u-boot-2022.10.orig/configs/rock-pi-4-rk3399_defconfig 2022-10-03 21:25:32.000000000 +0200
-+++ u-boot-2022.10/configs/rock-pi-4-rk3399_defconfig 2022-12-25 06:25:34.169217143 +0100
-@@ -4,7 +4,8 @@ CONFIG_COUNTER_FREQUENCY=24000000
- CONFIG_ARCH_ROCKCHIP=y
- CONFIG_SYS_TEXT_BASE=0x00200000
- CONFIG_NR_DRAM_BANKS=1
--CONFIG_ENV_OFFSET=0x3F8000
-+CONFIG_ENV_OFFSET=-0x20000
-+CONFIG_ENV_SIZE=0x20000
- CONFIG_DEFAULT_DEVICE_TREE="rk3399-rock-pi-4b"
- CONFIG_ROCKCHIP_RK3399=y
- CONFIG_TARGET_EVB_RK3399=y
-@@ -60,7 +61,7 @@ CONFIG_REGULATOR_RK8XX=y
++++ u-boot-2022.10/configs/rock-pi-4-rk3399_defconfig 2022-12-25 08:01:46.267056624 +0100
+@@ -60,7 +62,7 @@ CONFIG_REGULATOR_RK8XX=y
CONFIG_PWM_ROCKCHIP=y
CONFIG_RAM_RK3399_LPDDR4=y
CONFIG_DM_RESET=y