Skip to content

"ValueError: invalid port" on machine module due to devicetree property deprecation in zephyr (?) #9115

@jaenrig-ifx

Description

@jaenrig-ifx

Hi @MaureenHelm,
Hi @dpgeorge,

After going a little bit through the commit history of the zephyr port, I believe you might be the most familiar with this topic 🔧.

When trying to instantiate Pin (and probably other machine module classes) there is no way to provide a valid port.

For example, when in REPL mode:

*** Booting Zephyr OS build deb243fcf94e  ***
MicroPython deb243fcf9-dirty on 2022-08-26; zephyr-cy8cproto_062_4343w with unknown-cpu
>>> from machine import Pin
>>> pin = Pin(("LED_0",7), Pin.OUT)                                                         
Traceback (most recent call last):                                                          
  File "<stdin>", line 1, in <module>                                                       
ValueError: invalid port 

I have tried with a couple boards: nrf52840DK and CY8CPROTO_062_4343W. The latest is currently being added to zephyr (work in progress). That combined with my inexperience with both zephyr and micropython led me to believe that I just don´t know how to provide the proper tuple for the pin.
But after some research it seems there is a deprecation in the devicetree node property "label", which is the property used by device_get_binding() to get the device instance in mp_pin_make_new().

Updates in the .dts files (i.e. the dts/arm/nxp family used by the frdm_k64f board) seem to be removing this property, and the way of creating pins or machine instances as described in the docs won´t work for any board removing all labels (?).

Not sure if I am still missing something, and it is all simpler than this...
If that is not the case, are you aware of this issue? Any plan to update the port to the new dts specification? I am still getting my way into zephyr, but maybe using device_from_handle() instead?

Thanks a lot!

For extra context. These are the versions used here to build micropython:

  • Zephyr version: 3.1.99
  • Zephyr sdk: 0.13.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions