diff --git a/conf/machine/am335x-nbhw16.conf b/conf/machine/am335x-nbhw16.conf new file mode 100644 index 0000000..9150c5a --- /dev/null +++ b/conf/machine/am335x-nbhw16.conf @@ -0,0 +1,23 @@ +#@TYPE: Machine +#@NAME: BeagleBone machine +#@DESCRIPTION: Machine configuration for the http://beagleboard.org/bone board + +require conf/machine/include/ti33x.inc + +IMAGE_FSTYPES += "tar.gz cpio cpio.gz.u-boot" +IMAGE_CLASSES += "image_types_uboot" + +MACHINE_EXTRA_RRECOMMENDS = " kernel-modules kernel-devicetree" + +KERNEL_DEFCONFIG = "nbhw16_defconfig" +KERNEL_DEVICETREE = "am335x-nbhw16.dtb" +KERNEL_IMAGETYPE = "zImage" + +UBOOT_MACHINE = "am335x_nbhw16_config" + +PREFERRED_PROVIDER_virtual/kernel = "linux-netmodule" +SRCREV_pn-linux-netmodule = "nbhw16-4.4" +PREFERRED_VERSION_linux = "4.4%" + +SERIAL_CONSOLE = "115200 ttyO0" + diff --git a/conf/machine/beaglebone.conf b/conf/machine/beaglebone.conf new file mode 100644 index 0000000..87e630c --- /dev/null +++ b/conf/machine/beaglebone.conf @@ -0,0 +1,22 @@ +#@TYPE: Machine +#@NAME: BeagleBone machine +#@DESCRIPTION: Machine configuration for the http://beagleboard.org/bone board + +require conf/machine/include/ti33x.inc + +IMAGE_FSTYPES += "tar.gz cpio cpio.gz.u-boot" +IMAGE_CLASSES += "image_types_uboot" + +MACHINE_EXTRA_RRECOMMENDS = " kernel-modules kernel-devicetree" + +KERNEL_DEFCONFIG = "nbhw16_defconfig" +KERNEL_DEVICETREE = "am335x-boneblack.dtb" +KERNEL_IMAGETYPE = "zImage" + +UBOOT_MACHINE = "am335x_boneblack_config" + +PREFERRED_PROVIDER_virtual/kernel = "linux-netmodule" +SRCREV_pn-linux-netmodule = "nbhw16-4.4" +PREFERRED_VERSION_linux = "4.4%" + +SERIAL_CONSOLE = "115200 ttyO0" diff --git a/conf/machine/include/ti33x.inc b/conf/machine/include/ti33x.inc new file mode 100644 index 0000000..ba24bb9 --- /dev/null +++ b/conf/machine/include/ti33x.inc @@ -0,0 +1,40 @@ +SOC_FAMILY = "ti33x" +require conf/machine/include/soc-family.inc + +DEFAULTTUNE ?= "cortexa8thf-neon" +require conf/machine/include/tune-cortexa8.inc + +PREFERRED_PROVIDER_virtual/xserver = "xserver-xorg" + +# For built-in LCD, add xf86-input-tslib +XSERVER = "xserver-xorg \ + xf86-input-evdev \ + xf86-input-mouse \ + xf86-video-fbdev \ + xf86-input-keyboard" + +# Default to external video, change to smallscreen for built-in LCD +GUI_MACHINE_CLASS = "bigscreen" + +# Increase this everytime you change something in the kernel +MACHINE_KERNEL_PR = "r22" + +# Default providers, may need to override for specific machines +PREFERRED_PROVIDER_virtual/kernel = "linux-mainline" +PREFERRED_PROVIDER_virtual/bootloader = "u-boot-ti-staging" +PREFERRED_PROVIDER_u-boot = "u-boot-ti-staging" + +KERNEL_IMAGETYPE = "uImage" + +UBOOT_ARCH = "arm" +UBOOT_MACHINE = "am335x_evm_config" + +UBOOT_ENTRYPOINT = "0x80008000" +UBOOT_LOADADDRESS = "0x80008000" + +# Use the expected value of the ubifs filesystem's volume name in the kernel +# and u-boot. +UBI_VOLNAME = "rootfs" + +# List common SoC features, may need to add touchscreen for specific machines +MACHINE_FEATURES = "kernel26 apm usbgadget usbhost vfat ext2 screen alsa ethernet sgx" diff --git a/recipes-demo/nbhw16-ctrl/nbhw16-ctrl.bb b/recipes-demo/nbhw16-ctrl/nbhw16-ctrl.bb new file mode 100644 index 0000000..c3c5dd1 --- /dev/null +++ b/recipes-demo/nbhw16-ctrl/nbhw16-ctrl.bb @@ -0,0 +1,15 @@ +DESCRIPTION = "NBHW16 python script to control the HW" +HOMEPAGE = "http://www.netmodule.com/" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Proprietary;md5=0557f9d92cf58f2ccdd50f62f8ac0b28" +RDEPENDS_${PN} = "python-subprocess" + +PV = "1.0.0" + +SRC_URI = " \ + file://nbhw16-ctrl.py \ + " + +do_install () { + install -D -m 0755 ${WORKDIR}/nbhw16-ctrl.py ${D}/${bindir}/nbhw16-ctrl +} diff --git a/recipes-demo/nbhw16-ctrl/nbhw16-ctrl/nbhw16-ctrl.py b/recipes-demo/nbhw16-ctrl/nbhw16-ctrl/nbhw16-ctrl.py new file mode 100644 index 0000000..5e1bc8e --- /dev/null +++ b/recipes-demo/nbhw16-ctrl/nbhw16-ctrl/nbhw16-ctrl.py @@ -0,0 +1,95 @@ +#!/usr/bin/python + +import subprocess +import time +from optparse import OptionParser + + +WLAN_INTERFACE = "wlan0" +init = None + + +def call_and_throw(cmd): + if subprocess.call(cmd, shell=True): + raise RuntimeError("Command {0} failed".format(cmd)) + + +def write_to_modem(data, read=False): + global init + if init is None: + init = True + call_and_throw("stty -F /dev/ttyUSB0 -echo -echok -echoe") + + f = open("/dev/ttyUSB0", "r+") + f.write(data) + if read: + time.sleep(0.5) + while f.readable() and read: + data += f.readline() + f.close() + return data + + +def get_modem(): + interface = "eth2" + try: + call_and_throw("ifconfig {0} &> /dev/null".format(interface)) + except: + interface = "usb0" + # Make sure that we now have a valid modem + call_and_throw("ifconfig {0} &> /dev/null".format(interface)) + return interface + + +def setup_modem(provider): + if provider == "swisscom": + write_to_modem("AT^NDISDUP=1,1,\"gprs.swisscom.ch\"\r\n") + + if provider == "salt": + write_to_modem("AT^NDISDUP=1,1,\"click\"\r\n") + + call_and_throw("udhcpc -i {0}".format(get_modem())) + + +def setup_ap(): + call_and_throw("ifconfig {0} 192.168.0.1".format(WLAN_INTERFACE)) + # Start udhcpd with config from /etc/udhcpd.conf + call_and_throw("udhcpd") + + +def setup_routing(): + f = open("/proc/sys/net/ipv4/ip_forward", "w") + f.write("1\n") + f.close() + call_and_throw("iptables -t nat -A POSTROUTING -o {0} -j MASQUERADE". + format(get_modem())) + + +def main(): + usage = "usage: %prog [options] arg" + parser = OptionParser(usage) + parser.add_option("-m", "--modem", action="store_true", dest="modem", + help="Create connection over GSM/UMTS/LTE Modem", + default=False) + parser.add_option("-c", "--connection", + action="store_const", dest="connection", + help="Provider of the modem connection (swisscom/salt)", + default="swisscom") + parser.add_option("-a", "--ap", action="store_true", dest="ap", + help="Create an access point", default=False) + parser.add_option("-r", "--routing", action="store_true", dest="routing", + help="Enable routing trough modem", default=False) + + (options, args) = parser.parse_args() + + if options.modem: + setup_modem(options.connection) + + if options.ap: + setup_ap() + + if options.routing: + setup_routing() + +if __name__ == "__main__": + main() diff --git a/recipes-kernel/linux/linux-netmodule_git.bb b/recipes-kernel/linux/linux-netmodule_git.bb index eeec666..b37500a 100755 --- a/recipes-kernel/linux/linux-netmodule_git.bb +++ b/recipes-kernel/linux/linux-netmodule_git.bb @@ -8,10 +8,14 @@ DESCRIPTION = "Linux kernel for various NetModule hardware" LICENSE = "GPLv2" LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7" -SRC_URI = "git://git@gitlab.com/eichest/linux.git;protocol=ssh;nobranch=1" +#SRC_URI = "git://git@gitlab.com/eichest/linux.git;protocol=ssh;nobranch=1" +SRC_URI = "git://gitolite@git/usr/se/linux;protocol=ssh;nobranch=1" SRCREV ??= "master" -PV = "4.5-${SRCPV}" +PV ?= "4.5-${SRCPV}" +PV_beaglebone = "4.4-${SRCPV}" +PV_am335x-nbhw16 = "4.4-${SRCPV}" + PR = "r0" S = "${WORKDIR}/git"