linguini1 opened a new pull request, #17011:
URL: https://github.com/apache/nuttx/pull/17011
## Summary
To resolve #17004, this commit sets the default Kconfig value for
`CONFIG_BOARD_LOOPSPERMSEC` as -1, which is invalid. It statically asserts at
compile time that the value is greater than or equal to 0 so that the user is
notified if their board/configuration does not yet have a calibrated value for
this configuration option. The user is directed to set a non-negative value and
then later calibrate with `calib_udelay`.
## Impact
Users will no longer waste time debugging issues that result from having an
incorrect value of this configuration option, causing delay/timing issues.
This will affect any user-created defconfig (or NuttX provided defconfig)
without a value set for `CONFIG_BOARD_LOOPSPERMSEC` by preventing them from
compiling. As such, please advise me if this is to be considered a breaking
change.
FYI, I have used `static_assert` to achieve the compilation error here since
it is defined in the NuttX implementation of `assert.h` and it is used
elsewhere within the codebase, so I assume it is safe for the toolchains used
in NuttX.
## Testing
Testing was performed by compiling the `raspberrypi-4b:nsh` configuration
with different values. Testing was done using the `gcc` compiler.
Compiling with CONFIG_BOARD_LOOPSPERMSEC set to 106645:
```console
$ make -j
Create version.h
CPP:
/home/linguini/coding/nuttx-space/nuttx/boards/arm64/bcm2711/raspberrypi-4b/scripts/dramboot.ld->
/home/linguini/coding/nuttx-space/nuttx/boards/arm64/bLD: nuttx
Memory region Used Size Region Size %age Used
CP: nuttx.hex
CP: nuttx.bin
Generating config.txt
```
Compiling with `CONFIG_BOARD_LOOPSPERMSEC` set to the default value of -1:
```console
$ make -j
Create version.h
LN: platform/board to /home/linguini/coding/nuttx-space/apps/platform/dummy
Register: leds
Register: nsh
Register: sh
Register: dd
Register: uorb_listener
Register: getprime
Register: ostest
Register: bmp280
Register: hello
Register: calib_udelay
Register: i2c
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/pthread.h:32,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/sched.h:37,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:89,
from clock/clock_systime_ticks.c:32:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from clock/clock_systime_timespec.c:31:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/pthread.h:32,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/sched.h:37,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:89,
from clock/clock_perf.c:29:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/fs/fs.h:46,
from
/home/linguini/coding/nuttx-space/nuttx/include/stdio.h:36,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/streams.h:35,
from
/home/linguini/coding/nuttx-space/nuttx/include/debug.h:32,
from clock/clock_initialize.c:33:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from clock/clock_gettime.c:31:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from environ/env_clearenv.c:33:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:64: clock_systime_ticks.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:64: clock_systime_timespec.o] Error 1
make[1]: *** [Makefile:64: clock_perf.o] Error 1
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/fs/fs.h:46,
from
/home/linguini/coding/nuttx-space/nuttx/include/stdio.h:36,
from environ/env_setenv.c:31:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/pthread.h:32,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/sched.h:37,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:89,
from
/home/linguini/coding/nuttx-space/nuttx/sched/sched/sched.h:36,
from environ/env_getenv.c:36:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:64: clock_initialize.o] Error 1
make[1]: *** [Makefile:64: clock_gettime.o] Error 1
In file included from clock/clock_settime.c:30:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
CC: group/group_leave.c make[1]: *** [Makefile:64: clock_settime.o] Error 1
make[1]: *** [Makefile:64: env_clearenv.o] Error 1
make[1]: *** [Makefile:64: env_setenv.o] Error 1
make[1]: *** [Makefile:64: env_getenv.o] Error 1
In file included from environ/env_unsetenv.c:33:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:64: env_unsetenv.o] Error 1
In file included from environ/env_dup.c:34:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from group/group_join.c:30:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/pthread.h:32,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/sched.h:37,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:89,
from
/home/linguini/coding/nuttx-space/nuttx/sched/sched/sched.h:36,
from environ/env_getenvironptr.c:33:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:64: env_dup.o] Error 1
make[1]: *** [Makefile:64: group_join.o] Error 1
In file included from group/group_create.c:30:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from group/group_leave.c:30:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:64: env_getenvironptr.o] Error 1
make[1]: *** [Makefile:64: group_create.o] Error 1
make[1]: *** [Makefile:64: group_leave.o] Error 1
make: *** [tools/LibTargets.mk:71: sched/libsched.a] Error 2
make: *** Waiting for unfinished jobs....
CC: syslog/syslog_initialize.c In file included from pipes/pipe_common.c:40:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
CC: syslog/ramlog.c make[1]: *** [Makefile:109: pipe_common.o] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/fs/fs.h:46,
from
/home/linguini/coding/nuttx-space/nuttx/include/stdio.h:36,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/streams.h:35,
from
/home/linguini/coding/nuttx-space/nuttx/include/debug.h:32,
from sensors/bmp280_uorb.c:33:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/pthread.h:32,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/sched.h:37,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/note/note_driver.h:34,
from drivers_initialize.c:40:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:109: bmp280_uorb.o] Error 1
make[1]: *** [Makefile:109: drivers_initialize.o] Error 1
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/fs/fs.h:46,
from
/home/linguini/coding/nuttx-space/nuttx/include/stdio.h:36,
from syslog/vsyslog.c:29:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:109: vsyslog.o] Error 1
In file included from syslog/syslog_channel.c:30:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
In file included from serial/serial.c:39:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:109: syslog_channel.o] Error 1
In file included from syslog/syslog_write.c:30:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:109: serial.o] Error 1
In file included from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/mutex.h:30,
from
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/fs/fs.h:46,
from
/home/linguini/coding/nuttx-space/nuttx/include/stdio.h:36,
from syslog/ramlog.c:32:
/home/linguini/coding/nuttx-space/nuttx/include/nuttx/arch.h:106:1: error:
static assertion failed: "Please set a non-negative value for
CONFIG_BOARD_LOOPSPERMSEC to pass compilation. It is recommended that after
your initial build, you use the example \'calib_udelay\' to get a precise value
for this option. Please search the NuttX documentation for
CONFIG_BOARD_LOOPSPERMSEC for more information."
106 | static_assert(
| ^~~~~~~~~~~~~
make[1]: *** [Makefile:109: syslog_write.o] Error 1
make[1]: *** [Makefile:109: ramlog.o] Error 1
make: *** [tools/LibTargets.mk:107: drivers/libdrivers.a] Error 2
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]