Entwicklung der Terkin-Sandbox

Einleitung

Bei Betrieb der Terkin-Sandbox für MicroPython unter Linux sowie Operate the Terkin-Sandbox using the MicroTerkin Agent kann der aktuelle Stand der Technik nachgelesen werden.

Hier geht es um die Weiterentwicklung bislang vermisster Funktionalitäten.

Habe das gerade unter WSL getestet, mit Andreas am Telefonhörer, da es Probleme mit für den Dateitransfer benötigten Programm lftp gab. Wir haben dann lftp über den Chocolatey Paketmanager nativ unter Windows installiert [1]. Damit konnten wir dann mit lftp -f .\tools\upload-all.lftprc nach ein paar kleinen Modifikationen in der upload-all.lftprc die Dateien erfolgreich und fehlerfrei hochladen.

Unter WSL ist eine ältere lftp-Version installiert, wir vermuten, dass es daher nicht in WSL funktioniert hat. Ein Teil der Daten wurde übertragen, aber einige Verzeichnisse nicht, selbst nach ca. 10 Versuchen.


  1. Die Installation klappt per choco install lftp und das Programm liegt dann unter C:\ProgramData\chocolatey\bin\lftp.exe. Siehe auch MicroPython-Firmware schmirgeln (240er) - #52 by Andreas. ↩︎

Sehr schade! Ich hatte noch überlegt, ob ich gleich den Pure-Python Weg einschlagen soll oder erst später ;]. lftp kann schon was, aber für unsere Zwecke ist es nun wohl doch zu eingeschränkt bzw. an dieser Stelle bzgl. der Deploymentaspekte zu wenig universell. Pure-Python wird angestrebt!

Any chance precompiled firmwares can also be transferred over USB?

Do you actually mean FTP in this context?

Not IP-based but same as I transfer files by now over /dev/ttyXXXX

Now I get it. We should decouple the recycle-ng from being FTP-only. I will check this.

Das könnte jetzt klappen per Improve "make install-ng": Now also works over USB/UART · hiveeyes/terkin-datalogger@07ab010 · GitHub.

Nach manueller Installation von netaddr, netifaces und scapy bin ich bei:

