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

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

Vorheriges Thema - Nächstes Thema

juergs

#15
Habe heute das Micropython Image (1MB-Version) auf ein W600-Board geflasht:

Nach anfänglichen Zögern:

ZitatD:\Work_Air602\_software\w600tool-0.1>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM3 --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: COM3
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:56send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
0% [##                            ] 100% | ETA: 00:00:57send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: expected ACK; got b'\x18' for block 33
send error: NAK received 17 times, aborting.
Reset board to run user code...

Es waren andere Schritte notwendig, ging aber dann doch:

python .\w600tool.py -p COM3 -b 115200 -e
ZitatD:\Work_Air602\_software\w600tool-0.1>python .\w600tool.py -p COM3 -b 115200 -e
Opening device: COM3
Erasing image

python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM3 --upload-baud 115200 --upload D:\Work_Air602\_firmware\W60x_MicroPython_1.10_B1.5_img
Zitat
D:\Work_Air602\_software\w600tool-0.1>python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM3 --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: COM3
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:51

Zitathelp()
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')
>>>

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

    WinnerMicro W600

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

:)

PS:
ZitatIntegrated 32bit Embedded Cortex-M3 CPU;
Integrated 288Kbyte RAM;
Integrated 1Mbyte Flash;
Integrated 2.4G Transceiver with IEEE802.11 Specification;
Integrated PA/LNA/TR-Switch;
Integrated 32.768KHZ Clock Oscillator;
Integrated Encrypted Hardware Accelerator; support ;PRNG/SHA1/MD5/RC4/DES/3DES/AES/CRC/RSA;

SDIO

2 x UART,38Kbps~2Mbps;

1 x High Speed SPI, Max 50Mbps;

I²C
PWM
I²S
GPIO

7816

IEEE802.11b/g/n
WAPI2.0
Wi-Fi WMM/WMM-PS/WPA/WPA2/WPS
Wi-Fi Director
Support 20/40M bandwidth working mode

Support STA/AP/AP+STA mode

Ralf9

Zitat>>> 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:
Mir ist noch nicht klar wie ich jetzt die "W600_Tcp_To_Serial_Bridge" drauf bekomme.

Gruß Ralf
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs

#17
Hallo Ralf,

es gibt mehrer Möglichkeiten:

1. Zum Testen : über den REPL-Modus mit ctrl-a, dann ändert sich der Prompt in ,,===,,.
Dann über ctrl-c und ctrl-v den Ascii-Text einfach in den Prompt pasten.
Danach mit ctrl-d ausführen.(ctrl-d löst im normalen Prompt ,,>>>" ein Softreset aus)
2. Permanent: über FTP den Code auf das ,,Filesystem" uploaden und in main.py oder boot.py ausführen lassen.

Für den ersten Modus hat sich bei mir Teraterm (Windows) bewährt. Es unterstützt den Paste-Modus hervorragend.
Außerdem verkraftet es einen Reconnect nach Reset besser als ein Terminal.
Leider gibt es das für Linux nicht. Hier mit Putty etc. arbeiten... oder mit ftp put etc in der Konsole....

In VSCode kann man mit Pymaker Extention auch direkt den gerade editierten Code downloaden bzw. ausführen.

Doku (zwar für ESP8266, aber ebenso anwendbar): docs.micropython.org/en/v1.9.4/micropython-esp8266.pdf

Um das "lästige" WLAN-Connect zu automatisieren, habe ich den Connect so in main.py via:
execfile("connect_main.py")
eingebunden.

# main.py -- put your code here!
import time
time.sleep(3)
print("Awaiting 10s .. to connect to WLAN... ")
time.sleep(10)
execfile("connect_main.py")


In connect_main.py steht:

import network
import w600
import time

def run():
    print("*** Connecting to WLAN jsifrz and establih a FTP-server on port 21 user=root password=root")
    print("*** Returning the sta_if object for disconnect() of WLAN")
    sta_if = network.WLAN(network.STA_IF)
    sta_if.active(True)
    sta_if.connect("my_wlan_ssid", "my_wlan_pwd")
    time.sleep(5)
    sta_if.isconnected()
    print("***connected, ip is " + sta_if.ifconfig()[0])   
    w600.run_ftpserver(port=21, username="root", password="root")
    print("***FTP-server on port 21 user=root password=root IP=" + sta_if.ifconfig()[0])

   
if __name__ == "__main__":
    run()


und rufe connect_main.py schon beim Booten auf. Dann erfahre ich auch gleich die per DHCP vergebene IP-Adresse des Moduls und der FTP-Server ist ebenfalls schon gleich aktiv.
Das ist beim Programmieren enorm hilfreich...  ;D ;)

