Skip to content
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 rp2040 RPi Pico W support #12

Closed
wants to merge 1 commit into from
Closed

Add rp2040 RPi Pico W support #12

wants to merge 1 commit into from

Conversation

ethancheez
Copy link

No description provided.

@capsulecorplab
Copy link

capsulecorplab commented Jul 18, 2023

I recently bought a few RPI Pico W's, specifically with the hopes that someone would eventually add support for it on fprime, so I'd be happy to assist with validating this PR. Are there guidelines for how one could go about doing so?

@capsulecorplab capsulecorplab mentioned this pull request Jul 18, 2023
@SterlingPeet
Copy link
Owner

I recently bought a few RPI Pico W's, specifically with the hopes that someone would eventually add support for it on fprime, so I'd be happy to assist with validating this PR. Are there guidelines for how one could go about doing so?

Hello @capsulecorplab , At this moment the most useful thing you could do is try to see if you can compile a demo deployment with this platform, and comment with whatever issues you run into. At the very least, the readme is sparse and may need some hints to get someone started using it.

@ethancheez
Copy link
Author

I recently bought a few RPI Pico W's, specifically with the hopes that someone would eventually add support for it on fprime, so I'd be happy to assist with validating this PR. Are there guidelines for how one could go about doing so?

@capsulecorplab @SterlingPeet
I worked on a basic fprime LED blinker deployment for Arduino platforms. You can reference this to test new platforms such as the RPi Pico W.

@capsulecorplab
Copy link

@SterlingPeet @ethancheez Thanks for the pointers! I've gotten as far as building/running unit tests for the workshop led blinker project. I'm working on updating my development environment with the arduino-cli tools for building the arduino-led-blinker project. Will post updates as I go~

@capsulecorplab
Copy link

capsulecorplab commented Jul 20, 2023

Got the Arduino CLI tools installed in (a branch of) my dev environment. I tried cloning the fprime-arduino-led-blinker and updating the fprime-arduino submodule to @ethancheez's rpipicow branch and changing teensy41 to rpipicow in settings.ini, but encountered a cmake error that arduino-cli and rpipico:rpipicow couldn't be found when attempting to run fprime-util generate, despite that it's installed

Screenshot from 2023-07-20 13-31-21
Screenshot from 2023-07-20 13-30-25
Screenshot from 2023-07-20 13-32-22

@ethancheez
Copy link
Author

ethancheez commented Jul 20, 2023

@capsulecorplab
Did you add the following board manager:

arduino-cli config add board_manager.additional_urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

And run:

arduino-cli core install rp2040:rp2040

@capsulecorplab
Copy link

Yup, installed here

@capsulecorplab
Copy link

Also, I think I found the issue... I didn't reset the persistence layer in my VM, so it didn't populate the arduino workspace directory with the board packages, which explains why it didn't find it 😅

@capsulecorplab
Copy link

Okay, I'm able run fprime-util generate now, but encountered the following when running fprime-util build -j4
Screenshot from 2023-07-20 14-51-56

@ethancheez
Copy link
Author

@capsulecorplab
Right... I remember running into this.

My workaroud was to comment out the DEPRECATED function in ActiveComponentBase.hpp:24.
And also the start() function in ActiveComponentBase.cpp:54

These are deprecated functions which (should?) be removed from core F' eventually?

@capsulecorplab
Copy link

My workaroud was to comment out the DEPRECATED function in ActiveComponentBase.hpp:24. And also the start() function in ActiveComponentBase.cpp:54

That worked!

Screenshot from 2023-07-20 15-19-28

@capsulecorplab
Copy link

capsulecorplab commented Jul 20, 2023

So full disclosure, it's my first time connecting a raspberry pi pico w to my (Linux Mint) desktop via usb cable... It shows up as a media device but I'm not seeing it on my list of devices with ls /dev/tty*. Any thoughts?

@ethancheez
Copy link
Author

So full disclosure, it's my first time connecting a raspberry pi pico w to my (Linux Mint) desktop via usb cable... It shows up as a media device but I'm not seeing it on my list of devices with ls /dev/tty*. Any thoughts?

If you run arduino-cli board list, does the pico appear in the list?

@capsulecorplab
Copy link

So full disclosure, it's my first time connecting a raspberry pi pico w to my (Linux Mint) desktop via usb cable... It shows up as a media device but I'm not seeing it on my list of devices with ls /dev/tty*. Any thoughts?

If you run arduino-cli board list, does the pico appear in the list?

No, but I would need to bind the device from my host machine to my virtual machine in order for that to work.

@capsulecorplab
Copy link

