Espruino on a STM32 L ARM Cortex-M3?

Posted on
  • Hi!
    I've just started to test out Espruino today, and it works great so far! Just built it for my STM32F4Discovery board, and it worked right out of the box! I probably want to test it soon on the official pico board too.

    Just wondering, if it would be possible to make Espruino work on a more power-efficient L variant of the controller used on the original board (STM32F103RCT6), and which chip would be most suitable.

    Probably the STM32L100RBT6 has not enough flash memory...
    Ultra-low-power 32-bit MCU ARM-based Cortex-M3, 128KB Flash, 10KB SRAM, 2KB EEPROM, LCD, USB, ADC, DAC

    Do you have any experiences with STM32 L series, and if there's really some strong benefit in terms of power consumption? In deep sleep mode the Espruino already draws very low amounts of power...

  • Mainly it's just a matter of getting it working with ST's slightly different API (they change it slightly for every model to keep you on your toes). The L1 version of the libs is in the repo already, but personally I haven't built for any of the l series yet.

    The real gotcha would be the USB if you care about that. Usually it's a total pain to get working.

  • Thank you Gordon! That's about what I thought... It's probably too early to get my hands on this right now, since I don't understand all the internals of Espruino yet. I'd like to hook up a LoRa Modem (RN2483) to the Espruino, and thought about using an L1 because of it's low power nature, but I'm not sure if it's worth the effort. In deep sleep the F1 is also only drawing very little power... and it might be good idea to measure things before trying to optimize too early.

    The smallest, already tested uC I've seen on that list is the STM32F100RBT6B:
    http://www.espruino.com/Other+Boards

    Maybe I make a board in KiCad using that chip soon. Just to try it out... It would be nice to use Espruino on such a LoRa node, and make it cheap and very power efficient.

    Out of curiosity, do you also use an LDO on your upcoming Puck.js board? It looks great by the way... I'm trying to learn more about electronics right now, and figured, if it wouldn't be better to use a buck/boost converter for such a low power device, like that one, which I've once already used in a project, and which has some kind of standby mode. I guess an LDO still draws less power in deep sleep mode than a buck/boost converter (there's no active switching). But actually, I don't have a clue about this. So yeah, probably I need to figure out all that hardware stuff before trying to move to another uC... ;)

  • This is a bit off topic, but I've found an interesting part with about the right properties! The TPS610986, a step-up converter with integrated load switch. After some digging, I think it comes down to finding a chip with low quiescent current Iq for for light loads, like the MCU in sleep mode. And low minimum supply voltage (to fully drain the battery), while having enough output current capability, to power the whole device... and high enough efficiency.

    I've found many other parts, that might be suitable, some with interesting energy harvesting features (among others: BQ25504, ADP5090, TPS65290, LTC3331) and some "normal" boost converters with low quiescent current (TPS61099x, LT1615, SC120, AS1323, maybe TPS61222 ). Also found this interesting approach of using an LDO in combination with a switch mode supply... but that seems not really practical.

    Maybe it would be more efficient and certainly easier to just hook up a battery directly, since the microcontroller will be fine with supply voltages down to 2 V or lower... But I think it's good to have a stable supply voltage, for other parts hooked up to the controller... - I do not really have experience with low power stuff at all. So any hints are appreciated :)

    As for STM32L, I've found that variant with enough flash/RAM for Espruino to hopefully work. I will probably give it a try...

    STM32L072xZ - Ultra-low-power ARM Cortex-M0+ MCU with 192 KB Flash, 20 KB RAM, 6 KB EEPROM, 32 MHz CPU, USB

  • I'd be a little wary of using the F100 - Espruino runs but there isn't a bunch of free space. If you want to do anything useful with the RN2483 then you could do with something bigger.

    I'd check up the LoRa module's power requirements - it could be it's way more than Espruino anyway :)

    Puck.js connects straight to the battery. The uC can run off something like 1.7-3.6v, so it's fine for a CR2032. The chip itself contains its own DC/DC regulator (I just have to fit an inductor/capacitor) so it can do that pretty efficiently as well.

  • I've corrected the post above, the STM32L072xZ has 192 KB Flash, and 20 KB RAM. (Oh, also finally found out that the main difference between the STM32L0 and F0 is: L0 == Cortex M0+ (2-stage pipline), F0 == Cortex M0 (3-stage pipline))

    I'd be a little wary of using the F100 - Espruino runs but there isn't a bunch of free
    space. If you want to do anything useful with the RN2483 then you could do with
    something bigger.

    Thank you for pointing that out! I should probably figure out how Espruino really works before trying to make it work on a new chip... ;) - I've figured that the user program, the JavaScript interpreter, and all the hardware specific peripheral code resides in the flash, and is executed from there. Stack with all the JavaScript variables is in the RAM.... But i really need to learn more, I think there's enough information around on the Espruino page about how you've made all this work. - I can't estimate yet what's possible with 192 KB Flash, and 20 KB RAM...

    (For LoRa applications, it normally just needs to sleep, speak to a sensor and the modem over UART (well, lots of command strings). And store log some values internally... so I think most programs should be fairly small.)

    I'd check up the LoRa module's power requirements - it could be it's
    way more than Espruino anyway :)

    Yes, it's certainly the most power hungry part. According to the RN2483 datasheet (page 7): At 3 V: typical TX supply current: ~15 - 40 mA / RX: ~14 mA / deep sleep: 1.8 uA. So I've figured that it should still be as power efficient as possible, since it only needs to send very rarely, maybe once an hour... and might collect data more often, without the need to wake up the modem.

    (Two colleagues and I work on an open hardware project to be used on the experimental and open thethingsnetwork.org. Still trying to decide whether to use Espruino, MicroPython or something homebrew... Beside the power issues, I'm a fan of Espruino, since people will have an easy time to figure out how to use the device and to work in the IDE is super direct and fun. JavaScript is more widespread, Espruino requires less memory than MicroPython and speed is not really important here...).

    Puck.js connects straight to the battery. The uC can run off something like 1.7-3.6v, so > it's fine for a CR2032. The chip itself contains its own DC/DC regulator (I just have to fit > an inductor/capacitor) so it can do that pretty efficiently as well.

    Oh, that's really interesting! But that's not possible on STM32 micros (?), since they don't include such power management features I think...

  • STM32s still have about that voltage range (2-3.6v I think?) - just no DC/DC converter. However it seems that for very low current draws they turn the DC/DC off - it's only when it's executing that they turn it on.

  • Yes the L0s should be fine with supply voltages from 3.6 V even down to 1.65 V. But the LoRa modem requires at least 2.1 V (according to the specs), and who knows what kind of add-on hardware people will plug in, so it's good to have a stable 3.3 V rail I think...

    To estimate memory usage, I could do a project with a normal Espruino board, and see how much flash and RAM a simple sensor LoRa node needs, and then decide whether the STM32L072xZ or similar would fit. I looked into the code a bit, and it's a really impressive system! Way beyond my current understanding, of JavaScript, interpreters and all that. So I guess, it's best to estimate by making examples first...

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Espruino on a STM32 L ARM Cortex-M3?

Posted by Avatar for rel @rel

Actions