adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4k stars 1.18k forks source link

Ethernet function with a uf2 file on Raspberry Pi pico #5522

Closed min-hs closed 2 years ago

min-hs commented 2 years ago

I'm using CircuitPython by uploading it on the Raspberry Pi Pico board.

I tried to make a uf2 file according to the contents in the guide.(https://learn.adafruit.com/building-cir ... cuitpython)

I want to create a uf2 file with added network functionality. Is there a way to get and use the Adafruit_wiznet5k file provided by Bundle?

Just as Adafruit_bus_device is ported, I would like to add a wiznet5k library.

Instead of adding a library to the lib file, we try to implement the ethernet function with a uf2 file. Can you help me?

Thank you.

tannewt commented 2 years ago

Why do you want the Wiznet library in the uf2? That will make it harder to update.

You'll need to submodule the library into the CircuitPython repo and then add it as frozen to the board. Here is an example: https://github.com/adafruit/circuitpython/blob/main/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk#L23

min-hs commented 2 years ago

Thanks alot.

This time, WIZnet launched Ethernet HAT and W5100S-EVB-Pico. Only W5500 and W5200 chips were available in the existing library. Additionally, I modified the wiznet5k file by adding the W5100S register.

I created a firmware file by putting the wiznet5k library in the uf2 file. Where should I attach the library that added W5100S and the uf2 file? Can I upload it to Pull Requests?

tannewt commented 2 years ago

Please create a pull request to the existing library that you added the W5100S support for.

You could also create a new library for the new chipset. Instructions for creating a new library are here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library

We won't redistribute a uf2 here. You can redistribute it yourself if you really want it bundled in the UF2. Otherwise, I think it's best to get the existing library update for the new chipset and then it'll be available in the bundle.

We're happy to help in chat too via Discord: https://adafru.it/discord

min-hs commented 2 years ago

I have one more question. I'd like to insert a library other than the one provided by Adafruit lib. After that, I want to frozen the module to create a uf2 file, is there a way to do it? I'd appreciate it if you let me know.

tannewt commented 2 years ago

The process is the same for non-Adafruit libraries. Add a new directory to the frozen directory and then reference it in a build file with FROZEN_MPY_DIRS.

min-hs commented 2 years ago

I took the library, put it in the Circuit Python/frozen folder, and did make, but the following error occurred. Is there anything else I need to modify?

circuitpython/ports/raspberrypi$ make -j4 BOARD=raspberry_pi_pico
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
FREEZE ../../frozen/Adafruit_CircuitPython_BusDevice ../../frozen/RP2040-HAT-CircuitPython
fatal: no tag exactly matches '30049537445f72f555c8835b21f2bb07ba973428'
Traceback (most recent call last):
  File "../../tools/preprocess_frozen_modules.py", line 20, in version_string
    tag = subprocess.check_output("git describe --tags --exact-match", shell=True, cwd=path)
  File "/usr/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'git describe --tags --exact-match' returned non-zero exit status 128.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../../tools/preprocess_frozen_modules.py", line 95, in <module>
    copy_and_process(in_dir, args.out_dir)
  File "../../tools/preprocess_frozen_modules.py", line 71, in copy_and_process
    module_version = version_string(root, valid_semver=True)
  File "../../tools/preprocess_frozen_modules.py", line 29, in version_string
    version_info = semver.parse_version_info(tag)
  File "/home/louis/pico/circuitpython/tools/python-semver/semver.py", line 123, in parse_version_info
    parts = parse(version)
  File "/home/louis/pico/circuitpython/tools/python-semver/semver.py", line 50, in parse
    raise ValueError('%s is not valid SemVer string' % version)
ValueError: mpy_libraries is not valid SemVer string
make: *** [../../py/mkrules.mk:140: build-raspberry_pi_pico/frozen_mpy] Error 1
make: *** Waiting for unfinished jobs....
tannewt commented 2 years ago

Ah, it is looking for a git tag to mark the release. Make sure you added it as a submodule and have a release tag at the commit. The format of the version should be x.x.x to match the semantic versioning expectation.

dhalbert commented 2 years ago

Closing this for now. Please reopen if this is unresolved.