STM32F2xx support in Chibios 3.0.3

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
ana_lazareva
Posts: 7
Joined: Mon Dec 07, 2015 11:11 am

STM32F2xx support in Chibios 3.0.3

Post by ana_lazareva »

Hi!

How to configure ChibiStudio to work with STM32F2?

What I have already done:
1. External Tools Configuration -> arguments for openocd.exe: -c "telnet_port 4444" -s "C:\ChibiStudio\tools\openocd\scripts" -f "interface/stlink-v2.cfg" -f "target/stm32f2x_stlink.cfg"
2. board.h:

/*
* MCU type as defined in the ST header.
*/
#define STM32F2XX

3. mcuconf.h: #define STM32F2xx_MCUCONF


But it does't work still.
Need help!)
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F2xx support in Chibios 3.0.3

Post by Giovanni »

Hi,

You need to start from an F407 project, the changes you made are OK however you should better describe the problem.

Also check:
- Maximum frequency, it is 120MHz for the F2, you need to set proper values in mcuconf.h.
- Board files, those are board-specific so you need to create new ones for your board.

Giovanni
ana_lazareva
Posts: 7
Joined: Mon Dec 07, 2015 11:11 am

Re: STM32F2xx support in Chibios 3.0.3

Post by ana_lazareva »

This is my output when I try to build project (RT-STM32F411RE-NUCLEO):