Ergebnis:
Zitat*** Connecting to WLAN "my_wlan" and establish a FTP-server on port 21 user=root password=root
*** Returning the sta_if object for disconnect() of WLAN
***connected, ip is 192.168.178.114
ftpserver is running.
***FTP-server on port 21 user=root password=root IP=192.168.178.114
MicroPython v1.10-284-g2eee4e2-dirty on 2019-11-08; WinnerMicro module with W600
Type "help()" for more information.
>>>
>>>

Beim Pico-Board hatte ich Probleme bei der ausgelieferten Version mit dem Filesystem:
https://forum.seeedstudio.com/t/trying-to-implement-micropython-on-w600-module/252033
https://forum.seeedstudio.com/t/module-w600-pico-bricked-filesystem/252035/2

Das ließ sich aber einfach mit dem zweimaligen Neuflashen mit esptool.py (PA0 = Low! => Konsole in SECBoot-Modus="CCCCCCCCCCC.....")  einer neueren Version beheben (Qualitäts-Tests?: Fehlanzeige):

Zitat>>> os.uname()
(sysname='w600', nodename='w600', release='1.11.0', version='v1.10-284-g2eee4e2-dirty on 2019-11-08', machine='WinnerMicro module with W600')

Unter dem Reiter  "Development Tool" das FLS-Image für 1MB nehmen: http://www.winnermicro.com/en/upload/1/editor/1573450100756.zip
ist die aktuellere Version zu finden.
Das ist die neueste kompilierte Binary-Version "MicroPython v1.10-284-g2eee4e2-dirty on 2019-11-08; WinnerMicro module with W600" die ich finden konnte.
Diese hier https://docs.wemos.cc/en/latest/tutorials/w600/get_started_with_micropython_w600.html scheint nicht ganz aktuell zu sein.

Die in den Foren erwähnte Version von 202002* konnte ich noch nicht kompiliert finden.

Evtl. baue ich eine Docker-Variante zum Selbst-Kompilieren ...

Grüße,
Jürgen



Ralf9

mit dem ftp Server passt irgendwas noch nicht

>>> import w600
>>> w600.run_ftpserver(port=21, username="root", password="root")
ftpserver is running.
>>> sta_if.isconnected()
True


> ftp 192.168.0.11
Connected to 192.168.0.11.
220-= welcome on W600 FTP server =-
220
Name (192.168.0.11:ralf): root
331 Password required for root
Password:
230 User logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
425 Can't open data connection 610.
425 Can't open data connection 879.


Gruß Ralf


FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs

Hallo Ralf,
mit welchem Board?

Schaue das mal bei mir über den Raspi an.

Ralf9

FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs

#21
Auf meinem USB-Test-System:
Zitatftp> open 192.168.178.114
Connected to 192.168.178.114.
220-= welcome on W600 FTP server =-
220
Name (192.168.178.114:js): root
331 Password required for root
Password:
230 User logged in
Remote system type is UNIX.
ftp> ls
200 Port Command Successful.
150 Opening Binary mode connection for file list.
drwxrwxrwx   0 root root      0 Jan 1 2018 .
drwxrwxrwx   0 root root      0 Jan 1 2018 ..
-rwxrwxrwx   0 root root    139 Jan 1 2018 boot.py
-rwxrwxrwx   0 root root    743 Jan 1 2018 connect.py
-rwxrwxrwx   0 root root    670 Jan 1 2018 connect_main.py
-rwxrwxrwx   0 root root   2136 Jan 1 2018 logging.py
-rwxrwxrwx   0 root root    154 Jan 1 2018 main.py
-rwxrwxrwx   0 root root    905 Jan 1 2018 ntptime.py
-rwxrwxrwx   0 root root   2415 Jan 1 2018 w600_js.py
226 Transfert Complete.
ftp>

Probiere es mal mit dem W600 auch aus .... muss es aber erst Programmieren  ;D

juergs

