diff --git a/configs/nonlinear_usb_os_restore_defconfig b/configs/nonlinear_usb_os_restore_defconfig new file mode 100644 index 0000000000..0f935c1ef6 --- /dev/null +++ b/configs/nonlinear_usb_os_restore_defconfig @@ -0,0 +1,115 @@ +BR2_arm=y +BR2_cortex_a8=y +BR2_PRIMARY_SITE="http://h2949050.stratoserver.net/buildroot/" +BR2_CCACHE=y +BR2_OPTIMIZE_3=y +BR2_KERNEL_HEADERS_VERSION=y +BR2_DEFAULT_KERNEL_VERSION="4.0" +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_0=y +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_GLIBC_VERSION_2_23=y +BR2_GCC_VERSION_5_X=y +BR2_EXTRA_GCC_CONFIG_OPTIONS="--with-fpu=vfpv3 --with-float=hard" +BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_GENERATE_LOCALE="en_US" +BR2_TARGET_GENERIC_HOSTNAME="nonlinux" +BR2_TARGET_GENERIC_ISSUE="Nonlinux by Nonlinear-Labs" +BR2_INIT_SYSTEMD=y +BR2_SYSTEM_BIN_SH_BASH=y +BR2_ROOTFS_OVERLAY="nonlinear/fs-overlay-usb-os-restore" +BR2_ROOTFS_POST_BUILD_SCRIPT="nonlinear/scripts/run.sh" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_GIT=y +BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/nonlinear-labs-dev/linux.git" +BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="e02b6242a72c1cc81d4aec8153897efdab2e6ec8" +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/nonlinear-labs-c15/.config" +BR2_LINUX_KERNEL_UIMAGE=y +BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x80008000" +BR2_PACKAGE_BUSYBOX_SELINUX=y +BR2_PACKAGE_ALSA_UTILS=y +BR2_PACKAGE_ALSA_UTILS_ALSACONF=y +BR2_PACKAGE_ALSA_UTILS_ACONNECT=y +BR2_PACKAGE_ALSA_UTILS_ALSALOOP=y +BR2_PACKAGE_ALSA_UTILS_AMIDI=y +BR2_PACKAGE_ALSA_UTILS_AMIXER=y +BR2_PACKAGE_ALSA_UTILS_APLAYMIDI=y +BR2_PACKAGE_ALSA_UTILS_ARECORDMIDI=y +BR2_PACKAGE_ALSA_UTILS_ASEQDUMP=y +BR2_PACKAGE_ALSA_UTILS_ASEQNET=y +BR2_PACKAGE_BZIP2=y +BR2_PACKAGE_E2FSPROGS=y +# BR2_PACKAGE_E2FSPROGS_BADBLOCKS is not set +# BR2_PACKAGE_E2FSPROGS_CHATTR is not set +# BR2_PACKAGE_E2FSPROGS_DUMPE2FS is not set +# BR2_PACKAGE_E2FSPROGS_E2FREEFRAG is not set +# BR2_PACKAGE_E2FSPROGS_E2FSCK is not set +# BR2_PACKAGE_E2FSPROGS_E2LABEL is not set +# BR2_PACKAGE_E2FSPROGS_E2UNDO is not set +# BR2_PACKAGE_E2FSPROGS_FILEFRAG is not set +# BR2_PACKAGE_E2FSPROGS_FSCK is not set +# BR2_PACKAGE_E2FSPROGS_LOGSAVE is not set +# BR2_PACKAGE_E2FSPROGS_LSATTR is not set +# BR2_PACKAGE_E2FSPROGS_MKLOSTFOUND is not set +# BR2_PACKAGE_E2FSPROGS_TUNE2FS is not set +# BR2_PACKAGE_E2FSPROGS_UUIDGEN is not set +BR2_PACKAGE_LINUX_FIRMWARE=y +BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT61=y +BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT73=y +BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT2XX=y +BR2_PACKAGE_LINUX_FIRMWARE_RTL_81XX=y +BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y +BR2_PACKAGE_AVRDUDE=y +BR2_PACKAGE_FREETYPE=y +BR2_PACKAGE_DTC=y +BR2_PACKAGE_DTC_PROGRAMS=y +BR2_PACKAGE_TSLIB=y +BR2_PACKAGE_LIBSOUP=y +BR2_PACKAGE_LIBSOUP_SSL=y +BR2_PACKAGE_BOOST=y +BR2_PACKAGE_GLIBMM=y +BR2_PACKAGE_DHCP=y +BR2_PACKAGE_DHCP_SERVER=y +BR2_PACKAGE_HOSTAPD=y +BR2_PACKAGE_HOSTAPD_EAP=y +BR2_PACKAGE_HOSTAPD_WPS=y +BR2_PACKAGE_IW=y +BR2_PACKAGE_OPENSSH=y +BR2_PACKAGE_RSYNC=y +BR2_PACKAGE_SOCAT=y +BR2_PACKAGE_SSHPASS=y +BR2_PACKAGE_THTTPD=y +BR2_PACKAGE_WIRELESS_TOOLS=y +BR2_PACKAGE_WIRELESS_TOOLS_LIB=y +BR2_PACKAGE_WPA_SUPPLICANT=y +BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y +BR2_PACKAGE_WPA_SUPPLICANT_EAP=y +BR2_PACKAGE_WPA_SUPPLICANT_HOTSPOT=y +BR2_PACKAGE_WPA_SUPPLICANT_WPS=y +BR2_PACKAGE_WPA_SUPPLICANT_CLI=y +BR2_PACKAGE_WPA_SUPPLICANT_WPA_CLIENT_SO=y +BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y +BR2_PACKAGE_UTIL_LINUX_LOGIN_UTILS=y +BR2_PACKAGE_UTIL_LINUX_SFDISK=y +BR2_PACKAGE_C15=y +BR2_PACKAGE_ESPI_DRIVER=y +BR2_PACKAGE_PLAYCONTROLLER_DRIVER=y +BR2_PACKAGE_NONLINEAR_USB_DTS=y +BR2_PACKAGE_NONLINEAR_USB_DTS_REPOSITORY="https://github.com/nonlinear-labs-dev/am335x-dts.git" +BR2_PACKAGE_MXLI=y +BR2_PACKAGE_NLIMAGEMAKER=y +BR2_TARGET_ROOTFS_TAR_GZIP=y +BR2_TARGET_ROOTFS_INITRAMFS=y +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y +BR2_TARGET_UBOOT_CUSTOM_GIT=y +BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/nonlinear-labs-dev/u-boot.git" +BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="nonlinear_v2021.47" +BR2_TARGET_UBOOT_BOARD_DEFCONFIG="nonlinear" +BR2_TARGET_UBOOT_FORMAT_IMG=y +BR2_TARGET_UBOOT_SPL=y +BR2_TARGET_UBOOT_SPL_NAME="MLO" +BR2_PACKAGE_HOST_DTC=y +BR2_PACKAGE_HOST_MKE2IMG=y +BR2_PACKAGE_HOST_UBOOT_TOOLS=y +BR2_PACKAGE_HOST_UTIL_LINUX=y diff --git a/create_usb_stick.sh b/create_usb_stick.sh index a41062b4e0..8d7367c9dc 100755 --- a/create_usb_stick.sh +++ b/create_usb_stick.sh @@ -1,5 +1,13 @@ #!/bin/bash +if [ $# -eq 0 ]; then + printf "Assuming nonlinear-labs-2D.dtb for device tree. \n" + DTB_FILE="nonlinear-labs-2D.dtb" +else + printf "Setting device tree to ${1} \n" + DTB_FILE="${1}" +fi + # THIS MUST POINT TO BUILT BUILDROOT SOURCES=$(readlink -f ../nonlinux) BASEDIR=$(dirname "${0}") @@ -12,6 +20,6 @@ echo ${NLIMAGEMAKER} echo ${SOURCES} gzip -c ${SOURCES}/output/images/rootfs.tar > ${SOURCES}/output/images/rootfs.tar.gz -${NLIMAGEMAKER} -k ${BASEDIR}/output/images/uImage -r ${SOURCES}/output/images/rootfs.tar.gz -d ${BASEDIR}/output/images/am335x-boneblack.dtb -o /tmp/nonlinear.img +${NLIMAGEMAKER} -k ${BASEDIR}/output/images/uImage -r ${SOURCES}/output/images/rootfs.tar.gz -d ${BASEDIR}/output/images/${DTB_FILE} -o /tmp/nonlinear.img echo "Image created: /tmp/nonlinear.img" diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/dhcpd-usbnet.conf b/nonlinear/fs-overlay-usb-os-restore/etc/dhcpd-usbnet.conf new file mode 100644 index 0000000000..4e5600fe4d --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/dhcpd-usbnet.conf @@ -0,0 +1,11 @@ +default-lease-time 600; +max-lease-time 7200; +option domain-name "nonlinear-labs.de"; +option broadcast-address 192.168.7.3; +option subnet-mask 255.255.255.252; + +subnet 192.168.7.0 netmask 255.255.255.252 + { + range 192.168.7.1 192.168.7.1; + } + diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/dhcpd-wlan.conf b/nonlinear/fs-overlay-usb-os-restore/etc/dhcpd-wlan.conf new file mode 100644 index 0000000000..b8609e8942 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/dhcpd-wlan.conf @@ -0,0 +1,11 @@ +default-lease-time 600; +max-lease-time 7200; +option domain-name "nonlinear-labs.de"; +option broadcast-address 192.168.8.31; +option subnet-mask 255.255.255.224; + +subnet 192.168.8.0 netmask 255.255.255.224 + { + range 192.168.8.3 192.168.8.30; + } + diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/fstab b/nonlinear/fs-overlay-usb-os-restore/etc/fstab new file mode 100644 index 0000000000..c9df47d8a1 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/fstab @@ -0,0 +1,9 @@ +# +/dev/root / ext2 rw,noauto 0 1 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts defaults,gid=5,mode=620 0 0 +tmpfs /dev/shm tmpfs mode=0777 0 0 +tmpfs /tmp tmpfs mode=1777 0 0 +tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 +sysfs /sys sysfs defaults 0 0 +/dev/sda1 /mnt/usb-stick auto rw,auto,nofail,user,umask=0000 0 0 diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/hostapd.conf b/nonlinear/fs-overlay-usb-os-restore/etc/hostapd.conf new file mode 100644 index 0000000000..ee9a6aa710 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/hostapd.conf @@ -0,0 +1,10 @@ +ssid=NonLinearInstrument +interface=wlan0 +channel=7 +hw_mode=g +wpa_passphrase=88888888 +wpa=2 +rsn_preauth=1 +rsn_preauth_interfaces=wlan0 +wpa_key_mgmt=WPA-PSK +rsn_pairwise=CCMP diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/modules-load.d/espi_driver.conf b/nonlinear/fs-overlay-usb-os-restore/etc/modules-load.d/espi_driver.conf new file mode 100644 index 0000000000..f7f5386703 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/modules-load.d/espi_driver.conf @@ -0,0 +1,2 @@ +# Load NonlinearLabs espi_driver.ko for emphase devices at boot +espi_driver diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/modules-load.d/lpc_bb_driver.conf b/nonlinear/fs-overlay-usb-os-restore/etc/modules-load.d/lpc_bb_driver.conf new file mode 100644 index 0000000000..7a5b9610bd --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/modules-load.d/lpc_bb_driver.conf @@ -0,0 +1,2 @@ +# Load NonlinearLabs lpc_bb_driver.ko for emphase devices at boot +lpc_bb_driver diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/network/interfaces b/nonlinear/fs-overlay-usb-os-restore/etc/network/interfaces new file mode 100644 index 0000000000..5a3ce71b6e --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/network/interfaces @@ -0,0 +1,8 @@ +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet static + address 192.168.10.11 + netmask 255.255.255.0 + diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/ssh/sshd_config b/nonlinear/fs-overlay-usb-os-restore/etc/ssh/sshd_config new file mode 100644 index 0000000000..c4a3f5acd9 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/ssh/sshd_config @@ -0,0 +1,124 @@ +# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $ + +# This is the sshd server system-wide configuration file. See +# sshd_config(5) for more information. + +# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin + +# The strategy used for options in the default sshd_config shipped with +# OpenSSH is to specify options with their default value where +# possible, but leave them commented. Uncommented options change a +# default value. + +#Port 22 +#AddressFamily any +#ListenAddress 0.0.0.0 +#ListenAddress :: + +# Disable legacy (protocol version 1) support in the server for new +# installations. In future the default will change to require explicit +# activation of protocol 1 +Protocol 2 + +# HostKey for protocol version 1 +#HostKey /etc/ssh_host_key +# HostKeys for protocol version 2 +#HostKey /etc/ssh_host_rsa_key +#HostKey /etc/ssh_host_dsa_key + +# Lifetime and size of ephemeral version 1 server key +#KeyRegenerationInterval 1h +#ServerKeyBits 1024 + +# Logging +# obsoletes QuietMode and FascistLogging +#SyslogFacility AUTH +#LogLevel INFO + +# Authentication: + +#LoginGraceTime 2m +PermitRootLogin yes +#StrictModes yes +#MaxAuthTries 6 +#MaxSessions 10 + +#RSAAuthentication yes +#PubkeyAuthentication yes +AuthorizedKeysFile .ssh/authorized_keys + +# For this to work you will also need host keys in /etc/ssh_known_hosts +#RhostsRSAAuthentication no +# similar for protocol version 2 +#HostbasedAuthentication no +# Change to yes if you don't trust ~/.ssh/known_hosts for +# RhostsRSAAuthentication and HostbasedAuthentication +#IgnoreUserKnownHosts no +# Don't read the user's ~/.rhosts and ~/.shosts files +#IgnoreRhosts yes + +# To disable tunneled clear text passwords, change to no here! +#PasswordAuthentication yes +PermitEmptyPasswords yes + +# Change to no to disable s/key passwords +#ChallengeResponseAuthentication yes + +# Kerberos options +#KerberosAuthentication no +#KerberosOrLocalPasswd yes +#KerberosTicketCleanup yes +#KerberosGetAFSToken no + +# GSSAPI options +#GSSAPIAuthentication no +#GSSAPICleanupCredentials yes + +# Set this to 'yes' to enable PAM authentication, account processing, +# and session processing. If this is enabled, PAM authentication will +# be allowed through the ChallengeResponseAuthentication and +# PasswordAuthentication. Depending on your PAM configuration, +# PAM authentication via ChallengeResponseAuthentication may bypass +# the setting of "PermitRootLogin without-password". +# If you just want the PAM account and session checks to run without +# PAM authentication, then enable this but set PasswordAuthentication +# and ChallengeResponseAuthentication to 'no'. +#UsePAM no + +#AllowAgentForwarding yes +#AllowTcpForwarding yes +#GatewayPorts no +X11Forwarding no +#X11DisplayOffset 10 +#X11UseLocalhost yes +#PrintMotd yes +PrintMotd no +#PrintLastLog yes +#TCPKeepAlive yes +#UseLogin no +#UsePrivilegeSeparation yes +#PermitUserEnvironment no +#Compression delayed +#ClientAliveInterval 0 +#ClientAliveCountMax 3 +UseDNS no +#PidFile /var/run/sshd.pid +#MaxStartups 10 +#PermitTunnel no +#ChrootDirectory none + +# no default banner path +#Banner none + +ClientAliveInterval 15 +ClientAliveCountMax 4 +AcceptEnv LANG LC_* + +# override default of no subsystems +Subsystem sftp /usr/libexec/sftp-server + +# Example of overriding settings on a per-user basis +#Match User anoncvs +# X11Forwarding no +# AllowTcpForwarding no +# ForceCommand cvs server diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/journald.conf b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/journald.conf new file mode 100644 index 0000000000..eae6ec1268 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/journald.conf @@ -0,0 +1,35 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# See journald.conf(5) for details + +[Journal] +Storage=persistent +#Compress=yes +#Seal=yes +#SplitMode=uid +#SyncIntervalSec=5m +#RateLimitInterval=30s +#RateLimitBurst=1000 +#SystemMaxUse= +#SystemKeepFree= +#SystemMaxFileSize= +#RuntimeMaxUse= +#RuntimeKeepFree= +#RuntimeMaxFileSize= +#MaxRetentionSec= +#MaxFileSec=1month +#ForwardToSyslog=no +#ForwardToKMsg=no +#ForwardToConsole=no +#ForwardToWall=yes +#TTYPath=/dev/console +#MaxLevelStore=debug +#MaxLevelSyslog=debug +#MaxLevelKMsg=notice +#MaxLevelConsole=info +#MaxLevelWall=emerg diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/accesspoint.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/accesspoint.service new file mode 100644 index 0000000000..25e5f3063a --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/accesspoint.service @@ -0,0 +1,9 @@ +[Unit] +Description=AccessPoint daemon +After=syslog.target network.target + +[Service] +ExecStart=/usr/sbin/hostapd /etc/hostapd.conf + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/dhcpd-usbnet.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/dhcpd-usbnet.service new file mode 100644 index 0000000000..c0fb29900d --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/dhcpd-usbnet.service @@ -0,0 +1,10 @@ +[Unit] +Description=DHCP Server for usbnet +After=syslog.target network.target + +[Service] +ExecStartPre=/bin/touch /tmp/dhcpd-usbnet.leases +ExecStart=/usr/sbin/dhcpd -d -q -cf /etc/dhcpd-usbnet.conf -lf /tmp/dhcpd-usbnet.leases -pf /tmp/usbnet.pid usb0 + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/dhcpd-wlan.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/dhcpd-wlan.service new file mode 100644 index 0000000000..543ac49cef --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/dhcpd-wlan.service @@ -0,0 +1,12 @@ +[Unit] +Description=DHCP Server for wlan +After=syslog.target network.target + +[Service] +ExecStartPre=/bin/touch /tmp/dhcpd-wlan.leases +ExecStart=/usr/sbin/dhcpd -d -q -cf /etc/dhcpd-wlan.conf -lf /tmp/dhcpd-wlan.leases -pf /tmp/wlan.pid wlan0 +Restart=on-failure +RestartSec=3 + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/redirect-to-epc.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/redirect-to-epc.service new file mode 120000 index 0000000000..57001c5d59 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/redirect-to-epc.service @@ -0,0 +1 @@ +nonlinear/fs-overlay/etc/systemd/system/redirect-to-epc.service \ No newline at end of file diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/restore-c15-os.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/restore-c15-os.service new file mode 120000 index 0000000000..d8f5a48d8e --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/restore-c15-os.service @@ -0,0 +1 @@ +../restore-c15-os.service \ No newline at end of file diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/sshd.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/sshd.service new file mode 120000 index 0000000000..d41264ec26 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/multi-user.target.wants/sshd.service @@ -0,0 +1 @@ +../sshd.service \ No newline at end of file diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/redirect-to-epc.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/redirect-to-epc.service new file mode 100644 index 0000000000..c9fc602f4d --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/redirect-to-epc.service @@ -0,0 +1,13 @@ +[Unit] +Description=Redirect all incoming http traffic to ePC +After=syslog.target network.target + +[Service] +ExecStart=/bin/socat TCP-LISTEN:80,fork TCP:192.168.10.10:80 +Restart=always +RestartSec=1 +StartLimitInterval=200 +StartLimitBurst=5 + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/restore-c15-os.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/restore-c15-os.service new file mode 100644 index 0000000000..632cb81ca4 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/restore-c15-os.service @@ -0,0 +1,10 @@ +[Unit] +Description=Restores the C15 OS depending on the update.tar on the USB +After=network.target +Wants=network.target + +[Service] +ExecStart=/usr/bin/restore-c15-os.sh + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/sshd.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/sshd.service new file mode 100644 index 0000000000..b5e96b3a25 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/sshd.service @@ -0,0 +1,11 @@ +[Unit] +Description=OpenSSH server daemon +After=syslog.target network.target auditd.service + +[Service] +ExecStartPre=/usr/bin/ssh-keygen -A +ExecStart=/usr/sbin/sshd -D -e +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/usbnet.service b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/usbnet.service new file mode 100644 index 0000000000..6c79a07785 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/systemd/system/usbnet.service @@ -0,0 +1,11 @@ +[Unit] +Description=Load Ethernet over USB module +After=syslog.target network.target + +[Service] +Type=idle +ExecStart=/sbin/modprobe g_ether +TimeoutStartSec=30 + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-accesspoint.rules b/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-accesspoint.rules new file mode 100644 index 0000000000..cb7c0369a6 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-accesspoint.rules @@ -0,0 +1,2 @@ +SUBSYSTEM=="net",ACTION=="add",KERNEL=="wlan0",RUN+="/sbin/ifconfig wlan0 192.168.8.2 netmask 255.255.255.224",RUN+="/bin/systemctl start accesspoint.service",RUN+="/bin/systemctl start dhcpd-wlan.service" +SUBSYSTEM=="net",ACTION=="remove",KERNEL=="wlan0",RUN+="/bin/systemctl stop accesspoint.service",RUN+="/bin/systemctl stop dhcpd-wlan.service" diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-gether.rules b/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-gether.rules new file mode 100644 index 0000000000..ee5521d0be --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-gether.rules @@ -0,0 +1 @@ +SUBSYSTEM=="usb", ATTR{idVendor}=="1d6b", ATTR{idProduct}=="0002", ACTION=="add", RUN+="/bin/systemctl start usbnet.service" diff --git a/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-usbnet.rules b/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-usbnet.rules new file mode 100644 index 0000000000..b5f3dc9d39 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/etc/udev/rules.d/100-usbnet.rules @@ -0,0 +1,2 @@ +SUBSYSTEM=="net",ACTION=="add",KERNEL=="usb0",RUN+="/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252",RUN+="/bin/systemctl start dhcpd-usbnet.service" +SUBSYSTEM=="net",ACTION=="remove",KERNEL=="usb0",RUN+="/bin/systemctl stop dhcpd.service" diff --git a/nonlinear/fs-overlay-usb-os-restore/root/.ssh/authorized_keys b/nonlinear/fs-overlay-usb-os-restore/root/.ssh/authorized_keys new file mode 100644 index 0000000000..3c128beb2c --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/root/.ssh/authorized_keys @@ -0,0 +1,2 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlxMKSV0nN1BR5kbfCjzgWcBP/737m2/zWUN39A/w2ye8C/IC0n20KgfuqtURj9wH2e40OZ/9DHz0r5vfmuUtr4NPtsmclOSXHMVKJrVySgXEnDyoKZYjQm4jU+j0jeNb3PQLiwqjuX8zxmMB4NuTSIHlI6bqh96kg18X7gD+Oxm5krIT+bRlA1YHkxjsohC5KEQ70O9TNp/waIdz713e+iSAfJ3MlrCcefDpLag10K2cncuzNqregW0LcIQ7e7I7EYbRnoTwb80YuFyc/Ru60KVoFjEAJAsJ9AQoRAQaq0vr9KCcnA0t5GKvegZBpD+9IXf0pvxdqJ1x67VCiAisHQ== hhoegelo@hho +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5Zf7MemvmDPZBXCt3NS52PCV1+cUK4Fkcuya56peiPNgjx8ZSc6zh5FJCfpI6VwwYO7ZxMqBbXf1rLfJagcYOwhwFrq/9F3VZzGmLBR5Rzv4vCnaYBxoWCThn8DB3VeRX3WCdxcDndwfLDB3DkLXdiF+FVTgLrtwPoCUJlntcsCRiJGeQbBKHgSKKeNLkB6WRQF3PPFb6WKCewsnk81hLwyDJOVW5gb2sQHtNUi+PZJbP6X+33Z5o0hX20kelWkh7I61EQdzbxhny+kj/RpnFMcM2JR5jYDlVwGbxWY/MzN4xGwo5CZQx/3M9mQcmRq2pMrjj/+5puSFYM5WFOy07 billserver@localhost.localdomain diff --git a/nonlinear/fs-overlay-usb-os-restore/root/uEnv.txt b/nonlinear/fs-overlay-usb-os-restore/root/uEnv.txt new file mode 100755 index 0000000000..6d6135fa5b --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/root/uEnv.txt @@ -0,0 +1,3 @@ +uenvcmd=mmc rescan; load mmc 1:2 ${loadaddr} boot/uImage; load mmc 1:2 ${fdtaddr} boot/nonlinear-labs-2D.dtb; setenv mmcroot /dev/mmcblk0p2 ro; setenv mmcrootfstype ext4 rootwait; setenv bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}; bootm ${loadaddr} - ${fdtaddr} +uname_r=nonlinear +uname_boot=mmc rescan; load mmc 1:2 ${loadaddr} boot/uImage; load mmc 1:2 ${fdtaddr} boot/nonlinear-labs-2D.dtb; setenv mmcroot /dev/mmcblk0p2 ro; setenv mmcrootfstype ext4 rootwait; setenv bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}; bootm ${loadaddr} - ${fdtaddr} diff --git a/nonlinear/fs-overlay-usb-os-restore/usr/bin/install_to_emmc.sh b/nonlinear/fs-overlay-usb-os-restore/usr/bin/install_to_emmc.sh new file mode 100755 index 0000000000..ee602025ba --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/usr/bin/install_to_emmc.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +systemctl stop playground +umount /internalstorage +mkfs.ext3 -F /dev/mmcblk1p2 +mkdir -p /tmp/rootfs +mount /dev/mmcblk1p2 /tmp/rootfs +tar -C /tmp/rootfs -xf /rootfs.tar +rm /tmp/rootfs/etc/systemd/system/internalstorage.mount +cp /tmp/rootfs/boot/nonlinear-labs-2D.dtb /tmp/rootfs/boot/am335x-boneblack.dtb +cp /tmp/rootfs/boot/nonlinear-labs-2D.dtb /tmp/rootfs/boot/ + +cp /root/uEnv.txt /tmp/rootfs/boot/uEnv.txt + + +sync diff --git a/nonlinear/fs-overlay-usb-os-restore/usr/bin/restore-c15-os.sh b/nonlinear/fs-overlay-usb-os-restore/usr/bin/restore-c15-os.sh new file mode 100755 index 0000000000..bbb7ea6177 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/usr/bin/restore-c15-os.sh @@ -0,0 +1,149 @@ +#!/bin/sh + +# This will only restore the rootfs of the BBB to the version of the deployed +# nonlinear-c15-update.tar on the stick. The user will have to run a full update +# after the resotring procedure is done. + +# ToDos: +# - How do we sync the LPC and the ePC?? Focus on BBB rootfs for now ... +# - mutliple partition check? assume mmcblk0p2 for now + +set -x + +LOG_FILE="/media/restore-os.log" +TIMEOUT=5 +BBB_DEVICE="/dev/mmcblk0p2" +BBB_ROOTFS_MOUNTPOINT="/tmp/bbb_rootfs" +BBB_ROOTFS_UPDATE_DIR="${BBB_ROOTFS_MOUNTPOINT}/update" + +MSG_DONE="DONE!" +MSG_FAILED="FAILED!" + +freeze() { + while true; do + sleep 1 + done +} + +executeAsRoot() { + echo "sscl" | sshpass -p 'sscl' ssh -o ServerAliveInterval=1 -o ConnectionAttempts=1 -o ConnectTimeout=1 -o StrictHostKeyChecking=no sscl@$192.168.10.10 "sudo -S /bin/bash -c '$1'" + return $? +} + +t2s() { + /usr/C15/text2soled/text2soled multitext "$1" "$2" "$3" "$4" "$5" "$6" +} + +pretty() { + echo "$*" + BOLED_LINE_1="$1" + BOLED_LINE_2="$2" + BOLED_LINE_3="$3" + SOLED_LINE_1="$4" + SOLED_LINE_2="$5" + SOLED_LINE_3="$6" + + t2s "${BOLED_LINE_1}@b2c" "${BOLED_LINE_2}@b3c" "${BOLED_LINE_3}@b4c" "${SOLED_LINE_1}@s0c" "${SOLED_LINE_2}@s1c" "${SOLED_LINE_3}@s2c" +} + +report() { + pretty "$1" "$2" "$3" "$1" "$2" "$3" + printf "$1 $2 $3\n" >> ${LOG_FILE} +} + +stop_services() { + systemctl stop playground > /dev/null || executeAsRoot "systemctl stop playground" + systemctl stop bbbb > /dev/null + return 0 +} + +mount_stick () { + USB_DEVICE= + for d in "/dev/sda" "/dev/sda1"; do + [ -e ${d} ] && USB_DEVICE=${d} + done + + if ( ! mount | grep ${USB_DEVICE} ); then + mount ${USB_DEVICE} /media + rm $LOG_FILE + touch $LOG_FILE + fi + + return 0 +} + +check_preconditions (){ + MSG_CHECK="Checking presocondtions ..." + report "$MSG_CHECK" + sleep 2 + [ -e /media/nonlinear-c15-update.tar ] || { report "$MSG_FAILED" "Update.tar missing!"; return 1; } + + report "$MSG_CHECK" "$MSG_DONE" + sleep 2 + return 0 +} + +mount_rootfs (){ + MSG_MOUNT="Mounting partitions ..." + report "$MSG_MOUNT" + sleep 2 + if ( ! mount | grep ${BBB_DEVICE} ); then + mkdir ${BBB_ROOTFS_MOUNTPOINT} \ + && mount ${BBB_DEVICE} ${BBB_ROOTFS_MOUNTPOINT} \ + || { report "$MSG_FAILED" "$MOUNTING_MSG"; return 1; } + fi + report "$MSG_MOUNT" "$MSG_DONE" + sleep 2 + return 0 +} + +unpack_update (){ + MSG_UNPACK="Unpacking files ..." + report "$MSG_UNPACK" + sleep 2 + rm -r ${BBB_ROOTFS_UPDATE_DIR} + mkdir ${BBB_ROOTFS_UPDATE_DIR} + + cp /media/nonlinear-c15-update.tar ${BBB_ROOTFS_UPDATE_DIR} \ + && cd ${BBB_ROOTFS_UPDATE_DIR} \ + && tar xf nonlinear-c15-update.tar \ + || { report "$MSG_FAILED" "Unpacking update ..."; return 1; } + + mkdir ${BBB_ROOTFS_UPDATE_DIR}/BBB/rootfs \ + && gzip -dc ${BBB_ROOTFS_UPDATE_DIR}/BBB/rootfs.tar.gz | tar -C ${BBB_ROOTFS_UPDATE_DIR}/BBB/rootfs -xf - \ + || { report "$MSG_FAILED" "Unpacking rootfs ..."; return 1; } + + report "$MSG_UNPACK" "$MSG_DONE" + sleep 2 + return 0 +} + +sync_rootfs (){ + MSG_RESTORE="Restoring OS ..." + report "$MSG_RESTORE" + sleep 2 + + rsync -cax --exclude=${BBB_ROOTFS_MOUNTPOINT}/etc/hostapd.conf --exclude=${BBB_ROOTFS_UPDATE_DIR} --delete-after ${BBB_ROOTFS_UPDATE_DIR}/BBB/rootfs/ ${BBB_ROOTFS_MOUNTPOINT} \ + || { report "$MSG_FAILED" "$MSG_RESTORE"; return 1; } + + report "$MSG_RESTORE" "$MSG_DONE" + sleep 2 + + return 0 +} + +main (){ + mount_stick + stop_services + report "Hello from rescue USB!" "Will start restoring OS shortly ..." + sleep 3 + check_preconditions || return 1 + mount_rootfs || return 1 + unpack_update || return 1 + sync_rootfs || return 1 + report "Please run a full update" "from USB with a valid" "nonlinear-C15-update.tar" && freeze + return 0 +} + +main + diff --git a/nonlinear/fs-overlay-usb-os-restore/usr/lib/systemd/system/remount-rootfs.service b/nonlinear/fs-overlay-usb-os-restore/usr/lib/systemd/system/remount-rootfs.service new file mode 100644 index 0000000000..fe01c4fe98 --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/usr/lib/systemd/system/remount-rootfs.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Remount Root FS +DefaultDependencies=no +Conflicts=shutdown.target +After=systemd-readahead-collect.service systemd-readahead-replay.service fsck-root.service +Before=local-fs-pre.target local-fs.target shutdown.target +Wants=local-fs-pre.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/mount -o remount,rw / diff --git a/nonlinear/fs-overlay-usb-os-restore/var/log/anker b/nonlinear/fs-overlay-usb-os-restore/var/log/anker new file mode 100644 index 0000000000..81c2bde2bf --- /dev/null +++ b/nonlinear/fs-overlay-usb-os-restore/var/log/anker @@ -0,0 +1 @@ +This file is just here, so the fs-overlay replaces the symlink for /var/log in order to get persistent logging diff --git a/package/Config.in b/package/Config.in index 8cac9565aa..41b15f31b2 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1705,6 +1705,7 @@ source "package/nonlinear/C15/Config.in" source "package/nonlinear/espi_driver/Config.in" source "package/nonlinear/playcontroller_driver/Config.in" source "package/nonlinear/nonlinear_dts/Config.in" +source "package/nonlinear/nonlinear_usb_dts/Config.in" source "package/nonlinear/mxli/Config.in" source "package/nonlinear/bbbrtc/Config.in" source "package/nonlinear/phyreg/Config.in" diff --git a/package/nonlinear/nonlinear_usb_dts/Config.in b/package/nonlinear/nonlinear_usb_dts/Config.in new file mode 100644 index 0000000000..096e6a6c3e --- /dev/null +++ b/package/nonlinear/nonlinear_usb_dts/Config.in @@ -0,0 +1,19 @@ +menuconfig BR2_PACKAGE_NONLINEAR_USB_DTS + bool "nonlinear-usb-dts" + depends on BR2_arm + help + Pulls the DTS files from our git repository and compiles them. Deploys the files under BINARIES_DIR + + http://www.nonlinear-labs.de/ + +if BR2_PACKAGE_NONLINEAR_USB_DTS + +config BR2_PACKAGE_NONLINEAR_USB_DTS_REPOSITORY + string "git repository that holds the dts files" + default "git@github.com:nonlinear-labs-dev/dts.git" + +config BR2_PACKAGE_NONLINEAR_USB_DTS_VERSION + string "version or branch to check out from the git repository" + default "master" + +endif diff --git a/package/nonlinear/nonlinear_usb_dts/nonlinear-usb-dts.mk b/package/nonlinear/nonlinear_usb_dts/nonlinear-usb-dts.mk new file mode 100644 index 0000000000..742004d0be --- /dev/null +++ b/package/nonlinear/nonlinear_usb_dts/nonlinear-usb-dts.mk @@ -0,0 +1,18 @@ +############################################################ +# +# nonlinear-usb-dts +# +############################################################# + +NONLINEAR_USB_DTS_VERSION = $(call qstrip,$(BR2_PACKAGE_NONLINEAR_USB_DTS_VERSION)) +NONLINEAR_USB_DTS_SITE = $(call qstrip,$(BR2_PACKAGE_NONLINEAR_USB_DTS_REPOSITORY)) +NONLINEAR_USB_DTS_SITE_METHOD = git + +NONLINEAR_USB_DTS_DEPENDENCIES = linux + +define NONLINEAR_USB_DTS_INSTALL_TARGET_CMDS + make LINUX_DIR=${LINUX_DIR} HOSTDIR=${HOST_DIR} DESTDIR=${BINARIES_DIR} -C ${NONLINEAR_USB_DTS_DIR} + @echo "Nonlinear-Labs device-tree blobs created in ${BINARIES_DIR}" +endef + +$(eval $(generic-package))