Live data from Hacker News

Bare Metal STM32 Programming and a Quadcopters Awakening

timakro.de

41–50 of 58 posts

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#41
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…

FWIW, Atollic was bought by ST [0], that IDE is now free, including professional features [1].

[0] https://www.electronicsweekly.com/news/business/st-buys-2017...

[1] https://atollic.com/truestudio/

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#42
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…

Atollic TrueSTUDIO is completely free without limitations since ST bought it and it uses GCC and normal linker description files AFAIK.

My personal preference is to use VS Code with the GNU Arm Embedded Toolchain as well though.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#43
post #18
post #2

Little bit off topic, but if anyone is on the fence about STM32, I strongly suggest trying out STM32 Black pill 3.3V version ( https://wiki.stm32duino.com/images/5/52/Black_Pill_Schematic... ). It's an amazing board, Arduino-compatible, 72MHz, i/o, adc and pwm pins, uart and i2c. You can get it cheaper and just solder the header yourself. Even has a micro USB support. Truly remarkable board.

I'm not an expert wrt. the clocking of these boards, how does it achieve the 72MHz? In that datasheet it looks like the onboard crystal is just 8MHz. Does it use some kind of internal clock multiplier to achieve 72MHz? Would such a magnified 8MHz to 72MHz provide a good stable clock?

As mentioned it uses PLL. The chip boots using the internal 8MHz oscillator, and you can then enable the external crystal using code.

The clock configuration is actually a bit complex, you can see an example from the STM32CubeMX configuration code generator tool here: https://imgur.com/S9L6U37

HS means high-speed and is used for the system clock and peripherals, while LS is low-speed and is used for the real-time clock. Peripherals have limits, like the ADC clock is shown to be 36MHz, but the maximum is 14MHz. The tool is not complaining because the ADC was not enabled for that project. Otherwise I would have to change the ADC prescaler, which take values like 2, 4, 6 etc. Thus had I enabled the ADC, I would have been forced to use a prescaler of 6, making the ADC clock 12MHz, below maximum.

To get the maximum ADC frequency of 14Mhz, I would have to lower the system clock to 56Mhz.

Other peripherals, like USB, also has some strict limits.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#44

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…

Curious if anyone has experience with ChibiOS/HAL instead of the ST provided HAL.

http://www.chibios.org/dokuwiki/doku.php?id=chibios:product:...

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#45

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…

Yeah, the same kind of fake "we're Open Source" seems to happen with kickstarter projects fairly often too. eg DoBot. Grrr.

One place which has done it correctly though is Dorna:

https://www.dorna.ai

They kickstarted (successfully, shipping to their backers etc), now have an online store, and all of the files (both software + hardware designs) are downloadable for everyone. :)

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#46
I can't help but wonder whether quadcopters will be where governments finally legislate control over general computation. Having access to bare metal means nobody can stop inexpensive and socially-disruptive quadcopter applications. How many years before quadcopters join rats and pigeons as the scourge of urban life, always on the prowl for unguarded power outlets or perches on power lines?

Governments and/or corporations have control of the bottom layer of cell phones and TCP/IP networking. Not so for firmware and cryptography, though not for lack of trying.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#48

Thanks for sharing the article! I think it would make a good addition to my WeeklyRobotics[1] series. Would you mind if I reshare it there? [1] http://weeklyrobotics.com/

Nice series you got there, I just took a look and found some really interesting projects. I would be honored for my article to be featured there!

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#49

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…

*(uint32_t *)0x40021018 = 0x00000004; Actually that line is not ok. But for another reason. Without "volatile" in there, the compiler may reorder this access with others, or remove it, or combine it with others. None of that is good.

Thanks, I updated the post.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#50
post #48

Thanks for sharing the article! I think it would make a good addition to my WeeklyRobotics[1] series. Would you mind if I reshare it there? [1] http://weeklyrobotics.com/

Nice series you got there, I just took a look and found some really interesting projects. I would be honored for my article to be featured there!

I'm glad you found some interesting projects, it means I'm doing some things right!

I'll most probably feature your article in the issue coming out this Sunday or a week after.

Thanks!

Post reply on HN