Skip to content

Conversation

@yezhonghui2024
Copy link
Contributor

@yezhonghui2024 yezhonghui2024 commented Dec 29, 2025

Note: Please adhere to Contributing Guidelines.

Summary

add gpiochip in sim platform

Impact

sim can access host gpiochip hardware via sim gpiochip driver

Testing

prepare:

  1. need a ch341A usb module(CH341A USB to SPI I2C Serial Adapter Module - Programmer/Converter)

  2. host driver reference open source driver
    https://github.com/frank-zago/ch341-i2c-spi-gpio;make and install ko
    sudo insmod ch341-core.ko
    sudo insmod gpio-ch341.ko
    sudo insmod i2c-ch341.ko
    sudo insmod spi-ch341.ko

  3. ls /dev check /dev/gpiochipX exist

4.CONFIG_SIM_GPIOCHIP=y
CONFIG_SIM_GPIOCHIP_NAME="/dev/gpiochipX"

  1. Result Test
    [ 73.170835] [61] [ INFO] [ap] [==========] tests: Running 4 test(s).
    [ 73.170856] [61] [ INFO] [ap] [ RUN ] drivertest_gpio_bool
    [ 73.171065] [61] [ INFO] [ap] [ OK ] drivertest_gpio_bool
    [ 73.171076] [61] [ INFO] [ap] [ RUN ] drivertest_gpio_loop
    [ 73.171114] [61] [ INFO] [ap] [ OK ] drivertest_gpio_loop
    [ 73.171118] [61] [ INFO] [ap] [ RUN ] drivertest_gpio_rw
    [ 73.171243] [61] [ INFO] [ap] [ OK ] drivertest_gpio_rw
    [ 73.171247] [61] [ INFO] [ap] [ RUN ] drivertest_gpio_interrupt
    [ 75.542250] [61] [ INFO] [ap] [ OK ] drivertest_gpio_interrupt
    [ 75.542270] [61] [ INFO] [ap] [==========] tests: 4 test(s) run.
    [ 75.542275] [61] [ INFO] [ap] [ PASSED ] 4 test(s).

@github-actions github-actions bot added Arch: simulator Issues related to the SIMulator Area: Drivers Drivers issues Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Dec 29, 2025
Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

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

@yezhonghui2024 Please include Documentation explaining how to test it. Please include the host commands as well

Donny9
Donny9 previously approved these changes Dec 30, 2025
@yezhonghui2024
Copy link
Contributor Author

yezhonghui2024 commented Dec 30, 2025

@yezhonghui2024 Please include Documentation explaining how to test it. Please include the host commands as well

The relevant commands for the host side, and test procedures test results have been supplemented. @acassis

@acassis
Copy link
Contributor

acassis commented Dec 30, 2025

@yezhonghui2024 thank you, but I mean in the Documentation/

image

New features require Documentation, otherwise users will not know how to use it and it will become another hidden features (NuttX has a lot of it)

@github-actions github-actions bot added the Area: Documentation Improvements or additions to documentation label Dec 30, 2025
@yezhonghui2024
Copy link
Contributor Author

@yezhonghui2024 thank you, but I mean in the Documentation/

image New features require Documentation, otherwise users will not know how to use it and it will become another hidden features (NuttX has a lot of it)

okay,I got. nuttx/Documentation/components/drivers/special/sim_gpiochip.rst add @acassis

@acassis
Copy link
Contributor

acassis commented Dec 30, 2025

@yezhonghui2024 your Documentation is excellent! Really detailed, this is the kind of Documentation we need on NuttX.

Please also add later the host prepare steps you added here in the summary.

It could be inside a new sim:gpiochip board profile example Documentation/, so please submit the gpiochip board profile that you used for testing. This way someone willing to test it will just run:

$ ./tools/configure.sh sim:gpiochip

and follow the testing steps from Documentation.

@yezhonghui2024
Copy link
Contributor Author

@yezhonghui2024 your Documentation is excellent! Really detailed, this is the kind of Documentation we need on NuttX.

Please also add later the host prepare steps you added here in the summary.

It could be inside a new sim:gpiochip board profile example Documentation/, so please submit the gpiochip board profile that you used for testing. This way someone willing to test it will just run:

$ ./tools/configure.sh sim:gpiochip

and follow the testing steps from Documentation.

In test section, I add the host prepare steps already,it need a CH341A USB to SPI I2C Serial Adapter Module - Programmer/Converter and I support host drivers source. I don't see any meaningful advantages in introducing a sim:gpiochip board

@yezhonghui2024 yezhonghui2024 force-pushed the sim-gpio branch 2 times, most recently from bbc45bf to 30b1be9 Compare December 31, 2025 08:03
@acassis
Copy link
Contributor

acassis commented Dec 31, 2025

@yezhonghui2024 your Documentation is excellent! Really detailed, this is the kind of Documentation we need on NuttX.
Please also add later the host prepare steps you added here in the summary.
It could be inside a new sim:gpiochip board profile example Documentation/, so please submit the gpiochip board profile that you used for testing. This way someone willing to test it will just run:

$ ./tools/configure.sh sim:gpiochip

and follow the testing steps from Documentation.

In test section, I add the host prepare steps already,it need a CH341A USB to SPI I2C Serial Adapter Module - Programmer/Converter and I support host drivers source. I don't see any meaningful advantages in introducing a sim:gpiochip board

