aboutsummaryrefslogtreecommitdiff
path: root/recipes-misc/de10-nano-usb-gadget
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-misc/de10-nano-usb-gadget')
-rw-r--r--recipes-misc/de10-nano-usb-gadget/de10-nano-usb-gadget.bb63
-rw-r--r--recipes-misc/de10-nano-usb-gadget/files/de10-nano-gadget-init.service10
-rw-r--r--recipes-misc/de10-nano-usb-gadget/files/de10-nano-gadget-init.sh10
-rw-r--r--recipes-misc/de10-nano-usb-gadget/files/udhcpd.conf5
4 files changed, 88 insertions, 0 deletions
diff --git a/recipes-misc/de10-nano-usb-gadget/de10-nano-usb-gadget.bb b/recipes-misc/de10-nano-usb-gadget/de10-nano-usb-gadget.bb
new file mode 100644
index 0000000..9c09c00
--- /dev/null
+++ b/recipes-misc/de10-nano-usb-gadget/de10-nano-usb-gadget.bb
@@ -0,0 +1,63 @@
+SUMMARY = "DE-Nano Units to initialize usb gadgets"
+DESCRIPTION = "Scripts to start usb gadget for usb mass storage, ethernet, and serial interfaces"
+AUTHOR = "Dalon Westergreen <dwesterg@gmail.com>"
+SECTION = "DE10-Nano"
+
+PR = "r0"
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+inherit systemd
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+SRCREV = "e191339d28d6d26ea5a9a5aedf3c04047cc04963"
+PV = "1.0${PR}+git${SRCPV}"
+
+SRC_URI = "file://de10-nano-gadget-init.service \
+ file://udhcpd.conf \
+ file://de10-nano-gadget-init.sh \
+ git://github.com/01org/de10-nano-drivers.git;protocol=https \
+ "
+
+do_install() {
+ install -d ${D}${base_libdir}/systemd/system
+ install -m 0644 ${WORKDIR}/*.service ${D}${base_libdir}/systemd/system
+
+ install -d ${D}${sysconfdir}
+ install -m 0644 ${WORKDIR}/*.conf ${D}${sysconfdir}
+
+ install -d ${D}${bindir}
+ install -m 0755 ${WORKDIR}/*.sh ${D}${bindir}
+
+ install -d ${D}${sysconfdir}/systemd/system/getty.target.wants
+ ( cd ${D}${sysconfdir}/systemd/system/getty.target.wants && ln -s /lib/systemd/system/serial-getty@.service serial-getty@ttyGS0.service )
+
+ install -d ${D}${datadir}/${PN}
+ tar -xzvf ${WORKDIR}/git/fat_image.img.tgz -C ${D}${datadir}/${PN}
+}
+
+PACKAGES =+ "${PN}-network ${PN}-udhcpd"
+
+ALLOW_EMPTY_${PN} = "1"
+
+FILES_${PN} = "${base_libdir}/systemd/system/de10-nano-gadget-init.service \
+ ${sysconfdir}/systemd/ \
+ ${datadir}/${PN}/ \
+ ${datadir}/${PN}/fat_image.img \
+ "
+
+FILES_${PN}-network = "${base_libdir}/systemd/system/network-gadget-init.service \
+ ${bindir}/de10-nano-gadget-init.sh \
+ ${datadir}/${PN}"
+
+FILES_${PN}-udhcpd = "${sysconfdir}/udhcpd.conf"
+
+RRECOMMENDS_${PN} = "${PN}-network ${PN}-udhcpd"
+RREPLACES_${PN} = "${PN}-storage"
+
+
+NATIVE_SYSTEMD_SUPPORT = "1"
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "de10-nano-gadget-init.service"
diff --git a/recipes-misc/de10-nano-usb-gadget/files/de10-nano-gadget-init.service b/recipes-misc/de10-nano-usb-gadget/files/de10-nano-gadget-init.service
new file mode 100644
index 0000000..4e7f7de
--- /dev/null
+++ b/recipes-misc/de10-nano-usb-gadget/files/de10-nano-gadget-init.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Start usb mass storage gadget
+After=dev-mmcblk0p1.device
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/de10-nano-gadget-init.sh
+
+[Install]
+WantedBy=basic.target
diff --git a/recipes-misc/de10-nano-usb-gadget/files/de10-nano-gadget-init.sh b/recipes-misc/de10-nano-usb-gadget/files/de10-nano-gadget-init.sh
new file mode 100644
index 0000000..4bfa204
--- /dev/null
+++ b/recipes-misc/de10-nano-usb-gadget/files/de10-nano-gadget-init.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+modprobe g_multi file=/usr/share/de10-nano-usb-gadget/fat_image.img
+
+sleep 5
+
+rm /var/lib/misc/udhcpd.leases
+/sbin/ifconfig usb0 hw ether 00:07:ed:01:02:03
+/sbin/ifconfig usb0 192.168.7.1 netmask 255.255.255.0
+/usr/sbin/udhcpd -fS -I 192.168.7.1 /etc/udhcpd.conf
diff --git a/recipes-misc/de10-nano-usb-gadget/files/udhcpd.conf b/recipes-misc/de10-nano-usb-gadget/files/udhcpd.conf
new file mode 100644
index 0000000..78102f6
--- /dev/null
+++ b/recipes-misc/de10-nano-usb-gadget/files/udhcpd.conf
@@ -0,0 +1,5 @@
+start 192.168.7.5
+end 192.168.7.6
+interface usb0
+max_leases 1
+option subnet 255.255.255.0