micropython-winbond


Namemicropython-winbond JSON
Version 0.5.4 PyPI version JSON
download
home_pagehttps://github.com/brainelectronics/micropython-winbond
SummarySimple MicroPython Winbond library
upload_time2024-05-30 18:15:46
maintainerNone
docs_urlNone
authorbrainelectronics
requires_pythonNone
licenseMIT
keywords micropython winbond library
VCS
bugtrack_url
requirements rshell
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MicroPython Winbond Flash

[![Downloads](https://pepy.tech/badge/micropython-winbond)](https://pepy.tech/project/micropython-winbond)
![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-winbond?include_prereleases&color=success)
![MicroPython](https://img.shields.io/badge/micropython-Ok-green.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/brainelectronics/micropython-winbond/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-winbond/actions/workflows/release.yml)

MicroPython library to interact with Winbond W25Q Flash chips

📚 The latest documentation is available at
[MicroPython Winbond ReadTheDocs][ref-rtd-micropython-winbond] 📚

-----------------------

<!-- MarkdownTOC -->

- [Installation](#installation)
    - [Install required tools](#install-required-tools)
- [Stetup](#stetup)
    - [Install package](#install-package)
        - [General](#general)
        - [Specific version](#specific-version)
        - [Test version](#test-version)
    - [Manually](#manually)
        - [Upload files to board](#upload-files-to-board)
- [Usage](#usage)
- [Credits](#credits)

<!-- /MarkdownTOC -->

## Installation

### Install required tools

Python3 must be installed on your system. Check the current Python version
with the following command

```bash
python --version
python3 --version
```

Depending on which command `Python 3.x.y` (with x.y as some numbers) is
returned, use that command to proceed.

```bash
python3 -m venv .venv
source .venv/bin/activate

pip install -r requirements.txt
```

For interaction with the filesystem of the device the
[Remote MicroPython shell][ref-remote-upy-shell] can be used.

Test the tool by showing its man/help info description.

```bash
rshell --help
```

## Stetup

### Install package

Connect the MicroPython device to a network (if possible)

```python
import network
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect('SSID', 'PASSWORD')
station.isconnected()
```

#### General

Install the latest package version of this lib on the MicroPython device

```python
import mip
mip.install("github:brainelectronics/micropython-winbond")
```

For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`

```python
import upip
upip.install('micropython-winbond')
```

#### Specific version

Install a specific, fixed package version of this lib on the MicroPython device

```python
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")
```

For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`.
With `upip` always the latest available version will be installed.

```python
import upip
upip.install('micropython-winbond')
```

#### Test version

Install a specific release candidate version uploaded to
[Test Python Package Index](https://test.pypi.org/) on every PR on the
MicroPython device. If no specific version is set, the latest stable version
will be used.

```python
import mip
mip.install("github:brainelectronics/micropython-winbond", version="0.4.0-rc2.dev4")
```

For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`.
With `upip` always the latest available version will be installed.

```python
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')
```

See also [brainelectronics Test PyPi Server in Docker][ref-brainelectronics-test-pypiserver]
for a test PyPi server running on Docker.

### Manually

#### Upload files to board

Copy the module to the MicroPython board and import them as shown below
using [Remote MicroPython shell][ref-remote-upy-shell]

Open the remote shell with the following command. Additionally use `-b 115200`
in case no CP210x is used but a CH34x.

```bash
rshell -p /dev/tty.SLAB_USBtoUART --editor nano
```

Perform the following command inside the `rshell` to copy all files and
folders to the device

```bash
mkdir /pyboard/lib
mkdir /pyboard/lib/winbond

cp winbond/* /pyboard/lib/winbond
cp main.py /pyboard/lib/winbond
cp boot.py /pyboard/lib/winbond
```

## Usage

```python
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)
```

## Credits

Kudos and big thank you to [crizeo of the MicroPython Forum][ref-crizeo] and
his [post to use Winbond flash chips][ref-upy-forum-winbond-driver]

<!-- Links -->
[ref-rtd-micropython-winbond]: https://micropython-winbond.readthedocs.io/en/latest/
[ref-remote-upy-shell]: https://github.com/dhylands/rshell
[ref-brainelectronics-test-pypiserver]: https://github.com/brainelectronics/test-pypiserver
[ref-crizeo]: https://forum.micropython.org/memberlist.php?mode=viewprofile&u=3067
[ref-upy-forum-winbond-driver]: https://forum.micropython.org/viewtopic.php?f=16&t=3899&start=10



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/brainelectronics/micropython-winbond",
    "name": "micropython-winbond",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "micropython, winbond, library",
    "author": "brainelectronics",
    "author_email": "info@brainelectronics.de",
    "download_url": "https://files.pythonhosted.org/packages/d2/31/40dd54a9409c1038deace2527704592446ac7f201db7c1713e44e98ee157/micropython-winbond-0.5.4.tar.gz",
    "platform": null,
    "description": "# MicroPython Winbond Flash\n\n[![Downloads](https://pepy.tech/badge/micropython-winbond)](https://pepy.tech/project/micropython-winbond)\n![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-winbond?include_prereleases&color=success)\n![MicroPython](https://img.shields.io/badge/micropython-Ok-green.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![CI](https://github.com/brainelectronics/micropython-winbond/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-winbond/actions/workflows/release.yml)\n\nMicroPython library to interact with Winbond W25Q Flash chips\n\n\ud83d\udcda The latest documentation is available at\n[MicroPython Winbond ReadTheDocs][ref-rtd-micropython-winbond] \ud83d\udcda\n\n-----------------------\n\n<!-- MarkdownTOC -->\n\n- [Installation](#installation)\n    - [Install required tools](#install-required-tools)\n- [Stetup](#stetup)\n    - [Install package](#install-package)\n        - [General](#general)\n        - [Specific version](#specific-version)\n        - [Test version](#test-version)\n    - [Manually](#manually)\n        - [Upload files to board](#upload-files-to-board)\n- [Usage](#usage)\n- [Credits](#credits)\n\n<!-- /MarkdownTOC -->\n\n## Installation\n\n### Install required tools\n\nPython3 must be installed on your system. Check the current Python version\nwith the following command\n\n```bash\npython --version\npython3 --version\n```\n\nDepending on which command `Python 3.x.y` (with x.y as some numbers) is\nreturned, use that command to proceed.\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\n\npip install -r requirements.txt\n```\n\nFor interaction with the filesystem of the device the\n[Remote MicroPython shell][ref-remote-upy-shell] can be used.\n\nTest the tool by showing its man/help info description.\n\n```bash\nrshell --help\n```\n\n## Stetup\n\n### Install package\n\nConnect the MicroPython device to a network (if possible)\n\n```python\nimport network\nstation = network.WLAN(network.STA_IF)\nstation.active(True)\nstation.connect('SSID', 'PASSWORD')\nstation.isconnected()\n```\n\n#### General\n\nInstall the latest package version of this lib on the MicroPython device\n\n```python\nimport mip\nmip.install(\"github:brainelectronics/micropython-winbond\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`\n\n```python\nimport upip\nupip.install('micropython-winbond')\n```\n\n#### Specific version\n\nInstall a specific, fixed package version of this lib on the MicroPython device\n\n```python\nimport mip\n# install a verions of a specific branch\nmip.install(\"github:brainelectronics/micropython-winbond\", version=\"feature/add-docs-and-detailed-examples\")\n# install a tag version\nmip.install(\"github:brainelectronics/micropython-winbond\", version=\"0.4.0\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`.\nWith `upip` always the latest available version will be installed.\n\n```python\nimport upip\nupip.install('micropython-winbond')\n```\n\n#### Test version\n\nInstall a specific release candidate version uploaded to\n[Test Python Package Index](https://test.pypi.org/) on every PR on the\nMicroPython device. If no specific version is set, the latest stable version\nwill be used.\n\n```python\nimport mip\nmip.install(\"github:brainelectronics/micropython-winbond\", version=\"0.4.0-rc2.dev4\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`.\nWith `upip` always the latest available version will be installed.\n\n```python\nimport upip\n# overwrite index_urls to only take artifacts from test.pypi.org\nupip.index_urls = ['https://test.pypi.org/pypi']\nupip.install('micropython-winbond')\n```\n\nSee also [brainelectronics Test PyPi Server in Docker][ref-brainelectronics-test-pypiserver]\nfor a test PyPi server running on Docker.\n\n### Manually\n\n#### Upload files to board\n\nCopy the module to the MicroPython board and import them as shown below\nusing [Remote MicroPython shell][ref-remote-upy-shell]\n\nOpen the remote shell with the following command. Additionally use `-b 115200`\nin case no CP210x is used but a CH34x.\n\n```bash\nrshell -p /dev/tty.SLAB_USBtoUART --editor nano\n```\n\nPerform the following command inside the `rshell` to copy all files and\nfolders to the device\n\n```bash\nmkdir /pyboard/lib\nmkdir /pyboard/lib/winbond\n\ncp winbond/* /pyboard/lib/winbond\ncp main.py /pyboard/lib/winbond\ncp boot.py /pyboard/lib/winbond\n```\n\n## Usage\n\n```python\nfrom machine import SPI, Pin\nimport os\nfrom winbond import W25QFlash\n\n# the used SPI and CS pin is setup specific, change accordingly\n# check the boot.py file of this repo for further boards\nflash = W25QFlash(spi=SPI(2), cs=Pin(5), baud=2000000, software_reset=True)\n\nflash_mount_point = '/external'\n\ntry:\n    os.mount(flash, flash_mount_point)\nexcept Exception as e:\n    if e.errno == 19:\n        # [Errno 19] ENODEV aka \"No such device\"\n        # create the filesystem, this takes some seconds (approx. 10 sec)\n        print('Creating filesystem for external flash ...')\n        print('This might take up to 10 seconds')\n        os.VfsFat.mkfs(flash)\n    else:\n        # takes some seconds/minutes (approx. 40 sec for 128MBit/16MB)\n        print('Formatting external flash ...')\n        print('This might take up to 60 seconds')\n        # !!! only required on the very first start (will remove everything)\n        flash.format()\n\n        # create the filesystem, this takes some seconds (approx. 10 sec)\n        print('Creating filesystem for external flash ...')\n        print('This might take up to 10 seconds')\n        # !!! only required on first setup and after formatting\n        os.VfsFat.mkfs(flash)\n\n    print('Filesystem for external flash created')\n\n    # finally mount the external flash\n    os.mount(flash, flash_mount_point)\n```\n\n## Credits\n\nKudos and big thank you to [crizeo of the MicroPython Forum][ref-crizeo] and\nhis [post to use Winbond flash chips][ref-upy-forum-winbond-driver]\n\n<!-- Links -->\n[ref-rtd-micropython-winbond]: https://micropython-winbond.readthedocs.io/en/latest/\n[ref-remote-upy-shell]: https://github.com/dhylands/rshell\n[ref-brainelectronics-test-pypiserver]: https://github.com/brainelectronics/test-pypiserver\n[ref-crizeo]: https://forum.micropython.org/memberlist.php?mode=viewprofile&u=3067\n[ref-upy-forum-winbond-driver]: https://forum.micropython.org/viewtopic.php?f=16&t=3899&start=10\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple MicroPython Winbond library",
    "version": "0.5.4",
    "project_urls": {
        "Bug Reports": "https://github.com/brainelectronics/micropython-winbond/issues",
        "Homepage": "https://github.com/brainelectronics/micropython-winbond",
        "Source": "https://github.com/brainelectronics/micropython-winbond"
    },
    "split_keywords": [
        "micropython",
        " winbond",
        " library"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d23140dd54a9409c1038deace2527704592446ac7f201db7c1713e44e98ee157",
                "md5": "a525e5aa9929e2b49e0d027bbd2442b1",
                "sha256": "b3f568354d154c42df3d99de3cbc31d02dd203a93eea00c775d14b81e3f3925e"
            },
            "downloads": -1,
            "filename": "micropython-winbond-0.5.4.tar.gz",
            "has_sig": false,
            "md5_digest": "a525e5aa9929e2b49e0d027bbd2442b1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7282,
            "upload_time": "2024-05-30T18:15:46",
            "upload_time_iso_8601": "2024-05-30T18:15:46.952969Z",
            "url": "https://files.pythonhosted.org/packages/d2/31/40dd54a9409c1038deace2527704592446ac7f201db7c1713e44e98ee157/micropython-winbond-0.5.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-30 18:15:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "brainelectronics",
    "github_project": "micropython-winbond",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "rshell",
            "specs": [
                [
                    "<",
                    "1.0.0"
                ],
                [
                    ">=",
                    "0.0.30"
                ]
            ]
        }
    ],
    "lcname": "micropython-winbond"
}
        
Elapsed time: 4.62224s