找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 551|回复: 2

[openwrt(x86)] 求助:如何在编译前调整 firmware 与 art 的大小位置

[复制链接]
发表于 2023-11-13 21:27 | 显示全部楼层 |阅读模式
[    0.903771] spi-nor spi0.0: w25q128 (16384 Kbytes)
[    0.908700] 3 fixed-partitions partitions found on MTD device spi0.0
[    0.915207] Creating 3 MTD partitions on "spi0.0":
[    0.920073] 0x000000000000-0x000000020000 : "u-boot"
[    0.928086] 0x000000020000-0x0000007f0000 : "firmware"
[    0.934671] 0x0000007f0000-0x000000800000 : "art"

已经修改为16mlzma,为什么firmware与8mlzma的一样啊

 楼主| 发表于 2023-11-13 22:53 | 显示全部楼层
Hello everybody,

this was the first time I built openwrt myself (so far only stock images). The reason is that I have a TPlink WDR4300 which has been modified with a 16MB flash (not by me) and came with LEDE Reboot, which is a bit dated now...

I first made a full backup, documented some stuff of the existing install, verified that the bootloader was indeed pepe2k (it was) and the serial pin header did work (it didn't, the person who did the mod failed to get a good ground connection - as did I in several tries - a jumper wire fixed that).

As a first try, I used the generic 19.07.7 sysupgrade image via luci. This worked in the sense that I had a booting router, but as expected with an 8MB flash layout and no wifi (as the art partition was not where it should be in the 8MB layout). The latter was of course easily fixed from backup...

Then I got the 19.7.07 source tree and went on to build it as per https://openwrt.org/docs/guide-u ... ginners-build-guide 6 and https://openwrt.org/docs/guide-developer/quickstart-build-images 5.

Before I edited target/linux/ath79/image/generic-tp-link.mk as shown in https://tbspace.de/wr84116mbflashmod.html 9 (which is for a LEDE based Freifunk Gluon, which might be the reason why it didn't work) to have a 16MB model of the 4300 by adding this:

define Device/tplink_tl-wdr4300-v1-16
  $(Device/tplink-16mlzma)
  ATH_SOC := ar9344
  DEVICE_TITLE := TP-Link TL-WDR4300 v1 16MB
  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
  TPLINK_HWID := 0x43000001
  SUPPORTED_DEVICES += tl-wdr4300
endef
TARGET_DEVICES += tplink_tl-wdr4300-v1-16
I then chose the 16MB version in make menuconfig and built it with make. After some time, the make stopped with the complaint that ./target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1-16.dts could not be found. I did find ./target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1.dts though and since it didn't seem to contain anything related to the flash size, I just made a copy with the new name and tried again.
This did indeed result into a 16MB factory image, which I could install (via webserver in pepe2k BL) and could boot from. Unfortunately the flash layout was still 8MB like this:

dev:    size   erasesize  name
mtd0: 00020000 00010000 "u-boot"
mtd1: 007d0000 00010000 "firmware"
mtd2: 0018e10f 00010000 "kernel"
mtd3: 00641ef0 00010000 "rootfs"
mtd4: 00430000 00010000 "rootfs_data"
mtd5: 00010000 00010000 "art"
while the LEDE reboot I had originally had the correct length 0f 00fd0000:

dev:    size   erasesize  name
mtd0: 00020000 00010000 "u-boot"
mtd1: 001333cc 00010000 "kernel"
mtd2: 00e9cc34 00010000 "rootfs"
mtd3: 00c60000 00010000 "rootfs_data"
mtd4: 00010000 00010000 "art"
mtd5: 00fd0000 00010000 "firmware"
So what is the correct procedure to build a current openwrt for a larger than stock flash (I'm not adverse to try the 21 RC or master but thought stable would be easiest as a first try)?

Thanks in advance,

Joachim

For openwrt-19.7.07. Enter the spoiler content in the file ar9344_tplink_tl-wdr4300-v1-16.dts.
ar9344_tplink_tl-wdr4300-v1-16.dts



created
Apr '21
last reply
May '21
19
replies
2.0k
views
4
users
10
likes
6
links
10
5
2

skreyda

1
Apr '21
For openwrt-19.7.07.
Enter the spoiler content in the file ar9344_tplink_tl-wdr4300-v1-16.dts.

ar9344_tplink_tl-wdr4300-v1-16.dts
Solution
2


jring
Apr '21
Hi,

thank you very much, will try and post results here...

Joachim




jring
Apr '21
Hi,

ok, after a long night of hacking, I have gotten a bit closer to the target - but not quite there:

As for the flash layout, the solution from skreyda was close. When I applied it as given, dtc complained about a duplicate label art as follows:

/home/ringo/openwrt-19.07.7/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-4.14.221/scripts/dtc/dtc -O dtb -i../dts/ -Wno-unit_address_vs_reg -Wno-unit_address_vs_reg -Wno-simple_bus_reg -Wno-unit_address_format -Wno-pci_bridge -Wno-pci_device_bus_num -Wno-pci_device_reg  -o /home/ringo/openwrt-19.07.7/build_dir/target-mips_24kc_musl/linux-ath79_generic/image-ar9344_tplink_tl-wdr4300-v1-16.dtb /home/ringo/openwrt-19.07.7/build_dir/target-mips_24kc_musl/linux-ath79_generic/image-ar9344_tplink_tl-wdr4300-v1-16.dtb.tmp
/home/ringo/openwrt-19.07.7/build_dir/target-mips_24kc_musl/linux-ath79_generic/image-ar9344_tplink_tl-wdr4300-v1-16.dtb: ERROR (duplicate_label): Duplicate label 'art' on /ahb/spi@1f000000/flash@0/partitions/partition@ff0000 and /ahb/spi@1f000000/flash@0/partitions/partition@7f0000
ERROR: Input tree has errors, aborting (use -f to force output)
I first tried to change the label in ar9344_tplink_tl-wdr4300-v1-16.dts to art16 which built but left me with two art partitions... probably not ideal later.

I then went reading and learned a bit about linux device trees and tried to remove the partition@7f0000 node from the ar9344_tplink_tl-wdrxxxx.dtsi like this:

                    /delete-node/ partition@7f0000;
                    art: partition@ff0000 {
                            label = "art";
                            reg = <0xff0000 0x010000>;
                            read-only;
which built fine and gave an image using the 16MB flash and an art partition at 0xff0000. Since the we actually are creating a different node partition@ff0000 instead of partition@7f0000, the normal overwrite mechanism does not work here... not sure if there is another way to do it... or whether it's safe... comments welcome
I found the following page on device tree dark arts: https://elinux.org/Device_Tree_Source_Undocumented 4

Unfortunately my new image did only have eth0 and wlan0 running... the switch was unconfigured as I found after some research. I stole /etc/config/network from the stock 19.07.7 factory image which did the trick...

Same for the rather short distfeeds.conf with only core and base repos... I added the missing ones manually...

What do I have to include in menuconfig to get those two as in the stock image? Or can I even download the config which was used to build the stock image somewhere?

TIA and good night,

Joachim

1 Reply



skreyda
Apr '21
What do I have to include in menuconfig to get those two as in the stock image?

Also edit the files before building.

patch
1


jring
Apr '21
Hi,

thanks again, that did the trick for the switch config 19.07 - so marked as solved now.

The distfeeds.conf can be manipulated in make menuconfig under Image Configuration -> Separate feed repositories.

Will test 21 RC tomorrow and post a writeup for the record.

Joachim




jring

2
Apr '21
Hi,

for the record, I have successfully applied the procedure described below to v21.02.0-rc1. There is a good chance that it will also work on other TPLink models based on the ar9344 (aka those that include ./target/linux/ath79/dts/ar9344_tplink_tl-wdrxxxx.dtsi).

Cheers,

Joachim

First of all: Remember to save what you need - at least the bootloeader and the arm partition...

Edit target/linux/ath79/image/generic-tp-link.mk and copy the tplink_tl-wdr4300-v1 entry and add as follows:

define Device/tplink_tl-wdr4300-v1-16
  $(Device/tplink-16mlzma)
  SOC := ar9344
  DEVICE_MODEL := TL-WDR4300
  DEVICE_VARIANT := v1 16MB
  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ledtrig-usbport
  TPLINK_HWID := 0x43000001
  SUPPORTED_DEVICES += tl-wdr4300-
endef
TARGET_DEVICES += tplink_tl-wdr4300-v1-16
Copy the dts file and change copy as follows:
cp ./target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1.dts ./target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1-16.dts
vi ./target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1-16.dts

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "ar9344_tplink_tl-wdr4300.dtsi"

/ {
        model = "TP-Link TL-WDR4300 v1 16";
        compatible = "tplink,tl-wdr4300-v1", "qca,ar9344";
};

&spi {
        num-cs = <1>;

        status = "okay";

        flash@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <25000000>;

                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;

                        uboot: partition@0 {
                                label = "u-boot";
                                reg = <0x000000 0x020000>;
                                read-only;
                        };

                        partition@20000 {
                                compatible = "tplink,firmware";
                                label = "firmware";
                                reg = <0x020000 0xfd0000>;
                        };
                        /delete-node/ partition@7f0000;
                        art: partition@ff0000 {
                                label = "art";
                                reg = <0xff0000 0x010000>;
                                read-only;
                        };
                };
        };
};
Search recursively for "tplink,tl-wdr4300-v1|" in target and add a new line with our new 16MB model after each occurence:

grep -r "tplink,tl-wdr4300-v1|" target
target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom: tplink,tl-wdr4300-v1|
target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration:tplink,tl-wdr4300-v1|
target/linux/ath79/generic/base-files/etc/board.d/02_network: tplink,tl-wdr4300-v1|
target/linux/ath79/generic/base-files/etc/board.d/02_network: tplink,tl-wdr4300-v1|\

tplink,tl-wdr4300-v1|
tplink,tl-wdr4300-v1-16|\

make menuconfig
choose Target Profile TP-Link TL-WDR4300 v1 16MB
choose Image Configuration -> Separate Feed repositories and tag all.
exit and save config

make
flash image
flash arm backup
Enjoy!

1


kmaras77
May '21
Could you please add these changes to the official repository so that there is a 16MB flash model in the official repository. I have two such modified 16m flash WDR4300 routers and I still have trouble keeping the modified files in the local repository.



回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-11-13 22:57 | 显示全部楼层
diff -Naur openwrt/target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1-16.dts openwrt-wdr4300-16/target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1-16.dts
--- openwrt/target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1-16.dts        1970-01-01 01:00:00.000000000 +0100
+++ openwrt-wdr4300-16/target/linux/ath79/dts/ar9344_tplink_tl-wdr4300-v1-16.dts        2021-05-04 22:28:12.870137111 +0200
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "ar9344_tplink_tl-wdr4300.dtsi"
+
+/ {
+        model = "TP-Link TL-WDR4300 v1 16";
+        compatible = "tplink,tl-wdr4300-v1", "qca,ar9344";
+};
+
+&spi {
+        num-cs = <1>;
+
+        status = "okay";
+
+        flash@0 {
+                compatible = "jedec,spi-nor";
+                reg = <0>;
+                spi-max-frequency = <25000000>;
+
+                partitions {
+                        compatible = "fixed-partitions";
+                        #address-cells = <1>;
+                        #size-cells = <1>;
+
+                        uboot: partition@0 {
+                                label = "u-boot";
+                                reg = <0x000000 0x020000>;
+                                read-only;
+                        };
+
+                        partition@20000 {
+                                compatible = "tplink,firmware";
+                                label = "firmware";
+                                reg = <0x020000 0xfd0000>;
+                        };
+                        /delete-node/ partition@7f0000;
+                        art: partition@ff0000 {
+                                label = "art";
+                                reg = <0xff0000 0x010000>;
+                                read-only;
+                        };
+                };
+        };
+};
+
diff -Naur openwrt/target/linux/ath79/generic/base-files/etc/board.d/02_network openwrt-wdr4300-16/target/linux/ath79/generic/base-files/etc/board.d/02_network
--- openwrt/target/linux/ath79/generic/base-files/etc/board.d/02_network        2021-05-04 22:23:55.409445782 +0200
+++ openwrt-wdr4300-16/target/linux/ath79/generic/base-files/etc/board.d/02_network        2021-05-04 22:31:02.011216281 +0200
@@ -287,6 +287,7 @@
        tplink,archer-c7-v5|\
        tplink,tl-wdr3600-v1|\
        tplink,tl-wdr4300-v1|\
+        tplink,tl-wdr4300-v1-16|\
        tplink,tl-wdr4300-v1-il|\
        tplink,tl-wdr4310-v1)
                ucidef_add_switch "switch0" \
