简体   繁体   English

如何在使用 Yocto Project for BeagleBone Black 构建映像之前配置 GPIO

[英]How do I configure the GPIO before building the image with Yocto Project for BeagleBone Black

I am starting with Yocto Project.我从 Yocto 项目开始。

I wish to control GPIOs of BeagleBone Black with the image built with Yocto.我希望用 Yocto 构建的镜像来控制 BeagleBone Black 的 GPIO。 Please help me.请帮我。 I simply find it hard to arrange the puzzles.我只是觉得很难安排谜题。 Believe me I have "googled", but did not find something to glue the practical steps and understand the concepts.相信我,我已经“用谷歌搜索”了,但没有找到可以粘合实际步骤和理解概念的东西。

I figure out it is something related to meta-yocto-bsp or I should build a BSP layer from scratch with the Boot modified for this.我发现它与 meta-yocto-bsp 相关,或者我应该从头开始构建一个 BSP 层,并为此修改 Boot。

Practically, I want to fire an LED when powering on the board,leave it on during the boot process and switch it to flash mode after the Operating System has been loaded.实际上,我想在板子上电时点亮一个 LED,在启动过程中让它亮着,并在加载操作系统后将其切换到 flash 模式。

I got some up and running knowledge of Yocto.我获得了一些有关 Yocto 的启动和运行知识。 Built several types of images, included an app in a Linux Image, did modifications to images.构建了几种类型的图像,在 Linux 图像中包含一个应用程序,对图像进行了修改。

I understood the notion of GPIOs and controlled these by我理解 GPIO 的概念并通过以下方式控制它们

echo 48 > /sys/class/gpio/export
echo 'out' > /sys/class/gpio/gpio48/direction

toggle the GPIOs切换 GPIO

echo 1 >  /sys/class/gpio/gpio48/value
echo 0 > /sys/class/gpio/gpio48/value

But I do not know how to modify the U-boot to set up the GPIO in Yocto Project before baking the actual Linux Image.但是在烘焙实际的 Linux 映像之前,我不知道如何修改 U-boot 以在 Yocto Project 中设置 GPIO。

Thank you very much for your help.非常感谢您的帮助。

George乔治

I haven't worked on a beaglebone board but the basic process should be the same for U-Boot.我没有在 beaglebone 板上工作过,但 U-Boot 的基本过程应该是相同的。 There should be a c file for your board somewhere in the board/ subdirectory of the U-Boot git folder.在 U-Boot git 文件夹的board/子目录中的某处,您的电路板应该有一个 c 文件。

That board file will have a board_init function, (also an early init and a late init).该板文件将有一个board_init function,(也是一个早期初始化和一个晚期初始化)。

In one of those init functions, you can write to the GPIOs by using a gpio_request that looks something like:在其中一个 init 函数中,您可以使用如下所示的 gpio_request 写入 GPIO:

gpio_request( SOME_MACRO(gpio_bank_num, gpio_num), "gpio name");
gpio_direction( SOME_MACRO(gpio_bank_num, gpio_num), 1); / 1 is O/P

where you can get the bank number, gpio number and name from the device tree file.您可以从设备树文件中获取银行编号、gpio 编号和名称。 And then rebuild u-boot and that should be it.然后重建u-boot,应该就是这样。 Once the OS is loaded you can use the echo commands to the /sys/class/gpio directories as you wrote, to flash the led.加载操作系统后,您可以使用 echo 命令到 /sys/class/gpio 目录,如您所写,到 flash 。 You will have to work out how the gpio number (eg in your example 48) maps to a bank and number in the device tree.您将必须弄清楚 gpio 编号(例如,在您的示例中为 48)如何映射到设备树中的银行编号 Obviously there is a lot of work to do but hope that's helpful.显然有很多工作要做,但希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM