# Automating Kernel Build scripts

**URL:** <https://forum.digikey.com/t/automating-kernel-build-scripts/35677>\
**Category:** Linux Discussions\
**Created:** [October 15, 2023, 1:27pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677 "2023-10-15T13:27:17Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![RobertCNelson](https://sea2.discourse-cdn.com/digikey/user_avatar/forum.digikey.com/robertcnelson/32/12_2.png) [@RobertCNelson](https://forum.digikey.com/u/RobertCNelson)\
**Post date:** [October 27, 2023, 9:11pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/21 "2023-10-27T21:11:02Z")

</div>

> [@dmccalla](#):
>
> model:[TI\_AM335x\_BeagleBone\_Green]  
> UBOOT: Booted Device-Tree:[am335x-bonegreen.dts]  
> kernel:[5.10.186-bone-rt-r76]  
> /boot/uEnv.txt Settings:  
> uboot\_overlay\_options:[enable\_uboot\_overlays=1]  
> uboot\_overlay\_options:[uboot\_overlay\_pru=AM335X-PRU-UIO-00A0.dtbo]  
> uboot\_overlay\_options:[enable\_uboot\_cape\_universal=1]  
> pkg check: to individually upgrade run: [sudo apt install --only-upgrade]

Yeah, that’s about how we can debug from user-space… DO you have anything to plug into J1, usb-serial, so we can see what u-boot is doing…

Regards,

---

<div class="post-metadata">

**Author:** ![dmccalla](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dmccalla](https://forum.digikey.com/u/dmccalla)\
**Post date:** [October 27, 2023, 9:20pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/22 "2023-10-27T21:20:09Z")

</div>

There serial port doesn’t get enabled until uEnv.txt is loaded from FAT partition, so I may be missing some stuff.

> Failed to mount ext2 filesystem…  
> \*\* Unrecognized filesystem type \*\*  
> switch to partitions #0, OK  
> mmc0 is current device  
> Checking for /boot/uEnv.txt on mmc0:2  
> switch to partitions #0, OK  
> mmc0 is current device  
> Scanning mmc 0:1…  
> gpio: pin 56 (gpio 56) value is 0  
> gpio: pin 55 (gpio 55) value is 0  
> gpio: pin 54 (gpio 54) value is 0  
> gpio: pin 53 (gpio 53) value is 1  
> switch to partitions #0, OK  
> mmc0 is current device  
> gpio: pin 54 (gpio 54) value is 1  
> Checking for: /uEnv.txt …  
> reading uEnv.txt  
> 387 bytes read in 3 ms (126 KiB/s)  
> gpio: pin 55 (gpio 55) value is 1  
> Loaded environment from uEnv.txt  
> Importing environment from mmc …  
> Checking if uenvcmd is set …  
> gpio: pin 56 (gpio 56) value is 1  
> Running uenvcmd …  
> Failed to mount ext2 filesystem…  
> \*\* Unrecognized filesystem type \*\*  
> Checking if client\_ip is set …  
> Checking for: /boot.scr …  
> Checking for: /boot/boot.scr …  
> Checking for: /boot/uEnv.txt …  
> gpio: pin 55 (gpio 55) value is 1  
> 215 bytes read in 24 ms (7.8 KiB/s)  
> Loaded environment from /boot/uEnv.txt  
> debug: [dtb=am335x-bonegreen.dtb] …  
> Using: dtb=am335x-bonegreen.dtb …  
> Checking if uname\_r is set in /boot/uEnv.txt…  
> gpio: pin 56 (gpio 56) value is 1  
> Running uname\_boot …  
> loading /boot/vmlinuz-5.10.186-bone-rt-r76 …  
> 9880064 bytes read in 567 ms (16.6 MiB/s)  
> loading /boot/dtbs/5.10.186-bone-rt-r76/am335x-bonegreen.dtb …  
> 90145 bytes read in 61 ms (1.4 MiB/s)  
> debug: [console=tty0 console=ttyS1,115200n8 console=ttyS1,115200n8 lcd\_detect=0xfff7ff ipaddr= serverip= gatewayip= netmask=255.255.255.0 root=/dev/mmcblk0p2 ro rootfstype=ext4 rootwait fsck.mode=force fsck.repair=yes uio\_pruss.extram\_pool\_sz=0x200000 net.ifnames=0] …  
> debug: [bootz 0x82000000 - 0x88000000] …  
> Kernel image @ 0x82000000 [0x000000 - 0x96c200]
> 
> ## Flattened Device Tree blob at 88000000
> 
> Booting using the fdt blob at 0x88000000  
> Loading Device Tree to 8ffe6000, end 8ffff020 … OK
> 
> Starting kernel …

---

<div class="post-metadata">

**Author:** ![RobertCNelson](https://sea2.discourse-cdn.com/digikey/user_avatar/forum.digikey.com/robertcnelson/32/12_2.png) [@RobertCNelson](https://forum.digikey.com/u/RobertCNelson)\
**Post date:** [October 27, 2023, 9:22pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/23 "2023-10-27T21:22:56Z")

</div>

> [@dmccalla](#):
>
> Loaded environment from /boot/uEnv.txt  
> debug: [dtb=am335x-bonegreen.dtb] …  
> Using: dtb=am335x-bonegreen.dtb …  
> Checking if uname\_r is set in /boot/uEnv.txt…  
> gpio: pin 56 (gpio 56) value is 1  
> Running uname\_boot …  
> loading /boot/vmlinuz-5.10.186-bone-rt-r76 …  
> 9880064 bytes read in 567 ms (16.6 MiB/s)  
> loading /boot/dtbs/5.10.186-bone-rt-r76/am335x-bonegreen.dtb …  
> 90145 bytes read in 61 ms (1.4 MiB/s)

Normally it would try to load the overlay after `90145 bytes read in 61 ms (1.4 MiB/s)` so either /boot/uEnv.txt doesn’t have the correct details to load the overlay, or you’ve patched too much of our u-boot changes out…

Regards,

---

<div class="post-metadata">

**Author:** ![dmccalla](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dmccalla](https://forum.digikey.com/u/dmccalla)\
**Post date:** [October 27, 2023, 9:47pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/24 "2023-10-27T21:47:06Z")

</div>

Maybe my bootloader is too old. I searched the u-boot source code for these keywords:

> enable\_uboot\_overlays  
> uboot\_overlay\_pru  
> enable\_uboot\_cape\_universal

and didn’t get any hits. I don’t know what u-boot is supposed to do when it sees these values set.

I’ll try this suggestion:

> fdtoverlay -i am335x-bonegreen.dtb -o am335x-bonegreen.dtb AM335X-PRU-UIO-00A0.dtbo

If that doesn’t work, I’ll try using the latest u-boot. If that doesn’t work, I’ll try using the ‘minfs’ file system. At that point I’ll have everything from the “Getting Started” tutorial. If still doesn’t work, you may have an easier time supporting me. If it **does** work, maybe I’ll be able to hone in on what the difference is.

---

<div class="post-metadata">

**Author:** ![dmccalla](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dmccalla](https://forum.digikey.com/u/dmccalla)\
**Post date:** [October 28, 2023, 7:28am UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/25 "2023-10-28T07:28:44Z")

</div>

The fdtoverlay trick worked! So I tried creating a custom dts by copying the pruss section of the overlay into the am335x-bonegreen.dts and adding status = “okay”, and that also works.

> /dts-v1/;
> 
> #include “am33xx.dtsi”  
> #include “am335x-bone-common.dtsi”  
> #include “am335x-bonegreen-common.dtsi”
> 
> &pruss {  
> compatible = “ti,pruss-v2”;  
> ti,pintc-offset = \<0x20000\>;  
> interrupt-parent = \<&intc\>;  
> status = “okay”;  
> interrupts = \<20 21 22 23 24 25 26 27\>;  
> };
> 
> / {  
> model = “TI AM335x BeagleBone Green”;  
> compatible = “ti,am335x-bone-green”, “ti,am335x-bone-black”, “ti,am335x-bone”, “ti,am33xx”;
> 
> chosen {  
> base\_dtb = “am335x-bonegreen.dts”;  
> base\_dtb\_timestamp = **TIMESTAMP** ;  
> };  
> };

So I added that to my custom device tree and now it works. The missing piece was in am33xx.dtsi in 4.4 kernel, but isn’t in am33xx.dtsi in the 5.10 kernel. I missed that.

Thanks for you help! I still may need more help figuring out how to fix or find replacement for gpio-of-helper.

---

<div class="post-metadata">

**Author:** ![dmccalla](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dmccalla](https://forum.digikey.com/u/dmccalla)\
**Post date:** [October 29, 2023, 3:44pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/26 "2023-10-29T15:44:53Z")

</div>

I looked into the gpio-of-helper issue. I couldn’t track down where to add -DDEBUG to see the debug messages, so I added some printks where errors were being returned related to &gpio0. I was surprised to find it wasn’t only returning errors for gpio-of-helper, but anywhere in device tree that has &gpio0.

> [2.946724] of\_get\_named\_gpiod\_flags: cd-gpios ERR\_PTR(-EPROBE\_DEFER)  
> [3.661613] of\_get\_named\_gpiod\_flags: gpio ERR\_PTR(-EPROBE\_DEFER)  
> [3.672634] of\_get\_named\_gpiod\_flags: gpios ERR\_PTR(-EPROBE\_DEFER)

An error is also returned for one of my LEDs in the “gpio-leds” section and for the CD signal in the mmc1 section, but these appear to be functioning correctly.

I also noticed that even though gpio-of-helper only complains about &gpio0, it fails to export the correct gpio#'s in /sys/class/gpio for the other gpios.

I’m going to stop looking into this and start looking for an alternative.

---

<div class="post-metadata">

**Author:** ![dmccalla](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dmccalla](https://forum.digikey.com/u/dmccalla)\
**Post date:** [October 30, 2023, 1:45am UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/27 "2023-10-30T01:45:27Z")

</div>

Another question: I need a timer with uS resolution. To accomplish this, I wrote a kernel module that sets up timer4 with 1MHz output and wired it to TCLKIN pin. Then I setup timer6 to use TCLKIN, which gives me a free running timer with uS resolution that wraps at 0xFFFFFFFF.

This kernel module won’t build with the latest kernel due to missing header files and I would like to find another way to do this.

**Can I do this with device tree?**

I think I have timer4 setup with omap-dmtimer-pwm to give me 1MHz output. I can’t verify because the trace connecting the output to TCLKIN is under the part. I don’t know how to enable and configure timer6 to use TCLKIN in device tree.

Any ideas?

---

<div class="post-metadata">

**Author:** ![RobertCNelson](https://sea2.discourse-cdn.com/digikey/user_avatar/forum.digikey.com/robertcnelson/32/12_2.png) [@RobertCNelson](https://forum.digikey.com/u/RobertCNelson)\
**Post date:** [October 30, 2023, 5:39pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/28 "2023-10-30T17:39:37Z")

</div>

timer-dm: [ti,timer-dm.yaml « timer « bindings « devicetree « Documentation - kernel/git/torvalds/linux.git - Linux kernel source tree](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/timer/ti,timer-dm.yaml)

There is a ti,clock-source option: [https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-PWM-TIMER-P8.07.dts#L63-L64](https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-PWM-TIMER-P8.07.dts#L63-L64)

Regards,

---

<div class="post-metadata">

**Author:** ![dmccalla](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dmccalla](https://forum.digikey.com/u/dmccalla)\
**Post date:** [November 5, 2023, 1:07am UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/29 "2023-11-05T01:07:16Z")

</div>

Sorry for bouncing back and forth between topics, but I spent some time trying to figure out why the gpio-of-helper isn’t working. A significant clue to the problem is that the gpios end up with the wrong name when gpio-of-helper exports them. For example, this

> gpio {  
> compatible = “gpio-of-helper”;  
> status = “okay”;  
> pinctrl-names = “default”;  
> pinctrl-0 = \<&gpio\_pins\>;  
> bla {  
> gpio-name = “bla”;  
> gpio = \<&gpio3 17 0\>;  
> input;  
> };  
> };

will give you a /sys/class/gpio/gpio49 directory instead of /sys/class/gpio/gpio81. If you cat /sys/class/gpio/gpio49/value, it will give you the value on pin gpio3\_17. The gpio#'s are off by 32 (one port). This tells me that this can probably be fixed with one line of code, but getting familiar enough with the code to find that line has proven difficult. It basically reads \<&gpio3 17 0\> from the device tree and iterates over a link list of gpio\_devices and gets a match one port too early. I don’t know if it’s not reading the device tree correctly, or the link list is not created correctly.

Are you familiar with this area of the code? If so, does this clue tell you where the problem may be?

---

<div class="post-metadata">

**Author:** ![dmccalla](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dmccalla](https://forum.digikey.com/u/dmccalla)\
**Post date:** [November 20, 2023, 2:34pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/30 "2023-11-20T14:34:23Z")

</div>

I spent two weekends trying to figure out what’s wrong with the gpio-of-helper driver and got nowhere. Now I’m trying to export the gpio in bash script and it doesn’t work either. Here’s what I’m doing in device tree:

> &am33xx\_pinmux {  
> gpio\_pins: pinmux\_gpio\_pins { // The GPIO pins  
> pinctrl-single,pins = \<  
> AM33XX\_IOPAD(0x898, PIN\_INPUT\_PULLUP | MUX\_MODE7)  
> \>;  
> };  
> };  
> gpio {  
> compatible = “gpio-of-helper”;  
> status = “okay”;  
> pinctrl-names = “default”;  
> pinctrl-0 = \<&gpio\_pins\>;  
> };

It looks like the pin is setup correctly:

> devmem 0x44e10898  
> 0x00000037

Here’s what I’m doing in bash script:

> echo “68” \> /sys/class/gpio/export  
> echo “in” \>/sys/class/gpio/gpio68/direction

I always read 0 whether the pin is high or low:

> cat /sys/class/gpio/gpio68/value  
> 0

Any idea why this method of using gpio isn’t working for me either?

---

<div class="post-metadata">

**Author:** ![dmccalla](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dmccalla](https://forum.digikey.com/u/dmccalla)\
**Post date:** [November 21, 2023, 1:35pm UTC](https://forum.digikey.com/t/automating-kernel-build-scripts/35677/31 "2023-11-21T13:35:11Z")

</div>

I forgot to mention that I can see the pin change value using devmem but not by reading value file

//jumper pin to ground

> devmem 0x481ac138  
> 0x00000000  
> cat /sys/class/gpio/gpio68/value  
> 0

//remove jumper and allow pullup to pull high

> devmem 0x481ac138  
> 0x00000010  
> cat /sys/class/gpio/gpio68/value  
> 0

[Previous page](https://forum.digikey.com/t/automating-kernel-build-scripts/35677.md?page=1)
