Issue compiling app

I’ve checked out the 0.4.7 FW an trying to compile my app, I copy all of the files in the src doing

mkdir user/applications/gatekeeper
cp $GATEKEEPER_REPO/src/application.cpp $GATEKEEPER_REPO/*/*{cpp,h} users/applications/gatekeeper

then I try to compile the app using

make PLATFORM=photon APP=gatekeeper

but this fails with

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 -DSYSTEM_VERSION_STRING=0.4.7 -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 ../../../build/target/user-part/platform-6-m/gatekeeper.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=3 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,8 -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb ../../../build/target/user-part/platform-6-m/src/user_module.o ../../../build/target/user-part/platform-6-m/src/module_info.o ../../../build/target/user-part/platform-6-m/src/user_export.o ../../../build/target/user-part/platform-6-m/src/newlib_stubs.o  --output ../../../build/target/user-part/platform-6-m/gatekeeper.elf -Wl,--whole-archive ../../../hal/src/photon/lib/STM32F2xx_Peripheral_Libraries.a -Wl,--no-whole-archive -L../../../build/arm/linker/stm32f2xx  -L../../../build/target/user/platform-6-m/applications/gatekeeper/ -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 -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/gatekeeper.map -lstdc++_nano -lm -Wl,--start-group -lgcc -lg_nano -lc_nano -Wl,--end-group -Wl,--start-group -lgcc -lc_nano -Wl,--end-group -nostartfiles -Xlinker --gc-sections
../../../build/target/user/platform-6-m/applications/gatekeeper//libuser.a(application.o): In function `__static_initialization_and_destruction_0':
/home/karlsone/projects/creator/firmware/user/applications/gatekeeper/application.cpp:38: undefined reference to `PN532_SPI::PN532_SPI(SPIClass&, unsigned char)'
collect2: error: ld returned 1 exit status
../../../build/module.mk:175: recipe for target '../../../build/target/user-part/platform-6-m/gatekeeper.elf' failed
make[2]: *** [../../../build/target/user-part/platform-6-m/gatekeeper.elf] Error 1
make[2]: Leaving directory '/home/karlsone/projects/creator/firmware/modules/photon/user-part'
../build/recurse.mk:11: recipe for target 'modules/photon/user-part' failed
make[1]: *** [modules/photon/user-part] Error 2
make[1]: Leaving directory '/home/karlsone/projects/creator/firmware/main'
build/recurse.mk:11: recipe for target 'main' failed
make: *** [main] Error 2

I’ve tried casting SS to uint8_t as well as noted by Kevin in the slack chat without any remediation. Any ideas around this? The project is a door controller for a makerspace.


(ScruffR: I reformatted your text for readability)

@ekarlso, you need to compile from the “main” directory, not the app’s directory :wink:

Yeah, that’s what I’m doing.

@ekarlso, do you have the code on github? I could test compile on my Windows setup to see if I get the same results.

Code is located in the repo here: https://gitlab.com/creator-makerspace/gatekeeper-ctrl-particle, I copied the PN532 code over from the repo here: https://github.com/jlkalberer/Tappt.Spark/tree/master/Source/

So as noted in chat:
If I in the PN532_SPI.h do uncomment the line “#define SPI_HW_MODE = 1” in https://gitlab.com/creator-makerspace/gatekeeper-ctrl-particle/blob/master/src/PN532_SPI/PN532_SPI.h#L9 then it compiles fine so it’s as if the #define SPI_HW_MODE inside my application.cpp is not picked up?

@ekarlso, #defines are not global in scope. So #define SPI_HW_MODE 1 does not get passed to PN532_SPI.cpp so the code doesn’t compile as expected. You need to place and/or copy #define SPI_HW_MODE 1 in an include file common to all .cpp files using it.

When I copy the line to PN532_SPI.h, everything compile without error. :wink: