Compare commits

...

34 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
Alexander Couzens 35dabe9f00 add missing configuration file for jb02v3-skw based on ap2 2015-05-12 16:11:51 +02:00
Alexander Couzens 4de88f22b4 add support for jb02v3-skw based on ap2 2015-05-12 16:10:06 +02:00
Alexander Couzens 92b0391332 rename jb02 into jb02v2-cb2 2015-05-12 16:09:47 +02:00
Alexander Couzens 7ea899a6d8 Revert "cmd_recovery: seperate multicommand lines by "&&"."
This reverts commit a418c264b2.
run_command() doesn't understand &&.
2015-04-06 19:40:52 +02:00
Alexander Couzens b5cd30559c cmd_setmac/showserial: use value not the pointer as output 2015-04-06 18:52:39 +02:00
Alexander Couzens a418c264b2 cmd_recovery: seperate multicommand lines by "&&". 2015-04-06 18:39:05 +02:00
Alexander Couzens fa2f0a886c cmd_setmac/setserial: fix incompatible pointer warning + unused variable 2015-04-06 18:30:52 +02:00
Alexander Couzens ac606588bb cmd_setmac/setserial: use simple_stroul instead of skip_atoi 2015-04-06 18:28:06 +02:00
Alexander Couzens 14586c76a0 cmd_setmac: remove unused include <stdlib.h> 2015-04-06 18:25:20 +02:00
Alexander Couzens a32bdf95de setserial: fix error message and rename var serialnumber -> serial_number 2015-04-06 18:23:11 +02:00
Alexander Couzens 2a21e331db use skip_atoi instead of atoi
atoi requires a stdlib. skip_atoi is much simpler
2015-04-06 18:19:14 +02:00
Alexander Couzens 0e514396fa add command setserial and showserial 2015-04-06 17:14:40 +02:00
Alexander Couzens d54bbbc1e8 version: fix a typo 2015-04-04 20:42:13 +02:00
Alexander Couzens 04d016d730 version: use git tags matching "ar9331-v*" as version 2015-04-04 17:40:47 +02:00
Alexander Couzens d6651043e2 replace 8devices/Caraboot version string with sysmocom 2015-04-04 17:30:14 +02:00
Alexander Couzens 38ad77b802 Makefile: limit git describe to tags "caraboot-v*" 2015-03-16 17:31:39 +01:00
Alexander Couzens 941f9e3083 README: update compile howto to include new buildroot configuration 2015-03-16 17:29:56 +01:00
Alexander Couzens 7de34dd008 Makefile: move buildroot toolchain to ./buildroot 2015-03-16 17:29:56 +01:00
Alexander Couzens ada36ea014 Makefile: remove user specific path and replace them with relative paths 2015-03-16 17:29:56 +01:00
Alexander Couzens 2315facb0c add buildroot.config: this config can be used to generate a sane crossgcc
The Caraboot doesn't compile with OpenWrt toolchain
2015-03-16 17:03:40 +01:00
20 changed files with 3057 additions and 275 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
buildroot/**

View File

@ -7,15 +7,8 @@ export UBOOTDIR=$(TOPDIR)/u-boot
#buildroot
#CONFIG_TOOLCHAIN_PREFIX=/opt/build/toolchain-mipsbe-4.7.3/bin/mips-linux-
#openwrt NOT YET
#CONFIG_TOOLCHAIN_PREFIX=mips-openwrt-linux-uclibc-
#export PATH:=/mnt/projects/lynxis/openwrt/lazus_2/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin:$(PATH)
#CONFIG_TOOLCHAIN_PREFIX=mips-openwrt-linux-uclibc-
#export PATH:=/home/lynxis/projects/work/sysmocom/Caraboot/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin:$(PATH)
CONFIG_TOOLCHAIN_PREFIX=mips-buildroot-linux-uclibc-
export PATH:=/home/lynxis/projects/work/sysmocom/buildroot/output/host/usr/bin/:$(PATH)
export PATH:=$(PWD)/buildroot/output/host/usr/bin/:$(PATH)
########################
@ -26,7 +19,7 @@ export UBOOT_GCC_4_3_3_EXTRA_CFLAGS=-fPIC
export BUILD_TYPE=squashfs
export COMPRESSED_UBOOT=0
export CARABOOT_RELEASE=$(shell git describe --dirty --always)
export CARABOOT_RELEASE=$(shell git describe --dirty --always --match="ar9331-v*")
IMAGEPATH=$(BUILD_TOPDIR)/bin
UBOOT_BINARY=u-boot.bin
@ -54,11 +47,15 @@ ap2: BOARD_TYPE:= ap2
ap2: UBOOTFILE=$(BOARD_TYPE)_u-boot.bin
ap2: compile
jb02: BOARD_TYPE:= jb02
jb02: UBOOTFILE=$(BOARD_TYPE)_u-boot.bin
jb02: compile
jb02v3-skw: BOARD_TYPE:= jb02v3-skw
jb02v3-skw: UBOOTFILE=$(BOARD_TYPE)_u-boot.bin
jb02v3-skw: compile
all: carambola2 ap1 ap2 jb02
jb02v2-cb2: BOARD_TYPE:= jb02v2-cb2
jb02v2-cb2: UBOOTFILE=$(BOARD_TYPE)_u-boot.bin
jb02v2-cb2: compile
all: carambola2 ap1 ap2 jb02v3-skw jb02v2-cb2
clean:
cd $(UBOOTDIR) && $(MAKECMD) distclean

View File

@ -11,14 +11,16 @@ Build
Download:
```
cd your_work_dir
git clone git://git.buildroot.net/buildroot
cd buildroot
git checkout 2015.02
```
Configure:
```
cd buildroot
make menuconfig
cp ../buildroot.config .config
make oldconfig
```
In Target Options select Target Architecture as MIPS (big endian) and Target Architecture Variant as mips 32r2.
In Toolchain select GCC Compiler version as gcc 4.7.x.
@ -26,7 +28,7 @@ Save and exit.
Build:
```
make
make toolchain
```
2) Build Caraboot image

2497
buildroot.config Normal file

File diff suppressed because it is too large Load Diff

View File

@ -283,9 +283,13 @@ ap2_config: unconfig hornet_common_config
@echo "#define CARABOOT_RELEASE \"$(CARABOOT_RELEASE)\"" >>include/config.h
@./mkconfig -a ap2 mips mips carambola2 ar7240 ar7240
jb02_config: unconfig hornet_common_config
jb02v2-cb2_config: unconfig hornet_common_config
@echo "#define CARABOOT_RELEASE \"$(CARABOOT_RELEASE)\"" >>include/config.h
@./mkconfig -a jb02 mips mips carambola2 ar7240 ar7240
@./mkconfig -a jb02v2-cb2 mips mips carambola2 ar7240 ar7240
jb02v3-skw_config: unconfig hornet_common_config
@echo "#define CARABOOT_RELEASE \"$(CARABOOT_RELEASE)\"" >>include/config.h
@./mkconfig -a jb02v3-skw mips mips carambola2 ar7240 ar7240
hornet_common_config :
@ >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);
#endif
ar7240_usb_initial_config();
ar7240_usb_otp_config();
//ar7240_usb_initial_config();
//ar7240_usb_otp_config();
//hornet_ddr_tap_init();
return (ar7240_ddr_find_size());
@ -458,16 +458,13 @@ long int initdram(int board_type)
#ifdef COMPRESSED_UBOOT
int checkboard (char *board_string)
{
strcpy(board_string, "Caraboot "CARABOOT_RELEASE" (AR9331) U-boot");
strcpy(board_string, "sysmocom "CARABOOT_RELEASE" (AR9331) U-boot");
return 0;
}
#else
int checkboard (void)
{
printf("=====================================\n");
printf("Caraboot "CARABOOT_RELEASE" (AR9331) U-boot\n");
printf("http://www.8devices.com/\n");
printf("-------------------------------------\n");
printf("sysmocom "CARABOOT_RELEASE" (AR9331) U-boot\n");
return 0;
}
#endif /* #ifdef COMPRESSED_UBOOT */

View File

@ -2,27 +2,3 @@
#include <config.h>
#include <asm/types.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
#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
*/
@ -24,25 +36,34 @@ static void ar7240_spi_write_page(uint32_t addr, uint8_t * data, int len);
#endif
static void ar7240_spi_sector_erase(uint32_t addr);
static void
ath_spi_read_id(void)
static ulong 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_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",
(rd >> 16) & 0xff, (rd >> 8) & 0xff, (rd >> 0) & 0xff);
ar7240_spi_delay_8();
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
void ar7240_spi_flash_unblock(void)
{
@ -54,25 +75,157 @@ void ar7240_spi_flash_unblock(void)
}
#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)
{
#ifndef CONFIG_WASP
#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);
flash_info_t *info;
/*
* hook into board specific code to fill flash_info
*/
return (flash_get_geom(&flash_info[0]));
info = &flash_info[0];
// spi flash clock
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
@ -102,7 +255,7 @@ flash_erase(flash_info_t *info, int s_first, int s_last)
show_activity(3);
#endif
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
WATCHDOG_RESET();
WATCHDOG_RESET();
#endif
#endif

View File

@ -59,6 +59,6 @@
#define ar7240_spi_delay_8() ar7240_spi_bit_banger(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*/

View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2012, 2013 sysmocom s.f.m.c. GmbH
* Author: Holger Hans Peter Freyther
* Author: Alexander Couzens <lynxis@fe80.eu>
* 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
@ -57,9 +58,9 @@ static int tftp_failed(void)
return -1;
}
static int flash_failed(void)
static int booting_failed(void)
{
printf("Flash failed.\n");
printf("Booting failed.\n");
BLINK_LED(15);
enable_netconsole();
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);
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);
//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)
return tftp_failed();
rc = run_command("erase 0x9f050000 +0x7a0000; "
"cp.b 0x81000000 0x9f050000 0x7a0000", 0);
rc = run_command("bootm 0x81000000", 0);
if (rc < 0)
return flash_failed();
return booting_failed();
return run_command("resetcycle; reset", 0);
}
U_BOOT_CMD(
run_recovery, 2, 0, do_run_recovery,
"run_recovery - Run the sysmocom sysmoBTS recovery process",
"[force]"
"run_recovery - tftp boot a given image",
""
);

