0

我目前正在使用层 meta-azure-device-update 和 meta-swupdate 进行 Azure 设备更新。我想运行一个安装后脚本。我遵循了以下提到的来源:

1.sw-description.rst https://git.rigado.com/vesta/swupdate/-/blob/acf50e361a8752db48e69ffe3c20a167c402d35f/doc/source/sw-description.rst#board-specific-settings

2.adu-swupdate.sh https://github.com/Azure/iot-hub-device-update/blob/main/src/adu-shell/scripts/adu-swupdate.sh

映像已成功构建,我能够在我提供 Azure 设备更新的 .swu 文件中找到 adu-swupdate.sh。安装失败给出以下错误:

Sep 21 07:21:30 rpi AducIotAgent[281]: -> 07:21:29 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin2021-09-21T07:21:30.2396Z [E] Install failed, extendedResultCode = 1 [Install]

Sep 21 07:21:30 rpi AducIotAgent[281]: 2021-09-21T07:21:30.2398Z [E] Install failed. error 0, 1 - Expecting service to send Cancel action [ADUC_Workflow_WorkCompletionCallback]

sw-update 日志如下:

Swupdate v2021.04.0

Licensed under GPLv2. See source distribution for detailed copyright notices.

[INFO ] : SWUPDATE running :  [main] : Running on raspberrypi4 Revision 1.0
[INFO ] : SWUPDATE running :  [print_registered_handlers] : Registered handlers:
[INFO ] : SWUPDATE running :  [print_registered_handlers] :     dummy
[INFO ] : SWUPDATE running :  [print_registered_handlers] :     archive
[INFO ] : SWUPDATE running :  [print_registered_handlers] :     tar
[INFO ] : SWUPDATE running :  [print_registered_handlers] :     uboot
[INFO ] : SWUPDATE running :  [print_registered_handlers] :     bootloader
[INFO ] : SWUPDATE running :  [print_registered_handlers] :     raw
[INFO ] : SWUPDATE running :  [print_registered_handlers] :     rawfile
[INFO ] : SWUPDATE running :  [print_registered_handlers] :     rawcopy
[INFO ] : SWUPDATE running :  [main] : software set: stable mode: copy2
[TRACE] : SWUPDATE running :  [listener_create] : creating socket at /tmp/swupdateprog
[TRACE] : SWUPDATE running :  [network_initializer] : Main loop daemon
[TRACE] : SWUPDATE running :  [listener_create] : creating socket at /tmp/sockinstctrl
[TRACE] : SWUPDATE running :  [network_thread] : Incoming network request: processing...
[INFO ] : SWUPDATE started :  Software Update started !
[TRACE] : SWUPDATE running :  [network_initializer] : Software update started
[WARN ] : SWUPDATE running :  [scan_mtd_devices] : MTD is not present on the target
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] : Found file
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] :   filename sw-description
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] :   size 1144
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] : Found file
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] :   filename sw-description.sig
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] :   size 256
[TRACE] : SWUPDATE running :  [swupdate_verify_file] : Verify signed image: Read 1144 bytes
[TRACE] : SWUPDATE running :  [swupdate_verify_file] : Verified OK
[TRACE] : SWUPDATE running :  [get_common_fields] : Version 0.1.0.1
[TRACE] : SWUPDATE running :  [parse_hw_compatibility] : Accepted Hw Revision : 1.0
[TRACE] : SWUPDATE running :  [_parse_images] : Found compressed Image: core-image-base-raspberrypi4.ext4.gz in device : /dev/mmcblk0p3 for handler raw
[TRACE] : SWUPDATE running :  [_parse_scripts] : Found Script: adu-swupdate.sh
[ERROR] : SWUPDATE failed [0] ERROR : feature 'postinstall' required for 'adu-swupdate.sh' in sw-description is absent!
[ERROR] : SWUPDATE failed [0] ERROR : Compatible SW not found
[ERROR] : SWUPDATE failed [1] Image invalid or corrupted. Not installing ...
[TRACE] : SWUPDATE running :  [network_initializer] : Main thread sleep again !
[INFO ] : No SWUPDATE running :  Waiting for requests...
[INFO ] : SWUPDATE running :  [endupdate] : Swupdate *failed* !```

4

1 回答 1

1

因此,经过数小时的探索和阅读 SW-UPDATE Wiki 的每一页后,我发现每个功能都有处理程序,我们必须在使用它之前启用这些处理程序。

你可以在这里阅读更多关于它们的信息。https://sbabic.github.io/swupdate/handlers.html

这些处理程序在 meta-swupdate/recipes-support/swupdate/defconfig 中可用

#
# Automatically generated file; DO NOT EDIT.
# Swupdate Configuration
#
CONFIG_HAVE_DOT_CONFIG=y

#
# Swupdate Settings
#

#
# General Configuration
#
# CONFIG_CURL is not set
# CONFIG_CURL_SSL is not set
# 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=""
CONFIG_SOCKET_REMOTE_HANDLER_DIRECTORY="/tmp/"
CONFIG_MTD=y
CONFIG_LUA=y
CONFIG_LUAPKG="lua"
# CONFIG_FEATURE_SYSLOG is not set

#
# Build Options
#
CONFIG_CROSS_COMPILE=""
CONFIG_SYSROOT=""
CONFIG_EXTRA_LDLIBS=""

#
# Debugging Options
#
# CONFIG_DEBUG is not set
# CONFIG_WERROR is not set
# CONFIG_NOCLEANUP is not set
# CONFIG_BOOTLOADER_EBG is not set
CONFIG_UBOOT=y
# CONFIG_BOOTLOADER_NONE is not set
# CONFIG_BOOTLOADER_GRUB is not set
CONFIG_UBOOT_FWENV="/etc/fw_env.config"
CONFIG_UBOOT_DEFAULTENV="/etc/u-boot-initial-env"
# CONFIG_SSL_IMPL_NONE is not set
CONFIG_SSL_IMPL_OPENSSL=y
# CONFIG_SSL_IMPL_MBEDTLS is not set
# CONFIG_DOWNLOAD is not set
# CONFIG_HASH_VERIFY is not set
# CONFIG_SIGNED_IMAGES is not set
# CONFIG_ENCRYPTED_IMAGES is not set
# CONFIG_SURICATTA is not set
CONFIG_WEBSERVER=y
CONFIG_MONGOOSE=y
CONFIG_MONGOOSEIPV6=y
CONFIG_MONGOOSESSL=y
CONFIG_GUNZIP=y
# CONFIG_ZSTD is not set

#
# Parser Features
#
CONFIG_LIBCONFIG=y
CONFIG_PARSERROOT=""
# CONFIG_JSON is not set
# CONFIG_LUAEXTERNAL is not set
# CONFIG_SETSWDESCRIPTION is not set

#
# Image Handlers
#
# CONFIG_UBIVOL is not set
CONFIG_CFI=y
# CONFIG_CFIHAMMING1 is not set
# CONFIG_DISKPART is not set
CONFIG_RAW=y
# CONFIG_RDIFFHANDLER is not set
CONFIG_LUASCRIPTHANDLER=y
CONFIG_SHELLSCRIPTHANDLER=y
# CONFIG_HANDLER_IN_LUA is not set
# CONFIG_ARCHIVE is not set
# CONFIG_REMOTE_HANDLER is not set
# CONFIG_SWUFORWARDER_HANDLER is not set
# CONFIG_BOOTLOADERHANDLER is not set
# CONFIG_SSBLSWITCH is not set
# CONFIG_UCFWHANDLER is not set

因此,要启用 post 和 preinstall 脚本功能,您应该在以下位置编辑此 defconfig 文件

CONFIG_SHELLSCRIPTHANDLER=y

这将为您的 swupdate 启用 post 和 preinstall 脚本功能。

于 2021-11-15T15:02:35.690 回答