-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"ValueError: invalid port" on machine module due to devicetree property deprecation in zephyr (?) #9115
Comments
Ok, some results over here: After modifying the corresponding cpu dts files (adding a label) on zephyr I got the nrf52840dk board able to toggle a pin using the machine module and the Pin class. I can state more confidently that for the current version (3.1.99) and newer of zephyr, 🔥 the mpy port will not work with any board which has removed the label property of the peripherals dts nodes 😿 |
The mpy port will still work, but you need to change the device name string you use with zephyr class constructors. Please see the documentation commit in #9335 :
|
@MaureenHelm, thanks for your support :) That is great. I wasn´t aware that node names are also resolved by device_get_binding() 😓 |
If you want to dig more into device name strings, please have a look at DEVICE_DT_DEFINE. Specifically, "The device structure's name field is set to DEVICE_DT_NAME(node_id)." |
Mmm, I see:
As most of these macros are resolved during build time (since they are concatenating tokens), the only(?) usable C types that could be handled in runtime by device_get_binding() are the nodes names strings. For end users to avoid using such tricky devicetree notation, maybe we could add some support python file/package with the list of available machine instances for a given board as you did in the docs examples in your pull request. Some like: frdm_k64f_machine.py:
This file can be imported in the application any zephyr dts implementation specific abstracted at mpy level. For
Or more generically, a zephyr_dts_machine_map.py package that is available as mpy module if the given mpy zephyr port board adds such file. Not sure yet how/where to add this within the mpy zephyr port. Thanks a lot for your support @MaureenHelm 😃 |
Hi everyone! Thanks @jaenrig-ifx for raising this issue. I'm having the same problem with an RT1060. I'm new to zephyr and I'm trying to understand what changes I must do in order to override the dts. Hope you don't mind for asking this here, but didn't find any better place. I'm currently using
And, as an extra detail, I'm getting a lot of deprecation warnings like the following one. Not sure if I should modify the micropython code to reflect the changes in Zephyr code.
|
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:
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 inmp_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:
The text was updated successfully, but these errors were encountered: