Probably a basic question, but I want to create a Torizon OS image based on 6.7.0 that includes GPIO functionality.
I have followed the tutorials on creating a custom image using Torizon-core builder but I am having a hard time finding documentation on how to create a custom .dts file that calls out using the GPIOLIB library.
Essentially I want to merge Torizon OS 6.7.0 and Embedded Toradex Image with the proper pin mapping.
I have the following setup:
Colibri Eval Board with iMXDX8
Im using a linux desktop for dev/image compilation
Thank you
You need to modify the device tree to configure the GPIO pins as required. The device tree source files (.dts) define the hardware configuration, including GPIO pin mappings.
Modify the Device Tree:
Locate the device tree source file for your specific module (Colibri iMX8X). You can find the base device tree files in the Toradex GitHub repository or in the TorizonCore Builder workspace.
Create a device tree overlay to modify the GPIO configuration. Here is an example of how to create a device tree overlay:
This example configures two GPIO pins (GPIO0_IO12 and GPIO0_IO13) on the Colibri iMX8X. Adjust the pin numbers and configurations as needed for your application.
Build the Custom TorizonCore Image:
Use TorizonCore Builder to integrate your custom device tree overlay into the TorizonCore image. Here is a basic example of how to do this:
# Initialize the TorizonCore Builder workspace
torizoncore-builder init --device colibri-imx8x
# Add your custom device tree overlay
torizoncore-builder dt checkout
cp path/to/your/custom-overlay.dts device-trees/overlays/
torizoncore-builder dt compile
# Bundle the custom device tree into the TorizonCore image
torizoncore-builder bundle --output-dir custom-torizon-image
Deploy the Custom Image:
Flash the custom TorizonCore image to your Colibri iMX8X module using Toradex Easy Installer or other suitable methods.
Verify GPIO Functionality:
Once the custom image is running on your module, you can use the libgpiod tools to verify the GPIO functionality. For example, you can use gpioset and gpioget to control and read the GPIO pins.
# List available GPIO chips
gpiodetect
# Get information about GPIO lines
gpioinfo gpiochip0
# Set a GPIO line to high
gpioset gpiochip0 12=1
# Read the value of a GPIO line
gpioget gpiochip0 12
By following these steps, you should be able to create a custom Torizon OS image with the required GPIO functionality and pin mapping for your Colibri iMX8X module. If you encounter any issues or need further assistance, feel free to ask the Toradex Community or refer to the Toradex Developer Center.
Please, also check if these links can help you solve your problem:
Where can I find the pin map to define the rest of the pins? Do I use Pinout Designer? Is so, what do I do with the xml output with respect to the .dts?
how to create a custom .dts file that calls out using the GPIOLIB library.
What do you mean exactly here “using the GPIOLIB library”? Are you talking about using sysfs for GPIO access, or are you talking about something else?
If you are talking about sysfs, you should know this method of GPIO access has been deprecated in recent kernel versions. It can still work but it’s not recommended anymore.
Essentially I want to merge Torizon OS 6.7.0 and Embedded Toradex Image with the proper pin mapping.
I’m not quite sure what you mean by this either. What do you mean merge these two images with proper pin mapping?
Where can I find the pin map to define the rest of the pins? Do I use Pinout Designer? Is so, what do I do with the xml output with respect to the .dts?
All pin mappings and definitions can be found in the respective datasheet on our website. Unless you are referring to something else.