diff --git a/cpu/cc2538/Makefile.cc2538 b/cpu/cc2538/Makefile.cc2538 index 85a5de204..bc39b6e3e 100644 --- a/cpu/cc2538/Makefile.cc2538 +++ b/cpu/cc2538/Makefile.cc2538 @@ -10,18 +10,21 @@ 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 += -ffunction-sections -fdata-sections CFLAGS += -fshort-enums -fomit-frame-pointer -fno-strict-aliasing CFLAGS += -Wall LDFLAGS += -mcpu=cortex-m3 -mthumb -nostartfiles LDFLAGS += -T $(LDSCRIPT) +LDFLAGS += -Wl,--gc-sections,--sort-section=alignment LDFLAGS += -Wl,-Map=$(@:.elf=-$(TARGET).map),--cref,--no-warn-mismatch OBJCOPY_FLAGS += -O binary --gap-fill 0xff ### Are we building with code size optimisations? ifeq ($(SMALL),1) - CFLAGS += -ffunction-sections -fdata-sections - LDFLAGS += -Wl,--gc-sections,--sort-section=alignment + CFLAGS += -Os +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 =====================