Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF5 SDK build error with GCC under windows

Hello,

I am using SDK5 for my code that builds successfully under Linux, but not under windows.

The error occurs in the SDK, not in the application. I am wondering what modifications are needed to migrate from Linux to Windows, apart from editing MakeFile.Windows?

The details are as follow:

build system: Makefile + GNU tools ARM embedded, version 7.3.1

Windows 7 vs UBUNTU

MakeFile.Windows:

GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/7 2018-q2-update/bin/
GNU_VERSION := 7.3.1 
GNU_PREFIX := arm-none-eabi

The error shown:

Building nrf52832
C:/Aries/Ares-NRF52/nrf52832/makefile.mak:162: *** empty variable name. Stop.

The mentioned line (MakeFile.mak: 162):

$(foreach target, $(TARGETS), $(call define_target, $(target)))

And the macro that is called in the above line:

# $1 target name
define define_target
$(eval OUTPUT_FILE := $(OUTPUT_DIRECTORY)/$(strip $(1))) \
$(eval $(1): $(OUTPUT_FILE).out $(OUTPUT_FILE).hex $(OUTPUT_FILE).bin \
           ; @echo DONE $(strip $(1))) \
$(call prepare_build, $(1), $(OUTPUT_FILE).inc, $(OUTPUT_FILE).out)
endef

this macro and subsequent ones look fine, considering that it builds successfully under Linux with the same makefile and GCC version.

I have read and applied all relevant guides and I don't see what is the issue.

As for the last comment, my windows GCC builds our other projects successfully. So, the problem is not in its installation.