#22
Hallo Ralf,

bei meinem W600-Modul:

Zitatjs@JS-DESKTOP:~$ ftp
ftp> open 192.168.178.145
Connected to 192.168.178.145.
220-= welcome on W600 FTP server =-
220
Name (192.168.178.145:js): root
331 Password required for root
Password:
230 User logged in
Remote system type is UNIX.
ftp> ls
200 Port Command Successful.
150 Opening Binary mode connection for file list.
drwxrwxrwx   0 root root      0 Jan 1 2018 .
drwxrwxrwx   0 root root      0 Jan 1 2018 ..
-rwxrwxrwx   0 root root    139 Jan 1 2018 boot.py
-rwxrwxrwx   0 root root     34 Jan 1 2018 main.py
226 Transfert Complete.
ftp>

Also kannst Du gleich mal das Image flashen  (üben) ....

Auf der Unterseite ist ein Lötpad erkennbar, das muss dauerhaft mit Masse verbunden werden und Power off/on.

Dann sollte im Terminal "CCCCCCCCCCCCC.... " kommen.

Vorher das Image herunterladen http://www.winnermicro.com/en/upload/1/editor/1573450100756.zip und entpacken.

Das Tool zum Flashen: https://github.com/wemos/w600tool


python3 "./w600tool.py" -p ttyXY -b 115200 -e
Das "1M_Flash"-Verzeichnis die Datei "wm_w600.fls" => ist auch ein Image aber persistent. Würdest Du nur das .img File nehmen,  wäre es nach dem Reboot wieder weg, bzw. das vorherige wieder aktiv.
python3 "[b]./w600tool.py[/b]" -p ttyXY --upload-baud 115200 --upload <path>/W60X_MicroPython_1.10_B1.5_img/1M_Flash/wm_w600.fls



Bin mir sicher, dass es dann geht.  :( :D

Nach dem Flashen Masseverbindung entfernen und neu einschalten, dann sollte es passen ...
Vermutlich legt er das Filesystem beim 2. Flashen erst richtig an ?



Ralf9

habe es auch mal mit den kleinen Modul mit externer Antenne versucht,
>>> import network
>>> import w600
>>> import time
>>> sta_if = network.WLAN(network.STA_IF)
>>> sta_if.active(True)
True
>>> sta_if.connect("xxx", "xxx")
>>> sta_if.isconnected()
True
>>> print("***connected, ip is " + sta_if.ifconfig()[0])
***connected, ip is 192.168.0.13
>>> w600.run_ftpserver(port=21, username="root", password="root")
ftpserver is running.
>>>


ftp> ls
425 Can't open data connection 610.
425 Can't open data connection 879.
ftp>


Bedeuted dies demnach, daß es erst nach dem zweiten Image flashen funktioniert?
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs


Ralf9

Das Image flashen hat funktioniert, das FTP funktioniert aber trotzdem nicht.

Ich habe die Befehle aus Deiner connect_main.py im Seriellen Monitor eingegeben, da ich nicht weiss wie ich die connect_main.py ohne ftp hochladen kann
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs

Hallo Ralf,
vielleicht liegt es gar nicht am Controller.
Beim Filezilla kam ein Popup hoch, das ftp user und pwd in Klartext übertragen würden, ,,...wollen Sie wirklich?"
Vielleicht versucht Du es einfach mal mit einem anderen System , z. B. Android etc.?

Bei mir funktionieren alle Controller, hoffentlich nicht weil oder gerade wegen Windows? 🤨

juergs

#27
Hallo Ralf,

habe es bei mir mit einem Android FTP-Client ausprobiert:
ZitatCan'open data connection 610

Aha!

Gleichzeitig geht Filezilla mit den gleichen Einstellungen (passive-mode).

Aber auch in der WSL geht es:

Zitatjs@JS-DESKTOP:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Zitatjs@JS-DESKTOP:~$ ftp
ftp> open 192.168.178.114
Connected to 192.168.178.114.
220-= welcome on W600 FTP server =-
220
Name (192.168.178.114:js): root
331 Password required for root
Password:
230 User logged in
Remote system type is UNIX.
ftp> ls
200 Port Command Successful.
150 Opening Binary mode connection for file list.
drwxrwxrwx   0 root root      0 Jan 1 2018 .
drwxrwxrwx   0 root root      0 Jan 1 2018 ..
-rwxrwxrwx   0 root root    139 Jan 1 2018 boot.py
-rwxrwxrwx   0 root root    743 Jan 1 2018 connect.py
-rwxrwxrwx   0 root root    670 Jan 1 2018 connect_main.py
-rwxrwxrwx   0 root root   2136 Jan 1 2018 logging.py
-rwxrwxrwx   0 root root    154 Jan 1 2018 main.py
-rwxrwxrwx   0 root root    905 Jan 1 2018 ntptime.py
-rwxrwxrwx   0 root root   2415 Jan 1 2018 w600_js.py
226 Transfert Complete.
ftp>

Vom Raspi 3:

Zitatpi@raspberrypi:~ $ ftp
ftp> open 192.168.178.114
Connected to 192.168.178.114.
220-= welcome on W600 FTP server =-
220
Name (192.168.178.114:pi): root
331 Password required for root
Password:
230 User logged in
Remote system type is UNIX.
ftp> ls
200 Port Command Successful.
150 Opening Binary mode connection for file list.
drwxrwxrwx   0 root root      0 Jan 1 2018 .
drwxrwxrwx   0 root root      0 Jan 1 2018 ..
-rwxrwxrwx   0 root root    139 Jan 1 2018 boot.py
-rwxrwxrwx   0 root root    743 Jan 1 2018 connect.py
-rwxrwxrwx   0 root root    670 Jan 1 2018 connect_main.py
-rwxrwxrwx   0 root root   2136 Jan 1 2018 logging.py
-rwxrwxrwx   0 root root    154 Jan 1 2018 main.py
-rwxrwxrwx   0 root root    905 Jan 1 2018 ntptime.py
-rwxrwxrwx   0 root root   2415 Jan 1 2018 w600_js.py
226 Transfert Complete.
ftp>

Evtl. eine Router-Einstellung, werde mal GooGl'en.

juergs

#28
Hallo Ralf9,

einfache Geschichte, eigentlich! ;) ;D :o

