Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


Link error passing double variable to sqrt function

I’m using the STemWin_HelloWorld demo project for STM32746G-Discovery in STM32Cube_FW_F4_V1.8.0 as Template.
Modifying BASIC_HelloWorld.c with function sqrt.
Passing a number to function sqrt is OK.
Passing the name of a double variable to function sqrt gives the error:

09:56:41 **** Incremental Build of configuration Debug for project STM32746G_DISCOVERY ****
make all
‘Building file: D:/STM32Cube_FW_F7_V1.3.0/Projects/STM32746G-Discovery/Applications/STemWin/STemWin_HelloWorld/Src/BASIC_HelloWorld.c’
‘Invoking: MCU GCC Compiler’
D:\STM32Cube_FW_F7_V1.3.0\Projects\STM32746G-Discovery\Applications\STemWin\STemWin_HelloWorld\SW4STM32\STM32746G_DISCOVERY\Debug
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -DUSE_HAL_DRIVER -DSTM32F746xx -DUSE_STM32756G_DISCOVERY -I”D:/STM32Cube_FW_F7_V1.3.0/Projects/STM32746G-Discovery/Applications/STemWin/STemWin_HelloWorld/Inc” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/CMSIS/Device/ST/STM32F7xx/Include” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/CMSIS/Include” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/STM32F7xx_HAL_Driver/Inc” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/BSP/STM32746G-Discovery” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/BSP/Components/Common” -I”D:/STM32Cube_FW_F7_V1.3.0/Drivers/BSP/Components” -I”D:/STM32Cube_FW_F7_V1.3.0/Middlewares/ST/STemWin/inc” -I”D:/STM32Cube_FW_F7_V1.3.0/Utilities” -I”D:/STM32Cube_FW_F7_V1.3.0/Utilities/Fonts” -Os -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -MMD -MP -MF”Application/User/BASIC_HelloWorld.d” -MT”Application/User/BASIC_HelloWorld.o” -o “Application/User/BASIC_HelloWorld.o” “D:/STM32Cube_FW_F7_V1.3.0/Projects/STM32746G-Discovery/Applications/STemWin/STemWin_HelloWorld/Src/BASIC_HelloWorld.c”
‘Finished building: D:/STM32Cube_FW_F7_V1.3.0/Projects/STM32746G-Discovery/Applications/STemWin/STemWin_HelloWorld/Src/BASIC_HelloWorld.c’
’ ’
‘Building target: STM32746G_DISCOVERY.elf’
‘Invoking: MCU GCC Linker’
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -L”D:\STM32Cube_FW_F7_V1.3.0\Middlewares\ST\STemWin\Lib” -specs=nosys.specs -specs=nano.specs -T”../STM32F746NGHx_FLASH.ld” -Wl,-Map=output.map -Wl,--gc-sections -lm -o “STM32746G_DISCOVERY.elf” @”objects.list” -l:STemWin528_CM7_GCC.a
c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.7.0.201602121829/tools/compiler/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv7e-m/fpu/fpv5-sp-d16\libm.a(lib_a-w_sqrt.o): In function `sqrt’:
w_sqrt.c:(.text.sqrt+0x9e): undefined reference to `__errno’
w_sqrt.c:(.text.sqrt+0xa8): undefined reference to `__errno’
collect2.exe: error: ld returned 1 exit status
make: *** STM32746G_DISCOVERY.elf Error 1

09:56:42 Build Finished (took 891ms)

Using GNU Tools for ARM Embedded Processors 5.3 2016q1

Following the modified file BASIC_HelloWorld.c

/*********************************************************************

  • SEGGER MICROCONTROLLER SYSTEME GmbH *
  • Solutions for real time microcontroller applications *

**********************************************************************

**********************************************************************

          • emWin - Graphical user interface for embedded applications *****

emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
--------------------------
File  : BASIC_HelloWorld.c
Purpose  : Simple demo drawing “Hello world”
--------------------------

  • /

  1. include “GUI.h”
  2. include “math.h”


/*********************************************************************

  • Public code

**********************************************************************

  • /

/*********************************************************************

  • MainTask
  • /


double b = 25.0;


void MainTask(void) {
GUI_Clear();
GUI_SetFont(&GUI_Font20_1);
GUI_DispStringAt(“Hello world!\n”, (LCD_GetXSize()-100)/2, (LCD_GetYSize()-20)/2);



double a = sqrt(b); // link error with this

//double a = sqrt(25.0); // OK with this



GUI_DispFloat(a, 10);
while(1);
}

/*************************** End of file ****************************/

Please help using the sqrt function.

France

Hi,

I don’t think your problem has anything to do with the sqrt function.

You have obviously converted the project from C to C++ (as you are using collect2 in the link phase). This conversion has a small bug (that will be corrected soon) where link editor options set to the C project are not transfered to the C++ project (as the link editor is different).

You should add in project >> Properties >> C/C++ Build >> Settings >> MCU G++ Linker >> Miscellaneous in the appropriate text box the “-specs=nosys.specs -specs=nano.specs” settings that are provided in the C version of the project.

Alternatively you can also get the syscalls.c file from a System Workbench-generated project and place a copy in the source folder, near your main.c file

Bernard (Ac6)

Hi Bernard,
thank you for outstanding help.
The specs settings are already present but including syscalls.c solved the
problem.
Thank you very much, Adolf


Hi

I’m working on Linux and get the same linker error when math.h is included and a function of libmath is used.
Not all functions from libmath trigger the linker error but sqrt() in any case. I’m using plain C.

EDIT Like in this example the error was only triggered if the value of the argument was not known at compile time.

The IDE automatically sets Project->Properties->C/C++ Build->Settings->MCU GCC Linker->Libraries button “Use C math library (-lm) checked

My solution found elswere is:

Goto Project->Properties->C/C++ Build->Settings->MCU GCC Linker->Libraries and uncheck this button “Use C math library (-lm)
Then click on add and type “m”.
The explanation for this found elsewere shall be: the order of linking libc and libmath is is reversed with default setting.

Dieter


Hi

I think I have “kind of” the same error: I copied a project where i already solved the problem of the linker with the arm_math library. I was using the sqrt32 function in the previous project and I have trubble using the arm_rms_f32 function in the copied project...

The compiler sends :

make all
‘Building target: TestADC.elf’
‘Invoking: MCU GCC Linker’
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -specs=nosys.specs -specs=nano.specs -T”../STM32L476RGTx_FLASH.ld” -Wl,-Map=output.map -Wl,--gc-sections -o “TestADC.elf” @”objects.list” -lm
Src/Treatments.o: In function `RMSCalculation’:
C:\Users\SESA405282\Documents\STM32Cube\Project_STM32\TestADC\Debug/../Src/Treatments.c:64: undefined reference to `arm_rms_f32’
collect2.exe: error: ld returned 1 exit status
make: *** TestADC.elf Error 1

14:55:00 Build Finished (took 850ms)

I did uncheck the “Use C math library” I typed “m”...
I am almost sure that the problem comes from the copy but I cannot find the file that is causing me that much trubbles..

Thank you in advance

Jefferson