Gebrauchsanleitung zum WLAN-Board Air602 (ARM Cortex M3 + WLAN)

Begonnen von juergs, 14 April 2020, 11:12:57

Vorheriges Thema - Nächstes Thema

juergs

Ich möchte Euch diese Variante zur Kommunikation mit WLAN vorstellen.
Da die Einarbeitung doch einige ,,Hürden" bereitstellt, möchte ich meine Vorgehensweise dazu hier schildern, um den Einstieg zu erleichtern.

Vielleicht findet der Eine oder Andere dies auch interessant findet, hat aber vor der Pionierarbeit zurückgeschreckt,
da u.A. die Dokumentation des Chips durchaus sehr dürftig zu nennen ist und noch schlimmer auch teilweise in Chinesisch verfasst ist.   :o
Ein Grund (für Schwaben  ;D) Kostenpunkt um die $1.90!

Im Prinzip handelt sich erst mal um dieses Board:https://www.seeedstudio.com/Air602-WiFi-Module.html
Dazu gibt es ein USB-Development-Board: http://wiki.seeedstudio.com/Air602_WiFi_Development_Board/
Weitere Infos und Eagle-Footprints: https://w600.chip.haus/ und  hier
Weiterführende Infos, auch zu anderen Boards: Air602-blink und hier w600-pico/
Brauchbarer Schaltplan : https://docs.wemos.cc/en/latest/_static/files/sch_w600_pico_v1.0.0.pdf
Pinout: http://www.winnermicro.com/upload/1/editor/1543924482374.pdf
Firmware: https://download.w600.fun/ und Firmware_Update_Guide
Hardware + Antenne: https://www.shotech.de/de/air602-wifi-module.html
Hersteller-Seite: http://www.winnermicro.com/en/html/1/156/158/497.html
Github: W600_Tcp_To_Serial_Bridge
Aktuelle MicroPython-Version: http://www.winnermicro.com/en/upload/1/editor/1573450100756.zip
(sysname='w600', nodename='w600', release='1.12.0', version='v1.12-479-gad28bc355-dirty on 2020-05-26', machine='WinnerMicro module with W600')
https://github.com/robert-hh/Shared-Stuff     wm_w600.fls vom 2020-05-26 (!)
First steps with the W600 (on Linux)
Funktionsübersicht

Es wird Standard-mäßig mit einer AT-Kommando-Firmware ausgeliefert. (Wer's mag...)

Wemos "versteckte" W600-Doku für MicroPython: https://docs.wemos.cc/en/latest/tutorials/w600/get_started_with_micropython_w600.html

Allerdings kann das Teil mit Hilfe von MicroPython wesentlich mehr leisten, wenn man die Voraussetzungen dafür in den wenigen Quellen im Internet  gefunden hat.
Das geht auch Plattform-unabhängig, in meinem Fall: Win10.
1.)   Reguläre Python3-Installation ( z. B. Python-Version 3.8 über den Marketplace)
2.)   Benutzung von VSCode + Plugin "Pymakr"
3.)   MicroPython-Image (Binaries ".img") aus der Wemos-Dokumentation: https://docs.wemos.cc/en/latest/tutorials/w600/get_started_with_micropython_w600.html
        Dort sind auch die Links auf: CH340 Driver + Python 3.7 or newer + w600tool (flash-Tool für w600 firmware) (pip3 install w600tool) + Micropython firmware v1.10 (Das zu flashende  Micropython-Image) zu finden.
4.)   Flashtool-Installation: pip3 install w600tool installiert zwar, lässt sich aber über pyton3 w600tool nicht aufrufen, deshalb ergab die Suche:
        C:\Users\js>where w600Tool.py
        C:\Users\js\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\w600tool.py.exe
        Dort liegt also die Exe. Hatte das w600tool.py-Script aber auch von github geladen: https://github.com/vshymanskyy/w600tool

5.)   Hardware: Steckbrett-Testboard: Über FTDI-COM-Schnittstelle RX/TX gedreht an TX/RX des Air602-Moduls. Reset-Taster an GND und RES. Stromversorgung (3V3) über MapleMini.

Python, in diesem Fall MicroPython ist natürlich etwas anders konzipiert wie die Programmierung in C/C++ (z.B. für den ES8266/ESP32.
Für die es aber durchaus auch Versionen gibt! 


Zum Flashen des Images habe ich mich erst mal für den manuellen Weg  über die Konsole entschieden und gleich ein BatchFile dazu angelegt (später dazu mehr):
python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload-baud 115200 --upload "D:\Work_STM32\_Hardware\Air602\_firmware\W600_Micropython_Firmware\W60X_MicroPython_1.10_B1.3_IMG\wm_w600_gz.img"

Ergab:
ZitatC:\Users\js>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload  D:\Work_STM32\_Hardware\Air602\_firmware\W600_Micropython_Firmware\W60X_MicroPython_1.10_B1.3_IMG\wm_w600_gz.img
Traceback (most recent call last):
  File "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py", line 10, in <module>
    import pyprind
ModuleNotFoundError: No module named 'pyprind'

und weitere Abhängigkeiten:

C:\Users\js>pip3 install serial
Collecting serial
  Downloading serial-0.0.97-py2.py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 1.3 MB/s
Collecting iso8601>=0.1.12
  Downloading iso8601-0.1.12-py2.py3-none-any.whl (12 kB)
Collecting future>=0.17.1
  Downloading future-0.18.2.tar.gz (829 kB)
     |████████████████████████████████| 829 kB 6.4 MB/s
Collecting pyyaml>=3.13
  Downloading PyYAML-5.3.1-cp38-cp38-win_amd64.whl (219 kB)
     |████████████████████████████████| 219 kB 3.2 MB/s
Installing collected packages: iso8601, future, pyyaml, serial
    Running setup.py install for future ... done
Successfully installed future-0.18.2 iso8601-0.1.12 pyyaml-5.3.1 serial-0.0.97

C:\Users\js>pip3 install pyprind
Collecting pyprind
  Downloading PyPrind-2.11.2-py3-none-any.whl (8.6 kB)
Installing collected packages: pyprind
Successfully installed pyprind-2.11.2

C:\Users\js>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload  D:\Work_STM32\_Hardware\Air602\_firmware\W600_Micropython_Firmware\W60X_MicroPython_1.10_B1.3_IMG\wm_w600_gz.img
Traceback (most recent call last):
  File "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py", line 11, in <module>
    from xmodem import XMODEM1k
ModuleNotFoundError: No module named 'xmodem'

C:\Users\js>pip3 install xmodem
Collecting xmodem
  Downloading xmodem-0.4.6.tar.gz (32 kB)
Installing collected packages: xmodem
    Running setup.py install for xmodem ... done
Successfully installed xmodem-0.4.6

C:\Users\js>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload  D:\Work_STM32\_Hardware\Air602\_firmware\W600_Micropython_Firmware\W60X_MicroPython_1.10_B1.3_IMG\wm_w600_gz.img
Traceback (most recent call last):
  File "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py", line 150, in <module>
    import serial.tools.list_ports
ModuleNotFoundError: No module named 'serial.tools'

C:\Users\js>pip3 install serial.tools
ERROR: Could not find a version that satisfies the requirement serial.tools (from versions: none)
ERROR: No matching distribution found for serial.tools

C:\Users\js>pip3 install pyserial
Collecting pyserial
  Using cached pyserial-3.4-py2.py3-none-any.whl (193 kB)
Installing collected packages: pyserial
Successfully installed pyserial-3.4

C:\Users\js>pip3 purge serial
ERROR: unknown command "purge"

Jetzt aber:

ZitatC:\Users\js>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload  D:\Work_STM32\_Hardware\Air602\_firmware\W600_Micropython_Firmware\W60X_MicroPython_1.10_B1.3_IMG\wm_w600_gz.img
Opening device: COM15
Push reset button to enter bootloader...
Error: Cannot switch speed

C:\Users\js>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload  D:\Work_STM32\_Hardware\Air602\_firmware\W600_Micropython_Firmware\W60X_MicroPython_1.10_B1.3_IMG\wm_w600_gz.img --upload-baud {115200,460800,921600}
usage: w600tool.py [-h] [-p PORT] [-b BAUD] [--get-mac] [--set-mac MAC] [-e] [-u FILE] [--upload-baud {115200,460800,921600,1000000,2000000}]
w600tool.py: error: argument --upload-baud: invalid int value: '{115200,460800,921600}'

C:\Users\js>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload  D:\Work_STM32\_Hardware\Air602\_firmware\W600_Micropython_Firmware\W60X_MicroPython_1.10_B1.3_IMG\wm_w600_gz.img --upload-baud 115200
Opening device: COM15
Push reset button to enter bootloader...
Uploading D:\Work_STM32\_Hardware\Air602\_firmware\W600_Micropython_Firmware\W60X_MicroPython_1.10_B1.3_IMG\wm_w600_gz.img
0% [##############################] 100% | ETA: 00:00:00
Total time elapsed: 00:00:32
Reset board to run user code...

Eureka, das wars!

Nicht den Resetbutton gedrückt, sondern gleich mal ins Terminal 115200,8N1:

    __            __
    \ \    /\    / /
     \ \  /  \  / /
      \ \/ /\ \/ /
       \  /  \  /
       / /\  / /\
      / /\ \/ /\ \
     / /  \  /  \ \
    /_/    \/    \_\
MicroPython v1.10-282-g6a9b3cb-dirty on 2019-09-17; WinnerMicro module with W600
Type "help()" for more information.
>>> help()
Welcome to MicroPython on the W600!

For generic online docs please visit http://docs.micropython.org/

For access to the hardware use the 'machine' module:

import machine
pb26 = machine.Pin(machine.Pin.PB_26, machine.Pin.OUT, machine.Pin.PULL_DOWN)
pb26.value(1)
pb27 = machine.Pin(machine.Pin.PB_27, machine.Pin.IN, machine.Pin.PULL_UP)
print(pb27.value())

Basic WiFi configuration:

import network
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.scan()                             # Scan for available access points
sta_if.connect("<AP_name>", "<password>") # Connect to an AP
sta_if.isconnected()                      # Check for successful connection

Control commands:
  CTRL-A        -- on a blank line, enter raw REPL mode
  CTRL-B        -- on a blank line, enter normal REPL mode
  CTRL-C        -- interrupt a running program
  CTRL-D        -- on a blank line, do a soft reset of the board
  CTRL-E        -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)


Das Board befindet sich im REPL-Modus, welches die Editor-Oberfäche des Boards darstellt.

Daraus ergaben sich zwei Fragen:

  • Wie verbinde ich mich mit meinem WLAN
  • Wie bekomme ich ".py" Progamme auf das Board

Frage 1: ist schnell beantwortet: steht ja in der Hilfe mittels "help()"  aufzurufen.
Frage 2:Programme/Module können über FTP (Filezilla) zum Board hochgelden werden:

Umständleich über manuelles Eintippen oder Copy&Paste aus der Hilfe:
import w600
import network
import time
import machine.Pin

sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect("<SSID>","WLAN-Passwort")
#while not sta_if.isconnected():
#    pass
time.sleep(3)
sta_if.isconnected()

print('network config:', sta_if.ifconfig())

w600.run_ftpserver(port=21, username="root", password="1")


Ergebnis:
  __            __
    \ \    /\    / /
     \ \  /  \  / /
      \ \/ /\ \/ /
       \  /  \  /
       / /\  / /\
      / /\ \/ /\ \
     / /  \  /  \ \
    /_/    \/    \_\

    WinnerMicro W600

MicroPython v1.10-284-g2eee4e2-dirty on 2019-11-08; WinnerMicro module with W600
Type "help()" for more information.
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import w600
=== import network
=== import time
=== from  machine import Pin
===
=== led = Pin(Pin.PB_08, Pin.OUT, Pin.PULL_FLOATING)
===
=== sta_if = network.WLAN(network.STA_IF)
=== sta_if.active(True)
=== sta_if.connect("<my_wlan","mywlan_passwd")
===
=== time.sleep(3)
===
=== sta_if.isconnected()
===
=== if (sta_if.isconnected()):
===    led(1)
=== else:
===     led(0)
===
===
=== print('network config:', sta_if.ifconfig())
===
===
=== w600.run_ftpserver(port=21,username="root",password="1")
===
True
True
network config: ('192.168.178.115', '255.255.255.0', '192.168.178.1', '192.168.178.1')
ftpserver is running.


Ich habe das zeilenweise in die Boardkonsole gepastet, geht aber auch komplett in den Edit-Modus zu schalten: CTRL-E dann den Code pasten und mit  Return + CTRL-D ablschließen.
Soweit so gut, eine Led an PB8 angeschlossen leuchtet und der FTP-Server läuft!

Nach einem Reset (CTRL-D)  ist alles wieder weg und man müssste es erneut eingeben. Wohl gemerkt wir befinden uns im REPL-Editor und haben noch nichts konkret mit "Autostart" geflasht.
Deshalb kann man "eigene" Module auf den Chip laden, die manuell oder nach reset auch automatisch ausgeführt werden können.
Das Utility Scrip easyw600.py habe ich angefügt.

Ok, aber mit Terminal ist das nicht so komfortabel! Es gibt verschiedene Wege: z.B. rshell oder  ampy

Deshalb mit VSCode über die Pymakr-Konsole läuft das wesentlich besser.
Aber die Macher von Pymaker haben leider einen Connect-Automatismus eingebaut, der erst mal durchschaut werden muss...
Konfiguration über: C:\Users\js\AppData\Roaming\Code\User\pymakr.json
Pymakr versucht sofort alle COM-Schnittstellen nach den im JSON defierten Adaptern ab. Als ich das Board noch nicht angeschlossen hatte sieht es so aus, als ob das Ganze hängt.
Board und Serial-Adapter an USB angeschlossen => keine Reaktion! (Siehe aber auch die Statuszeile)
Also die Konfiguration in den VSCode-Editor geholt und
"auto_connect": false,
auf false gesetzt. Dann wieder auf true und siehe da, VSCode merkt die Änderung und Pymakr findet das Board und begibt sich in den REPL-Modus! Voilà!  :)

