[source] ar71xx: Add support for Netgear WNR2000v1

LEDE Commits lede-commits at lists.infradead.org
Wed Dec 14 01:37:34 PST 2016


blogic pushed a commit to source.git, branch master:
https://git.lede-project.org/fd62fa752bbff9ae5277098152e7960a14d241e1

commit fd62fa752bbff9ae5277098152e7960a14d241e1
Author: Huan Truong <htruong at tnhh.net>
AuthorDate: Mon Dec 12 15:25:01 2016 -0600

    ar71xx: Add support for Netgear WNR2000v1
    
    This patch adds supports for the WNR2000v1 board with 4MB flash, and
    produces device-specific factory, rootfs, and sysupgrade files for the
    WNR2000v1. This board is errorneously claimed as supported on the OpenWRT
    wiki as AP81, but AP81 image would not work because of APT81 image
    requiring having 8MB of flash, while WNR2000v1 has only 4MB.
    
    The image requires the u-boot bootloader to be modified to fuhry's
    bootloader first.
    
    Short specification:
    
    - CPU: Atheros AR9132
    - 4x 10/100 Mbps Ethernet, 1x WAN 10/100 Mbps
    - 4 MB of Flash
    - 32 MB of RAM
    - UART header (J1) on board
    - 1x button
    
    Factory/Initial flash instructions:
    
    - Set up a TFTP server on your local machine.
    - Download the uImage for ar71xx-generic and the rootfs image for
      ar71xx-generic-wnr2000 and save in the tftp server root.
    - Gain serial access to the router via the UART port (telnetenable over
      the network only won't work!).
    - Upgrade the u-boot bootloader to fuhry's version by running the
      script: http://fuhry.com/b/wnr2000/install-repart.sh
    - When the router restarts, interrupt u-boot and gain access to u-boot command line.
    - Repartititon the board and flash initial uImage and rootfs as follow.
    
    Commands to type in u-boot:
    
    	# tells u-boot that we have a tftp server on 192.168.1.10
    	setenv serverip 192.168.1.10
    
    	# tells u-boot that the router should take the address 192.168.1.1
    	setenv ipaddr 192.168.1.1
    
    	# erase the region from 0x050000-0x3f0000
    	erase 0xbf050000 +0x3A0000
    
    	# loads sqfs.bin on TFTP server, and put it to memory address 0x81000000
    	tftpboot 0x81000000 sqfs.bin
    	# it will tell you the length of sqfs.bin in hex, let's say ZZZZZZ
    	# copy bit by bit 0xZZZZZZ bytes from offset 0x050000
    	cp.b 0x81000000 0xbf050000 0xZZZZZZ
    
    	# same to the uImage.bin, write it right next to sqfs.bin
    	# again, 0xYYYYYY is the length that tftpboot reports
    	tftpboot 0x81000000 uImage.bin
    	cp.b 0x81000000 0xbf2a0000 0xYYYYYY
    
    	# We need to tell the kernel what board it is booting into, and where to find the partitions
    	setenv bootargs "board=WNR2000 console=ttyS0,115200 mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,3712k(firmware),64k(art)ro rootfstype=squashfs,jffs2 noinitrd"
    
    	# Tell u-boot where to find the uImage
    	setenv bootcmd "bootm 0xbf2a0000"
    
    	# Tell u-boot to save parameters to the u-boot-env partitions
    	saveenv
    
    	# Reset the board
    	reset
    
    Tested on:
    
    - WNR2000v1 board.
    - Initial flash works.
    
    Known bugs:
    
    - I don't know why factory image doesn't work on initial flash on stock
      firmware in u-boot recovery mode while it should.
    - Sysupgrade does not yet work, if you do -f it will mess up your
      installation (requiring a reinstall of sqfs and uImage).
    
    Signed-off-by: Huan Truong <htruong at tnhh.net>
---
 .../ar71xx/files/arch/mips/ath79/mach-wnr2000.c    | 45 +---------------------
 target/linux/ar71xx/image/legacy-devices.mk        |  5 +++
 target/linux/ar71xx/image/legacy.mk                |  6 +++
 .../files/drivers/mtd/mtdsplit/mtdsplit_uimage.c   |  2 +
 4 files changed, 14 insertions(+), 44 deletions(-)

diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000.c
index b4da7ec..6e3beca 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000.c
@@ -32,49 +32,6 @@
 #define WNR2000_KEYS_POLL_INTERVAL	20	/* msecs */
 #define WNR2000_KEYS_DEBOUNCE_INTERVAL	(3 * WNR2000_KEYS_POLL_INTERVAL)
 
-static struct mtd_partition wnr2000_partitions[] = {
-	{
-		.name		= "u-boot",
-		.offset		= 0,
-		.size		= 0x040000,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "u-boot-env",
-		.offset		= 0x040000,
-		.size		= 0x010000,
-	}, {
-		.name		= "rootfs",
-		.offset		= 0x050000,
-		.size		= 0x240000,
-	}, {
-		.name		= "user-config",
-		.offset		= 0x290000,
-		.size		= 0x010000,
-	}, {
-		.name		= "uImage",
-		.offset		= 0x2a0000,
-		.size		= 0x120000,
-	}, {
-		.name		= "language_table",
-		.offset		= 0x3c0000,
-		.size		= 0x020000,
-	}, {
-		.name		= "rootfs_checksum",
-		.offset		= 0x3e0000,
-		.size		= 0x010000,
-	}, {
-		.name		= "art",
-		.offset		= 0x3f0000,
-		.size		= 0x010000,
-		.mask_flags	= MTD_WRITEABLE,
-	}
-};
-
-static struct flash_platform_data wnr2000_flash_data = {
-	.parts		= wnr2000_partitions,
-	.nr_parts	= ARRAY_SIZE(wnr2000_partitions),
-};
-
 static struct gpio_led wnr2000_leds_gpio[] __initdata = {
 	{
 		.name		= "netgear:green:power",
@@ -130,7 +87,7 @@ static void __init wnr2000_setup(void)
 	ath79_register_eth(0);
 	ath79_register_eth(1);
 
-	ath79_register_m25p80(&wnr2000_flash_data);
+	ath79_register_m25p80(NULL);
 
 	ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
 				 wnr2000_leds_gpio);
diff --git a/target/linux/ar71xx/image/legacy-devices.mk b/target/linux/ar71xx/image/legacy-devices.mk
index 7bf4f93..3f865da 100644
--- a/target/linux/ar71xx/image/legacy-devices.mk
+++ b/target/linux/ar71xx/image/legacy-devices.mk
@@ -421,6 +421,11 @@ define LegacyDevice/WPE72_16M
 endef
 LEGACY_DEVICES += WPE72_16M
 
+define LegacyDevice/WNR2000
+  DEVICE_TITLE := NETGEAR WNR2000V1
+endef
+LEGACY_DEVICES += WNR2000
+
 define LegacyDevice/WNR2000V3
   DEVICE_TITLE := NETGEAR WNR2000V3
 endef
diff --git a/target/linux/ar71xx/image/legacy.mk b/target/linux/ar71xx/image/legacy.mk
index 53e53f0..226b66e 100644
--- a/target/linux/ar71xx/image/legacy.mk
+++ b/target/linux/ar71xx/image/legacy.mk
@@ -276,6 +276,7 @@ wpj531_mtdlayout_16M=mtdparts=spi0.0:192k(u-boot)ro,16128k(firmware),64k(art)ro
 wpj558_mtdlayout_16M=mtdparts=spi0.0:192k(u-boot)ro,16128k(firmware),64k(art)ro
 wndap360_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1728k(kernel),6016k(rootfs),64k(nvram)ro,64k(art)ro,7744k at 0x50000(firmware)
 wnr2200_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7808k(firmware),64k(art)ro
+wnr2000_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,3712k(firmware),64k(art)ro
 wnr2000v3_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,3712k(firmware),64k(art)ro
 wnr2000v4_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,3776k(firmware),64k(art)ro
 r6100_mtdlayout=mtdparts=ar934x-nfc:128k(u-boot)ro,256k(caldata)ro,256k(caldata-backup),512k(config),512k(pot),2048k(kernel),122240k(ubi),25600k at 0x1a0000(firmware),2048k(language),3072k(traffic_meter)
@@ -686,6 +687,10 @@ define Image/Build/Netgear
 				-o $(call imgname,$(1),$(2))-factory$$dashr.img; \
 		done; \
 	fi
+	if [ "$2" = "wnr2000" ]; then \
+		dd if=$(KDIR)/root.$(1) \
+			of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync; \
+	fi
 endef
 
 
@@ -970,6 +975,7 @@ $(eval $(call SingleProfile,MyLoader,64k,WPE72_16M,wpe72,,ttyS0,115200,0x1000000
 
 $(eval $(call SingleProfile,Netgear,64kraw,WNR2000V3,wnr2000v3,WNR2000V3,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x32303033,WNR2000V3,"" NA,-H 29763551+04+32))
 $(eval $(call SingleProfile,NetgearLzma,64kraw,WNR2000V4,wnr2000v4,WNR2000V4,ttyS0,115200,$$(wnr2000v4_mtdlayout),0x32303034,WNR2000V4,"" NA,))
+$(eval $(call SingleProfile,Netgear,64kraw,WNR2000,wnr2000,WNR2000,ttyS0,115200,$$(wnr2000_mtdlayout),0x32303031,WNR2000,"" NA,))
 $(eval $(call SingleProfile,Netgear,64kraw,WNR2200,wnr2200,WNR2200,ttyS0,115200,$$(wnr2200_mtdlayout),0x32323030,wnr2200,"" NA,))
 $(eval $(call SingleProfile,Netgear,64kraw,REALWNR612V2,wnr612v2,WNR612V2,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x32303631,WNR612V2,"",))
 $(eval $(call SingleProfile,Netgear,64kraw,N150R,n150r,WNR612V2,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x32303631,N150R,"",))
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index 26cb66a..41a1b37 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -246,6 +246,7 @@ static struct mtd_part_parser uimage_generic_parser = {
 	.type = MTD_PARSER_TYPE_FIRMWARE,
 };
 
+#define FW_MAGIC_WNR2000V1	0x32303031
 #define FW_MAGIC_WNR2000V3	0x32303033
 #define FW_MAGIC_WNR2000V4	0x32303034
 #define FW_MAGIC_WNR2200	0x32323030
@@ -265,6 +266,7 @@ static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len)
 	case FW_MAGIC_WNR612V2:
 	case FW_MAGIC_WNR1000V2:
 	case FW_MAGIC_WNR1000V2_VC:
+	case FW_MAGIC_WNR2000V1:
 	case FW_MAGIC_WNR2000V3:
 	case FW_MAGIC_WNR2200:
 	case FW_MAGIC_WNDR3700:



More information about the lede-commits mailing list