Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
There isn't a build of the Mongoose OS mos cli tool for a Raspberry Pi provided, so this shows how to build the tool on an RPi

Install Mongoose OS mos CLI Tool on Raspberry Pi RPi

I enjoy seeing how little my dev environment can actually be to accomplish cool stuff. Currently I'm using a terminal app on my iPhone to remote into a RPi0w connected to an ESP8266 dev board to code and program the ESP8266 'from my iphone'. Mongoose OS is a fantastic OS for the ESPxx family line, with it's super easy interface and tons of built-in support into the OS (configuration, common IoT platforms, event-driven javascript, libraries, etc).

Considerations

  • Memory Constraint: Unfortunately RPi0s w 512MB of RAM do not have enough free memory (344MB on my RPi0) to compile. So I used an Raspberry Pi 4 with 2GB RAM to compile, then copied the binary over to the RPi0. I haven't tried a Pi3 or Pi2 w 1GB RAM, but they may work too.
  • I've only tested this using mos as a command line tool, not the GUI interface.

Build mos Tool

On the RPi...

# install dependencies
sudo apt-get install --yes golang build-essential python python-git libftdi-dev libusb-1.0 libftdi1-dev
go get github.com/kardianos/govendor

# create a working directory
mkdir ~/go; cd ~/go

# add to ~/.bashrc and reload
export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin"
export GO111MODULE=on
export GOPROXY=https://goproxy.io

# clone the mos tool repro
git clone --depth 1 https://github.com/mongoose-os/mos.git $GOPATH/src/mos
cd $GOPATH/src/mos

# build
make

# test build
./mos help

That's it! The output binary is at $GOPATH/bin/mos and can be copied to another RPi.

Remember that if you run ./mos by itself, the version of the tool at the time of writing this brings up a user interface, which if you're running in a terminal only, you won't see. So ctrl+c to close it and run it with commands.

If you get an out of memory error during compile, check with free -h. I know you'll need more than 344MB.

Acknolwedgements

Thanks to Brian Degger for his post on building the mos tool on an RPi that inspired me to bring it current.

@jerzykolysz
Copy link

jerzykolysz commented Jan 5, 2022

Could You please share binary, I have only rpi02 like You.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment