Trying to build with the develop branch locally

Hi All,

To test some new fixes in the develop branch for the Photon I am forced to build locally something I have not been doing.

Anyway I am running into a few snags. Not knowing where I am going wrong

I have tried to follow the instructions at https://github.com/spark/firmware/blob/develop/docs/build.md

When I enter the following command

C:\spark\firmware\modules>make PLATFORM=photon clean all program-dfu v=1

I get a long verbose output which seems good but then it fails in the last part of the output.

Building target: ../../../build/target/system-part1/platform-6-m-lto/system-part1.elf
Invoking: ARM GCC C++ Linker
mkdir -p ../../../build/target/system-part1/platform-6-m-lto/
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 -DPRODUCT_
ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -fno-builtin -fno-builtin-malloc -fno-builtin-free -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMA
GE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=2 -DMODULE_FUNCTION=4 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=0,0,0 -DRELEASE_BUILD -Werror -I../../../modules/photon/system-par
t1/inc -I../../../communication/lib/tropicssl/include -I../../../communication/src -I../../../hal/inc -I../../../hal/shared -I../../../hal/src/photon -I../../../hal/src/photon/api -I../
../../services/inc -I../../../platform/shared -I../../../platform/MCU/STM32F2xx/CMSIS/Include -I../../../platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I../../../platform/MCU/STM32F2xx
/SPARK_Firmware_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I../../../platform/MCU/STM32F2xx/S
TM32_USB_Host_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../../../dynalib/inc -I../../../rt-dynalib/inc -I. -MD -MP -MF ../../../build/target/system-part1/p
latform-6-m-lto/system-part1.elf.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DSTART_DFU
_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -flto ../../../build/target/system-part1/platform-6-m-lto/../../../module
s/photon/system-part1/src/import_rt.o ../../../build/target/system-part1/platform-6-m-lto/../../../modules/photon/system-part1/src/init_dynalib.o ../../../build/target/system-part1/plat
form-6-m-lto/../../../modules/photon/system-part1/src/module_info.o ../../../build/target/system-part1/platform-6-m-lto/../../../modules/photon/system-part1/src/module_system_part1.o ..
/../../build/target/system-part1/platform-6-m-lto/../../../modules/photon/system-part1/src/wiced_stubs.o ../../../build/target/system-part1/platform-6-m-lto/../../../modules/photon/syst
em-part1/src/wifi_dynalib.o   --output ../../../build/target/system-part1/platform-6-m-lto/system-part1.elf --specs=nano.specs -lnosys ../../../hal/src/photon/lib/resources.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-lto/system-par
t1.map  -L../../../build/target/communication/platform-6-m-lto-prod-6/ -L../../../build/target/hal/platform-6-m-lto/ -L../../../build/target/services/platform-6-m-lto/ -L../../../build/
target/platform/platform-6-m-lto/ -Wl,--whole-archive -lcommunication -lhal -lservices -lplatform -Wl,--no-whole-archive -L../../../build/arm/linker -nostartfiles -Xlinker --gc-sections
  -flto -Os -fuse-linker-plugin
`free' referenced in section `.text.mpi_grow' of C:\Users\LONDON~1\AppData\Local\Temp\cc3zbAFp.ltrans1.ltrans.o: defined in discarded section `.text' of ../../../build/target/system-par
t1/platform-6-m-lto/../../../modules/photon/system-part1/src/import_rt.o (symbol from plugin)
`free' referenced in section `.text.mpi_free' of C:\Users\LONDON~1\AppData\Local\Temp\cc3zbAFp.ltrans2.ltrans.o: defined in discarded section `.text' of ../../../build/target/system-par
t1/platform-6-m-lto/../../../modules/photon/system-part1/src/import_rt.o (symbol from plugin)
`free' referenced in section `.text._ZNSt14_Function_base13_Base_managerIZN13SparkProtocol20handle_function_callERNS1_3msgEEUlPKvN15SparkReturnType4EnumEE_E10_M_managerERSt9_Any_dataRKS
A_St18_Manager_operation.5348' of C:\Users\LONDON~1\AppData\Local\Temp\cc3zbAFp.ltrans3.ltrans.o: defined in discarded section `.text' of ../../../build/target/system-part1/platform-6-m
-lto/../../../modules/photon/system-part1/src/import_rt.o (symbol from plugin)
collect2.exe: error: ld returned 1 exit status
make[1]: *** [../../../build/target/system-part1/platform-6-m-lto/system-part1.elf] Error 1
make[1]: Leaving directory `/c/spark/firmware/modules/photon/system-part1'
make: *** [/c/spark/firmware/modules/photon/system-part1/makefile] Error 2

Sorry to post so much of the output not sure what others would be looking for.

Any help would be most appreciated.

@HardWater, I feel you pain! @mdma had me add COMPILE_LTO=n to the make line and that works, for me at least. Not sure why but I hope at some point, that won’t be needed. :smile:

Can you check your version of the compiler

arm-none-eabi-gcc --version

It should be 4.9.3 or newer. Thanks :smile:

@mdma, FYI, that is the version of gcc I am using.

@mdma Yes I checked I am at 4.8 something so will have to update.

I will not be able to get to it later but will post back when I have a chance to try it out.

1 Like

please also try deleting the build/target folder to be 100% sure the build is clean.

Hi @mdma & @peekay123

Hey this has been real tough I figured out that my initial MAKE from the main directory was not completing properly.

Through a lot of trial and errror, error & error I figured out that in addition to the compiler I also had to change the make program itself and get msys installed.

Anyways that seems to be an improvement. When I run

C:\spark\firmware\main>make PLATFORM=photon v=1

The output ends in the following

arm-none-eabi-objcopy -O ihex ../../../build/target/user-part/platform-6-m-lto/user-part.elf ../../../build/target/user-part/platform-6-m-lto/user-part.hex
arm-none-eabi-size --format=berkeley ../../../build/target/user-part/platform-6-m-lto/user-part.elf
   text    data     bss     dec     hex filename
   4232     104     332    4668    123c ../../../build/target/user-part/platform-6-m-lto/user-part.elf
arm-none-eabi-objdump -h -S ../../../build/target/user-part/platform-6-m-lto/user-part.elf > ../../../build/target/user-part/platform-6-m-lto/user-part.lst
make[1]: Leaving directory `C:/spark/firmware/modules/photon/user-part'

When I go to the firmware/modules dir and and run the following:

C:\spark\firmware\modules>make PLATFORM=photon clean all program-dfu v=1

I get the following end to the output which seems wrong

arm-none-eabi-objcopy -O ihex ../../../build/target/system-part1/platform-6-m-lto/system-part1.elf ../../../build/target/system-part1/platform-6-m-lto/system-part1.hex
arm-none-eabi-size --format=berkeley ../../../build/target/system-part1/platform-6-m-lto/system-part1.elf
   text    data     bss     dec     hex filename
 246916     128     136  247180   3c58c ../../../build/target/system-part1/platform-6-m-lto/system-part1.elf
arm-none-eabi-objdump -h -S ../../../build/target/system-part1/platform-6-m-lto/system-part1.elf > ../../../build/target/system-part1/platform-6-m-lto/system-part1.lst
dfu-suffix -v 2B04 -p D006 -a ../../../build/target/system-part1/platform-6-m-lto/system-part1.dfu
process_begin: CreateProcess(NULL, dfu-suffix -v 2B04 -p D006 -a ../../../build/target/system-part1/platform-6-m-lto/system-part1.dfu, ...) failed.
make (e=2): The system cannot find the file specified.
make[1]: *** [../../../build/target/system-part1/platform-6-m-lto/system-part1.dfu] Error 2
make[1]: Leaving directory `C:/spark/firmware/modules/photon/system-part1'
make: *** [C:/spark/firmware/modules/photon/system-part1/makefile] Error 2

Any ideas as to what is wrong.

Looks like you don't have dfu-suffix installed. It's usually installed as part of the dfu-utils package, which you can find here

Hi @mdma

Yeah that would make sense. I decided to keep going forward in the hopes that the failure above was not fatal. It has proven not to be as I just managed to compile my code locally and flash a photon with it. Though I have not tested anything carefully I can see it is sending data WooHoo!

2 Likes