Compare commits

...

14 Commits

Author SHA1 Message Date
Alexander Couzens 40032e1b0b replace old u-boot setlocalversion script with our git describe
version now includes our tag as well.
2015-07-19 21:49:02 +02:00
Alexander Couzens 451635eda3 configs/jb02v2: remove 'v2' from initramfs file
the jb02v2 must match the openwrt board name which doesn't contain a v2 and isn't
easy changable
2015-07-19 21:01:53 +02:00
Alexander Couzens d97d1ee1f2 correct recovery filenames to be in sync with openwrt builds
removed prefix -skw and -cb2 from jb names
2015-07-19 19:02:34 +02:00
Alexander Couzens a40eea5aa4 fix type which broke jb02v2-cb2 image
jb02v2-cb used the wrong config file.
2015-07-15 01:51:13 +02:00
Alexander Couzens aa579e90e9 configs: rename recovery image filename to be consistant
sed -i 's/-sysmo-/-sysmocom-/g'
2015-06-30 19:17:30 +02:00
Alexander Couzens 7923dcb950 correct recovery file names to match openwrt initramfs names 2015-06-03 21:57:16 +02:00
Alexander Couzens 2caf7c3d47 disable usb init stuff
usbboot is not used by us.
ar7240_usb_initial_config changes PLL value which could be
a problem.
2015-06-03 21:26:12 +02:00
Alexander Couzens 07469c59e3 detect flash chips by jedec ids instead of using hardcoded values 2015-06-02 11:38:54 +02:00
Alexander Couzens 37e46a66f3 fix indention
2 space indention was used. Using tabs
2015-05-20 14:24:19 +02:00
Alexander Couzens 832abd89bb ar7240/flash: make jedec id usable
It just read and printf() the value, but doesn't returned it
2015-05-20 14:12:02 +02:00
Alexander Couzens 6ae76c3541 dhcp: increase timeout counts to wait long enoguh for STP forward 2015-05-19 16:18:49 +02:00
Alexander Couzens 36f05d569d cmd_recovery: remove old unused argument force 2015-05-19 11:00:29 +02:00
Alexander Couzens e962169649 cmd_recovery: replace flashing with booting an initramfs image 2015-05-19 10:59:29 +02:00
Alexander Couzens 211d005623 jb02v3-skw: increase flash size to 16mb 2015-05-12 17:15:46 +02:00
16 changed files with 455 additions and 302 deletions

View File

@ -285,7 +285,7 @@ ap2_config: unconfig hornet_common_config
jb02v2-cb2_config: unconfig hornet_common_config jb02v2-cb2_config: unconfig hornet_common_config
@echo "#define CARABOOT_RELEASE \"$(CARABOOT_RELEASE)\"" >>include/config.h @echo "#define CARABOOT_RELEASE \"$(CARABOOT_RELEASE)\"" >>include/config.h
@./mkconfig -a jb02v3-skw mips mips carambola2 ar7240 ar7240 @./mkconfig -a jb02v2-cb2 mips mips carambola2 ar7240 ar7240
jb02v3-skw_config: unconfig hornet_common_config jb02v3-skw_config: unconfig hornet_common_config
@echo "#define CARABOOT_RELEASE \"$(CARABOOT_RELEASE)\"" >>include/config.h @echo "#define CARABOOT_RELEASE \"$(CARABOOT_RELEASE)\"" >>include/config.h

View File

@ -443,8 +443,8 @@ ar7240_mem_config(void)
debug("#### TAP VALUE 1 = %x, 2 = %x\n",tap_val1, tap_val2); debug("#### TAP VALUE 1 = %x, 2 = %x\n",tap_val1, tap_val2);
#endif #endif
ar7240_usb_initial_config(); //ar7240_usb_initial_config();
ar7240_usb_otp_config(); //ar7240_usb_otp_config();
//hornet_ddr_tap_init(); //hornet_ddr_tap_init();
return (ar7240_ddr_find_size()); return (ar7240_ddr_find_size());

View File

@ -2,27 +2,3 @@
#include <config.h> #include <config.h>
#include <asm/types.h> #include <asm/types.h>
#include <flash.h> #include <flash.h>
/*
* sets up flash_info and returns size of FLASH (bytes)
*/
unsigned long
flash_get_geom (flash_info_t *flash_info)
{
int i;
/* XXX this is hardcoded until we figure out how to read flash id */
flash_info->flash_id = FLASH_M25P64;
flash_info->size = CFG_FLASH_SIZE; /* bytes */
flash_info->sector_count = flash_info->size/CFG_FLASH_SECTOR_SIZE;
for (i = 0; i < flash_info->sector_count; i++) {
flash_info->start[i] = CFG_FLASH_BASE + (i * CFG_FLASH_SECTOR_SIZE);
flash_info->protect[i] = 0;
}
debug ("flash size %d, sector count = %d\n", flash_info->size, flash_info->sector_count);
return (flash_info->size);
}

View File

