bb green, custom kernel, uboot, busybox. gpio does not react.

Dear All!

I’m using beagle bone green for my project. What I need is a couple of gpios, spi bus, second ethernet with usb or spi (I have custom wiznet5200 board). I was planning to have minimalistic system, which could run with busybox rootfs on ramdisk.

What I did is:
git clone GitHub - beagleboard/linux: The official BeagleBoard and BeagleBone kernel repository,
git clone GitHub - u-boot/u-boot: "Das U-Boot" Source Tree,
git clone GitHub - mirror/busybox: BusyBox mirror.

for kernel I use tag v5.18-rc4, made ‘make omap2def_config’ and after that menuconfig and switch off some drivers which I don’t need (audio, video, unneeded fs etc.).

for busybox I used default configuration

for uboot I used ‘make am335x_boneblack_vboot_defconfig’

with helps of uboot’s mkimage tool I make kernel image ‘make LOADADDR=0x80008000 uImage’ and image of busybox rootfs for ramdisk with ‘mkimage -C none -A arm -O linux -T ramdisk -d ramdisk uRamDisk’ (I copied files from busybox’s _install folder to ram disk together with kernel modules).

On sd card I have next files: MLO, u-boot, uEnv.txt, uImage, uRamDisk, am335x-bonegreen.dtb.

In uEnv.txt I have:
setenv bootargs console=/dev/ttyS0,115200n8 root=/dev/ram0 ramdisk_size=102500 init=/linuxrc rw
load mmc 0:1 ${loadaddr} uImage;
load mmc 0:1 ${rdaddr} uRamDisk;
load mmc 0:1 ${fdtaddr} am335-bonegreen.dtb;
bootm ${loadaddr} ${rdaddr} ${ftdaddr}

I connect serial to usb adapter to debug port and in minicom I see system loading from sd card. If I remove sd card I get debian system in emmc loading.

in the shell of my busybox system I execute:
cd /sys/class/gpio
export 67 > export
cd gpio67

The problem:
‘cat direction’ shows ‘in’, and then ‘cat value’ always shows 0 whatever I apply on P8_8 port.
after ‘echo out > direction’ both ‘cat 0 > value’ or ‘cat 1 > value’ does not change anything on input.

Hardware is ok, because if I remove sd card and load debian from emmc I can get gpio value and can control it by writing 0 or 1 in gpio67/value file.

Im feeling that I lack something in kernel configuration or there is something else in userspace that should made additional system configuration but I don’t have any clue what it could be.

Here is some fragment of kernel .config file:

$ grep 'GPIO_' .config 
# CONFIG_INPUT_GPIO_BEEPER is not set
# CONFIG_INPUT_GPIO_DECODER is not set
# CONFIG_INPUT_GPIO_VIBRA is not set
# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
# CONFIG_SERIO_GPIO_PS2 is not set
CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_CDEV=y
CONFIG_GPIO_CDEV_V1=y
CONFIG_GPIO_GENERIC=y
# CONFIG_GPIO_74XX_MMIO is not set
# CONFIG_GPIO_ALTERA is not set
# CONFIG_GPIO_CADENCE is not set
# CONFIG_GPIO_DWAPB is not set
# CONFIG_GPIO_FTGPIO010 is not set
CONFIG_GPIO_GENERIC_PLATFORM=y
# CONFIG_GPIO_GRGPIO is not set
# CONFIG_GPIO_HLWD is not set
# CONFIG_GPIO_LOGICVC is not set
# CONFIG_GPIO_MB86S7X is not set
# CONFIG_GPIO_MPC8XXX is not set
CONFIG_GPIO_OMAP=y
# CONFIG_GPIO_SAMA5D2_PIOBU is not set
# CONFIG_GPIO_SIFIVE is not set
CONFIG_GPIO_SYSCON=y
# CONFIG_GPIO_XILINX is not set
# CONFIG_GPIO_ZEVIO is not set
# CONFIG_GPIO_AMD_FCH is not set
# CONFIG_GPIO_ADP5588 is not set
# CONFIG_GPIO_ADNP is not set
# CONFIG_GPIO_GW_PLD is not set
# CONFIG_GPIO_MAX7300 is not set
# CONFIG_GPIO_MAX732X is not set
CONFIG_GPIO_PCA953X=m
# CONFIG_GPIO_PCA953X_IRQ is not set
# CONFIG_GPIO_PCA9570 is not set
CONFIG_GPIO_PCF857X=y
# CONFIG_GPIO_TPIC2810 is not set
# CONFIG_GPIO_LP873X is not set
CONFIG_GPIO_LP87565=y
CONFIG_GPIO_PALMAS=y
# CONFIG_GPIO_TPS65218 is not set
# CONFIG_GPIO_TPS65910 is not set
CONFIG_GPIO_TWL4030=y
# CONFIG_GPIO_TWL6040 is not set
# CONFIG_GPIO_74X164 is not set
# CONFIG_GPIO_MAX3191X is not set
# CONFIG_GPIO_MAX7301 is not set
# CONFIG_GPIO_MC33880 is not set
# CONFIG_GPIO_PISOSR is not set
# CONFIG_GPIO_XRA1403 is not set
# CONFIG_GPIO_AGGREGATOR is not set
# CONFIG_GPIO_MOCKUP is not set
# CONFIG_GPIO_VIRTIO is not set
# CONFIG_GPIO_SIM is not set
# CONFIG_POWER_RESET_GPIO_RESTART is not set
# CONFIG_USB_GPIO_VBUS is not set

Thanks in advance for any ideas, documentation links or any other info.

I would double check your devicetree, it sounds like the pin muxing is not set correctly.

Never used the BB Green. Is it using the same DTB file ? does u-boot on the eMMC load any overlay files ?

am335x-bonegreen.dtb is compiled from bunch of dts and dtsi files in linux kernel. I didn’t change any of them, just use dtb from arch/arm/boot/dts/ folder.

initially of course I made modification of am335x-bonegreen-common.dtsi to make spi1 bus visible for user spi device driver (that one, who is responsible for /dev/spidevX.X files). I made this by copying some lines from overlay dts which describe spi bus. This worked, I got /dev/spidev2.0 file by I didn’t check it with any hardware. At least chip select pin is low, so I have some suspitions that it does not work.

gpio lines does not react with both modified and unmodified dts file.

uboot does not load any overlays. Initialy my plan was just modify default dtb file for spi bus and set up gpios from /sys/class/gpio interface, thats why I switched off overlay support in kernel config.

# CONFIG_OF_OVERLAY is not set
# CONFIG_OVERLAY_FS is not set

Im not big expert in dts files so I cannot say how much dts files for black and green version differ.
I will try to recompile kernel with overlay support build in, maybe this will help.

looking at the DTS files, I don’t think you should be using am335x-bonegreen.dtb.

None of the files it includes has much in the way of pin muxing.

am335x-bonegreen-wireless-common-univ.dtsi looks like it includes much more in the way of pin muxing, but this is not being included as far as I can see. It is being included by am335x-bonegreen-wireless-uboot-univ.dts

I don’t know if on the standard BB Green u-boot is actually setting up the pin muxing. Perhaps it is just strange naming.

You could probably take the pin muxing from am335x-bonegreen-wireless-common-univ and create your own dts file.

yes, indeed. there are not to much things exported but I don`t need them.

for some reason I don`t have -wireless-uboot-univ, only -wireless.

I was trying to make it work using some, it seems working, solution but none of those worked.

I tried https://develop.phytec.com/troubleshooting-articles/unable-to-toggle-gpio-pins-in-yocto-bsp, https://e2e.ti.com/support/processors-group/processors/f/processors-forum/711719/linux-processor-sdk-omapl138-unable-to-toggle-gpio-led-s-in-linux and Accessing GPIO From UserSpace - NXP Community but I still cannot toggle gpio.

Also I tried explaination in Documentation/gpio/gpio.txt file, but it does not work as well. The feature which is called gpio hog shows me that some pins should be set up as dts file saying (input, output-low, output-high), I can see the dts settings in debugfs (cat /sys/kernel/debug/gpio), but still do not get any output-high or output-low on physical pinouts, its always 3.3v whatever I set in dts file.

I cannot invest time in this anymore and basically do not have any idea what could be the reason of this magic problem. I will try to modify default debian image.

Anyway thanks for help!

I will write here If I have solution in future.

What branch are you using for the kernel ?
I checked out 5.10 and that DTS files is there.

Can you take the dts file from the Debian install where GPIOs work and use it in your image. If the GPIOs work then the issue is with your DTS file, if not, it will be a kernel issue. I suspect it is the DTS file