找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 9629|回复: 15

关于用TTL线刷写CFE

[复制链接]
发表于 2007-10-28 12:12 | 显示全部楼层 |阅读模式
1.TTL线,连接路由后,可以用save命令来备份 FLASH芯片中的指定地址指定长度任何部分内容。所以用TTL线应该能备份CFE。关键需要知道芯片中CFE的起始位置和结束位置。
2.可以用LOAD命令把 (RAW格式文件)载入到FLASH芯片的指定地址中,故也应该可以用来刷写CFE,乃至其它你想刷写的任何内容。
可惜的是,我对这些一点也不懂。

有懂的朋友,希望能提供一下帮助。谢谢。以下为用TTL对7231-4的操作。

CFE> help
Available commands:

et                  Broadcom Ethernet utility.
led                 LED control.
tftpupg             Upgrade firmware through ethernet TFTP.
dnvram              Default NVRAM utility.
nvram               NVRAM utility.
reboot              Reboot.
flash               Update a flash memory device
autoboot            Automatic system bootstrap.
batch               Load a batch file into memory and execute it
go                  Verify and boot OS image.
boot                Load an executable file into memory and execute it
load                Load an executable file into memory without executing it
save                Save a region of memory to a remote file via TFTP
ping                Ping a remote IP host.
arp                 Display or modify the ARP Table
ifconfig            Configure the Ethernet interface
unsetenv            Delete an environment variable.
printenv            Display the environment variables
setenv              Set an environment variable.
help                Obtain help for CFE commands

For more information about a command, enter 'help command-name'
*** command status = 0
CFE> flash

     flash [options] filename [flashdevice]
     
     Copies data from a source file name or device to a flash memory device.
     The source device can be a disk file (FAT filesystem), a remote file
     (TFTP) or a flash device.  The destination device may be a flash or eeprom.
     If the destination device is your boot flash (usually flash0), the flash
     command will restart the firmware after the flash update is complete

     -noerase     Don't erase flash before writing
     -offset=*    Begin programming at this offset in the flash device
     -size=*      Size of source device when programming from flash to flash
     -trx         Multi-files header, allow programming muliple images to flash
     -noheader    Override header verification, flash binary without checking

*** command status = -2
CFE> load

     load [-options] host:filename|dev:filename
     
     This command loads an executable file into memory, but does not
     execute it.  It can be used for loading data files, overlays or
     other programs needed before the 'boot' command is used.  By
     default, 'load' will load a raw binary at virtual address 0x20000000.

     -elf         Load the file as an ELF executable
     -srec        Load the file as ASCII S-records
     -raw         Load the file as a raw binary
     -z           Load compessed file
     -loader=*    Specify CFE loader name
     -tftp        Load the file using the TFTP protocol
     -fatfs       Load the file from a FAT file system
     -rawfs       Load the file from an unformatted file system
     -fs=*        Specify CFE file system name
     -max=*       Specify the maximum number of bytes to load (raw only)
     -addr=*      Specify the load address (hex) (raw only)

*** command status = -2
CFE> save

     save [-options] host:filename startaddr length
     

*** command status = -2
CFE>
 楼主| 发表于 2007-10-28 12:18 | 显示全部楼层
主要是不想去做那根JTAG的鸟线。谢谢各位。
发表于 2007-10-28 12:36 | 显示全部楼层
 楼主| 发表于 2007-10-28 13:02 | 显示全部楼层
楼上的那个链接打不开。 ,谢谢。
 楼主| 发表于 2007-10-28 13:03 | 显示全部楼层
用代理才能上去,河南网通真他妈的操蛋。。
 楼主| 发表于 2007-10-28 13:07 | 显示全部楼层
实在不好意思,这个地方还得用JTAG。而我不想去做这根线。
发表于 2007-10-28 13:19 | 显示全部楼层
没拿机器试过,我一直以为 在 OPENWRT 里面 可以直接更新 CFE.
 楼主| 发表于 2007-10-28 13:45 | 显示全部楼层
原帖由 a9988cd 于 2007-10-28 13:19 发表
没拿机器试过,我一直以为 在 OPENWRT 里面 可以直接更新 CFE.

是想换一块大点FLASH芯片。在纯裸的情况下写CFE。
发表于 2007-10-28 16:55 | 显示全部楼层

abug:请问使用哪一个代理服务器?抑或代理浏览器?

俺不幸也是河南网通的用户!http://wl500g.dyndns.org/wrt54g.html已经好几天打不开,无法更新ipkg!
发表于 2007-10-28 17:13 | 显示全部楼层

abug:请问使用哪一个代理服务器?抑或代理浏览器?

俺不幸也是河南网通的用户!http://wl500g.dyndns.org/wrt54g.html已经好几天打不开,无法更新ipkg!
 楼主| 发表于 2007-10-28 18:59 | 显示全部楼层

回复 #10 sharkman2004 的帖子

十分不好意思,代理服务器可以上http://www.cnproxy.com/proxy1.html查询。如果河南网通不能上这个网站的话,换个国内的其它地区的试试。我是用的单位的收费代理。
发表于 2007-10-28 20:05 | 显示全部楼层
原帖由 a9988cd 于 2007-10-28 13:19 发表
没拿机器试过,我一直以为 在 OPENWRT 里面 可以直接更新 CFE.

openwrt下要对cfe操作,必须是特殊的固件,在wiki里提到,可以自己编译。
openwrt并没有提供编译好的下载。
否则,刷写cfe必须用jtag线。
发表于 2007-10-28 23:36 | 显示全部楼层
原帖由 abug 于 2007-10-28 13:45 发表