@ -14,6 +14,18 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
#undef display #undef display
#define display(x) ; #define display(x) ;
#define SIZE_INBYTES_4MBYTES (4 * 1024 * 1024)
#define SIZE_INBYTES_8MBYTES (2 * SIZE_INBYTES_4MBYTES)
#define SIZE_INBYTES_16MBYTES (2 * SIZE_INBYTES_8MBYTES)
#define SIZE_INBYTES_4KBYTES (4 * 1024)
#define SIZE_INBYTES_64KBYTES (16 * SIZE_INBYTES_4KBYTES)
#ifndef DEFAULT_FLASH_SIZE_IN_MB
#error "DEFAULT_FLASH_SIZE_IN_MB not defined!"
#endif
/* /*
* statics * statics
*/ */
@ -24,25 +36,34 @@ static void ar7240_spi_write_page(uint32_t addr, uint8_t * data, int len);
#endif #endif
static void ar7240_spi_sector_erase(uint32_t addr); static void ar7240_spi_sector_erase(uint32_t addr);
static void static ulong read_id(void)
ath_spi_read_id(void)
{ {
u32 rd = 0x777777; unsigned int flashid = 0;
ar7240_reg_wr_nf(AR7240_SPI_FS, 1);
ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_DIS); ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_DIS);
ar7240_spi_bit_banger(AR7240_SPI_CMD_RDID);
ar7240_spi_delay_8();
ar7240_spi_delay_8();
ar7240_spi_delay_8();
ar7240_spi_go();
rd = ar7240_reg_rd(AR7240_SPI_RD_STATUS); ar7240_spi_bit_banger(0x9F);
debug("Flash Manuf Id 0x%x, DeviceId0 0x%x, DeviceId1 0x%x\n", ar7240_spi_delay_8();
(rd >> 16) & 0xff, (rd >> 8) & 0xff, (rd >> 0) & 0xff); ar7240_spi_delay_8();
ar7240_spi_delay_8();
ar7240_spi_delay_8();
flashid = ar7240_reg_rd(AR7240_SPI_RD_STATUS);
/*
* We have 3 bytes:
* - manufacture ID (1b)
* - product ID (2b)
*/
flashid = flashid >> 8;
ar7240_spi_done();
return((ulong)flashid);
} }
#ifdef ATH_SST_FLASH #ifdef ATH_SST_FLASH
void ar7240_spi_flash_unblock(void) void ar7240_spi_flash_unblock(void)
{ {
@ -54,25 +75,157 @@ void ar7240_spi_flash_unblock(void)
} }
#endif #endif
static void flash_set_geom(int size, int sector_count, int sector_size){
int i;
flash_info_t *info = &flash_info[0];
info->size = size;
info->sector_count = sector_count;
info->sector_size = sector_size;
for(i = 0; i < info->sector_count; i++){
info->start[i] = CFG_FLASH_BASE + (i * info->sector_size);
}
}
unsigned long flash_init(void) unsigned long flash_init(void)
{ {
#ifndef CONFIG_WASP flash_info_t *info;
#ifdef ATH_SST_FLASH
ar7240_reg_wr_nf(AR7240_SPI_CLOCK, 0x3);
ar7240_spi_flash_unblock();
ar7240_reg_wr(AR7240_SPI_FS, 0);
#else
ar7240_reg_wr_nf(AR7240_SPI_CLOCK, 0x43);
#endif
#endif
ar7240_reg_rmw_set(AR7240_SPI_FS, 1);
ath_spi_read_id();
ar7240_reg_rmw_clear(AR7240_SPI_FS, 1);
/* info = &flash_info[0];
* hook into board specific code to fill flash_info
*/ // spi flash clock
return (flash_get_geom(&flash_info[0])); ar7240_reg_wr(AR7240_SPI_FS, 0x01);
ar7240_reg_wr(AR7240_SPI_CLOCK, 0x43);
ar7240_reg_wr(AR7240_SPI_FS, 0x0);
// get flash id
info->flash_id = read_id();
puts("FLASH: ");
// fill flash info based on JEDEC ID
switch(info->flash_id) {
/*
* 4M flash chips
*/
case 0x010215: // tested
flash_set_geom(SIZE_INBYTES_4MBYTES, 64, SIZE_INBYTES_64KBYTES);
puts("Spansion S25FL032P (4 MB)");
break;
case 0x1F4700:
flash_set_geom(SIZE_INBYTES_4MBYTES, 64, SIZE_INBYTES_64KBYTES);
puts("Atmel AT25DF321 (4 MB)");
break;
case 0x1C3016: // tested
flash_set_geom(SIZE_INBYTES_4MBYTES, 64, SIZE_INBYTES_64KBYTES);
puts("EON EN25Q32 (4 MB)");
break;
case 0x1C3116: // tested
flash_set_geom(SIZE_INBYTES_4MBYTES, 64, SIZE_INBYTES_64KBYTES);
puts("EON EN25F32 (4 MB)");
break;
case 0x202016:
flash_set_geom(SIZE_INBYTES_4MBYTES, 64, SIZE_INBYTES_64KBYTES);
puts("Micron M25P32 (4 MB)");
break;
case 0xEF4016:
flash_set_geom(SIZE_INBYTES_4MBYTES, 64, SIZE_INBYTES_64KBYTES);
puts("Winbond W25Q32 (4 MB)");
break;
case 0xC22016:
flash_set_geom(SIZE_INBYTES_4MBYTES, 64, SIZE_INBYTES_64KBYTES);
puts("Macronix MX25L320 (4 MB)");
break;
/*
* 8M flash chips
*/
case 0x010216:
flash_set_geom(SIZE_INBYTES_8MBYTES, 128, SIZE_INBYTES_64KBYTES);
puts("Spansion S25FL064P (8 MB)");
break;
case 0x1F4800:
flash_set_geom(SIZE_INBYTES_8MBYTES, 128, SIZE_INBYTES_64KBYTES);
puts("Atmel AT25DF641 (8 MB)");
break;
case 0x1C3017: // tested
flash_set_geom(SIZE_INBYTES_8MBYTES, 128, SIZE_INBYTES_64KBYTES);
puts("EON EN25Q64 (8 MB)");
break;
case 0x202017:
flash_set_geom(SIZE_INBYTES_8MBYTES, 128, SIZE_INBYTES_64KBYTES);
puts("Micron M25P64 (8 MB)");
break;
case 0xEF4017: // tested
flash_set_geom(SIZE_INBYTES_8MBYTES, 128, SIZE_INBYTES_64KBYTES);
puts("Winbond W25Q64 (8 MB)");
break;
case 0xC22017: // tested
case 0xC22617:
flash_set_geom(SIZE_INBYTES_8MBYTES, 128, SIZE_INBYTES_64KBYTES);
puts("Macronix MX25L64 (8 MB)");
break;
/*
* 16M flash chips
*/
case 0xEF4018: // tested
flash_set_geom(SIZE_INBYTES_16MBYTES, 256, SIZE_INBYTES_64KBYTES);
puts("Winbond W25Q128 (16 MB)");
break;
case 0xC22018:
case 0xC22618:
flash_set_geom(SIZE_INBYTES_16MBYTES, 256, SIZE_INBYTES_64KBYTES);
puts("Macronix MX25L128 (16 MB)");
break;
case 0x012018:
flash_set_geom(SIZE_INBYTES_16MBYTES, 256, SIZE_INBYTES_64KBYTES);
puts("Spansion S25FL127S (16 MB)");
break;
case 0x20BA18:
flash_set_geom(SIZE_INBYTES_16MBYTES, 256, SIZE_INBYTES_64KBYTES);
puts("Micron N25Q128 (16 MB)");
break;
/*
* Unknown flash
*/
default:
#if (DEFAULT_FLASH_SIZE_IN_MB == 4)
flash_set_geom(SIZE_INBYTES_4MBYTES, 64, SIZE_INBYTES_64KBYTES);
puts("Unknown type (using only 4 MB)\n");
#elif (DEFAULT_FLASH_SIZE_IN_MB == 8)
flash_set_geom(SIZE_INBYTES_8MBYTES, 128, SIZE_INBYTES_64KBYTES);
puts("Unknown type (using only 8 MB)\n");
#elif (DEFAULT_FLASH_SIZE_IN_MB == 16)
flash_set_geom(SIZE_INBYTES_16MBYTES, 256, SIZE_INBYTES_64KBYTES);
puts("Unknown type (using only 16 MB)\n");
#endif
printf("\nPlease, send request to add support\nfor your FLASH - JEDEC ID: 0x%06lX\n", info->flash_id);
info->flash_id = FLASH_CUSTOM;
break;
}
puts("\n");
return(info->size);
} }
void void
@ -102,7 +255,7 @@ flash_erase(flash_info_t *info, int s_first, int s_last)
show_activity(3); show_activity(3);
#endif #endif
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
WATCHDOG_RESET(); WATCHDOG_RESET();
#endif #endif
#endif #endif

