Skip to content

Commit

Permalink
Merge pull request #2288 from particle-iot/photon_lto/ch73834
Browse files Browse the repository at this point in the history
Enable LTO for Photon system firmware
  • Loading branch information
sergeuz authored Apr 1, 2021
2 parents a2e8e25 + 27f0f35 commit aedf623
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .buildpackrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# build targets in Particle Cloud when pushing a tag.

# GCC buildpack variation to use ( see: https://hub.docker.com/r/particle/buildpack-hal/tags/ )
export BUILDPACK_VARIATION=gcc-arm-none-eabi-9_2-2019q4
export BUILDPACK_VARIATION=gcc-arm-none-eabi-10_2-2020q4

# Platforms for which this firmware is considered stable
export RELEASE_PLATFORMS=( )
Expand Down
20 changes: 10 additions & 10 deletions .workbench/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"platforms": [6, 8, 10, 12, 13, 22, 23, 25, 26],
"firmware": "deviceOS@source",
"compilers": "gcc-arm@9.2.1",
"compilers": "gcc-arm@10.2.1",
"tools": "[email protected]",
"scripts": "[email protected]",
"debuggers": "[email protected]"
Expand Down Expand Up @@ -62,10 +62,10 @@
"x64": [
{
"name": "gcc-arm",
"version": "9.2.1",
"version": "10.2.1",
"main": "./bin",
"url": "https://binaries.particle.io/gcc-arm/windows/x64/gcc-arm-v9.2.1.tar.gz",
"sha256": "4cd5e43a2ab144b2beb589b0b0d9f9632ad918154f3749fcff0c36da93468a96"
"url": "https://binaries.particle.io/gcc-arm/windows/x64/gcc-arm-v10.2.1.tar.gz",
"sha256": "81d51a85dae99dd64012f620306ff14b55b38b66e4af1697b9f71cc08b63e6f8"
}
],
"x86": []
Expand All @@ -74,10 +74,10 @@
"x64": [
{
"name": "gcc-arm",
"version": "9.2.1",
"version": "10.2.1",
"main": "./bin",
"url": "https://binaries.particle.io/gcc-arm/darwin/x64/gcc-arm-v9.2.1.tar.gz",
"sha256": "c98939900d147182f3e603a7ec4fd13e4e67292f3c7f1f3bc09308c7f97e9974"
"url": "https://binaries.particle.io/gcc-arm/darwin/x64/gcc-arm-v10.2.1.tar.gz",
"sha256": "c340f722c06f5768320bb02a1e9cb654b6f824649c17554cbff82b337b0b43af"
}
],
"x86": []
Expand All @@ -86,10 +86,10 @@
"x64": [
{
"name": "gcc-arm",
"version": "9.2.1",
"version": "10.2.1",
"main": "./bin",
"url": "https://binaries.particle.io/gcc-arm/linux/x64/gcc-arm-v9.2.1.tar.gz",
"sha256": "d7c24c8a3464b1806c8d2e93e2d616acb1ac934199756316cf746fdfddaaefe4"
"url": "https://binaries.particle.io/gcc-arm/linux/x64/gcc-arm-v10.2.1.tar.gz",
"sha256": "b6ce735c36c79caa02a95aaefc6d829e7d265c68eda73ac6e5afcd6cd6ba68a1"
}
],
"x86": []
Expand Down
2 changes: 1 addition & 1 deletion bootloader/src/nRF52840/nrf_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void HardFault_Handler(void)
" mrseq r0, msp \n"
" mrsne r0, psp \n"
" ldr r1, [r0, #24] \n"
" ldr r2, handler2_address_const \n"
" ldr r2, =handler2_address_const \n"
" bx r2 \n"
" handler2_address_const: .word prvGetRegistersFromStack \n"
);
Expand Down
24 changes: 9 additions & 15 deletions build/arm-tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,21 @@ endif
CFLAGS += --specs=nano.specs