$ make recycle-ng MPY_CROSS=true MPY_TARGET=pycom MPY_VERSION=1.9.4
Device port: usb => /dev/ttyACM0
make[1]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
\x1b[0m[INFO]   \x1b[0m Uploading MicroPython code to device using USB
make[1]: *** No rule to make target 'make'.  Stop.
make[1]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
Makefile:220: recipe for target 'install-ng' failed
make: *** [install-ng] Error 2

Hallo Matthias,

im Makefile waren noch ein paar Fehler und – viel wichtiger – ich hatte vergessen, die Datei upload-mpy.rshell zu committen – sorry! Bitte versuche es jetzt noch einmal.

Diese Pakete solltest Du eigentlich nicht benötigen, wenn Du nicht per IP-Kommunikation arbeitest. Die Installation über das Make-Target setup-terkin-agent wurde vermutlich durch das fehlerhafte Makefile ausgelöst.

Mit den neueren Firmwares wäre MPY_VERSION=1.11 besser, upload-mpy.rshell lädt ohnehin nur den Ordner lib-mpy-1.11-pycom hoch.

Viele Grüße,
Andreas.

1 Like

Wie auch immer. Es wurde sich darüber beschwert und erst nach der PIP-Installation in die .venv3 ging es überhaupt weiter. Meine, das auch schon bei der ersten Inbetriebnahme der Sandbox vollziehen zu müssen.

Es geht nun weiter bis:

$ make recycle-ng MPY_CROSS=true MPY_TARGET=pycom MPY_VERSION=1.11
Device port: usb => /dev/ttyACM0
make[1]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
\x1b[0m[INFO]   \x1b[0m Uploading MicroPython code to device using USB
make[1]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
make[1]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
make[2]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
\x1b[0m[INFO]   \x1b[0m Ahead-of-time compiling to .mpy pycom
\x1b[0m[INFO]   \x1b[0m Populating folder "lib-mpy-1.11-pycom"
make[3]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
PYTHONPATH=bin/mpy-cross/1.11 .venv2/bin/python ./bin/mpy_cross_all.py --target pycom --out lib-mpy-1.11-pycom dist-packages
make[3]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
make[3]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
PYTHONPATH=bin/mpy-cross/1.11 .venv2/bin/python ./bin/mpy_cross_all.py --target pycom --out lib-mpy-1.11-pycom lib
make[3]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
make[3]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
PYTHONPATH=bin/mpy-cross/1.11 .venv2/bin/python ./bin/mpy_cross_all.py --target pycom --out lib-mpy-1.11-pycom/terkin terkin
make[3]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
\x1b[0m[INFO]   \x1b[0m Size of lib-mpy-1.11-pycom:
480K	lib-mpy-1.11-pycom
480K	total
make[2]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
Using buffer-size of 2048
Connecting to /dev/ttyACM0 (buffer-size 2048)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /flash/
Setting time ... Dec 19, 2019 20:49:56
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
Unable to create /flash/lib-mpy-1.11-pycom
make[1]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
make[1]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
\x1b[32;01m[OK]     \x1b[0m MicroPython code upload finished
make[1]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'

\x1b[38;5;208m[WARNING]\x1b[0m It is crucial all files have been transferred successfully before restarting the device.
          Otherwise, chances are high the program will crash after restart.

\x1b[36;01m[ADVICE] \x1b[0m You might want to check the output of the file transfer process above for any errors.

make[1]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
\x1b[33;01m[CONFIRM]\x1b[0m Restart device using the HTTP API?make[2]: Entering directory '/home/thias/LoPy4/terkin-datalogger'
 [y/n] 

Zunächst werden die Farbcodes wohl nicht richtig interpretiert. Liegt das an der Shell? Ich bin auf der Bash unterwegs.

Der [y/n] Promt blinkt zwar aber, egal ob ich y oder n eingebe - es passiert weiter nichts. Außer mit [ENTER] dann:

tools/core.mk:124: recipe for target 'prompt_yesno' failed
make[2]: *** [prompt_yesno] Error 1
make[2]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
tools/core.mk:132: recipe for target 'confirm' failed
make[1]: *** [confirm] Error 2
make[1]: Leaving directory '/home/thias/LoPy4/terkin-datalogger'
Makefile:148: recipe for target 'recycle-ng' failed
make: *** [recycle-ng] Error 2

Jedoch, ein Reset des Boards zeigt mit make console den Boot und die Firmware tut ihre Dienste.

Die Ladezeit der Module wird von 10 auf 5 Sekunden reduziert. Für einen Zyklus nach DEEPSLEEP mit der LoRa/TTN Konfiguration sowie 2xDS18B20, 1xBME280 und 1xHX711 benötigt die Firmware nun nur noch 18 Sekunden Laufzeit.

18.6632 [terkin.device ] INFO : Entering deep sleep for 280.637 seconds
18.6803 [terkin.device ] INFO : Shutting down Terminal
1 Like

Der Reset des Boards nach der Übertragung wird wohl weiterhin über die http API versucht - was zwangsweise nicht funktioniert.

Das klappt jetzt vielleicht mit Improve "recycle-ng" Makefile target · hiveeyes/terkin-datalogger@8603855 · GitHub besser.

even with this PR that fixes two typos I can’t get rid of this error

/bin/sh: 5: @make: not found
Makefile:148: recipe for target 'recycle-ng' failed
make: *** [recycle-ng] Error 127

EDIT 1 : Oh, now I think I know. I’m not familiar with Makefile syntax :confused: one more commit…
EDIT 2 : seems to be working now

2 Likes

Neuerdings beim make setup:

Installing mpy-cross for MicroPython 1.9.4
ERROR: Could not find a version that satisfies the requirement mpy-cross==1.9.4 (from versions: none)
ERROR: No matching distribution found for mpy-cross==1.9.4
tools/micropython.mk:105: recipe for target 'mpy-cross-setup' failed
make: *** [mpy-cross-setup] Error 1

Gleiches auch bei anderen mpy-cross Versionen, zB 1.11

pip==20.0.1 macht wohl die Probleme. 19.3.1 funktioniert, wird aber beim Setup immer auf 20.0.1 angehoben.

Edit: gefixt mit

1 Like

@poesel also wants to use the cross-compilation procedure for uploading the firmware to a device running vanilla MicroPython 1.12.

What I am observing is…

root@Calvin:/home/markus/GitHub/terkin-datalogger# make install-ng
Device port: usb => /dev/ttyS3
make[1]: Entering directory '/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger'
[INFO]    Uploading MicroPython code to device using USB
make[1]: Leaving directory '/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger'
make[1]: Entering directory '/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger'
make[2]: Entering directory '/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger'
Device port: usb => /dev/ttyS3
.venv3/bin/rshell --port /dev/ttyS3 --user micro --password python --buffer-size 2048 mkdir /flash/dist-packages
Using buffer-size of 2048
Connecting to /dev/ttyS3 (buffer-size 2048)...
Trying to connect to REPL .. connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /boot.py/ /dist-packages/ /lib/ /main.py/ /project.pymakr/ /terkin/ /settings.py/ /backup/
Setting time ... Feb 16, 2020 16:24:06
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 2000
Unable to create /flash/dist-packages
.venv3/bin/rshell --port /dev/ttyS3 --user micro --password python --buffer-size 2048 rsync dist-packages /flash/dist-packages
Using buffer-size of 2048
Connecting to /dev/ttyS3 (buffer-size 2048)...
Trying to connect to REPL .... connected
Testing if ubinascii.unhexlify exists ... b"ets Jun  8 2016 00:22:57\r\n\r\nrst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)\r\nconfigsip: 0, SPIWP:0xee\r\nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00\r\nmode:DIO, clock div:2\r\nload:0x3fff0018,len:4\r\nload:0x3fff001c,len:4844\r\nload:0x40078000,len:10532\r\nload:0x40080400,len:6736\r\nentry 0x400806f0\r\n\x1b[0;32mI (534) psram: This chip is ESP32-D0WD\x1b[0m\r\n\x1b[0;32mI (534) spiram: Found 64MBit SPI RAM device\x1b[0m\r\n\x1b[0;32mI (534) spiram: SPI RAM mode: flash 40m sram 40m\x1b[0m\r\n\x1b[0;32mI (537) spiram: PSRAM initialized, cache is in low/high (2-core) mode.\x1b[0m\r\n\x1b[0;32mI (544) cpu_start: Pro cpu up.\x1b[0m\r\n\x1b[0;32mI (548) cpu_start: Application information:\x1b[0m\r\n\x1b[0;32mI (553) cpu_start: Compile time:     Dec 20 2019 07:52:43\x1b[0m\r\n\x1b[0;32mI (559) cpu_start: ELF file SHA256:  0000000000000000...\x1b[0m\r\n\x1b[0;32mI (565) cpu_start: ESP-IDF:          v3.3\x1b[0m\r\n\x1b[0;32mI (570) cpu_start: Starting app cpu, entry point is 0x40083d90\x1b[0m\r\n\x1b[0;32mI (562) cpu_start: App cpu up.\x1b[0m\r\n\x1b[0;32mI (1446) spiram: SPI SRAM memory test OK\x1b[0m\r\n\x1b[0;32mI (1446) heap_init: Initializing. RAM available for dynamic allocation:\x1b[0m\r\n\x1b[0;32mI (1446) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM\x1b[0m\r\n\x1b[0;32mI (1452) heap_init: At 3FFBA658 len 000259A8 (150 KiB): DRAM\x1b[0m\r\n\x1b[0;32mI (1459) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM\x1b[0m\r\n\x1b[0;32mI (1465) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM\x1b[0m\r\n\x1b[0;32mI (1472) heap_init: At 400973F0 len 00008C10 (35 KiB): IRAM\x1b[0m\r\n\x1b[0;32mI (1478) cpu_start: Pro cpu start user code\x1b[0m\r\n\x1b[0;32mI (154) cpu_start: Chip Revision: 1\x1b[0m\r\n\x1b[0;33mW (155) cpu_start: Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.\x1b[0m\r\n\x1b[0;32mI (158) cpu_start: Starting scheduler on PRO CPU.\x1b[0m\r\n\x1b[0;32mI (0) cpu_start: Starting scheduler on APP CPU.\x1b[0m\r\n[boot.py] INFO: Python module search path is: ['', '/lib']\r\n[boot.py] INFO: Universal MicroPython Application Loader (umal)\r\n[umal]    INFO: Python module search path is: ['/lib-mpy-1.11-bytecode', '', '/lib', '/dist-packages', '/terkin']\r\n[main.py] INFO: Loading settings\r\n[main.py] INFO: Starting logging\r\n[main.py] INFO: Loading Terkin Datalogger\r\n[main.py] INFO: Loading modules\r\n"
Traceback (most recent call last):
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 1255, in connect
    ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".venv3/bin/rshell", line 8, in <module>
    sys.exit(main())
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/command_line.py", line 4, in main
    rshell.main.main()
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 2843, in main
    real_main()
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 2805, in real_main
    connect(args.port, baud=args.baud, wait=args.wait, user=args.user, password=args.password)
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 1261, in connect
    connect_serial(port, baud=baud, wait=wait)
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 1285, in connect_serial
    dev = DeviceSerial(port, baud, wait)
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 1565, in __init__
    Device.__init__(self, pyb)
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 1339, in __init__
    unhexlify_exists = self.remote_eval(test_unhexlify)
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 1459, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/main.py", line 1437, in remote
    self.pyb.enter_raw_repl()
  File "/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger/.venv3/lib/python3.7/site-packages/rshell/pyboard.py", line 187, in enter_raw_repl
    raise PyboardError('could not enter raw repl')
rshell.pyboard.PyboardError: could not enter raw repl
make[2]: *** [Makefile:240: install-requirements] Error 1
make[2]: Leaving directory '/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger'
make[1]: *** [Makefile:217: install-rshell] Error 2
make[1]: Leaving directory '/mnt/c/Users/Markus/Documents/GitHub/terkin-datalogger'
make: *** [Makefile:227: install-ng] Error 2
  1. It looks like the program is still running. You might want to stop it firsthand.

  2. It looks like the process doesn’t pick up the cross-compiled directory yet. It should eventually be called "lib-mpy-1.12-bytecode".

… coming from Unlocking and improving the Pythings SIM800 GPRS module for MicroPython here. Thanks already!

Till now I have used MicroPython with PyCom devices and the fitting tools from PyCom like PyCom firmware updater, Atom with Pymkr, Terkin Sandbox. So what are the steps to unlock MicroPython on a “normal”, non-PyCom device as the TTGO T-Call?

I have sucessfully used the PyCom tool to erase the existing data on the devide with
pycom-fwtool-cli.exe --port COM6 erase_all

What worked also was: Installing the firmware TBEAMv1-1.20.2.rc3-0.8.0-vanilla-squirrel.tar.gz with

C:\Program Files (x86)\Pycom\Pycom Firmware Update>pycom-fwtool-cli.exe --port COM6 flash --tar TBEAMv1-1.20.2.rc3-0.8.0-vanilla-squirrel.tar.gz
Running in FTDI mode
Script Version: 2.1
Flash operation successful.

But I stall now with the next step install software. Can I use the Terkin Sandbox for this tasks or do I have to install other tools?

I have tried to access the REPL but had no luck neither with Atom / pymakr nor with the Terkin Sandbox:

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# make repl
Device port: usb => /dev/ttyS6
.venv3/bin/rshell --port /dev/ttyS6 --user micro --password python --buffer-size 2048 repl
Using buffer-size of 2048
Connecting to /dev/ttyS6 (buffer-size 2048)...
Trying to connect to REPL ....................Unable to connect to REPL

No MicroPython boards connected - use the connect command to add one

Unable to find board ''

Should it work? Is the TBEAM firmware working on the T-Call? Are the credentials --user micro --password python the same here? Any idea how to go on here?

[edit] When I update the firmware (via Windows shell) and switch directly after that to WSL and call make repl the REPL works, nice!

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# make repl
Device port: usb => /dev/ttyS6
.venv3/bin/rshell --port /dev/ttyS6 --user micro --password python --buffer-size 2048 repl
Using buffer-size of 2048
Connecting to /dev/ttyS6 (buffer-size 2048)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /flash/
Setting time ... Feb 19, 2020 11:01:35
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
Entering REPL. Use Control-X to exit.
>
Pycom MicroPython 1.20.2.rc3-0.8.0-vanilla-squirrel [v1.20.2.rc3-11-g69432bb17-dirty] on 2020-02-11; TBEAMv1 with ESP32
Type "help()" for more information.
>>>

make install starts running but stopps after a time, I think because the REPL is no more available:

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# make install
Device port: usb => /dev/ttyS6
.venv3/bin/rshell --port /dev/ttyS6 --user micro --password python --buffer-size 2048 mkdir /flash/dist-packages
Using buffer-size of 2048
Connecting to /dev/ttyS6 (buffer-size 2048)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /flash/
Setting time ... Feb 19, 2020 11:13:22
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
.venv3/bin/rshell --port /dev/ttyS6 --user micro --password python --buffer-size 2048 rsync dist-packages /flash/dist-packages
Using buffer-size of 2048
Connecting to /dev/ttyS6 (buffer-size 2048)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /flash/
Setting time ... Feb 19, 2020 11:13:23
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
timed out or error in transfer to remote
.venv3/bin/rshell --port /dev/ttyS6 --user micro --password python --buffer-size 2048 --file tools/upload-framework.rshell
Using buffer-size of 2048
Connecting to /dev/ttyS6 (buffer-size 2048)...
Trying to connect to REPL ....................Unable to connect to REPL
Destination directory /flash/lib does not exist.
Unable to create /flash/lib/terkin
Destination directory /flash/lib/terkin does not exist.
.venv3/bin/rshell --port /dev/ttyS6 --user micro --password python --buffer-size 2048 --file tools/upload-sketch.rshell
Using buffer-size of 2048
Connecting to /dev/ttyS6 (buffer-size 2048)...
Trying to connect to REPL ....................Unable to connect to REPL