Linker Error on sprintf

Sysprogs forums Forums VisualGDB Linker Error on sprintf

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #804
    Anonymous
    Participant

    Does anybody know the Error Result: “VGDB1000: undefined reference to `_sbrk'”
    I get it when compiling code for a STM32F103VET6, i know the line which causes it:
    snippet:
    void displayMemory(uint8_t ant, uint8_t mem)
    {
    uint8_t tempstr[30];
    LCD_SetFGColor(MEM_COLOR);
    LCD_SetBGColor(BackLightColor);
    LCD_SetFont(&MEM_FONT);
    sprintf(tempstr,”# %d L= %d C= %d”,mem,Memory[ant][mem].L,Memory[ant][mem].C);
    LCD_DisplayStringLine(1,90,tempstr);
    }
    end snippet
    the sprintf causes the problem. It seems as if newlib does not implement the sprintf correctly.
    Has anybody a workaround for that behavior?

    #3104
    G40
    Participant
    #3105
    support
    Keymaster

    Hi,

    You can also check out our UART tutorial explaining how to fix a similar issue: http://visualgdb.com/tutorials/arm/stm32/uart/

    #3106
    sierra29
    Participant

    OK, thank you. Now i know why 😉
    This behavior was a little strange for me, because until now i used Keil uVision4 MDK ARM, where an printf to uart or sprintf to string was implemented.
    So I can create a workaround.
    Thank´s again….

    #3107
    osnwt
    Participant

    @sierra wrote:

    Does anybody know the Error Result: “VGDB1000: undefined reference to `_sbrk'”
    Has anybody a workaround for that behavior?

    You also may consider using the latest arm-none-eabi toolchain from launchpad.com which supports nano lib option (nno version of nwlib). It is usually ok for embedded projects and some projects which require such stubs can be linked just fine with nano lib.

    #3109
    sedwardstx
    Participant

    I recently ran into this exact same issue, and ultimately resolved it by pulling in the syscalls.c implementation from the STM32CubeF4 samples which are downloadable from the st.com site for your board. Below is the folder I found a suitable version of the implementations for my discovery board.

    C:stm32cubef4STM32Cube_FW_F4_V1.3.0ProjectsSTM32F429I-DiscoveryExamplesBSPTrueSTUDIO

    #3108
    support
    Keymaster

    Hi,

    Just FYI: our new GCC 4.9.1-based toolchain comes with standard syscall definitions declared as weak, so you can simply override the relevant ones with the STM32-specific implementations without having to modify the library.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.