Archive for diciembre 2012

Ubuntu ARM toolchain compiles Stellaris USB examples correctly

22/12/2012

I managed to get the StellarisWare libraries and examples working without Sourcery Codebench. Based on these two articles:

The complete StellarisWare suite compiles without errors, and the examples I tried (including usb_dev_serial and usb_dev_mouse) work correctly. This is an improvement over summon-arm-toolchain, which compiled non-functional USB examples.

Instructions for Ubuntu 12.10:

  1. # Install toolchain
    sudo aptitude install gcc-arm-linux-gnueabi
    # Download and compile newlib (had trouble with the toolchain's libc and libm)
    wget ftp://sources.redhat.com/pub/newlib/newlib-1.18.0.tar.gz
    tar xzf newlib-1.18.0.tar.gz
    cd newlib-1.18.0/
    ./configure --target arm-linux-gnueabi --disable-newlib-supplied-syscalls
    make

    This makes the files libc.a and libm.a in the subdirectory arm-linux-gnueabi/newlib

  2. Unzip the StellarisWare files, and in the root directory edit makedefs. Search for the following settings and change them, replacing something with the directory where you unzipped newlib
    PREFIX=arm-linux-gnueabi
    LIBC=/something/newlib-1.18.0/arm-linux-gnueabi/newlib/libc.a
    LIBM=/something/newlib-1.18.0/arm-linux-gnueabi/newlib/libm.a

    Also change CFLAGS, adding the line with -fno-stack-protector, so it looks like this:

    CFLAGS=-mthumb             \
           ${CPU}              \
           ${FPU}              \
           -Os                 \
           -ffunction-sections \
           -fdata-sections     \
           -MD                 \
           -std=c99            \
           -Wall               \
           -pedantic           \
           -DPART_${PART}      \
           -fno-stack-protector \
           -c
  3. To compile everything, run make clean and make

USB Mouse example for Stellaris Launchpad

10/12/2012

With some help I got the USB Mouse example from the LM3S9D90 board working on the Stellaris Launchpad. It needed a few changes:

  • Replaced the linker script usb_dev_mouse.ld with one from the Launchpad examples. The only difference was the size and location of the FLASH and SRAM memory regions.
  • Added code to configure the USB pins at startup, as suggested by dellwoodbu.
  • Changed several lines in the Makefile:
    • PART=LM4F120H5QR
    • VARIANT=cm4f
    • Set ROOT to my StellarisWare directory as usual
    • Added a target for programming the board:
      .PHONY: download

      download: ${COMPILER}/usb_dev_mouse.bin
          lm4flash -v $<

    • Replaced all instances of «cm3» with «cm4f»
    • CFLAGSgcc=-DTARGET_IS_BLIZZARD_RA2

You can download the example project files. Remember to set ROOT in the Makefile to your StellarisWare directory.

Warning: it does not work when compiled with the Summon Arm Toolchain. It compiles without errors but the device fails to enumerate. It responds to descriptor requests with malformed USB packets (seen with Wireshark). Works fine if compiled with Sourcery Codebench, haven’t tried other toolchains.