Einfach den Passive-Modus ausschalten (abhänging von den Default-Einstellungen ob Passiv oder Aktiv -Modus verwendet wird!)


Was zu beweisen war.  :)

Zitatftp> open 192.168.178.114
Connected to 192.168.178.114.
220-= welcome on W600 FTP server =-
220
Name (192.168.178.114:js): root
331 Password required for root
Password:
230 User logged in
Remote system type is UNIX.
ftp> passive
Passive mode on.
ftp> ls
425 Can't open data connection 610.
Passive mode refused.        <=============
ftp> active
?Invalid command
ftp> passive
Passive mode off.
ftp> ls
200 Port Command Successful.
150 Opening Binary mode connection for file list.
drwxrwxrwx   0 root root      0 Jan 1 2018 .
drwxrwxrwx   0 root root      0 Jan 1 2018 ..
-rwxrwxrwx   0 root root    139 Jan 1 2018 boot.py
-rwxrwxrwx   0 root root    743 Jan 1 2018 connect.py
-rwxrwxrwx   0 root root    670 Jan 1 2018 connect_main.py
-rwxrwxrwx   0 root root   2136 Jan 1 2018 logging.py
-rwxrwxrwx   0 root root    154 Jan 1 2018 main.py
-rwxrwxrwx   0 root root    905 Jan 1 2018 ntptime.py
-rwxrwxrwx   0 root root   2415 Jan 1 2018 w600_js.py
226 Transfert Complete.
ftp>

how-to-check-the-passive-and-active-ftp

Ralf9

es funktioniert anscheinend nicht mit allen FTP Clients.
Mit dem FTP von Opensuse auf meinem PC funktioniert es auch nicht mit passive off.
Auf dem Handy funktioniert es.
Auf dem Bananapi funktioniert es auch.

Nun benötige ich noch Deine aktuelle "w600_net2ser.py", dann mache ich
put w600_net2ser.py
put connect_main.py

und dann
get main.py
die main.py editieren und dann
put main.py

passt es so mit der main.py?
# main.py -- put your code here!
import time
import w600_net2ser
time.sleep(3)
print("Awaiting 10s .. to connect to WLAN... ")
time.sleep(10)
execfile("connect_main.py")
w600_net2ser.main()


Gruß Ralf
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7