<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OpenWrt &#8211; Yuanle&#039;s Blog</title>
	<atom:link href="https://blog2.emacsos.com/category/linux-server-and-sysadmin/openwrt/feed" rel="self" type="application/rss+xml" />
	<link>https://blog2.emacsos.com</link>
	<description></description>
	<lastBuildDate>Sun, 14 Dec 2025 07:18:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog2.emacsos.com/wp-content/uploads/2025/05/favicon-150x150.png</url>
	<title>OpenWrt &#8211; Yuanle&#039;s Blog</title>
	<link>https://blog2.emacsos.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Build Kernel Module for CP2102 Serial Module</title>
		<link>https://blog2.emacsos.com/how-to-build-kernel-module-for-cp2102-serial-module.html</link>
		
		<dc:creator><![CDATA[sylecn]]></dc:creator>
		<pubDate>Sun, 14 Dec 2025 07:12:04 +0000</pubDate>
				<category><![CDATA[OpenWrt]]></category>
		<guid isPermaLink="false">https://blog2.emacsos.com/?p=120</guid>

					<description><![CDATA[Some CP2102 device is recognized as &#8220;VeriFone Inc Verifone USB to Modem&#8221;, doesn&#8217;t register Serial support. It&#8217;s hardware driver issue. [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Some CP2102 device is recognized as &#8220;VeriFone Inc Verifone USB to Modem&#8221;, doesn&#8217;t register Serial support. It&#8217;s hardware driver issue. You can build a new cp210x module to solve this issue.</p>



<h2 class="wp-block-heading">Get kernel source code</h2>



<p>I use Linux mainline kernel source. My Debian has 6.12.12 kernel.</p>



<pre class="wp-block-code"><code>wget https://mirror.nju.edu.cn/kernel.org/linux/kernel/v6.x/linux-6.12.12.tar.xz</code></pre>



<p>unpack to ~/fromsource/linux-6.12.12/</p>



<p>I think the debian source pkg should also work.</p>



<h2 class="wp-block-heading">Modify the cp210x driver&#8217;s source code</h2>



<p>You need to add support for your device in the source code. First get the USB vendor ID and product ID. You can get it from kernel log (<code>journalctl -k |tail</code>) or <code>lsusb </code>command. Kernel log is usually like &#8220;idVendor=11ca, idProduct=0211, bcdDevice=1.00&#8221;, lsusb output is like &#8220;Bus 007 Device 005: ID 11ca:0211 VeriFone Inc Verifone USB to Modem&#8221;. In my example, vendor ID is 11ca, product ID is 0211. Now you need to modify the source code at <code>~/fromsource/linux-6.12.12/drivers/usb/serial/cp210x.c</code></p>



<p>add<br><code>{ USB_DEVICE(0x11CA, 0x0211) },</code></p>



<p>between all those device vendor ID, product ID lines.</p>



<h2 class="wp-block-heading">Build the cp210x module</h2>



<p>Install some dependencies: pahole and resolve_btfids.</p>



<p>sudo apt install pahole libelf-dev</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
cd ~/fromsource/linux-6.12.12/
cd ./tools/bpf/resolve_btfids
make
ls -l resolve_btfids
sudo mkdir -p /usr/src/linux-headers-`uname -r`/tools/bpf/resolve_btfids
sudo ln -s $(realpath resolve_btfids) /usr/src/linux-headers-`uname -r`/tools/bpf/resolve_btfids
</pre></div>


<p>To avoid Skipping BTF generation for xxx Error:</p>



<pre class="wp-block-code"><code>sudo cp /sys/kernel/btf/vmlinux /usr/lib/modules/`uname -r`/build/</code></pre>



<p>Now it&#8217;s time to build the cp210x kernel module.</p>



<pre class="wp-block-code"><code>cd ~/fromsource/linux-6.12.12/drivers/usb/serial/
make -C /lib/modules/`uname -r`/build M=$PWD
ls -l cp210x.ko</code></pre>



<h2 class="wp-block-heading">Install and load cp210x module</h2>



<pre class="wp-block-code"><code># install cp210x
sudo cp usbserial.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/usbserial.ko
sudo cp cp210x.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/cp210x.ko
# you must update module dependency map after cp new file to kernel
# module dir. otherwise, you will get "unknown symbol in module" error.
sudo depmod -a

# load cp210x
sudo modprobe cp210x</code></pre>



<p>Now plugin your device, you should have /dev/ttyUSB0</p>



<p>In kernel log you should see</p>



<pre class="wp-block-code"><code>Nov 29 00:25:26 agem10.dev.emacsos.com kernel: usbcore: registered new interface driver usbserial_generic
Nov 29 00:25:26 agem10.dev.emacsos.com kernel: usbserial: USB Serial support registered for generic
Nov 29 00:25:28 agem10.dev.emacsos.com kernel: usbcore: registered new interface driver cp210x
Nov 29 00:25:28 agem10.dev.emacsos.com kernel: usbserial: USB Serial support registered for cp210x
Nov 29 00:25:28 agem10.dev.emacsos.com kernel: cp210x 7-1.2:1.0: cp210x converter detected
Nov 29 00:25:28 agem10.dev.emacsos.com kernel: usb 7-1.2: cp210x converter now attached to ttyUSB0</code></pre>



<p>Now the device is fully working.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Qihoo 360T7 UART TTL Flash OpenWRT Guide</title>
		<link>https://blog2.emacsos.com/qihoo-360t7-uart-ttl-flash-openwrt-guide.html</link>
		
		<dc:creator><![CDATA[sylecn]]></dc:creator>
		<pubDate>Sun, 14 Dec 2025 06:36:37 +0000</pubDate>
				<category><![CDATA[OpenWrt]]></category>
		<guid isPermaLink="false">https://blog2.emacsos.com/?p=110</guid>

					<description><![CDATA[Qihoo 360T7 is one of the routers that uses MediaTek MT7981B SoC (System-On-Chip). It is a WiFi-6 router with 128M [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Qihoo 360T7 is one of the routers that uses MediaTek MT7981B SoC (System-On-Chip). It is a WiFi-6 router with 128M flash and 256MB RAM. It has good performance and is very affordable. The stock firmware runs an old version of OpenWRT. To get latest security patch and features, this guide shows you how to flash latest OpenWRT on the device.</p>



<h2 class="wp-block-heading">Before You Start</h2>



<p>Before you try to access the UART via TTL, check whether telnet is enabled on the current firmware. If telnet is enabled, you don&#8217;t need to use UART. Also check if a 3rd party u-boot is installed on the device. If it is, you don&#8217;t need to use UART.</p>



<p>Check your USB TTL device is working properly. Plug in your device, you should see /dev/ttyUSB0 shown up in your device tree. In my case, I use a CP2102 USB device, I need to build my own kernel module for it to work.</p>



<p>Get latest OpenWRT files for this device. You can find them at <a href="https://firmware-selector.openwrt.org/">https://firmware-selector.openwrt.org/</a>, type in 360t7, the files will show up. You need the SYSUPGRADE, PRELOADER.BIN, BL31-UBOOT.FIP files.</p>



<h2 class="wp-block-heading">Connect the UART TTL Cables</h2>



<p>It is possible to connect 3 cables to the device without opening the case. Put the device on the table, face down. Put antenna on the left side, put RJ45 sockets on the right side. Put a cellphone flashlight on the back of the device, adjust the flashlight spotlight so you can see 4 holes on the board. The first hole is square; the rest are circles. Ignore the first hole, the remaining 3 circle holes are GND, TX, RX. You need to connect them to your TTL device&#8217;s GND, RX, TX.</p>



<p>Get 3 thin metal wire. Those used to fasten charging cables works fine. Remove the outside of the wire. Fold them to Z shape so they can be insert to the 360t7 device through the louver holes on the case. Use tape to fix each wire once they are in position. Connect all 3 wires to duPont wire on your USB TTL device. GND-GND, TX-RX, RX-TX.</p>



<h2 class="wp-block-heading">Prepare Terminal to Connect to Serial</h2>



<p>On Linux, install minicom package. Run minicom with</p>



<pre class="wp-block-code"><code>sudo minicom -D /dev/ttyUSB0</code></pre>



<p>Configure minicom by pressing <code>Ctrl-A O</code></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
 Serial port setup
 F - Hardware Flow Control
 G - Software Flow Control
</pre></div>


<p>Make sure both says No. Otherwise, keyboard input won&#8217;t work.</p>



<p>Save this configure as default in <code>Ctrl-A O</code> menu. Otherwise, each time you start minicom, you need to config this again.</p>



<h2 class="wp-block-heading">Go To OpenWRT Failsafe Mode</h2>



<p>With minicom running, all cables connected, now connect power cable to boot your device. You should see u-boot and kernel output in minicom terminal. After kernel boot, wait for 3s, then press F and Enter key repeatedly to enter failsafe mode.</p>



<p>If you never saw failsafe mode text prompt, let the router boot normally, then flash <code>360T7-v4.2.4.7959_upgrade.bin</code> in stock firmware web UI. In newer firmware, failsafe mode is disabled, revert to this older version to allow OpenWRT failsafe mode.</p>



<h2 class="wp-block-heading">Enable Telnet and Set Root Password in Failsafe Mode</h2>



<p>Once you get to failsafe mode root shell, run these commands:</p>



<pre class="wp-block-code"><code>fw_setenv bootmenu_delay 3
mount_root
# Enable telnet service
sed -i 's/.*local debug=.*/\tlocal debug=1/' /etc/init.d/telnet
# Set password for root, type a password of your choice twice.
passwd root
cat /proc/mtd
# you should see stock Qihoo 360t7 layout.</code></pre>



<pre class="wp-block-code"><code>root@(none):/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 08000000 00020000 "spi0.0"
mtd1: 00100000 00020000 "bl2"
mtd2: 00080000 00020000 "u-boot-env"
mtd3: 00200000 00020000 "Factory"
mtd4: 00200000 00020000 "fip"
mtd5: 02400000 00020000 "ubi"
mtd6: 02400000 00020000 "firmware-1"
mtd7: 02400000 00020000 "plugin"
mtd8: 00100000 00020000 "config"
mtd9: 00080000 00020000 "factory"
mtd10: 00700000 00020000 "log"</code></pre>



<p>Run &#8220;reboot&#8221; to reboot the device. Now you should use stock u-boot menu. You can use u-boot menu to flash u-boot and firmware, or you can do it in telnet session after the device is fully boot. I choose to use u-boot menu.</p>



<p>On u-boot menu, select &#8220;Upgrade ATF BL2&#8221;, serve OpenWRT preloader.bin via TFTP. Run mtkautoboot to show u-boot menu again.</p>



<p>Select &#8220;Upgrade ATF FIP&#8221;, serve OpenWRT bl31-uboot.fip via TFTP. Run &#8220;reset&#8221; to reboot device. Now you should see OpenWRT&#8217;s u-boot menu. It is different than stock u-boot menu.</p>



<pre class="wp-block-code"><code>  ( ( ( OpenWrt ) ) )       U-Boot 2024.10-OpenWrt-r28872-daca7c049b (Sep 19 20

1. Run default boot command.
2. Boot system via TFTP.
3. Boot production system from NAND.
4. Boot recovery system from NAND.
5. Load production system via TFTP then write to NAND.
6. Load recovery system via TFTP then write to NAND.
7. Load BL31+U-Boot FIP via TFTP then write to NAND.
8. Load BL2 preloader via TFTP then write to NAND.
9. Reboot.
a. Reset all settings to factory defaults.
0. Exit

Press UP/DOWN to move, ENTER to select, ESC to quit</code></pre>



<h2 class="wp-block-heading">Flash OpenWRT</h2>



<p>On Linux computer, serve <code>openwrt-mediatek-filogic-qihoo_360t7-initramfs-recovery.itb</code> via 192.168.1.254 TFTP server. In OpenWRT u-boot menu, select &#8220;Boot system via TFTP.&#8221; It will boot to OpenWRT initramfs-recovery. When initramfs-recovery boots, use ssh or luci to flash OpenWRT sysupgrade image.</p>



<p>After that, router will auto reboot, you will have latest OpenWRT running on Qihoo 360T7.</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to write to a protected FIP partition in openwrt?</title>
		<link>https://blog2.emacsos.com/how-to-write-to-a-protected-fip-partition-in-openwrt.html</link>
		
		<dc:creator><![CDATA[sylecn]]></dc:creator>
		<pubDate>Sat, 21 Jun 2025 09:58:03 +0000</pubDate>
				<category><![CDATA[OpenWrt]]></category>
		<guid isPermaLink="false">https://blog2.emacsos.com/?p=102</guid>

					<description><![CDATA[When you try to write u-boot image to a partition, sometimes you get this error msg: You may use this [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>When you try to write u-boot image to a partition, sometimes you get this error msg:</p>



<pre class="wp-block-code"><code>Could not open mtd device: fip
Can't open device for writing!</code></pre>



<p>You may use this trick to allow write to the FIP and other MTD partitions.</p>



<pre class="wp-block-code"><code>opkg update
opkg install kmod-mtd-rw

insmod /lib/modules/$(uname -r)/mtd-rw.ko i_want_a_brick=1
# the i_want_a_brick=1 part is required! Otherwise, the command will fail.</code></pre>



<p>Now you can run the mtd write command again.</p>



<p>If write still fail, make sure the partition name is correct. The partition name is case sensitive. You can check the partition name using</p>



<pre class="wp-block-code"><code>cat /proc/mtd</code></pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
