added my Recipes

This commit is contained in:
2024-07-11 14:16:35 +02:00
parent 38bc4f53ac
commit 09b621d929
7118 changed files with 525762 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
# Copyright (C) 2016, STMicroelectronics - All Rights Reserved
# Released under the MIT license (see COPYING.MIT for the terms)
# Tools extracted from 96boards-tools https://github.com/96boards/96boards-tools
SUMMARY = "Tools for resizing the file system"
SECTION = "devel"
LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-or-later;md5=fed54355545ffd980b814dab4a3b312c"
# e2fsprogs for resize2fs
RDEPENDS:${PN} += " e2fsprogs-resize2fs "
SRC_URI = " file://resize-helper.service file://resize-helper file://resize-helper.sh.in"
S = "${WORKDIR}/git"
START_RESIZE_HELPER_SERVICE ?= "1"
inherit systemd update-rc.d
SYSTEMD_PACKAGES += " resize-helper "
SYSTEMD_SERVICE:${PN} = "resize-helper.service"
SYSTEMD_AUTO_ENABLE:${PN} = "${@bb.utils.contains('START_RESIZE_HELPER_SERVICE','1','enable','disable',d)}"
do_install() {
install -d ${D}${systemd_unitdir}/system ${D}${base_sbindir}
install -m 0644 ${WORKDIR}/resize-helper.service ${D}${systemd_unitdir}/system
install -m 0755 ${WORKDIR}/resize-helper ${D}${base_sbindir}
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/resize-helper.sh.in ${D}${sysconfdir}/init.d/resize-helper.sh
sed -i -e "s:@sbindir@:${base_sbindir}:; s:@sysconfdir@:${sysconfdir}:" \
${D}${sysconfdir}/init.d/resize-helper.sh
if [ "${START_RESIZE_HELPER_SERVICE}" -eq 0 ]; then
rm ${D}${sysconfdir}/init.d/resize-helper.sh
echo "#!/bin/sh" > ${D}${sysconfdir}/init.d/resize-helper.sh
chmod +x ${D}${sysconfdir}/init.d/resize-helper.sh
fi
}
INITSCRIPT_NAME = "resize-helper.sh"
INITSCRIPT_PARAMS = "start 22 5 3 ."

View File

@@ -0,0 +1,80 @@
#!/bin/sh
# Copyright (c) Fathi Boudra <fathi.boudra@linaro.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# we must be root
[ $(whoami) = "root" ] || { echo "E: You must be root" && exit 1; }
# we must have few tools
RESIZE2FS=$(which resize2fs) || { echo "E: You must have resize2fs" && exit 1; }
# find root device
# ROOT_DEVICE=$(findmnt --noheadings --output=SOURCE / | cut -d'[' -f1)
DEVICES=$(ls /sys/fs/ext4/)
echo "RESIZE-HELPER START" > /dev/kmsg
# disable service to be sure it will be executed only one time
if [ -f /bin/systemctl ]; then
/bin/systemctl --no-reload disable resize-helper.service
else
rm /etc/rc[35].d/S22resize-helper.sh &> /dev/null
fi
sync
if `grep -q nfsroot /proc/cmdline` ; then
exit 0;
fi
if [ -f /lib/systemd/systemd-growfs ]; then
echo "RESIZE-HELPER: Using systemd-growfs" > /dev/kmsg
# force to mount partitions
if [ -z $(findmnt --noheadings --output=SOURCE /boot|cut -d'[' -f1) ];
then
[ -f /sbin/mount-partitions.sh ] && /sbin/mount-partitions.sh stop
fi
/lib/systemd/systemd-growfs /
/lib/systemd/systemd-growfs /boot
/lib/systemd/systemd-growfs /vendor
/lib/systemd/systemd-growfs /usr/local/
else
echo "RESIZE-HELPER: Using directly resize2fs" > /dev/kmsg
# umount partition before to resize it
[ -f /sbin/mount-partitions.sh ] && /sbin/mount-partitions.sh stop
for device in ${DEVICES}; do
PART_TABLE_TYPE=$(udevadm info --query=property --name=/dev/${device} | grep '^ID_PART_TABLE_TYPE=' | cut -d'=' -f2)
if [ -e /dev/${device} ]; then
if [ "$PART_TABLE_TYPE" = "gpt" ]; then
echo "Resize /dev/${device}"
${RESIZE2FS} "/dev/${device}"
fi
fi
done
fi
df -h > /dev/kmsg
#echo "RESIZE-HELPER: For integrity of file-system after a resize2fs, the system need to be rebooted" > /dev/kmsg
#echo "RESIZE-HELPER REBOOTING of system" > /dev/kmsg
echo "RESIZE-HELPER FINISH" > /dev/kmsg

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Resize root filesystem to fit available disk space
DefaultDependencies=false
After=mount-partitions.service
Before=local-fs.target serial-getty@ttySTM0.service netdata.service
[Service]
Type=oneshot
ExecStartPre=-/bin/udevadm settle
ExecStart=-/sbin/resize-helper
WatchdogSec=45
[Install]
WantedBy=local-fs.target

View File

@@ -0,0 +1,24 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: Resize root filesystem to fit available disk space
# Description: Start resize helper, then remove own init from runlevels,
# as it is required only for first boot. run settle to provide partition
# table details.
### END INIT INFO
DESC="resize helper"
case $1 in
start)
echo "Starting $DESC"
@sbindir@/resize-helper
;;
*)
echo "Usage: @sysconfdir@/init.d/resize-helper.sh {start}" >&2
exit 1
;;
esac
exit 0
# vim:noet

View File

@@ -0,0 +1,32 @@
# Copyright (C) 2018, STMicroelectronics - All Rights Reserved
# Released under the MIT license (see COPYING.MIT for the terms)
SUMMARY = "The goal is to enable USB gadget configuration"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PV = "1.0"
SRC_URI = " file://stm32_usbotg_eth_config.sh \
file://53-usb-otg.network \
file://97-ustotg.rules \
"
S = "${WORKDIR}/git"
do_install() {
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${systemd_unitdir}/network
install -m 0644 ${WORKDIR}/53-usb-otg.network ${D}${systemd_unitdir}/network
fi
install -d ${D}${base_sbindir}
install -m 0755 ${WORKDIR}/stm32_usbotg_eth_config.sh ${D}${base_sbindir}
# install udev rule
install -D -p -m0644 ${WORKDIR}/97-ustotg.rules ${D}${sysconfdir}/udev/rules.d/97-ustotg.rules
}
FILES:${PN} += "${systemd_unitdir}/network ${sysconfdir}/udev"

View File

@@ -0,0 +1,14 @@
[Match]
Name=usb0
Type=gadget
[Network]
Address=192.168.7.1/24
DHCPServer=yes
KeepConfiguration=yes
[DHCPServer]
ServerAddress=192.168.7.1/24
EmitTimezone=no
EmitRouter=no

View File

@@ -0,0 +1,2 @@
ACTION=="add", SUBSYSTEM=="udc", RUN+="/sbin/stm32_usbotg_eth_config.sh restart"

View File

@@ -0,0 +1,153 @@
#!/bin/sh
#add stm32_eth_config script to enable USB Ethernet & MSC gadget This script configures USB Gadget
#configfs to use USB OTG as a USB Ethernet Gadget with Remote NDIS (RNDIS), well supported by Microsoft
#Windows and Linux.
configfs="/sys/kernel/config/usb_gadget"
g=g1
c=c.1
d="${configfs}/${g}"
func_eth=ncm.0
func_ms=mass_storage.0
VENDOR_ID="0x1d6b"
PRODUCT_ID="0x0104"
IP="192.168.7.2"
NETMASK="255.255.255.0"
#MAC address for ethernet-over-USB can be defined here
MAC_HOST_CUST=""
MAC_DEV_CUST=""
get_mac_address_from_serial_number(){
sha1sum /proc/device-tree/serial-number \
| fold -1 \
| sed -n '1{h;d};2{y/1235679abdef/000444888ccc/;H;d};13{g;s/\n//g;p;q};s/^/:/;N;H;d'
}
do_start() {
if [ ! -d ${configfs} ]; then
modprobe libcomposite
if [ ! -d ${configfs} ]; then
exit 1
fi
fi
if [ -d ${d} ]; then
exit 0
fi
udc=$(ls -1 /sys/class/udc/)
if [ -z $udc ]; then
echo "No UDC driver registered"
exit 1
fi
mkdir "${d}"
echo ${VENDOR_ID} > "${d}/idVendor"
echo ${PRODUCT_ID} > "${d}/idProduct"
echo 0x0200 > "${d}/bcdUSB"
# Windows extension to use IAD (Interface Association Descriptor)
# https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-interface-association-descriptor
echo "0xEF" > "${d}/bDeviceClass"
echo "0x02" > "${d}/bDeviceSubClass"
echo "0x01" > "${d}/bDeviceProtocol"
echo "0x0100" > "${d}/bcdDevice"
mkdir -p "${d}/strings/0x409"
tr -d '\0' < /proc/device-tree/serial-number > "${d}/strings/0x409/serialnumber"
echo "STMicroelectronics" > "${d}/strings/0x409/manufacturer"
echo "STM32MP1" > "${d}/strings/0x409/product"
# Config
mkdir -p "${d}/configs/${c}"
mkdir -p "${d}/configs/${c}/strings/0x409"
echo "Config 1: NCM" > "${d}/configs/${c}/strings/0x409/configuration"
echo 0 > "${d}/configs/${c}/MaxPower"
echo 0xC0 > "${d}/configs/${c}/bmAttributes" # self powered device
# Enable use of OS descriptor (for windows to bind drivers like NCM, RNDIS...
# without additional .inf file)
mkdir -p "${d}/os_desc"
echo "1" > "${d}/os_desc/use"
echo "0xbc" > "${d}/os_desc/b_vendor_code"
echo "MSFT100" > "${d}/os_desc/qw_sign"
# Select windows UsbNcm Host driver
mkdir -p "${d}/functions/${func_eth}"
mkdir -p "${d}/functions/${func_eth}/os_desc/interface.ncm"
echo "WINNCM" > "${d}/functions/${func_eth}/os_desc/interface.ncm/compatible_id"
if [ "$MAC_HOST_CUST" != "" ]; then
echo $MAC_HOST_CUST > "${d}/functions/${func_eth}/host_addr"
else
mac_host=$(get_mac_address_from_serial_number)
echo $mac_host > "${d}/functions/${func_eth}/host_addr"
fi
if [ "$MAC_DEV_CUST" != "" ]; then
echo $MAC_DEV_CUST > "${d}/functions/${func_eth}/dev_addr"
fi
# Set up the rndis device only first
ln -s "${d}/functions/${func_eth}" "${d}/configs/${c}"
ln -s "${d}/configs/${c}" "${d}/os_desc"
echo "${udc}" > "${d}/UDC"
sleep 0.2
interfacename=$(cat ${d}/functions/${func_eth}/ifname 2> /dev/null)
if [ -z "${interfacename}" ];
then
interfacename=usb0
fi
# ifconfig ${interfacename} $IP netmask $NETMASK
ifconfig ${interfacename} up
}
do_stop() {
interfacename=$(cat ${d}/functions/${func_eth}/ifname 2> /dev/null)
if [ -z "${interfacename}" ];
then
echo "Nothing to do"
return
fi
ifconfig ${interfacename} down
sleep 0.2
echo "" > "${d}/UDC"
rm -f "${d}/os_desc/${c}"
[ -d "${d}/configs/${c}/${func_eth}" ] &&rm -f "${d}/configs/${c}/${func_eth}"
[ -d "${d}/strings/0x409/" ] && rmdir "${d}/strings/0x409/"
[ -d "${d}/configs/${c}/strings/0x409" ] && rmdir "${d}/configs/${c}/strings/0x409"
[ -d "${d}/configs/${c}" ] && rmdir "${d}/configs/${c}"
[ -d "${d}/functions/${func_eth}" ] && rmdir "${d}/functions/${func_eth}"
[ -d "${d}" ] && rmdir "${d}"
}
case $1 in
start)
echo "Start usb gadget"
do_start
;;
stop)
echo "Stop usb gadget"
do_stop
;;
restart)
echo "Stop usb gadget"
do_stop
sleep 1
echo "Start usb gadget"
do_start
;;
*)
echo "Usage: $0 (stop | start | restart)"
;;
esac