Get some basic Teensy code working
It prints some stuff over the USB serial port and turns the on-board LED
on. Also tweak some of the existing code so it works with better
compiler options for what we're doing.
Change-Id: Ifcbd36f9eaca47a86f7a97e8c458c64f9b3df3ab
diff --git a/tools/cpp/CROSSTOOL b/tools/cpp/CROSSTOOL
index 5a374af..7e6efdb 100644
--- a/tools/cpp/CROSSTOOL
+++ b/tools/cpp/CROSSTOOL
@@ -22,6 +22,11 @@
toolchain_identifier: "clang_linux_armhf"
}
+default_toolchain {
+ cpu: "cortex-m4f"
+ toolchain_identifier: "cortex-m4f"
+}
+
toolchain {
abi_version: "armeabi-v7a"
abi_libc_version: "armeabi-v7a"
@@ -781,3 +786,223 @@
linker_flag: "-Wl,--gc-sections"
}
}
+
+toolchain {
+ abi_version: "cortex-m4f"
+ abi_libc_version: "cortex-m4f"
+ builtin_sysroot: ""
+ compiler: "gcc"
+ host_system_name: "local"
+ needsPic: false
+ supports_gold_linker: false
+ supports_incremental_linker: false
+ supports_fission: false
+ supports_interface_shared_objects: false
+ supports_normalizing_ar: false
+ supports_start_end_lib: false
+ supports_thin_archives: false
+ target_libc: "cortex-m4f"
+ target_cpu: "cortex-m4f"
+ target_system_name: "cortex-m4f"
+ toolchain_identifier: "cortex-m4f"
+
+ tool_path { name: "ar" path: "/usr/bin/arm-none-eabi-ar" }
+ tool_path { name: "compat-ld" path: "/usr/bin/arm-none-eabi-ld" }
+ tool_path { name: "cpp" path: "/usr/bin/arm-none-eabi-cpp" }
+ tool_path { name: "dwp" path: "/usr/bin/arm-none-eabi-dwp" }
+ tool_path { name: "gcc" path: "/usr/bin/arm-none-eabi-gcc" }
+ tool_path { name: "gcov" path: "/usr/bin/arm-none-eabi-gcov" }
+ # C(++) compiles invoke the compiler (as that is the one knowing where
+ # to find libraries), but we provide LD so other rules can invoke the linker.
+ tool_path { name: "ld" path: "/usr/bin/arm-none-eabi-ld" }
+ tool_path { name: "nm" path: "/usr/bin/arm-none-eabi-nm" }
+ tool_path { name: "objcopy" path: "/usr/bin/arm-none-eabi-objcopy" }
+ objcopy_embed_flag: "-I"
+ objcopy_embed_flag: "binary"
+ tool_path { name: "objdump" path: "/usr/bin/arm-none-eabi-objdump" }
+ tool_path { name: "strip" path: "/usr/bin/arm-none-eabi-strip" }
+ linking_mode_flags { mode: FULLY_STATIC }
+
+ # TODO(bazel-team): In theory, the path here ought to exactly match the path
+ # used by gcc. That works because bazel currently doesn't track files at
+ # absolute locations and has no remote execution, yet. However, this will need
+ # to be fixed, maybe with auto-detection?
+ cxx_builtin_include_directory: '/usr/lib/gcc/arm-none-eabi/4.8/include'
+ cxx_builtin_include_directory: '/usr/lib/gcc/arm-none-eabi/4.8/include-fixed'
+ cxx_builtin_include_directory: '/usr/lib/arm-none-eabi/include'
+ cxx_builtin_include_directory: '/usr/include/newlib',
+
+ feature {
+ name: "dbg"
+ implies: "all_modes"
+ flag_set {
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-header-preprocessing"
+ action: "c++-module-compile"
+ flag_group {
+ flag: "-fno-omit-frame-pointer"
+ }
+ }
+ }
+
+ feature {
+ name: "opt"
+ implies: "all_modes"
+ }
+ feature {
+ name: "fastbuild"
+ implies: "all_modes"
+ }
+
+ feature {
+ name: "all_modes"
+ flag_set {
+ action: "preprocess-assemble"
+ action: "assemble"
+ action: "c-compile"
+ flag_group {
+ flag: "--std=gnu99"
+ }
+ }
+ flag_set {
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-header-preprocessing"
+ action: "c++-module-compile"
+ flag_group {
+ flag: "--std=gnu++11"
+ flag: "-fno-exceptions"
+ flag: "-fno-rtti"
+ }
+ }
+ }
+
+ # Anticipated future default.
+ # This makes GCC and Clang do what we want when called through symlinks.
+ unfiltered_cxx_flag: "-no-canonical-prefixes"
+ linker_flag: "-no-canonical-prefixes"
+
+ # Things that the code wants defined.
+ compiler_flag: "-D__STDC_FORMAT_MACROS"
+ compiler_flag: "-D__STDC_CONSTANT_MACROS"
+ compiler_flag: "-D__STDC_LIMIT_MACROS"
+ compiler_flag: "-D__MK64FX512__"
+ compiler_flag: "-DF_CPU=120000000"
+ compiler_flag: "-Wl,--gc-sections"
+
+ # Make C++ compilation deterministic. Use linkstamping instead of these
+ # compiler symbols.
+ unfiltered_cxx_flag: "-Wno-builtin-macro-redefined"
+ unfiltered_cxx_flag: "-D__DATE__=\"redacted\""
+ unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\""
+ unfiltered_cxx_flag: "-D__TIME__=\"redacted\""
+
+ # Security hardening on by default.
+ # Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases.
+ # We need to undef it before redefining it as some distributions now have
+ # it enabled by default.
+ compiler_flag: "-fstack-protector"
+ compiler_flag: "-mcpu=cortex-m4"
+ compiler_flag: "-mfpu=fpv4-sp-d16"
+ compiler_flag: "-mthumb"
+ compiler_flag: "-mfloat-abi=hard"
+ compiler_flag: "-fno-strict-aliasing"
+ linker_flag: "-mcpu=cortex-m4"
+ linker_flag: "-mfpu=fpv4-sp-d16"
+ linker_flag: "-mthumb"
+ linker_flag: "-mfloat-abi=hard"
+ linker_flag: "-fno-strict-aliasing"
+ linker_flag: "--specs=nano.specs"
+
+ # Pretty much everything needs this, including parts of the glibc STL...
+ linker_flag: "-lgcc"
+ linker_flag: "-lstdc++"
+ linker_flag: "-lm"
+ linker_flag: "-lc"
+ linker_flag: "-Tmotors/core/mk64fx512.ld"
+
+ compiler_flag: "-fmessage-length=80"
+
+ compiler_flag: "-Wall"
+ compiler_flag: "-Wextra"
+ compiler_flag: "-Wswitch-enum"
+ compiler_flag: "-Wpointer-arith"
+ compiler_flag: "-Wcast-qual"
+ compiler_flag: "-Wwrite-strings"
+ compiler_flag: "-Wtype-limits"
+ compiler_flag: "-Wsign-compare"
+ compiler_flag: "-Wformat=2"
+ compiler_flag: "-Werror"
+ compiler_flag: "-Wstrict-aliasing=2"
+
+ # Be annoying about using doubles places we probably didn't mean to, because
+ # the FPU only does single-precision.
+ compiler_flag: "-Wdouble-promotion"
+
+ # Don't use temp files while compiling.
+ compiler_flag: "-pipe"
+
+ # Stamp the binary with a unique identifier.
+ # TODO(austin): Put these back in.
+ #linker_flag: "-Wl,--build-id=md5"
+ #linker_flag: "-Wl,--hash-style=gnu"
+
+ # Enable debug symbols.
+ compiler_flag: "-g"
+
+ # Commons symbols are weird and not what we want, so just give multiple
+ # declaration errors instead.
+ compiler_flag: "-fno-common"
+
+ compilation_mode_flags {
+ mode: OPT
+
+ # Freescale recommends this combination for reducing cycle count.
+ # http://www.nxp.com/assets/documents/data/en/application-notes/AN4808.pdf
+ compiler_flag: "-O2"
+ compiler_flag: "-finline-functions"
+
+ # This is definitely worth it for us. It makes the FPU a lot more useful,
+ # especially with complex arithmetic, which matters a lot.
+ compiler_flag: "-ffast-math"
+
+ # It seems like this is a good idea, at least for the number crunching code.
+ # Might want to look into moving it to copts on specific rules if the code
+ # size increase becomes a problem.
+ compiler_flag: "-funroll-loops"
+
+ # Disable assertions
+ compiler_flag: "-DNDEBUG"
+
+ # Removal of unused code and data at link time (can this increase binary size in some cases?).
+ compiler_flag: "-ffunction-sections"
+ #compiler_flag: "-fdata-sections"
+ linker_flag: "-Wl,--gc-sections"
+ }
+
+ feature {
+ name: 'include_paths'
+ flag_set {
+ action: 'preprocess-assemble'
+ action: 'c-compile'
+ action: 'c++-compile'
+ action: 'c++-header-parsing'
+ action: 'c++-header-preprocessing'
+ action: 'c++-module-compile'
+ flag_group {
+ flag: '-iquote'
+ flag: '%{quote_include_paths}'
+ }
+ flag_group {
+ flag: '-I%{include_paths}'
+ }
+ flag_group {
+ flag: '-iquote'
+ flag: '%{system_include_paths}'
+ }
+ }
+ }
+}