1
votes

I am starting with Yocto Project.

I wish to control GPIOs of BeagleBone Black with the image built with Yocto. 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.

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.

I got some up and running knowledge of Yocto. Built several types of images, included an app in a Linux Image, did modifications to images.

I understood the notion of GPIOs and controlled these by

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

toggle the GPIOs

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.

Thank you very much for your help.

George

1

1 Answers

1
votes

I haven't worked on a beaglebone board but the basic process should be the same for U-Boot. There should be a c file for your board somewhere in the board/ subdirectory of the U-Boot git folder.

That board file will have a board_init function, (also an early init and a late init).

In one of those init functions, you can write to the GPIOs by using a gpio_request that looks something like:

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. And then rebuild u-boot and that should be it. Once the OS is loaded you can use the echo commands to the /sys/class/gpio directories as you wrote, to flash the led. 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. Obviously there is a lot of work to do but hope that's helpful.