Skip to content

sim/ft2232h: Add FT2232H GPIO integration on NuttX sim#18951

Open
acassis wants to merge 3 commits into
apache:masterfrom
acassis:sim_ft2232h
Open

sim/ft2232h: Add FT2232H GPIO integration on NuttX sim#18951
acassis wants to merge 3 commits into
apache:masterfrom
acassis:sim_ft2232h

Conversation

@acassis

@acassis acassis commented May 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This driver implements a FT2232H GPIO integration NuttX sim to allow users to read/write external GPIOs and control external devices.
It will help to control external devices using NuttX sim.

The next steps will be adding SPI and I2C integration support.

Impact

User will be able to use a FT2232H module to read/write external GPIO

Testing

nsh> ls /dev
/dev:
console
gpio60
gpio61
gpio62
gpio63
gpio64
gpio65
gpio66
gpio67
loop
null
oneshot
ram0
ram1
ram2
zero

nsh> gpio /dev/gpio60
Driver: /dev/gpio60
gplh_read: pin0: value=0x7fa69b5d4117
Output pin: Value=0

nsh> gpio /dev/gpio60
Driver: /dev/gpio60
gplh_read: pin0: value=0x7fa69b5d4117
Output pin: Value=1

nsh> gpio -o 1 /dev/gpio67
Driver: /dev/gpio67
gplh_read: pin7: value=0x7fa69b5d4117
Output pin: Value=0
Writing: Value=1
gplh_write: pin7: value=1
gplh_read: pin7: value=0x7fa69b5d4117
Verify: Value=1

nsh> gpio -o 0 /dev/gpio67
Driver: /dev/gpio67
gplh_read: pin7: value=0x7fa69b5d4117
Output pin: Value=1
Writing: Value=0
gplh_write: pin7: value=0
gplh_read: pin7: value=0x7fa69b5d4117
Verify: Value=1
nsh>

@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: simulator Issues related to the SIMulator Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: simulator labels May 24, 2026
linguini1
linguini1 previously approved these changes May 24, 2026
Comment thread Documentation/platforms/sim/sim_ft2232h_gpio.rst Outdated
Comment thread Documentation/platforms/sim/sim_ft2232h_gpio.rst Outdated
@acassis acassis force-pushed the sim_ft2232h branch 2 times, most recently from 1e68630 to 0c68d8c Compare May 24, 2026 20:23
linguini1
linguini1 previously approved these changes May 24, 2026
@acassis

acassis commented May 24, 2026

Copy link
Copy Markdown
Contributor Author

@simbit18 is it possible to install libftdio-dev to get FT2232H integration passing on CI?

No package 'libftdi1' found
./sim/posix/sim_ft2232h.c:40:10: fatal error: ftdi.h: No such file or directory
   40 | #include <ftdi.h>
      |          ^~~~~~~~
compilation terminated.
ERROR: cc failed: 1
       command: cc -MT ./sim_ft2232h.o  -M '-g' '-fomit-frame-pointer' '-fprofile-arcs' '-ftest-coverage' '-fno-inline' '-fno-common' '-fvisibility=hidden' '-ffunction-sections' '-fdata-sections' '-Wall' '-Wstrict-prototypes' '-Wshadow' '-Wundef' '-Wno-attributes' '-Wno-unknown-pragmas' '-fno-pic' '-mcmodel=medium' '-no-pie' '-D__KERNEL__' '-Wno-cpp' '-Werror' '-D__SIM__' '-fvisibility=default' '-I' '/github/workspace/sources/nuttx/arch/sim/src' '-I' '/github/workspace/sources/nuttx/arch/sim/src/chip' ./sim/posix/sim_ft2232h.c
make[2]: *** [Makefile:546: sim_ft2232h.ddh] Error 1

Comment thread arch/sim/src/sim/sim_internal.h Outdated
acassis added a commit that referenced this pull request May 29, 2026
This commit is needed to get PR #18951 passing on CI test.
I think this USB Device could be used in the future to do
real hardware tests, including automated tests on our CI.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Comment thread arch/sim/Kconfig Outdated
Comment thread arch/sim/Kconfig Outdated
Comment thread arch/sim/src/sim/sim_ft2232h_ioexpander.h Outdated
Comment thread arch/sim/src/sim/posix/sim_ft2232h.c Outdated
@acassis acassis force-pushed the sim_ft2232h branch 2 times, most recently from 2b03469 to 7db2a5e Compare June 14, 2026 14:20
@acassis

acassis commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 PTAL

Comment thread arch/sim/Kconfig Outdated
Comment thread arch/sim/src/sim/sim_gpiochip.h Outdated
Comment thread arch/sim/src/sim/sim_ft2232h_ioexpander.h Outdated
Comment thread arch/sim/src/sim/sim_ft2232h_ioexpander.c Outdated
Comment thread arch/sim/src/sim/posix/sim_ft2232h.c Outdated
Comment thread arch/sim/Kconfig Outdated
@github-actions github-actions Bot added Size: M The size of the change in this PR is medium and removed Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Jun 14, 2026
@github-actions github-actions Bot added Size: L The size of the change in this PR is large and removed Size: M The size of the change in this PR is medium labels Jun 14, 2026
Comment thread arch/sim/src/sim/posix/sim_ftdi_gpiochip.c Outdated
Comment thread arch/sim/src/sim/posix/sim_ftdi_gpiochip.c Outdated
Comment thread arch/sim/src/sim/posix/sim_ftdi_gpiochip.c Outdated
Comment thread arch/sim/src/sim/posix/sim_ftdi_gpiochip.c Outdated
Comment thread arch/sim/src/sim/sim_internal.h
Comment thread arch/sim/src/sim/posix/sim_ftdi_gpiochip.h Outdated
Comment thread arch/sim/src/sim/posix/sim_ftdi_gpiochip.h Outdated
Comment thread arch/sim/src/sim/posix/sim_linux_gpiochip.h Outdated
acassis added 3 commits June 15, 2026 08:51
This patch adds support to use FT2232H as GPIO to control external
devices.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
This commit add documentation to explain about the FT2232H integration
on NuttX.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
This board profile configure the FT2232H module to use as a GPIO
to NuttX sim.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
uint8_t port_value;
};

#define gpioerr(fmt, ...) \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move to preprocess section

@@ -45,6 +45,18 @@
* Pre-processor Definitions
****************************************************************************/

/****************************************************************************

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move after line 67 and remove the dup banner

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you @xiaoxiang781216
The banners are not duplicated: Type Definitions and Private Types

I think we could remove all those Private * since they are not used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The banners are not duplicated: Type Definitions and Private Types.

If you want I can remove those Privates* since they are empty.

@acassis

acassis commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

I will add this board config to the blacklist, even after installing the libftdi1-dev in the docker image the CI still failing to find it:

====================================================================================
Configuration/Tool: sim/ft2232h_gpio
2026-06-15 12:08:43

Cleaning...
Configuring...
Building NuttX...
Package libftdi1 was not found in the pkg-config search path.
Perhaps you should add the directory containing libftdi1.pc' to the PKG_CONFIG_PATH environment variable No package 'libftdi1' found Package libftdi1 was not found in the pkg-config search path. Perhaps you should add the directory containing libftdi1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libftdi1' found
Package libftdi1 was not found in the pkg-config search path.
Perhaps you should add the directory containing libftdi1.pc' to the PKG_CONFIG_PATH environment variable No package 'libftdi1' found Package libftdi1 was not found in the pkg-config search path. Perhaps you should add the directory containing libftdi1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libftdi1' found
Package libftdi1 was not found in the pkg-config search path.
Perhaps you should add the directory containing libftdi1.pc' to the PKG_CONFIG_PATH environment variable No package 'libftdi1' found Package libftdi1 was not found in the pkg-config search path. Perhaps you should add the directory containing libftdi1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libftdi1' found
Package libftdi1 was not found in the pkg-config search path.
Perhaps you should add the directory containing libftdi1.pc' to the PKG_CONFIG_PATH environment variable No package 'libftdi1' found Package libftdi1 was not found in the pkg-config search path. Perhaps you should add the directory containing libftdi1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libftdi1' found
Package libftdi1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libftdi1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libftdi1' found
./sim/posix/sim_ftdi_gpiochip.c:40:10: fatal error: ftdi.h: No such file or directory
40 | #include <ftdi.h>
| ^~~~~~~~
compilation terminated.
ERROR: cc failed: 1
command: cc -MT ./sim_ftdi_gpiochip.o -M '-g' '-fomit-frame-pointer' '-fprofile-arcs' '-ftest-coverage' '-fno-inline' '-fno-common' '-fvisibility=hidden' '-ffunction-sections' '-fdata-sections' '-Wall' '-Wstrict-prototypes' '-Wshadow' '-Wundef' '-Wno-attributes' '-Wno-unknown-pragmas' '-fno-pic' '-mcmodel=medium' '-no-pie' '-D__KERNEL__' '-Wno-cpp' '-Werror' '-D__SIM__' '-fvisibility=default' '-I' '/github/workspace/sources/nuttx/arch/sim/src' '-I' '/github/workspace/sources/nuttx/arch/sim/src/chip' ./sim/posix/sim_ftdi_gpiochip.c
make[2]: *** [Makefile:546: sim_ftdi_gpiochip.ddh] Error 1
make[2]: Target 'makedepfile' not remade because of errors.
make[1]: *** [Makefile:554: .depend] Error 2
make[1]: Target 'depend' not remade because of errors.
make: *** [tools/Unix.mk:679: pass2dep] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 397: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
[1/1] Normalize sim/ft2232h_gpio
HEAD detached at pull/18951/merge
Untracked files:
(use "git add ..." to include in what will be committed)
arch/sim/src/sim_errno.ddh
arch/sim/src/sim_ftdi_gpiochip.ddh
arch/sim/src/sim_hostfs.ddh
arch/sim/src/sim_hostirq.ddh
arch/sim/src/sim_hostmemory.ddh
arch/sim/src/sim_hostmisc.ddh
arch/sim/src/sim_hostsmp.ddh
arch/sim/src/sim_hosttime.ddh
arch/sim/src/sim_hostuart.ddh

nothing added to commit but untracked files present (use "git add" to track)
/github/workspace/sources/nuttx /github/workspace/sources/nuttx
HEAD detached at pull/18951/merge
nothing to commit, working tree clean
/github/workspace/sources/nuttx
/github/workspace/sources/apps /github/workspace/sources/nuttx
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
/github/workspace/sources/nuttx
Build Attempt 1 of 1

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

Labels

Arch: simulator Issues related to the SIMulator Area: Documentation Improvements or additions to documentation Board: simulator Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants