apache / apache/nuttx

[BUG] Missing board initialization symbols when Board common logic is disabled

Open
#17,024 1 comment 0 reactions 0 assignees View on GitHub
Arch: all OS: Linux Type: Bug
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

### Description / Steps to reproduce the issue

When building an out-of-tree application against the nuttx-export package with Board common logic needs to be enabled, the linker fails due to missing board-level functions such as stm32_boardinitialize, board_autoled_on/off, and board_app_initialize.

This issue is related to https://github.com/apache/nuttx/pull/16970

### Steps to Reproduce
Follow the doc procedure in this PR or in `Documentation/guides/cpp_cmake.rst`

### Error
```
➜ hellocpp cp ../nuttx/nuttx-export-12.10.0.tar.gz ./ && rm -rf nuttx-export-12.10.0 && tar xf nuttx-export-12.10.0.tar.gz && cd build && rm -rf * && cmake .. -DCMAKE_TOOLCHAIN_FILE=../nuttx-export-12.10.0/scripts/toolchain.cmake && make
zsh: sure you want to delete all 4 files in /home/thomas/nuttxspace/hellocpp/build [yn]? y
-- The C compiler identification is GNU 13.2.1
-- The CXX compiler identification is GNU 13.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/thomas/nuttxspace/hellocpp/build
[ 33%] Building CXX object CMakeFiles/hello.dir/HelloWorld.cpp.obj
[ 66%] Building CXX object CMakeFiles/hello.dir/main.cpp.obj
[100%] Linking CXX executable hello
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: warning: hello has a LOAD segment with RWX permissions
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libarch.a(stm32_start.o): in function `__start':
stm32_start.c:(.text.__start+0x46): undefined reference to `stm32_boardinitialize'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libarch.a(arm_doirq.o): in function `arm_doirq':
arm_doirq.c:(.text.arm_doirq+0x1a): undefined reference to `board_autoled_on'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: arm_doirq.c:(.text.arm_doirq+0x4a): undefined reference to `board_autoled_off'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libarch.a(arm_sigdeliver.o): in function `arm_sigdeliver':
arm_sigdeliver.c:(.text.arm_sigdeliver+0x8): undefined reference to `board_autoled_on'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: arm_sigdeliver.c:(.text.arm_sigdeliver+0x3a): undefined reference to `board_autoled_off'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libsched.a(nx_bringup.o): in function `nx_start_task':
nx_bringup.c:(.text.nx_start_task+0x8): undefined reference to `board_late_initialize'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libsched.a(assert.o): in function `reset_board':
assert.c:(.text.reset_board+0x4): undefined reference to `board_autoled_on'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: assert.c:(.text.reset_board+0x10): undefined reference to `board_autoled_off'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libsched.a(assert.o): in function `_assert':
assert.c:(.text._assert+0x92): undefined reference to `board_autoled_on'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libarch.a(stm32_allocateheap.o): in function `up_allocate_heap':
stm32_allocateheap.c:(.text.up_allocate_heap+0x8): undefined reference to `board_autoled_on'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libarch.a(arm_createstack.o): in function `up_create_stack':
arm_createstack.c:(.text.up_create_stack+0x2e): undefined reference to `board_autoled_on'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libarch.a(arm_initialize.o): in function `up_initialize':
arm_initialize.c:(.text.up_initialize+0x10): undefined reference to `board_autoled_on'
/home/thomas/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ld: /home/thomas/nuttxspace/hellocpp/nuttx-export-12.10.0/scripts/../libs/libboards.a(boardctl.o): in function `boardctl':
boardctl.c:(.text.boardctl+0x1e): undefined reference to `board_app_initialize'
Memory region Used Size Region Size %age Used
flash: 129672 B 1 MB 12.37%
sram: 5756 B 112 KB 5.02%
make[2]: *** [CMakeFiles/hello.dir/build.make:113: hello] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hello.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
```

Not sure if the expected behavior should be that the build should succeed even with Board common logic disabled, or the export should stub out these symbols appropriately to allow linking.

Note: if you run `make` before `make export` the symbols seem to be resolved which is a bit curious. This only occurs when i run make export directly after configuration. I seem to already have an old issue on this matter here https://github.com/apache/nuttx/issues/10388

### On which OS does this issue occur?

[OS: Linux]

### What is the version of your OS?

Ubuntu 24.04

### NuttX Version

master

### Issue Architecture

[Arch: all]

### Issue Area

[Area: Other]

### Host information

_No response_

### Verification

- [x] I have verified before submitting the report.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.