diff --git a/targets/nanopi_neo_plus2.conf b/targets/nanopi_neo_plus2.conf new file mode 100644 index 0000000..be938b6 --- /dev/null +++ b/targets/nanopi_neo_plus2.conf @@ -0,0 +1,55 @@ +#!/bin/bash + +IMAGE_MB=512 +MIRROR=http://mirrors.kernel.org/debian +SYSTEM=debian +ARCH=arm64 +SUITE=stretch + +read -r -d '' EXTRA_PACKAGES << EOF +alsa-utils +bluez +dosfstools +dnsutils +ifupdown +insserv +iputils-ping +isc-dhcp-client +kmod +less +libbluetooth3 +locales +net-tools +openssh-client +openssh-server +parted +rfkill +systemd +systemd-sysv +udev +vim-tiny +wireless-tools +wpasupplicant +EOF + +HOSTNAME=nanopi_neo_plus2 +LOCALE=en_US.UTF-8 + +post_install() { + find "${ROOTFS}/usr/share/doc" ! -name copyright -type f -delete + find "${ROOTFS}/usr/share/doc" -type d -delete > /dev/null 2>&1 + rm -rf "${ROOTFS}/usr/share/man/"* + rm -rf "${ROOTFS}/usr/share/info/"* + rm -rf "${ROOTFS}/usr/share/lintian/"* + + cat >> "${ROOTFS}/etc/securetty" << EOF + +ttys0 +EOF + + cp -r "${DIBS}/targets/nanopi_neo_plus2_overlay/"* "${ROOTFS}" + sed -i "s/#PermitEmptyPasswords no/PermitEmptyPasswords yes/g" ${ROOTFS}/etc/ssh/sshd_config + sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" ${ROOTFS}/etc/ssh/sshd_config + sed -i "s/UsePAM yes/UsePAM no/g" ${ROOTFS}/etc/ssh/sshd_config + run_target /usr/sbin/update-rc.d firstboot defaults +} diff --git a/targets/nanopi_neo_plus2_overlay/etc/apt/apt.conf.d/02nocache b/targets/nanopi_neo_plus2_overlay/etc/apt/apt.conf.d/02nocache new file mode 100644 index 0000000..fa32f81 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/apt/apt.conf.d/02nocache @@ -0,0 +1,4 @@ +Dir::Cache { + srcpkgcache ""; + pkgcache ""; +} diff --git a/targets/nanopi_neo_plus2_overlay/etc/dpkg/dpkg.cfg.d/01_smalldisk b/targets/nanopi_neo_plus2_overlay/etc/dpkg/dpkg.cfg.d/01_smalldisk new file mode 100644 index 0000000..f56cfd9 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/dpkg/dpkg.cfg.d/01_smalldisk @@ -0,0 +1,13 @@ +# block documentation +path-exclude /usr/share/doc/* +# keep copyright files for legal reasons +path-include /usr/share/doc/*/copyright +path-exclude /usr/share/man/* +path-exclude /usr/share/groff/* +path-exclude /usr/share/info/* +# lintian stuff is small, but really unnecessary +path-exclude /usr/share/lintian/* +path-exclude /usr/share/linda/* +# block non-us locales +path-exclude /usr/share/locale/* +path-include /usr/share/locale/en* diff --git a/targets/nanopi_neo_plus2_overlay/etc/fstab b/targets/nanopi_neo_plus2_overlay/etc/fstab new file mode 100644 index 0000000..577c819 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/fstab @@ -0,0 +1,2 @@ +devpts /dev/pts devpts defaults,gid=5,mode=620 0 0 +/dev/mmcblk0p1 /boot vfat defaults 0 0 diff --git a/targets/nanopi_neo_plus2_overlay/etc/init.d/firstboot b/targets/nanopi_neo_plus2_overlay/etc/init.d/firstboot new file mode 100755 index 0000000..a4b2f49 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/init.d/firstboot @@ -0,0 +1,33 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: firstboot +# Required-Start: $remote_fs $syslog +# Required-Stop: +# X-Start-Before: sshd +# Default-Start: 2 3 4 5 S +# Default-Stop: +# Short-Description: First boot configuration. +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +test "$1" = "start" || exit 0 + +EXPAND_ROOTFS=0 +MAKE_SWAP=1 +SWAP_SIZE=128 + +test -f /boot/firstboot.txt && . /boot/firstboot.txt + +if [ "$EXPAND_ROOTFS" ] && [ $EXPAND_ROOTFS -gt 0 ]; then + if [ "$MAKE_SWAP" ] && [ $MAKE_SWAP -gt 0 ]; then + expand-rootfs.sh -s $SWAP_SIZE + else + expand-rootfs.sh + fi +fi + +/usr/bin/ssh-keygen -A +update-rc.d firstboot disable + +exit 0 diff --git a/targets/nanopi_neo_plus2_overlay/etc/network/interfaces.d/eth0 b/targets/nanopi_neo_plus2_overlay/etc/network/interfaces.d/eth0 new file mode 100644 index 0000000..768218b --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/network/interfaces.d/eth0 @@ -0,0 +1,3 @@ +auto eth0 +allow-hotplug eth0 +iface eth0 inet dhcp diff --git a/targets/nanopi_neo_plus2_overlay/etc/network/interfaces.d/wlan0 b/targets/nanopi_neo_plus2_overlay/etc/network/interfaces.d/wlan0 new file mode 100644 index 0000000..aec9ff3 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/network/interfaces.d/wlan0 @@ -0,0 +1,4 @@ +auto wlan0 +allow-hotplug wlan0 +iface wlan0 inet dhcp + wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf diff --git a/targets/nanopi_neo_plus2_overlay/etc/systemd/system/brcm-bluetooth.service b/targets/nanopi_neo_plus2_overlay/etc/systemd/system/brcm-bluetooth.service new file mode 100644 index 0000000..f5122b5 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/systemd/system/brcm-bluetooth.service @@ -0,0 +1,6 @@ +[Unit] +Description=Broadcom firmware and hci service + +[Service] +Type=simple +ExecStart=/usr/local/bin/brcm-bluetooth.sh diff --git a/targets/nanopi_neo_plus2_overlay/etc/udev/rules.d/10-brcm-bluetooth.rules b/targets/nanopi_neo_plus2_overlay/etc/udev/rules.d/10-brcm-bluetooth.rules new file mode 100644 index 0000000..2412d30 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/udev/rules.d/10-brcm-bluetooth.rules @@ -0,0 +1,2 @@ +SUBSYSTEM=="rfkill", ACTION=="change", ATTR{name}=="sunxi-bt", ATTR{state}=="1", RUN+="/bin/systemctl --no-block start brcm-bluetooth.service" +SUBSYSTEM=="rfkill", ACTION=="change", ATTR{name}=="sunxi-bt", ATTR{state}=="0", RUN+="/bin/systemctl --no-block stop brcm-bluetooth.service" diff --git a/targets/nanopi_neo_plus2_overlay/etc/wpa_supplicant/wpa_supplicant.conf b/targets/nanopi_neo_plus2_overlay/etc/wpa_supplicant/wpa_supplicant.conf new file mode 100644 index 0000000..cbe12f5 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/etc/wpa_supplicant/wpa_supplicant.conf @@ -0,0 +1 @@ +country=US diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/bcm43438a0.hcd b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/bcm43438a0.hcd new file mode 100644 index 0000000..1fc806e Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/bcm43438a0.hcd differ diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/bcm43438a1.hcd b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/bcm43438a1.hcd new file mode 100644 index 0000000..c4a4b55 Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/bcm43438a1.hcd differ diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/config.txt b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/config.txt new file mode 100644 index 0000000..dfb60b0 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/config.txt @@ -0,0 +1,2 @@ +PM=0 +nv_by_chip=2 43430 0 nvram.txt 43430 1 nvram_ap6212.txt diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0.bin b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0.bin new file mode 100644 index 0000000..59972d5 Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0.bin differ diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0_apsta.bin b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0_apsta.bin new file mode 100644 index 0000000..93e3107 Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0_apsta.bin differ diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0_p2p.bin b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0_p2p.bin new file mode 100644 index 0000000..59972d5 Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a0_p2p.bin differ diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1.bin b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1.bin new file mode 100644 index 0000000..e815f44 Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1.bin differ diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1_apsta.bin b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1_apsta.bin new file mode 100644 index 0000000..e815f44 Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1_apsta.bin differ diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1_p2p.bin b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1_p2p.bin new file mode 100644 index 0000000..e815f44 Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/fw_bcm43438a1_p2p.bin differ diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/nvram.txt b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/nvram.txt new file mode 100644 index 0000000..578376c --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/nvram.txt @@ -0,0 +1,54 @@ +#AP6212_NVRAM_V1.0_20140603 +# 2.4 GHz, 20 MHz BW mode + +# The following parameter values are just placeholders, need to be updated. +manfid=0x2d0 +prodid=0x0726 +vendid=0x14e4 +devid=0x43e2 +boardtype=0x0726 +boardrev=0x1101 +boardnum=22 +macaddr=00:90:4c:c5:12:38 +sromrev=11 +boardflags=0x00404201 +xtalfreq=26000 +nocrc=1 +ag0=255 +aa2g=1 +ccode=ALL + +pa0itssit=0x20 +extpagain2g=0 + +#PA parameters for 2.4GHz, measured at CHIP OUTPUT +pa2ga0=-168,7161,-820 +AvVmid_c0=0x0,0xc8 +cckpwroffset0=5 + +# PPR params +maxp2ga0=90 +txpwrbckof=6 +cckbw202gpo=0x5555 +legofdmbw202gpo=0x77777777 +mcsbw202gpo=0xaaaaaaaa + +# OFDM IIR : +ofdmdigfilttype=7 +# PAPD mode: +papdmode=2 + +il0macaddr=00:90:4c:c5:12:38 +wl0id=0x431b + +#OOB parameters +hostwake=0x40 +hostrdy=0x41 +usbrdy=0x03 +usbrdydelay=100 +deadman_to=0xffffffff +# muxenab: 0x1 for UART enable, 0x10 for Host awake +muxenab=0x10 +# CLDO PWM voltage settings - 0x4 - 1.1 volt +#cldo_pwm=0x4 + diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/nvram_ap6212.txt b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/nvram_ap6212.txt new file mode 100644 index 0000000..03b49a3 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/lib/firmware/ap6212/nvram_ap6212.txt @@ -0,0 +1,54 @@ +#AP6212_NVRAM_V1.0.1_20160606 +# 2.4 GHz, 20 MHz BW mode + +# The following parameter values are just placeholders, need to be updated. +manfid=0x2d0 +prodid=0x0726 +vendid=0x14e4 +devid=0x43e2 +boardtype=0x0726 +boardrev=0x1101 +boardnum=22 +macaddr=00:90:4c:c5:12:38 +sromrev=11 +boardflags=0x00404201 +xtalfreq=26000 +nocrc=1 +ag0=255 +aa2g=1 +ccode=ALL + +pa0itssit=0x20 +extpagain2g=0 + +#PA parameters for 2.4GHz, measured at CHIP OUTPUT +pa2ga0=-168,7161,-820 +AvVmid_c0=0x0,0xc8 +cckpwroffset0=5 + +# PPR params +maxp2ga0=90 +txpwrbckof=6 +cckbw202gpo=0x5555 +legofdmbw202gpo=0x77777777 +mcsbw202gpo=0xaaaaaaaa + +# OFDM IIR : +ofdmdigfilttype=7 +# PAPD mode: +papdmode=2 + +il0macaddr=00:90:4c:c5:12:38 +wl0id=0x431b + +#OOB parameters +hostwake=0x40 +hostrdy=0x41 +usbrdy=0x03 +usbrdydelay=100 +deadman_to=0xffffffff +# muxenab: 0x1 for UART enable, 0x10 for Host awake +muxenab=0x10 +# CLDO PWM voltage settings - 0x4 - 1.1 volt +#cldo_pwm=0x4 +glitch_based_crsmin=1 diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430-sdio.bin b/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430-sdio.bin new file mode 120000 index 0000000..a2ddb0c --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430-sdio.bin @@ -0,0 +1 @@ +/lib/firmware/ap6212/fw_bcm43438a0.bin \ No newline at end of file diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430-sdio.txt b/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430-sdio.txt new file mode 120000 index 0000000..3d49026 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430-sdio.txt @@ -0,0 +1 @@ +/lib/firmware/ap6212/nvram.txt \ No newline at end of file diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430a1-sdio.bin b/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430a1-sdio.bin new file mode 120000 index 0000000..630d2a6 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430a1-sdio.bin @@ -0,0 +1 @@ +/lib/firmware/ap6212/fw_bcm43438a1.bin \ No newline at end of file diff --git a/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430a1-sdio.txt b/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430a1-sdio.txt new file mode 120000 index 0000000..847d72a --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/lib/firmware/brcm/brcmfmac43430a1-sdio.txt @@ -0,0 +1 @@ +/lib/firmware/ap6212/nvram_ap6212.txt \ No newline at end of file diff --git a/targets/nanopi_neo_plus2_overlay/usr/local/bin/brcm-bluetooth.sh b/targets/nanopi_neo_plus2_overlay/usr/local/bin/brcm-bluetooth.sh new file mode 100755 index 0000000..6181bd8 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/usr/local/bin/brcm-bluetooth.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +DEVICE=/dev/ttyS3 +BAUD=115200 +MAC=aa:22:33:44:55:66 + +echo > $DEVICE +brcm_patchram_plus --patchram /lib/firmware/ap6212/ --bd_addr $MAC --no2bytes --tosleep 5000 --baudrate $BAUD $DEVICE +sleep 1 +exec hciattach -n $DEVICE any $BAUD diff --git a/targets/nanopi_neo_plus2_overlay/usr/local/bin/brcm_patchram_plus b/targets/nanopi_neo_plus2_overlay/usr/local/bin/brcm_patchram_plus new file mode 100755 index 0000000..52bc084 Binary files /dev/null and b/targets/nanopi_neo_plus2_overlay/usr/local/bin/brcm_patchram_plus differ diff --git a/targets/nanopi_neo_plus2_overlay/usr/local/bin/expand-rootfs.sh b/targets/nanopi_neo_plus2_overlay/usr/local/bin/expand-rootfs.sh new file mode 100755 index 0000000..6f9174e --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/usr/local/bin/expand-rootfs.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +try() { + output=$("$@" 2>&1) + if [ $? -ne 0 ]; then + echo "error running \"$@\"" + echo "$output" + exit 1 + fi +} + +show_usage() { + echo "Usage: $0 [-s SWAPSIZE]" >&2 + echo "Where SWAPSIZE is a number in megabytes" >&2 + exit 1 +} + +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -s|--swap) + SWAP_SIZE_MB="$2" + shift + ;; + *) + show_usage + ;; + esac + shift +done + +BLOCK_DEVICE=/dev/mmcblk0 + +if [[ ! -b ${BLOCK_DEVICE}p1 ]]; then + echo "1st partition missing. Refusing to continue." >&2 + exit 1 +fi + +if [[ ! -b ${BLOCK_DEVICE}p2 ]]; then + echo "2nd partition missing. Refusing to continue." >&2 + exit 1 +fi + +if [[ -b ${BLOCK_DEVICE}p3 ]]; then + echo "3rd partition exists. Refusing to continue." >&2 + exit 1 +fi + +if [[ -b ${BLOCK_DEVICE}p4 ]]; then + echo "4th partition exists. Refusing to continue." >&2 + exit 1 +fi + +DEVICE_NAME=$(basename ${BLOCK_DEVICE}) +DEVICE_SIZE=$(cat /sys/block/${DEVICE_NAME}/size) +P1_POSITION=$(cat /sys/block/${DEVICE_NAME}/${DEVICE_NAME}p1/start) +P1_SIZE=$(cat /sys/block/${DEVICE_NAME}/${DEVICE_NAME}p1/size) +P2_POSITION=$(cat /sys/block/${DEVICE_NAME}/${DEVICE_NAME}p2/start) +P2_SIZE=$(cat /sys/block/${DEVICE_NAME}/${DEVICE_NAME}p2/size) + +if [[ $P1_POSITION -gt $P2_POSITION ]]; then + echo "1st partition comes after 2nd partition. Refusing to continue." >&2 + exit 1 +fi + +let FREE_SIZE=$DEVICE_SIZE-$P2_POSITION-$P2_SIZE + +if [[ "$SWAP_SIZE_MB" -gt 0 ]]; then + MAKE_SWAP=1 + let P3_SIZE=$SWAP_SIZE_MB*2048 + let P3_POSITION=$DEVICE_SIZE-$P3_SIZE + if [[ $P3_SIZE -gt $FREE_SIZE ]]; then + echo "Swap size larger than available space. Refusing to continue." >&2 + exit 1 + fi + let FREE_SIZE=$FREE_SIZE-$P3_SIZE +else + MAKE_SWAP=0 +fi + +let P2_SIZE=$P2_SIZE+$FREE_SIZE + +if [[ $MAKE_SWAP -eq 1 ]]; then + sfdisk -u S --Linux --no-reread ${BLOCK_DEVICE} >/dev/null 2>&1 << EOF +${P1_POSITION},${P1_SIZE},0x0C,- +${P2_POSITION},${P2_SIZE},0x83,- +${P3_POSITION},${P3_SIZE},0x82,- +EOF + + try partprobe ${BLOCK_DEVICE} + + try mkswap ${BLOCK_DEVICE}p3 + + echo "/dev/mmcblk0p3 none swap sw 0 0" >> /etc/fstab + + try swapon /dev/mmcblk0p3 +else + sfdisk -u S --Linux --no-reread ${BLOCK_DEVICE} >/dev/null 2>&1 << EOF +${P1_POSITION},${P1_SIZE},0x0C,- +${P2_POSITION},${P2_SIZE},0x83,- +EOF +fi + +try resizepart ${BLOCK_DEVICE} 2 ${P2_SIZE} + +try resize2fs -f ${BLOCK_DEVICE}p2 diff --git a/targets/nanopi_neo_plus2_overlay/var/lib/systemd/rfkill/platform-rfkill_bt:bluetooth b/targets/nanopi_neo_plus2_overlay/var/lib/systemd/rfkill/platform-rfkill_bt:bluetooth new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/targets/nanopi_neo_plus2_overlay/var/lib/systemd/rfkill/platform-rfkill_bt:bluetooth @@ -0,0 +1 @@ +0 \ No newline at end of file