Live data from Hacker News

Bare Metal STM32 Programming and a Quadcopters Awakening

timakro.de

31–40 of 58 posts

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#31
post #28
post #6

Keil has a completely free version of their compiler for STM32F0, STM32G0, and STM32L0 micros: https://www2.keil.com/stmicroelectronics-stm32/mdk

I cannot reccomend against Kiel, iar, and atollic enough. They are garbage ide's (can only do string based auto complete, no dark theme, very poor window management), yet still cost a small fortune if you want to go above 32KB of flash usage or whatever other the free versions do. They also have their version of a linker script which is even worse than normal linker scripts, and if you are forced to use their compile…

Yes, gcc and clang are overwhelmingly superior for all purposes.

Let me advise against growing dependent on IDEs. They make it easy to get started, but soon begin to hold you back. Vim, meanwhile, takes some practice, but it repays so much, year in and year out. I have never heard of anyone who learned and then abandoned it.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#32

Ok, this drives me nuts ARGH! Seriously? The STM32F103? Crazy (or should that be Craze) hobbyists using "blue pill" boards because they are cheap (and they are, like $3 on ebay) which use this bastard chip of the ST Cortex-M line and they say "gee, its a really simple circuit and since they sell for so cheap on ebay it should be a good idea to use this chip!" BZZZZZZT! ST Micro makes much better CPUs that would be id…

Do you want to carry a payload or fly in wind? otherwise, I strongly recommend the Crazyflie, it is a good product with a vibrant community. It has an STM32F405 with FPU that is surprisingly powerful - nontrivial math in the fast control loop is no problem.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#33

Hi, interesting article, but I would like to suggest you something. While it's OK to do bare metal just using the memory locations like you did: *(uint32_t *)0x40021018 = 0x00000004; after a few days, it will become tiresome to read and to remember all those addresses. I suggest you to use the header [0] that the ST provides for STM32F1, which is included in packages such as STMCubeF1 [1], STMCubeF0, etc. For instanc…

To be fair, the last paragraph of the post mentions CMSIS, which provides proper headers with register names at least.

The HAL is very complete, but a bit hard to read because it supports all the (sometimes very subtle, possibly even undocumented) variations in the STM32 feature blocks. These variations have accumulated over the years.

Edit: also, the STMCube tool is a great help for configuring the chips of that family. It can configure IO pins, function blocks, the sometimes insanely flexible clock tree, generate project skeletons, estimate power consumption, etc... it is actually quite useful.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#34

Ok, this drives me nuts ARGH! Seriously? The STM32F103? Crazy (or should that be Craze) hobbyists using "blue pill" boards because they are cheap (and they are, like $3 on ebay) which use this bastard chip of the ST Cortex-M line and they say "gee, its a really simple circuit and since they sell for so cheap on ebay it should be a good idea to use this chip!" BZZZZZZT! ST Micro makes much better CPUs that would be id…

Fair enough, my first idea was actually to use MicroPython. With a megabyte of Flash that would have been possible, but 64K is just not enough.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#35
post #32

Ok, this drives me nuts ARGH! Seriously? The STM32F103? Crazy (or should that be Craze) hobbyists using "blue pill" boards because they are cheap (and they are, like $3 on ebay) which use this bastard chip of the ST Cortex-M line and they say "gee, its a really simple circuit and since they sell for so cheap on ebay it should be a good idea to use this chip!" BZZZZZZT! ST Micro makes much better CPUs that would be id…

Do you want to carry a payload or fly in wind? otherwise, I strongly recommend the Crazyflie, it is a good product with a vibrant community. It has an STM32F405 with FPU that is surprisingly powerful - nontrivial math in the fast control loop is no problem.

I have three of them :-) And I would like something with just a bit more payload. In particular I have been fascinated by the papers on cooperative work by multiple quad copters when driven by a supervising computer vision system.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#36
post #34

Ok, this drives me nuts ARGH! Seriously? The STM32F103? Crazy (or should that be Craze) hobbyists using "blue pill" boards because they are cheap (and they are, like $3 on ebay) which use this bastard chip of the ST Cortex-M line and they say "gee, its a really simple circuit and since they sell for so cheap on ebay it should be a good idea to use this chip!" BZZZZZZT! ST Micro makes much better CPUs that would be id…

Fair enough, my first idea was actually to use MicroPython. With a megabyte of Flash that would have been possible, but 64K is just not enough.

A micropython based flight control system would be a really cool project.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#37
post #34

Earlier quoted context omitted.

Fair enough, my first idea was actually to use MicroPython. With a megabyte of Flash that would have been possible, but 64K is just not enough.

A micropython based flight control system would be a really cool project.

I think it's going to happen sooner that we'd expect, with the OpenPilot Revolution board being considered for a port: https://github.com/micropython/micropython/wiki/Boards-Summa...

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#38
post #34

Earlier quoted context omitted.

Fair enough, my first idea was actually to use MicroPython. With a megabyte of Flash that would have been possible, but 64K is just not enough.

A micropython based flight control system would be a really cool project.

hmm, watching your copter crash during Pythons garbage-collection cycle might be an issue....

Python != realtime, flight-control == hard real-time

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#39
post #28
post #6

Keil has a completely free version of their compiler for STM32F0, STM32G0, and STM32L0 micros: https://www2.keil.com/stmicroelectronics-stm32/mdk

I cannot reccomend against Kiel, iar, and atollic enough. They are garbage ide's (can only do string based auto complete, no dark theme, very poor window management), yet still cost a small fortune if you want to go above 32KB of flash usage or whatever other the free versions do. They also have their version of a linker script which is even worse than normal linker scripts, and if you are forced to use their compile…

Unfortunately, iffy IDEs are pretty common in the embedded world. I too dislike Keil's uVision IDE, but sometimes you need to take the bad with the good. At work I use Keil + MDK-Pro and now and again also use ETM trace for debugging really tricky problems. AFAIK armcc also produces higher performing binaries than arm gcc (but this probably irrelevant in a lot of use cases).

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#40
post #5

Looks like a nice write-up! ST actually sells an evaluation board for learning about drone control; it has a BTLE module, four small FETs, sensors for pressure and a 9-axis IMU, a 1S battery charging circuit, and source code for some example firmware on Github. Search for 'STEVAL-FCU001V1'. I've also seen a lot of cheap STM32-based FCU boards from the same places you'd get one of these 'blue pill' boards. These are v…

On-chip debugging with OpenOCD was actually one of the next things I wanted to try out with my drone. I need to get an ST-Link dongle because the drone doesn't have one on board. I'm not sure if JTAG will even work or if they connected a pin to some sensor or similar on the board. SWD will work for sure, I saw the two SWCLK and SWDIO connectors on the board.

If SWCLK and SWDIO signals are present, there are great chances that SWD will work. In any case, you can control with registers if you want to enable full JTAG, SWD, or nothing, and reuse those pins as you wish.

You can use JTAG probes that implement the CMSIS-DAP (also called DAPLink) protocol, so you get a probe that doesn't need any driver as is seen as an HID USB device. I ran through some problems when trying to use the ST-LINK/V2 with Linux, but that was some years ago and I don't know if things have changed since then.

CMSIS-DAP: https://os.mbed.com/handbook/CMSIS-DAP

Some probes: https://www.adafruit.com/product/2764

https://www.artekit.eu/products/debug/ak-cmsis-dap/

Post reply on HN