@@ -583,6 +584,7 @@
        mercury,mw4530r-v1|\
        tplink,tl-wdr3600-v1|\
        tplink,tl-wdr4300-v1|\
+        tplink,tl-wdr4300-v1-16|\
        tplink,tl-wdr4300-v1-il)
                base_mac=$(mtd_get_mac_binary u-boot 0x1fc00)
                wan_mac=$(macaddr_add "$base_mac" 1)
diff -Naur openwrt/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom openwrt-wdr4300-16/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
--- openwrt/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom        2021-05-04 22:20:16.646634511 +0200
+++ openwrt-wdr4300-16/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom        2021-05-04 22:29:33.272823270 +0200
@@ -94,6 +94,7 @@
        tplink,tl-wdr3500-v1|\
        tplink,tl-wdr3600-v1|\
        tplink,tl-wdr4300-v1|\
+        tplink,tl-wdr4300-v1-16|\
        tplink,tl-wdr4300-v1-il|\
        tplink,tl-wdr4310-v1|\
        tplink,tl-wdr4900-v2|\
diff -Naur openwrt/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration openwrt-wdr4300-16/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration
--- openwrt/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration        2021-05-04 22:20:16.646634511 +0200
+++ openwrt-wdr4300-16/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration        2021-05-04 22:30:14.199236628 +0200
@@ -57,6 +57,7 @@
tplink,archer-c7-v2|\
tplink,tl-wdr3600-v1|\
tplink,tl-wdr4300-v1|\
+tplink,tl-wdr4300-v1-16|\
tplink,tl-wdr4300-v1-il|\
tplink,tl-wdr4310-v1)
        migrate_leds "blue:=green:"
diff -Naur openwrt/target/linux/ath79/image/generic-tp-link.mk openwrt-wdr4300-16/target/linux/ath79/image/generic-tp-link.mk
--- openwrt/target/linux/ath79/image/generic-tp-link.mk        2021-05-04 22:23:55.409445782 +0200
+++ openwrt-wdr4300-16/target/linux/ath79/image/generic-tp-link.mk        2021-05-04 22:27:17.137735165 +0200
@@ -531,6 +531,17 @@
endef
TARGET_DEVICES += tplink_tl-wdr4300-v1

+define Device/tplink_tl-wdr4300-v1-16
+  $(Device/tplink-16mlzma)
+  SOC := ar9344
+  DEVICE_MODEL := TL-WDR4300
+  DEVICE_VARIANT := v1 16MB
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ledtrig-usbport
+  TPLINK_HWID := 0x43000001
+  SUPPORTED_DEVICES += tl-wdr4300-
+endef
+TARGET_DEVICES += tplink_tl-wdr4300-v1-16
+
define Device/tplink_tl-wdr4300-v1-il
   $(Device/tplink-8mlzma)
   SOC := ar9344
cp wdr-4300-16.patch /tmp
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-6-2 02:46

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表