Thank you for any idea

  • Hi,

    Did you create your own makefile instead of using the ones we provide with the SDK? This seems like more of a GCC question than a Nordic question, but if you upload your makefil I can see if i can help you out.

    Have you checked the files for linux specific characters, or made sure there is no whitespaces, etc. that should not be there?

    Best regards,
    Jørgen

  • We have our own makefile that uses the SDK's makefiles, specifically MakeFile.common (SDK dir\components\toolchain\gcc\), where the error occurs. 

    I am not sure about Linux-specific characters. I only considered / and \. Do you possibly have any reference that can forward me?

    I can upload my MakeFile, if it helps and if you please tell me how to upload it.

  • You can upload files in your comments from the 'Insert' menu. If you do not want the file to be shared in public, please let me know. I can then convert the case into a private case.

  • 0434.Makefile.common

    PROJECT_NAME     := ares_nrf52_s132
    TARGETS          := $(PROJECT_NAME)
    OUTPUT_DIRECTORY := $(PROJ_DIR)/obj/$(VARIANT)
    
    SDK_ROOT := $(PROJ_DIR)/NordicSDK15
    
    $(OUTPUT_DIRECTORY)/ares_nrf52_s132.out: \
      LINKER_SCRIPT  := $(PROJ_DIR)/ares_gcc_nrf52.ld
    
    # Source files common to all targets
    SRC_FILES += \
      $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52.S \
      $(SDK_ROOT)/components/boards/boards.c \
      $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_pwm.c \
    
    # Include folders common to all targets
    INC_FOLDERS += \
      $(SDK_ROOT)/components \
      $(SDK_ROOT)/components/libraries/experimental_memobj \
      $(PROJ_DIR)/hal/inc \
    
    # Libraries common to all targets
    LIB_FILES += \
    
    # Optimization flags
    OPT = -O3 -g3
    # Uncomment the line below to enable link time optimization
    OPT += -flto
    
    # C flags common to all targets
    CFLAGS += $(OPT)
    CFLAGS += -DBOARD_PCA10040
    CFLAGS += -DBSP_DEFINES_ONLY
    CFLAGS += -DCONFIG_GPIO_AS_PINRESET
    CFLAGS += -DFLOAT_ABI_HARD
    CFLAGS += -DNRF52
    CFLAGS += -DNRF52832_XXAA
    CFLAGS += -DNRF52_PAN_74
    CFLAGS += -DNRF_SD_BLE_API_VERSION=6
    CFLAGS += -DS132
    CFLAGS += -DSOFTDEVICE_PRESENT
    CFLAGS += -mcpu=cortex-m4
    CFLAGS += -mthumb -mabi=aapcs
    CFLAGS += -Wall -Werror
    CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    # keep every function in a separate section, this allows linker to discard unused ones
    CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
    CFLAGS += -fno-builtin -fshort-enums
    CFLAGS += -std=gnu99
    
    # C++ flags common to all targets
    CXXFLAGS += $(OPT)
    
    # Assembler flags common to all targets
    ASMFLAGS += -g3
    ASMFLAGS += -mcpu=cortex-m4
    ASMFLAGS += -mthumb -mabi=aapcs
    ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    ASMFLAGS += -DBOARD_PCA10040
    ASMFLAGS += -DBSP_DEFINES_ONLY
    ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
    ASMFLAGS += -DFLOAT_ABI_HARD
    ASMFLAGS += -DNRF52
    ASMFLAGS += -DNRF52832_XXAA
    ASMFLAGS += -DNRF52_PAN_74
    ASMFLAGS += -DNRF_SD_BLE_API_VERSION=6
    ASMFLAGS += -DS132
    ASMFLAGS += -DSOFTDEVICE_PRESENT
    
    # Linker flags
    LDFLAGS += $(OPT)
    LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
    LDFLAGS += -mcpu=cortex-m4
    LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    # let linker dump unused sections
    LDFLAGS += -Wl,--gc-sections
    # use newlib in nano version
    LDFLAGS += --specs=nano.specs
    LDFLAGS += -L$(ROOT_DIR)/scale2/obj/ps2/
    LDFLAGS += -L$(ROOT_DIR)/scale2/src/
    LDFLAGS += -lscale2
    
    ares_nrf52_s132: CFLAGS += -D__HEAP_SIZE=8192
    ares_nrf52_s132: CFLAGS += -D__STACK_SIZE=8192
    ares_nrf52_s132: ASMFLAGS += -D__HEAP_SIZE=8192
    ares_nrf52_s132: ASMFLAGS += -D__STACK_SIZE=8192
    
    # Add standard libraries at the very end of the linker input, after all objects
    # that may need symbols provided by these libraries.
    LIB_FILES += -lc -lnosys -lm
    
    
    .PHONY: default help
    
    # Default target - first one defined
    default: ares_nrf52_s132
    
    # Print all targets that can be built
    help:
    	@echo following targets are available:
    	@echo		ares_nrf52_s132
    	@echo		flash_softdevice
    	@echo		sdk_config - starting external tool for editing sdk_config.h
    	@echo		flash      - flashing binary
    
    TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
    
    
    include $(TEMPLATE_PATH)/Makefile.common
    
    $(foreach target, $(TARGETS), $(call define_target, $(target)))
    
    .PHONY: flash flash_softdevice erase
    
    # Flash the program
    flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
    	@echo Flashing: $<
    	nrfjprog -f nrf52 --program $< --sectorerase
    	nrfjprog -f nrf52 --reset
    
    # Flash softdevice
    flash_softdevice:
    	@echo Flashing: s132_nrf52_6.0.0_softdevice.hex
    	nrfjprog -f nrf52 --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_6.0.0_softdevice.hex --sectorerase
    	nrfjprog -f nrf52 --reset
    
    erase:
    	nrfjprog -f nrf52 --eraseall
    
    SDK_CONFIG_FILE := ../config/sdk_config.h
    CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
    sdk_config:
    	java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)
    
    GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/7 2018-q2-update/bin/
    GNU_VERSION := 7.3.1 
    GNU_PREFIX := arm-none-eabi
    
    

    Here are my Makefiles. For some reason, makefile.mak and MakeFile.wondows fail to upload, so I renamed them to makefile-mak.txt and makefile-windows.txt to be able to upload them.

    Thank you very much for your help

  • Your makefile is shorter than line 162. Did you change it? Where have you defined the variables PROJ_DIR and VARIANT on line 3?

    OUTPUT_DIRECTORY := $(PROJ_DIR)/obj/$(VARIANT)

Related