Azure / iot-hub-device-update

Device Update for IoT Hub agent
MIT License
51 stars 36 forks source link

Device update agent on bullseye 11 raspberry zero #622

Open Kralg opened 2 months ago

Kralg commented 2 months ago

Expected Behavior

Working device update agent to perform multi-step update.

Current Behavior

If I try to install the deviceUpdate-agent with command: sudo apt-get install deviceupdate-agent I am getting error: Register all reference step handlers... /var/lib/dpkg/info/deviceupdate-agent.postinst: line 218: 10000 Illegal instruction $adu_bin_path -l 2 --extension-type updateContentHandler --extension-id "microsoft/apt:1" --register-extension $adu_extensions_sources_dir/$adu_apt_handler_file dpkg: error processing package deviceupdate-agent (--configure): installed deviceupdate-agent package post-installation script subprocess returned error exit status 132 Processing triggers for man-db (2.9.4-2) ... Errors were encountered while processing: deviceupdate-agent

Steps to Reproduce

Provide a detailed set of steps to reproduce the bug.

  1. Raspbian bullseye 11
  2. sudo apt-get install deviceupdate-agent

Device Information

Logs

sudo apt-get install deviceupdate-agent Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: libcurl4-openssl-dev Suggested packages: deliveryoptimization-plugin-apt libcurl4-doc libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev libssl-dev The following NEW packages will be installed: deviceupdate-agent libcurl4-openssl-dev 0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded. Need to get 0 B/2,157 kB of archives. After this operation, 5,237 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Selecting previously unselected package libcurl4-openssl-dev:armhf. (Reading database ... 44914 files and directories currently installed.) Preparing to unpack .../libcurl4-openssl-dev_7.74.0-1.3+deb11u11_armhf.deb ... Unpacking libcurl4-openssl-dev:armhf (7.74.0-1.3+deb11u11) ... Selecting previously unselected package deviceupdate-agent. Preparing to unpack .../deviceupdate-agent_1.1.0_armhf.deb ... **** Running /var/lib/dpkg/tmp.ci/preinst install 1.1.0 * Create the 'adu' group. Adding group adu' (GID 117) ... Done. Create the 'adu' user. Adding system useradu' (UID 111) ... Adding new user adu' (UID 111) with groupadu' ... Not creating home directory `/home/adu'. Add the 'adu' user to the 'syslog' group. Unpacking deviceupdate-agent (1.1.0) ... Setting up libcurl4-openssl-dev:armhf (7.74.0-1.3+deb11u11) ... Setting up deviceupdate-agent (1.1.0) ... **** Running /var/lib/dpkg/info/deviceupdate-agent.postinst configure * Setting directories and files... Generate the template configuration file... Generating the diagnostics configuration file... Create data dir... drwxrwx--- 3 adu adu 4096 May 6 17:59 /var/lib/adu drwxrwx--- 2 adu adu 4096 May 6 17:59 /var/lib/adu/downloads Register all reference step handlers... /var/lib/dpkg/info/deviceupdate-agent.postinst: line 218: 10000 Illegal instruction $adu_bin_path -l 2 --extension-type updateContentHandler --extension-id "microsoft/apt:1" --register-extension $adu_extensions_sources_dir/$adu_apt_handler_file dpkg: error processing package deviceupdate-agent (--configure): installed deviceupdate-agent package post-installation script subprocess returned error exit status 132 Processing triggers for man-db (2.9.4-2) ... Errors were encountered while processing: deviceupdate-agent E: Sub-process /usr/bin/dpkg returned an error code (1)

jw-msft commented 1 month ago

/var/lib/dpkg/info/deviceupdate-agent.postinst: line 218: 10000 Illegal instruction $adu_bin_path -l 2 --extension-type ... installed deviceupdate-agent package post-installation script subprocess returned error exit status 132

The armhf .deb on PMC is for armv7+ only, so would need to recompile for armv6l I think with -mcpu, etc. We support gen2+ not gen1 cortex cpu I think, so RPi3B+ is supported but RPi Zero.

Error 132 is likely errno EOVERFLOW and for ARMv7/armhf so my guess is it is using an instruction that is not available on armv6l.

The key issue I am seeing is the binary has armv7-only mov.w instruction in the _startup function in the ELF binary that are instructions not available in armv6l

wget https://packages.microsoft.com/debian/11/prod/pool/main/d/deviceupdate-agent/deviceupdate-agent_1.1.0_armhf.deb
ar x deviceupdate-agent_1.1.0_armhf.deb
tar xzvf data.tar.gz
sudo apt install -y gcc-arm-none-eabi
arm-linux-gnueabihf-objdump -d ./usr/bin/AducIotAgent > out.log
grep '<_start>' out.log -B4 -A 5

Here is _startup with the armv7-only mov.w instruction:

0000e17c <_start>:
    e17c:       f04f 0b00       mov.w   fp, #0
    e180:       f04f 0e00       mov.w   lr, #0
    e184:       bc02            pop     {r1}
    e186:       466a            mov     r2, sp
    e188:       b404            push    {r2}

readelf -A ./usr/bin/AducIotAgent shows it is compiled as armv7 so could have instructions in a .o that is not available in armv6l arch

$ readelf -A ./usr/bin/AducIotAgent
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_rounding: Needed
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6
Kralg commented 1 month ago

Hi @jw-msft,

Thanks for the insights. I was trying to build from sources the iot-hub-device-update agent but it seems in scripts/install-deps.sh that it depends on cmake 3.23.2 while the latest cmake on debian 11 raspberry zero is 3.18.4. If I change the deps to ignore cmake version I am getting: write error: No space left on device. Which is interesting that the SD card I use is 32GB. Wondering what is happening there. However, I guess cmake version ignoring probably can lead to error at some point.

jw-msft commented 1 month ago

@Kralg cmake 3.18.4 might work ok but haven't tried it on armv6l arm32 + deb11. NOTE: To build ADU Agent, you'll need to build the dependencies as per install-deps.sh such as IoTHub SDK, microsoft/do-client SDK static lib, and diagnostics (azure blob c++ SDK). Also, DO Agent needs to be built and installed on the runtime device for the DO SDK client calls to work. There are build-time options to simplify these dependencies if needed(e.g. you want to see things working e2e with minimal dependencies), so let us know if there is interest in that.

Kralg commented 1 month ago

Hi @jw-msft there is definetly interest in update agent support on armv6l. As there are mentioned cmake difference in version and building runs out of memory, I was not able to build. In general it would be very helpful if you could provide with simplified dependencies. Also would be very helpful if you could build a working binary. Thanks for your answers and I am looking forward to hearing from you.