From a63376f8be7d837220bcf42778a941b39fc4c694 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Thu, 30 Jan 2014 16:41:51 +0000 Subject: [PATCH] Use -Os for CC2538 builds As discussed in #503, -Os was broken with one of the toolchains recommended in the platform's README and for that reason we were using -O2 by default. This commit sets the default to -Os and updates the README to no longer recommend the toolchain in question --- cpu/cc2538/Makefile.cc2538 | 6 ++++-- platform/cc2538dk/README.md | 15 ++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cpu/cc2538/Makefile.cc2538 b/cpu/cc2538/Makefile.cc2538 index 85a5de204..cab0a7046 100644 --- a/cpu/cc2538/Makefile.cc2538 +++ b/cpu/cc2538/Makefile.cc2538 @@ -10,7 +10,7 @@ SOURCE_LDSCRIPT = $(CONTIKI_CPU)/cc2538.lds endif LDSCRIPT = $(OBJECTDIR)/cc2538.ld -CFLAGS += -O2 -mcpu=cortex-m3 -mthumb -mlittle-endian +CFLAGS += -mcpu=cortex-m3 -mthumb -mlittle-endian CFLAGS += -fshort-enums -fomit-frame-pointer -fno-strict-aliasing CFLAGS += -Wall LDFLAGS += -mcpu=cortex-m3 -mthumb -nostartfiles @@ -20,8 +20,10 @@ OBJCOPY_FLAGS += -O binary --gap-fill 0xff ### Are we building with code size optimisations? ifeq ($(SMALL),1) - CFLAGS += -ffunction-sections -fdata-sections + CFLAGS += -Os -ffunction-sections -fdata-sections LDFLAGS += -Wl,--gc-sections,--sort-section=alignment +else + CFLAGS += -O2 endif ### If the user-specified a Node ID, pass a define diff --git a/platform/cc2538dk/README.md b/platform/cc2538dk/README.md index 18273d2b6..5b4b66869 100644 --- a/platform/cc2538dk/README.md +++ b/platform/cc2538dk/README.md @@ -72,13 +72,10 @@ The toolchain used to build contiki is arm-gcc, also used by other arm-based Con Thread model: single gcc version 4.3.2 (Sourcery G++ Lite 2008q3-66) -If the toolchain is not installed, download and install one of the following versions: +The platform is currently being used/tested with the following toolchains: -* GNU Tools for ARM Embedded Processors. Works nicely on OS X. +* GNU Tools for ARM Embedded Processors. This is the recommended version. Works nicely on OS X. * Alternatively, you can use this older version for Linux. At the time of writing, this is the version used by Contiki's regression tests. -* Lastly: Sourcery Codebench Lite for ARM processors from the URL below. Make sure to select the EABI Release. - -The first one is newer. The second has been in use for a longer period of time and the Contiki code has been tested with it more extensively. Drivers ------- @@ -423,11 +420,11 @@ Setting this define to 1 will automatically set the following to 0: * `UART_CONF_ENABLE` * `STARTUP_CONF_VERBOSE` -Further Code Size Reduction ---------------------------- -The build system currently uses optimization level `-O2`. Further code size reduction can be achieved by replacing `-O2` with `-Os` in `cpu/cc2538/Makefile.cc2538`. However, this is not selected as default because images generated with gcc version 4.7.2 (Sourcery CodeBench Lite) are broken for unknown reasons. +Code Size Optimisations +----------------------- +The build system currently uses optimization level `-Os`, which is controlled indirectly through the value of the `SMALL` make variable. This value can be overridden by example makefiles, or it can be changed directly in `platform/cc2538dk/Makefile.cc2538dk`. -If you are using gcc version 4.3.2 (Sourcery G++ Lite), you should be able to switch to `-Os` without problems. +Historically, the `-Os` flag has caused problems with some toolchains. If you are using one of the toolchains documented in this README, you should be able to use it without issues. If for whatever reason you do come across problems, try setting `SMALL=0` or replacing `-Os` with `-O2` in `cpu/cc2538/Makefile.cc2538`. Doxygen Documentation =====================