[U-Boot-Users] [PATCH] ixp: Support for NSLU2

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Mon Mar 31 12:18:56 CEST 2008


> +
> +#include <common.h>
> +
> +/*-----------------------------------------------------------------------
> + * Linksys NSLU2 RedBoot Trailer Block:
> + *
> + * If we boot from RAM on a system which still contains the original
> + * RedBoot bootloader, check if the trailer signature exists and save
> + * the MAC address information it contains.
> + *
> + * 0x3ffb0: six byte binary mac address
> + * 0x3fff8: ' sErCoMm'
> + */
> +
> +void load_sernum_ethaddr (void)
> +{
> +	unsigned char *hwi;
> +	unsigned char  ethaddr[19]; /* 6 x "%02X", + 1 */
> +	unsigned short ih, ie;
> +
> +	/* Check for signature at the end of RedBoot partition */
> +	/* If RedBoot has been replaced, this will not exist. */
> +	hwi = (unsigned char *)(CFG_FLASH_BASE + CFG_SERCOMM_OFFSET);
> +	if (strncmp((char *)hwi, " sErCoMm", 8)) {
> +		return;
> +	}
> +
> +	hwi = (unsigned char *)(CFG_FLASH_BASE + CFG_ETHADDR_OFFSET);
> +	ie = 0;
> +
> +	/* copy MAC address */
> +	for (ih = 0; ih < 6; ih++) {
> +		sprintf((char *)&ethaddr[ie], "%02X:", hwi[ih]);
> +		ie += 3;
> +	}
> +	ethaddr[--ie] = '\0';
> +
> +	/* set ethaddr if not yet defined */
> +	if (getenv("ethaddr") == NULL) {
> +		setenv ((char *)"ethaddr", (char *)ethaddr);
> +	}

read the mac address only if the getenv return NULL

	/* set ethaddr if not yet defined */
	if (getenv("ethaddr") == NULL) {
		hwi = (unsigned char *)(CFG_FLASH_BASE + CFG_ETHADDR_OFFSET);
		ie = 0;

		/* copy MAC address */
		for (ih = 0; ih < 6; ih++) {
			sprintf((char *)&ethaddr[ie], "%02X:", hwi[ih]);
			ie += 3;
		}
		ethaddr[--ie] = '\0';

		setenv ((char *)"ethaddr", (char *)ethaddr);
	}


> Index: u-boot/board/nslu2/nslu2.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ u-boot/board/nslu2/nslu2.c	2008-03-27 15:10:31.000000000 +1030
> @@ -0,0 +1,96 @@
> +/*
> + * (C) Copyright 2008
> + * Rod Whitby <rod at whitby.id.au>
> + *
> + * (C) Copyright 2006
> + * Stefan Roese, DENX Software Engineering, sr at denx.de.
> + *
> + * (C) Copyright 2002
> + * Kyle Harris, Nexus Technologies, Inc. kharris at nexus-tech.net
> + *
> + * (C) Copyright 2002
> + * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
> + * Marius Groeger <mgroeger at sysgo.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 <common.h>
> +#include <command.h>
> +#include <malloc.h>
> +#include <asm/arch/ixp425.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/*
> + * Miscelaneous platform dependent initialisations
> + */
> +int board_init (void)
> +{
> +	/* arch number of NSLU2 */
> +	gd->bd->bi_arch_number = MACH_TYPE_NSLU2;
> +
> +	/* adress of boot parameters */
> +	gd->bd->bi_boot_params = 0x00000100;
> +
> +	/*
> +	 * Setup GPIO's for PCI interrupts
> +	 */
> +	GPIO_OUTPUT_DISABLE(CFG_GPIO_PCI_INTA_N);
> +	GPIO_INT_ACT_LOW_SET(CFG_GPIO_PCI_INTA_N);
> +	GPIO_OUTPUT_DISABLE(CFG_GPIO_PCI_INTB_N);
> +	GPIO_INT_ACT_LOW_SET(CFG_GPIO_PCI_INTB_N);
> +	GPIO_OUTPUT_DISABLE(CFG_GPIO_PCI_INTC_N);
> +	GPIO_INT_ACT_LOW_SET(CFG_GPIO_PCI_INTC_N);
> +
> +	/*
> +	 * Setup GPIO's for 33MHz clock output
> +	 */
> +	*IXP425_GPIO_GPCLKR = 0x01FF01FF;
> +	GPIO_OUTPUT_ENABLE(CFG_GPIO_PCI_CLK);
> +	GPIO_OUTPUT_ENABLE(CFG_GPIO_EXTBUS_CLK);
> +
> +	return 0;
> +}
> +
> +/*
> + * Check Board Identity
> + */
> +int checkboard(void)
> +{
> +	char *s = getenv("serial#");
> +
> +	puts("Board: NSLU2 - Linksys NSLU2");
> +
> +	if (s != NULL) {
> +		puts(", serial# ");
> +		puts(s);
> +	}
> +	putc('\n');
> +
> +	return (0);
please choose a style
return 0;
or
return (0);
> +}
> +
> +int dram_init (void)
> +{
> +	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
> +	gd->bd->bi_dram[0].size  = PHYS_SDRAM_1_SIZE;
> +
> +	return (0);
> +}
> +#define CONFIG_ENV_OVERWRITE	1	/* Allow changing of the MAC address */
> +
> +/*
> + * Default Environment
> + */
> +#define	CONFIG_EXTRA_ENV_SETTINGS					\
> +	"hostname=nslu2\0"						\
> +	"setncip=setenv autoload no;dhcp;setenv autoload;"		\
> +		"setenv ncip ${serverip}\0"				\
> +	"setnc=setenv stdin nc;setenv stdout nc;setenv stderr nc\0"	\
> +	"setser=setenv stdin serial;setenv stdout serial;"		\
> +		"setenv stderr serial\0"				\
> +	"bootfile=/tftpboot/nslu2/uImage\0"				\
> +	"rootpath=/tftpboot/nslu2/rootfs\0"				\
> +	"nfsargs=setenv bootargs root=/dev/nfs rw "			\
> +		"nfsroot=${serverip}:${rootpath}\0"			\
> +	"addip=setenv bootargs ${bootargs} "				\
> +		"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}"	\
> +		":${hostname}:eth0:off panic=1\0"			\
> +	"addtty=setenv bootargs ${bootargs} console=ttyS0,${baudrate}\0"\
> +	"net_nfs=tftp 10000 ${bootfile};run nfsargs addip addtty;"	\
> +		"bootm\0"						\
> +	""
> +
> +/*
> + * Configuration Settings
> + */
> +#define CFG_LONGHELP		1		/* undef to save memory		*/
> +#define CFG_PROMPT		"=> "	/* Monitor Command Prompt	*/
> +
> +#define CFG_CBSIZE		256		/* Console I/O Buffer Size	*/
> +#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
> +#define CFG_MAXARGS		16		/* max number of command args	*/
> +#define CFG_BARGSIZE		CFG_CBSIZE	/* Boot Argument Buffer Size	*/
> +
> +#define CFG_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200 }
> +
> +#define CFG_MEMTEST_START	0x00400000	/* memtest works on	*/
> +#define CFG_MEMTEST_END		0x00800000	/* 4 ... 8 MB in DRAM	*/
> +
> +#define CFG_LOAD_ADDR		0x00010000	/* default load address */
> +
> +#define CFG_MONITOR_BASE	CFG_FLASH_BASE
> +#define CFG_MONITOR_LEN		(256 << 10)	/* Reserve 256 kB for Monitor	*/
> +
> +#define CFG_MALLOC_LEN		(256 << 10)
> +
> +#define CFG_FLASH_BASE		0x50000000
> +
> +#define CFG_MAX_FLASH_BANKS	1	/* max number of memory banks		*/
> +#define CFG_MAX_FLASH_SECT	128	/* max number of sectors on one chip	*/
> +
> +#define CFG_FLASH_CFI		1	/* The flash is CFI compatible	*/
> +#define CFG_FLASH_CFI_DRIVER	1	/* Use common CFI driver	*/
> +
> +#define CFG_FLASH_CFI_WIDTH	FLASH_CFI_16BIT	/* no byte writes on IXP4xx	*/
> +
> +#define CFG_FLASH_EMPTY_INFO	1	/* print 'E' for empty sector on flinfo */
> +#define CFG_FLASH_USE_BUFFER_WRITE 1	/* use buffered writes (20x faster)	*/
> +
> +#define CFG_ENV_IS_IN_FLASH	1
> +#define CFG_ENV_OFFSET		0x40000	/* use the sysconfig partition */
> +#define CFG_ENV_SECT_SIZE	0x20000	/* size of one complete sector	*/
> +#define CFG_ENV_SIZE		0x2000	/* Total Size of Environment Sector	*/
> +
> +#define CFG_ETHADDR_OFFSET	0x3FFB0	/* Location of MAC address in flash */
> +#define CFG_SERCOMM_OFFSET	0x3FFF8	/* Location of " sErCoMm" signature */
> +
> +#define CFG_CACHELINE_SIZE	32
> +
> +#define CFG_HZ			33000000	/* NSLU2 has a 33.000 MHz crystal */
> +
> +#define CONFIG_STACKSIZE	(128*1024)	/* regular stack */
> +
> +#define CFG_GBL_DATA_SIZE	128	/* size in bytes reserved for initial data */
> +
> +/*
If possible add the HUSH support and the completion support.

Best Regards,
J.




More information about the U-Boot mailing list