Forum: Mikrocontroller und Digitale Elektronik sscanf() mit -mfloat-abi=hard


von Felix (Gast)


Lesenswert?

Ich möchte ich einen string mithilfe von sscanf() auswerten. 
Gleichzeitig muss ich aber die FPU direkt nutzen. Leider führt diese 
Kombination dazu , dass der Linkvorang nicht durchführbar ist, da die 
newlib anscheinend nur als nicht FPU Variante vorhanden ist. Auch die 
Verwendung von siscanf() hilft nicht ...
1
    [cc] 22 total files to be compiled.
2
       [cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wall -ffunction-sections -g -O0 -c -DSTM32F407VG -DSTM32F4XX -DUSE_STDPERIPH_DRIVER -D__ASSEMBLY__ -D__FPU_USED - //habe die includes rausgeworfen
3
       [cc] Starting link
4
       [cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g -nostartfiles -Wl,-Map=fw_Target_Flash.map -O0 -Wl,--gc-sections -LC:\CooCox\CoIDE\configuration\ProgramData\fw_Target -Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\fw_Target/arm-gcc-link.ld -g -o fw_Target_Flash.elf ..\obj\common_data.o ..\obj\stm32f4xx_usart.o ..\obj\stm32f4xx_can.o ..\obj\epos.o ..\obj\drive.o ..\obj\startup_stm32f4xx.o ..\obj\main.o ..\obj\stm32f4xx_rcc.o ..\obj\printf.o ..\obj\can.o ..\obj\default_hardware.o ..\obj\odometry.o ..\obj\can_drive.o ..\obj\stm32f4xx_gpio.o ..\obj\stm32f4xx_flash.o ..\obj\system_stm32f4xx.o ..\obj\syscalls.o ..\obj\misc.o ..\obj\serial.o ..\obj\spline.o ..\obj\circular_buffer.o ..\obj\stm32f4xx_tim.o "-L..\..\..\..\..\..\..\..\..\..\..\Program Files (x86)\GNU Tools ARM Embedded\4.6 2012q2\arm-none-eabi\lib\armv7e-m\fpu" -lm
5
       [cc] ..\..\..\..\..\..\..\..\..\..\..\Program Files (x86)\GNU Tools ARM Embedded\4.6 2012q2\arm-none-eabi\lib\armv7e-m\fpu\libg.a(lib_a-impure.o):(.data._impure_ptr+0x0): multiple definition of `_impure_ptr'
6
       [cc] ..\obj\printf.o:(.data+0x428): first defined here
7
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(bpabi.o)
8
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(unwind-arm.o) does not
9
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(bpabi.o) does not
10
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(unwind-arm.o)
11
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(pr-support.o) does not
12
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(pr-support.o)
13
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(_divdi3.o) does not
14
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(_divdi3.o)
15
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(_udivdi3.o) does not
16
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(_udivdi3.o
17
       [cc] collect2: ld returned 1 exit status
18
       [cc] )

von Sam P. (Gast)


Lesenswert?

Die ABI ( https://de.wikipedia.org/wiki/Bin%C3%A4rschnittstelle ) 
bestimmt, wie dein Programm mit Bibliotheken kommuniziert. Etliche 
Compileroptionen verändern die ABI, so auch -mfloat-abi. Es ist also nur 
logisch, dass Funktionen, die unterschiedliche -mfloat-abi-Einstellungen 
benutzten, nicht miteinander reden können.

Die konsequente Lösung ist, dir eine newlib mit -mfloat-abi=hard zu 
bauen.

Was dich vermutlich jetzt erstmal weiterbringt ist -mfloat-abi=softfp. 
Damit nutzt GCC die FPU, kommuniziert aber mit anderen Funktionen als ob 
es keine FPU gäbe. Das ist natürlich weniger effizient als konsequente 
FPU-Nutzung, aber es läuft eben auch mit gemischtem FPU/soft-float code.

von Andy K. (notandy)


Lesenswert?

Wenn du mit dem gcc-frontend linkst, wird gegen libgcc gelinkt, die 
typischweise arithmetische Funktionionen implementiert die der Compiler 
nicht direkt durch Assembler ersetzt.

Deine Compilerchain sollte hardfloat unterstützen (multilib), du must 
dem linker aber sagen welche libgcc du denn haben willst (soft- oder 
hardfloat), offensichtlich verwendet sie softfloat Standardmäßig.

also -mfloat-abi=hard bei linken mit angeben.

Grüße,

Andy

von Felix (Gast)


Lesenswert?

"Die konsequente Lösung ist, dir eine newlib mit -mfloat-abi=hard zu
bauen."

wie mache ich das?

Die FPU soft zu nutzen würde ich nur sehr ungerne machen da ich die FPU 
viel nutze.

habe -mfloat-abi=hard mit angegeben, die Fehler bleiben bestehen:
1
[cc] Starting link
2
       [cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g -nostartfiles -Wl,-Map=fw_Target_Flash.map -O0 -Wl,--gc-sections -LC:\CooCox\CoIDE\configuration\ProgramData\fw_Target -Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\fw_Target/arm-gcc-link.ld -g -o fw_Target_Flash.elf ..\obj\common_data.o ..\obj\stm32f4xx_usart.o ..\obj\stm32f4xx_can.o ..\obj\epos.o ..\obj\drive.o ..\obj\startup_stm32f4xx.o ..\obj\main.o ..\obj\stm32f4xx_rcc.o ..\obj\printf.o ..\obj\can.o ..\obj\default_hardware.o ..\obj\odometry.o ..\obj\can_drive.o ..\obj\stm32f4xx_gpio.o ..\obj\stm32f4xx_flash.o ..\obj\system_stm32f4xx.o ..\obj\syscalls.o ..\obj\misc.o ..\obj\serial.o ..\obj\spline.o ..\obj\circular_buffer.o ..\obj\stm32f4xx_tim.o "-L..\..\..\..\..\..\..\..\..\..\..\Program Files (x86)\GNU Tools ARM Embedded\4.6 2012q2\arm-none-eabi\lib\armv7e-m\fpu" -lm
3
       [cc] ..\..\..\..\..\..\..\..\..\..\..\Program Files (x86)\GNU Tools ARM Embedded\4.6 2012q2\arm-none-eabi\lib\armv7e-m\fpu\libg.a(lib_a-impure.o):(.data._impure_ptr+0x0): multiple definition of `_impure_ptr'
4
       [cc] ..\obj\printf.o:(.data+0x428): first defined here
5
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(bpabi.o) does not
6
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(bpabi.o)
7
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(unwind-arm.o) does not
8
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(unwind-arm.o)
9
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(pr-support.o) does not
10
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(pr-support.o)
11
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(_divdi3.o) does not
12
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(_divdi3.o)
13
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(_udivdi3.o) does not
14
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7e-m\libgcc.a(_udivdi3.o
15
       [cc] )
16
       [cc] collect2: ld returned 1 exit status

von Andy K. (notandy)


Lesenswert?

Felix schrieb:
>
> habe -mfloat-abi=hard mit angegeben, die Fehler bleiben bestehen:
> [c][cc] Starting link
>        [cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g -nostartfiles
> -Wl,-Map=fw_Target_Flash.map -O0 -Wl,--gc-sections
> -LC:\CooCox\CoIDE\configuration\ProgramData\fw_Target
> -Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\fw_Target/arm-gcc-link.l d
> -g -o fw_Target_Flash.elf ..\obj\common_data.o ..\obj\stm32f4xx_usart.o
> ...

Achja?

von Felix (Gast)


Lesenswert?

Sry hatte den alten code nochmal gepostet...
1
 [cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g -nostartfiles -Wl,-Map=fw_Target_Flash.map -O0 -Wl,--gc-sections -mfloat-abi=hard -LC:\CooCox\CoIDE\configuration\ProgramData\fw_Target -Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\fw_Target/arm-gcc-link.ld -g -o fw_Target_Flash.elf ..\obj\common_data.o ..\obj\stm32f4xx_usart.o ..\obj\stm32f4xx_can.o ..\obj\epos.o ..\obj\drive.o ..\obj\startup_stm32f4xx.o ..\obj\main.o ..\obj\stm32f4xx_rcc.o ..\obj\printf.o ..\obj\can.o ..\obj\default_hardware.o ..\obj\odometry.o ..\obj\can_drive.o ..\obj\stm32f4xx_gpio.o ..\obj\stm32f4xx_flash.o ..\obj\system_stm32f4xx.o ..\obj\syscalls.o ..\obj\misc.o ..\obj\serial.o ..\obj\spline.o ..\obj\circular_buffer.o ..\obj\stm32f4xx_tim.o "-L..\..\..\..\..\..\..\..\..\..\..\Program Files (x86)\GNU Tools ARM Embedded\4.6 2012q2\arm-none-eabi\lib\armv7e-m\fpu" -lm
2
       [cc] ..\..\..\..\..\..\..\..\..\..\..\Program Files (x86)\GNU Tools ARM Embedded\4.6 2012q2\arm-none-eabi\lib\armv7e-m\fpu\libg.a(lib_a-impure.o):(.data._impure_ptr+0x0): multiple definition of `_impure_ptr'
3
       [cc] ..\obj\printf.o:(.data+0x428): first defined here
4
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(bpabi.o) does not
5
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(bpabi.o)
6
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(unwind-arm.o) does not
7
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(unwind-arm.o)
8
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(pr-support.o)
9
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(pr-support.o) does not
10
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(_divdi3.o) does not
11
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(_divdi3.o)
12
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: error: fw_Target_Flash.elf uses VFP register arguments, c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(_udivdi3.o) does not
13
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(_udivdi3.o
14
       [cc] )

von Andy K. (notandy)


Lesenswert?

Ok. Vermutlich fehlt gcc die fpu-version: -mfpu=fpv4-sp-d16 um die 
geeignete multilib zu finden.

mit
  arm-none-eabi-gcc -print-multi-lib
siehst du welche libs dein compiler hat.

von Felix (Gast)


Lesenswert?

OK Problem gelöst: Ich musste einfach selbst die libgcc.a und die 
libgcov.a aus dem lib\gcc\arm-none-eabi\4.6.2\armv7e-m\fpu Verzeichnis 
zum linker hinzuzufügen. Schade, dass das CoIDE nicht automatisch macht 
wenn man Hard FPU wählt.

von Andy K. (notandy)


Lesenswert?

Felix schrieb:
> OK Problem gelöst: Ich musste einfach selbst die libgcc.a und die
> libgcov.a aus dem lib\gcc\arm-none-eabi\4.6.2\armv7e-m\fpu Verzeichnis
> zum linker hinzuzufügen. Schade, dass das CoIDE nicht automatisch macht
> wenn man Hard FPU wählt.

Muss es auch nicht bei verwendung von gcc zum linken:
1
$ arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -print-libgcc-file-name                    
2
/opt/gcc-arm-embedded-bin/bin/../lib/gcc/arm-none-eabi/4.7.3/libgcc.a
3
$ arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -print-libgcc-file-name
4
/opt/gcc-arm-embedded-bin/bin/../lib/gcc/arm-none-eabi/4.7.3/armv7e-m/fpu/libgcc.a

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.