Installing Arduino_Core_STM32 git sources into Arduino IDE

The official STMicroelectronics Arduino core
troth
Posts: 4
Joined: Mon Jun 12, 2017 9:29 pm

Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by troth » Tue Jun 13, 2017 3:21 am

I have installed Arduino_Core_STM32 using the Board Manager successfully, but have found a bug in the SPI class. Before I submit a bug report or preferrable try to fix it myself, I want to clone the upstream repo into my sketchbook and build using that (since I see some SPI related fixes have been made since the 2017.6.2 release that I installed).

I uninstalled Arduino_Core_STM32 via the board manager (but that also uninstalled the necessary tool chain) and cloned the upstream repo into my sketchbook (in ${SKETCHBOOKDIR}/hardware/stm32). Started up the IDE (1.8.3) and it found the source, but complained about not finding the arm C++ compiler in /bin).

What's the best way to use the tools installed by the board manager for Arduino_Core_STM32, but use the source from the git repo (aka manually installed source)? Would be awesome if this was documented in the Arduino_Core_STM32 wiki under "Hacking Instructions" as that would have saved me the two+ hours I spent before posting this message. ;-)

zmemw16
Posts: 1449
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by zmemw16 » Tue Jun 13, 2017 4:21 am

http://wiki.stm32duino.com/index.php?title=Installation

specifically
Run the IDE, and on the Tools menu, select the Boards manager, and install the Arduino Due from the list of available boards. This installs compiler support for ARM Cortex-M3.
although i think the current suggestion is to install SAMD ( Cortex-M3 ) :?:
http://www.stm32duino.com/viewtopic.php ... amd#p28164

stephen

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

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by fpiSTM » Tue Jun 13, 2017 5:17 am

Hi,

You should install this one:
Arduino SAMD Boards (32-bits ARM Cortex-M0+)

it will install the cmsis and arm gcc toolchain 4.8.
But if you want use the F7 core you will need to install the updated arm gcc 6 for cortex M7

troth
Posts: 4
Joined: Mon Jun 12, 2017 9:29 pm

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by troth » Wed Jun 14, 2017 12:02 am

After installing Arduino SAMD Boards (32-bits ARM Cortex-M0+):

Code: Select all

WARNING: library SPI claims to run on (stm32) architecture(s) and may be incompatible with your current board which runs on (Arduino_Core_STM32) architecture(s).
Archiving built core (caching) in: /tmp/arduino_cache_752848/core/core_stm32_Arduino_Core_STM32_Nucleo_144_Nucleo_144_board_NUCLEO_F429ZI,upload_method_MassStorageMethod_c0d4b91288b1fc936faf44b4535cfccb.a
Sketch uses 21748 bytes (1%) of program storage space. Maximum is 2097152 bytes.
Global variables use 11032 bytes (4%) of dynamic memory, leaving 251112 bytes for local variables. Maximum is 262144 bytes.
[/size]

After installing SAM Boards (32-bits ARM Cortex-M3) for Due:

Code: Select all

In file included from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:159:0,
                 from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/cores/arduino/stm32/stm32_def.h:36,
                 from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/cores/arduino/stm32/hw_config.h:43,
                 from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/cores/arduino/chip.h:25,
                 from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/cores/arduino/Arduino.h:37,
                 from sketch/PowerStep01.ino.cpp:1:
/home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f429xx.h:192:81: fatal error: core_cm4.h: No such file or directory
 #include "core_cm4.h"             /* Cortex-M4 processor and core peripherals */
                                                                                 ^
compilation terminated.
exit status 1
Error compiling for board Nucleo-144.
[/size]

After installing Arduino STM32F4 Boards by Arduino version 1.0.1:

Code: Select all

In file included from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:159:0,
                 from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/cores/arduino/stm32/stm32_def.h:36,
                 from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/cores/arduino/stm32/hw_config.h:43,
                 from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/cores/arduino/chip.h:25,
                 from /home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/cores/arduino/Arduino.h:37,
                 from sketch/PowerStep01.ino.cpp:1:
/home/troth/git/Arduino/src/hardware/stm32/Arduino_Core_STM32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f429xx.h:192:81: fatal error: core_cm4.h: No such file or directory
 #include "core_cm4.h"             /* Cortex-M4 processor and core peripherals */
                                                                                 ^
compilation terminated.
exit status 1
Error compiling for board Nucleo-144.
[/size]

