[deprecated]First release of STM32F4 core

The official STMicroelectronics Arduino core
Post Reply
fpiSTM
Posts: 224
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

[deprecated]First release of STM32F4 core

Post by fpiSTM » Sat Apr 01, 2017 7:02 am

Hi Roger and all,

Repalced by viewtopic.php?f=48&t=2098

As you probably seen, I've released the Arduino_Core_STM32F4
https://github.com/stm32duino/Arduino_Core_STM32F4


It supports the Nucleo F429ZI.
All pins are available based on mbed pinmap feature.
PeripheralPins.c automatically generated from stm32cube mcu xml file. This avoid issue on pins definition.
Python script to generate it is available here:
https://github.com/fpistm/stm32_tools
This also saved memory compared to old implementation even if all pins are defined.
USB feature is available, I removed it from the static lib to save memory and it is disabled by default.
To enable, edit the boards.txt file then add '-DUSBCON' to enable the core and '-DUSBD_USE_HID_COMPOSITE' to enable HID (keyboard and mouse support)
CDC support should come soon ;)

It respect Arduino pin naming thanks the following pin functions defined in Arduino.h:
// Convert a digital pin number Dxx to a PinName Pxy
PinName digitalToPinName(uint32_t p)
// Convert an analog pin number Axx to a PinName Pxy
PinName analogToPinName(uint32_t p)
// Convert an analog pin number to a digital pin number
uint32_t analogToDigital(uint32_t p)
// Convert a PinName Pxy to a pin number
uint32_t pinNametoPinNumber(PinName p);

So in the sketch, use A0 or 0 with AnalogRead/Write is ok as use D0 or 0 with DigitalRead/Write.
Moreover, the piname (Pxy) could be used directly in the sketch thanks: AnalogRead(pinNametoPinNumber(PC7))

Some features still to be reworked: timers, SPI and I2C. (on going with fprwi6labs :) )

If you have any questions/remarks/proposal do not hesitate.
If you see any issue, please enter an issue on github. ;)

I will release the package soon. I'm waiting feedback and some rework.
Note: I will rework the other stm32 families with this new pin management in order to manage all pins and saved memory. ;)

BR
Last edited by fpiSTM on Thu May 18, 2017 6:41 am, edited 1 time in total.

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: First release of STM32F4 core

Post by danieleff » Sat Apr 01, 2017 9:05 am

Maybe the official core should be renamed from stm32duino to something else (stm32HALduino...), as it is confusing to have 2 projects with the same name for the same purpose.

Pin names and numbers should be interchangeable, the maple and F1 core already is like that. digitalRead(0) == digitalRead(D0) == digitalRead(PG9) (on 429ZI Nucleo). The popular bluepill does not have numbers, so using pinNametoPinNumber everywhere is not user friendly.

Why is USB code in variant?

It would be cool to have a .txt describing how to add a variant. (I mean I know how to do it, its just a drawn out process of finding files, what to put where, what to change etc... I may later try to do it for my 411RE)

(My personal pet peeve: Is there a possibility to merge the F1/L4/F4 ... repositories into one? The way I see it is they are very similar with some changes here and there. Now that the peripheral pins moved to (generated, very nice!) PeripheralPins.c, they will be even more similar.)

fpiSTM
Posts: 224
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: First release of STM32F4 core

Post by fpiSTM » Sat Apr 01, 2017 9:49 am

danieleff wrote:Maybe the official core should be renamed from stm32duino to something else (stm32HALduino...), as it is confusing to have 2 projects with the same name for the same purpose.
Probably. Only for F4 at this time but I hope it will be merge ;)
danieleff wrote: Pin names and numbers should be interchangeable, the maple and F1 core already is like that. digitalRead(0) == digitalRead(D0) == digitalRead(PG9) (on 429ZI Nucleo). The popular bluepill does not have numbers, so using pinNametoPinNumber everywhere is not user friendly.
In fact, Pxy is not numbered as before. Using directly Pxy is possible, it depends which one. Using this function will avoid issue.AFAIK Arduino manage pin number not pinname. Currently, I develop a variant for the F4, with A0-A15 and D0 to D80 so using pin name directly will raised mistake.
danieleff wrote:Why is USB code in variant?
Only the conf and desc are in variant. As it could be different.
danieleff wrote: It would be cool to have a .txt describing how to add a variant. (I mean I know how to do it, its just a drawn out process of finding files, what to put where, what to change etc... I may later try to do it for my 411RE)
You are right, I think to write a wiki about that.
danieleff wrote: (My personal pet peeve: Is there a possibility to merge the F1/L4/F4 ... repositories into one? The way I see it is they are very similar with some changes here and there. Now that the peripheral pins moved to (generated, very nice!) PeripheralPins.c, they will be even more similar.)
Probably, as main Arduino API and HAL are mainly common for each family (except for F1 as alternate function are not managed in the same way). I study possibility to get the CMSIS as a dependent package and kept only specific file for the device. But it still need to study how manage the cubefw for each family.

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: First release of STM32F4 core