In file included from ../../../os/hal/include/hal.h:32:0,
from ../../../os/hal/src/hal.c:25:
../../../os/hal/ports/STM32/STM32F4xx/hal_lld.h:724:2: error: #error "Using a wrong mcuconf.h file, STM32F4xx_MCUCONF not defined"
Compiling st.c
Compiling hal_queues.c
make: *** [build/obj/hal.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ../../../os/hal/include/hal.h:32:0,
from ../../../os/hal/src/st.c:25:
../../../os/hal/ports/STM32/STM32F4xx/hal_lld.h:724:2: error: #error "Using a wrong mcuconf.h file, STM32F4xx_MCUCONF not defined"
In file included from ../../../os/hal/include/hal.h:32:0,
from ../../../os/hal/src/hal_queues.c:38:
../../../os/hal/ports/STM32/STM32F4xx/hal_lld.h:724:2: error: #error "Using a wrong mcuconf.h file, STM32F4xx_MCUCONF not defined"
make: *** [build/obj/st.o] Error 1
make: *** [build/obj/hal_queues.o] Error 1

13:21:31 Build Finished (took 6s.97ms)
ana_lazareva
Posts: 7
Joined: Mon Dec 07, 2015 11:11 am

Re: STM32F2xx support in Chibios 3.0.3

Post by ana_lazareva »

And this is my output when I try to build RT-STM32F407-DISCOVERY project

In file included from ../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:75:0,
from ../../../os/common/ports/ARMCMx/compilers/GCC/crt1.c:30:
../../../os/ext/CMSIS/ST/stm32f4xx.h:144:3: error: #error "Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)"
In file included from ../../../os/common/ports/ARMCMx/compilers/GCC/crt1.c:30:0:
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:77:21: warning: "__CORTEX_M" is not defined [-Wundef]
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:78:2: error: #error "CMSIS __CORTEX_M mismatch"
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:81:23: warning: "__FPU_PRESENT" is not defined [-Wundef]
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:82:2: error: #error "CMSIS __FPU_PRESENT mismatch"
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:85:29: warning: "__NVIC_PRIO_BITS" is not defined [-Wundef]
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:86:2: error: #error "CMSIS __NVIC_PRIO_BITS mismatch"
../../../os/common/ports/ARMCMx/compilers/GCC/crt1.c: In function '__core_init':
../../../os/common/ports/ARMCMx/compilers/GCC/crt1.c:44:5: warning: "__CORTEX_M" is not defined [-Wundef]
make: *** [build/obj/crt1.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:75:0,
from ../../../os/common/ports/ARMCMx/compilers/GCC/vectors.c:31:
../../../os/ext/CMSIS/ST/stm32f4xx.h:144:3: error: #error "Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)"
In file included from ../../../os/common/ports/ARMCMx/compilers/GCC/vectors.c:31:0:
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:77:21: warning: "__CORTEX_M" is not defined [-Wundef]
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:78:2: error: #error "CMSIS __CORTEX_M mismatch"
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:81:23: warning: "__FPU_PRESENT" is not defined [-Wundef]
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:82:2: error: #error "CMSIS __FPU_PRESENT mismatch"
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:85:29: warning: "__NVIC_PRIO_BITS" is not defined [-Wundef]
../../../os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h:86:2: error: #error "CMSIS __NVIC_PRIO_BITS mismatch"
make: *** [build/obj/vectors.o] Error 1
ana_lazareva
Posts: 7
Joined: Mon Dec 07, 2015 11:11 am

Re: STM32F2xx support in Chibios 3.0.3

Post by ana_lazareva »

Maybe I should change STM32F407xG.ld file, because memory setup is wrong there?

There is
MEMORY
{
flash : org = 0x08000000, len = 1M
ram0 : org = 0x20000000, len = 128k /* SRAM1 + SRAM2 */
ram1 : org = 0x20000000, len = 112k /* SRAM1 */
ram2 : org = 0x2001C000, len = 16k /* SRAM2 */
ram3 : org = 0x00000000, len = 0
ram4 : org = 0x10000000, len = 64k /* CCM SRAM */
ram5 : org = 0x40024000, len = 4k /* BCKP SRAM */
ram6 : org = 0x00000000, len = 0
ram7 : org = 0x00000000, len = 0
}

and I need (I just think so):

MEMORY
{
flash : org = 0x08000000, len = 256k
ram0 : org = 0x20000000, len = 128k
ram1 : org = 0x00000000, len = 0
ram2 : org = 0x00000000, len = 0
ram3 : org = 0x00000000, len = 0
ram4 : org = 0x00000000, len = 0
ram5 : org = 0x00000000, len = 0
ram6 : org = 0x00000000, len = 0
ram7 : org = 0x00000000, len = 0
}


And what about Makefile? Should I specify MCU?

There is: MCU = cortex-m4
I need: MCU = cortex-m3
ana_lazareva
Posts: 7
Joined: Mon Dec 07, 2015 11:11 am

Re: STM32F2xx support in Chibios 3.0.3

Post by ana_lazareva »

Maybe I should write board-scecific file here: os/ext/CMSIS/ST?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F2xx support in Chibios 3.0.3

Post by Giovanni »

Hi,

I will post a template application here tomorrow, I will not be able to test it because I don't have any F2 HW but it will compile.

Giovanni
ana_lazareva
Posts: 7
Joined: Mon Dec 07, 2015 11:11 am

Re: STM32F2xx support in Chibios 3.0.3

Post by ana_lazareva »

Ok, thanks!
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F2xx support in Chibios 3.0.3

Post by Giovanni »

Hi,

I added the demo to the repository as \demos\STM32\RT-STM32F207-DISCOVERY

You need to checkout the latest code from subversion: https://sourceforge.net/p/chibios/svn/HEAD/tree/trunk/

It compiles fine but I have not tested it on HW, it assumes an STM32F407-Discovery board with the MCU replaced by an STM32F207.

Giovanni
ana_lazareva
Posts: 7
Joined: Mon Dec 07, 2015 11:11 am

Re: STM32F2xx support in Chibios 3.0.3

Post by ana_lazareva »

Hi!

Thanks for the demo.

What I've done:

1. Added files: sym32f2xx.h, system_stm32f2xx.h and stm32f207xx.h to the \os\ext\CMSIS\ST directory.

2. Created directory \os\common\ports\ARMCMx\devices\STM32F2xx and added there file cmparams.h with right cortex model number.

After that my project builds well.

But now I have the other problem:
My project runs well, but when I try to debug I have this message in the Console tab:
WARNING! The target is already running. All changes GDB did to registers will be discarded! Waiting for target to halt.

Why?
Post Reply