Hi all.
i'm trying to control GPIO pins, for that i installed libgpiod package.
when i try gpioset with that command given as below:-
gpioset gpiochip5 9=1
error = "gpioset: invalid line value"
same error come when i try gpioget.
in my board pin 13,14,16,18 are present for expansion in J21 connector.
when i run gpioinfo that time i getting this information ,
from this i try to run gpioset & gpioget (gpioset gpiochip5 9=1 ) i'm getting error = "gpioset: invalid line value".
can anyone suggest me how to approach.
below one is the file path, in this it is already enable
home/deevia/imx-yocto-bsp/sources/meta-freescale-3rdparty/recipes-kernel/linux/linux-kontron/defconfig
but in our case inside sys/class -> gpio folder is not present
while searching on internet i found this article on one of the website.
So that's why i installed libgpiod package but through that also when i try i'm getting error i attached that snippet.
can you help to resolve this @weidong_sun
Dear @vrutik7781 ,
1. /sys/clase/gpio/ (SYSFS)
I checked kernel configuration just now. my kernel version is 6.1.55, /sys/clase/gpio/ (SYSFS) for gpio should be deprecated.
So your kernel should be the same as mine.
Sorry for my mistake!
2. command tools of libgpiod
Currently I saw only the following tools are provided for command line operation.
- gpiodetect
- gpioinfo
- gpioset
- gpioget
- gpiomon
I didn't find a tool to set gpio direction. You want to set EXP_P1_1 to output 1, but from your listed gpio information, all expansion gpios are INPUT. I think if you want it to OUTPU 1, at first the gpio should be set to OUTPU, then set it 1.
If above tools are not sufficient for your operation, maybe you will have to write code to get the purpose.
Thanks!
Regards,
weidong
dear @weidong_sun
i tried to add below code in my recipe in my layer .while running bitbake my_recipe_name ,it throws compile time errors i'm getting error like function definition are not present..
int main() {
struct gpiod_chip *chip;
struct gpiod_line *line;
int req, value;
chip = gpiod_chip_open("/dev/gpiochip0");
if (!chip)
return -1;
line = gpiod_chip_get_line(chip, 3);
if (!line) {
gpiod_chip_close(chip);
return -1;
}
req = gpiod_line_request_input(line, "gpio_state");
if (req) {
gpiod_chip_close(chip);
return -1;
}
value = gpiod_line_get_value(line);
printf("GPIO value is: %d\n", value);
gpiod_chip_close(chip);
}
Dear @vrutik7781 ,
No necessary to add your app to Yocto Layer, you know it is not convenient to build it in Yocto. You can follow these steps to do it.
1. Exporting toolchain from Yocto
2. Installing the toolchain to /opt/
3. Writing code and Makefile for your code
4. Configuring cross compilation environment using the following commands
# source /opt/fsl-imx-wayland/6.1-mickledore/environment-setup-armv8a-poky-linux
# make your_app
Here is my the directory of toolchain, for your reference.
[Note]
On the issue of building app, please re-create a new post on community or a new case in our SFDC system.
Thanks!
Regards,
weidong
Dear @vrutik7781 ,
See the link , please!
All iMX linux materials are here:
Download all documents, please!
Then you open IMX_LINUX_USERS_GUIDE.pdf, on page 33, chapter 4.5.12 How to build U-Boot and Kernel in standalone environment, you can find the command:
In order to get more libs, you can use imx-image-multimedia, like this:
# DISTRO=fsl-imx-fb MACHINE=imx6ull14x14evk bitbake imx-image-multimedia -c populate_sdk
For image types, you can find them in IMX_YOCTO_PROJECT_USERS_GUIDE.pdf, all yocto operations are also in the document.
Try it, please!
Regards,
weidong
dear @weidong_sun
sorry for disturbing you , while trying this method I'm getting following errors.
I try this thing,
"If the building process is interrupted, modify conf/local.conf to comment out the line:
PACKAGE_CLASSES = "package_deb", and then execute the populate_sdk command again."
but again I'm facing same issue what should i need to do?
Thanks.
Regards.
Vrutik
Dear @vrutik7781 ,
I tested L6.1.55_2.1.0 yocto bsp. My cross compilation platform is ubuntu 20.04 host.
Before building it, some necessary software packages must be installed using apt-get install , See IMX_YOCTO_PROJECT_USERS_GUIDE.pdf, please!
Below is all steps on building toolchain for imx8 serials, even if we build it based on i.mx8mp, the toolchain can also be used for other i.mx CPU based on arm64.
# cd ~/imx-yocto-bsp # DISTRO=fsl-imx-wayland MACHINE=imx8mp-lpddr4-evk source imx-setup-release.sh -b build-wayland The following command is to get all packages for toolchain. at the time, it is under build-wayland . # bitbake imx-image-multimedia -c populate_sdk --runall=fetch -k
So far all packages needed by toolchain have been downloaded successfully. Then begin to build toolchain # bitbake imx-image-multimedia -c populate_sdk
|
After compilation is done, you can find a xxx.sh file in tmp/work/deploy.
you can copy it to /opt/ , then
# sudo chmod a+x xxx.sh
# ./xxx.sh
The toolchain will start installation.
Regards,
weidong
dear @weidong_sun
My cross compilation platform is also ubunto 20.04 host.
by referring IMX_YOCTO_PROJECT_USERS_GUIDE.pdf i created my image by following the steps and installing the required packages.
i try the command to get all packages for toolchain and it downloaded successfully.
bitbake imx-image-full -c populate_sdk --runall=fetch -k
after that i try to build toolchain, but again I'm facing same issue..
bitbake imx-image-full -c populate_sdk
i try the Note: given in IMX_LINUX_USERS_GUIDE.pdf, on page 33, chapter 4.5.12. modify conf/local.conf to comment out the line.
after also I'm facing same issue.
Can you please give me guidance what should i need to resolve this issue.
Thanks.
vrutik
Hello @vrutik7781 ,
You didn't follow my steps.
imx-image-multimedia, not imx-image-full.
Regards,
weidong
Dear @weidong_sun
my image is imx-image-full that's why instead of imx-image-multimedia i am using imx-image-full.
while building image only, i build imx-image-full, is it the right way ?
Hello @vrutik7781 ,
imx-image-full includes qt lib, if you don't want to build qt app, no need to build the image, it is very big.
Regards,
weidong
Dear @vrutik7781 ,
It seems that there are some issues on the package "nativesdk-qtbase", maybe it's incomplete.
Try these steps:
1. Cleaning all previous downloading
## bitbake nativesdk-qtbase -c cleanall ( or bitbake nativesdk-qtbase -c cleansstate)
2. Fetching it separately
# bitbake nativesdk-qtbase -c fetch
3. Compiling it separately
# bitbake nativesdk-qtbase -c compile
I tested above steps on my ubuntu host, no problem.
For other packages, if you encounter similar issue, above steps can also be used.
Thanks!
Regards,
weidong
Dear @weidong_sun
Thanks for your support. I'm able to export toolchain and install in /opt/ successfully.
After that I've gone for the third step, Makefile for my code and for that I referred : main.c - https://variwiki.com/index.php?title=MX8M_GPIO and did changes as per my requirements, but I am getting an errors: undefined references, even though I've installed libgpiod.
I request you to please assist me here to resolve this.
Regards,
Vrutik
Dear @vrutik7781 ,
Obviously, cross compiler didn't find libgpiod lib, so link errors occurred.
check if cross compiler includes the lib, please!
if not, add the line to ./conf/local.conf
==========================
IMAGE_INSTALL:append = " libgpiod libgpiod-dev libgpiod-tools"
==========================
If above suggestions can't still solve the question, please re-create a new post or case for building your app! iMX support team will continue to support you.
Thanks!
Regards,
weidong
Dear @weidong_sun
I check and it is present in my case.
but while creating Makefile it gives error.
Ok I'll create new post regarding building my app.
Thanks & regards
Vrutik.
Dear @vrutik7781 ,
Let us see iMX8MP-11X11-evk schematic, please!
1. Connections between PCA6416 & J21
PCA6416.P1_1--->J21.pin13 ( EXP_P1_1)
PCA6416.P1_2--->J21.pin15 ( EXP_P1_2)
PCA6416.P1_3--->J21.pin16 ( EXP_P1_3)
PCA6416.P1_4--->J21.pin13 ( EXP_P1_4)
2. Numbering of PCA6416 on linux platform
Let us assume the base number of PCA6416 is BASE on linux platform,
Then each GPIO number of PCA6416 on linux will be:
--P0 port
P0_0 : BASE + 0
P0_1: BASE + 1
...
P0_7: BASE + 7
--P1 port
P1_0 : BASE + 8
P1_1 : BASE + 9
...
P1_7 : BASE +15
So we only need to know the BASE of PCA6416 on linux system.
3. Checking BSAE of PCA6416
Try the following steps, please!
# cd /sys/class/gpio
# ls -l
gpiochipBASE -->.../.../devices/platform/30a40000.i2c/i2c-1/1-0020/gpio/gpiochipBASE
[Note]
BASE should be a concrete number you will see.
Let us assume the BASE is 500, then the PCA6416's starting gpio number is 500, what you found above is :
gpiochip500 -->.../.../devices/platform/30a40000.i2c/i2c-1/1-0020/gpio/gpiochip500
THEN:
EXP_P1_1 : gpio number is 500 + 9 = 509
EXP_P1_2 : gpio number is 500 + 10 = 510
EXP_P1_3 : gpio number is 500 + 11 = 511
EXP_P1_4 : gpio number is 500 + 12 = 512
4. Operating expansion gpios
Taking EXP_P1_0 as an example:
# cd /sys/class/gpio/gpiochip500
# echo out > direction (set it to be OUTPUT, "in" is used to set it INPUT )
# echo 1 > value (set it to output High, 0 output Low)
Above steps are on how to operate expansion GPIO on linux platform, for you reference.
Try it, please!
Thanks!
Regards,
weidong