Momentan habe ich aber noch alle Probleme nicht behoben bekommen, z.B. falls noch kein "Programm" in den Autostartmodus gesetzt ist,
reagiert die Firmware "komisch":
ZitatConnecting to COM15...
Connection error: Error: timeout

secboot running...
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

Hier meldet sich der Secbootloader, dass er den Sprung in die Anwendung nicht kann. Zuerst dachte ich dass der Boolader im Zusammenhang mit der AT-Command-Firmware nicht passt,
aber das ist (noch) ein "normales" Verhalten.
Das bekomme ich momentan nur so gelöst, das Image neu zu Flashen (deswegen das Batch-File). Erfreulich ist: dass die Hilfs-Module im Flash erhalten bleiben,
so dass sich das Verbinden mit dem WLAN relativ einfach gestalten lässt...

Hier die OK-Variante:
ZitatCCConnecting to COM15...

>>>
>>>
>>> help()
Welcome to MicroPython on the W600!

For generic online docs please visit http://docs.micropython.org/

For access to the hardware use the 'machine' module:

import machine
pb26 = machine.Pin(machine.Pin.PB_26, machine.Pin.OUT, machine.Pin.PULL_DOWN)
pb26.value(1)
pb27 = machine.Pin(machine.Pin.PB_27, machine.Pin.IN, machine.Pin.PULL_UP)
print(pb27.value())

Basic WiFi configuration:

import network
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.scan()                             # Scan for available access points
sta_if.connect("<AP_name>", "<password>") # Connect to an AP
sta_if.isconnected()                      # Check for successful connection

Control commands:
  CTRL-A        -- on a blank line, enter raw REPL mode
  CTRL-B        -- on a blank line, enter normal REPL mode
  CTRL-C        -- interrupt a running program
  CTRL-D        -- on a blank line, do a soft reset of the board
  CTRL-E        -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')
>>>


import easyw600.py
easyw600.connect("<WLAN>,"WLAN_PASSWD")
   
Dann besteht die Verbing zum WLAN und kann weiter genutzt werden ...
Zum Beispiel zum weiteren Code hochzuladen:
easyw600.ftpserver()

Tip: Code-Completion im REPL-Modus: TAB zeigt alle verfügbaren Module. Giibt man "<modulname>." ein , dann kann man mit TAB alle Methoden angezeigt bekommen.

Richtig coole Sache !

Es gibt noch tausend offene Fragen, aber wie gesagt die Infos sind dürftig. Micropyton.org hat das Board noch nicht "offiziell" in die Doku aufgenommen ...
Aber das kann sich ja ändern ...   :D

Allerdings weiß ich auch nicht, ob das alles so "gedacht" ist ...  aber so funktioniert es bei mir erst mal ... und ein Blick über den Tellerrand auf Python ist bestimmt auch lohnenswert !

Für Tipps bin ich gerne empfänglich. (Z.B. der Upload und Run in pymakr und ampy funktioniert nocht nicht. SecBootloader tauschen.. [".fls", PA0 auf GND]. Anwendungcode persitieren => boot.py + main.py.)

So,  jetzt geht es ans Implementieren ...  SPI, I2C .. OLED, BME680, Tasmota  ;) usw.

Grüße,
Jürgen

