Trying to build Etcher on Raspberry Pi 4

I tried

./node_modules/.bin/electron-builder --arm --linux deb

And it failed with the message:

Unknown argument: arm

It also dumped all the permitted commands, as if I had specified “–help”, and there are clearly only two arm-related choices, which are:

  --armv7l                 Build for armv7l                            [boolean]
  --arm64                  Build for arm64                             [boolean]

So, I’m going to try armv7l, just to see what happens.

When I try armv7l, I get the following, which seems like a lot of successful building followed by a failure to package, trying to run an x86 version of fpm on an arm machine.

pi@pi4:~/Documents/etcher $ ./node_modules/.bin/electron-builder --armv7l --linux deb
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
  • electron-builder version=20.40.2
  • loaded configuration file=/home/pi/Documents/etcher/electron-builder.yml
  • writing effective config file=dist/builder-effective-config.yaml
  • executing node-gyp rebuild arch=armv7l
  • rebuilding native production dependencies platform=linux arch=armv7l
  • packaging       platform=linux arch=armv7l electron=3.1.9 appOutDir=dist/linux-armv7l-unpacked
  • building        target=deb arch=armv7l file=dist/balena-etcher_1.5.60_armv7l.deb
Error: Exit code: 1. Command failed: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/fpm -s dir -t deb --architecture armv7l --name balena-etcher --force --after-install /tmp/t-Bew2la/0-after-install --after-remove /tmp/t-Bew2la/1-after-remove --description balenaEtcher is a powerful OS image flasher built with web technologies to ensure flashing an SDCard or USB drive is a pleasant and safe experience. It protects you from accidentally writing to your hard-drives, ensures every byte of data was written correctly and much more.
 Flash OS images to SD cards and USB drives, safely and easily. --version 1.5.60 --package /home/pi/Documents/etcher/dist/balena-etcher_1.5.60_armv7l.deb --maintainer Balena Inc. <hello@etcher.io> --url https://github.com/balena-io/etcher --vendor Balena Inc. <hello@etcher.io> --category utils --deb-compression xz --deb-priority optional --depends gconf2 --depends gconf-service --depends libappindicator1 --depends libasound2 --depends libatk1.0-0 --depends libc6 --depends libcairo2 --depends libcups2 --depends libdbus-1-3 --depends libexpat1 --depends libfontconfig1 --depends libfreetype6 --depends libgcc1 --depends libgconf-2-4 --depends libgdk-pixbuf2.0-0 --depends libglib2.0-0 --depends libgtk-3-0 --depends liblzma5 --depends libnotify4 --depends libnspr4 --depends libnss3 --depends libpango1.0-0 --depends libstdc++6 --depends libx11-6 --depends libxcomposite1 --depends libxcursor1 --depends libxdamage1 --depends libxext6 --depends libxfixes3 --depends libxi6 --depends libxrandr2 --depends libxrender1 --depends libxss1 --depends libxtst6 --depends polkit-1-auth-agent | policykit-1-gnome | polkit-kde-1 --license Apache-2.0 /home/pi/Documents/etcher/dist/linux-armv7l-unpacked/=/opt/balenaEtcher /home/pi/Documents/etcher/assets/iconset/16x16.png=/usr/share/icons/hicolor/16x16/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/32x32.png=/usr/share/icons/hicolor/32x32/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/48x48.png=/usr/share/icons/hicolor/48x48/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/128x128.png=/usr/share/icons/hicolor/128x128/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/256x256.png=/usr/share/icons/hicolor/256x256/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/512x512.png=/usr/share/icons/hicolor/512x512/apps/balena-etcher-electron.png /tmp/t-Bew2la/2-balenaEtcher.desktop=/usr/share/applications/balena-etcher-electron.desktop
/home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: cannot execute binary file: Exec format error
/home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: Success

/home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: cannot execute binary file: Exec format error
/home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: Success

    at /home/pi/Documents/etcher/node_modules/builder-util/src/util.ts:126:16
    at ChildProcess.exithandler (child_process.js:301:5)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Pipe._handle.close (net.js:600:12)
From previous event:
    at FpmTarget.build (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/targets/fpm.ts:93:44)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/platformPackager.ts:131:24
From previous event:
    at AsyncTaskManager.add (/home/pi/Documents/etcher/node_modules/builder-util/src/asyncTaskManager.ts:14:20)
    at LinuxPackager.packageInDistributableFormat (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/platformPackager.ts:123:17)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/platformPackager.ts:114:10
    at Generator.next (<anonymous>)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
From previous event:
    at LinuxPackager.pack (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/platformPackager.ts:111:95)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:430:24
    at Generator.next (<anonymous>)
    at xfs.stat (/home/pi/Documents/etcher/node_modules/fs-extra-p/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16)
    at /home/pi/Documents/etcher/node_modules/graceful-fs/polyfills.js:285:20
    at FSReqWrap.oncomplete (fs.js:155:5)
From previous event:
    at Packager.doBuild (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:396:24)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:366:57
    at Generator.next (<anonymous>)
    at /home/pi/Documents/etcher/node_modules/graceful-fs/graceful-fs.js:111:16
    at /home/pi/Documents/etcher/node_modules/graceful-fs/graceful-fs.js:45:10
    at FSReqWrap.oncomplete (fs.js:141:20)
From previous event:
    at Packager._build (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:335:133)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:331:23
    at Generator.next (<anonymous>)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
From previous event:
    at Packager.build (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:288:14)
    at build (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/index.ts:59:28)
    at build (/home/pi/Documents/etcher/node_modules/electron-builder/src/builder.ts:228:10)
    at then (/home/pi/Documents/etcher/node_modules/electron-builder/src/cli/cli.ts:46:19)

and, as previous posts have covered, so far I haven’t been able to get a proper fpm.

I’ve asked for help with this on the Raspberry Pi forum - perhaps they can help me get a working fpm installed, and then I can get back here to continue the build, trying @shaunmulligan’s tip about pointing to a local fpm.

Hello everyone,
It seems that another user successfully built a debian package for rpi4, you can check the forum thread here
@futurejones If you’re willing to give some feedback about the issues you encountered and how you overcame them, even if they made you switch to another path, that would be highly appreciated so we can hopefully enhance the documentation with the missing pieces and/or investigate more!

@thundron, I am working on that now. When I have successfully reproduced all the build steps I will post details.

In pursuit of getting a native fpm installed, I did the following:

It seemed that I couldn’t get rubygems via apt because the debian/apt dependencies were messed up, so I got it the ruby way:

sudo gems update --system

This got me RubyGems 3.0.6

Install ruby header files:

sudo apt install ruby-dev

This then allowed me to install fpm, the package tool I think I need to package the .deb:

sudo gem install fpm

Now trying the workaround to use the native fpm, that @shaunmulligan suggested:

USE_SYSTEM_FPM="true" ./node_modules/.bin/electron-builder --armv7l --linux deb

pi@pi4:~/Documents/etcher $ USE_SYSTEM_FPM="true" ./node_modules/.bin/electron-builder --armv7l --linux deb
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
  • electron-builder version=20.40.2
  • loaded configuration file=/home/pi/Documents/etcher/electron-builder.yml
  • writing effective config file=dist/builder-effective-config.yaml
  • executing node-gyp rebuild arch=armv7l
  • rebuilding native production dependencies platform=linux arch=armv7l
  • packaging       platform=linux arch=armv7l electron=3.1.9 appOutDir=dist/linux-armv7l-unpacked
  • building        target=deb arch=armv7l file=dist/balena-etcher_1.5.60_armv7l.deb


   ╭─────────────────────────────────────────────────╮
   │                                                 │
   │       Update available 20.40.2 → 22.1.0         │
   │   Run yarn upgrade electron-builder to update   │
   │                                                 │
   ╰─────────────────────────────────────────────────╯

Now, I’ll have to try that deb…

I get errors:

Installing /var/cache/apt/archives/partial/balena-etcher_1.5.60_armv7l.deb
tar: Archive is compressed. Use -J option
tar: Error is not recoverable: exiting now
dpkg-deb: error: tar subprocess returned error exit status 2
dpkg: error processing archive /var/cache/apt/archives/partial/balena-etcher_1.5.60_armv7l.deb (--install):
 dpkg-deb --control subprocess returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/partial/balena-etcher_1.5.60_armv7l.deb

