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/hiveeyes-micropython-firmware@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.