/edit: Als registrierter User bekommt man auf der Webseite mehr Informationen geliefert... ;-(

juergs


juergs

#2
Für Arduino gibt es noch eine andere Lösung als über den Boardmanager:

ZitatIt is recommended that you go to the official website to download the information.
hier

Anmerkung:
Zitatw600-arduino-InnerIDE-0.2.6
package_wmcom_index.json
Arduino_Hardware_design_file
Nach Entpacken des Tar-Files:: WM_w600-arduino-InnerIDE-instruction-En_v1.1_190218.pdf

TAR-Inhalt "w600" in \hardware-Ordner in  (bei mir im Arduino-Libraries-Ordner)  und "package_wmcom_index.json" in Verzeichnis: "%LOCALAPPDATA%\Arduino15" kopieren.

Aber doch  noch nicht zu 100%:

ZitatC:\Program Files (x86)\Arduino>C:\Users\js\Documents\Arduino\hardware\w600/wmtools/gcc-arm-none-eabi/bin/arm-none-eabi-objcopy  --output-target=binary C:\Users\js\AppData\Local\Temp\arduino_build_21272/sketch_apr16a.ino.elf C:\Users\js\AppData\Local\Temp\arduino_build_21272/sketch_apr16a.ino.objcopy.bin

Zugriff verweigert

input C:\Users\js\AppData\Local\Temp\arduino_build_21272/sketch_apr16a.ino.objcopy.img file error

Manuell in der Konsole:
C:\Users\js>C:\Users\js\Documents\Arduino\hardware\w600\wmtools\gcc-arm-none-eabi\bin\arm-none-eabi-objcopy  --output-target=binary C:\Users\js\AppData\Local\Temp\arduino_build_21272\sketch_apr16a.ino.elf C:\Users\js\AppData\Local\Temp\arduino_build_21272\sketch_apr16a.ino.objcopy.bin

... geht durch ...  >:(

juergs

Mit heißer Nadel gestrickt ....

Makeimg.exe verucht im Arduino-Ordner eine Datei test.bin anzulegen. Was natürlich unter Windows10 scheitert.
Ein temporäres Schreibrecht auf das Verzeichnis bestätigt das.

Hoffe, dass das schnell hier gefixt wird...

juergs

#4
Oh, wirklich schnell!

Zitatif you want to download and install the board definition of W600.

    Add W600 board manager URL from File -> Preference
    copy and paste the link https://raw.githubusercontent.com/salmanfarisvp/snippet/master/package_wmcom_index.json

    Open Board Manager Tools -> Board -> Board Manager

    Search for W600 and click install.

ZitatC:\Users\js\Documents\Arduino\hardware\w600/wmtools/upload.bat C:\Users\js\Documents\Arduino\hardware\w600/wmtools COM15 115200 C:\Users\js\AppData\Local\Temp\arduino_build_21272/sketch_apr16a.ino.gz.img
Current Python main version is not 3, Use binary to upgrade the firmware.
Serial open success! com: COM15, baudrate: 115200.
Waiting for restarting device ...
Start send ESC thread.
Start serial read thread.
Start restart thread.
First try cycle...
Try to open Serial with baud speed: 115200...
Try to re-open Serial with baud speed: 230400...
Try to re-open Serial with baud speed: 460800...
Try to re-open Serial with baud speed: 921600...
Try to re-open Serial with baud speed: 1000000...
Try to re-open Serial with baud speed: 1500000...
Try to re-open Serial with baud speed: 2000000...
Try to re-open Serial with baud speed: 9600...
Try to re-open Serial with baud speed: 19200...
Try to re-open Serial with baud speed: 38400...
Try to re-open Serial with baud speed: 57600...
Second try cycle...
Try to open Serial with baud speed: 115200...
Try to re-open Serial with baud speed: 230400...
Try to re-open Serial with baud speed: 460800...
Try to re-open Serial with baud speed: 921600...
Try to re-open Serial with baud speed: 1000000...
Try to re-open Serial with baud speed: 1500000...
Try to re-open Serial with baud speed: 2000000...
Try to re-open Serial with baud speed: 9600...
Try to re-open Serial with baud speed: 19200...
Try to re-open Serial with baud speed: 38400...
Try to re-open Serial with baud speed: 57600...
Third try cycle...
Try to open Serial with baud speed: 115200...
Try to re-open Serial with baud speed: 230400...
Try to re-open Serial with baud speed: 460800...
Try to re-open Serial with baud speed: 921600...
Try to re-open Serial with baud speed: 1000000...
Try to re-open Serial with baud speed: 1500000...
Try to re-open Serial with baud speed: 2000000...
Try to re-open Serial with baud speed: 9600...
Try to re-open Serial with baud speed: 19200...
Try to re-open Serial with baud speed: 38400...
Try to re-open Serial with baud speed: 57600...
!!! PLEASE BURN FIRMWARE MANUALLY !!!
An error occurred while uploading the sketch

"Current Python main version is not 3, Use binary to upgrade the firmware." ist bei mir die 3er im Pfad!
Korrektur:
C:\Users\js\AppData\Local\Temp\arduino_build_131628>where python.exe
C:\Python27\python.exe
C:\Users\js\AppData\Local\Microsoft\WindowsApps\python.exe


Oh!  :-[ ;D

juergs

Ok, manual upload with "newest" w600tool.py:

ZitatC:\Users\js\AppData\Local\Temp\arduino_build_131628>python3 "D:\Work_STM32_Hardware\Air602_software\w600tool-0.1\w600tool.py" -p COM15 --upload C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img --upload-baud 115200
Opening device: COM15
Uploading C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img
0% [##############################] 100% | ETA: 00:00:00
Total time elapsed: 00:00:27
Reset board to run user code...

works !

In Hoffnung auf bessere Zeiten  ;) :)

Jürgen

juergs

#6
Zitatpython  C:\Users\js\AppData\Local\Arduino15\packages\w600\tools\wmtools\0.3.2/download.py -c COM15 -b 115200 -f C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img

Dann werde ich mal das Skrpit: w600tool.py in download.py umbennen und im Tool-Verzeichnis ersetzen.
Das sollte funktionieren, wenn man -c durch -p und --upload durch -f -Parameter ersetzt ...
Nein: w600tool.py modifiziert und die upload.bat angepasst.


/edit, war dann doch nicht so einfach, weil die Arduino-Ide auf bestimmten TextOutput triggert:
ZitatUse python script to upgrade the firmware.
python C:\Users\js\AppData\Local\Arduino15\packages\w600\tools\wmtools\0.3.2/w600tool.py -p COM15 --upload C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img --upload-baud 115200

Opening device: COM15
Uploading C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img
Start upgrade C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img
Please wait for upgrade ...
Upgrade image success! => C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img
Please wait for about 10 seconds before uncompress & restart...

https://github.com/juergs/w600-arduino_upload-workaround

Geht doch ...  ;D

juergs

#7
Zur Info, noch die Variante für ESP8266 und ESP32:

ZitatD:\Work_ESP32\esptool>pip3 install esptool
Collecting esptool
  Downloading esptool-2.8.tar.gz (84 kB)
     |████████████████████████████████| 84 kB 2.9 MB/s
Requirement already satisfied: pyserial>=3.0 in c:\users\js\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from esptool) (3.4)
Collecting pyaes
  Downloading pyaes-1.6.1.tar.gz (28 kB)
Collecting ecdsa
  Downloading ecdsa-0.15-py2.py3-none-any.whl (100 kB)
     |████████████████████████████████| 100 kB 2.9 MB/s

ZitatD:\Work_ESP32\esptool>python esptool.py --port COM12 --chip esp32 erase_flash
esptool.py v3.0-dev
Serial port COM12
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
WARNING: Detected crystal freq 41.13MHz is quite different to normalized freq 40MHz. Unsupported crystal in use?
Crystal is 40MHz
MAC: 24:0a:c4:32:3e:8c
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 8.9s
Hard resetting via RTS pin...



D:\Work_ESP32\esptool>python esptool.py --port COM12 --chip esp32 write_flash 0x1000 C:\Users\js\Downloads\esp32-idf3-20191220-v1.12.bin
esptool.py v3.0-dev
Serial port COM12
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 24:0a:c4:32:3e:8c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 1247280 bytes to 787794...
Wrote 1247280 bytes (787794 compressed) at 0x00001000 in 70.2 seconds (effective 142.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

How-To: flashing-micropython-firmware-esptool-py-esp32-esp8266/

Beispiel:  esp8266/tutorial/network_tcp]esp8266/tutorial/network_tcp

Zitat>>> s.connect(addr)
>>> while True:
...     data=s.recv(500)
...     print(str(data,'utf8'),end='')
...
Huhu
hallo 1234567890
hi

Beim ESP32: zum Flashen auch Reset-Button drücken ...

Sockets: python-sockets/

juergs

#8
Für Arduino, angepasste Boardmanager-URL:   
 
if you want to download and install the board definition of W600.
       
Upload-Workaround. Da der orginal-Upload scheinbar nicht geht....

MicroPython REPL:
http://docs.micropython.org/en/latest/reference/repl.html


Ranseyer

Coole Sache. Mir was das seinerzeit zu aufwändig und sonst hatte keiner Interesse was schade ist...

Denke du kennst das ?
https://github.com/ranseyer/CUN-STM32/blob/master/HW-MAPLE-Large/Archiv/AddOns/RFM69-usw-aktuell/bot-15.png
https://github.com/ranseyer/CUN-STM32/blob/master/HW-MAPLE-Large/Archiv/V3.4/bot-copper.png (Hier direkt mit integrierter Antenne. Eine solche Platine sollte bei dir liegen...)

(Ich finde das eine äßerst coole HW! )
FHEM mit FTUI. Homematic-Funk für Thermostate und Licht. MySensors als Basis für eigene HW.
Zentrale ist der MAPLE-CUL mit RFM69+HModUART-AddOn.
Doku zu meinen Projekten: Github/Ranseyer. Platinen falls verfügbar gerne auf Anfrage.
Support: gerne wenn ich Zeit+Lust habe im Forum. Nicht per PN!

juergs

Hallo Martin,
ZitatDenke du kennst das ?
... kommt mir sehr bekannt vor, allerdings fehlte mir der Schaltplan dazu.

Das Teil ist wirklich gut, aber zu wenig bekannt und viele scheuen die Pionierarbeit.
Die Community ist da für den ESP schon sehr viel weiter ... 
Was mich interessiert: das Flashen des passenden Bootloaders ...

Mit der ab Fabrik geflashten AT-Firmware werde ich einfach nicht warm und  meine Begeisterung für Micropython
wächst! Trotz Toolvielfalt etc...  ;)


