I have been following along with the documentation for setting up a local build environment with debugging and everything has been going pretty smoothly so far. I can compile and load via DFU, I even have my J-Link working with SWD. The issue I have is when removing the C compilers -Os switch as the documents state. I am only compiling a very small blinky.cpp program to blink an LED but it seems that even so removing this option causes an error that appears to be related to the size of the compiled program not fitting in APP_FLASH.
Specifically, when i remove -Os from CFLAGS in firmware/build/arm-tools.mk i get this error:
Building target: ../../../build/target/system-part1/platform-6-m/system-part1.elf
Invoking: ARM GCC C++ Linker
mkdir -p ../../../build/target/system-part1/platform-6-m/
arm-none-eabi-g++ -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFORM_NAME=photon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -g3 -gdwarf-2 -mcpu=cortex-m3 -mthumb -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DUSE_SWD_JTAG -DMBEDTLS_CONFIG_FILE="<mbedtls_config.h>" -fno-builtin -DSYSTEM_VERSION_STRING=0.7.0 -DDEBUG_BUILD -Werror -I../../../modules/photon/system-part1/inc -I../../../modules/shared/stm32f2xx/inc -I../../../communication/src -I../../../services/inc -I../../../platform/shared/inc -I../../../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I../../../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I../../../platform/MCU/shared/STM32/inc -I../../../platform/MCU/STM32F2xx/CMSIS/Include -I../../../platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I../../../hal/inc -I../../../hal/shared -I../../../hal/src/photon -I../../../hal/src/stm32f2xx -I../../../hal/src/stm32 -I../../../hal/src/photon/api -I../../../hal/src/photon/include -I../../../hal/src/photon/wiced/security/BESL/host/WICED/ -I../../../hal/src/photon/wiced/security/BESL/include -I../../../hal/src/photon/wiced/security/BESL -I../../../hal/src/photon/wiced/security/BESL/crypto -I../../../hal/src/photon/wiced/WWD/include/ -I../../../hal/src/photon/wiced/platform/include/ -I../../../hal/src/photon/wiced/platform/GCC/ -I../../../hal/src/photon/wiced/security/BESL/supplicant/ -I../../../hal/src/photon/libraries/crypto -I../../../crypto/mbedtls/include -I../../../crypto/inc -I../../../dynalib/inc -I../../../rt-dynalib/inc -I. -MD -MP -MF ../../../build/target/system-part1/platform-6-m/system-part1.elf.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DCRYPTO_PART1_SIZE_OPTIMIZATIONS -DMODULE_VERSION=207 -DMODULE_FUNCTION=4 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=0,0,0 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE ../../../build/target/system-part1/platform-6-m/../../../modules/photon/system-part1/src/module_system_part1.o ../../../build/target/system-part1/platform-6-m/../../../modules/photon/system-part1/src/wiced_stubs.o ../../../build/target/system-part1/platform-6-m/../../../modules/photon/system-part1/src/init_dynalib.o ../../../build/target/system-part1/platform-6-m/../../../modules/photon/system-part1/src/crypto_dynalib.o ../../../build/target/system-part1/platform-6-m/../../../modules/photon/system-part1/src/module_info.o ../../../build/target/system-part1/platform-6-m/../../../modules/photon/system-part1/src/import_rt.o ../../../build/target/system-part1/platform-6-m/../../../modules/photon/system-part1/src/wifi_dynalib.o ../../../build/target/system-part1/platform-6-m/../../../modules/photon/system-part1/src/newlib.o --output ../../../build/target/system-part1/platform-6-m/system-part1.elf -nostartfiles -Xlinker --gc-sections -L../../../build/arm/linker/stm32f2xx -L../../../build/target/communication/platform-6-m-prod-6/ -L../../../build/target/hal-dynalib/platform-6-m/ -L../../../build/target/services/platform-6-m/ -L../../../build/target/platform/platform-6-m/ -L../../../build/target/crypto/platform-6-m/ -L../../../build/arm/linker -Wl,--whole-archive -lcommunication -lhal-dynalib -lservices -lplatform -lcrypto -Wl,--no-whole-archive --specs=nano.specs -lnosys ../../../hal/src/photon/lib/resources.a ../../../build/target/hal/platform-6-m/src/photon/resources.o ../../../hal/src/photon/lib/FreeRTOS/STM32F2xx.a -T../../../modules/photon/system-part1/linker.ld -L../../../modules/photon/system-part2 -Wl,--defsym,PLATFORM_DFU=0x8020000 -Wl,-Map,../../../build/target/system-part1/platform-6-m/system-part1.map
/usr/local/gcc-arm/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: ../../../build/target/system-part1/platform-6-m/system-part1.elf section `.text' will not fit in region `APP_FLASH'
../../../build/module.mk:222: recipe for target '../../../build/target/system-part1/platform-6-m/system-part1.elf' failed
/usr/local/gcc-arm/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: region `APP_FLASH' overflowed by 34636 bytes
collect2: error: ld returned 1 exit status