Introducing the new Arduino core for STM32

fpiSTM
Thu May 18, 2017 6:34 am
Hi All,

I would like to introduce the new Arduino core for STM32:
https://github.com/stm32duino/Arduino_Core_STM32

A first package version is available through the Arduino IDE Boards manager by adding the following link to the “Additional Boards Managers URLs” field of the “Preferences” dialog:
https://github.com/stm32duino/BoardMana … index.json

It now support every STM32 families based on HAL (all version added to the repo) , some boards are already available:

  • F0: Nucleo F091RC, Nucleo F030R8
    F1: Nucleo F103RB
    F2: Nucleo F207ZG
    F3: Nucleo F303RE
    F4: Nucleo F429ZI, STM32F407G-DISC1
    F7: STM32F746G-DISCOVERY
    L0: Nucleo L053R8, Nucleo L432KC
    L4: Nucleo L476RG

BP and MM will come soon.

No more static libraries for the HAL. By modifying the stm32YYxx_hal_conf.h in the variant, it is possible to enable or disable HAL features.
CMSIS is no more include in the source, it a package dependency and use the one package by Arduino: CMSIS 4.5.0.
ARM gcc toolchain has been updated to 6-2017-q1-update version to support F7 family (cortex-m7) but for other families the 4.8.3-2014q1 version still valid.
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 thanks the Arduino_Tools package or the github repo:
https://github.com/stm32duino/Arduino_Tools
Pins capabilities are configurable through this file by commenting or not pin description.
USB feature is available and disabled by default. To enable it, use the menu “Tools->USB Interface”

Further features will be added. Do not hesitate to contribute or submit issues.
uSD with FatFs has been added and tested on F7.
USB Serial is ongoing (CDC).
Ethernet support based on LwIp will be added. added:
https://github.com/stm32duino/STM32Ethernet
https://github.com/stm32duino/LwIP

ADC features will be extended.

I will update the wiki in order to be inline with this new core and adding add a page on how to include a new variant (PeripheralPins.c generation, config,…).
Wiki:
https://github.com/stm32duino/wiki/wiki


caniggia
Thu May 18, 2017 11:37 am
Hi
If i add ‘-DUSBCON’ to .build.upload_flags in ‘boards.txt’,
i get this error:
AppData\Local\Arduino15\packages\STM32\hardware\stm32f1\2017.1.20\cores\arduino\main.cpp:54:2: error: 'USBDevice' was not declared in this scope

USBDevice.attach();

^

exit status 1
Error compiling for board BluePill F103C8.


caniggia
Thu May 18, 2017 12:01 pm
OK,
i’ve added ‘-USBCON’ instead of ‘-DUSBCON’ and now it compiles.

And if i add ‘Serial.begin()’ to the sketch i get USB virtual COM.


ChrisMicro
Thu May 18, 2017 1:56 pm
@ fpiSTM
very good :D Thank you.

I try the STM32F7 Discovery because I didn’t have the compiler before.

Here is my first test:

1. download the package by the board manager as described above
==> status message:
Index error: could not find referenced tool name=openocd version=0.10.0-arduino1-static packager=arduino-org
Index error: could not find referenced tool name=nrf5x-cl-tools version=9.3.1 packager=arduino-org
Index error: could not find referenced tool name=openocd version=0.10.0-arduino1-static packager=arduino-org
Index error: could not find referenced tool name=nrf5x-cl-tools version=9.3.1 packager=arduino-org
Index error: could not find referenced tool name=openocd version=0.10.0-arduino1-static packager=arduino-org
Index error: could not find referenced tool name=nrf5x-cl-tools version=9.3.1 packager=arduino-org

2. compiling the blink example and download by mass storage:
==> it is blinking, very good

3. compile and download the ” Arduino TFT Bitmap Logo example”
==> screen remains blank


fpiSTM
Thu May 18, 2017 2:48 pm
@caniggia
You are not working with the repo mention in this thread. You work with the stm32f1.

@ChrisMicro
1. for the download status it is not link to the STM32 package as it do not mention openocd not the nrf5x.
Probably, link to another json file you have used.

2. ;)

3. Right, nice shot :roll:
I need to update the SD lib to use the default one if the card slot used is on the shield (SPI) or use the other if we want use the onboard card slot.
FYI, currently the LCD is not managed. I will add the support later.


holla2040
Sat May 20, 2017 9:44 pm
on ubuntu 16.04 x64, arduino 1.8.1, I get this error when compiling blink,

fork/exec /home/holla/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++: no such file or directory
Error compiling for board BluePill F103C8

looks like the board manager isn’t downloading the compiler.