Die Module, die ich gerade habe sind die kleinsten Varianten, hier reicht es schon mal Pin-technisch, um ein OLED-Display anzuschließen
ggf. auch um ein WLAN-Gateway für den Maple-Signalduino zu bilden.
Muss mich aber in die Infrastruktur rund um fhem und SignalESP einarbeiten.

Was mich interessiert: das Flashen des passenden Bootloaders ...
Um besser an PA0 heranzukommen habe ich diese Board bestellt:
]https://www.cnx-software.com/2020/01/11/2-wemos-w600-pico-wifi-iot-board-ships-with-micropython-firmware/]
Bei den kleinen Modulen ist der PIN 13 am Prozessor mit Masse zu verbinden und dann mit Spannung via Usb einschalten um in den Boot-Modus zu kommen und die FLS-Variante flashen zu können. Sonst meldet sich immer nur der AT-FW-Bootloader mit "CCCCCCC...."
Für Micropython muss ich umflashen ... sonst muss ich immer wieder das MP-Image flashen.

Die Module, die ich gerade habe, sind die kleinsten Varianten, hier reicht es trotzdem schon mal um ein OLED anzuschließen
ggf. auch um ein WLAN-Gateway für den MAple-Signalduino zu bilden. Muss mich aber in die Infrastruktur rund um fhem und SignalESP einarbeiten.

