16 Comments

Hi Jim, rp-rs developer + maintainer here.

Thanks for the write-up, both for where things worked and where they didn't. We haven't had too much feedback on that, so it is most welcome!

Great to see a good step-by-step configuration options for OpenOCD - I haven't used it for debugging rp2040 but I know that a few have and had issues getting it set up correctly; we should really have some of this documentation as part of the project.

It's a bit late to help now (since you look to be done with this series) but I'd be interested in trying to work out why the probe / debug configuration from rp2040-app-template didn't work for you so that others don't have the same problems.

We spend most of our time in https://app.element.io/#/room/#rp-rs:matrix.org if you'd prefer a real-time group chat style conversation, or you could raise an issue on github on either rp2040-app-template or rp-hal - whichever works best for you.

This is an open invitation by the way - everyone is welcome in the matrix room, and issues / PRs for the repos most welcome.

Expand full comment

Hi there! Thanks for taking the time to add a comment here. I’d love for the instructions that I’ve put together to make it into the rp2040-app-template. I’ll consider prepping a PR for that myself, it’s the least I can do to contribute to such a great project!

Thanks for the invitation to the group chat as well, I wasn’t aware of that. Something else to add to the project README as well.

I encourage all of my readers interested in the Pico + Rust to join that chat. With any luck, we’ll continue to create an exciting and robust Rust community around the Pico.

Expand full comment

Hey! Thank you for this series of post.

I was just playing around with some RP2040 controllers, and ended up with a slightly simpler setup (IMO). Instead of using a separate controller for handling the debug, I've just set up debug logging via USB serial port. This requires a bit more boilerplate (handling the USB interrupt and such), but is much simpler from the hardware perspective: you need to just plug in a single Pico board in your USB, flash it and you can immediately see the debug output.

Here's my repo: https://github.com/eterevsky/rp2040-blink

Expand full comment

This is very good stuff and thank you for sharing it with me and other readers! Are you working on some fun projects with the RPi Pico and Rust or professionally for work (or a little of both)?

Expand full comment

I'm just learning how embedded programming works in general and in Rust in particular. This is quite far from what I do professionally.

As a goal, I would like to figure out how to work with WiFi using Pico Wireless or Arduino Nano Connect to be able to remotely control things like smart lightbulbs and sensors. But we'll see how it goes.

Expand full comment

That's excellent, good for you in embarking on a journey to learn embedded programming with Rust!

As soon as I receive my Pimoroni Pico Decker (https://shop.pimoroni.com/products/pico-decker) I'm going to try and work on a Rust module for the Pimoroni Pico Wireless (https://shop.pimoroni.com/products/pico-wireless-pack). If that interests you at all I could use some help.

Expand full comment

Yes, that's exactly the setup that I'm using. From what I can tell, here's the C++ drivers for the WiFi controller: https://github.com/pimoroni/pimoroni-pico/tree/main/drivers/esp32spi. It seems straight-forward enough to port to Rust. (I haven't started on it yet though.)

Expand full comment

Indeed, that’s going to be exactly the approach I take. The C++ version is very straightforward code.

Expand full comment

a quick heads up: "ext install rust-lang.rust" seems to be deprecated in favor of "rust-analyzer"?

Expand full comment

Thank you, updated.

Expand full comment

Thanks for the steps! I'm building my first project but finding that the target listed above does not generate Thumb2 assembly. I'm trying to implement a coroutine project that uses Thumb2. How can I get the compiler to generate Thumb2 on an armv6m target?

Expand full comment

I haven't explored much myself yet, but there are two resources to point out here that I think you'll find quite helpful.

The first is this article which covers quite a few ways to generate assembly output with rustc: https://blog.logrocket.com/interacting-with-assembly-in-rust/

The second is a fantastic online resource to paste some Rust code (make sure to select Rust, C++ is default) and it'll give you the assembler version of it for your choice of target (x86 is default): https://godbolt.org/

Hope this helps and thanks for reading!

Expand full comment

Thanks for the references. I've bookmarked them. Actually, the rust devs were super quick and knowledgeable on github. Here is their response. https://github.com/rust-lang/stdarch/issues/1312

Expand full comment

Ah very good, I misunderstood your question as wondering how to view Arm assembly versions of Rust in general, not that the Thumb2 part was specific. Glad you found a solution that was helpful.

Expand full comment

I'm on Mac and I've got a small test project which compiles and runs, and can use breakpoints from VS and step through, but I can't seem to get any debug print output anywhere. I've checked my wiring and used test programs from the pico C++ SDK. They write just fine to the serial output. But using the rust project, I see no debug output whatsoever, anywhere. DEFMT_LOG is set to "debug". It doesn't matter if I use defmt::info! or debug! or println. The "output" section of VSCode stays empty as well as the debug console. VS "Terminal" only shows build tool output. I've got a "screen" session attached to the /dev/tty.usbXXX device, which shoud be the debug probe pico that is connected to my computer. Using the C++ examples, it shows the serial output. Running the rust examples shows nothing here. There is also no debug logging in gdb or openocd. What am I missing? Thanks!

Expand full comment

Hi Tony, there can be several different reasons why it's not working for you right now. Have you tried approaching things like this, setting up a UART connected to your picoprobe and writing more directly to this port?

https://github.com/Jim-Hodapp-Coaching/edge-rs/blob/master/src/main.rs

If this doesn't help, double check your wiring for the Pico to Picoprobe configuration against this section: https://reltech.substack.com/i/43043413/hardware-setup

Expand full comment