This patches makes a G300NH version of u-boot, heavily based upon the
existing Zyxel NGB460 code.  This is sufficient to be able to kexec
into (or whatever) then access flash, then boot from there back into
Linux. (See previous threads on kexec).

I know that the flash setup isn't exactly right, since there are
messages about too many sectors, and the CRC for the existing
env settings is wrong.  Also, I left in the ethernet stuff,
since I couldn't completely turn that off.

I don't think this will work as-is on G300NH2, since that has
a different flash interface.  However, this is sufficient for my
immediate needs, and if anyone has any improvements, I'll try
them out.

Signed-off-by: Peter Naulls <pe...@chocky.org>

Index: uboot-ar71xx/files/include/configs/g300nh.h
===================================================================
--- uboot-ar71xx/files/include/configs/g300nh.h	(revision 0)
+++ uboot-ar71xx/files/include/configs/g300nh.h	(revision 0)
@@ -0,0 +1,154 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.k...@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/* This file contains the configuration parameters for the zyxel nbg460n board. */
+
+#define DEBUG
+
+#ifndef _NBG460N_CONFIG_H
+#define _NBG460N_CONFIG_H
+
+#define CONFIG_MIPS32		1  /* MIPS32 CPU core */
+#define CONFIG_AR71XX		1
+#define CONFIG_AR91XX		1
+#define CONFIG_SYS_HZ		1000
+#define CONFIG_SYS_MIPS_TIMER_FREQ (400000000/2)
+
+/* Cache Configuration */
+#define CONFIG_SYS_DCACHE_SIZE		32768
+#define CONFIG_SYS_ICACHE_SIZE		65536
+#define CONFIG_SYS_CACHELINE_SIZE	32
+/* Cache lock for stack */
+#define CONFIG_SYS_INIT_SP_OFFSET	0x1000
+
+#define CONFIG_SYS_MONITOR_BASE	(TEXT_BASE)
+
+#define CONFIG_BAUDRATE		115200
+#define CONFIG_SYS_BAUDRATE_TABLE  {115200}
+
+#define CONFIG_MISC_INIT_R
+
+/* SPI-Flash support */
+#define CONFIG_SPI_FLASH
+
+#define CONFIG_AR71XX_SPI
+//#define CONFIG_SPI_FLASH_SPANSION
+#define CONFIG_SF_DEFAULT_HZ	25000000
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_ENV_SPI_MAX_HZ	25000000
+#define CONFIG_ENV_SPI_BUS		0
+#define CONFIG_ENV_SPI_CS		0
+
+
+#define CONFIG_FSL_ESPI
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_SPANSION
+
+
+#define	CONFIG_ENV_IS_IN_SPI_FLASH
+//#define CONFIG_ENV_ADDR			0xbe400000
+#define CONFIG_ENV_OFFSET		0x40000
+#define CONFIG_ENV_SIZE			0x20000
+#define CONFIG_ENV_SECT_SIZE	0x10000
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+#define CONFIG_SYS_MAX_FLASH_SECT 1
+#define CONFIG_SYS_FLASH_BASE 0xbe000000
+
+#define CONFIG_SYS_FLASH_CFI
+
+#define CONFIG_SYS_FLASH_BANKS_LIST     { CONFIG_SYS_FLASH_BASE }
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+
+//#define CONFIG_ENV_IS_NOWHERE
+
+/* Net support */
+#define CONFIG_ETHADDR_ADDR     0xbfc0fff8
+#define CONFIG_SYS_RX_ETH_BUFFER  	16
+#define CONFIG_AG71XX
+#define CONFIG_AG71XX_PORTS     { 1, 1 }
+#define CONFIG_AG71XX_MII0_IIF  MII0_CTRL_IF_RGMII
+#define CONFIG_AG71XX_MII1_IIF  MII1_CTRL_IF_RGMII
+#define CONFIG_NET_MULTI
+#define CONFIG_IPADDR			192.168.11.1
+#define CONFIG_SERVERIP			192.168.11.2
+
+/* Switch support */
+#define CONFIG_MII
+#define CONFIG_RTL8366_MII
+#define RTL8366_PIN_SDA 16
+#define RTL8366_PIN_SCK 18
+#define MII_GPIOINCLUDE <asm/ar71xx_gpio.h>
+#define MII_SETSDA(x)   ar71xx_setpin(RTL8366_PIN_SDA, x)
+#define MII_GETSDA      ar71xx_getpin(RTL8366_PIN_SDA)
+#define MII_SETSCK(x)   ar71xx_setpin(RTL8366_PIN_SCK, x)
+#define MII_SDAINPUT    ar71xx_setpindir(RTL8366_PIN_SDA, 0)
+#define MII_SDAOUTPUT   ar71xx_setpindir(RTL8366_PIN_SDA, 1)
+#define MII_SCKINPUT    ar71xx_setpindir(RTL8366_PIN_SCK, 0)
+#define MII_SCKOUTPUT   ar71xx_setpindir(RTL8366_PIN_SCK, 1)
+
+#define CONFIG_BOOTDELAY	3
+#define	CONFIG_BOOTARGS		"console=ttyS0,115200 rootfstype=squashfs,jffs2 noinitrd machtype=WZR-HP-G300NH"
+#define CONFIG_BOOTCOMMAND	"bootm be060000"
+#define CONFIG_LZMA
+
+/* Commands */
+
+#include <config_cmd_default.h>
+#define CONFIG_CMD_BDI
+//#define CONFIG_CMD_FPGA
+#define CONFIG_CMD_IMI
+#define CONFIG_CMD_IMLS
+#define CONFIG_CMD_LOADS
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_MII
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_DHCP
+//#define CONFIG_CMD_SPI
+
+#define CONFIG_CMD_DIAG
+
+/* Miscellaneous configurable options */
+#define CONFIG_SYS_PROMPT		"U-Boot> "
+#define CONFIG_SYS_CBSIZE		256
+#define CONFIG_SYS_MAXARGS		16
+#define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_LONGHELP		1
+#define CONFIG_CMDLINE_EDITING	1
+#define CONFIG_AUTO_COMPLETE
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN		ROUND(3 * 0x10000 + 128*1024, 0x1000)
+#define CONFIG_SYS_GBL_DATA_SIZE	128	/* 128 bytes for initial data */
+
+#define CONFIG_SYS_BOOTPARAMS_LEN	128*1024
+
+#define CONFIG_SYS_SDRAM_BASE		0x80000000     /* Cached addr */
+#define	CONFIG_SYS_LOAD_ADDR		0x80060000     /* default load address	*/
+
+#define CONFIG_SYS_MEMTEST_START	0x80000800
+#define CONFIG_SYS_MEMTEST_END		0x81E00000
+
+#endif	/* _NBG460N_CONFIG_H */
Index: uboot-ar71xx/files/board/buffalo/g300nh/g300nh.c
===================================================================
--- uboot-ar71xx/files/board/buffalo/g300nh/g300nh.c	(revision 0)
+++ uboot-ar71xx/files/board/buffalo/g300nh/g300nh.c	(revision 0)
@@ -0,0 +1,98 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.k...@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <netdev.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+#include <asm/reboot.h>
+#include <asm/ar71xx.h>
+#include <asm/ar71xx_gpio.h>
+
+#define NBG460N_WAN_LED			19
+
+phys_size_t initdram(int board_type)
+{
+    return (64*1024*1024);
+    //return (32*1024*1024);
+}
+
+int checkboard(void)
+{
+	// Set pin 19 to 1, to stop WAN LED blinking
+    //ar71xx_setpindir(NBG460N_WAN_LED, 1);
+    //ar71xx_setpin(NBG460N_WAN_LED, 1);
+
+    printf("U-boot on WZR-HP-G300NH\n");
+    return 0;
+}
+
+void _machine_restart(void)
+{
+	for (;;) {
+		writel((RESET_MODULE_FULL_CHIP | RESET_MODULE_DDR),
+			KSEG1ADDR(AR71XX_RESET_BASE + AR91XX_RESET_REG_RESET_MODULE));
+        readl(KSEG1ADDR(AR71XX_RESET_BASE + AR91XX_RESET_REG_RESET_MODULE));
+	}
+}
+
+int board_eth_init(bd_t *bis)
+{
+  /*
+    char *phynames[] = {RTL8366_DEVNAME, RTL8366_DEVNAME};
+    u16 phyids[] = {RTL8366_LANPHY_ID, RTL8366_WANPHY_ID};
+    u16 phyfixed[] = {1, 0};
+
+    if (ag71xx_register(bis, phynames, phyids, phyfixed) <= 0)
+        return -1;
+
+	if (rtl8366s_initialize())
+        return -1;
+
+    if (rtl8366_mii_register(bis))
+        return -1;
+		*/
+    return 0;
+}
+
+int misc_init_r(void) {
+    uint8_t macaddr[6];
+    uint8_t enetaddr[6];
+/*
+	debug("Testing mac addresses\n");
+	
+    memcpy(macaddr, (uint8_t *) CONFIG_ETHADDR_ADDR, 6);
+
+    if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+        debug("Setting eth0 mac addr to %pM\n", macaddr);
+        eth_setenv_enetaddr("ethaddr", macaddr);
+    }
+
+    if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
+		macaddr[5] += 1;
+        debug("Setting eth1 mac addr to %pM\n", macaddr);
+        eth_setenv_enetaddr("eth1addr", macaddr);
+    }
+*/
+    return 0;
+}
Index: uboot-ar71xx/files/board/buffalo/g300nh/u-boot.lds
===================================================================
--- uboot-ar71xx/files/board/buffalo/g300nh/u-boot.lds	(revision 0)
+++ uboot-ar71xx/files/board/buffalo/g300nh/u-boot.lds	(revision 0)
@@ -0,0 +1,42 @@
+OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
+OUTPUT_ARCH(mips)
+ENTRY(_start)
+SECTIONS
+{
+	. = 0x00000000;
+
+	. = ALIGN(4);
+	.text       :
+	{
+	  *(.text)
+	}
+
+	. = ALIGN(4);
+	.rodata  : { *(.rodata) }
+
+	. = ALIGN(4);
+	.data  : { *(.data) }
+
+	. = ALIGN(4);
+	.sdata  : { *(.sdata) }
+
+	_gp = ALIGN(16);
+
+	__got_start = .;
+	.got  : { *(.got) }
+	__got_end = .;
+
+	.sdata  : { *(.sdata) }
+
+	__u_boot_cmd_start = .;
+	.u_boot_cmd : { *(.u_boot_cmd) }
+	__u_boot_cmd_end = .;
+
+	uboot_end_data = .;
+	num_got_entries = (__got_end - __got_start) >> 2;
+
+	. = ALIGN(4);
+	.sbss  : { *(.sbss) }
+	.bss  : { *(.bss) }
+	uboot_end = .;
+}
Index: uboot-ar71xx/files/board/buffalo/g300nh/config.mk
===================================================================
--- uboot-ar71xx/files/board/buffalo/g300nh/config.mk	(revision 0)
+++ uboot-ar71xx/files/board/buffalo/g300nh/config.mk	(revision 0)
@@ -0,0 +1 @@
+TEXT_BASE = 0x81E00000
Index: uboot-ar71xx/files/board/buffalo/g300nh/Makefile
===================================================================
--- uboot-ar71xx/files/board/buffalo/g300nh/Makefile	(revision 0)
+++ uboot-ar71xx/files/board/buffalo/g300nh/Makefile	(revision 0)
@@ -0,0 +1,46 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).a
+
+COBJS-y += $(BOARD).o
+SOBJS-y += lowlevel_init.o
+
+SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+SOBJS	:= $(addprefix $(obj),$(SOBJS-y))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
Index: uboot-ar71xx/files/board/buffalo/g300nh/lowlevel_init.S
===================================================================
--- uboot-ar71xx/files/board/buffalo/g300nh/lowlevel_init.S	(revision 0)
+++ uboot-ar71xx/files/board/buffalo/g300nh/lowlevel_init.S	(revision 0)
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.k...@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <config.h>
+#include <version.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+
+
+
+.globl lowlevel_init
+/*
+	All done by Bootbase, nothing to do
+*/
+lowlevel_init:
+    jr ra
+    nop
+
Index: uboot-ar71xx/patches/001-ar71xx.patch
===================================================================
--- uboot-ar71xx/patches/001-ar71xx.patch	(revision 29712)
+++ uboot-ar71xx/patches/001-ar71xx.patch	(working copy)
@@ -12,7 +12,7 @@
 diff -ur u-boot-2010.03/Makefile u-boot-nbg/Makefile
 --- u-boot-2010.03/Makefile	2010-03-31 23:54:39.000000000 +0200
 +++ u-boot-nbg/Makefile	2010-04-11 23:31:29.000000000 +0200
-@@ -3455,6 +3455,13 @@
+@@ -3455,6 +3455,16 @@
  	@$(MKCONFIG) -a qemu-mips mips mips qemu-mips
  
  #########################################################################
@@ -22,6 +22,9 @@
 +nbg460n_550n_550nh_config : 	unconfig
 +	@$(MKCONFIG) -a nbg460n mips mips nbg460n zyxel
 +
++g300nh_config : 	unconfig
++	@$(MKCONFIG) -a g300nh mips mips g300nh buffalo
++
 +#########################################################################
  ## MIPS64 5Kc
  #########################################################################
Index: uboot-ar71xx/Makefile
===================================================================
--- uboot-ar71xx/Makefile	(revision 29712)
+++ uboot-ar71xx/Makefile	(working copy)
@@ -30,8 +30,12 @@
   TITLE:=U-boot for the NBG460N/550N/550NH routers
 endef
 
-UBOOTS:=nbg460n_550n_550nh
+define uboot/g300nh
+  TITLE:=U-boot for the WZR-G300NH router
+endef
 
+UBOOTS:=nbg460n_550n_550nh g300nh
+
 define Package/uboot/template
 define Package/uboot-ar71xx-$(1)
   SECTION:=boot
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to