Skip to content

Commit

Permalink
Merge with 354
Browse files Browse the repository at this point in the history
  • Loading branch information
RMerl committed Mar 27, 2013
1 parent aeb1646 commit 3cf5a2c
Show file tree
Hide file tree
Showing 9,594 changed files with 4,113,208 additions and 194,567 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
72 changes: 46 additions & 26 deletions README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,61 @@ Set Up Environment (Tested in Fedora 8/9 and Ubuntu 10.04/12.04 LTS amd64)

1. prepare environment

Install these packages (I used synaptic: "sudo synaptic")

bison
flex
g++
g++-4.4
g++-multilib
gawk
gcc-multilib
gconf (or gconf-editor)
gitk
lib32z1-dev
libncurses5
libncurses5-dev
libstdc++6-4.4-dev
libtool
m4
pkg-config
zlib1g-dev
gperf
lib32z1-dev
libssl-dev
a. Ubuntu
Install these packages (I used synaptic: "sudo synaptic")

bison
flex
g++
g++-4.4
g++-multilib
gawk
gcc-multilib
gconf (or gconf-editor)
gitk
lib32z1-dev
libncurses5
libncurses5-dev
libstdc++6-4.4-dev
libtool
m4
pkg-config
zlib1g-dev
autoconf
autopoint
libtool
shtool
autogen
gperf
lib32z1-dev
libssl-dev

b. Fedora
sudo yum groupinstall "Development Tools"

2. prepare source to, ex, $HOME/asuswrt

cd $HOME
tar xvfz [tar file]

3. setup development system

ln -s $HOME/asuswrt/tools/brcm /opt/brcm
export PATH=$PATH:/opt/brcm/hndtools-mipsel-linux/bin:/opt/brcm/hndtools-mipsel-uclibc/bin
mkdir -p /media/ASUSWRT/
ln -s ~/asuswrt /media/ASUSWRT/asuswrt

Note: Broadcom/Ralink platform use the same toolchain for user space program, so please set PATH to the same directory as above

4. build firmware, ex, rt-n16
cd ~/asuswrt/release/src-rt
make rt-n16
4. build firmware.
a. rt-n16
cd release/src-rt
make rt-n16

b. rt-n56u
cd release/src-ra
make rt-n56u

c. rt-n65u
cd release/src-ra-3.0
make rt-n65u

3 changes: 3 additions & 0 deletions release/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src-rt-6.x/.config
src-rt/.config

2 changes: 1 addition & 1 deletion release/src-rt-6.x/cfe/build/broadcom/bcm947xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ endif
COMPRESSED_CFE := 1
RESCUE_MODE := 1 # disable for tmp
RTN66U := 1
DUAL_TRX :=1
DUAL_TRX :=0

# read sdram params from nvram in internal builds
CFG_SDRAM_PARAM_FROM_EMBEDDED_NVRAM := 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,11 +914,12 @@ secret_code=12345670
hw_version=1.5

# Bootloader version
bl_version=1.0.1.3
bl_version=1.0.1.6

# for NAND flash
bootflags=1
ntype=0
nflash_swecc=1

# serial number
serial_no=CAIAA2000001
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# $Id: Makefile 315309 2012-02-16 06:57:20Z $
# $Id: Makefile 315309 2012-02-16 06:57:20Z dboyce $
#

# Max sizes for vanilla external
Expand All @@ -34,6 +34,9 @@ CFE_MAXSIZE = 262144
endif

# Max sizes for internal
CFE_INTERNAL = 1
CFEZ_MAXSIZE = 262144
CFE_MAXSIZE = 524288

BSPOBJS += bcm947xx_init.o bcm947xx_devs.o ui_bcm947xx.o

Expand Down Expand Up @@ -75,6 +78,7 @@ endif
ifeq ($(strip ${CFG_MINIMAL_SIZE}),1)
CFLAGS += -DCFG_MINIMAL_SIZE=1
else
CFLAGS += -DBCMINTERNAL -DBCMDBG -DUNRELEASEDCHIP
endif

ifeq ($(strip $(CFG_FLASH)),1)
Expand All @@ -90,7 +94,7 @@ endif

ifeq ($(strip ${CFG_NFLASH}),1)
CFLAGS += -DCFG_NFLASH=1 -DNFLASH_SUPPORT -DCFG_HEAP_SIZE=2048
ALLOBJS += dev_nflash.o nflash.o
ALLOBJS += dev_nflash.o nflash.o nand_ecc.o
endif

ifeq ($(strip $(CFG_ET)),1)
Expand Down
2 changes: 1 addition & 1 deletion release/src-rt-6.x/cfe/cfe/ui/ui_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ static int ui_cmd_flash(ui_cmdline_t *cmd,int argc,char *argv[])
char *scode = "secret_code";
uint8_t SCODE[5] = {0x53, 0x43, 0x4F, 0x44, 0x45};
#endif // RESCUE_MODE
#ifdef DUAL_TRX
int cfe = 0;
#ifdef DUAL_TRX
int write_trx2 = 0;
#endif

