ARM cortex toolchain (gcc-7.1.0)

1. SET_UP OF THE .bash_profile (minimal version)

  1. PATH=${PATH}:/opt/local/bin
  2. PATH=${PATH}:/opt/local/sbin
  3. PATH=${PATH}:/opt/subversion/bin
  4. PATH=${PATH}:/usr/local/bin
  5. PATH=${PATH}:/usr/bin

  6. PATH_TOOLS_ROOT=/opt/uKOS
  7. PATH_TOOLS_GCC=${PATH_TOOLS_ROOT}
  8. PATH_GCC_CORTEX3=${PATH_TOOLS_GCC}/cross/gcc-7.1.0/arm
  9. PATH=${PATH}:${PATH_GCC_CORTEX3}/bin
  10. PATH=${PATH}:${PATH_GCC_CNATIVE}/bin

  11. export PATH_TOOLS_GCC
  12. export PATH_GCC_CORTEX3
  13. export PATH_GCC_CNATIVE

2. MODIFY THE CODE FRAME: t-arm-elf

Replace the code frame t_arm_elf (location: /opt/uKOS/Packages/gcc-7.1.0/gcc/config/arm/t_arm_elf, with the following description:

  1. MULTILIB_OPTIONS     = marm/mthumb
  2. MULTILIB_DIRNAMES    = arm thumb

  3. # Only we don't actually want any ARM libraries.  Or
  4. # vanilla thumb libraries.
  5. MULTILIB_EXCEPTIONS  = marm* mthumb

  6. # Build with any one of arm7tdmi, M3 or M4 support.
  7. MULTILIB_OPTIONS    += mcpu=arm7tdmi-s/mcpu=cortex-m3/mcpu=cortex-m4
  8. MULTILIB_DIRNAMES   += arm7tdmi-s cortex-m3 cortex-m4

  9. # These don't make any sense without thumb, because GCC likes to
  10. # tell you that you have to supply another commandline argument
  11. # rather than just setting it itself.
  12. MULTILIB_EXCEPTIONS += mcpu=arm7tdmi-s* mcpu=cortex-m3* mcpu=cortex-m4*

  13. # All this just to get mfloat-abi=hard mfpu=fpv4-sp-d16 only specified for the M4
  14. MULTILIB_OPTIONS    += mfloat-abi=hard mfpu=fpv4-sp-d16
  15. MULTILIB_DIRNAMES   += float-abi-hard fpuv4-sp-d16
  16. MULTILIB_EXCEPTIONS += mfloat* mthumb/mfloat*
  17. MULTILIB_EXCEPTIONS += mfpu* mthumb/mfpu*
  18. MULTILIB_EXCEPTIONS += mthumb/mcpu=cortex-m4/mfloat-abi=hard
  19. MULTILIB_EXCEPTIONS += mthumb/mcpu=cortex-m4/mfpu=fpv4-sp-d16
  20. MULTILIB_EXCEPTIONS += *arm7tdmi-s*mfloat-abi* *arm7tdmi-s*mfpu*
  21. MULTILIB_EXCEPTIONS += *cortex-m3*mfloat-abi* *cortex-m3*mfpu*
  22. EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o

3. THE MAIN TOOLCHAIN: ukos_arm_eabi.sh

  1. # For OSX == 10.10, the native compiler is LLVM
  2. # For OSX == 10.12, the native compiler is gcc-7.1.0
  3. # For Ubuntu, the native compiler is gcc

  4. case "$(uname)" in
  5.     "Darwin")
  6.         case "$OSTYPE" in
  7.             "darwin14")
  8.                 echo "Target OSX clang"
  9.                 export CC=clang
  10.                 ;;
  11.             "darwin15")
  12.                 echo "Target OSX gcc-7.1.0"
  13.                 export CC=${PATH_GCC_CNATIVE}/bin/gcc-7.1.0
  14.                 ;;
  15.          esac
  16.         ;;
  17.     "Linux")
  18.         echo "Target Linux"
  19.         ;;
  20. esac

  21. export TARGET=arm-none-eabi
  22. export MACHINE=arm
  23. export BIN_VER=2.28
  24. export GCC_VER=7.1.0
  25. export NLB_VER=2.5.0
  26. export GDB_VER=8.0.0

  27. export PACKS_GCC=${PATH_TOOLS_GCC}/Packages/gcc-${GCC_VER}
  28. export PACKS_BIN=${PATH_TOOLS_GCC}/Packages/binutils-${BIN_VER}
  29. export PACKS_NBL=${PATH_TOOLS_GCC}/Packages/newlib-${NLB_VER}
  30. export PACKS_GDB=${PATH_TOOLS_GCC}/Packages/gdb-${GDB_VER}
  31. export PATCH=${PATH_TOOLS_GCC}/Scripts/Patches
  32. export BUILD=${PATH_TOOLS_GCC}/builds/gcc-${GCC_VER}
  33. export CROSS=${PATH_TOOLS_GCC}/cross/gcc-${GCC_VER}
  34. export prefix=${CROSS}/${MACHINE}
  35. export executables=${prefix}/bin

  36. export BIN_CONFIG=“--enable-interwork"
  37. export GCC1_CONFIG="--enable-interwork --enable-languages=c,c++ --with-newlib \
  38.     --with-headers=${PACKS_NBL}/newlib/libc/include --with-system-zlib"
  39. export NLB_CONFIG="--enable-interwork --enable-newlib-io-long-long --enable-newlib-io-float"
  40. export GDB_CONFIG=“--enable-interwork"

  41. # Building the toolchain

  42. rm -rf ${BUILD}/${MACHINE}
  43. rm -rf ${CROSS}/${MACHINE}

  44. PATH_SCRIPTS="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  45. cd ${PACKS_GCC}
  46. ./contrib/download_prerequisites

  47. ${PATH_SCRIPTS}/_patch_cortex.sh
  48. ${PATH_SCRIPTS}/_build_binutils.sh
  49. ${PATH_SCRIPTS}/_build_gcc_pass1.sh
  50. ${PATH_SCRIPTS}/_build_newlib.sh
  51. ${PATH_SCRIPTS}/_build_gcc_pass2.sh
  52. ${PATH_SCRIPTS}/_build_gdb.sh