View File

@ -59,6 +59,6 @@
#define ar7240_spi_delay_8() ar7240_spi_bit_banger(0) #define ar7240_spi_delay_8() ar7240_spi_bit_banger(0)
#define ar7240_spi_done() ar7240_reg_wr_nf(AR7240_SPI_FS, 0) #define ar7240_spi_done() ar7240_reg_wr_nf(AR7240_SPI_FS, 0)
extern unsigned long flash_get_geom (flash_info_t *flash_info); extern unsigned long flash_get_geom (flash_info_t *flash_info, u32 flashid);
#endif /*_FLASH_H*/ #endif /*_FLASH_H*/

View File

@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2012, 2013 sysmocom s.f.m.c. GmbH * Copyright (C) 2012, 2013 sysmocom s.f.m.c. GmbH
* Author: Holger Hans Peter Freyther * Author: Holger Hans Peter Freyther
* Author: Alexander Couzens <lynxis@fe80.eu>
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -57,9 +58,9 @@ static int tftp_failed(void)
return -1; return -1;
} }
static int flash_failed(void) static int booting_failed(void)
{ {
printf("Flash failed.\n"); printf("Booting failed.\n");
BLINK_LED(15); BLINK_LED(15);
enable_netconsole(); enable_netconsole();
return -1; return -1;
@ -82,11 +83,6 @@ static int do_run_recovery(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
//status_led_set(0, STATUS_LED_ON); //status_led_set(0, STATUS_LED_ON);
printf("Starting the recovery process.\n"); printf("Starting the recovery process.\n");
/* Wait a bit and check if the reset button is still pressed */
if (argc == 2 && strcmp(argv[1], "force") == 0) {
printf("Forcing the recovery process.\n");
}
BLINK_LED(5); BLINK_LED(5);
//status_led_set(0, STATUS_LED_ON); //status_led_set(0, STATUS_LED_ON);
@ -110,16 +106,15 @@ static int do_run_recovery(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (rc < 0) if (rc < 0)
return tftp_failed(); return tftp_failed();
rc = run_command("erase 0x9f050000 +0x7a0000; " rc = run_command("bootm 0x81000000", 0);
"cp.b 0x81000000 0x9f050000 0x7a0000", 0);
if (rc < 0) if (rc < 0)
return flash_failed(); return booting_failed();
return run_command("resetcycle; reset", 0); return run_command("resetcycle; reset", 0);
} }
U_BOOT_CMD( U_BOOT_CMD(
run_recovery, 2, 0, do_run_recovery, run_recovery, 2, 0, do_run_recovery,
"run_recovery - Run the sysmocom sysmoBTS recovery process", "run_recovery - tftp boot a given image",
"[force]" ""
); );

View File

@ -22,7 +22,10 @@
*/ */
#include <common.h> #include <common.h>
#include <ar7240_soc.h>
#include <asm/addrspace.h>
#include <command.h> #include <command.h>
#include <malloc.h>
#ifdef CFG_CMD_SETMAC #ifdef CFG_CMD_SETMAC
@ -34,9 +37,9 @@
extern flash_info_t flash_info[]; /* info for FLASH chips */ extern flash_info_t flash_info[]; /* info for FLASH chips */
static int mac_location[] = { static int mac_location[] = {
0x0, /* eth0 */ 0x0, /* eth0 */
0x6, /* eth1 */ 0x6, /* eth1 */
0x1002, /* wlan0 */ 0x1002, /* wlan0 */
}; };
typedef unsigned char bool; typedef unsigned char bool;
@ -45,282 +48,327 @@ typedef unsigned char bool;
/* from xyzmodem.c */ /* from xyzmodem.c */
// Validate a hex character // Validate a hex character
__inline__ static bool __inline__ static bool
_is_hex(char c) _is_hex(char c)
{ {
return (((c >= '0') && (c <= '9')) || return (((c >= '0') && (c <= '9')) ||
((c >= 'A') && (c <= 'F')) || ((c >= 'A') && (c <= 'F')) ||
((c >= 'a') && (c <= 'f'))); ((c >= 'a') && (c <= 'f')));
} }
/* from xyzmodem.c */ /* from xyzmodem.c */
// Convert a single hex nibble // Convert a single hex nibble
__inline__ static u8 __inline__ static u8
_from_hex(char c) _from_hex(char c)
{ {
u8 ret = 0; u8 ret = 0;
if ((c >= '0') && (c <= '9')) { if ((c >= '0') && (c <= '9')) {
ret = (c - '0'); ret = (c - '0');
} else if ((c >= 'a') && (c <= 'f')) { } else if ((c >= 'a') && (c <= 'f')) {
ret = (c - 'a' + 0x0a); ret = (c - 'a' + 0x0a);
} else if ((c >= 'A') && (c <= 'F')) { } else if ((c >= 'A') && (c <= 'F')) {
ret = (c - 'A' + 0x0A); ret = (c - 'A' + 0x0A);
} }
return ret; return ret;
} }
static int is_valid_mac_str(char *mac) static int is_valid_mac_str(char *mac)
{ {
/* mac must look like "00:11:22:33:44:55" */ /* mac must look like "00:11:22:33:44:55" */
int i; int i;
if (strlen(mac) < 17) if (strlen(mac) < 17)
return 0; return 0;
for (i=0; i <=15 ; i+=3) { for (i=0; i <=15 ; i+=3) {
if (!_is_hex(mac[i]) || !_is_hex(mac[i+1])) if (!_is_hex(mac[i]) || !_is_hex(mac[i+1]))
return 0; return 0;
/* check for colons - last group doesn't end with a colon*/
if (i != 15 && mac[i+2] != ':')
return 0;
}
return 1; /* check for colons - last group doesn't end with a colon*/
if (i != 15 && mac[i+2] != ':')
return 0;
}
return 1;
} }
static int parse_mac(u8 *dst, char *mac_str) { static int parse_mac(u8 *dst, char *mac_str) {
int i; int i;
int j; int j;
if (!is_valid_mac_str(mac_str)) if (!is_valid_mac_str(mac_str))
return 1; return 1;
/* j = dst offset /* j = dst offset
* i = mac_str offset * i = mac_str offset
*/ */
for (i=0, j=0; i<= 15; i+=3, j++) { for (i=0, j=0; i<= 15; i+=3, j++) {
dst[j] = _from_hex(mac_str[i]) << 4 | _from_hex(mac_str[i + 1]); dst[j] = _from_hex(mac_str[i]) << 4 | _from_hex(mac_str[i + 1]);
} }
return 0; return 0;
} }
/* copy calibration sector to the sector before calibration */ /* copy calibration sector to the sector before calibration */
static int backup_calibration(u8 *buffer) static int backup_calibration(u8 *buffer)
{ {
int rc = -1; int rc = -1;
/* read */ ulong sector_size = flash_info[0].sector_size;
memcpy(buffer, (void *)BOARDCAL, CFG_FLASH_SECTOR_SIZE); ushort cal_sector = flash_info[0].sector_count -1;
u8 *board_cal = (u8 *) (KSEG1ADDR(AR7240_SPI_BASE) + cal_sector * flash_info[0].sector_size);
/* erase */ /* read */
rc = flash_erase(flash_info, CAL_SECTOR-1, CAL_SECTOR-1); memcpy(buffer, (void *)board_cal, sector_size);
if (rc) {
printf("Backup failed because flash erase failed! rc %d\n", rc);
return 1;
}
/* cp */ /* erase */
rc = write_buff(flash_info, buffer, BOARDCAL-CFG_FLASH_SECTOR_SIZE, CFG_FLASH_SECTOR_SIZE); rc = flash_erase(flash_info, cal_sector-1, cal_sector-1);
if (rc) { if (rc) {
printf("Backup failed because write to flash failed! rc %d\n", rc); printf("Backup failed because flash erase failed! rc %d\n", rc);
return 1; return 1;
} }
/* compare */ /* writing into flash - we use the mapped flash as source */
if (memcmp(buffer, (void *)BOARDCAL-CFG_FLASH_SECTOR_SIZE, CFG_FLASH_SECTOR_SIZE)) { rc = write_buff(flash_info, buffer, board_cal - sector_size, sector_size);
printf("Backup failed. Read back different value!\n"); if (rc) {
return 1; printf("Backup failed because write to flash failed! rc %d\n", rc);
} return 1;
}
return 0; /* compare */
if (memcmp(buffer, (void *)board_cal - sector_size, sector_size)) {
printf("Backup failed. Read back different value!\n");
return 1;
}
return 0;
} }
int write_mac(u8 *buffer, u8 macs[ARRAY_SIZE(mac_location)][ETH_ALEN]) int write_mac(u8 *buffer, u8 macs[ARRAY_SIZE(mac_location)][ETH_ALEN])
{ {
int i; int i;
int rc; int rc;
/* read */ ulong sector_size = flash_info[0].sector_size;
memcpy(buffer, (void *)BOARDCAL, CFG_FLASH_SECTOR_SIZE); ushort cal_sector = flash_info[0].sector_count -1;
u8 *board_cal = (u8 *) (KSEG1ADDR(AR7240_SPI_BASE) + cal_sector * flash_info[0].sector_size);
/* set macs */ /* read */
for(i=0; i<ARRAY_SIZE(mac_location); i++) { memcpy(buffer, (void *)board_cal, sector_size);
memcpy(buffer + mac_location[i], macs[i], ETH_ALEN);
}
/* erase */ /* set macs */
rc = flash_erase(flash_info, CAL_SECTOR, CAL_SECTOR); for(i=0; i<ARRAY_SIZE(mac_location); i++) {
if (rc) { memcpy(buffer + mac_location[i], macs[i], ETH_ALEN);
printf("Write mac failed because flash_erase failed! rc %d\n", rc); }
return 1;
}
/* write */ /* erase */
rc = write_buff(flash_info, buffer, BOARDCAL, CFG_FLASH_SECTOR_SIZE); rc = flash_erase(flash_info, cal_sector, cal_sector);
if (rc) { if (rc) {
printf("Write mac failed because write_buff failed! rc %d\n", rc); printf("Write mac failed because flash_erase failed! rc %d\n", rc);
return 1; return 1;
} }
return 0; /* write */
rc = write_buff(flash_info, buffer, board_cal, sector_size);
if (rc) {
printf("Write mac failed because write_buff failed! rc %d\n", rc);
return 1;
}
return 0;
} }
int do_setmac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_setmac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{ {
u8 buffer[CFG_FLASH_SECTOR_SIZE]; ulong sector_size = flash_info[0].sector_size;
u8 macs[ARRAY_SIZE(mac_location)][ETH_ALEN]; ushort cal_sector = flash_info[0].sector_count -1;
int i;
bool do_backup = true;
/* valid arguments are: u8 *buffer;
* set_mac <mac0> <mac1> [..] or set_mac <mac0> <mac1> [..] nobackup u8 macs[ARRAY_SIZE(mac_location)][ETH_ALEN];
* check if enough arguments given int i;
*/ bool do_backup = true;
if (argc != (ARRAY_SIZE(mac_location)+1) && int rc;
argc != (ARRAY_SIZE(mac_location)+2))
return CMD_RET_FAILURE;
/* check if nobackup was given */ /* valid arguments are:
if (argc == (ARRAY_SIZE(mac_location)+2)) { * set_mac <mac0> <mac1> [..] or set_mac <mac0> <mac1> [..] nobackup
if(!strncmp("nobackup", argv[argc-1], 8)) { * check if enough arguments given
do_backup = false; */
} else { if (argc != (ARRAY_SIZE(mac_location)+1) &&
printf("Unknown argument %s!\n", argv[argc-1]); argc != (ARRAY_SIZE(mac_location)+2))
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
}
}
/* all other arguments are mac address */ /* check if nobackup was given */
for (i=0; i < ARRAY_SIZE(mac_location); i++) { if (argc == (ARRAY_SIZE(mac_location)+2)) {
if (!is_valid_mac_str(argv[i+1])) { if(!strncmp("nobackup", argv[argc-1], 8)) {
printf("Invalid MAC address %s!\n", argv[i+1]); do_backup = false;
return CMD_RET_FAILURE; } else {
} printf("Unknown argument %s!\n", argv[argc-1]);
} return CMD_RET_FAILURE;
}
}
/* parse macs and copy into macs */ /* all other arguments are mac address */
for (i=0; i < ARRAY_SIZE(mac_location); i++) { for (i=0; i < ARRAY_SIZE(mac_location); i++) {
if (parse_mac(macs[i], argv[i+1])) { if (!is_valid_mac_str(argv[i+1])) {
printf("Can not parse mac %s!\n", argv[i+1]); printf("Invalid MAC address %s!\n", argv[i+1]);
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }
} }
if (do_backup) { /* parse macs and copy into macs */
if (backup_calibration(buffer)) { for (i=0; i < ARRAY_SIZE(mac_location); i++) {
printf("Backup failed to the sector before calibration. Not updating calibration sector!"); if (parse_mac(macs[i], argv[i+1])) {
return CMD_RET_FAILURE; printf("Can not parse mac %s!\n", argv[i+1]);
} return CMD_RET_FAILURE;
} }
}
if (!write_mac(buffer, macs)) { buffer = malloc(sector_size);
return CMD_RET_FAILURE; if (!buffer) {
} printf("Could not allocate memory");
return CMD_RET_FAILURE;
}
return CMD_RET_SUCCESS; if (do_backup) {
if (backup_calibration(buffer)) {
printf("Backup failed to the sector before calibration.\n"
"Not updating calibration sector!\n");
rc = CMD_RET_FAILURE;
goto out;
}
}
if (!write_mac(buffer, macs)) {
rc = CMD_RET_FAILURE;
goto out;
}
rc = CMD_RET_SUCCESS;
out:
free(buffer);
return rc;
} }
int do_showmac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_showmac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{ {
int i = 0; int i = 0;
u8 buffer[CFG_FLASH_SECTOR_SIZE]; u8 *buffer;
u8 *mac; u8 *mac;
memcpy(buffer, (void *)BOARDCAL, CFG_FLASH_SECTOR_SIZE); ushort cal_sector = flash_info[0].sector_count -1;
u8 *board_cal = (u8 *) (KSEG1ADDR(AR7240_SPI_BASE) + cal_sector * flash_info[0].sector_size);
for (i=0; i < ARRAY_SIZE(mac_location); i++) { /* using mapped spi memory */
mac = buffer + mac_location[i]; buffer = (void *)board_cal;
printf("mac %d = %02x:%02x:%02x:%02x:%02x:%02x\n", i,
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
return CMD_RET_SUCCESS; for (i=0; i < ARRAY_SIZE(mac_location); i++) {
mac = buffer + mac_location[i];
printf("mac %d = %02x:%02x:%02x:%02x:%02x:%02x\n", i,
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
return CMD_RET_SUCCESS;
} }
int do_setserial(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_setserial(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{ {
u8 buffer[CFG_FLASH_SECTOR_SIZE]; u8 *buffer;
int32_t *serial; int32_t *serial;
int32_t serial_number; int32_t serial_number;
int rc; int rc;
ulong sector_size = flash_info[0].sector_size;
ushort cal_sector = flash_info[0].sector_count -1;
u8 *board_cal = KSEG1ADDR(AR7240_SPI_BASE) + cal_sector * flash_info[0].sector_size;
if (argc != 2) if (argc != 2)
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
serial_number = simple_strtoul(argv[1], NULL, 16); serial_number = simple_strtoul(argv[1], NULL, 16);
if (serial_number <= 0) { if (serial_number <= 0) {
printf("Invalid serialnumber. <= 0!\n"); printf("Invalid serialnumber. <= 0!\n");
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }
/* read */ buffer = malloc(sector_size);
memcpy(buffer, (void *)BOARDCAL, CFG_FLASH_SECTOR_SIZE); if (!buffer) {
printf("Could not allocate memory");
return CMD_RET_FAILURE;
}
/* set serial number */ /* read */
serial = (int32_t *) (buffer + SERIAL_LOCATION); memcpy(buffer, (void *)board_cal, sector_size);
*serial = serial_number;
/* erase */ /* set serial number */
rc = flash_erase(flash_info, CAL_SECTOR, CAL_SECTOR); serial = (int32_t *) (buffer + SERIAL_LOCATION);
if (rc) { *serial = serial_number;
printf("Write serial failed because flash_erase failed! rc %d\n", rc);
return 1;
}
/* write */ /* erase */
rc = write_buff(flash_info, buffer, BOARDCAL, CFG_FLASH_SECTOR_SIZE); rc = flash_erase(flash_info, cal_sector, cal_sector);
if (rc) { if (rc) {
printf("Write serial failed because write_buff failed! rc %d\n", rc); printf("Write serial failed because flash_erase failed! rc %d\n", rc);
return 1; rc = CMD_RET_SUCCESS;
} goto out;
}
printf("Set serial to %d\n", serial_number); /* write */
rc = write_buff(flash_info, buffer, board_cal, sector_size);
if (rc) {
printf("Write serial failed because write_buff failed! rc %d\n", rc);
rc = CMD_RET_FAILURE;
goto out;
}
return CMD_RET_SUCCESS; printf("Set serial to %d\n", serial_number);
rc = CMD_RET_SUCCESS;
out:
free(buffer);
return rc;
} }
int do_showserial(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_showserial(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{ {
u8 buffer[CFG_FLASH_SECTOR_SIZE]; ulong sector_size = flash_info[0].sector_size;
int32_t *serial; ushort cal_sector = flash_info[0].sector_count -1;
memcpy(buffer, (void *)BOARDCAL, CFG_FLASH_SECTOR_SIZE); u8 *board_cal = KSEG1ADDR(AR7240_SPI_BASE) + cal_sector * flash_info[0].sector_size;
u8 *buffer = board_cal;
serial = (int32_t *) (buffer + SERIAL_LOCATION); int32_t *serial;
printf("serial %d\n", *serial);
return CMD_RET_SUCCESS; serial = (int32_t *) (buffer + SERIAL_LOCATION);
printf("serial %d\n", *serial);
return CMD_RET_SUCCESS;
} }
U_BOOT_CMD( U_BOOT_CMD(
setmac, ARRAY_SIZE(mac_location)+2, 0, do_setmac, setmac, ARRAY_SIZE(mac_location)+2, 0, do_setmac,
"setmac - Set ethernet MAC addresses\n", "setmac - Set ethernet MAC addresses\n",
"setmac [<eth0> <eth1> <wlan0> [nobackup]]\n" "setmac [<eth0> <eth1> <wlan0> [nobackup]]\n"
" without arguments it shows actual configuration\n" " without arguments it shows actual configuration\n"
" <eth0> mac address\n" " <eth0> mac address\n"
" <eth1> mac address\n" " <eth1> mac address\n"
" <wlan0> mac address\n" " <wlan0> mac address\n"
" mac address 00:aa:bb:cc:dd:ee\n" " mac address 00:aa:bb:cc:dd:ee\n"
" nobackup - don't do a backup in the sector before calibration" " nobackup - don't do a backup in the sector before calibration"
); );
U_BOOT_CMD( U_BOOT_CMD(
showmac, 1, 0, do_showmac, showmac, 1, 0, do_showmac,
"showmac - Show ethernet MAC addresses\n", "showmac - Show ethernet MAC addresses\n",
); );
U_BOOT_CMD( U_BOOT_CMD(
setserial, 2, 0, do_setserial, setserial, 2, 0, do_setserial,
"setserial - Set the serial number\n", "setserial - Set the serial number\n",
"setserial serial\n" "setserial serial\n"
); );
U_BOOT_CMD( U_BOOT_CMD(
showserial, 1, 0, do_showserial, showserial, 1, 0, do_showserial,
"showserial - Show serial number\n", "showserial - Show serial number\n",
); );
#endif /* CFG_CMD_SETMAC */ #endif /* CFG_CMD_SETMAC */

View File

@ -21,11 +21,8 @@
* FLASH and environment organization * FLASH and environment organization
*----------------------------------------------------------------------- *-----------------------------------------------------------------------
*/ */
#define CFG_MAX_FLASH_BANKS 1 #define DEFAULT_FLASH_SIZE_IN_MB 16
#define CFG_MAX_FLASH_SECT 256
#define CFG_FLASH_SECTOR_SIZE (64*1024)
#define CFG_FLASH_SIZE 0x01000000
#define BOARDCAL 0x9fff0000 #define BOARDCAL 0x9fff0000
@ -48,7 +45,7 @@
#define CONFIG_SERVERIP 192.168.2.254 #define CONFIG_SERVERIP 192.168.2.254
#define CFG_FAULT_ECHO_LINK_DOWN 1 #define CFG_FAULT_ECHO_LINK_DOWN 1
#define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmo-sob-ap1-squashfs-sysupgrade.bin" #define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmocom-sob-ap1-initramfs-uImage.bin"
#define CFG_PHY_ADDR 0 #define CFG_PHY_ADDR 0

View File

@ -22,10 +22,7 @@
*----------------------------------------------------------------------- *-----------------------------------------------------------------------
*/ */
#define CFG_MAX_FLASH_BANKS 1 #define DEFAULT_FLASH_SIZE_IN_MB 16
#define CFG_MAX_FLASH_SECT 128
#define CFG_FLASH_SECTOR_SIZE (64*1024)
#define CFG_FLASH_SIZE 0x00800000
#define BOARDCAL 0x9f7f0000 #define BOARDCAL 0x9f7f0000
@ -47,7 +44,7 @@
#define CONFIG_SERVERIP 192.168.2.254 #define CONFIG_SERVERIP 192.168.2.254
#define CFG_FAULT_ECHO_LINK_DOWN 1 #define CFG_FAULT_ECHO_LINK_DOWN 1
#define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmo-sob-ap2-squashfs-sysupgrade.bin" #define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmocom-sob-ap2-initramfs-uImage.bin"
#define CFG_PHY_ADDR 0 #define CFG_PHY_ADDR 0

View File

@ -22,10 +22,7 @@
*----------------------------------------------------------------------- *-----------------------------------------------------------------------
*/ */
#define CFG_MAX_FLASH_BANKS 1 #define DEFAULT_FLASH_SIZE_IN_MB 16
#define CFG_MAX_FLASH_SECT 256
#define CFG_FLASH_SECTOR_SIZE (64*1024)
#define CFG_FLASH_SIZE 0x01000000
#define BOARDCAL 0x9fff0000 #define BOARDCAL 0x9fff0000
@ -48,7 +45,7 @@
#define CONFIG_SERVERIP 192.168.2.254 #define CONFIG_SERVERIP 192.168.2.254
#define CFG_FAULT_ECHO_LINK_DOWN 1 #define CFG_FAULT_ECHO_LINK_DOWN 1
#define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-carambola2-squashfs-sysupgrade.bin" #define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-carambola2-initramfs-uImage.bin"
#define CFG_PHY_ADDR 0 #define CFG_PHY_ADDR 0

View File

@ -5,6 +5,9 @@
* We boot from this flash * We boot from this flash
*/ */
#define CFG_FLASH_BASE 0x9f000000 #define CFG_FLASH_BASE 0x9f000000
#define CFG_MAX_FLASH_SECT 4096
#define CFG_MAX_FLASH_BANKS 1
#define CFG_MAX_FLASH_SECT 256
#define CFG_CMD_SETMAC #define CFG_CMD_SETMAC

View File

@ -21,11 +21,8 @@
* FLASH and environment organization * FLASH and environment organization
*----------------------------------------------------------------------- *-----------------------------------------------------------------------
*/ */
#define CFG_MAX_FLASH_BANKS 1 #define DEFAULT_FLASH_SIZE_IN_MB 16
#define CFG_MAX_FLASH_SECT 256
#define CFG_FLASH_SECTOR_SIZE (64*1024)
#define CFG_FLASH_SIZE 0x01000000
#define BOARDCAL 0x9fff0000 #define BOARDCAL 0x9fff0000
@ -48,7 +45,7 @@
#define CONFIG_SERVERIP 192.168.2.254 #define CONFIG_SERVERIP 192.168.2.254
#define CFG_FAULT_ECHO_LINK_DOWN 1 #define CFG_FAULT_ECHO_LINK_DOWN 1
#define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmo-sob-jb02v2-cb2-squashfs-sysupgrade.bin" #define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmocom-sob-jb02-initramfs-uImage.bin"
#define CFG_PHY_ADDR 0 #define CFG_PHY_ADDR 0

View File

@ -22,12 +22,9 @@
*----------------------------------------------------------------------- *-----------------------------------------------------------------------
*/ */
#define CFG_MAX_FLASH_BANKS 1 #define DEFAULT_FLASH_SIZE_IN_MB 16
#define CFG_MAX_FLASH_SECT 128
#define CFG_FLASH_SECTOR_SIZE (64*1024)
#define CFG_FLASH_SIZE 0x00800000
#define BOARDCAL 0x9f7f0000 #define BOARDCAL 0x9fff0000
#if (CFG_MAX_FLASH_SECT * CFG_FLASH_SECTOR_SIZE) != CFG_FLASH_SIZE #if (CFG_MAX_FLASH_SECT * CFG_FLASH_SECTOR_SIZE) != CFG_FLASH_SIZE
# error "Invalid flash configuration" # error "Invalid flash configuration"
@ -47,7 +44,7 @@
#define CONFIG_SERVERIP 192.168.2.254 #define CONFIG_SERVERIP 192.168.2.254
#define CFG_FAULT_ECHO_LINK_DOWN 1 #define CFG_FAULT_ECHO_LINK_DOWN 1
#define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmo-sob-jb02v3-skw-squashfs-sysupgrade.bin" #define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmocom-sob-jb02v3-initramfs-uImage.bin"
#define CFG_PHY_ADDR 0 #define CFG_PHY_ADDR 0

View File

@ -31,6 +31,7 @@
typedef struct { typedef struct {
ulong size; /* total bank size in bytes */ ulong size; /* total bank size in bytes */
ulong sector_size; /* size of erase unit in bytes */
ushort sector_count; /* number of erase units */ ushort sector_count; /* number of erase units */
ulong flash_id; /* combined device & manufacturer code */ ulong flash_id; /* combined device & manufacturer code */
ulong start[CFG_MAX_FLASH_SECT]; /* physical sector start addresses */ ulong start[CFG_MAX_FLASH_SECT]; /* physical sector start addresses */
@ -418,6 +419,7 @@ extern void flash_read_factory_serial(flash_info_t * info, void * buffer, int of
#define FLASH_M25P64 0x00F2 #define FLASH_M25P64 0x00F2
#define FLASH_CUSTOM 0x1111
#define FLASH_UNKNOWN 0xFFFF /* unknown flash type */ #define FLASH_UNKNOWN 0xFFFF /* unknown flash type */

View File

@ -35,7 +35,7 @@
#define TIMEOUT 5 /* Seconds before trying BOOTP again */ #define TIMEOUT 5 /* Seconds before trying BOOTP again */
#ifndef CONFIG_NET_RETRY_COUNT #ifndef CONFIG_NET_RETRY_COUNT
# define TIMEOUT_COUNT 5 /* # of timeouts before giving up */ # define TIMEOUT_COUNT 31 /* # of timeouts before giving up */
#else #else
# define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT) # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
#endif #endif

View File

@ -8,15 +8,6 @@ usage() {
cd "${1:-.}" || usage cd "${1:-.}" || usage
# Check for git and a git repo. if version=$(git describe --dirty --always --match="ar9331-v*" 2>/dev/null) ; then
if head=`git rev-parse --verify HEAD 2>/dev/null`; then echo "-$version"
# Do we have an untagged version?
if [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then
printf '%s%s' -g `echo "$head" | cut -c1-8`
fi
# Are there uncommitted changes?
if git diff-files | read dummy; then
printf '%s' -dirty
fi
fi fi