Guidance on modifying Micropython for upcoming Pimoroni Yukon board #12116
Replies: 4 comments 3 replies
-
You can post this to the pimoroni forum too: https://forums.pimoroni.com/ |
Beta Was this translation helpful? Give feedback.
-
Hi. Just wondering if any of the devs here have had a think over the questions I posted? |
Beta Was this translation helpful? Give feedback.
-
While there are C hooks a board profile can use to run C functions at startup( eg. So yeah in theory you could write some reset / init functions in C and use this or similar C hooks... but I hate writing drivers twice (python and C) so wouldn't reccomend this for myself :-) I do think there's a real place for a That being said... I've had discussions about trying to find a way for board profiles to include drivers for on-board devices (regardless of whether they're auto-imported or not), there's a question about where these drivers would/should live. We don't want individual copies of drivers living in the board profile folders, eg drivers for generic things like i2c expanders should not be duplicated into every board folder that uses them. So these drivers probably just need to be submitted / merged into micropython-lib and manifest.py frozen into the board build, then said hypothetical This could make testing releases for boards more complicated, ie if said shared driver is upgraded do all boards that use it still work? I guess it also means getting new boards merged will be blocked by getting all their drivers merged first too... not insurmountable issues though certainly. But on some boards there could be custom output hardware that does not really use a driver you'd consider generic, so maybe that doesn't belong in micropython-lib... does it do into the board folder? What if the manf makes 5 different boards that all use this same custom output, does that code then need replicating... maybe? Or it needs to manifest.py reference directly to their own github repo... but do we want to allow boards to automatically pull in third-party code? Couple of questions more than answers, but I personally think an auto-import |
Beta Was this translation helpful? Give feedback.
-
@ZodiusInfuser This is because CircuitPython resets the runtime+VM before dropping to the REPL, whereas MicroPython keeps the existing program state (triggered by the Ctrl-C that Thonny sends). Personally I really like the MicroPython behavior, it's very useful for debugging. With regard to your other questions, the answer kind of falls into two parts:
The current behavior is that it drops to the REPL (after displaying the exception). I feel like if your program wants to soft reset automatically on uncaught exception then it should add a global exception handler to explicitly call |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I am a dev at Pimoroni, working on an upcoming RP2040-powered robot controller called Yukon (https://www.tomshardware.com/news/pimoroni-stealthily-announce-rp2040-yukon-modular-robotics-platform), and am looking for some guidance in modifying Micropython for it.
Yukon is designed for high power (well higher than we have done before), supporting 30A peak inputs at 17, and features interchangeable modules to suit people's different project needs. As such it not only uses all of the RP2040's GPIO, it also have two I2C IO expanders, and ADC muxes onboard to give the number of IO necessary. One of its key features is various voltage, current, and temperature sensors onboard letting users monitor their system and turn off the power mosfet in the event of a fault.
Initial firmware development for the product took place with CircuitPython, as that was the one we had least control over, so likely the hardest to get the required functionality working. In fact it turned out to be easier, and came with some surprises that made for a nice user experience. Namely the board initialisation/resetting letting the IO be automatically configured, and the board definition system, letting the various IO be grouped into their respective slots. It also appears that the stop command from Thonny causes the board to soft reset, causing all the IO to be put back into a safe state.
I am now at the point of wanting to replicate the firmware in Micropython. As you may be aware, Pimoroni create their own MPy builds for products, so I have lot of flexibility in what I can change, though some of my planned changes could be worth upstreaming to benefit everybody. Unfortunately I am having difficulty identifying what areas of code I need to modify (and how) in order to get the behaviour I need.
Here is a list of what I am currently aware of:
machine_pin_ext
functions)I briefly talked with Matt Trentini on twitter about the initialisation and resetting points, and there were certainly some valid questions raised. For instance, such resetting should be unnecessary if users followed best practices with handling all code paths and exceptions, but given one tester killed their Yukon board recently because they forgot to perform a specific function call in their loop that was in ALL the provided examples (!), that just cannot be guaranteed. I would therefore much rather encourage best practices, but have low-level systems in place as a fallback. We are also modifying the board with more hardware level protections based on that specific event.
As for the other points regarding the IO expanders, there could well be a module the user imports that lets them control those IO pins, which would be fine. After seeing what was done for the Raspberry Pi with the Pico W's WiFi module to abstract the user LED, I think this is a nice approach to apply to Yukon too. And anyway, the IO expanders are an implementation detail that are only there because the RP2040 doesn't have enough pins 😆
TL:DR, Working on a new RP2040 board, and would like guidance on modifying Micropython to support board initialisation/resetting, IO expander based Pin objects, and soft resetting under more conditions.
Thanks for your time!
P.S if this is the wrong sub-section, please let me know or move it to the correct place
Beta Was this translation helpful? Give feedback.
All reactions