View File

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

View File

@ -21,11 +21,8 @@
* FLASH and environment organization
*-----------------------------------------------------------------------
*/
#define CFG_MAX_FLASH_BANKS 1
#define CFG_MAX_FLASH_SECT 256
#define CFG_FLASH_SECTOR_SIZE (64*1024)
#define CFG_FLASH_SIZE 0x01000000
#define DEFAULT_FLASH_SIZE_IN_MB 16
#define BOARDCAL 0x9fff0000
@ -48,7 +45,7 @@
#define CONFIG_SERVERIP 192.168.2.254
#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

View File

@ -22,10 +22,7 @@
*-----------------------------------------------------------------------
*/
#define CFG_MAX_FLASH_BANKS 1
#define CFG_MAX_FLASH_SECT 128
#define CFG_FLASH_SECTOR_SIZE (64*1024)
#define CFG_FLASH_SIZE 0x00800000
#define DEFAULT_FLASH_SIZE_IN_MB 16
#define BOARDCAL 0x9f7f0000
@ -47,7 +44,7 @@
#define CONFIG_SERVERIP 192.168.2.254
#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

View File

@ -22,10 +22,7 @@
*-----------------------------------------------------------------------
*/
#define CFG_MAX_FLASH_BANKS 1
#define CFG_MAX_FLASH_SECT 256
#define CFG_FLASH_SECTOR_SIZE (64*1024)
#define CFG_FLASH_SIZE 0x01000000
#define DEFAULT_FLASH_SIZE_IN_MB 16
#define BOARDCAL 0x9fff0000
@ -48,7 +45,7 @@
#define CONFIG_SERVERIP 192.168.2.254
#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

View File

@ -5,6 +5,9 @@
* We boot from this flash
*/
#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

View File

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

View File

@ -0,0 +1,61 @@
/*
* This file contains the configuration parameters for the dbau1x00 board.
*/
#ifndef __CONFIG_H
#define __CONFIG_H
#include <configs/ar7240.h>
#include <config.h>
#define CONFIG_AR7240 1
#define CONFIG_MACH_HORNET 1
#define CONFIG_HORNET_1_1_WAR 1
/* enable watchdog */
#define CONFIG_HW_WATCHDOG
#define CFG_CMD_BOOTCYCLE
/*-----------------------------------------------------------------------
* FLASH and environment organization
*-----------------------------------------------------------------------
*/
#define DEFAULT_FLASH_SIZE_IN_MB 16
#define BOARDCAL 0x9fff0000
#if (CFG_MAX_FLASH_SECT * CFG_FLASH_SECTOR_SIZE) != CFG_FLASH_SIZE
# error "Invalid flash configuration"
#endif
/* pll and ddr configuration */
#define NEW_DDR_TAP_CAL 1
#undef CFG_PLL_FREQ
#define CFG_PLL_FREQ CFG_PLL_400_400_200
#include <configs/ar7240_freq.h>
#define CFG_ATHRS26_PHY 1
#define CONFIG_IPADDR 192.168.2.100
#define CONFIG_SERVERIP 192.168.2.254
#define CFG_FAULT_ECHO_LINK_DOWN 1
#define RECOVERY_FILENAME_STRING "openwrt-ar71xx-generic-sysmocom-sob-jb02v3-initramfs-uImage.bin"
#define CFG_PHY_ADDR 0
#define CFG_AG7240_NMACS 2
#define CFG_GMII 0
#define CFG_MII0_RMII 1
#define CFG_AG7100_GE0_RMII 1
#include <configs/common.h>
#include <cmd_confdefs.h>
#endif /* __CONFIG_H */

View File

@ -31,6 +31,7 @@
typedef struct {
ulong size; /* total bank size in bytes */
ulong sector_size; /* size of erase unit in bytes */
ushort sector_count; /* number of erase units */
ulong flash_id; /* combined device & manufacturer code */
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_CUSTOM 0x1111
#define FLASH_UNKNOWN 0xFFFF /* unknown flash type */

View File

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

View File

@ -8,15 +8,6 @@ usage() {
cd "${1:-.}" || usage
# Check for git and a git repo.
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
# 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
if version=$(git describe --dirty --always --match="ar9331-v*" 2>/dev/null) ; then
echo "-$version"
fi