Skip to content

boards: Fix modbus configs after moving it to apps/industry#18744

Open
acassis wants to merge 1 commit intoapache:masterfrom
acassis:fix_modbus_loc
Open

boards: Fix modbus configs after moving it to apps/industry#18744
acassis wants to merge 1 commit intoapache:masterfrom
acassis:fix_modbus_loc

Conversation

@acassis
Copy link
Copy Markdown
Contributor

@acassis acassis commented Apr 15, 2026

Summary

The modbus was moved to inside apps/industry, so these defconfigs need to be updated

Impact

None, only organization

Testing

On NuttX board:

NuttShell (NSH) NuttX-12.13.0                                                     
nsh> uname -a                                                                     
NuttX 12.13.0 b5bb475d5f Apr 15 2026 10:46:51 arm stm32f401rc-rs485               
nsh> modbus -e

On Linux side:

$ mbpoll -a 10 -b 38400 -t 3 -r 1000 -c 4 /dev/ttyUSB1  -R
mbpoll 1.0-0 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright © 2015-2019 Pascal JEAN, https://github.com/epsilonrt/mbpoll
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'mbpoll -w' for details.

Protocol configuration: Modbus RTU
Slave configuration...: address = [10]
                        start reference = 1000, count = 4
Communication.........: /dev/ttyUSB1,      38400-8E1 
                        t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave 10... Ctrl-C to stop)
[1000]: 	44816 (-20720)
[1001]: 	0
[1002]: 	0
[1003]: 	0
-- Polling slave 10... Ctrl-C to stop)
[1000]: 	38771 (-26765)
[1001]: 	0
[1002]: 	0
[1003]: 	0
-- Polling slave 10... Ctrl-C to stop)
[1000]: 	17140
[1001]: 	0
[1002]: 	0
[1003]: 	0
-- Polling slave 10... Ctrl-C to stop)
[1000]: 	49449 (-16087)
[1001]: 	0
[1002]: 	0
[1003]: 	0
-- Polling slave 10... Ctrl-C to stop)
[1000]: 	11597
[1001]: 	0
[1002]: 	0
[1003]: 	0
-- Polling slave 10... Ctrl-C to stop)
[1000]: 	42530 (-23006)
[1001]: 	0
[1002]: 	0
[1003]: 	0
^C--- /dev/ttyUSB1 poll statistics ---
6 frames transmitted, 6 received, 0 errors, 0.0% frame loss

everything was closed.
Have a nice day !

@acassis acassis marked this pull request as draft April 15, 2026 12:59
@github-actions github-actions bot added Size: S The size of the change in this PR is small Board: arm Board: xtensa labels Apr 15, 2026
@acassis acassis marked this pull request as ready for review April 15, 2026 13:59
@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 15, 2026

It is funny, I was going to update the Documentation and discovery that is was already appointing to apps/industry/modbus: applications/examples/modbus/index.rst

No idea how it happened :-D

@acassis acassis requested review from anchao, cederom and linguini1 April 15, 2026 14:48
@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 15, 2026

It is funny, I was going to update the Documentation and discovery that is was already appointing to apps/industry/modbus: applications/examples/modbus/index.rst

No idea how it happened :-D

It is funny, I was going to update the Documentation and discovery that is was already appointing to apps/industry/modbus: applications/examples/modbus/index.rst

No idea how it happened :-D

Actually it was @raiden00pl who predicted that it was going to happen! :-D

@raiden00pl
Copy link
Copy Markdown
Member

@acassis I've had this on my TODO list for a long time :)

image

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 15, 2026

Hmm, I made a mistake: I renamed the CONFIG_INDUSTRY_MODBUS directly inside defconfig,:
$ ./tools/refresh.sh --silent esp32-devkitc:modbus
[1/1] Normalize esp32-devkitc:modbus
37a38,39

CONFIG_INDUSTRY_MODBUS=y
CONFIG_INDUSTRY_MODBUS_SLAVE=y
43,44d44
< CONFIG_INDUSTRY_MODBUS=y
< CONFIG_INDUSTRY_MODBUS_SLAVE=y
Saving the new configuration file

@cederom
Copy link
Copy Markdown
Contributor

cederom commented Apr 15, 2026

Hmm, I am wondering if INDUSTRY really needs to be part of the CONFIG_ variable? Other parts are located in various locations and they do not necessarily contain all location prefixes. I would remove this INDUSTRY part from a config name.

Instead, if we plan to have different modbus implementations we could use something like CONFIG_FREEMODBUS and CONFIG_FREEMODBUS_MASTER? That would be short and self-explanatory pointing at the modbus stack implementation right?

For other implementations we would then use CONFIG_OPENMODBUS_* or something like that? :-)

@raiden00pl
Copy link
Copy Markdown
Member

The problem with the current Kconfig is that we don't have any standardization for option names. Some programs/libs use one format, others another. The main (and probably the only disadvantage of INDUSTRY_MODBUS) is that the options become long, the advantage is that we have context added to the option name (like INDUSTRY). Personally, I would be in favor of the name INDUSTRY_FREEMODBUS, but it's a bit long.

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 16, 2026

Hmm, I am wondering if INDUSTRY really needs to be part of the CONFIG_ variable? Other parts are located in various locations and they do not necessarily contain all location prefixes. I would remove this INDUSTRY part from a config name.

Instead, if we plan to have different modbus implementations we could use something like CONFIG_FREEMODBUS and CONFIG_FREEMODBUS_MASTER? That would be short and self-explanatory pointing at the modbus stack implementation right?

For other implementations we would then use CONFIG_OPENMODBUS_* or something like that? :-)

@cederom keeping the INDUSTRY in the name is important to context, someone seem CONFIG_INDUSTRY_MODBUS will know he/she needs to look inside apps/industry/ to find it. Same is used in many places like apps/graphics, apps/testing, etc. In same places part of the sub-directories are suppressed (i.e. apps/testing/fs/smart)

I think if we find places where this convention is not used we need to fix it. But of course as @raiden00pl noticed, we need to avoid long names.

@cederom
Copy link
Copy Markdown
Contributor

cederom commented Apr 16, 2026

Up to you guys, just thinking aloud, fine for me with the industry included, but it may be good to name it freemodbus though if we plan differen modbus implementations? Thanks! :-)

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 16, 2026

@simbit18 @lupyuen any idea why the defconfig says it is not normalize, at least here I can see it is normalize:

alan@dev:~/nuttxspace/nuttx$ ./tools/refresh.sh --silent stm32f4discovery:modbus_slave
  [1/1] Normalize stm32f4discovery:modbus_slave
alan@dev:~/nuttxspace/nuttx$ git diff
alan@dev:~/nuttxspace/nuttx$

@simbit18
Copy link
Copy Markdown
Contributor

simbit18 commented Apr 16, 2026

Hi @acassis, try using the new tool

#18568

Set it up as follows:

Nuttx repository: acassis/incubator-nuttx
    Nuttx branch: fix_modbus_loc
 Apps repository: acassis/nuttx-apps
     Apps branch: master
    Architecture: all
   Host platform: linux

Workflow -> Manually build NuttX CI for test

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 16, 2026

Hi @acassis, try using the new tool

#18568

Set it up as follows:

Nuttx repository: acassis/incubator-nuttx
    Nuttx branch: fix_modbus_loc
 Apps repository: acassis/nuttx-apps
     Apps branch: master
    Architecture: all
   Host platform: linux

Workflow -> Manually build NuttX CI for test

Thank you @simbit18, but the original CI shouldn't report an error if the board are synced/normalized.
So, what could be the root cause of this issue in the first place?

@lupyuen
Copy link
Copy Markdown
Member

lupyuen commented Apr 16, 2026

@acassis I tested with Docker, refresh.sh seems to be working correctly: https://gist.github.com/lupyuen/a77be35dbcd40f959e2e4930d126963b

$ sudo docker run -it \
  ghcr.io/apache/nuttx/apache-nuttx-ci-linux:latest
# cd ; pwd ;
# git clone https://github.com/acassis/incubator-nuttx --branch fix_modbus_loc nuttx
# git clone https://github.com/apache/nuttx-apps apps ;
# cd nuttx
# ./tools/refresh.sh --silent stm32f4discovery:modbus_slave
  [1/1] Normalize stm32f4discovery:modbus_slave
9d8
< # CONFIG_MB_TCP_ENABLED is not set
32,33d30
< CONFIG_INDUSTRY_MODBUS=y
< CONFIG_INDUSTRY_MODBUS_SLAVE=y
Saving the new configuration file

# git diff
diff --git a/boards/arm/stm32/stm32f4discovery/configs/modbus_slave/defconfig b/boards/arm/stm32/
stm32f4discovery/configs/modbus_slave/defconfig
index 0eba5c05bc..e574e4de0b 100644
--- a/boards/arm/stm32/stm32f4discovery/configs/modbus_slave/defconfig
+++ b/boards/arm/stm32/stm32f4discovery/configs/modbus_slave/defconfig
@@ -6,7 +6,6 @@
 # modifications.
 #
 # CONFIG_ARCH_FPU is not set
-# CONFIG_MB_TCP_ENABLED is not set
 # CONFIG_NSH_ARGCAT is not set
 # CONFIG_NSH_CMDOPT_HEXDUMP is not set
 # CONFIG_NSH_DISABLE_MB is not set
@@ -29,8 +28,6 @@ CONFIG_EXAMPLES_MODBUS_PORT=1
 CONFIG_FS_PROCFS=y
 CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
-CONFIG_INDUSTRY_MODBUS=y
-CONFIG_INDUSTRY_MODBUS_SLAVE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LINE_MAX=64

Update: refresh.sh also works OK on macOS and Ubuntu. Is there something special about your PC?

Or maybe you're using a different NuttX Apps repo?

git clone https://github.com/apache/nuttx-apps apps

@simbit18
Copy link
Copy Markdown
Contributor

simbit18 commented Apr 17, 2026

Hi @acassis, I hope to explain below why we came up with this new system

#18568

and why I advised you to take a test.

The NuttX source code here includes the changes made to defconfig
The Apps source code here does not include the change to the path for industry/modbus

The NuttX source here does not includes defconfig changes
The Apps source here include the change to the path for industry/modbus

The NuttX source code here includes the changes made to defconfig
The Apps source here include the change to the path for industry/modbus

When a change affects the PRs in both repositories, it is very difficult for NuttX maintainers to check whether those changes might cause problems after merging.

This new system helps us to verify that the build at least doesn’t break anything.

Results of the test I carried out
error here

====================================================================================
Configuration/Tool: linum-stm32h753bi/modbus_master,CONFIG_ARM_TOOLCHAIN_CLANG
2026-04-17 10:03:44
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_CLANG
  Building NuttX...
ld.lld: error: undefined symbol: eMBMasterReqReadHoldingRegister
>>> referenced by mbmaster_main.c:312 (/github/workspace/sources/apps/examples/modbusmaster/mbmaster_main.c:312)
>>>               mbmaster_main.c.github.workspace.sources.apps.examples.modbusmaster_1.o:(mbmaster_main) in archive /github/workspace/sources/nuttx/staging/libapps.a
ld.lld: error: undefined symbol: eMBMasterInit
>>> referenced by mbmaster_main.c:138 (/github/workspace/sources/apps/examples/modbusmaster/mbmaster_main.c:138)
>>>               mbmaster_main.c.github.workspace.sources.apps.examples.modbusmaster_1.o:(mbmaster_initialize) in archive /github/workspace/sources/nuttx/staging/libapps.a
ld.lld: error: undefined symbol: eMBMasterEnable
>>> referenced by mbmaster_main.c:149 (/github/workspace/sources/apps/examples/modbusmaster/mbmaster_main.c:149)
>>>               mbmaster_main.c.github.workspace.sources.apps.examples.modbusmaster_1.o:(mbmaster_initialize) in archive /github/workspace/sources/nuttx/staging/libapps.a
ld.lld: error: undefined symbol: eMBMasterPoll
>>> referenced by mbmaster_main.c:195 (/github/workspace/sources/apps/examples/modbusmaster/mbmaster_main.c:195)
>>>               mbmaster_main.c.github.workspace.sources.apps.examples.modbusmaster_1.o:(mbmaster_pollthread) in archive /github/workspace/sources/nuttx/staging/libapps.a
ld.lld: error: undefined symbol: eMBMasterDisable
>>> referenced by mbmaster_main.c:172 (/github/workspace/sources/apps/examples/modbusmaster/mbmaster_main.c:172)
>>>               mbmaster_main.c.github.workspace.sources.apps.examples.modbusmaster_1.o:(mbmaster_deinitialize) in archive /github/workspace/sources/nuttx/staging/libapps.a
ld.lld: error: undefined symbol: eMBMasterClose
>>> referenced by mbmaster_main.c:176 (/github/workspace/sources/apps/examples/modbusmaster/mbmaster_main.c:176)
>>>               mbmaster_main.c.github.workspace.sources.apps.examples.modbusmaster_1.o:(mbmaster_deinitialize) in archive /github/workspace/sources/nuttx/staging/libapps.a
make[1]: *** [Makefile:226: nuttx] Error 1
make: *** [tools/Unix.mk:568: nuttx] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize linum-stm32h753bi/modbus_master
On branch fix_modbus_loc
Your branch is up to date with 'origin/fix_modbus_loc'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	boards/arm/stm32h7/linum-stm32h753bi/scripts/flash.ld.tmp
nothing added to commit but untracked files present (use "git add" to track)
====================================================================================

Linux (arm-13)
https://github.com/simbit18/manual-nuttx-ci/actions/runs/24523935870

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 17, 2026

Thank you very much @lupyuen and @simbit18
I synced my nuttx-apps again with mainline, do I need to force a new git push here to make the CI use the new nuttx-apps HEAD ?

@simbit18
Copy link
Copy Markdown
Contributor

simbit18 commented Apr 17, 2026

Hi @acassis Have you tested this build linum-stm32h753bi:modbus_master?

The modbus was moved to inside apps/industry, so these defconfigs
need to be updated

Signed-off-by: Alan C. Assis <acassis@gmail.com>
@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 17, 2026

Hi @acassis Have you tested this build linum-stm32h753bi:modbus_master?

I tested again and fixed the issue, some Kconfigs were missing, thank you for your help!

@cederom
Copy link
Copy Markdown
Contributor

cederom commented Apr 17, 2026

@acassis do we want the CONFIG_INDUSTRY_FREEMODBUS? :-)

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 17, 2026

@acassis do we want the CONFIG_INDUSTRY_FREEMODBUS? :-)

I think if in the future we get a new MODBUS library we can change the name. For now we only have a unique modbus lib. :-)

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 17, 2026

@acassis do we want the CONFIG_INDUSTRY_FREEMODBUS? :-)

I think if in the future we get a new MODBUS library we can change the name. For now we only have a unique modbus lib. :-)

whoa!!! Things happen fast on NuttX :-D

Copy link
Copy Markdown
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, lets go with this one, next lets update to freemodbus as nxmodbus showed up for review here github.com/apache/nuttx-apps/pull/3459 :-)

Copy link
Copy Markdown
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, some ci build fails at xtensa :-(

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 19, 2026

oops, some ci build fails at xtensa :-(

Strange, the config seems normalized:

alan@dev:~/nuttxspace/nuttx$ ./tools/refresh.sh --silent esp32-devkitc:modbus
  [1/1] Normalize esp32-devkitc:modbus
alan@dev:~/nuttxspace/nuttx$ git diff
alan@dev:~/nuttxspace/nuttx$ 

@cederom
Copy link
Copy Markdown
Contributor

cederom commented Apr 19, 2026

Yup, CI seems broken, the same here #18730, I will play with modbus on this board :-)

Maybe this fix from Lup will help #18763 its already merged :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: arm Board: xtensa Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants