Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

newbie stuck..malloc won't compile

Help
Syd
2012-06-28
2013-03-06
  • Syd
    Syd
    2012-06-28

    Hi all,
         I have downloaded msp toolchain for SUSE linux 11 and have been able to compile my application only to find I did not have a stdlib. I downloaded latest stdlib source (less than 11 hours old) and tried to compile to create a stdlib to link to, but compilation of stdlib fails.

    I have the following error being reported when it gets to malloc.c:
    ./stdlib/malloc.c:42:5: error: lvalue required in asm statement
    ./stdlib/malloc.c:42:5: error: invalid lvalue in asm output 0
    This equates to the line in malloc.c:
    GET_HEAP_BOTTOM (heap_bottom);

    which in turn is defined as:
    #define GET_HEAP_BOTTOM(__x) __asm__ __volatile__ ("mov r1, %0": "=r" ((uint16_t)__x) :)

    I have Googled, but come up blank.

    This seems to happen for all of the recursive builds (make adds -msr20 -mc20 -md20 ….)

    I am a C programmer and have no idea about the architecture of the msp430 or indeed it's assembly code, so I can't figure what is wrong. Can anybody help?

    Thanks.

     
  • Peter A. Bigot
    Peter A. Bigot
    2012-06-28

    If by "downloaded msp toolchain for SUSE" you downloaded pre-built packages, there should be a corresponding msp430-libc package that you need.  If there isn't one, then the packaged versions are not complete and you need to talk to whoever provided them.

    If you built the toolchain from source, the instructions should have included a reference to the correct msp430-libc to use.  The recommended stable release is LTS-20120406; if you need 20-bit support for larger MSP430 MCUs, get the 20120627 development release.  Do not attempt to mix versions of the compiler/binutils/library/mcu components.

    If you are using LTS-20120406, you can find patches at https://sourceforge.net/projects/mspgcc/files/Patches/LTS/20120406/  which includes one to malloc that fixes a bug, and incidentally removes that macro.  Applying that patch should fix the problem.

     
  • Peter A. Bigot
    Peter A. Bigot
    2012-06-28

    Paying more attention, that you reference -msr20 means you're probably using the 4.7.x development series.

    Update to mspgcc-20120627 from https://sourceforge.net/projects/mspgcc/files/mspgcc/DEVEL-4.7.x/ and use the versions of all tools that are recommended by that bundle.

    I don't know where you found a recent msp430-libc release with that macro in it.  msp430-libc-20120627 doesn't have it since it was removed in May when the bug was fixed.

     
  • Syd
    Syd
    2012-07-01

    Packages were downloaded from a variety of sources (this could be part of the issue) whilst trying to get a working set of tools. I may have inadvertently mixed different revisions of code. The main set of code came from http://download.opensuse.org/repositories/home:/scalpel4k:/msp430/openSUSE_11.4/ although this does not appear to include a package including a pre built msp43-libc

    I downloaded some time ago a package msp430-libc-20120425.tar.bz2 from https://sourceforge.net/projects/mspgcc, then left the project alone for a while. I guess my biggest mistakes were a) leaving the project then coming back to it…. b) not ensuring I had the most recent source!

    I will slap my wrists accordingly and download the latest versions of all from sourceforge.

    Thanks for your help and sorry to have overlooked the bloomin' obvious.