I mean here:
https://github.com/apache/nuttx/pull/17719/changes#diff-462098d5c4311e7d28a18bc110975ef12aa199ef7279ffa5e6d17dbad4d1433b

Remember: after the PR is merged and closed it will be difficult to end user find this PR with the test, this is why we need it in the Documentation.

add sim gpiochip driver

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
fix gpio pinval issue

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
sim gpiochip ioexpander export to user

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
@yezhonghui2024
Copy link
Contributor Author

@yezhonghui2024 your Documentation is excellent! Really detailed, this is the kind of Documentation we need on NuttX.
Please also add later the host prepare steps you added here in the summary.
It could be inside a new sim:gpiochip board profile example Documentation/, so please submit the gpiochip board profile that you used for testing. This way someone willing to test it will just run:

$ ./tools/configure.sh sim:gpiochip

and follow the testing steps from Documentation.

In test section, I add the host prepare steps already,it need a CH341A USB to SPI I2C Serial Adapter Module - Programmer/Converter and I support host drivers source. I don't see any meaningful advantages in introducing a sim:gpiochip board

I mean here: https://github.com/apache/nuttx/pull/17719/changes#diff-462098d5c4311e7d28a18bc110975ef12aa199ef7279ffa5e6d17dbad4d1433b

Remember: after the PR is merged and closed it will be difficult to end user find this PR with the test, this is why we need it in the Documentation.

Documentation update: Add host setup prerequisites and external references to sim_gpiochip.rst @acassis

@acassis
Copy link
Contributor

acassis commented Jan 4, 2026

@yezhonghui2024 your Documentation is excellent! Really detailed, this is the kind of Documentation we need on NuttX.
Please also add later the host prepare steps you added here in the summary.
It could be inside a new sim:gpiochip board profile example Documentation/, so please submit the gpiochip board profile that you used for testing. This way someone willing to test it will just run:

$ ./tools/configure.sh sim:gpiochip

and follow the testing steps from Documentation.

In test section, I add the host prepare steps already,it need a CH341A USB to SPI I2C Serial Adapter Module - Programmer/Converter and I support host drivers source. I don't see any meaningful advantages in introducing a sim:gpiochip board

I mean here: https://github.com/apache/nuttx/pull/17719/changes#diff-462098d5c4311e7d28a18bc110975ef12aa199ef7279ffa5e6d17dbad4d1433b
Remember: after the PR is merged and closed it will be difficult to end user find this PR with the test, this is why we need it in the Documentation.

Documentation update: Add host setup prerequisites and external references to sim_gpiochip.rst @acassis

@yezhonghui2024 I failed to find these steps in the Documentation:

Testing

prepare:

need a ch341A usb module(CH341A USB to SPI I2C Serial Adapter Module - Programmer/Converter)

host driver reference open source driver
[https://github.com/frank-zago/ch341-i2c-spi-gpio;make](https://github.com/frank-zago/ch341-i2c-spi-gpio%EF%BC%9Bmake) and install ko
sudo insmod ch341-core.ko
sudo insmod gpio-ch341.ko
sudo insmod i2c-ch341.ko
sudo insmod spi-ch341.ko

ls /dev check /dev/gpiochipX exist

4.CONFIG_SIM_GPIOCHIP=y
CONFIG_SIM_GPIOCHIP_NAME="/dev/gpiochipX"

Maybe you forgot to push the Documentation modification, I noticed your last commit didn't modify any file inside Documentation/

@yezhonghui2024
Copy link
Contributor Author

@yezhonghui2024 your Documentation is excellent! Really detailed, this is the kind of Documentation we need on NuttX.
Please also add later the host prepare steps you added here in the summary.
It could be inside a new sim:gpiochip board profile example Documentation/, so please submit the gpiochip board profile that you used for testing. This way someone willing to test it will just run:

$ ./tools/configure.sh sim:gpiochip

and follow the testing steps from Documentation.

In test section, I add the host prepare steps already,it need a CH341A USB to SPI I2C Serial Adapter Module - Programmer/Converter and I support host drivers source. I don't see any meaningful advantages in introducing a sim:gpiochip board

I mean here: https://github.com/apache/nuttx/pull/17719/changes#diff-462098d5c4311e7d28a18bc110975ef12aa199ef7279ffa5e6d17dbad4d1433b
Remember: after the PR is merged and closed it will be difficult to end user find this PR with the test, this is why we need it in the Documentation.

Documentation update: Add host setup prerequisites and external references to sim_gpiochip.rst @acassis

@yezhonghui2024 I failed to find these steps in the Documentation:

Testing

prepare:

need a ch341A usb module(CH341A USB to SPI I2C Serial Adapter Module - Programmer/Converter)

host driver reference open source driver
[https://github.com/frank-zago/ch341-i2c-spi-gpio;make](https://github.com/frank-zago/ch341-i2c-spi-gpio%EF%BC%9Bmake) and install ko
sudo insmod ch341-core.ko
sudo insmod gpio-ch341.ko
sudo insmod i2c-ch341.ko
sudo insmod spi-ch341.ko

ls /dev check /dev/gpiochipX exist

4.CONFIG_SIM_GPIOCHIP=y CONFIG_SIM_GPIOCHIP_NAME="/dev/gpiochipX"

Maybe you forgot to push the Documentation modification, I noticed your last commit didn't modify any file inside Documentation/

Documentation/platforms/sim/sim_gpiochip.rst has follow information
Host Prepare

Preparation required on the host side:

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 Area: Drivers Drivers issues 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.

4 participants