Building with gpiod for remote debugging

I am evaluating two Toradex boards, the iMX6ULL 512MB WB IT and the iMX8QXP 2GB WB IT, both running Linux on the target. I am testing the iMX6ULL by developing in Eclipse Neon.3 on an Ubuntu 18.04 LTS host system. For iMX8, I am using Visual Studio Community 2019 on Windows 10. On either system, I am able to set breakpoints and run in debug mode from the host.

Now I need to add code to program the GPIO pins. On the MX6, I followed the steps in Basic GPIO usage - Colibri Evaluation Board - Colibri iMX6ULL and used the Linux sysfs interface to successfully program the GPIO.

But on the MX8, I see that the sysfs is deprecated, and replaced by gpiod. I am trying to use gpiod according to How to Use GPIO on TorizonCore. I am able to run the command line tools from torizonextras/arm64v8-gpiod. I am also able to create an image with the C programs from torizon-samples, and run them on the target machine.

However, I would like to be able to build my program in Visual Studio on the host, integrate gpiod, and run the program remotely on the MX8 in debug mode, to allow breakpoints and debugging. I assume I need to integrate gpiod into Visual Studio via Docker, so it can be uploaded to the MX8, but I’m not sure how this works with the Torizon extension. Maybe this is more of a Docker question, but how can I do this?

Greetings @gloverbarker,

I believe this is what you’re looking for: How to Use GPIO with Torizon Visual Studio Extension (C++) | Toradex Developer Center

The article shows how to integrate gpiod and configure the project correctly with our extension.

Best Regards,

Thanks for the quick response. That is what I was looking for. However, I am having a problem with it. When I do a deploy and debug, or just a project build, VS fails to find the gpiod libraries when linking. It does compile them okay. Attached are the two problem source files and the build output. For example, the first build error is “… sensor.cpp(37): error : undefined reference to `gpiod_chip_open_by_number’”.

I followed the instructions in your link. Attached are a screenshot of my Torizon Application Properties, as well as the config.yaml file.

I didn’t have any issues building a libgpiod based solution on my end. I mean I couldn’t build your sensor.cpp app since I don’t have the header file, sensor.h. But I made a quick example app that uses the gpiod_chip_open_by_number method and it compiled fine with no issue.

Did you remember to add the libgpiod library to the liner as shown here?: How to Use GPIO with Torizon Visual Studio Extension (C++) | Toradex Developer Center

Best Regards,

Yes, I added libgpiod , as shown in this screenshot. I have attached a zip of my entire VS project, if you want to try to reproduce the build.

Ok I figured out the issue. While you did set the linker, you only set it for the ARM platform as show by your above picture. When doing builds since the build is done locally on the host it seems the extension used the Active(x64) platform.

Furthermore it seems the linker settings are on a per platform basis. So since you set it for the ARM platform it only sets the linker for this platform. With your project once I set the the linker for the Active(x64) platform, I was able to build your project without error.

Best Regards,

That fixed it, and I have it running now. Thank you.

I have a followup question. If you need me to post it as a separate issue, let me know. Do you have a similar plugin for gpiod in Eclipse/C++, for the MX8 or MX6ULL?

I can answer that quickly here.

In short no. The only IDE extensions/plugins that we ourselves support and develop in-house is the VS and VSCode extensions for Torizon. Any other general IDE platform should be usable with our products. But, we don’t really have any specific instructions on how to get setup with these alternate IDEs.

Best Regards,

Okay, thanks for your help and information.

Your welcome