Electron & Particle failed to compile

Hi all,

thanks for the help as always! I am trying to compile my code on 2 different photon and 1 electron. It all failed. The strange thing is that is still work when I compile for a raspberry pi. Here is were it failed:

Building target: target/workspace.elf
Invoking: ARM GCC C++ Linker
mkdir -p target/
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 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -fno-builtin -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=0.6.3 -DRELEASE_BUILD -Werror -I./inc -I../../../user/inc -I../../../dynalib/inc -I../../../services/inc -I../../../hal/inc -I../../../hal/shared -I../../../hal/src/photon -I../../../hal/src/stm32f2xx -I../../../hal/src/stm32 -I../../../hal/src/photon/api -I../../../system/inc -I../../../rt-dynalib/inc -I../../../wiring/inc -I../../../modules/photon/system-part1/inc -I../../../modules/shared/stm32f2xx/inc -I../../../platform/shared/inc -I../../../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_USB_OTG_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. -MD -MP -MF target/workspace.elf.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=4 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,109 -D_WINSOCK_H -D_GNU_SOURCE target//obj/src/user_module.o target//obj/src/module_info.o target//obj/src/user_export.o target//obj/src/newlib_stubs.o  --output target/workspace.elf -Wl,--whole-archive ../../../hal/src/photon/lib/STM32F2xx_Peripheral_Libraries.a -Wl,--no-whole-archive -nostartfiles -Xlinker --gc-sections -L../../../build/arm/linker/stm32f2xx  -L../../../build/target/user/platform-6-m -L../../../build/target/services-dynalib/arm/ -L../../../build/target/hal-dynalib/platform-6-m/ -L../../../build/target/system-dynalib/platform-6-m/ -L../../../build/target/rt-dynalib/platform-6-m/ -L../../../build/target/wiring/platform-6-m/ -L../../../build/target/communication-dynalib/platform-6-m/ -L../../../build/target/platform/platform-6-m/ -L../../../build/target/wiring_globals/platform-6-m/ -L../../../hal/src/photon/lib/ -L../../../build/arm/linker -Wl,--whole-archive -luser -lhal-dynalib -lservices-dynalib -lsystem-dynalib -lrt-dynalib -lwiring -lcommunication-dynalib -lplatform -lwiring_globals -Wl,--no-whole-archive -lnosys --specs=nano.specs -L../../../modules/photon/system-part2 -L../../../modules/photon/system-part1 -L. -T./linker.ld -Wl,--defsym,USER_FIRMWARE_IMAGE_SIZE=0x20000 -Wl,--defsym,USER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -Wl,-Map,target/workspace.map
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: target/workspace.elf section `.data' will not fit in region `APP_FLASH'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: region `APP_FLASH' overflowed by 344 bytes
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x10): undefined reference to `_read'
collect2: error: ld returned 1 exit status
../../../build/module.mk:222: recipe for target 'target/workspace.elf' failed
make[1]: Leaving directory '/firmware/modules/photon/user-part'
make[1]: *** [target/workspace.elf] Error 1
../build/recurse.mk:11: recipe for target 'modules/photon/user-part' failed


In that text, I see:
workspace.elf section `.data' will not fit in region `APP_FLASH'
region `APP_FLASH' overflowed by 344 bytes

does it really mean that I am out of memory?

thank you

It sounds like you are. I would recommend refactoring your code to save memory.

1 Like

Also when you get undefined references to _write, _close, etc. it typically means you accidentally attempted to pull in standard I/O support, which won’t work.

For example, if you accidentally used printf instead of sprintf that would happen. It would compile, but fail to link.

1 Like

It is not strange at all that code written for linux (raspberry pi) would not compile for photon or the electron. They have completely different libraries. Perhaps if you posted your code itself, someone could help.

Hi,

I am sorry, I just saw your reply… thanks for the help.

I found my problem. I added #include iostream. I am not sure why but I think it’s because I saw it was needed to use std:: (make sense? not sure…)

So I removed it and it’s working.

Here is my memory usage:
Memory use:
text data bss dec hex filename
33540 120 1580 35240 89a8 /workspace/target/workspace.elf

How much text Memory is available on Eletron and photon? I am trying to find on internet without success…

Again, thanks for your help

Francis

I’m also getting this same error. I last compiled and worked on my code a month ago. Without making any changes, I tried to compile it yesterday and got this error. I made sure my Photons (2) had the latest firmware update (0.7.0).

My codebase is almost 500 lines long. Would moving code into a separate library help? It’s strange that this used to compile just a month ago.

The last post in this thread was 10 months ago. You may want to reiterate which error you particularly mean - especially since the OP’s problem was resolved.

Having 0.7.0 system installed on your devices is only half the story. You should also check whether you are actually targeting the correct device and 0.7.0 when building you project.

No, if it is a memory issue, it doesn’t matter where the memory is consumed.

Where you targeting 0.7.0 a month ago?

Thanks for your reply, @ScruffR

I received the same error as in the original comment:

/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: target/workspace.elf section `.text' will not fit in region `APP_FLASH'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: region `APP_FLASH' overflowed by 1912 bytes
collect2: error: ld returned 1 exit status
../build/module.mk:222: recipe for target 'target/workspace.elf' failed
make: *** [target/workspace.elf] Error 1

Correction to my comment – I brought a new Photon online. This Photon was running 0.5.5. My other Photon had 0.7.0, and my code was targeting 0.7.0. Both are showing as Particle devices, whereas last month I only had my 0.7.0/0.7.0 original one.

Since I hadn’t touched the code in a month, I compiled it as a sanity check and got this error. I saw that the second Photon’s firmware was ancient, and the code was targeting a higher version.

So I upgraded this Photon, confirmed that I was targeting 0.7.0 with both Photons, and got this error again.

I tried to trim down my code, but am still getting this error.

If the answer is to trim down the code, then I’ll continue on. But it’s unclear why I’m getting this when a month ago – targeting the same version – I didn’t get this error.

Today, I’ll try to compile my code in a new file and will comment back if this works.

1 Like

If you use Web IDE you can always post a SHARE THIS REVISION link for us to have a quick try.

I figured this out!!!

I had the following in my code in order to find out the current time to compare to values selected in the Blynk Timer widget:

 TimeInputParam t(param);
 time_t now = Time.now() + t.getTZ_Offset();
 struct tm *ptm = localtime(&now); 

All I did was change localtime to gmtime:

 TimeInputParam t(param);
 time_t now = Time.now() + t.getTZ_Offset();
 struct tm *ptm = gmtime(&now); // NEW

And the error went away! When I last compiled in November, this worked. I can’t recall if I last compiled before Daylight Savings Time ended – and I don’t know if this has any relation. But after creating a new file and recompiling piecemeal, I narrowed the issue down to this line with localtime(), Googled around for an alternative, and found a recommendation to use gmtime() on Quora.

I still need to test this to see what it outputs, but I got past the compile error with this change.

1 Like