Building Espruino on OSX? --Solved

Posted on
  • So, I have been trying to build Espruino on OSX and I am having an issue. When I build it native (for OSX) everything works fine. However, when I build it using the cross tools, I get one of a number of errors.

    I have tried 2 different versions of YAGARTO (4.6.2 and 4.7.2), Code Sourcery 2013.11-24 and GNU Arm tools 4.8.
    All of them give me a different problem.

    YAGARTO and Code Sourcery say:
    _sbrk is undefined at link time.
    YAGARTO also says _exit is undefined.
    The GNU Arm tools say that they cannot find crt0.o.

    I am thinking that I must be using tools that are too new.
    What version of tools are you using to build the arm binary?

  • It should build with most versions of GCC - but you need arm-none-eabi versions, not arm-linux, which is what I think you may be using?

  • mine are all arm-none-eabi, or at least that is what the name of the files say. For instance, I have arm-none-eabi-gcc-4.6.2, arm-none-eabi-gcc-4.7.2 and arm-none-eabi-gcc-4.8.1 in my path.

  • If I had the version used internally, I am sure this would work fine. According to these instructions , and based on the errors I am getting, there are some stubs needed to make this work.

    It is entirely possible that I don't have something configured correctly in my makefile, but I have attempted to follow all of the instructions on the tutorial for building the code. It works fine as a native osx build, but not cross.

    All of the gcc-arm-none-eabi versions I have tried from 4.6.2 to 4.8.1 don't work or at least not with the makefile that I have from github. I have added the GNU Arm Tools version 4.7.4 to my list of non-working versions at present.

    I can add these additional stubs and make it work, I am just wondering if I need to, or if this is an indication of a code/configuration problem. It should be noted that I have not altered the base code in any way yet. Straight from github it wont build on osx with those compilers or this makefile.

    Has anyone succeeded in building a version of the Espruino software as-is from github for their version 1.3 device?
    If so, what compiler and version did you use?

  • As an additional point of information, I added the following line to the section of the makefile inside else ifdef ESPRUINO_1V3 :

    LIBS+=-lnosys

    Then I switched to the GNU Arm Tools v4.8 compiler, and now it compiles without error. The resulting size of the bin file is: 228872.
    Anyone know if this is correct or why I need to do this?

  • As it turns out, adding -Wl,--gc-sections to the LDFLAGS, without -lnosys added to the libs, also eliminates the compiler errors. Plus, the size drops down to 214504. Unfortunately, flashing the resulting binary does not work, in either situation.

    Gordon,
    What command do I need to use to build a usable image for the Espruino 1.3 boards? I read somewhere that you need to merge the bootloader into the image or something?
    Also, I took a look at the build log with the automated builds of the binaries. It looks like there is some other option set that you are building, I see 2 sets of builds in the log and one of them seems to build the bootloader. Can you explain that for me, please?

  • OK. I finally figured out how everything has to work and I got a new version of the Espruino software on the v1.3 device from a compile on OSX.

    Here is what I did:
    1) Get the prebuild OSX GNU ARM Tools 4.8 from here: https://launchpad.net/gcc-arm-embedded. I updated my patch to place the binaries at the front, you could also update the makefile as described in other tutorials. How you do that is up to you.

    2) Install CoreUtils from macports or something. I issued the command sudo port install coreutils to get it. You will need it for 'gdu' to get the size of the resulting binary. 'du' on OSX does not have a '-b' option to get the size of a file in bytes. Installing coreutils will get you a binary named gdu that does have that option (the name was changed to not conflict with system binaries).

    3) The file named scripts/check_size.sh will need to be modified. Simply change du to gdu to get it working, then save the file.

    4) -Wl,--gc-sections: There is a variable named MACOSX in the Makefile. This variable is set to '1' if we are building on Darwin. One of the consequences is that -Wl,--gc-sections is not applied if we are cross compiling. This is the source of the problems when compiling on OSX. The spirit seems to be to detect if we are building native on OSX and do something special for it. To Fix this issue, do the following:
    remove:

    ifeq ($(shell uname),Darwin)
    MACOSX=1
    endif

    from the top and merge it with the ifndef located in the linux section so that it looks like this:

    else
    BOARD=LINUX
    LINUX=1
    USE_FILESYSTEM=1
    USB=1
    USE_GRAPHICS=1
    ifeq ($(shell uname),Darwin)
    MACOSX=1
    else
    USE_LCD_SDL=1
    # http libs need some tweaks before net can compile
    USE_NET=1
    endif
    endif

    Note that I moved USE_LCD_SDL into the else section above. Without it, native builds fail. It happens on OSX and I noticed that it happend on the build server. At least for me, that is because I don't have libSDL installed, but I probably wouldn't be using it when on my OSX box anyway.

    5) plug-in your board to the computer and find out the serial port name. I use the WebIDE for that, just hit refresh if it doesn't show up right away. Then update the Makefile and find the location that says something like:
    STM32LOADER_FLAGS+=-k -p /dev/ttyPortName

    I just search for the word STM32LOADER_FLAGS then replace the /dev/portname with the name of the port where your device is located. Mine was /dev/tty.usbmodemfa121.

    6) In the Espruino directory, issue the command ESPRUINO_1V3=1 Release=1 make to build the software for the Espruino boards. After the build completes, you should see something like this:

    LD espruino_1v52_espruino_1r3.elf
    GEN espruino_1v52_espruino_1r3.lst
    GEN espruino_1v52_espruino_1r3.bin
    bash scripts/check_size.sh espruino_1v51_espruino_1r3.bin
    PASS - size of 214504 is under 215040 bytes

    7) Now to flash your board, issue the following command at the command prompt: ESPRUINO_1V3=1 Release=1 make serialflash

    Your board will get updated and the next time you connect you will be running on new software.

  • Thanks for all the info... Yes, looks like the ifdef to make macos compile work with llvm broke the cross compile... I think I need to make a proper docs page on building - and sort the makefile.

    Also, not working on flashing is probably just because you were flashing to 0x08000000 not 0x08002800 like the Makefile would do...

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Building Espruino on OSX? --Solved

Posted by Avatar for cephdon @cephdon

Actions