PINE64
Article: Debug Rust on PineCone BL602 with VSCode and GDB - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: General (https://forum.pine64.org/forumdisplay.php?fid=1)
+--- Forum: General (https://forum.pine64.org/forumdisplay.php?fid=74)
+--- Thread: Article: Debug Rust on PineCone BL602 with VSCode and GDB (/showthread.php?tid=12499)



Article: Debug Rust on PineCone BL602 with VSCode and GDB - lupyuen - 12-14-2020

Here's how we build and debug Embedded Rust Firmware for PineCone BL602... With VSCode and GDB

Debug Rust on PineCone BL602 with VSCode and GDB


RE: Article: Debug Rust on PineCone BL602 with VSCode and GDB - barray - 12-14-2020

@lupyuen Thank you for your article (I got the notification via RSS), very excited to start playing with mine Smile

Some questions (if you don't mind):

1. Is the USB only for power? Does the device not allow for flashing via USB? I kind of hoped there would be a USB to serial flashing process.

2. How mature is the Rust library now? Is it functioning and if so, is it using binary blobs?

3. What is the compelling argument for using Rust over C for the stack?


RE: Article: Debug Rust on PineCone BL602 with VSCode and GDB - lupyuen - 12-14-2020

(12-14-2020, 08:42 AM)barray Wrote: 1. Is the USB only for power? Does the device not allow for flashing via USB? I kind of hoped there would be a USB to serial flashing process.

2. How mature is the Rust library now? Is it functioning and if so, is it using binary blobs?

3. What is the compelling argument for using Rust over C for the stack?

So glad to have you onboard PineCone and RISC-V! :-)

1.  The USB port is connected to PineCone's UART port. That's how we flash firmware over USB (and UART). Debugging is not supported over USB. More details here

The UART flashing protocol is non-standard, that's why I chose to use a JTAG Debugger instead. It just works better with Rust, GDB and VSCode. :-)

2.  Many features are still missing in the Rust libraries for BL602, e.g. I2C, SPI. Check the docs here

BLE and WiFi are still not supported in the Rust BL602 libraries. We need to reverse engineer the blobs then get them working with Rust. 

3.  About C vs Rust: Yep it's perfectly fine to use C! :-) I'll be porting Mynewt OS to PineCone, which is mostly C anyway.

Rust seems friendlier for folks who are new to embedded coding. But it can get unnecessarily complex.

I wrote about Rust because the Sipeed Community has ported it to BL602. And it has GDB config files that actually work for flashing and debugging PineCone. So we can adapt them for our C projects as well.


RE: Article: Debug Rust on PineCone BL602 with VSCode and GDB - barray - 12-14-2020

@lupyuen Thanks for the reply Smile

> Debugging is not supported over USB.

If it's two way serial, surely you could at least print some debug messages over the UART? Much better than nothing?

> BLE and WiFi are still not supported in the Rust BL602 libraries. We need to reverse engineer the blobs then get them working with Rust.

Ah yes, so you're in the same boat. Might be best to team up with the C guys for the stack and later port it to rust or something. Or bind the C stack to the Rust firmware...

> I'll be porting Mynewt OS to PineCone, which is mostly C anyway.

This is interesting... I was actually considering the possibility that this could end up being the processor for the PineTime watch down the road. I really think the PineTime could do with another core just to service the I/O and keep the whole thing responsive.


RE: Article: Debug Rust on PineCone BL602 with VSCode and GDB - lupyuen - 12-14-2020

(12-14-2020, 08:33 PM)barray Wrote: If it's two way serial, surely you could at least print some debug messages over the UART? Much better than nothing?

Yep the USB port works perfectly fine for printing debugging messages :-)

My idea of debugging is Breakpoints + Code Stepping + Variable Inspection.

Check out what a JTAG Debugger can do with PineCone and VSCode...

https://youtu.be/b9f2vxYahHY