Um besser an PA0 heranzukommen habe ich diese Board bestellt:
https://www.cnx-software.com/2020/01/11/2-wemos-w600-pico-wifi-iot-board-ships-with-micropython-firmware/
Leider sitzt PA0 echt ungünstig am Prozessor ...

Relativ schnell mit den Modulen geht es hier air602-wifi-module und w600-a800-Prozessor

Jürgen

juergs

#11
Noch habe ich es nicht herausggefunden, Micropython persistent zu flashen:
Zitat
D:\Work_STM32\_Hardware\Air602\_cmd>Flash_MicroPython_FLS_on_W600-Board.cmd

D:\Work_STM32\_Hardware\Air602\_cmd>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload-baud 115200 --upload "D:\Work_Air602\_firmware\W60x_MicroPython_1.10_B1.5_img\W60X_MicroPython_1.10_B1.5_img\1M_Flash\wm_w600.fls"
Opening device: COM15
Error: IMG file is required for secboot

D:\Work_STM32\_Hardware\Air602\_cmd>pause
Drücken Sie eine beliebige Taste . . .

D:\Work_STM32\_Hardware\Air602\_cmd>

Zitati should have mentioned that the reset button should be pressed after send 1B.

juergs

#12
Zitat von: juergs am 25 April 2020, 11:51:48
Noch habe ich es nicht herausggefunden, Micropython persistent zu flashen:

3D-Nozzle-Anti-Clogging-Nadel, aka. Akkupunktur-Nadeln in 0.4mm Durchmesser ... erfüllen den Zweck. 

Deshalb: Anfrage

ZitatSECBOOT Error Codes
During SECBOOT startup, if some exceptions happen, SECBOOT will be inendless loop.
At the same time,error code will be printed on UART0 terminal to tell userscurrent state.
Following is the error code table:

