DI-604 Flash Reverse Engineering

本文档详细介绍了D-Link DI-604路由器的固件逆向工程过程,包括其硬件配置、闪存映射、固件格式及校验方式等关键信息,并深入探讨了启动加载器的工作原理。

DI-604 Flash Reverse Engineering

硬件:D-Link DI-604 (兩年前的塑膠殼新機) CPU: Conexant CX84200-11 的網路處理器 (ARM 9 CPU + 整合式網路晶片), RAM: Hynix HY57V643220, flash

ROM: MX 29LV800BTC

Flash image with firmaware version 2.10 flash.bin

Encoding: little

Flash memory map:

  • 0x0000.0000 - 0x0002.0000 - bootloader (permanent) (used up to 0x1.39e0)
    • 0x0000.0000 - 0x0000.1800 - initialisation code
    • 0x0000.1800 - 0x0000.3000 - uncompression code (ARJ), copied to the 0x2030.0000 prior to execution
    • 0x0000.3000 - 0x0001.0000 - ARJ compressed "factory setting" restoration image
    • 0x0001.0000 - 0x0001.39e0 - text strings/ configuration data ???
    • 0x0001.39e0 - 0x0002.0000 - empty space ??
  • 0x0002.0000 - 0x0010.0000 - ARJ compressed firmware image - upgradable via HTTP or TFTP (current version is 2.10)
  • 0x2000.0000 - SDRAM start
  • 0x2038.0000 - 0x2039.477b
  • 2038.3884 - ??
  • 2038.3964 - ??

Firmware Format

Info from Chris Windibank, 01/Mar/04

The firmware file is always 917,504 (0xe0000) bytes in length, presumably because it's a 1MB flash and the bootloader, backup firmware and settings area is 131,072 (0x20000) which leaves exacly that amount!

It is checksummed by the attached code. They decided to xor all bytes together and check it against a know value. I'm not really an expert in checksums so I can't say if this is unusual or not but it's certainly not a mainstream algorithm.

The first part of the file is the actual firmware in ARJ format using the -m1 compression mode and the archive consists of a single file named NML.MEM. The unused area after the firmware is zeroed and finally a signature and checksum is attached at the end. The signature is constant and the checksum can be calculated by xoring all the bytes in the file minus the checksum area and then xoring the result with 0xaabbbbaa.

The attached file can be used to generate a valid flash binary. I am a WindowsXP user and it was tested with Visual Studio 6.0 but it only contains C standard library calls so it should compile fine with GCC. It's usage is as follows:

mkflash outfile - where outfile is the name of the output file (I use di604_firmware_ucl.bin)

It expects to find a file name NML.ARJ in the current directory (the first version took and input file but I got tired of typing it). I have been renaming zImage NML.MEM and then using the following to make the archive for mkflash.

arj32 a -m1 NML.ARJ NML.MEM

I'm not sure if the firmware checks to see if the arjed file in the archive is actually name NML.MEM but that is the way DLink does it so I did the same.

The bootloader expands the archived firmware sitting at 0x20000 in flash ROM to 0x20000000 in RAM. It then flips the RAM/ROM address spaces and jumps to address 0 which is the begginning of RAM after the flip.

At this point the router will start to execute zImage which is a compressed kernal and ramdisk. It should decompress the kernal and ramdisk and then jump to the entry point of the decompressed kernal. I chose to go with the compressed kernal because it's an easy way to get the ramdisk into memory from a single arjed archive. It may be better to try something different later when the kernal is actually working!

Bootloader decoding

AddressDescriptionCalls Called by
0x0000Exceptions vectors.
Reset/IRQ-
0x0048 - 0x007cSwitch between 0 address from Flash mem to SDRAM.
-0x2E0
0x0080 - 0x0254Initialisation:
  • SDRAM memory controller
  • Flash memory contorller
  • GPIO
    Pass contorol to 0x500
0x5000x0000
0x0268 - 0x0268Endless loop-0x324
0x026C - 0x028Cread input value of the GPIO[6] (CONFIG RESET TO FACTORY). return 1 if input 0;
-0x324
0x0290 - 0x02DCXOR starting from start_addr(r0) for bytes(r1) length
Return 0 if ==0xaabbbbaa
else return -1
-0x324
0x02E0 - 0x320memcpy(src,dst,len)-0x324
0x0324 - 0x03D0
check SRC of the main firware (0x2000)
check reset buttom

load uncompression code to SDRAM
      if RESET load from      0x03000
      if no RESET load from   0x20000
if uncompression return 1 - then switch memory and start from 0
	   
