Merge pull request #549 from g-oikonomou/cc2538-code-size-opt

Improve optimisation settings for CC2538 builds
This commit is contained in:
George Oikonomou 2014-01-31 13:27:11 -08:00
commit c0ef70f88a
2 changed files with 12 additions and 12 deletions

View file

@ -10,18 +10,21 @@ SOURCE_LDSCRIPT = $(CONTIKI_CPU)/cc2538.lds
endif endif
LDSCRIPT = $(OBJECTDIR)/cc2538.ld 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 += -fshort-enums -fomit-frame-pointer -fno-strict-aliasing
CFLAGS += -Wall CFLAGS += -Wall
LDFLAGS += -mcpu=cortex-m3 -mthumb -nostartfiles LDFLAGS += -mcpu=cortex-m3 -mthumb -nostartfiles
LDFLAGS += -T $(LDSCRIPT) LDFLAGS += -T $(LDSCRIPT)
LDFLAGS += -Wl,--gc-sections,--sort-section=alignment
LDFLAGS += -Wl,-Map=$(@:.elf=-$(TARGET).map),--cref,--no-warn-mismatch LDFLAGS += -Wl,-Map=$(@:.elf=-$(TARGET).map),--cref,--no-warn-mismatch
OBJCOPY_FLAGS += -O binary --gap-fill 0xff OBJCOPY_FLAGS += -O binary --gap-fill 0xff
### Are we building with code size optimisations? ### Are we building with code size optimisations?
ifeq ($(SMALL),1) ifeq ($(SMALL),1)
CFLAGS += -ffunction-sections -fdata-sections CFLAGS += -Os
LDFLAGS += -Wl,--gc-sections,--sort-section=alignment else
CFLAGS += -O2
endif endif
### If the user-specified a Node ID, pass a define ### If the user-specified a Node ID, pass a define

View file

@ -72,13 +72,10 @@ The toolchain used to build contiki is arm-gcc, also used by other arm-based Con
Thread model: single Thread model: single
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-66) 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. <https://launchpad.net/gcc-arm-embedded> * GNU Tools for ARM Embedded Processors. This is the recommended version. Works nicely on OS X. <https://launchpad.net/gcc-arm-embedded>
* Alternatively, you can use this older version for Linux. At the time of writing, this is the version used by Contiki's regression tests. <https://sourcery.mentor.com/public/gnu_toolchain/arm-none-eabi/arm-2008q3-66-arm-none-eabi-i686-pc-linux-gnu.tar.bz2> * Alternatively, you can use this older version for Linux. At the time of writing, this is the version used by Contiki's regression tests. <https://sourcery.mentor.com/public/gnu_toolchain/arm-none-eabi/arm-2008q3-66-arm-none-eabi-i686-pc-linux-gnu.tar.bz2>
* Lastly: Sourcery Codebench Lite for ARM processors from the URL below. Make sure to select the EABI Release. <http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/>
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 Drivers
------- -------
@ -423,11 +420,11 @@ Setting this define to 1 will automatically set the following to 0:
* `UART_CONF_ENABLE` * `UART_CONF_ENABLE`
* `STARTUP_CONF_VERBOSE` * `STARTUP_CONF_VERBOSE`
Further Code Size Reduction Code Size Optimisations
--------------------------- -----------------------
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. 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 Doxygen Documentation
===================== =====================