海运的博客

n1盒子ubuntu使用netplan配置wifi无线连接

发布时间:October 25, 2018 // 分类:N1 // 2 Comments

ubuntu 18.04使用netplan配置网络信息,后端使用Network Manager或systemd-networkd管理网络,默认使用systemd-networkd,systemd-networkd本身不支持无线,使用wpasupplicant连接无线。

apt install iproute2 wpasupplicant

查看无线网卡名称:

iw dev          

网卡名称为wlan0,开启:

ip lin set wlan0 up

搜索路由ssid:

iw dev wlan0 scan

netplan配置:

network:
  version: 2
  renderer: networkd
  wifis:
    wlan0:
      dhcp4: yes
      dhcp6: no
      access-points:
        "ssid":
          password: "password"

netplan更多配置示例:https://netplan.io/examples

n1盒子armbian下载址及写入u盘软件

发布时间:October 20, 2018 // 分类:N1 // No Comments

armbian下载地址:
https://yadi.sk/d/pHxaRAs-tZiei
https://yadi.sk/d/_rQgn_FosYuW0g
写入u盘linux下使用dd,windows下可使用以下:
https://etcher.io/
https://www.alexpage.de/usb-image-tool/download/

更新:
最好不要使用linux虚拟机dd到u盘,速度太慢还不稳定。

n1盒子的uboot u盘引导armbian/linux系统

发布时间:October 20, 2018 // 分类:N1 // No Comments

查看uboot的默认变量,保存在/dev/env设备中,armbian4.18内核不能识别此设备,3.14内核可以,查看默认启动命令为start_autoscript:

fw_printenv | grep bootcmd
bootcmd=run start_autoscript; run storeboot;

start_autoscript判断有usb刚执行start_usb_autoscript命令,mmc执行start_mmc_autoscript,具体如下:

start_autoscript=if usb start ; then run start_usb_autoscript; fi; run start_mmc_autoscript;
start_mmc_autoscript=if fatload mmc 0 1020000 s905_autoscript; then autoscr 1020000; fi;if fatload mmc 1 1020000 s905_autoscript; then autoscr 1020000; fi;
start_emmc_autoscript=if fatload mmc 1 1020000 emmc_autoscript; then autoscr 1020000; fi;
start_usb_autoscript=if fatload usb 0 1020000 s905_autoscript; then autoscr 1020000; fi; if fatload usb 1 1020000 s905_autoscript; then autoscr 1020000; fi; if fatload usb 2 1020000 s905_autoscript; then autoscr 1020000; fi; if fatload usb 3 1020000 s905_autoscript; then autoscr 1020000; fi;

start_usb_autoscript 加载usb设备1和2 fat分区根目录s905_autoscript文件并执行,s905_autoscript内容如下:

setenv env_addr    "0x10400000"
setenv kernel_addr "0x11000000"
setenv initrd_addr "0x13000000"
setenv boot_start booti ${kernel_addr} ${initrd_addr} ${dtb_mem_addr}
if fatload usb 0 ${kernel_addr} zImage; then if fatload usb 0 ${initrd_addr} uInitrd; then if fatload usb 0 ${env_addr} uEnv.ini; then env import -t ${env_addr} ${filesize};run cmdline_keys;fi; if fatload usb 0 ${dtb_mem_addr} dtb.img; then run boot_start; else store dtb read ${dtb_mem_addr}; run boot_start;fi;fi;fi;
if fatload usb 1 ${kernel_addr} zImage; then if fatload usb 1 ${initrd_addr} uInitrd; then if fatload usb 1 ${env_addr} uEnv.ini; then env import -t ${env_addr} ${filesize};run cmdline_keys;fi; if fatload usb 1 ${dtb_mem_addr} dtb.img; then run boot_start; else store dtb read ${dtb_mem_addr}; run boot_start;fi;fi;fi;
if fatload mmc 0 ${kernel_addr} zImage; then if fatload mmc 0 ${initrd_addr} uInitrd; then if fatload mmc 0 ${env_addr} uEnv.ini; then env import -t ${env_addr} ${filesize};run cmdline_keys;fi; if fatload mmc 0 ${dtb_mem_addr} dtb.img; then run boot_start; else store dtb read ${dtb_mem_addr}; run boot_start;fi;fi;fi;
if fatload mmc 1 ${kernel_addr} zImage; then if fatload mmc 1 ${initrd_addr} uInitrd; then if fatload mmc 1 ${env_addr} uEnv.ini; then env import -t ${env_addr} ${filesize};run cmdline_keys;fi; if fatload mmc 1 ${dtb_mem_addr} dtb.img; then run boot_start; else store dtb read ${dtb_mem_addr}; run boot_start;fi;fi;fi;

s905_autoscript加载所在分区zImage、uInitrd、dtb.img、uEnv.ini文件,并引导系统启动。

更改uboot变量方法如下:

/usr/sbin/fw_setenv start_autoscript "if usb start ; then run start_usb_autoscript; fi; run start_mmc_autoscript;"
/usr/sbin/fw_setenv start_mmc_autoscript "if fatload mmc 0 1020000 s905_autoscript; then autoscr 1020000; fi;if fatload mmc 1 1020000 s905_autoscript; then autoscr 1020000; fi;"

对于s905_autoscript文件可用mkimage生成:

mkimage -C none -A arm -T script -d /boot/s905_autoscript.cmd /boot/s905_autoscript

为n1制作aarcm64/arm64 ubuntu rootfs系统

发布时间:October 20, 2018 // 分类:N1 // No Comments

安装debootstrap和qemu-user-static:

apt install apt-transport-https qemu qemu-user-static binfmt-support debootstrap

构建ubuntu 18.04系统,基础包为minbase,使用清大的源:

qemu-debootstrap --arch arm64 --variant=minbase --include=whiptail,ca-certificates,tzdata bionic rootfs http://mirrors.ustc.edu.cn/ubuntu-ports/

配置软件源:

cat > rootfs/etc/apt/sources.list <<EOF
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
EOF

配置网络信息:

mkdir rootfs/etc/network/ 
echo 'nameserver 192.168.168.1' > rootfs/etc/resolv.conf
echo 'ubuntu-18.04' > rootfs/etc/hostname
cat > rootfs/etc/netplan/50-cloud-init.yaml <<EOF
network:
    ethernets:
        eth0:
            addresses:
            - 192.168.168.6/24
            dhcp4: false
            gateway4: 192.168.168.1
            nameservers:
                addresses:
                - 192.168.168.1
                search: []
    version: 2
EOF

挂载本地设备文件到rootfs:

mount -t proc /proc  rootfs/proc 
mount -t sysfs /sys  rootfs/sys 
mount -o bind /dev  rootfs/dev 
mount -o bind /dev/pts  rootfs/dev/pts 

chroot rootfs内配置:

LANG=C.UTF-8 chroot rootfs/  /bin/bash

在rootfs内执行:

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
apt update
apt upgrade
apt install systemd -y 
apt install wireless-regdb crda -y
apt install rsyslog udev dbus kmod openssh-server netplan.io man vim wget net-tools sysstat tmux less wireless-regdb crda dosfstools parted rng-tools -y
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
passwd root
umount /dev/pts/ /dev/ /proc/ /sys 
exit

为方便使用之前编译的内核和armbian的uInitrd、firmware文件,挂载armbian的img镜像到本地:

losetup -P -f --show Armbian_5.62_Aml-s9xxx_Ubuntu_bionic_default_4.18.7_20181012.img
mount /dev/loop3p2 /mnt
mount /dev/loop3p2 /mnt/boot
mv /mnt/boot/* rootfs/boot/
mv /mnt/lib/modules/ rootfs/lib/
#也可安装armbian的firmware-aml-4.18-20181011_5.62_arm64.deb
mv /mnt/lib/firmware/ rootfs/lib/
mv /mnt/etc/modprobe.d/ rootfs/etc/
mv /mnt/etc/fstab rootfs/etc/
mv /mnt/root/install.sh rootfs/root/

将armbain镜像内的文件全部删除,将新做的系统移动过去。

rm -rf /mnt/*
mv rootfs/boot/* /mnt/boot/
mv rootfs/* /mnt/

参考:
https://help.ubuntu.com/lts/installation-guide/s390x/apds04.html

n1下ubuntu安装cups配置airprint网络打印服务器

发布时间:October 20, 2018 // 分类:N1 // No Comments

打印机通过usb接口连接n1,ubuntu/armbian要安装usblp内核模块,查看本机是否有usblp模块:

modinfo usblp
filename:       /lib/modules/4.18.7-aml-s9xxx/kernel/drivers/usb/class/usblp.ko
license:        GPL
description:    USB Printer Device Class driver

如果没有需编译内核usblp模块,可参考:https://www.haiyun.me/archives/1266.html
系统软件源使用所有,不然很多打印机驱动没有:

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse

然后安装配置cpus

apt update
apt install cups

修改为以下配置:

#这行很重要,是否将共享的打印机让本地网络发现,如使用airprint。
Browsing on
Listen 0.0.0.0:631
<Location />
  Order allow,deny
  Allow all
</Location>

<Location /admin>
  Order allow,deny
  Allow all
</Location>

重启cups:

systemctl restart cups
systemctl restart cups-browsed

将打印机和n1连接,此时内核日志应该提示打印机已连接:

dmesg|tail -n 1
usblp 1-1:1.1: usblp0: USB Bidirectional printer dev 8 if 1 alt 0 proto 2 vid 0x04A9 pid 0x176C

cups有此打印机驱动也正常识别了:

lpinfo -v      
network ipp
direct usb://Canon/MG2400%20series?serial=988776&interface=1

查看支持的打印机驱动:

lpinfo -m

访问cups web管理界面添加打印机,地址:ip:631,配置很简单,详细步骤略过。
添加打印机后iphone应该就能通过airprint识别打印机了。
windows下可在控制面板下添加打印机,地址为ip:631/printers/name

无打印机驱动的可添加打印机为raw模式,windows下连接共享的打印机选择相应的驱动也可打印:

lpadmin -p mg2400 -E -v  parallel:/dev/usb/lp0 

遇到的一些问题:
1.开机启动时加载内核驱动失败,cups默认会加载lp/ppdev/parport_pc内核驱动,由于已使用usblp内核驱动,可将这些注释掉,/etc/modules-load.d/cups-filters.conf
2.通过cups打印时没反应,内核提示usblp0: removed,打印机未正常工作,可将打印机连接至电脑查看具体原因。

更多参考:
http://www.winotmk.com/2017/03/1136
https://www.ncnynl.com/archives/201608/742.html
https://ubuntuforums.org/showthread.php?t=2295559

分类
最新文章
最近回复
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...