diff --git a/external/board/radxa03w/boot.cmd b/external/board/radxa03w/boot.cmd index 814d340..6ab904d 100644 --- a/external/board/radxa03w/boot.cmd +++ b/external/board/radxa03w/boot.cmd @@ -1,9 +1,17 @@ setenv load_addr "0x6000000" +saveenv +if env exists bootpart; then + echo Booting from mmcblk${devnum}p${bootpart} +else + setenv bootpart 2 + echo bootpart not set, default to ${bootpart} +fi + echo "setting boot args" -setenv bootargs "root=/dev/mmcblk${devnum}p2 console=ttyS2,1500000n8 ro rootwait loglevel=3 init=/etc/overlay_init" +setenv bootargs "root=/dev/mmcblk${devnum}p${bootpart} console=ttyS2,1500000n8 ro rootwait loglevel=3 init=/etc/overlay_init" fatload mmc ${devnum}:1 ${fdt_addr_r} rk3566-radxa-zero-3w.dtb fatload mmc ${devnum}:1 ${kernel_addr_r} Image.gz echo booting linux ... -booti ${kernel_addr_r} - ${fdt_addr_r} \ No newline at end of file +booti ${kernel_addr_r} - ${fdt_addr_r} diff --git a/external/board/radxa03w/genimage.cfg b/external/board/radxa03w/genimage.cfg index 8092882..4b903f2 100644 --- a/external/board/radxa03w/genimage.cfg +++ b/external/board/radxa03w/genimage.cfg @@ -4,9 +4,10 @@ image boot.vfat { boot.scr, Image.gz, rk3566-radxa-zero-3w.dtb, + uboot.env } } - size = 20M + size = 32M } image userdata.ext4 { @@ -38,7 +39,12 @@ image sdcard.img { offset = 16M } - partition rootfs { + partition rootfsA { + partition-type-uuid = "L" + image = "rootfs.ext4" + } + + partition rootfsB { partition-type-uuid = "L" image = "rootfs.ext4" } diff --git a/external/board/radxa03w/post-image.sh b/external/board/radxa03w/post-image.sh index 8f589b5..f032dfc 100755 --- a/external/board/radxa03w/post-image.sh +++ b/external/board/radxa03w/post-image.sh @@ -4,5 +4,19 @@ set -u set -e set -x +cat << EOF > "${BINARIES_DIR}/uboot_vars.txt" +bootpart=2 +ustate=0 +bootlimit=3 +EOF + +${HOST_DIR}/bin/mkenvimage -s 16384 -o "${BINARIES_DIR}/uboot.env" "${BINARIES_DIR}/uboot_vars.txt" + support/scripts/genimage.sh -c $BR2_EXTERNAL_AA_PROXY_OS_PATH/board/radxa03w/genimage.cfg +cp "${BR2_EXTERNAL_AA_PROXY_OS_PATH}/board/radxa03w/swupdate/update.sh" "${BINARIES_DIR}/" + +swugenerator -o "${BINARIES_DIR}/update_image.swu" \ + -a "${BINARIES_DIR}" \ + -s "${BR2_EXTERNAL_AA_PROXY_OS_PATH}/board/radxa03w/swupdate/sw-description" \ + -e create \ No newline at end of file diff --git a/external/board/radxa03w/rootfs_overlay/etc/fstab b/external/board/radxa03w/rootfs_overlay/etc/fstab new file mode 100644 index 0000000..7f2a39d --- /dev/null +++ b/external/board/radxa03w/rootfs_overlay/etc/fstab @@ -0,0 +1,10 @@ +# +/dev/root / ext2 ro,noauto 0 1 +/dev/mmcblk1p1 /uboot vfat rw,noatime 0 2 +LABEL=userdata /data ext4 defaults,noatime 0 2 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts defaults,gid=5,mode=620,ptmxmode=0666 0 0 +tmpfs /dev/shm tmpfs mode=0777 0 0 +tmpfs /tmp tmpfs mode=1777 0 0 +tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 +sysfs /sys sysfs defaults 0 0 diff --git a/external/board/radxa03w/rootfs_overlay/etc/fw_env.config b/external/board/radxa03w/rootfs_overlay/etc/fw_env.config new file mode 100644 index 0000000..79644bb --- /dev/null +++ b/external/board/radxa03w/rootfs_overlay/etc/fw_env.config @@ -0,0 +1 @@ +/uboot/uboot.env 0x0000 0x4000 diff --git a/external/board/radxa03w/rootfs_overlay/etc/hwrevision b/external/board/radxa03w/rootfs_overlay/etc/hwrevision new file mode 100644 index 0000000..682a776 --- /dev/null +++ b/external/board/radxa03w/rootfs_overlay/etc/hwrevision @@ -0,0 +1 @@ +radxa03w 1.0 diff --git a/external/board/radxa03w/rootfs_overlay/etc/swupdate.cfg b/external/board/radxa03w/rootfs_overlay/etc/swupdate.cfg new file mode 100644 index 0000000..5f07796 --- /dev/null +++ b/external/board/radxa03w/rootfs_overlay/etc/swupdate.cfg @@ -0,0 +1,14 @@ +globals : +{ + loglevel = 4; + syslog = true; + postupdatecmd = "(sleep 3 && reboot) &"; +}; + +webserver : +{ + document_root = "/www"; + userid = 0; + groupid = 0; + run-postupdate = true; +}; diff --git a/external/board/radxa03w/rootfs_overlay/etc/swupdate/conf.d/09-swupdate-args b/external/board/radxa03w/rootfs_overlay/etc/swupdate/conf.d/09-swupdate-args new file mode 100755 index 0000000..8a4a874 --- /dev/null +++ b/external/board/radxa03w/rootfs_overlay/etc/swupdate/conf.d/09-swupdate-args @@ -0,0 +1,17 @@ +#!/bin/sh + +ROOTFS="$(swupdate -g)" + +if [ "$ROOTFS" = "/dev/mmcblk1p2" ]; then + SELECTION="stable,part2" +else + SELECTION="stable,part1" +fi + +USTATE="$(fw_printenv -n ustate)" +if [ "$USTATE" != "0" ]; then + fw_setenv ustate 0 +fi + +CFGFILE="/etc/swupdate.cfg" +SWUPDATE_ARGS="-e ${SELECTION} -f ${CFGFILE}" diff --git a/external/board/radxa03w/swupdate.config b/external/board/radxa03w/swupdate.config new file mode 100644 index 0000000..b28eaea --- /dev/null +++ b/external/board/radxa03w/swupdate.config @@ -0,0 +1,168 @@ +# +# SWUpdate Settings +# + +# +# General Configuration +# +CONFIG_CURL=y +CONFIG_CURL_SSL=y +# CONFIG_SYSTEMD is not set +CONFIG_DEFAULT_CONFIG_FILE="/etc/swupdate.cfg" +CONFIG_SCRIPTS=y +CONFIG_HW_COMPATIBILITY=y +CONFIG_HW_COMPATIBILITY_FILE="/etc/hwrevision" +CONFIG_SW_VERSIONS_FILE="/etc/sw-versions" + +# +# Socket Paths +# +CONFIG_SOCKET_CTRL_PATH="" +CONFIG_SOCKET_PROGRESS_PATH="" +# end of Socket Paths + +CONFIG_MTD=y +CONFIG_LUA=y +CONFIG_LUAPKG="lua" +# end of General Configuration + +# +# Debugging Options +# +# CONFIG_DEBUG is not set +# CONFIG_WERROR is not set +# CONFIG_NOCLEANUP is not set +# end of Debugging Options +# end of SWUpdate Settings + +# +# Bootloader support +# + +# +# Bootloader Interfaces +# +# CONFIG_BOOTLOADER_NONE is not set +# CONFIG_BOOTLOADER_EBG is not set +CONFIG_UBOOT=y +CONFIG_UBOOT_FWENV="/etc/fw_env.config" +CONFIG_UBOOT_DEFAULTENV="/etc/u-boot-initial-env" +# CONFIG_BOOTLOADER_GRUB is not set +# CONFIG_BOOTLOADER_CBOOT is not set +# end of Bootloader Interfaces + +CONFIG_BOOTLOADER_DEFAULT_UBOOT=y +# CONFIG_BOOTLOADER_STATIC_LINKED is not set +CONFIG_UPDATE_STATE_CHOICE_BOOTLOADER=y +CONFIG_UPDATE_STATE_BOOTLOADER="ustate" + +# +# Interfaces +# +CONFIG_DOWNLOAD=y +CONFIG_DOWNLOAD_SSL=y +CONFIG_CHANNEL_CURL=y +# CONFIG_SURICATTA is not set +CONFIG_WEBSERVER=y +CONFIG_MONGOOSE=y +# CONFIG_MONGOOSEIPV6 is not set +CONFIG_MONGOOSESSL=y + +# +# Security +# + +# +# Crypto libraries +# +CONFIG_SSL_IMPL_OPENSSL=y +# CONFIG_SSL_IMPL_WOLFSSL is not set +# CONFIG_SSL_IMPL_MBEDTLS is not set +# CONFIG_SSL_IMPL_GPGME is not set +# end of Crypto libraries + +CONFIG_HASH_VERIFY=y +CONFIG_SIGNED_IMAGES=n + +# +# Signature verification algorithm +# +CONFIG_SIGALG_RAWRSA=y +# CONFIG_SIGALG_RSAPSS is not set +# CONFIG_SIGALG_CMS is not set +# end of Signature verification algorithm + +# +# Encryption +# +CONFIG_ENCRYPTED_IMAGES=n +# CONFIG_ENCRYPTED_SW_DESCRIPTION is not set +# CONFIG_ENCRYPTED_IMAGES_HARDEN_LOGGING is not set +# end of Encryption + +CONFIG_CHANNEL_CURL_SSL=y + +# +# Compressors (zlib always on) +# +CONFIG_GUNZIP=y +# CONFIG_XZ is not set +# CONFIG_ZSTD is not set + +# +# Parsers +# + +# +# Parser Features +# +CONFIG_LIBCONFIG=y +CONFIG_PARSERROOT="" +# CONFIG_LUAEXTERNAL is not set +# CONFIG_SETSWDESCRIPTION is not set +# end of Parser Features + +# +# Handlers +# + +# +# Image Handlers +# +CONFIG_ARCHIVE=y +CONFIG_LOCALE=y +CONFIG_BOOTLOADERHANDLER=y +CONFIG_CFI=y +# CONFIG_CFIHAMMING1 is not set +# CONFIG_COPY is not set +# CONFIG_DELTA is not set +# CONFIG_DISKPART is not set +# CONFIG_DISKFORMAT_HANDLER is not set +CONFIG_LUASCRIPTHANDLER=y +# CONFIG_EMBEDDED_LUA_HANDLER is not set +# CONFIG_EMMC_HANDLER is not set +CONFIG_RAW=y +# CONFIG_RDIFFHANDLER is not set +# CONFIG_READBACKHANDLER is not set +CONFIG_REMOTE_HANDLER=y +CONFIG_SHELLSCRIPTHANDLER=y +# CONFIG_SWUFORWARDER_HANDLER is not set +# CONFIG_SSBLSWITCH is not set +CONFIG_UBIVOL=n +CONFIG_UBIATTACH=n +CONFIG_UBIBLACKLIST="" +CONFIG_UBIWHITELIST="" +CONFIG_UBIVIDOFFSET=0 +# CONFIG_UCFWHANDLER is not set +# CONFIG_UNIQUEUUID is not set +# end of Image Handlers + +# +# Containers +# + +# +# Update containers +# +# CONFIG_DOCKER is not set +# end of Update containers diff --git a/external/board/radxa03w/swupdate/sw-description b/external/board/radxa03w/swupdate/sw-description new file mode 100644 index 0000000..4a3836c --- /dev/null +++ b/external/board/radxa03w/swupdate/sw-description @@ -0,0 +1,64 @@ +software = +{ + version = "0.0.0"; + + radxa03w = { + hardware-compatibility: [ "1.0"]; + stable : { + part1 : { + images: ( + { + filename = "rootfs.ext4"; + type = "raw"; + compressed = "zlib"; + installed-directly = true; + device = "/dev/mmcblk1p2"; + } + ); + scripts: ( + { + filename = "update.sh"; + type = "shellscript"; + } + ); + bootenv: ( + { + name = "bootpart"; + value = "2"; + }, + { + name = "ustate"; + value = "1"; + } + ); + }; + part2 : { + images: ( + { + filename = "rootfs.ext4"; + type = "raw"; + compressed = "zlib"; + installed-directly = true; + device = "/dev/mmcblk1p3"; + } + ); + scripts: ( + { + filename = "update.sh"; + type = "shellscript"; + } + ); + bootenv: ( + { + name = "bootpart"; + value = "3"; + }, + { + name = "ustate"; + value = "1"; + } + ); + }; + }; + } +} diff --git a/external/board/radxa03w/swupdate/update.sh b/external/board/radxa03w/swupdate/update.sh new file mode 100755 index 0000000..662cdb9 --- /dev/null +++ b/external/board/radxa03w/swupdate/update.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +case "$1" in +postinst) + ROOTFS="$(swupdate -g)" + if [ "$ROOTFS" = "/dev/mmcblk0p2" ]; then + fw_setenv bootpart 3 + else + fw_setenv bootpart 2 + fi + fw_setenv ustate 1 + ;; +esac + +exit 0 diff --git a/external/board/radxa03w/uboot.fragment b/external/board/radxa03w/uboot.fragment index 2a58358..715fdbe 100644 --- a/external/board/radxa03w/uboot.fragment +++ b/external/board/radxa03w/uboot.fragment @@ -2,6 +2,11 @@ CONFIG_BOOTDELAY=0 CONFIG_BAUDRATE=1500000 CONFIG_GZIP=y +CONFIG_ENV_IS_IN_FAT=y +# CONFIG_ENV_RELOC_GD_ENV_ADDR is not set +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_ENV_SIZE=0x4000 + CONFIG_USB=n CONFIG_NET=n CONFIG_BOOTMETH_EFI_BOOTMGR=n \ No newline at end of file diff --git a/external/configs/radxa03w_defconfig b/external/configs/radxa03w_defconfig index 9911a7c..6acbc81 100644 --- a/external/configs/radxa03w_defconfig +++ b/external/configs/radxa03w_defconfig @@ -52,6 +52,16 @@ BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_AA_PROXY_OS_PATH)/board/r BR2_PACKAGE_HOST_UBOOT_TOOLS=y BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT=y BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT_SOURCE="$(BR2_EXTERNAL_AA_PROXY_OS_PATH)/board/radxa03w/boot.cmd" +BR2_PACKAGE_LIBUBOOTENV=y + +# SWUpdate +BR2_PACKAGE_SWUPDATE=y +BR2_PACKAGE_LIBCONFIG=y +BR2_PACKAGE_ZLIB=y +BR2_PACKAGE_OPENSSL=y +BR2_PACKAGE_SWUPDATE_WEBSERVER=y +BR2_PACKAGE_SWUPDATE_CONFIG="$(BR2_EXTERNAL_AA_PROXY_OS_PATH)/board/radxa03w/swupdate.config" +BR2_PACKAGE_HOST_SWUGENERATOR=y # Wireless Drivers BR2_PACKAGE_AIC8800=y