2022年10月3日 星期一

Openwrt 22.03.0 ASUS Lyra Trio MAP-AC1750

 原本不想追版本的 但19.07一直有個問題,雖然後來發現那個不是Openwrt或Lyra Trio的問題。


這次來用imagebuilder來作吧!


先來搞定22.03.0用的dts,就是以下檔案。放在imagebuilder裡面。跟19.07.10有一點差別。


./target/linux/ath79/dts/qca9563_asus_map-ac1750.dts

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

/dts-v1/;
#include "qca956x.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
/ {
        model = "ASUS Lyra Trio MAP-AC1750";
        compatible = "asus,map-ac1750", "qca,qca9563";
        aliases {
                led-boot = &led_blue;
                led-failsafe = &led_red;
                led-running = &led_blue;
                led-upgrade = &led_green;
        };
        leds {
                compatible = "gpio-leds";
                led_red: led_red {
                        label = "red";
                        gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
                };
                led_blue: led_blue {
                        label = "blue";
                        gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
                };
                led_green: led_green {
                        label = "green";
                        gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
                };
        };
        keys {
                compatible = "gpio-keys";
                wps {
                        label = "WPS button";
                        linux,code = <KEY_WPS_BUTTON>;
                        gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
                        debounce-interval = <60>;
                };
                reset {
                        label = "Reset button";
                        linux,code = <KEY_RESTART>;
                        gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
                        debounce-interval = <60>;
                };
        };
        gpio-export {
                compatible = "gpio-export";
                gpio_ar3012_power {
                        gpio-export,name = "asus:power:ar3012";
                        gpio-export,output = <1>;
                        gpios = <&gpio 7 GPIO_ACTIVE_HIGH>;
                };
                gpio_ar3012_reset {
                        gpio-export,name = "asus:reset:ar3012";
                        gpio-export,output = <1>;
                        gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
                };
        };
};
&uart {
        status = "okay";
};
&gpio {
        status = "okay";
};
&pcie {
        status = "okay";
};
&spi {
        status = "okay";
        flash@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <50000000>;
                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;
                        partition@0 {
                                label = "u-boot";
                                reg = <0x000000 0x40000>;
                                read-only;
                        };
                        partition@40000 {
                                label = "u-boot-env";
                                reg = <0x040000 0x10000>;
                                read-only;
                        };
                        art: partition@50000 {
                                label = "art";
                                reg = <0x050000 0x10000>;
                                read-only;
                                compatible = "nvmem-cells";
                                #address-cells = <1>;
                                #size-cells = <1>;
                                macaddr_art_1002: macaddr@1002 {
                                        reg = <0x1002 0x6>;
                                };
                        };
                        partition@60000 {
                                compatible = "denx,uimage";
                                label = "firmware";
                                reg = <0x060000 0x1fa0000>;
                        };
                };
        };
};
&usb_phy0 {
        status = "okay";
};
&usb0 {
        status = "okay";
};
&usb_phy1 {
        status = "okay";
};
&usb1 {
        status = "okay";
};
&mdio0 {
        status = "okay";
        phy-mask = <0>;
        phy0: ethernet-phy@0 {
                reg = <0>;
                phy-mode = "sgmii";
                qca,ar8327-initvals = <
                        0x04 0x00080080 /* PORT0 PAD MODE CTRL */
                        0x7c 0x0000007e /* PORT0_STATUS */
                >;
        };
};
&eth0 {
        status = "okay";
        nvmem-cells = <&macaddr_art_1002>;
        nvmem-cell-names = "mac-address";
        mac-address-increment = <1>;
        phy-handle = <&phy0>;
};
&wmac {
        status = "okay";
        mtd-cal-data = <&art 0x1000>;
        mtd-mac-address = <&art 0x1002>;
};

修改generic.mk
./target/linux/ath79/image/generic.mk

define Device/asus_map-ac1750
  SOC := qca9563
  DEVICE_VENDOR := ASUS
  DEVICE_MODEL := MAP-AC1750
  IMAGE_SIZE := 16000k
  DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca988x-ct-htt kmod-usb-core kmod-usb2
  SUPPORTED_DEVICES += map-ac1750
endef
TARGET_DEVICES += asus_map-ac1750


修改Network
./target/linux/ath79/generic/base-files/etc/board.d/02_network
                ;;
        asus,map-ac1750|\
        compex,wpj344-16m|\
        compex,wpj563)
                ucidef_add_switch "switch0" \
                        "0@eth0" "3:lan" "2:wan"
                ;;
修改ATH10K Calibration Data
./target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
        engenius,enstationac-v1|\
        glinet,gl-x750)
                caldata_extract "art" 0x5000 0x844
                ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) 2)
                ;;
        asus,map-ac1750)
                caldata_extract "art" 0x5000 0x844
                ath10k_patch_mac $(mtd_get_mac_binary art 0x5006)
                ;;
        asus,rp-ac66|\
        comfast,cf-wr650ac-v1|\
        comfast,cf-wr650ac-v2|\
修改targetinfo
./.targetinfo
Target-Profile-Description:
Build firmware images for Aruba AP-105



@@

Target-Profile: DEVICE_asus_map-ac1750
Target-Profile-Name: ASUS MAP-AC1750
Target-Profile-Packages: kmod-ath10k-ct ath10k-firmware-qca988x-ct kmod-usb2
Target-Profile-hasImageMetadata: 1
Target-Profile-SupportedDevices: asus,map-ac1750

Target-Profile-Description:
Build firmware images for ASUS Lyra Trio MAP-AC1750



@@

Target-Profile: DEVICE_asus_rp-ac66
Target-Profile-Name: ASUS RP-AC66
修改profile.mk
./.profile.mk
第一行加Device_asus_map-ac1750
下面加入以下
DEVICE_aruba_ap-105_SUPPORTED_DEVICES:=aruba,ap-105
DEVICE_aruba_ap-105_PACKAGES:=kmod-i2c-gpio kmod-tpm-i2c-atmel
DEVICE_asus_map-ac1750_NAME:=ASUS MAP-AC1750
DEVICE_asus_map-ac1750_HAS_IMAGE_METADATA:=1
DEVICE_asus_map-ac1750_SUPPORTED_DEVICES:=asus,map-ac1750
DEVICE_asus_map-ac1750_PACKAGES:=kmod-ath10k-ct ath10k-firmware-qca988x-ct kmod-usb2
DEVICE_asus_rp-ac66_NAME:=ASUS RP-AC66
DEVICE_asus_rp-ac66_HAS_IMAGE_METADATA:=1

imagebuilder不會重新編譯,所以前面製作的dts要手動編譯產生blob。由於dts是用C的語法,需要先作一次preprocessing轉成標準dtc後再編成blob。這邊要用到cpp以及include。我的作法是在imagebuilder的同一層放Openwrt git clone並且編譯過的就會包含include folder。
blob: qca9563_asus_map-ac1750.dtb
cpp -nostdinc -I../openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-5.10.138/include/ \
-I./target/linux/ath79/dts -undef -x assembler-with-cpp ./target/linux/ath79/dts/qca9563_asus_map-ac1750.dts | \
./build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-5.10.138/scripts/dtc/dtc -O dtb -b 0 -o ./build_dir/target-mips_24kc_musl/linux-ath79_generic/image-qca9563_asus_map-ac1750.dtb
與vmlinux合併
cat ./build_dir/target-mips_24kc_musl/linux-ath79_generic/{vmlinux,image-qca9563_asus_map-ac1750.dtb} > \
./build_dir/target-mips_24kc_musl/linux-ath79_generic/image-qca9563_asus_map-ac1750.tmp
lzma壓縮
./staging_dir/host/bin/lzma e ./build_dir/target-mips_24kc_musl/linux-ath79_generic/image-qca9563_asus_map-ac1750.tmp \
-lc1 -lp2 -pb2 ./build_dir/target-mips_24kc_musl/linux-ath79_generic/image-qca9563_asus_map-ac1750.lzma
產生UIMAGE
./staging_dir/host/bin/mkimage -A mips -O linux -T kernel -C lzma -a 0x80060000 -e 0x80060000 \
-n "MIPS OpenWrt Linux 5.10.138" \
-d ./build_dir/target-mips_24kc_musl/linux-ath79_generic/image-qca9563_asus_map-ac1750.lzma \
./build_dir/target-mips_24kc_musl/linux-ath79_generic/asus_map-ac1750-kernel.bin
刪掉前面產生的暫存檔
rm ./build_dir/target-mips_24kc_musl/linux-ath79_generic/image-qca9563_asus_map-ac1750.{tmp,lzma}


