How to automate making the dtb file needed

Hi,
My project makes use of P9-15 as a pull-up input. I am following rcn-ee kernel releases and run 4.0.4.
0. can I use the same dtb file for diffrent kernel version from 3.19 - 4.0.4 ?
In any case I prefer to provide sources. so I came up with this small script to build the dtb and use it.

P9-15-pull-up.dtsi :

`
/{
fragment@0 {
target = <&am33xx_pinmux>;
overlay {
pinctrl_test: P9_15_pullup_Pins {
pinctrl-single,pins = <
0x040 0x37 /* P9_15 16 INPUT MODE7 pullup */

;
};
};
};

fragment@1 {
overlay {
test_helper: helper {
compatible = “bone-pinmux-helper”;
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_test>;
status = “okay”;
};
};
};
};
`

generate_dtb_for_p9_15.sh :

`
#!/bin/sh
pushd /tmp/
git clone GitHub - RobertCNelson/dtb-rebuilder
[ ! -f ‘src/arm/am335x-boneblack.dts’ ] && echo ‘Missing src/arm/am335x-boneblack.dts’ && exit 1
cat << EOF >>‘src/arm/am335x-boneblack.dts’
#include “P9-15-pull-up.dtsi”
#include “am335x-cape-rtc-ds1307.dtsi”
#include “i2c-1.dtsi”
EOF

make
/bin/cp src/arm/am335x-boneblack.dtb /boot/dtbs/
popd

`

Some questions:

  1. Are the files in order?
    2.must I run then when ever I upgrade a kernel for example from 3.19 → 4.0 ?

make sure you install the dependencies as build-essential. then run:

`
#!/bin/sh
set -x
cd /tmp/
git clone https://github.com/RobertCNelson/dtb-rebuilder.git
cd dtb-rebuilder
cp /root/devicetree/P9-15-pull-up.dtsi src/arm/
#cp /root/devicetree/am335x-cape-rtc-ds1307.dtsi src/arm/
cp /root/devicetree/i2c-1.dtsi src/arm/

#git clone https://github.com/beagleboard/bb.org-overlays
[ ! -f ‘src/arm/am335x-boneblack.dts’ ] && echo ‘Missing src/arm/am335x-boneblack.dts’ && exit 1
cat << EOF >>‘src/arm/am335x-boneblack.dts’
#include “P9-15-pull-up.dtsi”
#include “am335x-cape-rtc-ds1307.dtsi”
#include “i2c-1.dtsi”
EOF

./dtc-overlay.sh
make
/bin/cp src/arm/am335x-boneblack.dtb /boot/dtbs/

`

in this code I use GPIO P9 pin 15 as pull-up as well as add overlays for i2c and rtc.
all seems to work for me.

btw, with 4.1.x you can convert this into an overlay..

https://github.com/beagleboard/bb.org-overlays

Regards,