This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Does difference exists between nRF52832 gcc and keil?

Hi,

I am doing a job with nRF52832 with keil in initial period. I have two peripherals and connect to nRF52832 via uart, and  it runs well. Recently, I migrate the job to gcc environment. All runs well except for the ble. My phone can't connect to device anymore, but it works with keil hex well. When remove the two uart peripherals, I can connect to device via ble.... But the code is identical between keil and gcc. 

My sdk version is S132, sdk is 15.0.0 and phone tool is nRF connect. The softdevice(6.0.0) is programmed and app download nextly. And before compiling, I checked the ROM and RAM in .ld file:

MEMORY
{
FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000
RAM (rwx) : ORIGIN = 0x20003000, LENGTH = 0xD000
}

So my question is : Is it different between keil and gcc when compiling ble (or uart)? or need to define macro i missed.

My part of  makefile is below:

CFLAGS += $(OPT)
CFLAGS += -DBOARD_PCA10040
CFLAGS += -DDEBUG
CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
CFLAGS += -DSOFTDEVICE_PRESENT
CFLAGS += -DNRF52
CFLAGS += -DS132
CFLAGS += -DSWI_DISABLE0
CFLAGS += -DNRF_SD_BLE_API_VERSION=5
CFLAGS += -DNRF52832_XXAA
CFLAGS += -DNRF52_PAN_74
CFLAGS += -mcpu=cortex-m4
CFLAGS += -mthumb -mabi=aapcs
CFLAGS += -Wall
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

# 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 += -DSOFTDEVICE_PRESENT
ASMFLAGS += -DS132
ASMFLAGS += -DNRF_SD_BLE_API_VERSION=5
# 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

Parents
  • Yes, of course Keil and GCC are entirely different products!

    This really has nothing specifically to do with nRF - the same applies to porting any system from one toolchain to another:

    • Although the 'C' language is standardised, the standards make many things implementation-defined - and a few which are undefined.
    • I don't think I've ever come across a compiler which doesn't add some proprietary extensions.
    • As well as the compiler, you need to consider the other parts of the toolchain, which are beyond the scope of the 'C' language definition - in particular, the Linker.
    My phone can't connect to device anymore

    So what debugging have you done to find where the problem(s) is/are ?

    Rather than try to port the Keil project, I would suggest that you start afresh with one of Nordic's specific GCC projects - to give you a known-good starting point.

    Once you have that working, you can start to merge in your functionality ...

  • Thanks for reply. The gcc toolchain is recommanded by nordic, C:\Program Files (x86)\GNU Tools Arm Embedded\7 2018-q2-update\arm-none-eabi. My main job is debug the two uart peripherals. When add the peripherals, 52832 ble is not working. Remove them, ble is ok. So I don't think it is the problem of toochain. If it is, ble won't work from beginning.

  • The gcc toolchain is recommanded by nordic

    In fact, they recommend Segger Embedded Studio - which comes with GCC as its toolchain.

    They provide SES projects for the examples.

    My main job is debug the two uart peripherals

    So start a separate thread on that.

    52832

    but the 52832 only has one hardware UART peripheral?

    I don't think it is the problem of toochain. If it is, ble won't work from beginning.

    Maybe.

    It's possible that you may have something incorrectly configured, which causes a problem which does not manifest during the initial connection ...

    You need to use the debugger to find where & why it's failing ...

  • Hi, it indeed has nothing to do with the toolchain. And I have found the problem is the stack overflow of my task in freertos. Thanks a lot again and have a nice day !

Reply Children
No Data
Related