到此應該要有image-asus_map-ac1750-kernel.bin這個檔案,怕出錯可以用binwalk去看一下跟官方Release的有沒有一樣,除了CRC與Length以外應該都一樣。bin檔裡包含了官方Release的vmlinux以及自編的blob。並且可以從make info當中找到asus,map-ac1750的資訊,就可以用make image產生完整的Openwrt image了。預設下Image Builder不會含luci的界面,直接指定luci-ssl會自動下載相依的ipk作包裝。同時因為前面有修改base-file的東西,需要指定FILES才會套用。 

make image PROFILE=asus_map-ac1750 PACKAGE="luci-ssl"  \ FILES="./target/linux/ath79//generic/base-files/

差不多就醬…

PS: 前面講的不是Openwrt也不是Lyra Trio 那自然是我的問題啊…
PS2: 22.03的MAC Address不吃mtd-mac-address的設定了,所以要改用nvmem-cell處理…(4 days)
PS3: 有關5G Channel問題只要先選Country Code後,符合的頻道就可以用了。
PS4: 用imagebuilder作的原因主要是編完的沒辦法用官方的kmod 可能跟feeds有關吧。
PS5: 流程驗證並修正一些命令。並且dts套用標準的Lyra Trio的作法,用2.4G MAC +1。排版跑掉了…

2022年8月21日 星期日

Openwrt 19.07 ASUS Lyra Trio MAP-AC1750

 一直沒有official的Openwrt 所以就自己搞了。


Step 1: GPIO Table.

三色LED分別是GPIO14(RED), GPIO15(GREEN), GPIO16(BLUE)

兩個按鈕是GPIO2 WPS, GPIO5 RESET

還有兩個OUTPUT 應該是AR3012的Power與Reset. GPIO7, GPIO8


Step 2: Flash Layout

使用的是MX25L25645G,是32MByte的Flash,在19.07下需要修改m25p80.c才能正常reboot。若是選擇使用21.04的應該就不用,因為Flash本身支援4B OPCODE,21.04有一定的判斷機制應該會判斷到支援就不用使用EN4B/EX4B。但19.07沒有實作…

Serial Flash MX25L25645G

MTD0: 0x00000000 ~ 0x00040000 uboot

MTD1: 0x00040000 ~ 0x00050000 uboot-env

MTD2: 0x00050000 ~ 0x00060000 factory

MTD3: 0x00060000 ~ 0x01d00000 firmwarey

MTD4: 0x01d00000 ~ 0x02000000 jffs2

2022年7月26日 星期二

Raspberry Pi 4B的各種折騰.

 大概去年的這個時間從美亞上買了樹莓派4B 8GB,當初含散熱器也才3千台…跟一年後的現在比差有夠多的…入手了之後目的是作為Linux Desktop使用,所以各種研究(折騰),又是超頻又是跟上最新的版號…估計大概重作了二十幾次系統…希望可以一直用到Ubuntu 22.04 EOL再換下一個LTS。


目前總算是相對穩定了,所以作個紀錄總結一下…

2022年3月30日 星期三

Openwrt 21.02 MX25L25635E 無法soft reboot


    原因是在於Kernel 5.4.179在回復狀態時, 多作了一個flag的檢查 SNOR_F_BROKEN_RESET. 目前看起來這個flag是為了在開機的時候有狀況而作的. 解決方式就是把它拿掉... 

下面是修改前的樣子.
void spi_nor_restore(struct spi_nor *nor)
{
    /* restore the addressing mode */
    if (nor->addr_width == 4 && !(nor->flags & SNOR_F_4B_OPCODES) &&
        nor->flags & SNOR_F_BROKEN_RESET)
            nor->params.set_4byte(nor, false);
}
下面是修改後.
void spi_nor_restore(struct spi_nor *nor)
{
    /* restore the addressing mode */
    if (nor->addr_width == 4 && !(nor->flags & SNOR_F_4B_OPCODES))
            nor->params.set_4byte(nor, false);
}
   


    下面是碎碎唸....
    之前為了MX25L25635E在Openwrt 19.07上boot開機的問題搞了好一陣子. 看到不少人講21.02已經修正這個問題. 想說總算不用那麼麻煩換版本還要改code的... 沒想到還是遇到了.
    其實去年中就有試過21.02發現Reboot還是會卡在System Restarting... 想說最近有了21.02.2了也是一樣, 應該是Kernel版本沒有變的關係吧...
 
    目前看起來21.02修正的內容應該是對那種本身有4B OPCODE的flash, 因為那些可以直接下READ4B/WRITE4B的命令, 而不需要執行EN4B/EX4B的flash. 像是MX25L25635F. 也就是因為沒有進到4 byte addressing mode, 所以重開機不受影響. 而MX25L25635E是需要的, 所以還是gg了.


    雖然最後發現拿掉那個判斷是最快的 但不是正式的, 看了比較新的source code那邊寫法又不一樣了, 等導入了再說吧. 到時候不要再折騰一次就好.

2021年2月8日 星期一

從Openwrt Release的版本中修改dts並且重新封裝.

     由於手邊有一片比較特別的板子, 是MT7620A+MT7530的評估板(EVB). 而Openwrt對這塊板子的dts與實際上略有不同. 主要是在於factory區段. 原廠是將MAC Address與WIFI一些資料放在MTD2當中, 而Openwrt的DTS則沒有指定. 以致於WIFI部份需要將/dev/mtd2的前512kb倒至/lib/firmware/soc_wmac.eeprom才會正常辨認到無線晶片. 

#dd if=/dev/mtd2 of=/lib/firmware/soc_wmac.eeprom

    而第二個問題是有線網路的MAC Address也會因為dts沒有指定到正確的位置, 所以每一次開機都會產生隨機的位置, 雖然對於使用上沒什麼問題...

    是可以重新編譯image來克服這些, 但是DTB的修改在一般的操作上只能在master下作修改, 但是這會造成package只能安裝自行編譯的版本... 這一點在操作上比較不方便. 若是使用官方Release的版本則是只能使用固定的DTB. 但是固定的DTB就是會有不方便的情況發生...

 

2020年10月5日 星期一

IGMP Snooping

 三月初時寫了篇VLAN的應用在MOD上 後來三不五時的被時下的802.11KVR網路所吸引  

看了幾台備選的機種

Asus Lyra Trio MAP-AC1750 (QCA9563+QCA8334+QCA9880)

TP-Link Deco M4 (IPQ4019)

Zyxel Multy U (RTL8198CS)


後來在Lyra Trio的官方image當中發現有swconfig的程式可以規劃VLAN

又見到拍賣上三入組有比較便宜的價錢 就衝了. 只是發現沒辦法改開機程式 官方寫死在/sbin/rc當中


看來官方的firmware是無望用VLAN了, 只好試著將當初沒研究完的IGMP Snooping再翻出來看一遍. 只是設備與當時多了台HP J9298A的POE帶管理的交換器 為了要接POE的IPCAM

2020年3月5日 星期四

OPENWRT與DD-WRT 組合應用於IPTV的環境當中. VLAN設定

因為種種原因, IPTV set-top box 必需與Modem直接連線, 在自家透天厝的環境當中就得需要拉兩條網路線才能夠同時提供無線上網的涵蓋, 以及IPTV的觀看.

目前每台電視旁邊都放了台無線AP(兩台TPLINK Archer C8與一台Linksys WRT1200AC). 同時也已經拉好網路線接上了, 不想再拉第二條線讓線變得複雜, 而且Modem本身只提供4 Port的接口, 而目前已經用了3個了 (長輩網路用, 第一台STB, 無線網路), 而剩的一個則是保留, 如果有需要對Modem作修改的時候用的...

預期是要有下圖般的網路, 其中右下角的三台STB是要等設定完才會正常動作.