Looking up about tar and -J, I found the following in the tar man page:

-J, --xz
Filter the archive through xz(1).

But I don’t know how to filter such a command into the installation process.

Looks like https://github.com/jordansissel/fpm/issues/1612 to me. So it’s a fpm issue again :confused:

As @robertgzr said, this is a known fpm-1.11.0 problem
https://github.com/jordansissel/fpm/issues/1612

fix by rolling back fpm to 1.10.2
	see https://stackoverflow.com/questions/17026441/how-to-install-a-specific-version-of-a-ruby-gem#17026442
	gem uninstall fpm
	gem install fpm -v 1.10.2

That builds OK (but so did the newer fpm, it just wouldn’t install!)

pi@pi4:~/Documents/etcher $ USE_SYSTEM_FPM="true" ./node_modules/.bin/electron-builder --armv7l --linux deb
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
  • electron-builder version=20.40.2
  • loaded configuration file=/home/pi/Documents/etcher/electron-builder.yml
  • writing effective config file=dist/builder-effective-config.yaml
  • executing node-gyp rebuild arch=armv7l
  • rebuilding native production dependencies platform=linux arch=armv7l
  • packaging       platform=linux arch=armv7l electron=3.1.9 appOutDir=dist/linux-armv7l-unpacked
  • building        target=deb arch=armv7l file=dist/balena-etcher_1.5.60_armv7l.deb


   ╭─────────────────────────────────────────────────╮
   │                                                 │
   │       Update available 20.40.2 → 21.2.0         │
   │   Run yarn upgrade electron-builder to update   │
   │                                                 │
   ╰─────────────────────────────────────────────────╯

Well, that gets farther, at least it doesn’t complain as it did before. But…

pi@pi4:~/Documents/etcher/dist $ sudo apt install  /var/cache/apt/archives/partial/balena-etcher_1.5.60_armv7l.deb 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'balena-etcher:armv7l' instead of '/var/cache/apt/archives/partial/balena-etcher_1.5.60_armv7l.deb'
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:
 balena-etcher:armv7l : Depends: libappindicator1:armv7l but it is not installable
                        Depends: libasound2:armv7l but it is not installable
                        Depends: libatk1.0-0:armv7l but it is not installable
                        Depends: libc6:armv7l but it is not installable
                        Depends: libcairo2:armv7l but it is not installable
                        Depends: libcups2:armv7l but it is not installable
                        Depends: libdbus-1-3:armv7l but it is not installable
                        Depends: libexpat1:armv7l but it is not installable
                        Depends: libfontconfig1:armv7l but it is not installable
                        Depends: libfreetype6:armv7l but it is not installable
                        Depends: libgcc1:armv7l but it is not installable
                        Depends: libgconf-2-4:armv7l but it is not installable
                        Depends: libgdk-pixbuf2.0-0:armv7l but it is not installable
                        Depends: libglib2.0-0:armv7l but it is not installable
                        Depends: libgtk-3-0:armv7l but it is not installable
                        Depends: liblzma5:armv7l but it is not installable
                        Depends: libnotify4:armv7l but it is not installable
                        Depends: libnspr4:armv7l but it is not installable
                        Depends: libnss3:armv7l but it is not installable
                        Depends: libpango1.0-0:armv7l but it is not installable
                        Depends: libstdc++6:armv7l but it is not installable
                        Depends: libx11-6:armv7l but it is not installable
                        Depends: libxcomposite1:armv7l but it is not installable
                        Depends: libxcursor1:armv7l but it is not installable
                        Depends: libxdamage1:armv7l but it is not installable
                        Depends: libxext6:armv7l but it is not installable
                        Depends: libxfixes3:armv7l but it is not installable
                        Depends: libxi6:armv7l but it is not installable
                        Depends: libxrandr2:armv7l but it is not installable
                        Depends: libxrender1:armv7l but it is not installable
                        Depends: libxss1:armv7l but it is not installable
                        Depends: libxtst6:armv7l but it is not installable
E: Unable to correct problems, you have held broken packages.

Or, trying to install another way:

pi@pi4:~/Documents/etcher/dist $ sudo dpkg -i balena-etcher_1.5.60_armv7l.deb 
dpkg: error processing archive balena-etcher_1.5.60_armv7l.deb (--install):
 package architecture (armv7l) does not match system (armhf)
Errors were encountered while processing:
 balena-etcher_1.5.60_armv7l.deb

After trying many different build combinations, including writing my own packaging script, I have found the following to be the most reliable and consistent method of building Etcher. This method has been tested on a fresh install of Raspbian Buster on a Raspberry Pi 4.

Build Instructions

  1. Install build dependencies.
sudo apt-get install -y git python gcc g++ make libx11-dev libxkbfile-dev fakeroot rpm libsecret-1-dev jq python2.7-dev python-pip python-setuptools libudev-dev
sudo apt-get install ruby-dev
sudo gem install fpm -v 1.10.2 #note: must be v1.10.2 NOT v1.11.0
#install NodeJS
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
  1. Clone Repo and Checkout Release .
git clone --recursive https://github.com/balena-io/etcher
cd etcher
git checkout v1.5.63
  1. Install Requirements
pip install -r requirements.txt
  1. Setup and Install NPM Modules .
make electron-develop

At this point you should be able to run a test of Etcher with -

npm start
  1. Patch Build Files
# disable tiffutil in the Makefile as this is a Mac only app and will cause the build to fail
sed -i 's/tiffutil/#tiffutil/g' Makefile 
# restrict output to .deb package only to save build time
sed -i 's/TARGETS="deb rpm appimage"/TARGETS="deb"/g' scripts/resin/electron/build.sh
  1. Build and Package
# use USE_SYSTEM_FPM="true" to force the use of the installed FPM version
USE_SYSTEM_FPM="true" make electron-build 
  1. Install Package
#  *.deb package will be in /etcher/dist/*
# filename will depend on which release version was checked out
sudo apt-get install ./dist/balena-etcher-electron_1.5.63+a1558116_armv7l.deb 

Note: You can ignore the chmod: cannot access '/opt/balenaEtcher/chrome-sandbox': No such file or directory warning. It is caused by the postinst file and is only relevant for electron versions 5+.

Thanks for sharing your notes @futurejones. Appreciated. Hope these are useful for @tinker2much and anyone following this thread.

I’m pinging our Etcher maintainers in residence (@thundron and @zvin) about it.

FYI: @futurejones has a github site where he’s got the whole Etcher-on-a-Pi process nailed, and where he provides some easy scripts : install_dependencies, build, and package_etcher. See here.

The Raspberry Pi 4 is the successor to the Raspberry Pi 3. It builds upon the Pi 3 by upgrading the ARM cores to Cortex-A72, offering up to 4GB RAM, USB 3.0, and gigabit ethernet.

I did see mention of an A71, in the threads below, but not a 72? IMHO this device was released working on Raspbian, but somehow “green” Just the issues app developers are having with it. Octoprint barely works on a Pi4, for example.

I’m not a code jock, but I see known inconsistencies. x86 Architecture is a CISC (inline construction set chip. The ARM 64 chip is a true RISC chip (reduced instruction set chip) aka parallel processing. It is more of the “Alpha” “Power” “Itanium” “Sun” series of chips. The fact that ARM servers are replacing CISC servers, for untethered parallel processing power, is not to be overlooked. I’m just pointing out these things, porting from one chip architecture to another.

That’s why the original Power Macs were such screamers. Parallel processing. The fact they ran MS Office (but the highest base of installed versions of MS Office) Still MS was a CISC company. Pushing to all PC/x86 manufacturers. But Mac is what kept them alive.

I digress… These are things to truly consider when porting across architectures. Not known to be a piece of cake. We just all have access to the tools today. But what did the Alpha, Itanium & Power programmers really do to port NT4-5 to their platforms? Privately own software originally developed for VMS. AKA Posix. Posix is still in Win.xxx today.

Another case of Mr. Gates silently slipping someone else’s code under his arm.