#include <common.h>
#include <linux/byteorder/swab.h>
+#include <environment.h>
#define PHYS_FLASH_SECT_SIZE 0x00020000 /* 256 KB sectors (x2) */
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
CFG_ENV_ADDR + CFG_ENV_SIZE - 1,
&flash_info[0]);
+#ifdef CFG_ENV_ADDR_REDUND
+ flash_protect ( FLAG_PROTECT_SET,
+ CFG_ENV_ADDR_REDUND,
+ CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
+ &flash_info[0]);
+#endif
+
return size;
}
int usbtty_configured_flag = 0;
+/*
+ * Serial number
+ */
+static char serial_number[16];
+
/*
* Descriptors
*/
static u8 wstrLang[4] = {4,USB_DT_STRING,0x9,0x4};
static u8 wstrManufacturer[2 + 2*(sizeof(CONFIG_USBD_MANUFACTURER)-1)];
static u8 wstrProduct[2 + 2*(sizeof(CONFIG_USBD_PRODUCT_NAME)-1)];
-static u8 wstrSerial[2 + 2*(sizeof(CONFIG_USBD_SERIAL_NUMBER)-1)];
+static u8 wstrSerial[2 + 2*(sizeof(serial_number) - 1)];
static u8 wstrConfiguration[2 + 2*(sizeof(CONFIG_USBD_CONFIGURATION_STR)-1)];
static u8 wstrInterface[2 + 2*(sizeof(CONFIG_USBD_INTERFACE_STR)-1)];
int drv_usbtty_init (void)
{
int rc;
-
+ char * sn;
+ int snlen;
+
+ if (!(sn = getenv("serial#"))) {
+ sn = "000000000000";
+ }
+ snlen = strlen(sn);
+ if (snlen > sizeof(serial_number) - 1) {
+ printf ("Warning: serial number %s is too long (%d > %d)\n",
+ sn, snlen, sizeof(serial_number) - 1);
+ snlen = sizeof(serial_number) - 1;
+ }
+ memcpy (serial_number, sn, snlen);
+ serial_number[snlen] = '\0';
/* prepare buffers... */
buf_init (&usbtty_input, USBTTY_BUFFER_SIZE);
str2wide (CONFIG_USBD_PRODUCT_NAME, string->wData);
string = (struct usb_string_descriptor *) wstrSerial;
- string->bLength = sizeof (wstrSerial);
+ string->bLength = 2 + 2*strlen(serial_number);
string->bDescriptorType = USB_DT_STRING;
- str2wide (CONFIG_USBD_SERIAL_NUMBER, string->wData);
+ str2wide (serial_number, string->wData);
string = (struct usb_string_descriptor *) wstrConfiguration;
string->bLength = sizeof (wstrConfiguration);
bus_instance->endpoint_array = endpoint_instance;
bus_instance->max_endpoints = 1;
bus_instance->maxpacketsize = 64;
- bus_instance->serial_number_str = CONFIG_USBD_SERIAL_NUMBER;
+ bus_instance->serial_number_str = serial_number;
/* configuration instance */
memset (config_instance, 0,
#define CONFIG_USBD_PRODUCTID 0x5678
#define CONFIG_USBD_MANUFACTURER "Siemens"
#define CONFIG_USBD_PRODUCT_NAME "SX1"
-#define CONFIG_USBD_SERIAL_NUMBER "000000000001"
-
/*
* I2C configuration
#include <cmd_confdefs.h>
#include <configs/omap1510.h>
-#define CONFIG_BOOTDELAY 3
#define CONFIG_BOOTARGS "mem=16M console=ttyS0,115200n8 root=/dev/mtdblock3 rw"
+#define CONFIG_PREBOOT "setenv stdout usbtty;setenv stdin usbtty"
/*
* Miscellaneous configurable options
#define CFG_ENV_SIZE 0x20000 /* Total Size of Environment Sector */
#define CFG_ENV_OFFSET 0x20000 /* environment starts here */
+/* Address and size of Redundant Environment Sector */
+#define CFG_ENV_SIZE_REDUND 0x20000
+#define CFG_ENV_OFFSET_REDUND 0x40000
+
#endif /* __CONFIG_H */