ErrorCode   Description

C   Normal

During updating (XModem protocol)
D   Host cancel
E   NACK
F   Time out without getting data
G   Packet number error
H   Packet number complement error
I   IMAGEis too large
J   IMAGE updating address is disagreement
K   IMAGE updating address page is not aligned
L   IMAGEheader checksum error
M   IMAGEcontent checksum error
Function module
R   Command check error
S   Command parameter error
U   Setting gain failedVSetting MAC failed
ZitatBootloader stored in upgradable accepts format:
SECBOOT    flash       via .fls    .img only
ROM       hardened    no    .fls only

juergs

#13
Resolved by myself with download.py and PA0=low + reset:

=> You must hold PA0 low for the whole download process !

Wäre ja schon in der Doku erwähnenswert gewesen ... Welche Doku?   ;)

ZitatIf the BOOTMODE pin of W60X is pulled low level last for more than 30ms when powered on, it will jump to ROM (Only UART0) code.

Warum die Hardwareentwickler für PA0 nicht wenigstens ein Testpad vorgesehen haben  >:( :( => sollten mal versuchen die Nadel zu halten und den USB-Stecker zu verbinden. ...  :o ::) 

MicroPython Version mit W60X Portierung mit neuerer Download-Tools Version: http://www.winnermicro.com/en/upload/1/editor/1573450104930.zip
Im entpackten Verzeichnis: W60X_MicroPython_1.10_B1.5_src\ports\w60x\tools  FLS-Downloader : "_firmware\W60X_MicroPython_1.10_B1.5_src\ports\w60x\tools\wm_tool.exe"  oder "download_fls.sh"
 
ZitatD:\Work_Air602_software\w600tool-0.1>python .\download.py -p COM15 -b 115200 --upload D:\Work_Air602_firmware\W60x_MicroPython_1.10_B1.5_img\W60X_MicroPython_1.10_B1.5_img\1M_Flash\wm_w600.fls

Zitat
Opening device: COM15
Switched speed to 1000000
Uploading D:\Work_Air602_firmware\W60x_MicroPython_1.10_B1.5_img\W60X_MicroPython_1.10_B1.5_img\1M_Flash\wm_w600.fls
0% [##############################] 100% | ETA: 00:00:00
Total time elapsed: 00:00:17
Reset board to run user code...

PS:

__            __
\ \    /\    / /
\ \  /  \  / /
  \ \/ /\ \/ /
   \  /  \  /
   / /\  / /\
  / /\ \/ /\ \
/ /  \  /  \ \
/_/    \/    \_\

WinnerMicro W600

MicroPython v1.10-284-g2eee4e2-dirty on 2019-11-08; WinnerMicro module with W600
Type "help()" for more information.

Zitat>>> help("modules")
__main__          machine           uctypes           uselect
_boot             math              uerrno            usocket
_onewire          micropython       uhashlib          ustruct
_thread           network           uheapq            utime
builtins          ntptime           uio               utimeq
cmath             sys               ujson             uwebsocket
easyw600          uarray            uos               uzlib
framebuf          ubinascii         urandom           w600
gc                ucollections      ure
Plus any modules on the filesystem
>>>

easyw600.py Script zum einfachen WLAN-Connect + FTP Transfer zum Modul von hier.

Hier ist das Modul "framebuf" schon mit im Image  :) ;) , dann steht ja dem OLED-Display oder der Wetterstation nichts mehr im Weg.


Requirements: Gute Augen + gute Lupe + kein Kaffee vorher trinken  ;D

/Edit: Unglücklicherweise ist beim Dev-Board PA0 mit dem CH330 Chip verdrahtet. PA0 auf low legen ist keine gute Idee, denn dann steigt der CH340 Chip aus und unterbindet den Upload ...  >:(
Hier muss man nochmal forschen  ... bzw. den Schaltplan finden und konsultieren ...
Hauptsache es geht beim Modul!


Klar, wenn man sich die Platine mit dem 0402-Widerstand anschaut sieht die 1..8 und die 9..16 -Seite fast identisch aus !
Also, man sollte den richtigen Pin zu Low-Setzen erwischen (Pin 13 !) ! Auweia, Gott-sei-Dank ist die Sicherungsdiode nicht in Rauch aufgegangen !  :( ;D

juergs

Wer mal etwas virtuell MicroPython ausprobieren möchte:
http://micropython.org/unicorn/

Hier habe ich noch einen generellen Überblick: W600_Tcp_To_Serial_Bridge/wiki/Introduction-to-Micropython-on-Air602