硬件和软件准备

所需硬件如下

  • 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.可能会出现如下问题

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.

执行如下即可

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

ok

img

一些设置

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

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

设置主源

1
nano /etc/apt/sources.list

写入如下

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

设置副源

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

然后

1
2
apt update
apt upgrade

设置固定IP, 方便ssh

1
vim /etc/network/interfaces

我的是192.168.137.0网段, 所以如下

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
1
systemctl restart networking.service

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

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

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

然后

1
source .bashrc

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

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