Out-of-tree custom board example missing from documentation
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
After spending considerably long time trying to use `CONFIG_ARCH_BOARD_CUSTOM` I was still not able to.
There is either a bug or it is difficult to use.
## Setup
With following directory structure
```
/base
/nuttx (incubator-nuttx)
/apps (incubator-nuttx-apps)
/board (empty folder)
```
```
cd base/nuttx ; ./tools/configure.sh hymini-stm32v:nsh2
```
Builds and runs.
Then I am trying to use `CONFIG_ARCH_BOARD_CUSTOM` functionality, with `hymini-stm32v:nsh2`, by making a copy of it and trying to build NuttX with the copy. This particular board is just an example.
## First attempt
Copied content of https://github.com/apache/incubator-nuttx/tree/master/boards/arm/stm32/hymini-stm32v into `/board`.
Using `make menuconfig` selected
```
CONFIG_ARCH_BOARD_CUSTOM=y
CONFIG_ARCH_BOARD_CUSTOM_NAME=custom-board # description says it is not relevant
CONFIG_ARCH_BOARD_CUSTOM_DIR=../../board
CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y
```
Issues at this step:
1) If I specify `CONFIG_ARCH_BOARD_CUSTOM_DIR` wrongly, it is not possible to run `make menuconfig` anymore.
2) If I specify correctly, it is not building.
```
make[2]: Entering directory '/home/user/dev/project/board/src'
make[2]: *** No rule to make target 'libboard.a'. Stop.
make[2]: Leaving directory '/home/user/dev/project/board/src'
make[1]: *** [Makefile:168: board/libboard.a] Error 2
make[1]: Leaving directory '/home/user/dev/project/base/nuttx/arch/arm/src'
make: *** [tools/Makefile.unix:423: nuttx] Error 2
```
## Second attempt
I guess `tools/configure.sh` should be used for this somehow
```
tools/configure.sh -h # doesn't give any related help
USAGE: tools/configure.sh [-E] [-e] [-l|m|c|g|n] [L] [-a ] : [make-opts]
Where:
-E enforces distclean if already configured.
-e performs distclean if configuration changed.
-l selects the Linux (l) host environment.
-m selects the macOS (m) host environment.
-c selects the Windows host and Cygwin (c) environment.
-g selects the Windows host and MinGW/MSYS environment.
-n selects the Windows host and Windows native (n) environment.
Default: Use host setup in the defconfig file
Default Windows: Cygwin
-L Lists all available configurations.
-a is the path to the apps/ directory, relative to the nuttx
directory
is the name of the board in the boards directory
configs/ is the name of the board configuration sub-directory
make-opts directly pass to make
```
Analysing mailing lists and the script I found that relative path can be used as parameter, but not sure how exactly, so a bit of guessing is involved
```
tools/configure.sh ../../board
File Make.defs could not be found
tools/configure.sh ../../board:nsh2
Directory for ../../board:nsh2 does not exist.
# This runs, but it is not consistent with normal usage of this command and absent from help or documentation
tools/configure.sh ../../board/configs/nsh2
```
It builds, but it just configures `hymini-stm32v:nsh2` as far as I can tell.
So I am changing `defconfig` in the copy (`/board`) before running `configure.sh` again
`/board/configs/nsh2/defconfig`
```diff
-CONFIG_ARCH_BOARD="hymini-stm32v"
-CONFIG_ARCH_BOARD_HYMINI_STM32V=y
+CONFIG_ARCH_BOARD_CUSTOM=y
+CONFIG_ARCH_BOARD_CUSTOM_NAME="custom-board"
+CONFIG_ARCH_BOARD_CUSTOM_DIR="../../board"
+CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y
```
```
make distclean
tools/configure.sh ../../board/configs/nsh2
```
These configuration variables can be found in the mailing list, this is why I am trying to use them. But the project is not building afterwards.
```
make[2]: Nothing to be done for 'clean_context'.
make[2]: Leaving directory '/home/user/dev/project/base/nuttx/arch/arm/src'
make[1]: Leaving directory '/home/user/dev/project/base/nuttx/tools'
make[1]: Leaving directory '/home/user/dev/project/base/nuttx'
Create version.h
LN: include/arch to arch/arm/include
LN: arch/arm/src/board to /home/user/dev/project/base/nuttx//src
LN: arch/arm/src/chip to arch/arm/src/stm32
LN: /home/user/dev/project/base/nuttx/drivers/platform to /home/user/dev/project/base/nuttx/drivers/dummy
No directory at /home/user/dev/project/base/nuttx//src
make: *** [tools/Makefile.unix:293: arch/arm/src/board] Error 1
```
## Conclusion
This functionality is difficult to use.
A receipe is missing from documentation.
I am not sure what I am missing, analysed Makefiles a bit and searched through different mailing lists of NuttX trying some solutions present there, but it doesn't help me solve this. It would be great if it would be easier. Recipe in the documentation would help a lot.
Reading this doesn't help much
- https://nuttx.apache.org/docs/latest/quickstart/organization.html#boardsdirectorystructure
- https://cwiki.apache.org/confluence/display/NUTTX/Platform+Directories
- [mail-archives](http://mail-archives.apache.org/mod_mbox/nuttx-dev/202008.mbox/<066c01d6704f$68bc0c50$3a3424f0$@gmail.com>)
Articles above provide information about links that build system creates, but these links seem to be fine, pointing to external `/board` directory.
If **you** are using this logic, could you provide a short example how it should be used?
Then I think it should be included in documentation.
## Appendix
```
$ tools/configure.sh -e ../../board/configs/nsh2 | grep -E "^LN:"
LN: include/arch to arch/arm/include
LN: include/arch/board to /home/user/dev/project/base/nuttx/../../board/include
LN: include/arch/chip to arch/arm/include/stm32
LN: arch/arm/src/board to /home/user/dev/project/base/nuttx/../../board/src
LN: arch/arm/src/chip to arch/arm/src/stm32
LN: /home/user/dev/project/base/nuttx/drivers/platform to /home/user/dev/project/base/nuttx/drivers/dummy
LN: platform/board to /home/user/dev/project/base/apps/platform/dummy
```
Using `master` branch.
Contributor guide
Assessment
This issue has not been assessed yet.