User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Mon May 04, 2020 11:30 pm

Hi Raspberry Pi community!
Raspberry Pi doesn't have native ADC, DAC, CAN Bus controller and other low-level peripherals found in most modern microcontrollers(MCU), such as STM32, Arduino Due, Teensy dev board. Normally this issue is ensured through external modules added to Raspberry Pi board. These are I2C and SPI modules like MCP3008(ADC chip), MCP2515(CAN bus), MCP4725(DAC) and other boards.
Image
But if you use an MCU for these purposes you have multiple peripherals at the same time. However, the MCU requires the firmware development, flashing and communication protocol implementation. In this case the code running on the Raspberry computer and the embedded firmware are written separately. Debugging communication problems occur on two completely disparate platforms.
Image
It would be great if our programs running on Rpi can work with MCU's peripherals without firmware development and transferring messages (command) between the board and the computer. As if these peripherals were a part of Raspberry SoC.
Image

Fortunately, Raspberry developers have a tool for dealing with this!

The REMCU Lib provides a way to harness the power of a more powerful machine to run complex processing while using the microcontroller being used to collect data from sensors and execute desired outputs. The library lets your Linux user space programs give access to all peripherals of tethered MCU by remote execution of SDK driver code provided by vendors or 3rd parties.
Image
In essence the MCU’s peripherals become a part of Raspberry SoC like other Raspberry peripherals SPI, HDMI, USB etc.
No need to develop firmware, flash the chip and setup communication. You can just call the peripheral driver functions in C/C++ or Python applications.
Image

In this video, one has shown how to make that. There are basic examples of GPIO control as well as ADC and DAC conversion on STM32
https://youtu.be/JdBabbC5Prk

GitHub repo with examples: https://github.com/remotemcu/remcu_exam ... 32F103RCT6
The repository also has examples to work with the CAN bus controller of the chip.

There is available the REMCU Raspberry version for STM32F103 to download for now.
Would you be interested in the library version for other STM32 or some other MCU?

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Tue May 05, 2020 12:32 am

… using 1 dollar STM32 MCU
I'm a fan of the STM32, but your example board is not $1 but nearly $30.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Tue May 05, 2020 1:05 am

scruss wrote:
Tue May 05, 2020 12:32 am
… using 1 dollar STM32 MCU
I'm a fan of the STM32, but your example board is not $1 but nearly $30.
Thanks for your note!
The board in the video is just a device that was illustrative for filming. We can use other STM32F103 board inlcuding popular Blue Pill and board of its own manufacture.
Last edited by remcu on Tue May 05, 2020 1:15 am, edited 1 time in total.

trejan
Posts: 1685
Joined: Tue Jul 02, 2019 2:28 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Tue May 05, 2020 1:13 am

remcu wrote:
Tue May 05, 2020 1:05 am
The board in the video is just a device that was illustrative for filming. We can use other STM32 board inlcuding popular Blue Pill and STM32 board of its own manufacture.
A warning about the Blue Pill and other low cost boards. There are a lot of cloned and counterfeit STM32F103 chips now and they're being put onto those low cost boards then sold as STM32F103s. Some do actually have their own part number e.g CS32F103 etched the IC but not all of them do. The problem is that they're not exact copies and there are differences like clock speed and registers on some peripherals.

BTW you've got a typo for Benefits on the menu on remotemcu.com

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Tue May 05, 2020 1:52 am

trejan wrote:
Tue May 05, 2020 1:13 am
A warning about the Blue Pill and other low cost boards. There are a lot of cloned and counterfeit STM32F103 chips now and they're being put onto those low cost boards then sold as STM32F103s. Some do actually have their own part number e.g CS32F103 etched the IC but not all of them do. The problem is that they're not exact copies and there are differences like clock speed and registers on some peripherals.
You are right. The STM32 is one of the most cloned MCU. You need to watch when work with the chip. And if you faced a fake you should replace it or fix code for peripheral differences.
trejan wrote:
Tue May 05, 2020 1:13 am
BTW you've got a typo for Benefits on the menu on remotemcu.com
P.S. Thank you for your observations! :)

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Fri May 22, 2020 10:06 pm

Hi again,
We have announced the new version of REMCU Library for low-cost STM32F0 MCUs (@tweet) including a support one of the most cheapest ARM cortex microcontrollers. A STM32F30 chip costs less than 50 cents and have ADC, Timers, PWM modules, GPIO, I2C, SPI, UART and RTC.
As well as we have prepared examples to work with these MCUs https://github.com/remotemcu/remcu_exam ... M32F030-51

If anyone has any interesting ideas for the REMCU use with Raspberry and MCU, we'll try one!

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Fri May 22, 2020 11:12 pm

Is this project open source? Since Raspbian changes so often, I'd be wary of using something that's a binary library that will age out. I have so many ARM boards that support has gone away, and they're basically landfill.

I'm currently running MicroPython on a STM32F411 and it makes a very capable interface via a fast USB serial connection. The fact that you can storage and execute code from the board's flash via USB mass storage is quite fun too.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Sat May 23, 2020 2:06 pm