Expand Down
2 changes: 1 addition & 1 deletion release/src-rt-6.x/cfe/patch/README
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cfe patch against brcm sdk linux-2.6-router-6.30.39.16
- src/cfe/cfe/arch/mips/board/bcm947xx/src/ui_bcm947xx.c
- src/include/amemc_core.h
- src/include/bcmnvram.h
- src/include/nflash.h
- src/shared/nflash.c
- src/shared/nand_ecc.c
201 changes: 201 additions & 0 deletions release/src-rt-6.x/cfe/patch/nand_ecc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/*
* This file contains an ECC algorithm from Toshiba that detects and
* corrects 1 bit errors in a 256 byte block of data.
*
* drivers/mtd/nand/nand_ecc.c
*
* Copyright (C) 2000-2004 Steven J. Hill ([email protected])
* Toshiba America Electronics Components, Inc.
*
* Copyright (C) 2006 Thomas Gleixner <[email protected]>
*
* $Id: nand_ecc.c,v 1.1.1.1 2007-08-03 18:52:44 rnuti Exp $
*
* This file 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 or (at your option) any
* later version.
*
* This file 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 file; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*
* As a special exception, if other files instantiate templates or use
* macros or inline functions from these files, or you compile these
* files and link them with other works to produce a work based on these
* files, these files do not by themselves cause the resulting work to be
* covered by the GNU General Public License. However the source code for
* these files must still be made available in accordance with section (3)
* of the GNU General Public License.
*
* This exception does not invalidate any other reasons why a work based on
* this file might be covered by the GNU General Public License.
*/

#include <typedefs.h>
typedef uint8 u_char;
struct mtd_info {
};
typedef uint8 uint8_t;
typedef uint16 uint16_t;
typedef uint32 uint32_t;
int nand_calculate_ecc(void *mtd, const u_char *dat,
u_char *ecc_code);
int nand_correct_data(void *mtd, u_char *dat,
u_char *read_ecc, u_char *calc_ecc);


/*
* Pre-calculated 256-way 1 byte column parity
*/
static const u_char nand_ecc_precalc_table[] = {
0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00,
0x65, 0x30, 0x33, 0x66, 0x3c, 0x69, 0x6a, 0x3f, 0x3f, 0x6a, 0x69, 0x3c, 0x66, 0x33, 0x30, 0x65,
0x66, 0x33, 0x30, 0x65, 0x3f, 0x6a, 0x69, 0x3c, 0x3c, 0x69, 0x6a, 0x3f, 0x65, 0x30, 0x33, 0x66,
0x03, 0x56, 0x55, 0x00, 0x5a, 0x0f, 0x0c, 0x59, 0x59, 0x0c, 0x0f, 0x5a, 0x00, 0x55, 0x56, 0x03,
0x69, 0x3c, 0x3f, 0x6a, 0x30, 0x65, 0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6a, 0x3f, 0x3c, 0x69,
0x0c, 0x59, 0x5a, 0x0f, 0x55, 0x00, 0x03, 0x56, 0x56, 0x03, 0x00, 0x55, 0x0f, 0x5a, 0x59, 0x0c,
0x0f, 0x5a, 0x59, 0x0c, 0x56, 0x03, 0x00, 0x55, 0x55, 0x00, 0x03, 0x56, 0x0c, 0x59, 0x5a, 0x0f,
0x6a, 0x3f, 0x3c, 0x69, 0x33, 0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3c, 0x3f, 0x6a,
0x6a, 0x3f, 0x3c, 0x69, 0x33, 0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3c, 0x3f, 0x6a,
0x0f, 0x5a, 0x59, 0x0c, 0x56, 0x03, 0x00, 0x55, 0x55, 0x00, 0x03, 0x56, 0x0c, 0x59, 0x5a, 0x0f,
0x0c, 0x59, 0x5a, 0x0f, 0x55, 0x00, 0x03, 0x56, 0x56, 0x03, 0x00, 0x55, 0x0f, 0x5a, 0x59, 0x0c,
0x69, 0x3c, 0x3f, 0x6a, 0x30, 0x65, 0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6a, 0x3f, 0x3c, 0x69,
0x03, 0x56, 0x55, 0x00, 0x5a, 0x0f, 0x0c, 0x59, 0x59, 0x0c, 0x0f, 0x5a, 0x00, 0x55, 0x56, 0x03,
0x66, 0x33, 0x30, 0x65, 0x3f, 0x6a, 0x69, 0x3c, 0x3c, 0x69, 0x6a, 0x3f, 0x65, 0x30, 0x33, 0x66,
0x65, 0x30, 0x33, 0x66, 0x3c, 0x69, 0x6a, 0x3f, 0x3f, 0x6a, 0x69, 0x3c, 0x66, 0x33, 0x30, 0x65,
0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00
};

/**
* nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256-byte block
* @mtd: MTD block structure
* @dat: raw data
* @ecc_code: buffer for ECC
*/
int nand_calculate_ecc(void *mtd, const u_char *dat,
u_char *ecc_code)
{
uint8_t idx, reg1, reg2, reg3, tmp1, tmp2;
int i;

/* Initialize variables */
reg1 = reg2 = reg3 = 0;

/* Build up column parity */
for(i = 0; i < 256; i++) {
/* Get CP0 - CP5 from table */
idx = nand_ecc_precalc_table[*dat++];
reg1 ^= (idx & 0x3f);

/* All bit XOR = 1 ? */
if (idx & 0x40) {
reg3 ^= (uint8_t) i;
reg2 ^= ~((uint8_t) i);
}
}

/* Create non-inverted ECC code from line parity */
tmp1 = (reg3 & 0x80) >> 0; /* B7 -> B7 */
tmp1 |= (reg2 & 0x80) >> 1; /* B7 -> B6 */
tmp1 |= (reg3 & 0x40) >> 1; /* B6 -> B5 */
tmp1 |= (reg2 & 0x40) >> 2; /* B6 -> B4 */
tmp1 |= (reg3 & 0x20) >> 2; /* B5 -> B3 */
tmp1 |= (reg2 & 0x20) >> 3; /* B5 -> B2 */
tmp1 |= (reg3 & 0x10) >> 3; /* B4 -> B1 */
tmp1 |= (reg2 & 0x10) >> 4; /* B4 -> B0 */

tmp2 = (reg3 & 0x08) << 4; /* B3 -> B7 */
tmp2 |= (reg2 & 0x08) << 3; /* B3 -> B6 */
tmp2 |= (reg3 & 0x04) << 3; /* B2 -> B5 */
tmp2 |= (reg2 & 0x04) << 2; /* B2 -> B4 */
tmp2 |= (reg3 & 0x02) << 2; /* B1 -> B3 */
tmp2 |= (reg2 & 0x02) << 1; /* B1 -> B2 */
tmp2 |= (reg3 & 0x01) << 1; /* B0 -> B1 */
tmp2 |= (reg2 & 0x01) << 0; /* B7 -> B0 */

/* Calculate final ECC code */
#ifdef CONFIG_MTD_NAND_ECC_SMC
ecc_code[0] = ~tmp2;
ecc_code[1] = ~tmp1;
#else
ecc_code[0] = ~tmp1;
ecc_code[1] = ~tmp2;
#endif
ecc_code[2] = ((~reg1) << 2) | 0x03;

return 0;
}


static inline int countbits(uint32_t byte)
{
int res = 0;

for (;byte; byte >>= 1)
res += byte & 0x01;
return res;
}

/**
* nand_correct_data - [NAND Interface] Detect and correct bit error(s)
* @mtd: MTD block structure
* @dat: raw data read from the chip
* @read_ecc: ECC from the chip
* @calc_ecc: the ECC calculated from raw data
*
* Detect and correct a 1 bit error for 256 byte block
*/
int nand_correct_data(void *mtd, u_char *dat,
u_char *read_ecc, u_char *calc_ecc)
{
uint8_t s0, s1, s2;

#ifdef CONFIG_MTD_NAND_ECC_SMC
s0 = calc_ecc[0] ^ read_ecc[0];
s1 = calc_ecc[1] ^ read_ecc[1];
s2 = calc_ecc[2] ^ read_ecc[2];
#else
s1 = calc_ecc[0] ^ read_ecc[0];
s0 = calc_ecc[1] ^ read_ecc[1];
s2 = calc_ecc[2] ^ read_ecc[2];
#endif
if ((s0 | s1 | s2) == 0)
return 0;

/* Check for a single bit error */
if( ((s0 ^ (s0 >> 1)) & 0x55) == 0x55 &&
((s1 ^ (s1 >> 1)) & 0x55) == 0x55 &&
((s2 ^ (s2 >> 1)) & 0x54) == 0x54) {

uint32_t byteoffs, bitnum;

byteoffs = (s1 << 0) & 0x80;
byteoffs |= (s1 << 1) & 0x40;
byteoffs |= (s1 << 2) & 0x20;
byteoffs |= (s1 << 3) & 0x10;

byteoffs |= (s0 >> 4) & 0x08;
byteoffs |= (s0 >> 3) & 0x04;
byteoffs |= (s0 >> 2) & 0x02;
byteoffs |= (s0 >> 1) & 0x01;

bitnum = (s2 >> 5) & 0x04;
bitnum |= (s2 >> 4) & 0x02;
bitnum |= (s2 >> 3) & 0x01;

dat[byteoffs] ^= (1 << bitnum);

return 1;
}

if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1)
return 1;

return -1;
}
Loading

0 comments on commit 3cf5a2c

Please sign in to comment.