共计 1661 个字符,预计需要花费 5 分钟才能阅读完成。
本文适合将 openwrt 安装到 mtd12 中,原厂固件在 mtd13 中
- 准备 ubi 固件
- 准备原厂固件 1.0.17 版本 并登录路由器回滚 下载地址
-
在路由器后台页面,打开浏览器 F12,在 console 输入一下命令获取 ssh,并设置 ssh 密码
function getSTOK() {let match = location.href.match(/;stok=(.*?)\//); if (!match) {return null;} return match[1]; } function execute(stok, command) {command = encodeURIComponent(command); let path = `/cgi-bin/luci/;stok=${stok}/api/misystem/set_config_iotdev?bssid=SteelyWing&user_id=SteelyWing&ssid=-h%0A${command}%0A`; console.log(path); return fetch(new Request(location.origin + path)); } function enableSSH() {stok = getSTOK(); if (!stok) {console.error('stok not found in URL'); return; } console.log(`stok = "${stok}"`); password = prompt('Input new SSH password'); if (!password) {console.error('You must input password'); return; } execute(stok, ` nvram set ssh_en=1 nvram commit sed -i 's/channel=.*/channel=\\"debug\\"/g' /etc/init.d/dropbear /etc/init.d/dropbear start ` ) .then((response) => response.text()) .then((text) => console.log(text)); console.log('New SSH password: ' + password); execute(stok, `echo -e "${password}\\n${password}" | passwd root`) .then((response) => response.text()) .then((text) => console.log(text)); } enableSSH();
-
终端输入以下代码测试
nc -v 192.168.31.1 22
-
终端输入登录 ssh
ssh root@192.168.31.1
-
在 ssh 中输入
nvram set uart_en=1 nvram set boot_wait=on nvram commit
-
查看分区
cat /proc/mtd
- ssh 中输入 nvram get flag_boot_rootfs 查看官方固件所在分区 0 是在 mtd12 / 1 是在 mtd13
-
ssh 中上传 ubi 固件到路由器 tmp 目录
scp Desktop/openwrt......ubi root@192.168.31.1:/tmp
-
刷写固件
ubiformat /dev/mtd12 -y -f /tmp/openwrt....ubi
-
设置启动分区
nvram set flag_last_success=0
备注:
切换固件 原厂固件 >>>>>>Openwrt,登录原厂固件的 ssh,输入以下命令
nvram set flag_last_success=0
nvram set flag_boot_rootfs=0
nvram commit
reboot
切换固件 Openwrt>>>>>> 原厂固件,登录 openwrt 的 ssh,输入以下命令
fw_setenv flag_last_success 1
fw_setenv flag_boot_rootfs 1
reboot
正文完
觉得有用?欢迎赞赏,感谢!