openthread / ot-br-posix

OpenThread Border Router, a Thread border router for POSIX-based platforms.
https://openthread.io/
BSD 3-Clause "New" or "Revised" License
420 stars 233 forks source link

ConfigFile() at config_file.cpp:50: Failure #2445

Open MaikVermeulen opened 2 months ago

MaikVermeulen commented 2 months ago

Describe the issue

We're using the Yocto Scarthgap ot-br-posix recipe to include it in our image. It references commit a35cc682305bb2201c314472adf06a4960536750 from this repository.

It builds successfully but does not run unfortunately:

systemd[1]: Started OpenThread Border Router Agent.
otbr-agent[2680]: 49d.17:17:20.280 [C] Platform------: ConfigFile() at config_file.cpp:50: Failure
systemd[1]: otbr-agent.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: otbr-agent.service: Failed with result 'exit-code'.

Which I believe tracks here, however I'm not sure what's causing the issue. We also tried running gdb, but no luck:

(gdb) run
Starting program: /usr/sbin/otbr-agent -I wpan0 -B eth0 spinel+hdlc+uart:///dev/ttyACM0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[Inferior 1 (process 1587) exited with code 01]
(gdb) backtrace
No stack.

Any ideas to solve this 🙂? Are we just not using it correctly?

zhanglongxia commented 2 months ago

It because the length of the config file path exceed kFileNameMaxSize. There are two options to resolve this issue: <1> Try to reduce the length of the config file path. <2> Change the code to update the kFileNameMaxSize to a larger value.

MaikVermeulen commented 2 months ago

Thanks @zhanglongxia, with your patch indeed it starts up just fine.

For clarity, which config file(s) does this apply to? A quick google search mainly shows compile/build-time files, but I assume the issue we faced here is runtime?

zhanglongxia commented 2 months ago

The configuration file is mainly used to configure the Thread radio power calibration parameters. Users should prepare a configuration file and set the OPENTHREAD_POSIX_CONFIG_FACTORY_CONFIG_FILE and OPENTHREAD_POSIX_CONFIG_PRODUCT_CONFIG_FILE to the path of the configuration file before running the otbr-agent. OpenThread uses the configuration file openthread.conf.example by default. If users do not need to configure power calibration parameters, they can just set the OPENTHREAD_POSIX_CONFIG_CONFIGURATION_FILE_ENABLE to 0 to disable using the configuration file.