Micropython Library für die Interaktion mit Winbond W25Q Flash Chips
Die neueste Dokumentation ist bei Micropython Winbond RededheDocs erhältlich
Python3 muss auf Ihrem System installiert werden. Überprüfen Sie die aktuelle Python -Version mit dem folgenden Befehl
python --version
python3 --version Verwenden Sie diesen Befehl, je nachdem, welcher Befehl Python 3.xy (mit XY als einige Zahlen) zurückgegeben wird.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtFür die Interaktion mit dem Dateisystem des Geräts kann die Remote -Micropython -Shell verwendet werden.
Testen Sie das Tool, indem Sie seinen Mann/Hilfe info Beschreibung anzeigen.
rshell --helpSchließen Sie das Mikropython -Gerät an ein Netzwerk an (wenn möglich) an ein Netzwerk (wenn möglich).
import network
station = network . WLAN ( network . STA_IF )
station . active ( True )
station . connect ( 'SSID' , 'PASSWORD' )
station . isconnected ()Installieren Sie die neueste Paketversion dieser LIB auf dem Micropython -Gerät
import mip
mip . install ( "github:brainelectronics/micropython-winbond" ) Für Mikropython -Versionen unter 1.19.1 Verwenden Sie das upip -Paket anstelle von mip
import upip
upip . install ( 'micropython-winbond' )Installieren Sie eine bestimmte, feste Paketversion dieser LIB auf dem Micropython -Gerät
import mip
# install a verions of a specific branch
mip . install ( "github:brainelectronics/micropython-winbond" , version = "feature/add-docs-and-detailed-examples" )
# install a tag version
mip . install ( "github:brainelectronics/micropython-winbond" , version = "0.4.0" ) Für Mikropythonversionen unter 1.19.1 verwenden Sie das upip -Paket anstelle von mip . Mit upip wird immer die neueste verfügbare Version installiert.
import upip
upip . install ( 'micropython-winbond' )Installieren Sie eine bestimmte Version des Release -Kandidaten, die zum Testen des Python -Paket -Index auf jedem PR auf dem Micropython -Gerät hochgeladen wurde. Wenn keine bestimmte Version festgelegt ist, wird die neueste stabile Version verwendet.
import mip
mip . install ( "github:brainelectronics/micropython-winbond" , version = "0.4.0-rc2.dev4" ) Für Mikropythonversionen unter 1.19.1 verwenden Sie das upip -Paket anstelle von mip . Mit upip wird immer die neueste verfügbare Version installiert.
import upip
# overwrite index_urls to only take artifacts from test.pypi.org
upip . index_urls = [ 'https://test.pypi.org/pypi' ]
upip . install ( 'micropython-winbond' )Siehe auch Brainelectronics Test PYPI Server in Docker für einen Test PYPI -Server, der auf Docker ausgeführt wird.
Kopieren Sie das Modul in die Mikropythonplatine und importieren Sie sie wie unten gezeigt mit Remote Micropython Shell
Öffnen Sie die Remote -Shell mit dem folgenden Befehl. Verwenden Sie zusätzlich -b 115200 , falls kein CP210x verwendet wird, aber ein CH34X.
rshell -p /dev/tty.SLAB_USBtoUART --editor nano Führen Sie den folgenden Befehl im rshell aus, um alle Dateien und Ordner auf das Gerät zu kopieren
mkdir /pyboard/lib
mkdir /pyboard/lib/winbond
cp winbond/ * /pyboard/lib/winbond
cp main.py /pyboard/lib/winbond
cp boot.py /pyboard/lib/winbond from machine import SPI , Pin
import os
from winbond import W25QFlash
# the used SPI and CS pin is setup specific, change accordingly
# check the boot.py file of this repo for further boards
flash = W25QFlash ( spi = SPI ( 2 ), cs = Pin ( 5 ), baud = 2000000 , software_reset = True )
flash_mount_point = '/external'
try :
os . mount ( flash , flash_mount_point )
except Exception as e :
if e . errno == 19 :
# [Errno 19] ENODEV aka "No such device"
# create the filesystem, this takes some seconds (approx. 10 sec)
print ( 'Creating filesystem for external flash ...' )
print ( 'This might take up to 10 seconds' )
os . VfsFat . mkfs ( flash )
else :
# takes some seconds/minutes (approx. 40 sec for 128MBit/16MB)
print ( 'Formatting external flash ...' )
print ( 'This might take up to 60 seconds' )
# !!! only required on the very first start (will remove everything)
flash . format ()
# create the filesystem, this takes some seconds (approx. 10 sec)
print ( 'Creating filesystem for external flash ...' )
print ( 'This might take up to 10 seconds' )
# !!! only required on first setup and after formatting
os . VfsFat . mkfs ( flash )
print ( 'Filesystem for external flash created' )
# finally mount the external flash
os . mount ( flash , flash_mount_point )Lob und großes Dankeschön an Crizeo vom Micropython Forum und seinen Beitrag, um Winbond Flash Chips zu verwenden