硬件和软件准备

所需硬件如下

  • CM311-1a 盒子及电源
  • USB 数据线
  • RJ45 网线
  • 带 WIFI 的 windows 笔记本电脑
  • U 盘

软件如下 (获取链接见文章末)

  • Rufus
  • Nmap
  • USB-burning-tool
  • 开心电视助手
  • Android 镜像
  • Armbian 镜像

首先,利用 Rufus 制作 Armbian 的启动 U 盘 (不细说了,自行百度或者看文末的 b 站视频)
然后,利用 usb-burning-tool 给盒子刷入带 root 的系统 (需要开盒短接 4R32 针脚以欺骗 HDMI)

此时盒子已经是安卓系统了
最后,重新启动盒子。开始下一步

刷机

windows 开启网络共享,用自己的网络 (wifi), , 开启以太网连接共享

img

启动盒子之后,arp 命令查看新增的 IP 地址,可能就是盒子的 IP

img

上面的懒得一个个试,用 nmap 扫描即可
nmap -sn IP/MASK

img

使用开心电视助手,连接安卓系统

img

调试选项,从 U 盘启动

img

这时候重点来了 (参考 B 站,见文末)
启动之后 ssh 连接盒子 (密码 1234), 然后盒子关机,重新刷入 armbian 的 U 盘

  • 关闭盒子的电源,拔下 U 盘。
  • 重新将 armbian 刷入 U 盘;
  • 将 U 盘插入盒子,开启电源,系统会自动从 U 盘引导 armbian

进入 ssh 终端 (可能会很慢,多等), 设置 root

img

执行 armbian-install 安装到 emmc, 选择我的型号 305

img

根据提示重启,重新 ssh. 可能会出现如下问题

text
1
2
3
4
5
6
7
8
9
10
11
12
13
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:NzU/ySnxsKxzs3LuZOWKfi/P6R+szwNQsRmNRvrr/AU.
Please contact your system administrator.
Add correct host key in C:\\Users\\LENOVO/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\LENOVO/.ssh/known_hosts:25
ECDSA host key for 192.168.137.71 has changed and you have requested strict checking.
Host key verification failed.

执行如下即可

sh
1
ssh-keygen -R xxx.xxx.xxx.xxx

ok

img

一些设置

如果上面没有重新刷入 armbian, 会出现 sudo 失效的问题 (治标)

sh
1
2
3
4
5
6
chown root:root /mnt -R
chown root:root /etc -R
chown root:root /usr -R
chmod 4755 /usr/bin/sudo
chown man:root /var/cache/man -R
chmod g+s /var/cache/man -R

设置主源

sh
1
nano /etc/apt/sources.list

写入如下

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

deb https://security.debian.org/debian-security bullseye-security main contrib non-free
# deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free

nano 用法:改完之后 ctrl+o, enter 保存。然后 ctrl+x, y, enter

设置副源

sh
1
sudo sed -i.bak 's#http://apt.armbian.com#https://mirrors.tuna.tsinghua.edu.cn/armbian#g' /etc/apt/sources.list.d/armbian.list

然后

sh
1
2
apt update
apt upgrade

设置固定 IP, 方便 ssh

sh
1
vim /etc/network/interfaces

我的是 192.168.137.0 网段,所以如下

text
1
2
3
4
5
6
7
auto eth0
iface eth0 inet static
address 192.168.137.2
netmask 255.255.255.0
gateway 192.168.137.1
dns-nameservers 8.8.8.8
dns-nameservers 114.114.114.114
sh
1
systemctl restart networking.service

然后连接就断开了 (ip 改变了), 重新 ssh 即可

以后就可以带个网线和电源,就能连终端了
也可以通过 USB 串口通信,但是好像需要焊接端口,不会…

此外,还可以设置一下终端颜色,因为默认 root 是黑白的
参考其他用户,更改 root 的 ~/.bashrc 里的代码即可

然后

sh
1
source .bashrc

可能还需要更改 /etc/profile 的内容
加入

text
1
export TERM=xterm-256color

即可


参考资料

刷机教程: https://www.bilibili.com/video/BV16d4y1x7Df
bug 解决: https://www.bilibili.com/read/cv23719863/

配置参考:
https://mirrors.tuna.tsinghua.edu.cn/help/debian/


工具下载

启动盘工具 rufus: https://rufus.ie/zh/
系统镜像 armbian: https://github.com/ophub/amlogic-s9xxx-armbian
局域网扫描 nmap: https://nmap.rog

其他的工具,如开心电视盒子 / 安卓盒子镜像 / USB 烧录工具 (来自参考资料中的 B 站视频): https://pan.baidu.com/s/1A39GLNYHWkrQS9SaJUWXWg?pwd=ubx0