This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Hard faults using sprintf() and float


Not sure what must be aligned and how. Could you please be more precise
? Here is a part of my linker script taken from Atmel's FreeRTOS demo:

    /* .bss section which is used for uninitialized data */
    .bss (NOLOAD) :
    {
        . = ALIGN(4);
        _sbss = . ;
        _szero = .;
        *(.bss .bss.*)
        *(COMMON)
        . = ALIGN(4);
        _ebss = . ;
        _ezero = .;
    } > ram

    /* stack section */
    .stack (NOLOAD):
    {
        . = ALIGN(8);
        _sstack = .;
        . = . + STACK_SIZE;
        . = ALIGN(8);
        _estack = .;
    } > ram

    /* heap section */
    .heap (NOLOAD):
    {
        . = ALIGN(8);
         _sheap = .;
        . = . + HEAP_SIZE;
        . = ALIGN(8);
        _eheap = .;
    } > ram

    . = ALIGN(4);
    _end = . ;
    _ram_end_ = ORIGIN(ram) + LENGTH(ram) -1 ;
}

I guess that printf/sprintf allocates dynamic memory. I provided
calloc_r(), alloc_r() etc in order to use the FreeRTOS memory allocation
but this doesn't seem to help out here. Therefore I would like to know
(a little) more about what must be provided in order to work newlib
smoothly with (Free)RTOS. Probably the info I found in the net is outdated.

BTW: Sometimes I get some weird formatted output as shown in the second
line of these three examples:

{"input":{"U":-1.955017e+01,"I":-4.877560e-04,"R":0.000000e+00},
{"input":{"U":-1.955017e+01,"I":-4.00    e-04,"R":0.000000e+00},

{"input":{"U":-1.956951e+01,"I":-4.856550e-04,"R":0.000000e+00},
{"input":{"U":-1.956951e+01,"I":-4.8  672e-04,"R":0.000000e+00},

{"input":{"U":-1.955017e+01,"I":-4.908266e-04,"R":0.000000e+00},
{"input":{"U":-3.00    e+01,"I":-4.959982e-04,"R":0.000000e+00},

Found this issue because the spaces between mantissa and exponent seem
to break the json parser in the python lib. Could this be related to a
probably memory misalignment or is this caused by something else ?

Regards,
Jochen



> Looks like you have a problem with misaligned loads. Check your MPU 
> configuration.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]