scruss wrote: Is this project open source? Since Raspbian changes so often, I'd be wary of using something that's a binary library that will age out. I have so many ARM boards that support has gone away, and they're basically landfill.
It is not an open source project for now. Our team plans to publish the source in GitHub at year-end. But I'm afraid the Covid situation in the world can possibly affect that. The REMCU library just depends on standard system libraries (libc, libm) and has no specific dependencies. This should make it more independent of Raspbian changes.
scruss wrote: I'm currently running MicroPython on a STM32F411 and it makes a very capable interface via a fast USB serial connection. The fact that you can storage and execute code from the board's flash via USB mass storage is quite fun too.
MicroPython is a great project and user-friendly shell. But it doesn't have a full support of MCU peripherals unlike peripherals drivers provided by vendors. In addition, the Micropython requires "256k of code space and 16k of RAM" at least, so it can not run on low-cost and even partially middle-cost MCU such as STM32F030, STM32F103, XMC1100(Infineon), SAMD20(Atmel/Microchip), LPC1100(NXP) etc.
I think these MCUs are a perfect and cheap replacement for high speciality MCPXXXX chips like MCP3008, MCP2515, MCP4725 that commonly used in Raspberry projects.

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Sat May 23, 2020 6:29 pm

remcu wrote:
Sat May 23, 2020 2:06 pm
It is not an open source project for now.
Okay, so it's less likely that I'll use it, but if it does the thing for other people, cool.
The REMCU library just depends on standard system libraries (libc, libm) and has no specific dependencies. This should make it more independent of Raspbian changes.
It should, but if you're talking GPIO via the GPIO sysfs, it's likely to go away soon. It would be nice if the GPIO chardev that replaces it had a bit more user documentation and functions.
MicroPython is a great project and user-friendly shell. But it doesn't have a full support of MCU peripherals unlike peripherals drivers provided by vendors.
Maybe so, but it does enough for me. And the deployment is way simpler than trying to develop directly on STM32, which always seems to need huge proprietary toolchains. Just drag the script to the emulated storage, and it runs. No ST-Link adapter in sight!
In addition, the Micropython requires "256k of code space and 16k of RAM" at least, so it can not run on low-cost and even partially middle-cost MCU such as …
But to deploy on those less expensive chips you need an ST-Link and probably many hours of configuration. Yes, they're cheap and provide peripherals the Raspberry Pi probably should've had from the start, but the cost per board for an M4 vs an M0 is not that much more.
I think these MCUs are a perfect and cheap replacement for high speciality MCPXXXX chips like MCP3008, MCP2515, MCP4725 that commonly used in Raspberry projects.
I absolutely agree with you, especially when you consider how expensive each of these chips can be and how little they can do. I mean, I've seen MCP3008 chips sold for the same price as a complete STM32F103C8T6 Blue Pill.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

blimpyway
Posts: 283
Joined: Mon Mar 19, 2018 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Sun May 24, 2020 9:05 am

This would be interesting if I could easily supply my own C code "modules" to be uploaded and executed on the target stm32.

For stuff which isn't included in standard STM32 library but I don't want to be passed through the pi - openocd - serial/swd loop.

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Mon May 25, 2020 1:45 pm

scruss wrote: It should, but if you're talking GPIO via the GPIO sysfs, it's likely to go away soon. It would be nice if the GPIO chardev that replaces it had a bit more user documentation and functions.
Thanks for your notice! I didn't know sysfs is deprecated. However the REMCU Lib doesn't use the sysfs and even GPIO dev. It interfaces with MCU with help of OpenOCD(http://openocd.org/) utility. OpenOCD runs a GDB server, then REMCU connects to the server using just a network interface.
scruss wrote: But to deploy on those less expensive chips you need an ST-Link and probably many hours of configuration
Oh no, an ST-Link programmer and difficult manual configuration don't require for that. No need flashing MCU. We provide the prepared Raspbian image that has examples, library, OpenOCD. Just flash the image on to your Rpi and plug MCU to Rpi by GPIO and a few wires. Run openocd utility... That's all, the configuration is done.
If you want to use the REMCU Lib on your own Raspbian system. Just install an Openocd

Code: Select all

sudo apt-get install openocd
Download REMCU archive for your MCU and extract it in Raspberry filesystem
plug MCU to Rpi and run openocd:

Code: Select all

openocd -f interface/raspberrypi-native.cfg -f target/stm32f0x.cfg
That's all, the configuration is done.

More information about Rpi connection with MCU using OpenOCD can be found here:
https://learn.adafruit.com/programming- ... spberry-pi
or
https://iosoft.blog/2019/01/28/raspberry-pi-openocd/
scruss wrote: Maybe so, but it does enough for me. And the deployment is way simpler than trying to develop directly on STM32, which always seems to need huge proprietary toolchains. Just drag the script to the emulated storage, and it runs. No ST-Link adapter in sight!
In our approach, you don't even have to drag the scripts to the chip. You can write regular Python scripts in Raspbian filesystem or other storage(USB flash, nfs, sshfs etc.). No ST-Link too :)

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Mon May 25, 2020 5:35 pm

remcu wrote:
Mon May 25, 2020 1:45 pm
…. However the REMCU Lib doesn't use the sysfs and even GPIO dev. It interfaces with MCU with help of OpenOCD(http://openocd.org/) utility. OpenOCD runs a GDB server, then REMCU connects to the server using just a network interface.
REMCU might not, but OpenOCD uses sysfs for GPIO: https://github.com/synthetos/PiOCD/wiki ... TAG-Dongle

Installing OpenOCD looks complex, and I don't want to run someone else's distro. An example that runs under stock Raspbian and works with a cheap Blue Pill STM32F103C8T6 / Black Pill STM32F103C8T6 would be lovely.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

blimpyway
Posts: 283
Joined: Mon Mar 19, 2018 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Mon May 25, 2020 7:09 pm

I had to look a couple days ago at openocd, It didn't seem that bad it installed quite easily on zero W with apt get install.. I followed this tutorial which is quite good: https://www.rototron.info/circuitpython ... -tutorial/

PS I didn't even compiled it, as described in tutorial I just used

Code: Select all

sudo apt install openocd

then proceeded with editing config files as in tutorial/video, for my cute nrf52840 dongle

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Mon May 25, 2020 9:28 pm

scruss wrote: REMCU might not, but OpenOCD uses sysfs for GPIO: https://github.com/synthetos/PiOCD/wiki ... TAG-Dongle
OpenOCD has some configurations and this conf:

Code: Select all

openocd -f interface/raspberrypi-native.cfg -f target/stm32f0x.cfg
Using the native registers.
You can use the sysfs with conf below:

Code: Select all

openocd -f interface/sysfsgpio-raspberrypi.cfg -f target/stm32f0x.cfg
scruss wrote:Installing OpenOCD looks complex,
Just one command:

Code: Select all

sudo apt install openocd
Or download from our own repo:

Code: Select all

git clone https://github.com/remotemcu/Raspbian_packages.git
This has the prebuild OpenOCD package and the scripts to easily run it.
scruss wrote:and I don't want to run someone else's distro
There is the HOWTO that talks about how to run the examples without flashing image. With your own Raspbian System.
If you have questions you can write here or open issue in the Github repo.
scruss wrote: An example that runs under stock Raspbian and works with a cheap Blue Pill STM32F103C8T6 / Black Pill STM32F103C8T6 would be lovely.
It is a great idea. We will add the example as soon as possible

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Mon May 25, 2020 9:30 pm

blimpyway wrote:
Sun May 24, 2020 9:05 am
For stuff which isn't included in standard STM32 library but I don't want to be passed through the pi - openocd - serial/swd loop.
It would be interesting what is this stuff? Could you provide examples.
I just guess the standard STM32 drivers have all necessary functions of which you can create lots more functions that you want.

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Sun May 31, 2020 11:30 am

scruss wrote:
Mon May 25, 2020 5:35 pm
An example that runs under stock Raspbian and works with a cheap Blue Pill STM32F103C8T6 / Black Pill STM32F103C8T6 would be lovely.
Hi,
We have added the STM32F103C8T6 Blue Pill examples in Github repo:
https://github.com/remotemcu/remcu_exam ... -Blue-Pill
I hope this gets you up and running Raspberry with STM32F103C8T6 Blue Pill board in no time.

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Sun May 31, 2020 6:51 pm

Thanks!

Does it really need a Raspberry Pi v1 board, though? And static IP? ಠ_ಠ We have avahi, so change the host name and then we could connect to remcu.local without fighting with IP address clashes.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Tue Jun 02, 2020 12:07 am

Thanks for your comment!
scruss wrote:
Sun May 31, 2020 6:51 pm
Does it really need a Raspberry Pi v1 board, though?
You can use other Raspberry boards too. We will publish detailed instructions for Pi 2, 3, 4 on our GitHub repo in the next couple of days.

scruss wrote:
Sun May 31, 2020 6:51 pm
And static IP? ಠ_ಠ We have avahi, so change the host name and then we could connect to remcu.local without fighting with IP address clashes.
It is a greate idea. We will fix it.

User avatar
remcu
Posts: 13
Joined: Sat Apr 25, 2020 1:18 pm

Re: REMCU Lib: lazy and cheap expansion of RPi hardware using 1 dollar STM32 MCU & few wires

Thu Jun 04, 2020 12:04 am

Hi again,
remcu wrote: You can use other Raspberry boards too. We will publish detailed instructions for Pi 2, 3, 4 on our GitHub repo in the next couple of days.
We have added the detailed instructions for RPi 2,3,4 in our GitHub repo:
https://github.com/remotemcu/remcu_exam ... ll#prepare
scruss wrote: We have avahi, so change the host name and then we could connect to remcu.local without fighting with IP address clashes.
Also the Avahi have been enabled in our Raspbian image so you can connect to remcu.local without static IP address. If you plug Raspberry Pi into laptop/PC directly without a DHCP service, the Rpi will has a static IP address 192.168.0.10 (255.255.255.0 mask and 192.168.0.1 gateway).

Return to “Automation, sensing and robotics”