-0x0874
0x03D4 - 0x042cUART-0x46C
0x0430 - 0x043cRead UART0 flag register for "receive FIFO full"-0x46C
0x0440 - 0x0468--0x46C
0x046c - 0x04dcno direct call-call itself ??
0x04E0 - 0x04fcno direct call!!--
0x0500 - 0x0870Calculates relocated addreses
Clean mem region 0x20380000(0x1477B bytes)
memcpy(0x11a9,0x1145,0x24) copy to flash????
call 0x0874
indirect 0x08740x80
0x0874 - 0x09c0do nothing;
call 0x324;
call 0xA08;
0x09c4 0x0e20 0x0db0 0x0324 0x0a08 indirect call
0x0500
0x09C4 - 0x09E0
void  f_0x9c4()
{
   f_0xebc(16,-1);
   return;
}	   
-0x0874
0x09E4 - 0x0A04---
0x0A08 - 0x0AC8---
0xacc - 0xae4--no direct call
0xae8 - 0xd24memcpy(src,dst,len)-indirect call
0x500
0xd28 - 0xdacmemset(addres, char , len) - set memory region with a specific byte-indirect call
0x500
0x0db0 - return 20383884;-indirect call
0xEDC
0x0ebc - 0x0ed8
*20383884 = r0;
return -1;
-0x09c4
0x0edc - 0x0f20
 if(!f_0x00db0)
       return 20383964;
 else
       return f_0x0db0(); // 20383884
	   
-0x0f24
0x0f24 - 0x0f44
void f_0x0f24(word val){
{
  word *addr;
  addr = f_0x0edc();
  if(addr!=0)
       *addr = val;
   return;
}
	  
-0x0ebc
0x0f48 - ---
0x1134indirect function call (call addr in IP registerIP defined addressmultiple
0x1138function to do nothing???? OR first parameter to itself and exit. What the big deal??-0x0ebc
----
0x29C4 - 0x2F9Clast function--

indirectly called functions 0x4e0
0xacc - 0xae4
0xae8 - 0xd24
0xd28 - 0xdac


$Id: flash_mem.html,v 1.5 2004/03/14 11:07:16 bcabral Exp $  
【无人机】基于改进粒子群算法的无人机路径规划研究[和遗传算法、粒子群算法进行比较](Matlab代码实现)内容概要:本文围绕基于改进粒子群算法的无人机路径规划展开研究,重点探讨了在复杂环境中利用改进粒子群算法(PSO)实现无人机三维路径规划的方法,并将其与遗传算法(GA)、标准粒子群算法等传统优化算法进行对比分析。研究内容涵盖路径规划的多目标优化、避障策略、航路点约束以及算法收敛性和寻优能力的评估,所有实验均通过Matlab代码实现,提供了完整的仿真验证流程。文章还提到了多种智能优化算法在无人机路径规划中的应用比较,突出了改进PSO在收敛速度和全局寻优方面的优势。; 适合人群:具备一定Matlab编程基础和优化算法知识的研究生、科研人员及从事无人机路径规划、智能优化算法研究的相关技术人员。; 使用场景及目标:①用于无人机在复杂地形或动态环境下的三维路径规划仿真研究;②比较不同智能优化算法(如PSO、GA、蚁群算法、RRT等)在路径规划中的性能差异;③为多目标优化问题提供算法选型和改进思路。; 阅读建议:建议读者结合文中提供的Matlab代码进行实践操作,重点关注算法的参数设置、适应度函数设计及路径约束处理方式,同时可参考文中提到的多种算法对比思路,拓展到其他智能优化算法的研究与改进中。
标题中的"EthernetIP-master.zip"压缩文档涉及工业自动化领域的以太网通信协议EtherNet/IP。该协议由罗克韦尔自动化公司基于TCP/IP技术架构开发,已广泛应用于ControlLogix系列控制设备。该压缩包内可能封装了协议实现代码、技术文档或测试工具等核心组件。 根据描述信息判断,该资源主要用于验证EtherNet/IP通信功能,可能包含测试用例、参数配置模板及故障诊断方案。标签系统通过多种拼写形式强化了协议主题标识,其中"swimo6q"字段需结合具体应用场景才能准确定义其技术含义。 从文件结构分析,该压缩包采用主分支命名规范,符合开源项目管理的基本特征。解压后预期可获取以下技术资料: 1. 项目说明文档:阐述开发目标、环境配置要求及授权条款 2. 核心算法源码:采用工业级编程语言实现的通信协议栈 3. 参数配置文件:预设网络地址、通信端口等连接参数 4. 自动化测试套件:包含协议一致性验证和性能基准测试 5. 技术参考手册:详细说明API接口规范与集成方法 6. 应用示范程序:展示设备数据交换的标准流程 7. 工程构建脚本:支持跨平台编译和部署流程 8. 法律声明文件:明确知识产权归属及使用限制 该测试平台可用于构建协议仿真环境,验证工业控制器与现场设备间的数据交互可靠性。在正式部署前开展此类测试,能够有效识别系统兼容性问题,提升工程实施质量。建议用户在解压文件后优先查阅许可协议,严格遵循技术文档的操作指引,同时需具备EtherNet/IP协议栈的基础知识以深入理解通信机制。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值