How to run 32-bit (armhf) binaries on 64-bit (arm64) Debian OS on Raspberry Pi?

8,293

I had the same issue (multiple package architecture (armhf) does not match system (arm64) when doing apt install libc6:armhf). For me executing dpkg --add-architecture armhf solved this problem.

Share:
8,293

Related videos on Youtube

zmike
Author by

zmike

Software Engineer with an interest in finance and big data. Currently have 2+ years of experience in the software industry, having worked with relational databases (e.g. SQL Server, MySQL), programming languages (e.g. C#, C/C++, Python), and various OS environments (Windows, Linux, cloud-based solutions). I graduated in 2020 from the University of British Columbia (UBC) with a Bachelors of Applied Science in Computer Engineering and Minor in Commerce.

Updated on September 18, 2022

Comments

  • zmike
    zmike over 1 year

    Original Problem

    I have aarch64/arm64 version of Debian on a Raspberry Pi 3 B+ (2017) or Pi 4 (using an image from here). Now I want to run 32-bit (armhf/armv7) versions of some applications/libraries but they don't seem to work. Particular raspistill from the Raspbery Pi userland apps.

    Question: If at all possible, how do I get raspistill (and other 32-bit arm binaries) to run on a 64-bit OS?

    What I have tried:

    Additional steps taken

    Attempting to install libc6:armh

    Using raspbian source

    I tried installing libc6:armh with sudo apt-get install libc6:armhf, and I get the following message:

    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:
    
    The following packages have unmet dependencies:
     libc6:armhf : Depends: libgcc1:armhf but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    

    If I then try sudo apt-get install libc6:armhf libgcc1:armhf, I get a long list of additional or new packages to be installed, suggested packages, and packages that will be removed. The last part of the message indicates this:

    WARNING: The following essential packages will be removed.
    This should NOT be done unless you know exactly what you are doing!
      apt adduser (due to apt) gpgv (due to apt) libapt-pkg5.0 (due to apt) libc6 (due to apt) libgcc1 (due to apt) libgnutls30 (due to apt) libseccomp2 (due to apt) libstdc++6 (due to apt) base-files base-passwd libdebconfclient0 (due to base-passwd) bash
      libtinfo6 (due to bash) debianutils (due to bash) bsdutils libsystemd0 (due to bsdutils) coreutils libacl1 (due to coreutils) libattr1 (due to coreutils) libselinux1 (due to coreutils) dash dpkg (due to dash) debconf (due to dash) diffutils libbz2-1.0 (due to dpkg)
      liblzma5 (due to dpkg) zlib1g (due to dpkg) tar (due to dpkg) e2fsprogs libblkid1 (due to e2fsprogs) libcom-err2 (due to e2fsprogs) libext2fs2 (due to e2fsprogs) libss2 (due to e2fsprogs) libuuid1 (due to e2fsprogs) fdisk libfdisk1 (due to fdisk)
      libmount1 (due to fdisk) libncursesw6 (due to fdisk) libsmartcols1 (due to fdisk) findutils grep libpcre3 (due to grep) gzip hostname init systemd-sysv (due to init) init-system-helpers (due to init) perl-base (due to init-system-helpers) libc-bin login
      libaudit1 (due to login) libpam0g (due to login) libpam-runtime (due to login) libpam-modules (due to login) mount util-linux (due to mount) ncurses-bin sed sysvinit-utils libcap-ng0 (due to util-linux) libudev1 (due to util-linux)
    0 upgraded, 3 newly installed, 272 to remove and 1 not upgraded.
    Need to get 2534 kB of archives.
    After this operation, 718 MB disk space will be freed.
    You are about to do something potentially harmful.
    To continue type in the phrase 'Yes, do as I say!'
    

    Using default debian source

    I thought that I would temporarily remove the raspbian source from /etc/apt/sources.list and just use the default debian sources, but with the armhf architecture enables. Example from sources.list: deb [arch=arm64,armhf] http://deb.debian.org/debian buster main contrib non-free.

    Now when I run sudo apt-get install libc6:armhf, I get an error stating: package architecture (armhf) does not match system (arm64). I get this error even after running sudo apt-get update, upgrade, dist-upgrade, clean and autoclean.

    Get:2 http://deb.debian.org/debian buster/main armhf libgcc1 armhf 1:8.3.0-6 [37.2 kB]
    Get:3 http://deb.debian.org/debian buster/main armhf libc6 armhf 2.28-10 [2390 kB]
    Get:4 http://deb.debian.org/debian buster/main armhf libunistring2 armhf 0.9.10-1 [368 kB]
    Get:5 http://deb.debian.org/debian buster/main armhf libidn2-0 armhf 2.0.5-1+deb10u1 [74.3 kB]
    Fetched 3060 kB in 2s (1430 kB/s)
    Preconfiguring packages ...
    dpkg: error processing archive /var/cache/apt/archives/gcc-8-base_8.3.0-6_armhf.deb (--unpack):
     package architecture (armhf) does not match system (arm64)
    dpkg: error processing archive /var/cache/apt/archives/libgcc1_1%3a8.3.0-6_armhf.deb (--unpack):
     package architecture (armhf) does not match system (arm64)
    dpkg: error processing archive /var/cache/apt/archives/libc6_2.28-10_armhf.deb (--unpack):
     package architecture (armhf) does not match system (arm64)
    dpkg: error processing archive /var/cache/apt/archives/libunistring2_0.9.10-1_armhf.deb (--unpack):
     package architecture (armhf) does not match system (arm64)
    dpkg: error processing archive /var/cache/apt/archives/libidn2-0_2.0.5-1+deb10u1_armhf.deb (--unpack):
     package architecture (armhf) does not match system (arm64)
    Errors were encountered while processing:
     /var/cache/apt/archives/gcc-8-base_8.3.0-6_armhf.deb
     /var/cache/apt/archives/libgcc1_1%3a8.3.0-6_armhf.deb
     /var/cache/apt/archives/libc6_2.28-10_armhf.deb
     /var/cache/apt/archives/libunistring2_0.9.10-1_armhf.deb
     /var/cache/apt/archives/libidn2-0_2.0.5-1+deb10u1_armhf.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    Running apt policy libc6:arm{hf,64} libgcc1:arm{hf,64} outputs:

    libc6:armhf:
      Installed: (none)
      Candidate: 2.28-10
      Version table:
         2.28-10 990
            990 http://deb.debian.org/debian buster/main armhf Packages
    libc6:
      Installed: 2.28-10
      Candidate: 2.28-10
      Version table:
     *** 2.28-10 990
            990 http://deb.debian.org/debian buster/main arm64 Packages
            100 /var/lib/dpkg/status
    libgcc1:armhf:
      Installed: (none)
      Candidate: 1:8.3.0-6
      Version table:
         1:8.3.0-6 990
            990 http://deb.debian.org/debian buster/main armhf Packages
    libgcc1:
      Installed: 1:8.3.0-6
      Candidate: 1:8.3.0-6
      Version table:
     *** 1:8.3.0-6 990
            990 http://deb.debian.org/debian buster/main arm64 Packages
            100 /var/lib/dpkg/status
    
    • Stephen Kitt
      Stephen Kitt over 3 years
      Do you have libc6:armhf installed?
    • zmike
      zmike over 3 years
      I tried installing libc6:armhf (on a test image) using apt-get along with a few dependencies, but it didn't work. apt did warn me that it was a dangerous alternative, and, unsurprisingly, this did lead to a kernel panic on reboot.
    • zmike
      zmike over 3 years
      @StephenKitt any alternatives?
    • Stephen Kitt
      Stephen Kitt over 3 years
      If you want to use multiarch to get 32-bit binaries running, you need libc6:armhf installed alongside libc6:arm64. Could you edit your question to include the information from your comment above, and add the exact messages shown by apt (informing you that it was a “dangerous alternative”)?
    • zmike
      zmike over 3 years
      @StephenKitt Updated the question
    • Stephen Kitt
      Stephen Kitt over 3 years
      Is your system fully up-to-date? You need to run apt upgrade before attempting to install multiarch packages.
    • zmike
      zmike over 3 years
      @StephenKitt Yes it is, I ran sudo apt-get update, then upgrade and then dist-upgrade (to upgrade linux-image-arm64).
    • zmike
      zmike over 3 years
      @StephenKitt I added the output to the question.
    • zmike
      zmike about 3 years
      @francis No, haven't figured it out yet. We used 32-bit Raspbian for the time being