So, apparently the RP2040 doesn't ship with a serial port and only shows up as a mass storage device https://learn.adafruit.com/dude-where-s-my-com-port?view=all#rp2040-rom-bootloader-specific-3136942

@ethancheez
Copy link
Author

ethancheez commented Jul 21, 2023

So, apparently the RP2040 doesn't ship with a serial port and only shows up as a mass storage device https://learn.adafruit.com/dude-where-s-my-com-port?view=all#rp2040-rom-bootloader-specific-3136942

Interesting, my Pico shows up as /dev/ttyACM0 (Ubuntu). On Windows 10 it shows up as a COM port, and using WSL1, I can see the device at /dev/ttyS10.

I can think of two ways to potentially solve this issue.

Method 1

I believe there should be a .UF2 file in your build-artifacts/rpipicow/LedBlinker/bin. Since your Pico appears as a media device, you may be able to drag and drop that file in there to program it.

Edit: I just tried this and can confirm this works.

Method 2

Here are the steps I did to acquire the upload command for the Pico W. Maybe you can try this and see if it works for you.

  1. Download the Arduino IDE
  2. Add the json URL to the board manager under Preferences.
  3. Install the RP2040 board under Board Manager
  4. Enable verbose mode for compiling/uploading on your Arduino IDE
  5. When you upload for the RPi Pico W, you should be able to see a command that calls an upload script on a .UF2 file. I basically copied that command.

Also take a note if the port name appears when you select the Pico board on your IDE. Maybe it isn't /dev/ttyACM0

@capsulecorplab
Copy link

Method 1

I believe there should be a .UF2 file in your build-artifacts/rpipicow/LedBlinker/bin. Since your Pico appears as a media device, you may be able to drag and drop that file in there to program it.

Edit: I just tried this and can confirm this works.

I think this worked for me as well, as I'm now seeing a /dev/ttyACM0 that I can bind to my VM. Though, ran into an argument error while trying to run the fprime-gds command from LED Blinker: Running on Hardware

Screenshot from 2023-07-21 09-49-10

@ethancheez
Copy link
Author

Though, ran into an argument error while trying to run the fprime-gds command from [LED Blinker: Running on Hardware]

Run pip install pyserial

@capsulecorplab
Copy link

Also, there's no build-artifacts/ folder after building with fprime-util build -j4 in the LedBlinker folder. Should I be in the project root directory instead?
Screenshot from 2023-07-21 09-53-32

@ethancheez
Copy link
Author

ethancheez commented Jul 21, 2023

Also, there's no build-artifacts/ folder after building with fprime-util build -j4 in the LedBlinker folder. Should I be in the project root directory instead?

Yes, I noted in this issue (and this) that we used the devel version of fprime-tools. So the build-artifacts/ directory is in the project root instead of the deployment, and thus you run fprime-gds in the project root.

@capsulecorplab
Copy link

capsulecorplab commented Jul 21, 2023

Also, there's no build-artifacts/ folder after building with fprime-util build -j4 in the LedBlinker folder. Should I be in the project root directory instead?

Yes, I noted in this issue (and this) that we used the devel version of fprime-tools. So the build-artifacts/ directory is in the project root instead of the deployment, and thus you run fprime-gds in the project root.

Cool~ Opened an issue here 🙂

@capsulecorplab
Copy link

LED blinker's working!
Screenshot from 2023-07-21 13-14-02

@capsulecorplab
Copy link

Anything else I can test while I'm here? Communicating over WLAN perhaps?

@ethancheez
Copy link
Author

Anything else I can test while I'm here? Communicating over WLAN perhaps?

WLAN communication was definitely in my TODOs, especially since I got F' deployed on both the Pico W and ESP32, both of which have WiFi chips. If you are willing to create a WLAN component, that would be amazing!

If you take a look at my Baremetal Reference, I am currently using a radio to wirelessly command an F' deployment. Think about it like a ground station talking to a satellite.
Now instead of using a radio component, replace it with a WLAN component, and theoretically we can use WiFi to communicate wirelessly between two WiFi chips!

@capsulecorplab
Copy link

Anything else I can test while I'm here? Communicating over WLAN perhaps?

WLAN communication was definitely in my TODOs, especially since I got F' deployed on both the Pico W and ESP32, both of which have WiFi chips. If you are willing to create a WLAN component, that would be amazing!

If you take a look at my Baremetal Reference, I am currently using a radio to wirelessly command an F' deployment. Think about it like a ground station talking to a satellite. Now instead of using a radio component, replace it with a WLAN component, and theoretically we can use WiFi to communicate wirelessly between two WiFi chips!

