STM32L072KBU3

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

STM32L072KBU3

Post by stijn » Fri Jun 07, 2019 7:23 pm

Long-time MicroPython user but only on PC and pretty clueless to the microcontroller side of things. We have a fairly simple device running an ATtiny programmed in C which gets data from one UART, does some translation/command handling and forwards it to a second UART upon getting a hardware trigger, and vice-versa. Now this device gets upgraded and the new controller will be an STM32L072KBU3 apparently. I noticed the 'stm32' part so immediately thought of MicroPython. Some questions:
- the C code is fairly simple, would it be even worth doing this in MicroPython and is it going to be able to run uninterrupted for days/weeks at 921600 baud? (pun sort of intended, sub-question is whether this board+uPy would be fast enough to use polling or is it only going to run properly when interrupt-driven?)
- how do I figure out if this particular device can be supported? I.e. what aspects determine why it would/would not be?
- building firmware is a matter of starting from one of the board subdirectories in the stm32 directory, adjusting, make?
- firmware gets flashed using standard JTag tools and can be debugged (the C code I mean)?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: STM32L072KBU3

Post by jimmo » Fri Jun 07, 2019 9:55 pm

stijn wrote:
Fri Jun 07, 2019 7:23 pm
the C code is fairly simple, would it be even worth doing this in MicroPython and is it going to be able to run uninterrupted for days/weeks at 921600 baud? (pun sort of intended, sub-question is whether this board+uPy would be fast enough to use polling or is it only going to run properly when interrupt-driven?)
The L0 family are interesting in that they're very capable (speed and features) they just have tiny amounts of flash and RAM. I haven't checked your exact part number but the L072 tops out at 192kiB / 20kiB respectively.

(This is more than a micro:bit, so definitely capable of doing plenty of stuff).

The L0 family can also include USB (which the L072 does).

And it's stupidly low power, and has some neat low-power-mode peripherals. Really quite impressive.
stijn wrote:
Fri Jun 07, 2019 7:23 pm
- how do I figure out if this particular device can be supported? I.e. what aspects determine why it would/would not be?
Currently MicroPython supports the F0, L4, F4, F7, H7 families.

I have WIP support for the L0 which I am attempting to get merged. I haven't finished all the peripherals (e.g. DMA, etc) but the REPL works and it can do the regular stuff like toggle pins and I2C/SPI. It's pretty close to being done, I think the bigger question is whether the MicroPython project wants to take on the maintenance of another STM family.

One other consideration is that there's so little flash that there isn't room for an onboard filesystem. So either frozen modules or external spiflash will be required.
stijn wrote:
Fri Jun 07, 2019 7:23 pm
building firmware is a matter of starting from one of the board subdirectories in the stm32 directory, adjusting, make?
Yeah, once I added the L0 HAL & CMSIS drivers and updated a bunch of places in ports/stm32 for L0-specific things, and added a board definition, it looks like any other STM32 port.
stijn wrote:
Fri Jun 07, 2019 7:23 pm
- firmware gets flashed using standard JTag tools and can be debugged (the C code I mean)?
Yes, it's an STM32 so by far the easiest is to use SWD (basically ARM JTAG) via at ST-Link. But the 072 also has a built-in USB DFU bootloader :) So it's exactly the same as flashing a pyboard (just slower!).

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: STM32L072KBU3

Post by stijn » Sat Jun 08, 2019 10:39 am

Thanks for the elaborate reply. The USB is nice but I don't think there's room for that on the PCB and housing.. I get that there's enough boards already but it's ok if we'd use this and it doesn't make it into the mainline. Things like onboard filesystem etc are not of interest for us and we also don't have the resources to contribute a complete port: this is just one part of a large measurement system so we're jusy trying to figure out if it would be worth it spending some time on getting MicroPython running.
I have WIP support for the L0 which I am attempting to get merged
Didn't find this, do you have a link perhaps?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: STM32L072KBU3

Post by jimmo » Sat Jun 08, 2019 11:06 am

stijn wrote:
Sat Jun 08, 2019 10:39 am
Didn't find this, do you have a link perhaps?
https://github.com/jimmo/micropython/tree/stm32l0 & https://github.com/jimmo/stm32lib/tree/ ... 2+L4-1.8.1 I'm actively working on this so I hope to sort out the remaining issues quite soon.

Something to be aware of, your STM32L072KBU3 only has 128kiB of ROM (and 20kiB of RAM, but that's fine). There's no question that MicroPython can work on that (the minimal ports are down in the 70-80kiB range) for a proper STM32 port, you'll have to disable a bunch of stuff. (I'm targeting one that has 192kiB).

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: STM32L072KBU3

Post by stijn » Sat Jun 08, 2019 11:26 am

Ok thanks. Amount of memory should be the least of my concerns as we don't have a lot of requirements as wrt features (both language and std lib). I'm only getting the board ready in 2 to 3 weeks or so, but depending on other hardware I'm working on it might be even longer before I'll actually get the time to work on it. I'll let you know how it turns out by then.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: STM32L072KBU3

Post by jimmo » Sun Jul 07, 2019 6:31 am

The L0 support is now merged. There's an example board definition for the Nucleo L073.

Post Reply