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

nRF51822 gcc unknown errors.

SDK: 12.3.0

SOFTDEVICE: s130_nrf51_2.0.1_softdevice

CHIP: nrf51822 AC 256K flash 32K ram

GCC flags:

# C flags common to all targets
CFLAGS += -DBOARD_CUSTOM
CFLAGS += -DSOFTDEVICE_PRESENT
CFLAGS += -DNRF51
CFLAGS += -DS130
CFLAGS += -DBLE_STACK_SUPPORT_REQD
CFLAGS += -DSWI_DISABLE0
CFLAGS += -DNRF51422
CFLAGS += -DNRF_SD_BLE_API_VERSION=2
CFLAGS += -mcpu=cortex-m0
CFLAGS += -mthumb -mabi=aapcs
#CFLAGS += -Wall -Werror
CFLAGS += -O3 -Os -g3
#CFLAGS += -O3 -Os -g3
# CFLAGS += -Wint-conversion -Wint-to-pointer-cast
CFLAGS += -mfloat-abi=soft
# keep every function in separate section, this allows linker to discard unused ones
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin --short-enums
CFLAGS += -DDEBUG
CFLAGS += -DDEBUG_NRF
Keil:
DEBUG_NRF DEBUG BLE_STACK_SUPPORT_REQD NRF51422 BOARD_CUSTOM NRF_SD_BLE_API_VERSION=2 S130 NRF51 SOFTDEVICE_PRESENT SWI_DISABLE0

hi, I have used both keil and gcc for nRF51822 development.

I found some strange situation. keil compiled product has no problem.

but, gcc product has some problem.

first, when ble connected, hardfault error occur sometimes. 

second, In ble connected state or just after disconnect event triggered, I have called ble_advertising_start(BLE_ADV_MODE_IDLE) function for triggering idle event.

but, gcc code always stuck somewhere. never out ble_advertising_start function.

The more weird thing is that second problem disappear after removing CFLAGS optimization flags -O3 -Os -g3 in Makefile.

and I again attached CFLAGS optimization flags -O3 -Os -g3. but second problem never occur. but The first problem still occurs.

I don't understand this situation and I can not be sure of the completeness of the product.

Thank you for your advice.

Related