scanf for floats in Studio 6

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel build tools clearly support vprintf party, completely ignoring vscanf's point of view. This policy cannot be tolerated in today's reality.

More seriously adding this linker option with other means is several clicks away and still wasting time on that.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

added -Wl,-u,vfscanf in Miscellaneous: Other Linker Flags.

got this line in makefile:
"C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.0.65\AVRToolchain\bin\avr-g++.exe" -o Flexipilot.elf flexipilot.o -Wl,-s -Wl,-static -Wl,-Map="Flexipilot.map" -Wl,-u,vfprintf -Wl,--start-group -Wl,-lprintf_flt -Wl,-lscanf_flt -Wl,--end-group -Wl,--gc-sections -Wl,-u,vfscanf -mmcu=atmega2561

This error has appeared, unable to get rid of it:
G:\ATMEGA\AtmelStudio\Flexipilot\Release\Flexipilot.o(1,1): internal error: out of range error

certainly something stinks here. The project was working already on the target with new studio6, without mentioned option for sscanf parsing.

in studio4 it worked...
studio6, problem:
avr-g++ -mmcu=atmega2561 -Wl,-u,vfprintf -Wl,-u,vfscanf -lm -Wl,--gc-sections -ffunction-sections -fdata-sections -Wl,-static -s -Wl,-Map=FLEXIPILOT.map flexipilot.o -lc -lm -lprintf_flt -lscanf_flt -o FLEXIPILOT.elf
studio 4, ok:
avr-g++.exe -Wl,-s -Wl,-static -Wl,-Map="Flexipilot.map" -Wl,-u,vfprintf -Wl,--start-group -Wl,-lprintf_flt -Wl,-lscanf_flt -Wl,--end-group -Wl,--gc-sections -Wl,-u,vfscanf -mmcu=atmega2561 -ffunction-sections -fdata-sections

Optimization level -Os
common fields have been underlined

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You aren't linking with libm.a

Given that you are linking with float versions of the other libraries then to not link with the main library providing float arithmetic and library functions is probably not wise.

Your AS4 command line does include -lm

Personally I think it's a bit mad that Atmel don't always just link with -lm anyway. If nothing's being used from it then nothing happens. If something is then it guarantees the right version is used.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Teh funny part that in in v4 math functions are used often. I am investigating why it worked at all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I am investigating why it worked at all.

But you sid it worked in AS4 and in the AS4 command there is a -lm. I'm saying that's probably why it worked.

In the AS6 command there is no -lm and if I understand you correctly you are saying that's where it does not work. I'm saying the lack of -lm is the reason.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Personally I think it's a bit mad that Atmel don't always just link with -lm anyway. If nothing's being used from it then nothing happens. If something is then it guarantees the right version is used.

When I create a new project in AS6 -lm is always the default under the Toolchain->Linker->Libraries. Is this not happening with your AS6, or did I misunderstand. To me it seems that the OP may have disabled it.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Is this not happening with your AS6, or did I misunderstand.

It was added yonks and yonks ago, to AS5.1 I believe (haven't got access to the tracker at the moment). kbosak, please file a bug in the tracker here:

http://asf.atmel.com/bugzilla/en...

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I didn't used defaults, I was making a project then copied options fromm V4 to V6 by finding them among GUI.
It worked until I realised sscanf is gone. I have to confirm it.
FYI with options
-Wl,-lprintf_flt -Wl,-lscanf_flt -Wl,-lm -Wl,-lc
the problem is gone, but the error message (internal error BS) was really scary, has driven me away from thinking this is -lm issue.

What is clear is that GUI support for fdata-sections and vscanf option as in screenshots is missing. But this is rather feature request/GUI inconsistency rather than bug.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kbosak wrote:
What is clear is that GUI support for fdata-sections and vscanf option as in screenshots is missing. But this is rather feature request/GUI inconsistency rather than bug.

Oh good, while we're adding GUI options add one for -save-temps too. :)

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

larryvc wrote:

Oh good, while we're adding GUI options add one for -save-temps too. :)

Its already there , GNU C++ compiler/Misc

however -Wextra in warnings woudl be cool, too

In G++ options/Optimization
-fno-exceptions -fno-jump-tables -fno-threadsafe-statics
reduces code size

Linker options, --rodata-writable leads to:
"C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.0.65\AVRToolchain\bin\avr-g++.exe" -o Flexipilot.elf flexipilot.o -Wl,-s -Wl,-static -Wl,-Map="Flexipilot.map" -Wl,-u,vfprintf -Wl,--start-group -Wl,-lprintf_flt -Wl,-lscanf_flt -Wl,-lm -Wl,-lc -Wl,--end-group -Wl,--gc-sections -Wl,-u,vfscanf -rodata-writable -mmcu=atmega2561
avr-g++.exe(0,0): unrecognized option '-rodata-writable'

I have created 'trivial buglist' for all those.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kbosak wrote:

Its already there , GNU C++ compiler/Misc

however -Wextra in warnings woudl be cool, too


Thanks, I thought I saw it once but then couldn't find it again.

+1 -Wextra

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius