Openwrt-18.06.2从u盘启动

本文详细记录了TL-WR702N路由器的硬件改造过程,包括升级内存与闪存、焊接USB接口及串口线,以及安装OpenWrt固件并进行配置的步骤。特别介绍了如何通过USB存储设备扩展路由器功能,解决无线信号丢失问题。

路由器:tl-wr702n 升级16M flash,64M Rom

焊接usb座

固件OpenWrt-18.06.2的,中科大镜像下载

使用breed-boot启动

启动后,唯一的网口被配置为wan口,且无法ssh登陆,没有wifi

焊接串口线,配置wifi

插上u盘,

opkg install kmod-usb-storage kmod-fs-ext4

中间会自动解决依赖,这样就能识别优盘了

重启路由器,通过wlan连接到路由器,http://192.168.1.1

在菜单system->mount points中将/dev/sda1的挂载点设置为/overlay

重启路由器,发现没有无线信号了,

将u盘插入电脑修改upper/etc/config/wireless

插回优盘,一切ok

config.buildinfo openwrt-ipq5424-generic-debug-ipq5424_norplusmmc-u-boot-stripped.elf openwrt-ipq5424-generic-norplusnand-u-boot.img debug openwrt-ipq5424-generic-debug-ipq5424_norplusnand-u-boot.elf openwrt-ipq5424-generic-norplusnand-u-boot-stripped.elf dtbs openwrt-ipq5424-generic-debug-ipq5424_norplusnand-u-boot.img openwrt-ipq54xx-generic-qcom_maxx-fit-uImage.itb feeds.buildinfo openwrt-ipq5424-generic-debug-ipq5424_norplusnand-u-boot-stripped.elf openwrt-ipq54xx-generic-qcom_maxx-squashfs-sysupgrade.bin kernel-debug.tar.zst openwrt-ipq5424-generic-mmc-u-boot.elf openwrt-ipq54xx-generic-qsdk_open.manifest openwrt-imagebuilder-ipq54xx-generic.Linux-x86_64.tar.zst openwrt-ipq5424-generic-mmc-u-boot.img openwrt-ipq54xx-generic-squashfs-root.img openwrt-ipq5424-generic-debug-ipq5424_mmc-u-boot.elf openwrt-ipq5424-generic-mmc-u-boot-stripped.elf openwrt-ipq54xx-generic-vmlinux.elf openwrt-ipq5424-generic-debug-ipq5424_mmc-u-boot.img openwrt-ipq5424-generic-nand-u-boot.elf openwrt-ipq54xx-generic-vmlinux-initramfs.elf openwrt-ipq5424-generic-debug-ipq5424_mmc-u-boot-stripped.elf openwrt-ipq5424-generic-nand-u-boot.img openwrt-toolchain-ipq54xx-generic_gcc-13.3.0_musl.Linux-x86_64.tar.zst openwrt-ipq5424-generic-debug-ipq5424_nand-u-boot.elf openwrt-ipq5424-generic-nand-u-boot-stripped.elf packages openwrt-ipq5424-generic-debug-ipq5424_nand-u-boot.img openwrt-ipq5424-generic-norplusmmc-u-boot.elf profiles.json openwrt-ipq5424-generic-debug-ipq5424_nand-u-boot-stripped.elf openwrt-ipq5424-generic-norplusmmc-u-boot.img sha256sums openwrt-ipq5424-generic-debug-ipq5424_norplusmmc-u-boot.elf openwrt-ipq5424-generic-norplusmmc-u-boot-stripped.elf version.buildinfo openwrt-ipq5424-generic-debug-ipq5424_norplusmmc-u-boot.img openwrt-ipq5424-generic-norplusnand-u-boot.elf 告诉我如何仿真
最新发布
09-24
<think> 我们面对的文件列表主要是OpenWrt为IPQ54xx平台编译的输出文件。用户的目标是进行仿真(emulation),即使用QEMU运行这些固件。 根据之前的对话,用户尝试过使用qemu-system-arm并指定内核(vmlinux.elf),但出现无反应的情况。 关键点: 1. 在文件列表中,我们看到了多个ELF文件(如vmlinux.elf)和镜像文件(如squashfs-root.img, sysupgrade.bin等)。 2. 对于仿真,我们通常需要: - 内核文件:例如 `openwrt-ipq54xx-generic-vmlinux.elf` - 根文件系统:例如 `openwrt-ipq54xx-generic-squashfs-root.img` 或 `openwrt-ipq54xx-generic-squashfs-sysupgrade.bin`(但注意sysupgrade.bin通常包含内核和根文件系统,需要拆分?) 3. 但是,OpenWrt的镜像结构可能比较复杂,有时内核和根文件系统是分开的,有时是合并的。 根据用户之前的命令尝试: qemu-system-arm -machine virt -kernel $vmlinux -append “root=/dev/ram” -initrd $root -nographic 这个命令试图使用一个内核(-kernel)和一个initrd(-initrd)来启动。但是,OpenWrt的根文件系统通常是squashfs格式,并不一定是一个RAM磁(initrd)。因此,可能需要调整。 另外,我们注意到有文件:`openwrt-ipq54xx-generic-qcom_maxx-fit-uImage.itb`,这是一个FIT(Flattened Image Tree)镜像,它可能包含了内核和设备树等,适合直接启动。 然而,用户使用的是`virt`机器类型,这是一个通用的ARM虚拟机,不一定需要特定的设备树。但OpenWrt可能期望特定的硬件,所以我们需要确保使用正确的机器类型。 建议步骤: 1. 确定使用哪个内核?通常,`vmlinux.elf`是未压缩的内核ELF文件,适合直接加载。 2. 根文件系统:可以使用`openwrt-ipq54xx-generic-squashfs-root.img`(如果存在)作为磁镜像挂载,或者使用`-initrd`加载(如果文件系统是ramdisk)。但注意,initrd方式要求内核支持将根文件系统加载到内存中运行。 另一种简单的方式是使用已经包含内核和根文件系统的镜像:`openwrt-ipq54xx-generic-qcom_maxx-squashfs-sysupgrade.bin`,但是这种格式通常需要被QEMU识别,而QEMU的`-kernel`参数不支持直接加载这种格式。我们需要将其转换为QEMU可引导的格式,或者使用其他方法(如挂载为磁)。 考虑到简便性,我们推荐使用内核和根文件系统分离的方式: -kernel openwrt-ipq54xx-generic-vmlinux.elf -initrd openwrt-ipq54xx-generic-squashfs-root.img # 注意:这个root.img是否适合作为initrd?它应该是squashfs格式,内核需要支持squashfs的initrd。 但是,OpenWrt的root.img通常是一个块设备映像(包含分区和文件系统),而不是一个cpio归档(initrd通常要求)。因此,更好的做法是将root.img作为磁挂载。 因此,我们需要创建一个虚拟磁,将root.img写入其中,然后让QEMU加载这个磁。或者,我们可以直接使用`-drive`参数加载root.img。 然而,在`virt`机器上,我们可以模拟一个存储设备(比如使用`-drive if=none,format=raw,file=root.img,id=hd0`)然后挂载根文件系统。 但是,由于我们使用的是`virt`机器,它没有默认的存储设备,所以我们需要手动添加。 参考命令: qemu-system-arm -M virt -kernel openwrt-ipq54xx-generic-vmlinux.elf -append "console=ttyAMA0 root=/dev/vda" -drive file=openwrt-ipq54xx-generic-squashfs-root.img,format=raw,if=virtio -nographic 注意: - 这里假设根文件系统在第一个virtio磁(/dev/vda)上。 - 需要内核支持virtio块设备。 如果用户使用的是`root=/dev/ram`,那么应该是把根文件系统作为initrd加载到内存。但是,我们的root.img是否是initrd格式?通常OpenWrt的rootfs是squashfs,所以需要内核支持squashfs,并且可以挂载为initrd。但这样会占用大量内存。 因此,我们有两种选择: 选项1:使用initrd方式(加载到内存) 命令:qemu-system-arm -M virt -kernel vmlinux.elf -initrd root.img -append "root=/dev/ram console=ttyAMA0" -nographic 选项2:使用磁方式(需要驱动) 命令:qemu-system-arm -M virt -kernel vmlinux.elf -append "console=ttyAMA0 root=/dev/vda" -drive file=root.img,format=raw,if=virtio -nographic 由于我们不知道用户的具体文件系统结构,需要用户尝试。 另外,注意文件列表中的`openwrt-ipq54xx-generic-vmlinux-initramfs.elf`,这是一个内置了initramfs的内核,意味着它已经包含了根文件系统。如果使用这个文件,则不需要指定initrd或磁,直接加载内核即可: qemu-system-arm -M virt -kernel openwrt-ipq54xx-generic-vmlinux-initramfs.elf -append "console=ttyAMA0" -nographic 因此,建议用户尝试使用`vmlinux-initramfs.elf`,因为这是最简单的。 总结仿真步骤: 1. 尝试使用initramfs内核(最简单): qemu-system-arm -M virt -kernel openwrt-ipq54xx-generic-vmlinux-initramfs.elf -append "console=ttyAMA0" -nographic 2. 如果不行,尝试使用initrd方式(确保有root.img文件): qemu-system-arm -M virt -kernel openwrt-ipq54xx-generic-vmlinux.elf -initrd openwrt-ipq54xx-generic-squashfs-root.img -append "root=/dev/ram console=ttyAMA0" -nographic 3. 或者使用磁方式(同样需要root.img): qemu-system-arm -M virt -kernel openwrt-ipq54xx-generic-vmlinux.elf -append "console=ttyAMA0 root=/dev/vda" -drive file=openwrt-ipq54xx-generic-squashfs-root.img,format=raw,if=virtio -nographic 注意:如果使用磁方式,需要确保root.img文件包含一个文件系统(如ext4或squashfs)并且内核支持该文件系统。 同时,用户需要确保当前目录下有这些文件,或者使用正确的路径。 由于用户之前遇到无反应的情况,请确保: - 命令参数正确(特别是文件路径和名称) - 使用`-append "console=ttyAMA0"`来重定向控制台输出 - 等待足够长时间(启动可能较慢) 最后,如果用户希望仿真特定的硬件(如IPQ5424),可能需要使用特定的机器类型(而不是`virt`)和设备树(dtb)。但是,在文件列表中我们看到了`dtbs`目录,里面可能有设备树文件。所以,如果使用特定机器类型(例如`-machine qcom`之类),需要指定设备树文件(`-dtb`)。但是,目前OpenWrt的IPQ54xx目标在QEMU中可能没有直接对应的机器类型,因此使用`virt`可能是唯一选择。 因此,我们首先尝试使用`virt`机器类型。 </think> 以下是基于您提供的文件列表进行OpenWrt仿真的方法: ### 仿真步骤 1. **选择正确的内核文件** 使用带调试符号的ELF内核文件(便于问题排查): ```bash vmlinux="openwrt-ipq54xx-generic-vmlinux.elf" # 完整内核 # 或使用带initramfs的内核(无需额外根文件系统) # vmlinux="openwrt-ipq54xx-generic-vmlinux-initramfs.elf" ``` 2. **准备根文件系统** 使用SquashFS格式的根文件系统镜像: ```bash root_img="openwrt-ipq54xx-generic-squashfs-root.img" ``` 3. **启动QEMU命令** ```bash qemu-system-arm -machine virt \ -kernel "$vmlinux" \ -append "console=ttyAMA0 root=/dev/vda" \ -drive "file=$root_img,format=raw,if=virtio" \ -nographic \ -serial mon:stdio ``` ### 关键参数说明 - **`-drive if=virtio`** 使用高效虚拟化驱动挂载根文件系统 - **`root=/dev/vda`** 指定virtio块设备为根分区 - **`-serial mon:stdio`** 双重串口重定向确保输出可见 - **`console=ttyAMA0`** 强制内核输出到虚拟串口 ### 调试建议 1.启动卡住,添加`-s -S`参数启用GDB调试: ```bash -s -S # 在QEMU启动时暂停等待GDB连接 ``` 另开终端执行: ```bash gdb-multiarch "$vmlinux" -ex "target remote :1234" ``` 2. 对于IPQ5424专用文件(如`*norplusnand*`),需: - 使用对应设备树(`dtbs/`目录) - 更换机器类型:`-machine qcom`
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值