4. THE BINUTILS: _build_binutils.sh

  1. mkdir -p ${BUILD}/${MACHINE}/binutils-${BIN_VER}
  2. cd ${BUILD}/${MACHINE}/binutils-${BIN_VER}
  3. ${PACKS_BIN}/configure --target=${TARGET} --prefix=${prefix} --enable-multilib --disable-werror \
  4.     --disable-nls --disable-libssp \
  5. ${BIN_CONFIG} || { echo “Er c. binutils"; exit 1; }
  6. make -j 4     || { echo “Er b. binutils”; exit 1; }
  7. make install  || { echo “Er i. binutils”; exit 1; }
  8. make clean    || { echo “Er c. binutils”; exit 1; }

5. THE GCC PASS 1: _build_gcc_pass1.sh

  1. mkdir -p ${BUILD}/${MACHINE}/gcc-${GCC_VER}
  2. cd ${BUILD}/${MACHINE}/gcc-${GCC_VER}
  3. case "$(uname)" in
  4.     "Darwin")
  5.         CFLAGS="-O2 -fbracket-depth=1024 -pipe"
  6.         CXXFLAGS="-O2 -fbracket-depth=1024 -pipe"
  7.         ${PACKS_GCC}/configure --target=${TARGET} --includedir=/usr/include --prefix=${prefix} \
  8.             --enable-multilib --disable-werror --disable-nls --disable-libssp \
  9.             ${GCC1_CONFIG}                                                             || { echo “Er c. gcc P 1"; exit 1; }
  10.         make CXXFLAGS="-fbracket-depth=1024" all-gcc -j 4 || { echo “Er b. gcc P 1”; exit 1; }
  11.         make install-gcc                                                                 || { echo “Er i. gcc P 1”; exit 1; }
  12.         ;;
  13.     "Linux")
  14.         ${PACKS_GCC}/configure --target=${TARGET} --includedir=/usr/include --prefix=${prefix} \
  15.             --enable-multilib --disable-werror --disable-nls --disable-libssp \
  16.             ${GCC1_CONFIG} || { echo "Er c. gcc P 1"; exit 1; }
  17.         make all-gcc -j 4  || { echo "Er b. gcc P 1”; exit 1; }
  18.         make install-gcc   || { echo "Er i. gcc P 1”; exit 1; }
  19.         ;;
  20. esac

6. THE NEWLIB: _build_newlib.sh

  1. mkdir -p ${BUILD}/${MACHINE}/newlib-${NLB_VER}
  2. cd ${BUILD}/${MACHINE}/newlib-${NLB_VER}
  3. ${PACKS_NBL}/configure --target=${TARGET} --prefix=${prefix} --enable-multilib --disable-werror \
  4.     --disable-nls --disable-libssp \
  5. ${NLB_CONFIG} || { echo "Er c. newlib"; exit 1; }
  6. make -j 4     || { echo "Er b. newlib”; exit 1; }
  7. make install  || { echo "Er i. newlib”; exit 1; }
  8. make clean    || { echo "Er c. newlib”; exit 1; }

7. THE GCC PASS 2: _build_gcc_pass2.sh

  1. cd ${BUILD}/${MACHINE}/gcc-${GCC_VER}
  2. case "$(uname)" in
  3.     "Darwin")
  4.         make CXXFLAGS="-fbracket-depth=1024" -j 4 || { echo “Er b. gcc P 2”; exit 1; }
  5.         make install                                                         || { echo "Er i. gcc P 2”; exit 1; }
  6.         make clean                                || { echo "Er c. gcc P 2”; exit 1; }
  7.         ;;
  8.     "Linux")
  9.         make -j 4                                 || { echo "Er b. gcc P 2”; exit 1; }
  10.         make install                              || { echo "Er i. gcc P 2”; exit 1; }
  11.         make clean                                || { echo "Er c. gcc P 2”; exit 1; }
  12.         ;;
  13. esac

8. THE GDB: _build_gdb.sh

  1. mkdir -p ${BUILD}/${MACHINE}/gdb-${GDB_VER}
  2. cd ${BUILD}/${MACHINE}/gdb-${GDB_VER}
  3. ${PACKS_GDB}/configure --target=${TARGET} --prefix=${prefix} --enable-multilib --disable-werror \
  4.     --disable-nls --disable-libssp \
  5.     ${GDB_CONFIG} || { echo “Er c. gdb"; exit 1; }
  6. make -j 4         || { echo “Er b. gdb”; exit 1; }
  7. make install      || { echo “Er i. gdb”; exit 1; }
  8. make clean        || { echo “Er c. gdb”; exit 1; }


© Franzi Edo. 2015