0

Eclipse gnu-mcu-arm makefile project vs managed project

efilabs gravatar image

asked 2017-12-07 00:26:06 +0100

a friendly hello to anyone interested in my question and setup

first i would like to explain the makefile setup, which works and 2nd i will go into the managed one and the linker errs i'm getting using the ble_uart example

also maybe this helps others with their nrf5x and eclipse setup issues

yes, there is segger embedded studio for linux, but i've been working with eclipse for the past 12 years on and off, so why to learn another ide and switch constantly between the 2 on multiple projects

i have to port a c++ proj from an nxp mcu to the nrf52832 to provide ble communication in a single mcu solution

setup : sdk14.2.0, eclipse oxygen, gnu-mcu-arm plugin and arm embedded toolchain

https://gnu-mcu-eclipse.github.io/too...

https://developer.arm.com/open-source...

create an eclipse based makefile project :

have your folders struct (e.g. sdk) with all *.h, *.c, *.cpp files in place

new -> "makefile project with existing code"

browse to your makefile ... select the toolchain ... change the proj name if you don't like it, and this will generate the .project and .cproject files along with the .settings files

i personally like to keep the nordic sdk files and my project files separated and not nested within the sdk and made therefore small changes to the makefile to move main.c, sdk_config.h and the linker scripts into my own project portion. to provide accessibility within the workspace i create a regular separate eclipse project of the sdk within the same workspace ... file -> new -> project ...

i renamed main.c to Main.cpp since it will eventually hold my TCppMain class and the entry "main ()" function within the same file, but outside of this class

this setup requires to provide include file references in project -> properties -> c/c++ general -> paths and symbols -> includes (information taken from the makefile, include folders)

to keep the eclipse indexer happy i also had to add the -Dxxx symbols from the makefile into the same as above -> symbols

i would like to mention that i sorted the source-files and includes-folder portions in the makefile to get a better understanding of all the files in use (hopefully this was not a mistake)

i also stripped all files and folders not referenced by the used *.c files in the project from the makefile and the sdk as well ... now i have a lean sdk tailored for my individual proj setup ... if the proj grows i can always add them from the org untouched sdk (i use beyond compare 3 to do this comparing and merging)

i have to admit that this might not be the usual setup, "BUT IT WORKS"

quick launch and debug setup : click the arrow next to the bug icon -> debug configuration

double click "GDB SEGGER J-Link Debugging" will add a new launch configuration for the project for download and debug

duplicate this launch, rename it to softdevice-load or similar and change :

Main tab -> c/c++ application, edit field to select the Softdevice hex file

Startup tab -> Load symbols, deselect

now you have a launch for the softdevice only