# Check if the compiler version is the minimum required
quote="
lt=\<
dollar=$$
arm_gcc_version_str:=$(strip $(shell $(CC) -dumpversion))
expected_version:=9.2.1
#$(info result $(shell test $(quote)$(arm_gcc_version_str)$(quote) $(lt) $(quote)$(expected_version)$(quote);echo $$?))
ifeq ($(shell test $(quote)$(arm_gcc_version_str)$(quote) $(lt) $(quote)$(expected_version)$(quote); echo $$?),0)
$(error "ARM gcc version $(expected_version) or later required, but found $(arm_gcc_version_str)")
version_to_number=$(shell v=$1; v=($${v//./ }); echo $$((v[0] * 10000 + v[1] * 100 + v[2])))
get_major_version=$(shell v=$1; v=($${v//./ }); echo $${v[0]})
arm_gcc_version_str:=$(shell $(CC) -dumpversion)
arm_gcc_version:=$(call version_to_number,$(arm_gcc_version_str))
expected_version_str:=10.2.1
ifeq ($(shell test $(arm_gcc_version) -lt $(call version_to_number,$(expected_version_str)); echo $$?),0)
$(error "ARM gcc version $(expected_version_str) or later required, but found $(arm_gcc_version_str)")
endif

arm_gcc_version_major:=$(word 1,$(subst ., ,$(arm_gcc_version_str)))
arm_gcc_version_minor:=$(word 2,$(subst ., ,$(arm_gcc_version_str)))
arm_gcc_version_patch:=$(word 3,$(subst ., ,$(arm_gcc_version_str)))
arm_gcc_version:=$(shell echo $(($(arm_gcc_version_major) * 10000 + $(arm_gcc_version_minor) * 100 + $(arm_gcc_version_patch))))

ifeq ($(shell test $(quote)$(arm_gcc_version_str)$(quote) $(lt) $(quote)4.9.0$(quote); echo $$?),0)
ifeq ($(shell test $(arm_gcc_version) -lt $(call version_to_number,4.9.0); echo $$?),0)
NANO_SUFFIX=_s
endif

# GCC 8 linker is broken and doesn't support LENGTH(region) when defining another memory region within
# MEMORY block
ifeq ($(arm_gcc_version_major),8)
ifeq ($(call get_major_version,$(arm_gcc_version_str)),8)
LDFLAGS += -Wl,--defsym=GCC_LD_BROKEN=1
endif
1 change: 1 addition & 0 deletions build/common-tools.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL = /bin/bash

RM = rm -f
RMDIR = rm -f -r
Expand Down
2 changes: 1 addition & 1 deletion hal/src/nRF52840/core_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void HardFault_Handler(void) {
" mrseq r0, msp \n"
" mrsne r0, psp \n"
" ldr r1, [r0, #24] \n"
" ldr r2, handler2_address_const \n"
" ldr r2, =handler2_address_const \n"
" bx r2 \n"
" handler2_address_const: .word prvGetRegistersFromStack \n"
);
Expand Down
1 change: 1 addition & 0 deletions hal/src/nRF52840/posix/syscalls_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
// IMPORANT: this is our own implementation header
#include <sys/dirent.h>
Expand Down
4 changes: 3 additions & 1 deletion hal/src/nRF52840/spi_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "logging.h"
#include <memory>
#include "nrf_gpio.h"
#include "nrfx_spim.h"
#include "nrfx_spis.h"
Expand All @@ -28,6 +27,9 @@
#include "delay_hal.h"
#include "check.h"

#include <memory>
#include <cstdlib>

#define DEFAULT_SPI_MODE SPI_MODE_MASTER
#define DEFAULT_DATA_MODE SPI_MODE3
#define DEFAULT_BIT_ORDER MSBFIRST
Expand Down
2 changes: 1 addition & 1 deletion hal/src/stm32f2xx/core_hal_stm32f2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void HardFault_Handler(void)
" mrseq r0, msp \n"
" mrsne r0, psp \n"
" ldr r1, [r0, #24] \n"
" ldr r2, handler2_address_const \n"
" ldr r2, =handler2_address_const \n"
" bx r2 \n"
" handler2_address_const: .word prvGetRegistersFromStack \n"
);
Expand Down
2 changes: 2 additions & 0 deletions modules/photon/system-part1/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ TARGET=elf bin lst hex size

include $(PROJECT_ROOT)/build/arm-tlm.mk

LDFLAGS += -flto -Os -fuse-linker-plugin

$(call check_modular)


2 changes: 2 additions & 0 deletions modules/photon/system-part2/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ TARGET=elf bin lst hex size

include $(PROJECT_ROOT)/build/arm-tlm.mk

LDFLAGS += -flto -Os -fuse-linker-plugin

$(call check_modular)


1 change: 1 addition & 0 deletions newlib_nano/src/mallocr.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#if defined(DEBUG) && DEBUG
#include <assert.h>
#else
#undef assert
#define assert(x) ((void)0)
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

/* Private variables ---------------------------------------------------------*/
uint8_t USE_SYSTEM_FLAGS = 0; //0, 1
uint16_t sys_health_cache = 0; // Used by the SYS_HEALTH macros store new heath if higher

button_config_t HAL_Buttons[] = {
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch-buildpack
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BUILDPACK_FILES=$(mkdir buildpack && wget https://github.com/particle-iot/firmware-buildpack-builder/tarball/0.0.10 -O - | tar -xvz -C buildpack --strip-components 1)
BUILDPACK_FILES=$(mkdir buildpack && wget https://github.com/particle-iot/firmware-buildpack-builder/tarball/0.0.11 -O - | tar -xvz -C buildpack --strip-components 1)
SHORT_REF=$(echo "$BUILDPACK_FILES" | head -n1 | cut -d '/' -f 1 | rev | cut -d '-' -f 1 | rev)
mkdir buildpack/.git
echo "${SHORT_REF}" > buildpack/.git/short_ref

0 comments on commit aedf623

Please sign in to comment.