I probably haven't gone through enough fprime tutorials to know where to start with developing a WLAN component, so I'd need some guidance to tackle such a feature, to say the least. I recall getting the blinking led example working wirelessly with the RPI reference deployment at one point - any chance we could reuse components from there?

@ethancheez
Copy link
Author

ethancheez commented Jul 21, 2023

I probably haven't gone through enough fprime tutorials to know where to start with developing a WLAN component, so I'd need some guidance to tackle such a feature, to say the least. I recall getting the blinking led example working wirelessly with the RPI reference deployment at one point - any chance we could reuse components from there?

The RPi Ref deployment uses TCP/IP to communicate through a socket. These are currently implemented as Drv::TcpClient, and a other libraries in fprime/Drv/Ip.

You would follow this structure since I believe the WiFi chip on the Pico W also uses sockets and the TCP/IP protocol. However the driver will most likely be different than the one in fprime/Drv since that is meant for Linux systems.

I would poke around some WLAN C++ libraries for the Pico W. The Arduino package might be a good start. For example, I found this after a quick Google search.

@capsulecorplab
Copy link

Should the TCP/IP driver be a part of this PR or perhaps its own separate ticket+PR?

@capsulecorplab
Copy link

Also, should probably add a license #13 to the repo, so that we're not in violation of any copyrights owned by @SterlingPeet 🙃

@ethancheez
Copy link
Author

Should the TCP/IP driver be a part of this PR or perhaps its own separate ticket+PR?

A separate PR would be better.

@ethancheez
Copy link
Author

@capsulecorplab

TCP Client Driver has been made :)

It is under fprime-community/fprime-arduino devel branch

I tested this with my Rpi Pico W and was successfully able to command it through the GDS. Here is an example of the implementation into the topology.

Also, when you start up the GDS, this is going to be your new command:

fprime-gds -n --dictionary build-artifacts/rpipicow/LedBlinker/dict/LedBlinkerTopologyAppDictionary.xml

You would need to start the GDS first, and then power on the Rpi Pico W.

@capsulecorplab
Copy link

@ethancheez sorry for the delay. Finally got around to compiling the arduino led blinker project with the tcp client driver (I think...). Though, I'm encountering an odd behavior when I try to drag and drop the .uf2 file into my rpi pico media storage device where it disconnects before it completes copying over. Any ideas?

@ethancheez
Copy link
Author

@ethancheez sorry for the delay. Finally got around to compiling the arduino led blinker project with the tcp client driver (I think...). Though, I'm encountering an odd behavior when I try to drag and drop the .uf2 file into my rpi pico media storage device where it disconnects before it completes copying over. Any ideas?

It only unmounts during the upload process? If you plug in the Pico with the BOOTSEL pressed down, wait for the media device to appear, leave it for a bit without uploading the .uf2 file, does it still unmount? If so, it could be a hardware issue.

From my experience, the pico automatically unmounts after the .uf2 file is copied over.

Perhaps you can try the second upload method using the cli, does it succeed there?

If not, try upload a simple blink program using the Arduino IDE and see if that succeeds.

@capsulecorplab
Copy link

It only unmounts during the upload process? If you plug in the Pico with the BOOTSEL pressed down, wait for the media device to appear, leave it for a bit without uploading the .uf2 file, does it still unmount? If so, it could be a hardware issue.

I haven't experienced it unmounting on its own; only while the .uf2 file is uploading.

From my experience, the pico automatically unmounts after the .uf2 file is copied over.

If plugged back in, the .uf2 file doesn't appear alongside the other files.

Perhaps you can try the second upload method using the cli, does it succeed there?

I haven't tried the 2nd method via the arduino-cli. Is it as simple as running arduino-cli upload build-artifacts/rpipicow/LedBlinker/bin/LedBlinker.uf2?

@ethancheez
Copy link
Author

If plugged back in, the .uf2 file doesn't appear alongside the other files.

If I recall correctly, the .uf2 file does not reappear in the media device after the upload completes.

I haven't tried the 2nd method via the arduino-cli. Is it as simple as running arduino-cli upload build-artifacts/rpipicow/LedBlinker/bin/LedBlinker.uf2?

I have the instructions written here

@capsulecorplab
Copy link

Right. I think I'd need to implement a serial bootloader on my Pico W, as it doesn't show up as a serial port https://learn.adafruit.com/dude-where-s-my-com-port?view=all#rp2040-rom-bootloader-specific-3136942; Maybe using something like https://github.com/usedbytes/rp2040-serial-bootloader

@capsulecorplab
Copy link

It's possible method 1 also worked, I'm just not able to connect to it with fprime-gds

@SterlingPeet
Copy link
Owner

SterlingPeet commented Aug 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants