How to change i.MX8MM EVK peripheral hardware on Yocto

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to change i.MX8MM EVK peripheral hardware on Yocto

1,504 次查看
Laiweiyu
Contributor I

Hello NXP,

I want to edit the development board peripheral hardware (like GPIO, USB, LED..) and rebuild image

But I am not an expert in this area

For example, if I want to change the LED state (like power LED or else LED) by edit driver

How to do step by step ?

Thanks

0 项奖励
7 回复数

1,475 次查看
joanxie
NXP TechSupport
NXP TechSupport

you can refer to the dts file

"https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mm-evk.d...

for led, pls find

leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpio_led>;

		status {
			label = "status";
			gpios = <&gpio3 16 GPIO_ACTIVE_HIGH>;
			default-state = "on";
		};

0 项奖励

1,464 次查看
Laiweiyu
Contributor I

Thanks for your reply

I connect the link but it show "Invalid branch: lf-5.15.y"

So I search other link about "imx8mm-evk.dts"

but I notice that 5.15.52 version have no "leds" part , why?

https://elixir.bootlin.com/linux/v5.15.52/source/arch/arm64/boot/dts/freescale/imx8mm-evk.dts

 

In addition, I try to control the GPIO like below link

https://variwiki.com/index.php?title=MX8_GPIO

I can use libgpiod command line to set GPIO

but when I use "libgpiod C Application" or "libgpiod Python Application"

C code can't find "gpiod.h" (use gcc to compile)

Python can't find "libgpiod.so"

My repo image is "imx-5.15.52.2.1.0"

How can I solve this issue

Thanks

 

0 项奖励

1,452 次查看
joanxie
NXP TechSupport
NXP TechSupport

Pls check the dtsi file instead of dts file, I mean imx8mm-evk.dtsi,

"https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mm-evk.d...

did you get this error when you cross compile your c source code?

 

0 项奖励

1,437 次查看
Laiweiyu
Contributor I

Thanks for your reply

About "libgpiod C Application" or "libgpiod Python Application"

I use directly gcc compile on NXP terminal, it can't find "gpiod.h" or "libgpiod.so"

And you say "did you get this error when you cross compile your c source code?"

It means I need to add recipe or bblayer and bitbake?

If it is like this, what's the GPIO recipe or bblayer?

Thanks

0 项奖励

1,417 次查看
joanxie
NXP TechSupport
NXP TechSupport

did your source code includes them? I find an example, you can refer it

Libgpiod Programing Examples

 

Following section provides examples how to use in Libgpiod 

 

  • How to read the state of an input GPIO pin?

Following example shows how to get the state of a GPIO pin:

 

  • Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gpiod.h"
int main(int argc, char * argv[]) {
 struct gpiod_chip *chip;
 struct gpiod_line *line;
 char *dev;
 int gpio_line;
 int i, req, value = 0;
 if (argc != 3)
 {
 printf("Wrong parameters \n \
 Usage:\n \
 ./gpio_read_example <gpio_dev> <line>\n \
 Example:\n \
 ./gpio_read_example /dev/gpiochip4 9 \n"
 );
 return -1;
 }
 dev = strdup(argv[1]);
 if(!dev)
 {
 printf("Wrong CharDev Name\n");
 return -1;
 }
 if (argv[2])
 {
 gpio_line = atoi(strdup(argv[2]));
 }
 chip = gpiod_chip_open(dev);
 if (!chip)
 return -1;
 line = gpiod_chip_get_line(chip, gpio_line);
 if (!line) {
 gpiod_chip_close(chip);
 return -1;
 }
 req = gpiod_line_request_input(line, "button");
 if (req < 0) {
 gpiod_chip_close(chip);
 return -1;
 }
 value = gpiod_line_get_value(line);
 printf("GPIO value of %s on line %d is: %d\n", dev, gpio_line, value);
 gpiod_chip_close(chip);
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
  • Cross-Compilation

    aarch64-linux-gnu-gcc gpio_read_example.c -I<workspace>/libgpiod/libgpiod_install/include -L<workspace>/libgpiod/libgpiod_install/lib -lgpiod -o gpio_read_example
    ‍‍‍‍‍‍‍‍
  • Run
./gpio_toggle_example /dev/gpiochip4 9

 

0 项奖励

1,394 次查看
Laiweiyu
Contributor I

Thanks for your reply

Now I can use libgpiod C to control GPIO state 

I control "exp_io9 " (gpiochip5 line 11) hight/low change 

And I want to use another way to achieve ,like edit dts file and add driver

let it can default "gpiochip5 line 11" hight/low change when I boot

How can I do it step by step (use dts file and driver)?

Thanks

0 项奖励

1,391 次查看
joanxie
NXP TechSupport
NXP TechSupport

you can refer to the dts file, which has gpio configuration, then config your own gpio, the detailed settings, pls refer to the reference manual, you also can refer to the document as below

"https://source.codeaurora.org/external/imx/linux-imx/tree/Documentation/devicetree/bindings/gpio?h=i..."

0 项奖励