Live data from Hacker News

Bare Metal STM32 Programming and a Quadcopters Awakening

timakro.de

11–20 of 58 posts

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#12
I have no idea about the load carrying capacity of the drone, but it would be an awfully cool project to add an ultrasound sensor(s) and write a program for flying it around randomly indoors without hitting walls. A fancy feature might be to solve a real-life maze by flying through it. Would such a thing be possible?

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#13
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 instance, instead of using the memory address directly, you could just do

    RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
so it's easier to remember what is what. STMCubeF1 is a big package, but you won't be using the API/drivers ST provides (such as HAL and LL), just the header. As I understand, the STM32 community kind of rejects this API as "bloated".

I have some examples here if you would like to take a look:

https://github.com/dbolgheroni/arm-makefile/blob/master/drv/...

Cheers,

[0] https://github.com/dbolgheroni/arm-makefile/blob/master/stm3... [1] https://www.st.com/en/embedded-software/stm32cubef1.html

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#15
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 ordered one from here, if anyone else is looking: https://www.aliexpress.com/item/STM32F103C8T6-ARM-STM32-Mini...

I can't vouch for the product or the seller, but for $2 shipped, the price is right.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#16
post #14

Just FYI, I don't recommend charging LiIon or LiPo batteries in parallel, as shown in one of the pictures. There's a greater risk of fire or just general damage to the capacity of the batteries.

For the small 1S batteries you can get this style of charger for $16 that will charge in parallel: https://www.amazon.com/Happymodel-Battery-Charger-Mobula7-Qu...

But for bigger batteries I recommend buying a charger that can handle 4 or more separate batteries at a time like the SkyRC Q200 or the Turnigy TQ4, or just do like me, charge each battery individually.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#17

STM32 chips are used on a lot of quadcopter flight controllers, often using open source firmware like Betaflight https://github.com/betaflight/betaflight/wiki

I am tracking this issue: https://github.com/betaflight/betaflight/issues/5516

I can't wait to see how a STM32H7 will perform on a quadcopter, and what it will allow for :)

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#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?

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#19
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 ideal for this application, they have things like on board DSP instructions in their floating point units, and can run at internal clock rates of 180 MHz with a megabyte of Flash and 384K of RAM, some of it very high performance (core coupled memory). These CPUs are no harder to put onto a PCB than the STM32F103 and they are so much more capable. And sure, they are $10 apiece instead of $1 apiece which is fine if you're making BILLIONS of these things, but a bespoke quadcopter?

Oh but its Open Source, cool, except I can't find the PCB files anywhere, if I could I could pull out that crap chip and put in a real CPU and have OSHPark make me a few. I did find the software repo : https://github.com/Crazepony and yeah, another budget quadcopter maker with a bunch of things they want to sell and an "open source" tag to try to get people to come and look. Fair enough, it made me look. It is sort of the 'freemium' hardware company model.

Sigh. I'd love something bigger than the Crazflie[1] which is like real open source (PCB and everything) and smaller than a DJI Phantom that I could play around with.

Re: Bare Metal STM32 Programming and a Quadcopters Awakening

#20
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?

The clock source is typically generated by a phase locked loop from the external crystal oscillator. There's a PLL multiplier and divider value that you can set obtain the desired frequency.

I think the MCU starts running at a low speed from an internal RC oscillator, and then setting up the high speed clock source happens early in the initialization code. This code can be generated by ST's STM32Cube software, which is useful as a reference implementation even if you don't use the generated code in your project.

Post reply on HN