diff options
author | Denys Dmytriyenko <denys@konsulko.com> | 2022-02-22 04:13:55 +0000 |
---|---|---|
committer | Ryan Eatmon <reatmon@ti.com> | 2022-02-22 12:01:39 -0600 |
commit | af04276c83b32ecb5cf07c14f014f657dbbb7a7b (patch) | |
tree | 857840a8d113a557a705b9d0a36d38af6e62f874 /meta-ti-extras | |
parent | 600a51055a1b443f36f6e6421e3165ddacb2ba86 (diff) | |
download | meta-ti-af04276c83b32ecb5cf07c14f014f657dbbb7a7b.tar.gz |
meta-ti: move beaglebone-specific components to meta-ti-extras
Move beagleboard.org beaglebone componentns to meta-ti-extras.
Signed-off-by: Denys Dmytriyenko <denys@konsulko.com>
Signed-off-by: Ryan Eatmon <reatmon@ti.com>
Diffstat (limited to 'meta-ti-extras')
16 files changed, 293 insertions, 0 deletions
diff --git a/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes.bb b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes.bb new file mode 100644 index 00000000..ceefe0d6 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes.bb | |||
@@ -0,0 +1,26 @@ | |||
1 | DESCRIPTION = "Userspace setup for beaglebone capes" | ||
2 | |||
3 | LICENSE = "MIT" | ||
4 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
5 | |||
6 | PR = "r4" | ||
7 | |||
8 | inherit allarch | ||
9 | |||
10 | SRC_URI = "file://cape.service \ | ||
11 | file://cape.sh \ | ||
12 | file://cape-stop.sh \ | ||
13 | " | ||
14 | |||
15 | do_install() { | ||
16 | install -d ${D}${base_libdir}/systemd/system/ | ||
17 | install -m 0644 ${WORKDIR}/cape.service ${D}${base_libdir}/systemd/system | ||
18 | |||
19 | install -d ${D}${base_libdir}/systemd/system/basic.target.wants | ||
20 | ln -sf ../cape.service ${D}${base_libdir}/systemd/system/basic.target.wants/ | ||
21 | |||
22 | install -d ${D}${bindir} | ||
23 | install -m 0755 ${WORKDIR}/cape*.sh ${D}${bindir} | ||
24 | } | ||
25 | |||
26 | FILES:${PN} += "${base_libdir}/systemd/system" | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape-stop.sh b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape-stop.sh new file mode 100755 index 00000000..222a010d --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape-stop.sh | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/bin/sh | ||
2 | for eeprom in /sys/bus/i2c/devices/3-005*/eeprom ; do | ||
3 | PARTNUMBER=$(hexdump -e '8/1 "%c"' $eeprom -s 58 -n16) | ||
4 | case $PARTNUMBER in | ||
5 | "BB-BONE-LCD3-01.") | ||
6 | echo "Turning off backlight for LCD3 cape" | ||
7 | i2cset -f -y 1 0x24 0x07 0x00;; | ||
8 | "BB-BONE-LCD4"*) | ||
9 | echo "Turning off backlight for LCD4 cape" | ||
10 | i2cset -f -y 1 0x24 0x07 0x00;; | ||
11 | *) | ||
12 | echo "unknown cape: $PARTNUMBER";; | ||
13 | esac | ||
14 | done | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape.service b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape.service new file mode 100644 index 00000000..ce0db719 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape.service | |||
@@ -0,0 +1,11 @@ | |||
1 | [Unit] | ||
2 | Description=Beaglebone cape support | ||
3 | |||
4 | [Service] | ||
5 | Type=oneshot | ||
6 | RemainAfterExit=yes | ||
7 | ExecStart=/usr/bin/cape.sh | ||
8 | ExecStop=/usr/bin/cape-stop.sh | ||
9 | |||
10 | [Install] | ||
11 | WantedBy=basic.target | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape.sh b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape.sh new file mode 100755 index 00000000..c279349d --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-capes/cape.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/sh | ||
2 | for eeprom in /sys/bus/i2c/devices/3-005*/eeprom ; do | ||
3 | PARTNUMBER=$(hexdump -e '8/1 "%c"' $eeprom -s 58 -n16) | ||
4 | case $PARTNUMBER in | ||
5 | "BB-BONE-LCD3-01.") | ||
6 | echo "Turning on backlight for LCD3 cape" | ||
7 | i2cset -f -y 1 0x24 0x07 0x09 | ||
8 | i2cset -f -y 1 0x24 0x08 0x60;; | ||
9 | "BB-BONE-LCD4"*) | ||
10 | echo "Turning on backlight for LCD4 cape" | ||
11 | i2cset -f -y 1 0x24 0x07 0x09 | ||
12 | i2cset -f -y 1 0x24 0x08 0x60;; | ||
13 | "BB-BONE-WTHR-01.") | ||
14 | echo "Initializing I2C devices" | ||
15 | echo sht21 0x40 > /sys/class/i2c-adapter/i2c-3/new_device | ||
16 | echo bmp085 0x77 > /sys/class/i2c-adapter/i2c-3/new_device | ||
17 | echo tsl2550 0x39 > /sys/class/i2c-adapter/i2c-3/new_device | ||
18 | echo 1 > /sys/bus/i2c/devices/3-0039/operating_mode;; | ||
19 | *) | ||
20 | echo "unknown cape: $PARTNUMBER";; | ||
21 | esac | ||
22 | done | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/beaglebone-getting-started.bb b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-getting-started.bb new file mode 100644 index 00000000..25538ace --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/beaglebone-getting-started.bb | |||
@@ -0,0 +1,21 @@ | |||
1 | SUMMARY = "BeagleBone Getting Started Guide" | ||
2 | |||
3 | PR = "r22" | ||
4 | |||
5 | inherit allarch | ||
6 | |||
7 | LICENSE = "CC-BY-SA-3.0 & GPLv3+ & MIT & PD" | ||
8 | LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=f6f02761e31334c48f7021fb94c89aaa" | ||
9 | |||
10 | SRCREV = "05bedba192646152b7bc80b0accaea75aef864e5" | ||
11 | SRC_URI = "git://github.com/jadonk/beaglebone-getting-started.git;protocol=https;branch=master" | ||
12 | |||
13 | S = "${WORKDIR}/git" | ||
14 | |||
15 | do_install() { | ||
16 | install -d ${D}${datadir}/${PN} | ||
17 | cp -R --no-dereference --preserve=mode,links ${S}/* ${D}${datadir}/${PN} | ||
18 | } | ||
19 | |||
20 | FILES:${PN} += "${datadir}/${PN}" | ||
21 | INSANE_SKIP:${PN} = "file-rdeps" | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init.bb b/meta-ti-extras/recipes-ti/beagleboard/gadget-init.bb new file mode 100644 index 00000000..3ab00ec3 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init.bb | |||
@@ -0,0 +1,60 @@ | |||
1 | DESCRIPTION = "Units to initialize usb gadgets" | ||
2 | |||
3 | PR = "r19" | ||
4 | |||
5 | LICENSE = "MIT" | ||
6 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
7 | |||
8 | COMPATIBLE_MACHINE = "(ti33x)" | ||
9 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
10 | |||
11 | SRC_URI = "file://storage-gadget-init.service \ | ||
12 | file://network-gadget-init.service \ | ||
13 | file://udhcpd.service \ | ||
14 | file://udhcpd.conf \ | ||
15 | file://bone-gmass-eject.rules \ | ||
16 | file://udhcpd.rules \ | ||
17 | file://g-storage-reinsert.sh \ | ||
18 | file://g-ether-start-service.sh \ | ||
19 | file://g-ether-load.sh \ | ||
20 | file://update-image-info-on-mmcblk0p1.sh \ | ||
21 | " | ||
22 | |||
23 | do_install() { | ||
24 | install -d ${D}${base_libdir}/systemd/system/basic.target.wants | ||
25 | install -m 0644 ${WORKDIR}/*.service ${D}${base_libdir}/systemd/system | ||
26 | |||
27 | for i in ${WORKDIR}/storage-gadget-init.service ; do | ||
28 | install -m 0644 $i ${D}${base_libdir}/systemd/system | ||
29 | ln -sf ../$(basename $i) ${D}${base_libdir}/systemd/system/basic.target.wants/ | ||
30 | done | ||
31 | |||
32 | install -d ${D}${sysconfdir}/udev/rules.d | ||
33 | install -m 0644 ${WORKDIR}/*.rules ${D}${sysconfdir}/udev/rules.d | ||
34 | install -m 0644 ${WORKDIR}/*.conf ${D}${sysconfdir} | ||
35 | |||
36 | install -d ${D}${bindir} | ||
37 | install -m 0755 ${WORKDIR}/*.sh ${D}${bindir} | ||
38 | } | ||
39 | |||
40 | PACKAGES =+ "${PN}-storage ${PN}-network ${PN}-udhcpd" | ||
41 | |||
42 | ALLOW_EMPTY:${PN} = "1" | ||
43 | |||
44 | FILES:${PN}-storage = "${base_libdir}/systemd/system/storage-gadget-init.service \ | ||
45 | ${base_libdir}/systemd/system/basic.target.wants/storage-gadget-init.service \ | ||
46 | ${bindir}/g-storage-reinsert.sh \ | ||
47 | ${bindir}/update-image-info-on-mmcblk0p1.sh \ | ||
48 | ${sysconfdir}/udev/rules.d/bone-gmass-eject.rules" | ||
49 | |||
50 | FILES:${PN}-network = "${base_libdir}/systemd/system/network-gadget-init.service \ | ||
51 | ${base_libdir}/systemd/system/basic.target.wants/network-gadget-init.service \ | ||
52 | ${bindir}/g-ether-load.sh \ | ||
53 | ${bindir}/g-ether-start-service.sh \ | ||
54 | ${sysconfdir}/udev/rules.d/udhcpd.rules" | ||
55 | |||
56 | FILES:${PN}-udhcpd = "${base_libdir}/systemd/system/udhcpd.service \ | ||
57 | ${base_libdir}/systemd/system/basic.target.wants/udhcpd.service \ | ||
58 | ${sysconfdir}/udhcpd.conf" | ||
59 | |||
60 | RRECOMMENDS:${PN} = "${PN}-storage ${PN}-network ${PN}-udhcpd" | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules new file mode 100644 index 00000000..ee6f93e2 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules | |||
@@ -0,0 +1 @@ | |||
SUBSYSTEM=="block",ACTION=="change",KERNEL=="mmcblk0p1",RUN+="/usr/bin/g-ether-start-service.sh" | |||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-ether-load.sh b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-ether-load.sh new file mode 100755 index 00000000..f9400649 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-ether-load.sh | |||
@@ -0,0 +1,46 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | function get_devmem() | ||
4 | { | ||
5 | /usr/bin/devmem2 $1 | grep ": " | cut -d ":" -f 2|cut -d "x" -f 2 | ||
6 | } | ||
7 | |||
8 | function hex_to_mac_addr() | ||
9 | { | ||
10 | addr=$1 | ||
11 | n=0 | ||
12 | mac_addr=$(echo ${addr} | while read -r -n2 c; do | ||
13 | if [ ! -z "$c" ]; then | ||
14 | if [ $n -ne 0 ] ; then | ||
15 | echo -n ":${c}" | ||
16 | else | ||
17 | echo -n "${c}" | ||
18 | fi | ||
19 | fi | ||
20 | n=$(($n+1)) | ||
21 | done) | ||
22 | echo ${mac_addr} | ||
23 | } | ||
24 | |||
25 | function reverse_bytes() | ||
26 | { | ||
27 | addr=$1 | ||
28 | New_addr=$(echo ${addr} | while read -r -n2 c; do | ||
29 | if [ ! -z "$c" ]; then | ||
30 | New_addr=${c}${New_addr} | ||
31 | else echo | ||
32 | echo ${New_addr} | ||
33 | fi | ||
34 | done) | ||
35 | echo ${New_addr} | ||
36 | } | ||
37 | |||
38 | DEVMEM_ADDR_LO=$(get_devmem 0x44e10638|bc) | ||
39 | DEVMEM_ADDR_LO=$(reverse_bytes ${DEVMEM_ADDR_LO}) | ||
40 | |||
41 | DEVMEM_ADDR_HI=$(get_devmem 0x44e1063C) | ||
42 | DEVMEM_ADDR_HI=$(reverse_bytes ${DEVMEM_ADDR_HI}) | ||
43 | |||
44 | DEV_ADDR=$(hex_to_mac_addr "${DEVMEM_ADDR_HI}${DEVMEM_ADDR_LO}") | ||
45 | |||
46 | modprobe g_ether host_addr=${DEV_ADDR} | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-ether-start-service.sh b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-ether-start-service.sh new file mode 100755 index 00000000..6e73b155 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-ether-start-service.sh | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/sh | ||
2 | if [ -a /sys/devices/platform/omap/musb-ti81xx/musb-hdrc.0/gadget/lun0/file ] | ||
3 | then | ||
4 | x=$(cat /sys/devices/platform/omap/musb-ti81xx/musb-hdrc.0/gadget/lun0/file) | ||
5 | if [ -z "$x" ] | ||
6 | then | ||
7 | /bin/systemctl stop storage-gadget-init.service | ||
8 | /bin/systemctl start network-gadget-init.service | ||
9 | fi | ||
10 | fi | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh new file mode 100755 index 00000000..d358640a --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | /bin/systemctl stop storage-gadget-init.service | ||
3 | /bin/systemctl stop network-gadget-init.service | ||
4 | /bin/systemctl start storage-gadget-init.service | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/network-gadget-init.service b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/network-gadget-init.service new file mode 100644 index 00000000..0ee29147 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/network-gadget-init.service | |||
@@ -0,0 +1,11 @@ | |||
1 | [Unit] | ||
2 | Description=Start USB Ethernet gadget | ||
3 | Conflicts=storage-gadget-init.service | ||
4 | |||
5 | [Service] | ||
6 | RemainAfterExit=yes | ||
7 | ExecStart=/usr/bin/g-ether-load.sh | ||
8 | ExecStop=/sbin/rmmod g_ether | ||
9 | |||
10 | [Install] | ||
11 | WantedBy=gether.target | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/storage-gadget-init.service b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/storage-gadget-init.service new file mode 100644 index 00000000..9a8513e8 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/storage-gadget-init.service | |||
@@ -0,0 +1,11 @@ | |||
1 | [Unit] | ||
2 | Description=Start usb mass storage gadget | ||
3 | After=dev-mmcblk0p1.device | ||
4 | |||
5 | [Service] | ||
6 | RemainAfterExit=yes | ||
7 | ExecStart=/sbin/modprobe g_mass_storage file=/dev/mmcblk0p1 cdrom=0 stall=0 removable=1 nofua=1 | ||
8 | ExecStop=/sbin/rmmod g_mass_storage | ||
9 | |||
10 | [Install] | ||
11 | WantedBy=basic.target | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.conf b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.conf new file mode 100644 index 00000000..3bcf00f0 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.conf | |||
@@ -0,0 +1,5 @@ | |||
1 | start 192.168.7.1 | ||
2 | end 192.168.7.1 | ||
3 | interface usb0 | ||
4 | max_leases 1 | ||
5 | option subnet 255.255.255.252 | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.rules b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.rules new file mode 100644 index 00000000..db65f9ac --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.rules | |||
@@ -0,0 +1,2 @@ | |||
1 | SUBSYSTEM=="net",ACTION=="add",KERNEL=="usb0",RUN+="/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252",RUN+="/bin/systemctl start udhcpd.service" | ||
2 | SUBSYSTEM=="net",ACTION=="remove",KERNEL=="usb0",RUN+="/bin/systemctl stop udhcpd.service" | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.service b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.service new file mode 100644 index 00000000..1f4ac688 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/udhcpd.service | |||
@@ -0,0 +1,12 @@ | |||
1 | [Unit] | ||
2 | Description=DHCP server for USB0 network gadget | ||
3 | After=dev-usb0.device | ||
4 | Conflicts=storage-gadget-init.service | ||
5 | |||
6 | [Service] | ||
7 | ExecStart=/usr/sbin/udhcpd -f -S /etc/udhcpd.conf | ||
8 | ExecStop=/bin/kill -TERM $MAINPID | ||
9 | KillSignal=SIGINT | ||
10 | |||
11 | [Install] | ||
12 | WantedBy=gether.target | ||
diff --git a/meta-ti-extras/recipes-ti/beagleboard/gadget-init/update-image-info-on-mmcblk0p1.sh b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/update-image-info-on-mmcblk0p1.sh new file mode 100755 index 00000000..a4daf734 --- /dev/null +++ b/meta-ti-extras/recipes-ti/beagleboard/gadget-init/update-image-info-on-mmcblk0p1.sh | |||
@@ -0,0 +1,37 @@ | |||
1 | #!/bin/sh | ||
2 | mount /dev/mmcblk0p1 /mnt | ||
3 | echo "Image info snapshot" > /mnt/info.txt | ||
4 | |||
5 | echo >> /mnt/info.txt | ||
6 | echo "/etc/angstrom-version:" >> /mnt/info.txt | ||
7 | cat /etc/angstrom-version >> /mnt/info.txt | ||
8 | |||
9 | echo >> /mnt/info.txt | ||
10 | echo "/proc/cpuinfo:" >> /mnt/info.txt | ||
11 | cat /proc/cpuinfo >> /mnt/info.txt | ||
12 | |||
13 | echo >> /mnt/info.txt | ||
14 | echo "uname -a:" >> /mnt/info.txt | ||
15 | uname -a >> /mnt/info.txt | ||
16 | |||
17 | echo >> /mnt/info.txt | ||
18 | echo "/proc/cmdline:" >> /mnt/info.txt | ||
19 | cat /proc/cmdline >> /mnt/info.txt | ||
20 | |||
21 | echo >> /mnt/info.txt | ||
22 | echo "ifconfig:" >> /mnt/info.txt | ||
23 | ifconfig >> /mnt/info.txt | ||
24 | |||
25 | echo >> /mnt/info.txt | ||
26 | echo "/etc/angstrom-build-info:" >> /mnt/info.txt | ||
27 | cat /etc/angstrom-build-info >> /mnt/info.txt | ||
28 | |||
29 | echo >> /mnt/info.txt | ||
30 | echo "/etc/image-version-info:" >> /mnt/info.txt | ||
31 | cat /etc/image-version-info >> /mnt/info.txt | ||
32 | |||
33 | echo >> /mnt/info.txt | ||
34 | echo "opkg list-installed:" >> /mnt/info.txt | ||
35 | opkg list-installed >> /mnt/info.txt | ||
36 | |||
37 | umount /mnt | ||