Setup commandline-based MicroPython development environment on Linux, macOS and Windows

Hi there,

Introduction

We recently made some efforts to verify our commandline-driven MicroPython development environment on Linux, macOS and Windows.

Installation

We would like to outline some steps for a successful installation here. Please let us know about any obstacles you might encounter as it will indirectly help others by improving the documentation.

Install Linux on WSL for Windows10

Install the development sandbox on Linux

Dokumentation

Die kanonische Dokumentation findet sich bei Setup Hiveeyes MicroPython Datalogger sandbox.

Schritt-für-Schritt Anleitung

1. Prerequisites

We need some packages for our work:

apt update
apt install make patch wget git python python3 python-virtualenv

2. Make or go to your working directory

cd /home
mkdir cgruber
cd cgruber

You should now have a prompt similar to
root@XPS13-CGruber:/home/cgruber#

3. Acquire source code

3.a First time

First, let’s create a directory called "sources" containing the working trees of source code repositories and change into that.

mkdir -p hiveeyes/sources
cd hiveeyes/sources/

There, let’s clone the Git repository from GitHub and change into that folder.

git clone https://github.com/hiveeyes/hiveeyes-micropython-firmware
cd hiveeyes-micropython-firmware/
3.b Update sources

If it’s a while ago since you initially cloned the repository, you might want to update it in order to grab the latest version.

git pull 

4. Configure your environment

Set your serial port with, in this case 16:

export MCU_PORT=/dev/ttyS16

You can check if this was done allready with

env

5. Go to the firmware dir and run setup

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware#

make setup
make install

6. Edit your settings file

Finally make a local copy of your setting file for the LoPy or FiPy and edit the settings.py file:

cp settings.example.py settings.py
nano settings.py

(of cause you can use emacs or vim instead of nano also ;-)

7. Upload the code to the LoPy or FiPy with

make sketch-and-run

Wie gewohnt kann mit git status der lokale branch mit dem auf github verglichen werden und bei Bedarf mit git pull die neueste Version heruntergeladen werden.


Cheatsheet

Schritte 3.b und 5. bis 7. kompakt und auf Englisch.

# Get most recent development sources
git pull

# Setup the sandbox environment on your workstation
make setup

# Upload framework and datalogger to the device
make install

# Upload program sketch and invoke device reset.
# This just uploads "boot.py", "main.py" and "settings.py".
make sketch-and-run
2 Likes

Dear Clemens,

thanks for caring about the stuff we are doing. In general, we are constantly trying to keep the documentation about how to Setup Hiveeyes MicroPython Datalogger sandbox updated and we did so recently for the 0.2.0 release.

Setting up the environment should work like outlined there and we will be happy to receive ideas about which could be improved.

Please don’t forget about "make download-requirements" and "make install-requirements" or its catch-all complement "make refresh-requirements". Otherwise, the Firmware will lack required dependencies after being uploaded to the device.

Cheers,
Andreas.

How can I check what serial port is in use in case I forgot my port?

1 Like

You might try the "make list-serials" command for that. At least, this gives an idea of all possible values you might want to use on your machine.

On my workstation, the output looks like that:

$ make list-serials
Serial Device: /dev/cu.Bluetooth-Incoming-Port
USB Serial Device 04d8:ef98 with vendor 'Pycom' serial 'Pye090a1' found @/dev/cu.usbmodemPye090a1

So, my personal sandbox initialization command would be:

export MCU_PORT=/dev/cu.usbmodemPye090a1

P.S.: You might want to pull the repository first, as you will need Fix "make list-serials" · hiveeyes/terkin-datalogger@948b375 · GitHub which does what it actually pretends to do: It fixes the very command I was referencing above ;].

A post was split to a new topic: Unstable serial port communication on Windows 10

Another way would be to use the pycom-fwtool-cli tool shipped with the Pycom Firmware Updater for your platform. You have to move from the Linux Subsystem to the Windows shell and run there:

cd c:\Program Files (x86)\Pycom\Pycom Firmware Update

pycom-fwtool-cli.exe list
COM4 [Prolific USB-to-Serial Comm Port (COM4)] [USB VID:PID=067B:2303 SER=6 LOCATION=1-1.1]

If it displays COM4 here, the corresponding TTY mapped into WSL would be /dev/ttyS4.

Thanks, @tonke!

After the baseline setup of the development sandbox works, you might want to look into installing additional sandbox tooling for your convenience, like Wartungsmodus für den Terkin-Datenlogger.

:warning: Please note the MicroTerkin Agent has to be installed natively on Windows, the WSL does not work here.

Wesentliche Teile unserer Makefile-basierten Sandbox ließen sich unter Windows auch alternativ nativ über eine geeignete make.exe ausführen.

Am einfachsten klappt die Installation von GNU Make nativ unter Windows in 2019 per

choco install make

Chocolatey Gallery | GNU Make 4.2.1
makefile - How to install and use "make" in Windows? - Stack Overflow

Vielleicht könnt Ihr bei Gelegenheit kurz prüfen, ob man damit z.B. make install-pycom-firmware ausgeführt bekommt?

P.S.: Auch wget werden wir brauchen, siehe Chocolatey Gallery | GNU Wget 1.20.3.20190531.

Habe choco install make in der Windows Power Shell als Admin ausgeführt, die Installation klappte.

Dann gibt es diese Fehlermeldungen:

PS C:\WINDOWS\system32> cd \\wsl$\Ubuntu\home\cgruber\hiveeyes\sources\hiveeyes-micropython-firmware
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Ubuntu\home\cgruber\hiveeyes\sources\hiveeyes-micropython-firmware> make install-pycom-firmware
process_begin: CreateProcess(NULL, cat .terkin/floatip, ...) failed.
make: tools/terkin.mk:15: pipe: No error
process_begin: CreateProcess(NULL, which lftp, ...) failed.
make: tools/micropython.mk:105: pipe: No error

\x1b[31;01m[ERROR]  \x1b[0m Pycom Firmware Updater not found

\x1b[36;01m[ADVICE] \x1b[0m Please go to https://docs.pycom.io/gettingstarted/installation/firmwaretool/ and follow
          the instructions to download the appropriate program matching your operating system.

          If you are running Linux, https://software.pycom.io/downloads/linux-1.15.1.html
          might make you happy.

make: *** [tools/pycom.mk:26: check-pycom-fwtool] Error 1
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Ubuntu\home\cgruber\hiveeyes\sources\hiveeyes-micropython-firmware>

wget läuft bei mir ein Versuch mit choco upgrade wget scheiterter aber

das log dazu: chocolatey-log.txt (33.1 KB)

Hi Clemens,

vielen Dank fürs kurz antesten!

Da ist in den Details wohl doch noch zu viel Makefile-spezifisches und Unixoides unter der Haube. Wir warten also besser, bis diese Eumelei nach Python portiert wurde, bevor wir hier komplette Plattformagnostik erwarten können.

Viele Grüße,
Andreas.

1 Like