http://moto.it168.com/thread-2756889-1-1.html
制作自己的刷机shx文件(作者:12345678)
特别说明:偶只会刷不会制,不过有人会哟,一起来看:
作者:12345678
一、 Hi,大家好!我又有些消息发布哦。最近一直研究刷机用的shx文件,为此也找了不少资料。参考了很多的资料后,把对shx的理解如下:
1、shx本身是S-format格式,具体文件格式编码定义可以看下面的备注1。
2、既然知道是ascii的shx,那么我们就可以用一个叫/BINEX的 软件 来转换。其实也就说刷到 手机 里的文件包括内核,rootfs,langu ag e,setup,ezxlocal等目录里的文件都是经过编码存放在这一个shx文件。总而言之shx是多个binary 格式的包的集合体。
3、他的格式为S0开头的一行字符串,到下一个S0开头的一段内容就是是一个完整的binary格式的包,我们可以利用ultraedit32来打开shx文件,然后把S0开头到下一个S0开头的一段拷贝形成新的一个文件,保存为hex为后缀名。我这里以48版本的shx为例子,总共可以从shx文件剥离出13个binary包。这13个小文件都是ASCII格式的,当然自己mount,修改啥都很不方便,所以我们就需要用工具把他从ascii格式转换成bin格式,这个工具就是binex。
4、转换,从ascii格式转换成bin,用binex /b s01.hex /os01.bin,这就把s01.hex从ascii转换成bin,这样我们就可以在linux下用mount修改/和setup这2个cramfs格式的包了。
5、如何mount这个包请参考备注2。
6、七里八啦一翻修改,想怎么整就怎么整,然后我们就得到了经过自己定义/和setup等2个cramfs包了。
7、现在问题来了,shx是ascii格式,而我们得到的是bin格式的文件,怎么转呢?呵呵,binex再次出场,还得靠他。
binex /h root.cramfs /o s1 2.hex (在此我们假设自己做的root叫root.cramfs,而s12为原来ascii的root的文件)来替换前面生成的root的hex文件。
8、接下来,还得用ultraedit32,分别把刚才展开的13个文件分别拷贝、粘贴。形成了新的shx文件。
9、有了自己做的shx文件,还等什么?打开你的PST,呵呵,让我一次刷个够,我刷我刷刷刷刷........
二、最近 论坛 里一直都很想弄到C5版本的shx文件,既然 moto 不放出来,难道我们不会自己做一个么?参考上面。请有C5版本的兄弟telnet进 手机 ,运行下面的命令
1、cd /
tar zcvf /mmc/mmca1/rootfs-c5.tar.gz .backup bin etc dev etc home lib sbin ezxlocal usr
2、有了这个tar.gz文件,我们就可以自己制作C5版本的680I的shx刷机文件了。
3、首先去的那个tar.gz文件,放到有linux系统的机器中,假设在/home/downloads目录中。而把680I的/
放在/home/downloads/ e680 i-c5-root目录中。
4、我们来构建/文件结构。
tar zxvf /home/downloads/rootfs-c5.tar.gz -C /home/downloads/ e680i -c5-root
cd /home/downloads/ e6 80i-c5-root
mkdir di sk a diskb ram proc
chown -R 2000:233 diska diskb
ln -sf /ram/proc proc
ln -sf /ram/var var
ln -sf /ram/tmp tmp
5、构建language这儿cramfs的包
mkcramfs usr/language/ /home/downloads/language.cramfs
6、构建setup包
mkcramfs usr/setup /home/downloads/setup.cramfs
7、rm -rf usr/language/* usr/setup/* (因为这2个目录的文件分别有language和setup包加载,就不需要打在root包里了。)
8、构建root包
mkcramfs /home/downloads/e680i-c5-root /home/downloads/rootfs.cramfs
9、得到上面3个包后,分别在windows系统下用binex转换成ASCII格式的文件,替换C3版本的shx文件中root,language,setup几个包的内容,从新再用PST刷,哈哈,一个自己做的不完整的C5版本的E680I产生了,哈哈哈。
注意:如果上面自己做的shx文件不能引导开机,也不用怕,从新用48或者51或者C3版本从新刷一下就好了
。大家大胆地刷吧。哈哈哈。
[ 本帖最后由 meakin 于 2006-5-20 09:08 编辑 ]
下面的英文我会试着逐步翻译一下,以方便致力于. shx 制作的兄弟姐妹们
备注1:Motorola S-records in EASy68K
DESCRIPTION描述
An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length. S-record文件是由一系列特别格式化的ASCII字符串组成,每个S-record文件的大小不会超过 78 字节。
The order of S-records within a file is of no significance and no particular order may be assumed.
The general format of an S-record follows:
S-record 文件的通用格式如下:
+-------------------//------------------//-----------------------+
| type | count | address | data | checksum |
+-------------------//------------------//-----------------------+
+-------------------//------------------//-----------------------+
| 类型 | count | 地址 | 数据 | checksum |
+-------------------//------------------//-----------------------+
type -- A char[2] field. These characters describe the type of record (S0, S1, S2, S3, S5, S7, S8, or S9).
count -- A char[2] field. These characters when paired and interpreted as a hexadecimal value, display the count of remaining character pairs in the record.
类型-- A
address -- A char[4,6, or 8] field. These characters grouped and interpreted as a hexadecimal value, display the address at which the data field is to be loaded into memory. The length of the field depends on the number of bytes necessary to hold the address. A 2-byte address uses 4 characters, a 3-byte address uses 6 characters, and a 4-byte address uses 8 characters.
data -- A char [0-64] field. These characters when paired and interpreted as hexadecimal values represent the memory loadable data or descriptive information.
checksum -- A char[2] field. These characters when paired and interpreted as a hexadecimal value display the least significant byte of the ones complement of the sum of the byte values represented by the pairs of characters making up the count, the address, and the data fields.
Each record is terminated with a line feed. If any additional or different record terminator(s) or delay characters are needed during transmission to the target system it is the responsibility of the transmitting program to provide them.
S0 Record. The type of record is 'S0' (0x5330). The address field is unused and will be filled with zeros (0x0000). The code/data field contains descriptive information identifying the following block of S-records as having been created by EASy68K.
S1 Record. The type of record field is 'S1' (0x5331). The address field is interpreted as a 2-byte address. The data field is composed of memory loadable data.
S2 Record. The type of record field is 'S2' (0x5332). The address field is interpreted as a 3-byte address. The data field is composed of memory loadable data.
S3 Record. The type of record field is 'S3' (0x5333). The address field is interpreted as a 4-byte address. The data field is composed of memory loadable data.
S5 Record. The type of record field is 'S5' (0x5335). The address field is interpreted as a 2-byte value and contains the count of S1, S2, and S3 records previously transmitted. There is no data field. (EASy68K does not generate this record.)
S7 Record. The type of record field is 'S7' (0x5337). The address field contains the starting execution address and is interpreted as 4-byte address. There is no data field.
S8 Record. The type of record field is 'S8' (0x5338). The address field contains the starting execution address and is interpreted as 3-byte address. There is no data field. (EASy68K always uses this termination record type.)
S9 Record. The type of record field is 'S9' (0x5339). The address field contains the starting execution address and is interpreted as 2-byte address. There is no data field.
EXAMPLE 例如
The following program was assembled with EASy68K. The .L68 file is shown. The .L68 file contains the address, machine code, line number and source code.
下面这个程序是由EASy68K装配的。
00001000 Starting Address起始地址
Assembler used: EASy68K Editor v1.9.2汇编程序使用:EASy68K Editor v1.9.2编辑器
Created On: 1/28/2004 4:51:58 PM生成日期:1/28/2004 4:51:58 PM
Address Machine Code Line Source Code
地址 机器代码 行 源代码
00000000 1 *-----------------------------------------------------------
00000000 2 * Program Number: S-Record demo for EASy68k
00000000 3 * Written by : Chuck Kelly
00000000 4 * Date Created : Jan-28-2004
00000000 5 * Description : demonstrate the S-Record file format used by EASy68K.
00000000 6 *
00000000 7 * This program is public domain.
00000000 8 *-----------------------------------------------------------
00000000 9
00001000 10 START ORG $1000 the program will load into address $1000
00001000 123C 0003 11 move.b #3,d1 put 3 in low byte of data register D1
00001004 5A01 12 add.b #5,d1 add 5 to low byte of data register D1
00001006 13 * Display string textD1
00001006 303C 000E 14 move #14,d0 load task number into D0
0000100A 43F9 00044446 15 lea textD1,a1 load address of string to display into A1
00001010 4E4F 16 trap #15 trap #15 activates input/output task
00001012 17 * Display D1 as a number
00001012 303C 0003 18 move #3,d0 task number 3 into D0
00001016 19 * task number 3 is used to display the contents of D1.L as a number
00001016 4E4F 20 trap #15 display number in D1.l
00001018 4EB9 00022222 21 jsr newLine
0000101E 22 * Stop execution
0000101E 4E72 2000 23 STOP #$2000
00001022 24
00022222 25 org $22222 this subroutine is located at address $22222
00022222 26 * Subroutine to display Carriage Return and Line Feed
00022222 27 newLine:
00022222 48E7 8040 28 movem.l d0/a1,-(a7) push d0 & a1
00022226 303C 000E 29 move #14,d0 task number into D0
0002222A 43F9 00044462 30 lea crlf,a1 address of string
00022230 4E4F 31 trap #15 display return, linefeed
00022232 4CDF 0201 32 movem.l (a7)+,d0/a1 restore d0 & a1
00022236 4E75 33 rts return
00022238 34
00044444 35 org $44444 this data is located at address $44444
00044444 36 sum2 ds.w 1 reserve word of memory for sum2
00044446 44 31 20 63 6F 6E ... 37 textD1 dc.b 'D1 contains: ',0 null terminated string
00044454 44 32 20 63 6F 6E ... 38 textD2 dc.b 'D2 contains: ',0 null terminated string
00044462 0D 0A 00 39 crlf dc.b $d,$a,0 carriage return & line feed, null
00044465 40
00044465 41 */\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
00044465 42 * E R R O R E R R O R E R R O R E R R O R E R R O R
00044465 43 */\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
00044465 44 * EASy68K does not support addresses beyond $FFFFFF or 16MBytes
00044465 45 * Comment out the following org directive if you want to run this program.
12345678 46 org $12345678
12345678 69 6E 76 61 6C 69 ... 47 junk dc.b 'invalid address'
12345687 48
12345687 49 END START end of program with start address specified
The S-record file created from the above program follows:.
S021000036384B50524F47202020313143524541544544204259204541535936384B6D
S1251000123C00035A01303C000E43F9000444464E4F303C00034E4F4EB9000222224E72200004
S21A02222248E78040303C000E43F9000444624E4F4CDF02014E75C2
S223044446443120636F6E7461696E733A2000443220636F6E7461696E733A20000D0A009A
S31412345678696E76616C69642061646472657373EA
S804001000EB
The S0 Record contains the following information:
/-version number
module name / /-revision number checksum
S0 0000 6 8 K P R O G 1 1 C R E A T E D B Y E A S Y 6 8 K /
S021000036384B50524F47202020313143524541544544204259204541535936384B6D
The version and revision number refer to the EASy68K S-Record file type, not the product version.
The file consists of one S0 record, one S1 record, two S2 records, one S3 record and an S8 record.
The first S1 record is comprised as follows:
S1 25 1000 123C00035A01303C000E43F9000444464E4F303C00034E4F4EB9000222224E722000 04
S1 S-record type, indicating it is a data record to be loaded at a 2-byte address.
25 Hexadecimal (decimal 37), indicating that thirty-seven character pairs, representing a 2 byte address, 34 bytes of binary data, and a 1 byte checksum, follow.
1000 Four character 2-byte address field; hexadecimal address $1000, where the data which follows is to be loaded.
123C00035A01... 34 character pairs representing the actual binary data.
04 The checksum.
The first S2 record is comprised as follows:
S2 1A 022222 48E78040303C000E43F9000444624E4F4CDF02014E75 C2
S2 S-record type, indicating it is a data record to be loaded at a 3-byte address.
1A Hexadecimal (decimal 26), indicating that twenty-six character pairs, representing a 3 byte address, 22 bytes of binary data, and a 1 byte checksum, follow.
022222 Six character 3-byte address field; hexadecimal address $022222, where the data which follows is to be loaded.
48E78040303C... 22 character pairs representing the actual binary data.
C2 The checksum.
The second S2 record contains additional data which is to be loaded at address $044446
The first S3 record is comprised as follows:
S3 14 12345678 696E76616C69642061646472657373 EA
S3 S-record type, indicating it is a data record to be loaded at a 4-byte address.
14 Hexadecimal (decimal 20), indicating that twenty character pairs, representing a 4 byte address, 15 bytes of binary data, and a 1 byte checksum, follow.
12345678 Eight character 4-byte address field; hexadecimal address $12345678, where the data which follows is to be loaded.
696E76616C69... 15 character pairs representing the actual binary data.
EA The checksum.
The S8 record is comprised as follows:
S8 04 001000 EB
S8 S-record type, indicating it is a termination record with a 3-byte address.
04 Hexadecimal (decimal 4), indicating that four character pairs follow.
001000 The address field, hexadecimal address $001000 indicating the starting execution address.
EB The checksum.
EASy68K always uses the S8 record.
备注2:mount 命令详解
简单用法:
fat32的分区
mount -o codepage=936,iocharset=cp936 /dev/hda7 /mnt/cdrom (mount -t vfat -o iocharset=cp936 /dev/hda7 /mnt/cdrom)
ntfs的分区
mount -o iocharset=cp936 /dev/hda7 /mnt/cdrom
iso文件
mount -o loop /abc.iso /mnt/cdrom
软盘
mount /dev/fd0 /mnt/floppy
USB闪存
mount /dev/sda1 /mnt/cdrom
所有/etc/fstab内容 mount -a
可以指定文件格式"-t 格式", 格式可以为vfat, ext2, ext3等.
镜像文件:
mount fileName mountPoint -o loop,fileName是镜像文件名(*.iso,*.img),其它的不用说了,跟上面一样。用例:如我有一个a.iso光盘镜像文件,mount a.iso a -o loop,这样进入目录a你就能浏览a.iso的内容了,*.img文件的用法一样。
显示中文方面,如果是fedora core 1 的话,用utf8更好
mount -o iocharset=uft8 /dev/hda1 /mnt/c
mount -o iocharset=uft8 /dev/sda1 /mnt/usb
mount -t smbfs //ip_addr/share/dir /mnt/smb/share -o iocharset=uft8,username=name, password=passwd
开机就mount上windows下的分区
自动将windows的d盘挂到/mnt/d上,用vi打开/etc/fstab,加入以下一行
/dev/hda5 /mnt/d vfat defaults,codepage=936,iocharset=cp936 0 0
注意,先得手工建立一个/mnt/d目录
mount局域网上其他windows机器共享出的目录(bjchenxu)
mount -t smbfs -o username=guest,password=guest //machine/path /mnt/cdrom
备注3: mount意思是 “架设”
[ 本帖最后由 meakin 于 2006-6-24 13:16 编辑 ]