Post by victor_pv » Sat Apr 01, 2017 2:52 pm

How hard would you think is to make a variant for the stm32f407? seems like there is plenty of those floating around in ebay and aliexpress.

User avatar
Rick Kimball
Posts: 1038
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: First release of STM32F4 core

Post by Rick Kimball » Sat Apr 01, 2017 3:44 pm

fpiSTM wrote:...
All pins are available based on mbed pinmap feature.
Yay! Nice job!
-rick

fpiSTM
Posts: 224
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: First release of STM32F4 core

Post by fpiSTM » Sat Apr 01, 2017 4:45 pm

victor_pv wrote:How hard would you think is to make a variant for the stm32f407? seems like there is plenty of those floating around in ebay and aliexpress.
It should be more simple with this implementation.
Hereafter, main steps to achieve this:
1/ create a variant for the board based on F407 (copy the current one ;)).
2/ Create the PeripheralPins.c thanks the genpinmap_arduino.py (available here https://github.com/fpistm/stm32_tools)
For example, for the STM32F407G-DISC1 board (old name STM32F4DISCOVERY) call:
python genpinmap_arduino.py DISCO_F407G "STM32F407V(E-G)Tx.xml"
3/ Edit the generated file to comment all unwanted pin depending of the board. Then updating variant.h and variant.cpp to define the hardware pin configuration (LED, button, SPI, I2C,...) , clock config,...
4/ Define the HAL config you want in the stm32f4xx_hal_conf.h
5/ Create the static lib by adding a new target in the Makefile (available her Arduino_Core_STM32F4/system/libstm32f4/build_gcc/)
6/ add the correct ld file in linker_scripts/gcc/. For f407 disco, you could find it in the CubeFwF4 (STM32Cube_FW_F4_V1.15.0\Projects\STM32F4-Discovery\Demonstrations\SW4STM32\STM32F4-DISCO\STM32F407VGTx_FLASH.ld)
7/ Finally add the new board to boards.txt
That's all folks (I hope :roll: )

I've already add a new variant for F4 functional in a half-day ;)
Rick Kimball wrote: Yay! Nice job!
Thanks ;)

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: First release of STM32F4 core

Post by danieleff » Sat Apr 01, 2017 4:54 pm

fpiSTM wrote:I've already add a new variant for F4 functional in a half-day ;)
Can you commit it to github?

fpiSTM
Posts: 224
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: First release of STM32F4 core

Post by fpiSTM » Sat Apr 01, 2017 7:14 pm

danieleff wrote:
fpiSTM wrote:I've already add a new variant for F4 functional in a half-day ;)
Can you commit it to github?
Currently not, some specific features are on going and require some dev/debug. I will commit it then ready.
It is not the F407 if that's you think. I took the F407 disco as an example to illustrate.

palmerr
Posts: 58
Joined: Tue Jan 31, 2017 6:21 am
Location: Melbourne, Australia

Re: First release of STM32F4 core

Post by palmerr » Wed Apr 05, 2017 7:09 am

Like a few others I've downloaded the new "Cube" F1 and F4 cores and am having a play.

So far, so good with a Maple Mini and the F1 core.

With the F4, I'm working up a new variant for my "Black F4VET6" board.

Everything is going fine with your instructions, but I'm caught with step 5/.

I've added a new target to the Makefile, but can't cause it to create the new static lib. Do I need to go over to my Linux box and cross compile (I've never tried a Make style build on my Win box) or have I missed an entry elsewhere to trigger the library compile?

Richard

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: First release of STM32F4 core

Post by danieleff » Wed Apr 05, 2017 7:13 am

Yes you will need to run make from command line in system/libstm32f4/build_gcc/ folder to compile step 5. It can be done in windows, but more straightforward in linux.

Post Reply