trying out stm's core

The official STMicroelectronics Arduino core
Post Reply
ag123
Posts: 161
Joined: Thu Mar 07, 2019 6:15 am
Location: Singapore
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

trying out stm's core

Post by ag123 » Sat Apr 06, 2019 6:39 am

finally i decided to give STM's core a try, and as usual here comes the newbie stumbles. :lol:

However, instead of using the (easy way) board manager.
this is on linux.

2 levels deep
i cloned it from the git:
git clone https://github.com/stm32duino/Arduino_Core_STM32

i put that folder in /arduino-1.8.x/hardware folder. and initially i can't find the stm32duino core and board and got this:

Code: Select all

WARNING: Error loading hardware folder /opt5/opt/arduino-1.8.2/hardware/Arduino_Core_STM32
  No valid hardware definitions found in folder Arduino_Core_STM32.
and as it turns out the core needs to be 2 levels deep, so i make Arduino_Core_STM32/stm32 and move the files there.
ok so i found the core and boards :D

CMSIS
next stumble is when building the sketch i got an error that core_cm3.h is not found

and rather than use the module i did it the hard way again
git clone https://github.com/ARM-software/CMSIS_5

patch up platforms.txt so that it reference the correct include folders from CMSIS_5
build

Code: Select all

/opt5/opt/gcc-arm-none-eabi-6-2017-q1-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/ld:/opt5/opt/arduino-1.8.2/hardware/Arduino_Core_STM32/stm32/system/CMSIS/lib/gcc//libarm_cortexM3l_math.a: file format not recognized; treating as linker script
/opt5/opt/gcc-arm-none-eabi-6-2017-q1-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/ld:/opt5/opt/arduino-1.8.2/hardware/Arduino_Core_STM32/stm32/system/CMSIS/lib/gcc//libarm_cortexM3l_math.a:1: syntax error
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Generic STM32F1 series.
it rurns out that lib/gcc/libarm_cortexM3l_math.a are text files and the real libarm_cortexM3l_math.a is found in
https://github.com/ARM-software/CMSIS
hence clone it again and copy those libs into a separate folder. so i use CMSIS 5 includes but the CMSIS 4 gcc libs :?
well it works

at least it builds

Code: Select all

Build options changed, rebuilding all
Sketch uses 11184 bytes (8%) of program storage space. Maximum is 131072 bytes.
Global variables use 780 bytes (3%) of dynamic memory, leaving 19700 bytes for local variables. Maximum is 20480 bytes.
:D

ag123
Posts: 161
Joined: Thu Mar 07, 2019 6:15 am
Location: Singapore
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

Re: trying out stm's core

Post by ag123 » Sat Apr 06, 2019 6:42 am

next stumble
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);

}

void loop() {
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
}
note on blue pill the led is active low, i did get the led to turn on or off.
but - it didn't blink :o
whatever happen with delay()? it seemed it would take quite some effort to 'debug'. seem like the vector tab got messed up.
btw i'm using stm32duino bootloader

i changed the ld file, the flash address from 0x8000000 to 0x8002000, i guess that's why the led lits. but systick seemed to be messed up somewhere.
:lol:

ag123
Posts: 161
Joined: Thu Mar 07, 2019 6:15 am
Location: Singapore
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

Re: trying out stm's core

Post by ag123 » Sun Apr 07, 2019 5:47 am

adding the flags -DVECT_TAB_OFFSET=0x2000
did just that, now stm32duino boot loader + stm32duino official core + that blinky is happy blinking away :D
the hack in
boards .txt

Code: Select all

################################################################################
# Generic F1
GenF1.name=Generic STM32F1 series
GenF1.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} -DVECT_TAB_OFFSET=0x2000
and of course in the ld script

Code: Select all

MEMORY
{
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
FLASH (rx)      : ORIGIN = 0x8002000, LENGTH = LD_MAX_SIZE - 0x2000
}
adding that -DVECT_TAB_OFFSET=0x2000 made all that difference. the convenience of 'roger's bootloader' is simply too good, connect usb

Code: Select all

dfu-util -a 2 -RD sketch.ino.bin
:D

Post Reply