So, basically, all I want to do is install the STM32 Cores using the board manager and replace the installed sources with the files from the upstream git repo. Clearly the developers of the upstream git repo are doing this (or something similar). What are the developers doing? I really don't want to do hacks that install/use a different toolchain than what gets installed via the official board manager instructions since that is not testing/debugging with the exact same environment that a release uses.

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

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by Rick Kimball » Wed Jun 14, 2017 12:39 am

I installed the normal package using the board manager and then slammed it with a github checkout.

Sort of step by step

Code: Select all

$ cd ~/.arduino15/packages/STM32/hardware/stm32
$ ls
2017.6.2
# this is where the stuff is you want to replace
# however the platform file is different
# so copy the original to someplace
$ cp 2017.6.2/platform.txt /tmp
$ rm -rf 2017.6.2
$ git clone https://github.com/stm32duino/Arduino_Core_STM32.git 2017.6.2
$ diff /tmp/platform.txt 2017.6.2/ # just to see the difference
$ cp /tmp/platform.txt 2017.6.2/
-rick

troth
Posts: 4
Joined: Mon Jun 12, 2017 9:29 pm

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by troth » Wed Jun 14, 2017 2:06 am

Thanks Rick. That seemed to work. I had tried having both the git source and the original 2017.6.2 source dirs side by side, but that confused the IDE. Once I moved it down to a single dir, my example code built with the git sources.

While I had both dirs side by side, I fired up kdiff3 on them. It showed only 19 files had changed and that included the platform.txt file.

Now I can get busy looking into the bug I found in the SPI.transfer16() code...

User avatar
zoomx
Posts: 523
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by zoomx » Wed Jun 14, 2017 2:47 pm

I installed the SAM Boards (32-bits ARM Cortex-M3) for Due

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

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by fpiSTM » Wed Jun 14, 2017 10:21 pm

I have wrote a wiki page about this:
https://github.com/stm32duino/wiki/wiki ... repository
Hope this help

troth
Posts: 4
Joined: Mon Jun 12, 2017 9:29 pm

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by troth » Thu Jun 15, 2017 1:32 am

Thanks for adding the wiki page.

I just walked through the instructions. If you uninstall the BoardManager files, the steps for installing into <Arduino install directory>/hardware/ will not install a compiler so you get this error:

Code: Select all

fork/exec /bin/arm-none-eabi-g++: no such file or directory
Error compiling for board Nucleo-144.
[/size]

Additionally, you would need to get the CMSIS files installed.

On my system, it looks like the board manager is installing the CMSIS files in ~/.arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/core_cm4.h and the gcc toolchain is installed into ~/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q1-update

So, it sounds like there are a few more steps needed in the instructions if you want to install everything without the board manager.

I suspect (wild educated guess on my part) that once you have everything working under <Arduino install directory>/hardware/ you could do the same thing under the <sketchbook>/hardware/ directory.

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

Re: Installing Arduino_Core_STM32 git sources into Arduino IDE

Post by fpiSTM » Thu Jun 15, 2017 5:11 am

troth wrote: I just walked through the instructions. If you uninstall the BoardManager files, the steps for installing into <Arduino install directory>/hardware/ will not install a compiler so you get this error:

Code: Select all

fork/exec /bin/arm-none-eabi-g++: no such file or directory
Error compiling for board Nucleo-144.
[/size]

Additionally, you would need to get the CMSIS files installed.
Yes that's why I told to install the package in order to have those dependencies.
If you do not want install the package, you can install the compiler and cmsis manually but you will have to update also the path in platform.txt.

Code: Select all

compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
and

Code: Select all

compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/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-4.5.0.path}/CMSIS/Lib/GCC/" -l{build.cmsis_lib_gcc}
Installing the package allow to define the

Code: Select all

runtime.tools.CMSIS-4.5.0.path
and

Code: Select all

runtime.tools.arm-none-eabi-gcc.path
That's why installing the Zero board package is another option as it will install CMSIS and arm gcc. But the gcc installed is 4.8.3 and do not support m7.
troth wrote: On my system, it looks like the board manager is installing the CMSIS files in ~/.arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/core_cm4.h and the gcc toolchain is installed into ~/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q1-update

So, it sounds like there are a few more steps needed in the instructions if you want to install everything without the board manager.

I suspect (wild educated guess on my part) that once you have everything working under <Arduino install directory>/hardware/ you could do the same thing under the <sketchbook>/hardware/ directory.
There is a lot way to use a repo with Arduino. I've described only 2 one.

Post Reply