Package: micropython-winbond
MicroPython Winbond FlashMicroPython library to interact with Winbond W25Q Flash chips📚 The latest documentation is available atMicroPython Winbond ReadTheDocs📚InstallationInstall required toolsStetupInstall packageGeneralSpecific versionTest versionManuallyUpload files to boardUsageCreditsInstallationInstall required toolsPython3 must be installed on your system. Check the current Python version
with the following commandpython--version
python3--versionDepending on which commandPython 3.x.y(with x.y as some numbers) is
returned, use that command to proceed.python3-mvenv.venvsource.venv/bin/activate

pipinstall-rrequirements.txtFor interaction with the filesystem of the device theRemote MicroPython shellcan be used.Test the tool by showing its man/help info description.rshell--helpStetupInstall packageConnect the MicroPython device to a network (if possible)importnetworkstation=network.WLAN(network.STA_IF)station.active(True)station.connect('SSID','PASSWORD')station.isconnected()GeneralInstall the latest package version of this lib on the MicroPython deviceimportmipmip.install("github:brainelectronics/micropython-winbond")For MicroPython versions below 1.19.1 use theupippackage instead ofmipimportupipupip.install('micropython-winbond')Specific versionInstall a specific, fixed package version of this lib on the MicroPython deviceimportmip# install a verions of a specific branchmip.install("github:brainelectronics/micropython-winbond",version="feature/add-docs-and-detailed-examples")# install a tag versionmip.install("github:brainelectronics/micropython-winbond",version="0.4.0")For MicroPython versions below 1.19.1 use theupippackage instead ofmip.
Withupipalways the latest available version will be installed.importupipupip.install('micropython-winbond')Test versionInstall a specific release candidate version uploaded toTest Python Package Indexon every PR on the
MicroPython device. If no specific version is set, the latest stable version
will be used.importmipmip.install("github:brainelectronics/micropython-winbond",version="0.4.0-rc2.dev4")For MicroPython versions below 1.19.1 use theupippackage instead ofmip.
Withupipalways the latest available version will be installed.importupip# overwrite index_urls to only take artifacts from test.pypi.orgupip.index_urls=['https://test.pypi.org/pypi']upip.install('micropython-winbond')See alsobrainelectronics Test PyPi Server in Dockerfor a test PyPi server running on Docker.ManuallyUpload files to boardCopy the module to the MicroPython board and import them as shown below
usingRemote MicroPython shellOpen the remote shell with the following command. Additionally use-b 115200in case no CP210x is used but a CH34x.rshell-p/dev/tty.SLAB_USBtoUART--editornanoPerform the following command inside thershellto copy all files and
folders to the devicemkdir/pyboard/lib
mkdir/pyboard/lib/winbond

cpwinbond/*/pyboard/lib/winbond
cpmain.py/pyboard/lib/winbond
cpboot.py/pyboard/lib/winbondUsagefrommachineimportSPI,PinimportosfromwinbondimportW25QFlash# the used SPI and CS pin is setup specific, change accordingly# check the boot.py file of this repo for further boardsflash=W25QFlash(spi=SPI(2),cs=Pin(5),baud=2000000,software_reset=True)flash_mount_point='/external'try:os.mount(flash,flash_mount_point)exceptExceptionase:ife.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 formattingos.VfsFat.mkfs(flash)print('Filesystem for external flash created')# finally mount the external flashos.mount(flash,flash_mount_point)CreditsKudos and big thank you tocrizeo of the MicroPython Forumand
hispost to use Winbond flash chips