Build NanoPi NEO Manual

最近入手了一块友善的NanoPi NEO

全志的H3芯片,512M内存,板载100M网口和USB2.0口,接口齐全。

虽然有官方提供的源码可以折腾,但还是选择从头开始。

  1. 从Linaro下载交叉编译工具
    wget https://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/arm-linux-gnueabihf/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz

  2. 从官网克隆u-boot仓库
    git clone git://git.denx.de/u-boot.git

  3. 从官网下载最新内核
    wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.5.tar.xz

  4. 从官网下载ubuntu最小系统
    wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04-core-armhf.tar.gz

  5. 环境变量设置
    #!/bin/bash
    export PATH=/opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin:$PATH
    export ARCH=arm
    export CROSS_COMPILE=arm-linux-gnueabihf-

  6. 编译u-boot
    make nanopi_neo_defconfig
    make -j8
    成果物:u-boot-sunxi-with-spl.bin

  7. 编译内核
    make sunxi_defconfig
    make zImage dtbs modules -j8
    成果物:arch/arm/boot/zImage arch/arm/boot/dts/dts/sun8i-h3-nanopi-neo.dtb

  8. 准备TF卡
    分区:MBR+64M FAT BOOT+REMAIN XG ROOT+1G SWAP

dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8

  1. 准备BOOT分区

boot.cmd
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10
load mmc 0:1 0x43000000 ${fdtfile} || load mmc 0:1 0x43000000 boot/${fdtfile}
load mmc 0:1 0x42000000 uImage || load mmc 0:1 0x42000000 boot/uImage
bootm 0x42000000 - 0x43000000

boot.csr
mkimage -A arm -O linux -T script -C none -n uboot -d boot.cmd boot.scr
script.bin
fex2bin nanopi_neo.fex script.bin
uImage

mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n linux-4.10.4-image -d zImage uImage

Ram disk还没有弄好
load mmc 0:1 0x42000000 uImage || load mmc 0:1 0x42000000 boot/uImage
mkimage -A arm -O linux -T ramdisk -C none -a 0x48000000 -e 0x48000000 -n linux-4.10.4-initrd -d initrd.img uInitrd

  1. 文件系统

解压Ubuntu core到TF卡ROOT分区
sudo cp -a /usr/bin/qemu-arm-static rootfs/usr/bin/
sudo chroot rootfs/
passwd root
ln -s /lib/systemd/system/serial-getty\@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service
apt install ifupdown net-tools
apt install udev

  1. 网络
    下载sun8i-emac patch
    dts添加:

    &emac {
    phy-handle = <&int_mii_phy>;
    phy-mode = "mii";
    allwinner,leds-active-low;
    status = "okay";
    };

  2. 移动硬盘
    内核编译+USB MASS Storage支持

最后贴上fex文件和网卡patch:
https://ocean.kevin125.com/cloud/index.php/s/sd7vPfd2sotuXxC

Install SSL (letsencrypt) On Synology DSM5 Manually

听说DSM6支持Let’s Encrypt,但是咱用DSM5也不能落下!

  1. 使用ipkg安装一些必须的组件

ipkg install libcurl openssl grep mktemp bash git

  1. Clone Let’s Encrypt脚本仓库

mkdir /volume1/system

cd /volume1/system

git clone https://github.com/lukas2511/dehydrated

cd dehydrated

  1. 拷贝配置文(docs/example/config)件到 /etc/dehydrated/config,然后根据自己需求配置

  2. 创建并编辑 domains.txt
    mydomain.com a.mydomain.com
    mydomain.net a.mydomain.net

  3. 编辑 /etc/httpd/conf/extra/httpd-userdir.conf-user


Alias /.well-known/acme-challenge /var/www/dehydrated

Order allow,deny
Allow from all

由于我已经开启Https,所以在这里卡了好久,Https需要把上述代码加到如下配置文件:

/etc/httpd/conf/extra/httpd-ssl.conf-user

*后续如果你开启HSTS的话,更新证书会遇到问题,修改上述文件即可。

synoservicectl --restart httpd-user

  1. 生成证书

./dehydrated -c

  1. 计划任务
    ./dehydrated -c
    cp -f /volume1/system/dehydrated/certs/xxx/fullchain.pem /usr/syno/etc/ssl/ssl.crt/server.crt
    cp -f /volume1/system/dehydrated/certs/xxx/privkey.pem /usr/syno/etc/ssl/ssl.key/server.key
    synoservicectl --restart httpd-sys

保存到文件,添加执行权限,在DSM里添加计划任务即可。

Addon Xpenology BootStrap IPKG DSM 5

在Control Panel中开启SSH登陆,使用Putty登陆

cd /volume1/@tmp

wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/syno-i686-bootstrap_1.2-7_i686.xsh

chmod +x syno-i686-bootstrap_1.2-7_i686.xsh

sh syno-i686-bootstrap_1.2-7_i686.xsh

rm syno-i686-bootstrap_1.2-7_i686.xsh

ipkg update

ipkg upgrade

vi /etc/rc.local
#!/bin/sh

mount -o bind /volume1/@optware /opt

[ -x /etc/rc.optware ] && /etc/rc.optware start

exit 0

vi /root/.profile

PATH=/opt/bin:/opt/sbin/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin