Loading...
 
Skip to main content

System Workbench for STM32


Issue snprintf floats

The answer to this is, no it does not always work. I will continue this monologue.

I have used the solution from: http://www.openstm32.org/forumthread353#threadId354
It appears to be an incorrect _sbrk implementation

I have update the example project on bitbucket

_sbrk implementation

caddr_t _sbrk(int incr) {

extern char end asm("end");
extern char _min_heap_end asm("_min_heap_end");
static char *heap_end;
char *prev_heap_end;

if (heap_end == 0) {
heap_end = &end;
}

prev_heap_end = heap_end;
if (prev_heap_end + incr > &_min_heap_end) {
if (heap_end + incr > stack_ptr) {
errno = ENOMEM;
return (caddr_t) -1;
}
}
heap_end += incr;
return (caddr_t) prev_heap_end;

}



Update to linker file:

/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
PROVIDE ( _min_heap_end = . );
. = . + _Min_Stack_Size;
. = ALIGN(4);
} >RAM