Photon, local build, on Windows


#1

I’m not sure if this is a bug in the current code, or something I’m doing wrong, however when working with the latest develop branch of the firmware, on Windows 7, with Arm 4.9 2015q2, I’m getting an error when building for the Photon platform, that I’m not seeing when building for the Core. I’m doing a git reset --hard prior to these builds, and building with make clean all v=1 with PLATFORM=photon for the photon build. Here’s the end of the build output:

Building target: ../../../build/target/user-part/platform-6-m-lto/user-part.elf
Invoking: ARM GCC C++ Linker
mkdir -p ../../../build/target/user-part/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 -DINCLUDE_PLATFORM=1 -fno-builtin -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=2 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,2 -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/photon/api -I../../../system/inc -I../../../rt-dynalib/inc -I../../../wiring/inc -I../../../modules/photon/system-part1/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/STM32_USB_Host_Driver/inc -I../../../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I. -MD -MP -MF ../../../build/target/user-part/platform-6-m-lto/user-part.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/user-part/platform-6-m-lto/src/module_info.o ../../../build/target/user-part/platform-6-m-lto/src/user_export.o ../../../build/target/user-part/platform-6-m-lto/src/user_module.o ../../../build/target/user-part/platform-6-m-lto/src/newlib_stubs.o  --output ../../../build/target/user-part/platform-6-m-lto/user-part.elf -Wl,--whole-archive ../../../hal/src/photon/lib/STM32F2xx_Peripheral_Libraries.a -Wl,--no-whole-archive --specs=nano.specs -lnosys -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,../../../build/target/user-part/platform-6-m-lto/user-part.map  -L../../../build/target/user/platform-6-m-lto/src/ -L../../../build/target/services-dynalib/arm/ -L../../../build/target/hal-dynalib/platform-6-m-lto/ -L../../../build/target/system-dynalib/platform-6-m-lto/ -L../../../build/target/rt-dynalib/platform-6-m-lto/ -L../../../build/target/wiring/platform-6-m-lto/ -L../../../build/target/communication-dynalib/platform-6-m-lto/ -L../../../build/target/platform/platform-6-m-lto/ -L../../../hal/src/photon/lib/ -Wl,--whole-archive -luser -lhal-dynalib -lservices-dynalib -lsystem-dynalib -lrt-dynalib -lwiring -lcommunication-dynalib -lplatform -Wl,--no-whole-archive -L../../../build/arm/linker -nostartfiles -Xlinker --gc-sections  -flto -Os -fuse-linker-plugin
C:\Users\Daniel\AppData\Local\Temp\ccUG1Xr6.ltrans0.ltrans.o: In function `sscanf':
C:\Users\Daniel\Documents\GitHub\firmware\modules\photon\user-part/./inc/rt_dynalib.h:33: multiple definition of `sscanf'
d:/dev/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-sscanf.o):sscanf.c:(.text.sscanf+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
make[2]: *** [../../../build/target/user-part/platform-6-m-lto/user-part.elf] Error 1
make[2]: Leaving directory `C:/Users/Daniel/Documents/GitHub/firmware/modules/photon/user-part'
make[1]: *** [modules/photon/user-part] Error 2
make[1]: Leaving directory `C:/Users/Daniel/Documents/GitHub/firmware/main'
make: *** [main] Error 2

I tried taking the offending line out of the rt_dynalib.h file, DYNALIB_FN(rt, sscanf), which results in a successful compile, however I’m afraid to try flashing the result, as I’m not sure if it’ll screw something up. Any ideas? Thanks!


Naive new user of Photon
Basic Power Loss Detection - Electron
#2

Paging @mdma, but this seems to be resolved by building with the 2015q1 ARM toolchain, so my problem is fixed, but does there need to be a note, and/or is this a bug in the firmware for it to compile on the newest ARM GCC setup?


#3

@mumblepins, are you running the build from the “modules” folder? I am building on Win7x64 without any issues.


#4

I, too, am having trouble compiling locally on Win7 64:


Invoking: ARM GNU Create Flash Image
arm-none-eabi-objcopy -O binary ../../../build/target/system-part1/platform-6-m/system-part1.elf ../../../build/target/system-part1/platform-6-m/system-part1.bin.pre_crc
head -c $((`stat --print %s ../../../build/target/system-part1/platform-6-m/system-part1.bin.pre_crc` - 38)) ../../../build/target/system-part1/platform-6-m/system-part1.bin.pre_cr
c > ../../../build/target/system-part1/platform-6-m/system-part1.bin.no_crc
      0 [main] stat 23416 open_stackdumpfile: Dumping stack trace to stat.exe.stackdump
head: -38: invalid number of bytes
make[1]: *** [../../../build/target/system-part1/platform-6-m/system-part1.bin] Error 1
make[1]: Leaving directory `W:/Particle/firmware-0.4.2/modules/photon/system-part1'
make: *** [W:/Particle/firmware-0.4.2/modules/photon/system-part1/makefile] Error 2

Any ideas what I may be doing wrong?


#5

You’ll need to double check your MinGW installation. Looks like the “stat” is failing. Try running “stat” on it’s own.


#6

Not sure if this tutorial helps: [Toolchain] Windows


#7

I’m also having issues, here is my error (when building with 2015q1)

C:\Spark\photon\firmware-develop\modules>make PLATFORM=photon clean all
      0 [main] stat 5176 open_stackdumpfile: Dumping stack trace to stat.exe.stackdump
head: -38: invalid number of bytes
make[1]: *** [../../../build/target/system-part1/platform-6-m-lto/system-part1.bin] Error 1
make: *** [C:/Spark/photon/firmware-develop/modules/photon/system-part1/makefile] Error 2

C:\Spark\photon\firmware-develop\modules>

and with 2015q2

C:\Spark\photon\firmware-develop\modules>make PLATFORM=photon clean all program-dfu
C:\Users\Chris\AppData\Local\Temp\ccF61aSd.ltrans4.ltrans.o: In function `sscanf':
C:\Spark\photon\firmware-develop\modules\photon\system-part1/../../../rt-dynalib/inc/rt_dynalib.h:33: multiple definition of `sscanf'
c:/sparkcoreprograms/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-ssca
nf.o):sscanf.c:(.text.sscanf+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
make[1]: *** [../../../build/target/system-part1/platform-6-m-lto/system-part1.elf] Error 1
make: *** [C:/Spark/photon/firmware-develop/modules/photon/system-part1/makefile] Error 2

C:\Spark\photon\firmware-develop\modules>

#8

The problem is the same as reported earlier in the thread - stat.exe is crashing.

  0 [main] stat 5176 open_stackdumpfile: Dumping stack trace to stat.exe.stackdump

Indicates that stat.exe crashed. That’s some issue with MinGW, that I’m afraid it out of my sphere of knowledge. The error when you downgraded to 2015q2 is the same error as others are seeing - it’s necessary to use the latest arm gcc version.


#9

the latest gives the multiple definition of `sscanf’ error… same as the original post


#10

@mdma, 2015q2 is the newest version, as near as I can tell? it was released 3 days ago… I haven’t seen any issues with the stat command on 2015q1, so I can’t help anything with that. @peekay123, with 2015q2, I tried building from the root folder, from main, and from modules, and still get the multiple definition of sscanf error. All of those individual builds work with 2015q1.


#11

I was getting mixed up with the versions I thought I was on 2015q2, I’m still using 2015q1, so please stick with that. (I had not seen the newer version.)

The stat.exe issue is not related to the compiler - it’s a problem with MinGW. Let’s keep both those issues separate in our minds to avoid further confusion.


#12

Been doing some research on the error… should i be using a msys shell instead of a command prompt? if so how do i do that?

edit:

So i what i figured out so far… install all the Dependencies from here (and make sure to check versions) and follow @kennethlimcp tut from post 6 above.
start a shell using ‪C:\MinGW\msys\1.0\msys.bat
navigate to the folder (note forward slash not back slash) cd c:/particle/firmware/modules
update system to develop firmware make PLATFORM=photon clean all program-dfu
that will compile part 1 and flash it using dfu, then go straight onto compile part 2 and flash it via dfu, and then compile user and flash via dfu. it then exits dfu mode and restarts the photon. now the photon is flashing green… and im yet to work out the next step of compiling my own code :slight_smile: wish me luck


#13

As far as I know, if you have all the correct tools in your path, a normal command shell should be fine. Btw, I was also working on compiling with a cygwin shell, and I got some errors if parts of the toolchain/compiler have spaces in their path.


#14

Im giving up for a few hours… 2 days solid trying to get it working now :frowning:

and i think i broke my photon :frowning: need to push the reset button to get it to switch on after plugging it in… then i get flashing green. all i can do is push and hold the mode till it enters listening mode then put in wifi creds… next reboot it just goes flashing green :frowning: and i dont know what fw its running


#15

Thank you so much @Hootie81 ! I was so frustrated because I got everything to build on an old slow XP computer with flakey USB ports but couldn’t get it to work on my newer Win7 64 computer until your post. Now I’m in business and can flash successfully despite some mysterious final error messages that seem bogus:

make[1]: *** [program-dfu] Error 74
make[1]: Leaving directory `c:/particle/firmware-develop/modules/photon/user-par
t'
make: *** [c:/particle/firmware-develop/modules/photon/user-part/makefile] Error
 2

#16

thats exactly the point im at!

same error…

if you leave off the program-dfu part whats the output then?


#17

@Hootie81, i will clean up my windows VM and reinstall the tools and see what happens :smile:


#18

make PLATFORM=photon all v=1
results in:

make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `c:/particle/firmware-develop/communication-dynalib'
c:/WinAVR-20100110/utils/bin/make -C ../../../platform  MODULAR_FIRMWARE=y 'GLOB
AL_DEFINES=USER_FIRMWARE_IMAGE_SIZE=0x20000 USER_FIRMWARE_IMAGE_LOCATION=0x80A00
00 MODULAR_FIRMWARE=1 MODULE_VERSION=2 MODULE_FUNCTION=5 MODULE_INDEX=1 MODULE_D
EPENDENCY=4,2,3' COMPILE_LTO=y PLATFORM=photon v=1 submake=1
make[2]: Entering directory `c:/particle/firmware-develop/platform'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `c:/particle/firmware-develop/platform'
arm-none-eabi-size --format=berkeley ../../../build/target/user-part/platform-6-
m-lto/user-part.elf
   text    data     bss     dec     hex filename
   2292      40     344    2676     a74 ../../../build/target/user-part/platform
-6-m-lto/user-part.elf
make[1]: Leaving directory `c:/particle/firmware-develop/modules/photon/user-par
t'

#19

so using the minGW shell ala @Hootie81 works fine for me (despite errors being reported) to flash photon from /modules in either the firmware-develop or firmware-0.4.2 branches. However, I bomb out with a stat.exe error if running from the simple windows7 64 bit command prompt. I can live with that.
Here’s the compile output in the minGW shell that works despite reported errors:

Opening DFU capable USB device...
ID 2b04:d006
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "Internal Flash   "
Downloading to address = 0x080a0000, size = 2328
Download        [=========================] 100%         2328 bytes
Download done.
File downloaded successfully
Error during download get_status
make[1]: *** [program-dfu] Error 74
make[1]: Leaving directory `c:/particle/firmware-0.4.2/modules/photon/user-part'

make: *** [c:/particle/firmware-0.4.2/modules/photon/user-part/makefile] Error 2

#20

I get the same error at the end… but the photon goes to flashing green? if i unplug and plug it back in it stays off till i push the reset button. when it comes on it goes back to flashing green. if i push and hold the mode button it goes solid green then into listening mode… i can enter the creds and it connects to the wifi and goes breathing cyan, but the next time i restart it goes to flashing green again…