[SOLVED] Sloeber and float sprintf: doesn't work

Development environment specific, Arduino, Eclipse, VS2013,Em::Blocks etc
User avatar
Pito
Posts: 1734
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Sloeber and float sprintf: doesn't work

Post by Pito » Fri Dec 08, 2017 12:15 pm

Combiner recipe in platform.txt (it adds the {compiler.combine.flags} into the build):

Code: Select all

## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group {compiler.combine.flags} {object_files} "{build.path}/{archive_file}" -Wl,--end-group
While building you have to see the -u stuff (see below), otherwise the _sbrk and friends will not be linked in, and therefore the malloc() and friends will not work, and therefore the sprintf and friends will not work either..

Code: Select all

'Starting combiner'
"C:\Program_Files\sloeber\/arduinoPlugin/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -Os -Wl,--gc-sections -mcpu=cortex-m3 "-TC:/Users/xxx/MyCode/Arduino/hardware/Arduino_STM32/STM32RG1/STM32F1/variants/generic_stm32f103c/ld/bootloader_20.ld" "-Wl,-Map,C:\Users\xxx\MyCode\Sloeber\Test_sprintf/Release/Test_sprintf.map" "-LC:/Users/xxx/MyCode/Arduino/hardware/Arduino_STM32/STM32RG1/STM32F1/variants/generic_stm32f103c/ld" -o "C:\Users\xxx\MyCode\Sloeber\Test_sprintf/Release/Test_sprintf.elf" "-LC:\Users\xxx\MyCode\Sloeber\Test_sprintf/Release" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid    .\.ino.cpp.o   C:\Users\xxx\MyCode\Sloeber\Test_sprintf\Release\arduino.ar    C:/Users/xxx/MyCode/Sloeber/Test_sprintf/Release/arduino.ar  -Wl,--end-group
'Finished building: Test_sprintf.elf'
' '
I use Sloeber4.0 under Win7, works fine. These issues are not Eclipse or Sloeber related but an Arduino heritage..
Pukao Hats Cleaning Services Ltd.

luca_stm32
Posts: 23
Joined: Wed Apr 26, 2017 12:39 pm

Re: Sloeber and float sprintf: doesn't work

Post by luca_stm32 » Fri Dec 08, 2017 7:25 pm

Hi Pito.
Thanks for suggestions.
In file platform.txt that is under /home/luca/arduino/hardware/Arduino_STM32-master/STM32F1/platform.txt I added:

Code: Select all

name=STM32 Boards (STM32duino.com)
version=0.1.2

compiler.warning_flags=-w -DDEBUG_LEVEL=DEBUG_NONE
compiler.warning_flags.none=-w -DDEBUG_LEVEL=DEBUG_NONE
compiler.warning_flags.default=-DDEBUG_LEVEL=DEBUG_NONE
compiler.warning_flags.more=-Wall -DDEBUG_LEVEL=DEBUG_FAULT
compiler.warning_flags.all=-Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL
compiler.combine.flags=-u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
and

Code: Select all

## Combine gc-sections, archives, and objects
#recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group {object_files} "{build.path}/{archive_file}" -Wl,--end-group
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group {compiler.combine.flags} {object_files} "{build.path}/{archive_file}" -Wl,--end-group
I restarted soeber to load changes but in sloeber console I can't still see added directives:

Code: Select all

Starting combiner
"/home/luca/sloeber//arduinoPlugin/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -Og -Wl,--gc-sections -mcpu=cortex-m3 "-T/home/luca/arduino/hardware/Arduino_STM32-master/STM32F1/variants/generic_stm32f103c/ld/jtag_c8.ld" "-Wl,-Map,/home/luca/Documenti/sloeber-workspace/Sprintf_Test/Release/Sprintf_Test.map" "-L/home/luca/arduino/hardware/Arduino_STM32-master/STM32F1/variants/generic_stm32f103c/ld" -o "/home/luca/Documenti/sloeber-workspace/Sprintf_Test/Release/Sprintf_Test.elf" "-L/home/luca/Documenti/sloeber-workspace/Sprintf_Test/Release" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group    ./sloeber.ino.cpp.o    /home/luca/Documenti/sloeber-workspace/Sprintf_Test/Release/arduino.ar  -Wl,--end-group
/home/luca/sloeber/arduinoPlugin/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/armv7-m/libnosys.a(sbrk.o): In function `_sbrk':
sbrk.c:(.text._sbrk+0x30): warning: undefined reference to `end'
Finished building: Sprintf_Test.elf
I will investigate.
I'm using Soleber 4.2 and Linux 64 bit

Thanks again
Regards.
Luca.

victor_pv
Posts: 1860
Joined: Mon Apr 27, 2015 12:12 pm

Re: Sloeber and float sprintf: doesn't work

Post by victor_pv » Fri Dec 08, 2017 8:21 pm

In the project properties, change the board to something else, apply, and then back to the one you were using. That will reload all flags from platform.txt

Not sure if it reloads them by just closing and opening, I believe it doesn't.

I use sloeber 4.1 in a windows 10 and 4.0 in Win 8.1, both work fine.

stevestrong
Posts: 2051
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: Sloeber and float sprintf: doesn't work

Post by stevestrong » Fri Dec 08, 2017 8:46 pm

luca, which upload method do you use?
I think the linker file is not the right one. Instead of jtag_c8.ld it should be bootloader_20.ld.

luca_stm32
Posts: 23
Joined: Wed Apr 26, 2017 12:39 pm

Re: Sloeber and float sprintf: doesn't work

Post by luca_stm32 » Sat Dec 09, 2017 9:58 am

@Victor
I followed your instructions and now added directives are loaded correclty and sketch works as aspected also under Sloeber :D

@Steve
I use STLink programmer. I think jtag_c8.ld in this case is correct.

@Victor, Steve, Pito and Roger
Thanks again for your support :D

@Roger
Could be possible adding this directives in platform.txt by default? I tested this sketch with modified platform.txt and Arduino IDE and works, but I don't know if the added directives have some sort of collateral effect.
I belive I'm not the first one asking you this thing. I also know that under Arduino IDE STM32 core works correctly and core STM32 is intended for Arduino IDE.
Otherwise, is there another method to make it be "compatible" with eclipse IDE?
What I'm trying to tell is that if someone want to use STM32 core from repository and use Eclipse, functions like new(), sprintf... doesn't work and they don't know why.

Thanks again and compliments again for your work.

Regards.
Luca.

User avatar
Pito
Posts: 1734
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Sloeber and float sprintf: doesn't work

Post by Pito » Sat Dec 09, 2017 10:44 am

Not sure if it reloads them by just closing and opening, I believe it doesn't.
In Sloeber, in order to load new properties and settings, you have to go:

Project -> Properties -> Arduino -> Apply -> OK.
Pukao Hats Cleaning Services Ltd.

Post Reply