是想换一块大点FLASH芯片。在纯裸的情况下写CFE。

这个不行,没有CFE的片子,串口连接不上去的
发表于 2007-10-29 05:33 | 显示全部楼层
Enabling boot_wait and changing other CFE defaults (WRT54G v.2.x)
Copyright (c) 2005 Oleg I. Vdovikin

IMPORTANT: This information provided AS IS, without any warranties. If in doubt leave this page now. This information applies to WRT54G hw rev 2.0, 2.2, 3.0. No other units were tested, but most likely WRT54GS units should be the same. WRT54G hw rev 1.x use different layout, so you need to adjust things accordingly.
The wrt54g v.2.2 unit was kindly donated to me by maxx, the member of the forum.chupa.nl forum. I would like to publically say thank you to him.

Extracting default values
Telnet/ssh to your router running your favorite firmware and type the following
dd if=/dev/mtdblock/0 bs=1 skip=4116 count=2048 | strings > /tmp/cfe.txt
dd if=/dev/mtdblock/0 of=/tmp/cfe.bin

Copy both cfe.bin and cfe.txt to your linux box (this is required). Check cfe.txt, it should look like this (this is from v.2.2):
boardtype=0x0708
boardnum=42
boardrev=0x10
boardflags=0x0118
boardflags2=0
sromrev=2
clkfreq=200
sdram_init=0x000b
sdram_config=0x0062
sdram_refresh=0x0000
sdram_ncdl=0x0
et0macaddr=00:90:4C:00:00:00
et0phyaddr=30
et0mdcport=0
gpio5=robo_reset
vlan0ports=1 2 3 4 5*
vlan0hwname=et0
vlan1ports=0 5
vlan1hwname=et0
wl0id=0x4320
il0macaddr=00:90:4C:00:00:00
aa0=3
ag0=255
pa0maxpwr=0x4e
pa0itssit=62
pa0b0=0x15eb
pa0b1=0xfa82
pa0b2=0xfe66
wl0gpio2=0
wl0gpio3=0
cctl=0
ccode=0
dl_ram_addr=a0001000
os_ram_addr=80001000
os_flash_addr=bfc40000
lan_ipaddr=192.168.1.1
lan_netmask=255.255.255.0
scratch=a0180000
boot_wait=off
watchdog=5000
bootnv_ver=2

Changing defaults
Open cfe.txt using text editor and change defaults in the way you like (but be extremelly careful, as some changes could prevent device from booting and you will need to use JTAG cable to bring it back to life). For me I've decided to enable both Afterburner (Speedbooster) and set boot_wait to on by default, so reset to default no longer messes the things, so I've applied this pseudo-patch (please note, that I've added bit 0x200 to boardflags to enable afterburner):
-boardflags=0x0118
-boot_wait=off
+boardflags=0x0318
+boot_wait=on

If you do not understand some things in this file, do not try to edit it. This is also applies to afterburner. I've also tried to change default lan_ipaddr, but this does not work in the way I expect: CFE started to answer to ping request to new lan_ipaddr, but it does not accept tftp transfers...
Creating new CFE image
You will need a nvserial utility which comes with several GPL tarballs. Linksys supplies it in the wrt54g.1.42.3, wrt54g.1.42.2, wap55ag.1.07, wap54gv2.2.06. Launch nvserial in the way like this on your x86 linux box:
nvserial -i cfe.bin -o cfe_new.bin -b 4096 -c 2048 cfe.txt

It works really slow, but it should finally create cfe_new.bin file for you, which has new embedded nvram.
Recompiling kernel with writable pmon partition
By default most firmwares has pmon partition write protected, i.e. you can't flash anything to this first 256k of flash. This is to prevent corrupting PMON/CFE. To remove this "lock" you will need to apply this patch to the kernel and recompile your firmware:
--- linux/arch/mips/brcm-boards/bcm947xx/setup.c.orig   2005-01-23 19:29:05.000000000 +0300
+++ linux/arch/mips/brcm-boards/bcm947xx/setup.c        2005-03-26 15:13:33.000000000 +0300
@@ -179,7 +179,7 @@
#ifdef CONFIG_MTD_PARTITIONS

static struct mtd_partition bcm947xx_parts[] = {
-       { name: "pmon", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, },
+       { name: "pmon", offset: 0, size: 0 /*, mask_flags: MTD_WRITEABLE,*/ },
        { name: "linux", offset: 0, size: 0, },
        { name: "rootfs", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, },
        { name: "nvram", offset: 0, size: 0, },

Flashing new CFE image
So, once you've recompiled and flashed your new firmware you need yo upgrade CFE. This process is dangerous, as flash failure during it will prevent your unit from booting. Copy cfe_new.bin to your wrt54g and flash it. The exact commands are dependent on the firmware. With OpenWRT I've used the folowing:
mtd unlock pmon
mtd write /tmp/cfe_new.bin pmon

Checking it
Embedded nvram is only used, when real nvram is either corrupted or empty (CRC/magic checks fails), so you will need to erase nvram or to reset to defaults. With OpenWRT type this:
mtd erase nvram

Then cross your fingers and reboot your unit. And remember - I'm not responsible for any damage to your unit, as this information is provided AS IS for my own pleasure.
--------------------------------------------------------------------------------
oleg@cs.msu.su
发表于 2007-10-29 09:24 | 显示全部楼层
原帖由 abug 于 2007-10-28 12:12 发表
关键需要知道芯片中CFE的起始位置和结束位置。


楼主思路是对的。
不过你得提供你设备上flash片子的型号,才能提供给你正确的CFE起始地址和结束位置。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-7-3 02:41

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com

快速回复 返回顶部 返回列表