-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Add support for Raspberry Pi Pico #668
Conversation
Answering some of my questions... I found the source for rpi2040load.exe. It's just a wrapper around elf2uf2 and picotool. I'm going to take a pass at updating this PR so it only uses picotool and gets rid of the other two apps. |
I've spent a bunch more time on this and unfortunately I've opened raspberrypi/picotool#48 on their side, hopefully there will either be a "you're doing X wrong" or "yeah we can fix that" response soon. |
Unfortunetely I can not answer these questions. I made it very simple, I flashed the Pico from PlatformIO with verbose output and copied what they are doing. I was wondering too why they used the .elf file and it is converted to an .uf2 file. But I didn't make such a deep dive as Neil did (and does). |
I've made a ton of progress on this in the last few days. The The I was successfully able to build picotool locally this morning and talk to a Pico via device address. The remaining problem is how to discover that device address. According to device manager my pico's address is |
After two days of digging into this I've given up on finding a way to flash from within MobiFlight. For any connected board (regardless of type, Arduino or Raspberry Pi, doesn't matter) MobiFlight needs to know two things:
On Arduinos the COM port is the address for flashing. This is obtained by looking in the Windows Registry. On the Pico the COM port is used for serial communication but the address is a combination of MobiFlight can successfully get the COM port for Picos during You might think "ok, split the two. Get the COM port and then later on look up the bus number and address". Unfortunately there's no way I can find to make a connection between the two. Imagine you have two Picos connected, one on COM1 and one on COM2, and you want to flash the second one. How does MobiFlight know after enumerating the bus number and address for all connected Picos that the one at bus 5 address 15 is the device connected to COM2? There's no unique identifier I can find for connected USB devices that could be used to make this link. So... I'm giving up for now :( |
The closest thing I can find that would make this link is On the libusb side of things Soooooooooo close. |
// This method would, in theory, return the bus number and address for the supplied module. | ||
// Unforutnately I can't find any way to do that. | ||
|
||
public static Tuple<int, int> GetBusNumberAndAddress(MobiFlightModule module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where to start reading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool work, but honestly and no offense: I don't like the strong dependency to the flash tool in the configuration.
As I described on Discord already, we should find a more flexible way to allow for adding additional boards without modifying the MobiFlight code every time. This would allow for something like a community board repository where you can simply drop the boards definition together with a updater file into the MobiFlight installation. The benefit of this would be that the community can come up with more exotic and (experimental) boards that implement the MobiFlight API without having to "officially" support them with the core project.
When we started to discuss custom boards, then you proposed a flag to say: i am not updateable. don't worry about me, I can update my firmware myself. And I find that idea still cool! Why do we have to put in these specific implementations. tomorrow there might be another board.
it is super cool that you were able to add it into mobiflight and maybe we could leave it now since we have done it, but i am sure there will be another board.
With the avr dude it is quite simple, we can put all config required for starting the script into the boards definition file. I understand the lookup is different for the pico, but MobiFlight at the moment needs a serial port. Can we not pass the serial port to a little wrapper exe that then does the lookup and starts the pico flasher correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter where the code lives because I can't find any way to take the serial port and do a lookup of the necessary values. Whether the code lives inside Mobiflight or as a separate tool is irrelevant if there's no way to do it in the first place ;)
After days of digging into this I'm convinced it isn't possible. The best we could do is provide a pico firmware file and ship a board.json for it with MobiFlight. People will have to manually flash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the manual flashing is totally acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and for clarification: this now works or still doesn't? because in the initial comments it sounds as if had figured it out how to do it through MF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this now works or still doesn't?
Calling PicoTool works, but there is no way to get the address and bus to pass to PicoTool so it knows what device to flash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it doesn't work with MF
Will open a new PR sometime with just the board definition file. |
Companion draft pull request to the Firmware side of things. As with the firmware this leverages the amazing work by @elral where he figured out how to use the
rpi2040load.exe
command to upload firmware to the Raspberry Pi Pico.Additions to Ralf's work:
PicoToolSettings
for the pico-specific flash options.DelayBeforeFirmwareUpload
setting to control how long to wait for a board to reconnect before trying to flash the firmware.This does work, I successfully used it to flash a Pico from 0.0.1 to 2.0.1. It's still draft though.
Questions I have:
picotool.exe
for this when it's actuallyrpi2040load.exe
that does the work?picotool.exe
even needed?Rpi2040LoadSettings
,RunRpi2040Load()
etc. instead since that's the actual command that gets run?.elf
on the end of the firmware, but when I did that (even on the command line manually) it got an extra.uf2
added to the end which caused a failure..elf
when as far as I can tell the tool wants the.uf2
version of the firmware? Is that because I never bothered to download theelf2uf2.exe
app?(Side note: this rpi2040load.exe is the most obscure and opaque piece of software I've seen in a long time!!!)