—–

update: I deleted my ~/.arduino15 directory and re-installed the tools using board manager and
https://github.com/stm32duino/BoardMana … index.json
then blink compiled fro BluePill F103CB, yay!


Rick Kimball
Fri Jun 09, 2017 9:35 pm
So is your goal to deprecate the F1 core at https://github.com/stm32duino/Arduino_Core_STM32F1 ?

fpiSTM
Fri Jun 09, 2017 9:53 pm
Yes, as the new repo take in account several remarks done on this implementation (code size, limited pins definition, static library,…).
All current open issues on F1 will be reported and corrected.
Is there any problem with that ?

Rick Kimball
Fri Jun 09, 2017 10:09 pm
This architecture seems much better than the previous setup. I’m all for moving forward. The only reason I stopped looking at the other one was because of the issue with the pin mapping. That seems all taken care of in this new port.

fpiSTM
Sat Jun 10, 2017 5:22 am
Yes this is one of the huge rework. Now all pins are available and I hope easily customizable thanks PeriperalPins.c (by comment/uncomment).
FYI, the new pins managements is fully inspired from mbed.

ChrisMicro
Sat Jun 10, 2017 8:11 am
Hi Together,

I just tried the repo with the SM32F746 discovery.
The SD-Card examples work, but the TFT examples did not.

In the STM32GENERIC repo the TFT examples are working including touch.


fpiSTM
Sat Jun 10, 2017 11:01 am
Hi Chris,

it is a known issue.
https://github.com/stm32duino/Arduino_C … 2/issues/2
I have to change the name of the modified SD library (SD.h) in order to use the default one through SPI (when you use th SD from the TFT shield).
And make some correction to the modified SD lib to be able to use the onboard SD with TFT shield (TFT lib pass the File opende by copy and in this implementation the copy reset the fp, so it read always from the beginning)

Note: the LCD from the F746 is not supported at this time


Rick Kimball
Sat Jun 10, 2017 3:06 pm
fpiSTM wrote:
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
Pins capabilities are configurable through this file by commenting or not pin description.

danieleff
Sun Jun 11, 2017 3:59 am
fpiSTM wrote:Hi Chris,

it is a known issue.
https://github.com/stm32duino/Arduino_C … 2/issues/2
I have to change the name of the modified SD library (SD.h) in order to use the default one through SPI (when you use th SD from the TFT shield).
And make some correction to the modified SD lib to be able to use the onboard SD with TFT shield (TFT lib pass the File opende by copy and in this implementation the copy reset the fp, so it read always from the beginning)

Note: the LCD from the F746 is not supported at this time


fpiSTM
Sun Jun 11, 2017 9:35 am
Rick Kimball wrote:
When you say it is using the mbed pinmap feature, do you mean the same structure?

fpiSTM
Sun Jun 11, 2017 3:07 pm
danieleff wrote:
But still, how to access the touch chip on I2C3(PH8/PH7)? It is commented out: https://github.com/stm32duino/Arduino_C … ins.c#L112
(Slightly unrelated, how to access non-first peripherals in general, SPI2, SPI3, I2C2, I2C3, UART2, …)

rmbult01
Sat Jun 17, 2017 12:23 pm
fpiSTM wrote:
PeripheralPins.c automatically generated from stm32cube mcu xml file. This avoid issue on pins definition.

fpiSTM
Sat Jun 17, 2017 8:33 pm
Hi, it seems this is the following file: STM32F446R(C-E)Tx.xml

The call command should be:
genpinmap_arduino.py NUCLEO_F446RE “STM32F446R(C-E)Tx.xml”

Xml file should be in <STM32CubeMX install dir>\db\mcu

The script expect to find the cubemx in default install dir:
if sys.platform.startswith('win32'):
#print ("Windows env")
cubemxdir = 'C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX\db\mcu'
cubemxdirIP = cubemxdir+"\\IP\\"
input_file_name = cubemxdir+"\\" + sys.argv[2] out_path = cur_dir+'\\Arduino\\_'+sys.argv[1] output_filename = out_path+"\\"+out_filename
else:
#print ("Linux env")
if sys.platform.startswith('linux'):
cubemxdir = os.getenv("HOME")+'/STM32CubeMX/db/mcu'
cubemxdirIP = cubemxdir+"/IP/"
input_file_name = cubemxdir+'/'+ sys.argv[2] out_path = cur_dir+'/Arduino/'+sys.argv[1] output_filename = out_path+'/'+out_filename


rmbult01
Sun Jun 18, 2017 10:03 am
I found it, thank you.

Since the utility did not support Mac OSX, I added support and created a pull request.

Regards,
Rob


fpiSTM
Tue Jun 20, 2017 6:38 am
Hi @rmbult01,

thanks I will add it.


ykciv
Thu May 10, 2018 6:00 am
I have a doubt…

What is the use of Arduino_Core_STM32-master since u already added the STM32 boards from boards manager???

I saw the Arduino_Core_STM32 has some libraries and cores for STM32. But how to add it to my arduino IDE?


fpiSTM
Thu May 10, 2018 6:27 am
Some users install the core thanks the board manager and update it when I release new version but some advanced users use the git repo in order to be on the master and get the last update without waiting an official release.
The libraries are available through the Library manager of Arduino IDE. Search “stm32duino”

ykciv
Thu May 10, 2018 6:43 am
Im using STM32F746NG board now but i cant find the official library for TFT or touch. Does the official core has Support for STM32F7?? If yes, How can i find and utilize it??

Thanks in advance.


ykciv
Thu May 10, 2018 7:22 am
I was using STM32GENERIC core before. It has support for TFT,LCD, GUI, Touch but it doesnt have support for EEPROM. But In official core EEPROM is working fine with STM32F7. Thanks.

If it has TFT and touch support it will be very useful.

Thanks.


fpiSTM
Thu May 10, 2018 8:38 am
The Touch and LTDC from the STM32Generic could be used with STM core, I’ve tested this end of 2017.
I will provide the updated examples in the STM32Examples library.

ykciv
Thu May 10, 2018 9:03 am
Thank u so much. Please share the examples.

ykciv
Fri May 11, 2018 4:39 am
Sorry for rushing up, Have u updated the library with graphics and touch??

fpiSTM
Fri May 11, 2018 4:51 am
No, I will see if I can do it today but I’ve lot of stuff to do and you’re not alone.
So be patient.

ykciv
Fri May 11, 2018 5:10 am
I think touch and GUI are independent libraries. Its compiling without a problem in official arduino core if we comment all the lines which uses TFT. I hope it will work if u provide the LTDC suppport in official arduino core.

I have tried to add LTDC as local library from STM32GENERIC but it needs lots of backup files and it throws more linker errors.


ykciv
Fri May 11, 2018 5:11 am
[fpiSTM – Fri May 11, 2018 4:51 am] –
No, I will see if I can do it today but I’ve lot of stuff to do and you’re not alone.
So be patient.

Ok. thanks.


robca
Sat Mar 02, 2019 12:44 am
I just installed the latest Arduino 1.8.8 on a computer and decided to try out the ST cores for my existing STM32 projects, and I have two questions:

  • Is the DFU upload available? In platform.txt I only see mass storage, St Link, Serial and Black Magic Probe (nice, depending on the board capabilities. But no DFU. I know DFU works for my board, since I can upload the hex file with DFUsedemo after converting the .hex file to .dfu, but would be nicer if I could do it from the IDE
  • I wanted to try our the CMSIS DSP library, and I see that it’s included in the distribution. How do I use the DSP library from the Arduino IDE? I could not find any documentation in the wiki? I’d be happy to help write some, if I could get a starting point

fpiSTM
Sat Mar 02, 2019 5:52 am
Hi Robca,
DFU should be available soon. Probably in the next release.
BennehBoy made a PR to add the support: https://github.com/stm32duino/Arduino_C … 2/pull/415
About CMSIS DSP, I never use it, I guess you have to include the proper header, probably the path should be added in the platform.txt:
https://github.com/stm32duino/Arduino_C … rm.txt#L65

compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.3.0.path}/CMSIS/Core/Include/" "-I{build.system.path}/Drivers/CMSIS/Device/ST/{build.series}/Include/" "-I{build.system.path}/Drivers/CMSIS/Device/ST/{build.series}/Source/Templates/gcc/"
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.3.0.path}/CMSIS/Lib/GCC/" -l{build.cmsis_lib_gcc}


robca
Sat Mar 02, 2019 11:46 pm
Thanks for the prompt reply.

I’ll wait patiently for the DFU option, I’m good at that ;) Not sure if it will use the HID option for F4 or native DFU, though. In the F4, the HID bootloader uses 16Kb of flash, even if it’s mitigated by the fact that the F4 has plenty of flash anyway compared to the F103 I used before

As soon as I have a moment I’ll try and play with one of the DSP libraries, and if I can make it work I’ll provide additional info. And, yes, I noticed that CMSIS 5.4.0 was already available, so I already copied that in my install… even if the DSP library has been unchanged in forever, and still at 1.5.2


Leave a Reply

Your email address will not be published. Required fields are marked *