so far so good ... the initial makefile setup works (haven't expanded beyond the example at this point

now the attempt to make use of what i have for the managed setup :

create a new c++ managed project within the same workspace and replace main.cpp with the above Main.cpp in the src folder ... replace the linker files with the one from above and remove the generated system startup folder and files

use the same lean sdk project setup from above

use the same includes and symbols definition lists from the makefile proj and enter them in project -> properties -> c/c++ build -> settings -> GNU ARM Cross Assembler, GNU ARM Cross Compiler and GNU ARM Cross C++ Compiler

issue a refresh followed by clean command

issuing a build command will compile all files with some warnings, but :

the linker throws the following errs

Invoking: GNU ARM Cross C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra  -g3 -T ble_app_uart_gcc_nrf52.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"nrfUartBle.map" --specs=nano.specs -o "nrfUartBle.elf"  ./src/Main.o   
/usr/eclipse-arm/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol Reset_Handler; defaulting to 0000000000023000
./src/Main.o: In function `ble_evt_handler':
/home/code-arm/cortex_nrf52ble/nrfUartBle/Debug/../src/Main.cpp:336: undefined reference to `bsp_indication_set'
/home/code-arm/cortex_nrf52ble/nrfUartBle/Debug/../src/Main.cpp:337: undefined reference to `app_error_handler_bare'
/home/code-arm/cortex_nrf52ble/nrfUartBle/Debug/../src/Main.cpp:357: undefined reference to `app_error_handler_bare'
/home/code-arm/cortex_nrf52ble/nrfUartBle/Debug/../src/Main.cpp:364: undefined reference to `app_error_handler_bare'
makefile:57: recipe for target 'nrfUartBle.elf' failed
/home/code-arm/cortex_nrf52ble/nrfUartBle/Debug/../src/Main.cpp:374: undefined reference to `app_error_handler_bare'
/home/code-arm/cortex_nrf52ble/nrfUartBle/Debug/../src/Main.cpp:380: undefined reference to `app_error_handler_bare'
./src/Main.o:/home/code-arm/cortex_nrf52ble/nrfUartBle/Debug/../src/Main.cpp:387: more undefined references to `app_error_handler_bare' follow
./src/Main.o:(.sdh_ble_observers1+0x0): undefined reference to `ble_advertising_on_ble_evt'
./src/Main.o:(.sdh_ble_observers1+0x8): undefined reference to `nrf_ble_gatt_on_ble_evt'
./src/Main.o:(.sdh_ble_observers2+0x0): undefined reference to `ble_nus_on_ble_evt'
./src/Main.o:(.sdh_soc_observers1+0x0): undefined reference to `ble_advertising_on_sys_evt'
collect2: error: ld returned 1 exit status
make: *** [nrfUartBle.elf] Error 1

11:14:37 Build Finished (took 2s.124ms)

those are the symbols in used

BOARD_PCA10040
CONFIG_GPIO_AS_PINRESET
FLOAT_ABI_HARD
NRF52
NRF52832_XXAA
NRF52_PAN_74
S132
SOFTDEVICE_PRESENT
SWI_DISABLE0
NRF_SD_BLE_API_VERSION=5
NRF_LOG_DEFAULT_LEVEL=0
NRF_LOG_ENABLED=0

at this point i'm not too concerned about the warning: cannot find entry symbol Reset_Handler ... will fix it later

the question now would be ... how comes that the managed project throws those linker errs by having the same sdk setup and includes and symbols used as in the makefile setup

i was also wondering if the project path length would be an issue in linux (the linker snippets above do not reflect the whole path)

maybe my story helps some other eclipse user with his initial startup attempts

many thanks to the ones able to explain what's wrong with the linker errs

i'm enclosing my examples for information

cortex_nrf52ble.zip

edit retag flag offensive close delete report spam

2 answers

Sort by » oldest newest most voted
0
joh2 gravatar image

answered 2017-12-07 11:42:39 +0100

Hi,

It seems you have not included some source files in your project, or you have not enabled the modules in sdk_config.h.

  • app_error_handler_bare implemented in \components\libraries\util\app_error.c
  • bsp_indication_set implemented in \components\libraries\bsp\bsp.c
  • app_error_handler_bare implemented in \components\libraries\util\app_error.c
  • ble_advertising_on_ble_evt implemented in \components\ble\ble_advertising\ble_advertising.c
  • nrf_ble_gatt_on_ble_evt implemented in \components\ble\nrf_ble_gatt\nrf_ble_gatt.c
  • ble_nus_on_ble_evt implemented in \components\ble\ble_services\ble_nus\ble_nus.c
  • ble_advertising_on_sys_evt implemented in\components\ble\ble_advertising\ble_advertising.c

Best regards,

Jørgen

edit flag offensive delete publish link more
0
efilabs gravatar image

answered 2017-12-08 04:20:49 +0100

thanks Jørgen

pointing at the missing *.c files got me digging deeper and i discovered that all the warnings (lots of them) were related to main.c ... i didn't inspect them too close i guess and so i missed that no other files got compiled

it turns out that the sdk can't be located outside the projects src directory ... at least for now

now that i have a working base, i will experiment a bit more ... maybe i can make a static library dedicated to my project out of it ... an initial attempt failed

so i moved the sdk (lean as mentioned in my initial questions description) into the src folder

i had to disable app_uart.c since it contained duplicate functions from app_uart_fifo.c

and a couple other cleanups in the startup section

and now the ble_uart example WORKS as an eclipse managed project

again, thanks Jørgen

edit flag offensive delete publish link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower

Stats

Asked: 2017-12-07 00:26:06 +0100

Seen: 48 times

Last updated: des. 08