Posts

Showing posts with the label rust

lnBMP : rp2040, Not forgotten

Image
  lnBMP : Lots of little issues tackled : - Preliminary FreeRTOS awareness through "mon fos M0|M3|M33' - Uart <->USB through DMA, that one was a pain - Configuration change to map the supported boards depending on the amount of RAM we have. But finally, here it is : lnBMP running on a RP2040 in a itsy bitsy case, and it works !

Rust + CH32V307 + ILI9341 : Small demo video

Image
The mandatory youtube-video-or-it-didnt-happen (This is the screen test for my power supply)

CH32V307 : Rust + I2C + Clang

Image
 I2C is still  a bit unstable but here we go : CH32V307+SSD1306 + rust + clang ! This is a pic of the simplerSSD1306 rust driver running on the CH32V307 + rnArduino NB: The code seems to be significantly larger than the exact same thing built for bluepill / Arm cortex m3 though. NB: Seems the rust target riscv32-imafc does not exist as of today. So no FPU with rust!

Reusing your C++ code in rust (embedded)

But why ? So you have some working code in c++ and you'd like to reuse in rust (libraries, hal,...) ? That's not uncommon, that code works and you may not want to spend times re-writing it for no gain (and also avoid double maintenance) Option 1 : Bindgen Bindgen is nice enough, give it a .h, it will generate automatically the rust bindings for it. But it comes with some annoying limitations : - It does not support virtual methods - The parameters are C/C++ types, not rust types, it feels awkard to use them. Example : func(usize , void *) vs func( data : &[u8]) - The generated functions are unsafe Option 2 ; Dual adaptation layer The idea here is to create : 1- A first shim layer that exports the C++ API as C api + a void *this parameter. 2- Run bindgen on this shim, that will create unsafe rust with c++ parameters. 3- Create proper rust code that is using that unsafe rust code The actual API is the one from the "proper code". It is *not...

Mixing C++ and Rust on a small embedded system

  This has been one of my pet project for some times now, mixing lnArduino  drivers ( hardwired to STM32F1 / GD32VF1 *AND* FreeRTOS) with  rust code. Why ? Because rust is fun :). There are a lot of gotchas, your mileage may varies, you may disagree with me. Below is the current status, in case it helps others.  I do not pretend to bring you the "truth"/"the right way to do it", this is just my journey so far. Building with cmake Corrosion  is a very nice project , that makes mixing Cargo based project and cmake project a breeze.  . Really no problem here. Interworking Calling C++ from rust and conversely is a bit hit & miss. The current setup i'm using is to use bindgen to generate a first layer of rust binding  AND THEN , on top of that, manually write  a very thin rust wrapper to get rid of the unsafe {}, have a cleaner API, and add the missing pieces. For example, bindgen cannot deal with pure virtual c++ function, so you have to add a int...