Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino CLI not working in mozillaiot/gateway Docker container on Raspberry Pi 4b (ARMv7) #19

Open
tatemz opened this issue Jul 19, 2020 · 4 comments

Comments

@tatemz
Copy link

tatemz commented Jul 19, 2020

I posted this issue in the docker image repo (WebThingsIO/gateway-docker#42), but have since found more info on the problem. The arduino-cli that comes pre-packaged in the Candle-manager-addon does not work within the mozillaiot/gateway Docker image (which is based on node:12-buster-slim). The workaround for me was to download the arduino-cli from https://arduino.github.io/arduino-cli/installation/ and update the SHA256SUMS file (using sed).

Here's my docker create/startup script that installs the addon and performs the above workaround.

#!/bin/bash

TMP_DIR=./.tmp
IOT_DATA=/home/pi/Development/iot/data 
ADDONS="$IOT_DATA/addons"
CANDLE_ADDON_SRC="https://s3-us-west-2.amazonaws.com/mozilla-gateway-addons/Candle-manager-addon-1.1.0-linux-arm-v3.5.tgz"
CANDLE_ADDON_DIR="$ADDONS/Candle-manager-addon"
ARDUINO_CLI_TAR="https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARMv7.tar.gz"

docker run \
    -it \
    -e TZ=America/Chicago \
    -v /home/pi/Development/iot/data:/home/node/.mozilla-iot \
    --device "/dev/ttyUSB0:/dev/ttyUSB0" \
    --network="host" \
    --log-opt max-size=1m \
    --log-opt max-file=10 \
    --name webthings-gateway \
    mozillaiot/gateway:latest

mkdir -p $ADDONS
if [ ! -d $CANDLE_ADDON_DIR ]; then
        mkdir -p $TMP_DIR
        curl -L $CANDLE_ADDON_SRC | tar xzv --directory $TMP_DIR
        mv $TMP_DIR/package $CANDLE_ADDON_DIR
        curl -kL $ARDUINO_CLI_TAR | tar xzv --directory $TMP_DIR
        mv $TMP_DIR/arduino-cli $CANDLE_ADDON_DIR/arduino-cli/linux-arm/arduino-cli
        ARDUINO_CLI_SUM=`cd $CANDLE_ADDON_DIR && sha256sum ./arduino-cli/linux-arm/arduino-cli`
        sed -i -e "s%^.*\s*\.\/arduino-cli\/linux-arm\/arduino-cli\$%$ARDUINO_CLI_SUM%g" $CANDLE_ADDON_DIR/SHA256SUMS
        rm -rf $TMP_DIR
fi

# Have to restart it because the first run exits with an SQLITE error
docker restart webthings-gateway
@tatemz tatemz changed the title Arduino CLI not working in mozillaiot/gateway Docker container (ARMv7) Arduino CLI not working in mozillaiot/gateway Docker container on Raspberry Pi 4b (ARMv7) Jul 19, 2020
@createcandle
Copy link
Collaborator

Very nice work.

I've also created a simple update script so updating will be easier in the future.

@renatose
Copy link

renatose commented Jan 4, 2021

I am using a RPi B+ and the bundled arduino-cli is the armv7 so it does not work, it needs to be the armv6 for that RPi.

@createcandle
Copy link
Collaborator

@renatose could you enable debugging in the settings and find out in the internal log if you find what it says after self.arduino_cli_path= ?

Candle Manager does have built in support for ArmV6 already.

@createcandle
Copy link
Collaborator

I was wrong, it did not. I'm adding it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants