Skip to content

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

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

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

Conversation

@acassis
Copy link
Copy Markdown
Contributor

@acassis acassis commented May 24, 2026

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
gpio20
gpio21
gpio22
gpio23
gpio24
gpio25
gpio26
gpio27
loop
null
oneshot
ram0
ram1
ram2
zero

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

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

nsh> gpio -o 1 /dev/gpio27
Driver: /dev/gpio27
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/gpio27
Driver: /dev/gpio27
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
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
Copy link
Copy Markdown
Contributor Author

acassis commented May 24, 2026

@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
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>
acassis added 4 commits May 29, 2026 18:07
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>
Comment thread arch/sim/Kconfig
config SIM_FT2232H
bool "Support FT2232H USB bridge to control external devices"
default n
depends on ARCH_SIM
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.

remove

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.

Right, I will make FT2232H be a specialization of GPIOCHIP, so we will have choice to use Generic Linux GPIOv2 or FT2232H

Comment thread arch/sim/Kconfig

endif # SIM_CANDEV

config SIM_FT2232H
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.

should you group SIM_FT2232H and SIM_GPIOCHIP into choice?

* Public Function Prototypes
****************************************************************************/

struct host_ft2232h_gpio_dev *host_ft2232h_gpio_alloc(uint8_t pins_dir);
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.

why not share the host interface of SIM_GPIOCHIP? so we don't need add sim_ft2232h_gpio_initialize, but implement host_gpiochip_xxx instead.

* 0 for success, other for fail.
****************************************************************************/

int host_ft2232h_gpio_irq_request(struct host_ft2232h_gpio_dev *priv, uint8_t pin,
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.

merge to the first patch

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: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants