#4504 closed defect (fixed)

RTEMS6 has incorrect code generation for stm32f4 bsp

Reported by: Andrei Chichak Owned by: Sebastian Huber <sebastian.huber@…>
Priority: normal Milestone:
Component: tool/gcc Version: 6
Severity: normal Keywords: gcc multilib stm32f4
Cc: Blocked By:
Blocking:

Description

I'm working with the master head targeting arm/stm32f4 for RTEMS 6.

I built the tools and RTEMS using:

mkdir -p rtems/6
export PREFIX=`pwd`/rtems/6
mkdir external
cd external
git clone git://git.rtems.org/rtems.git
git clone git://git.rtems.org/rtems-source-builder.git
cd rtems-source-builder/rtems
../source-builder/sb-set-builder --prefix=${PREFIX} --log=../b-rsb-toolchain-arm.log 6/rtems-arm
cd ../../rtems
./waf bsp_defaults --rtems-bsps=arm/stm32f4 > config.ini
./waf configure --prefix=${PREFIX}
./waf

This setup gives me code that faults when calling the memset() function from bsp_start_clear_bss(). The version of memset() being used in any of the compiled samples has the flags (from rtems-execinfo -O) of:

   | memset.c                          : -mcpu=arm7tdmi -marm -march=armv4t

whereas other functions in the executable have:

   | lseek.c                           : -mthumb -mcpu=cortex-m4 -march=armv7e-m

If I rebuild with

./waf bsp_defaults --rtems-bsps=arm/stm32f105rc > config.ini

then all of the functions are compiled with the correct architecture flags for a 105rc and the program can reach Init() when run on a 105rc chip.

 Common flags: 3
  | -mthumb -mcpu=cortex-m3 -march=armv7-m

If I configure for stm32f4 and change the config.ini file to use:

ABI_FLAGS = -mthumb -mcpu=cortex-m3

Then rtems-exeinfo shows that all functions are using the same common flags as the stm32f105rc bsp configuration. The generated code cannot be used on an stm32f407, but it does compile an executable with one consistent instruction set.

So, providing -mcpu=cortex-m4 in ABI_FLAGS triggers the use of the wrong version of functions from libgcc (I think).

Change History (1)

comment:1 Changed on Sep 14, 2021 at 5:53:28 AM by Sebastian Huber <sebastian.huber@…>

Owner: set to Sebastian Huber <sebastian.huber@…>
Resolution: fixed
Status: newclosed

In af722b7/rtems:

bsps/arm: Fix ABI flags for Cortex-M4

Close #4504.

Note: See TracTickets for help on using tickets.