forked from mirror/firmware-mod-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firmware_mod_kit.htm
919 lines (898 loc) · 40.1 KB
/
firmware_mod_kit.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
<html>
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Firmware Modification Kit</title>
<meta name="description" content="Extract, Modify, Rebuild Firmware Images of various types" />
<meta name="keywords" content="dd-wrt, ddwrt, openwrt, freewrt, squashfs, squashfs-lzma, hyperwrt, sveasoft, tomato, xwrt, x-wrt, firmware, binwalk, unsquashfs, wrt54g, wl530g, tew632brp, dir615, untrx, trx" />
</head>
<body>
<p><b><font size="6">Firmware Modification Kit<br />
</font></b><i><b>Giving YOU the power to customize your firmware<br />
</b><font size="2">documentation version 0.78 beta<br />
all scripts, untrx, wrt_vx_imgtool, crcalc, binwalk and docs (c) 2006-2011<br />
Craig Heffner <[email protected]>, Jeremy Collake <[email protected]>, and other contributors (see project page) <br />
other portions (c) their respective holders</font></i></p>
<p><b><span class="highlight"><b>THERE ARE NEW DOCS:</b></span> This documentation may be superseded or extended by documentation at the <a href="http://code.google.com/p/firmware-mod-kit/wiki/Documentation">Google Code project site</a>. An essentially new, and much improved, rendition is now available. Firmware-Mod-Kit-Ng ;)</b></p>
<p><b><font size="4">Contents</font></b></p>
<p>I. <a href="#Description">Description</a><br />
II. <a href="#Why_is_this_useful">Why is this useful?</a><br />
III. <a href="#Where_to_get_the_kit">Where to get the kit</a><br />
IV. <a href="#Requirements">Requirements</a><br />
V. <a href="#Compatibility">Compatibility</a><br />
VI. <a href="#Instructions">Instructions</a><br />
A. <a href="#Extracting_the_firmware_(extract_firmware.sh)">
extracting firmware</a><br />
B.
<a href="#Modifying_the_firmware_(manual_and/or_ipkg_install.sh)">modifying
firmware</a><br />
1.<a href="#Installing_packages">
installing packages</a><br />
2. <a href="#Removing_packages">
removing packages</a><br />
C. <a href="#Re-building_the_firmware_(build_firmware.sh)">
re-building firmware</a><br />
VII. <a href="#Caveats">Caveats</a><br />
A. <a href="#Binary_compatibility_issues">binary
compatibility issues</a><br />
B. <a href="#Maximum_firmware_size">maximum firmware size</a><br />
C. <a href="#Solutions_to_case_sensitivity">solutions to file
system incompatibilities</a><br />
VIII. <a href="#Acknowledgments">Acknowledgements and more</a><br />
IX. <a href="#Links">Links</a><br />
X. <a href="#Revision_history">Revision history</a><br />
<p> </p>
<p><font size="5"><b>I. <a name="Description">Description</a></b><br />
</font><br />
This kit gives the user the ability to make changes to a firmware image without
recompiling the firmware sources. It works by extracting the firmware into
its component parts, then extracting the file system image (assuming its in one
the supported formats). The user can then make modifications
to the extracted file system, and rebuild the firmware image.</p>
<p>Although this kit completely automates the process, it is also useful for
those who need a handy collection of utilities to manipulate firmware images. The following utilities are included in this kit, along with scripts to
automate their use:</p>
<table border="1" width="100%" id="table8">
<tr>
<td><b>ASUSTRX</b></td>
<td width="1457">An extended version of ASUSTRX that can build both
'normal' TRX files and, optionally, those with an ASUS <b><i>addver </i>
</b>style header appended. It can also, uniquely, force segment offsets
in the TRX (with -b switch) for compatibility with Marvell ASUS devices
like the WL-530g.
This tool replaces both 'normal' trx tool and addver. Current versions
included are: 0.90 beta.</td>
</tr>
<tr>
<td height="23"><b>ADDPATTERN</b></td>
<td height="23" width="1457">Utility to pre-pend Linksys style HDR0
header to a TRX.</td>
</tr>
<tr>
<td><b>ADDVER</b></td>
<td width="1457">ASUS utility to append a header to a TRX image that
contains version information. ASUSTRX includes this capability. Current
version: unversioned.</td>
</tr>
<tr>
<td><b>BINWALK</b></td>
<td width="1457">Firmware analysis tool, used for searching firmware images
for known file types. Used by the extract-ng.sh script to identify valid
file systems inside firmware images. Current version included is 0.3.9.
Tool home page: http://binwalk.googlecode.com.</td>
</tr>
<tr>
<td><b>CRAMFSCK</b></td>
<td width="1457">CRAMFS file system image checker and extractor. Current
versions included are: 2.4x.</td>
</tr>
<tr>
<td><b>CRCALC</b></td>
<td width="1457">Re-calculates and patches header checksums for TRX and
uImage firmware headers.</td>
</tr>
<tr>
<td height="23"><b>MKSQUASHFS</b></td>
<td height="23" width="1457">Builds a squashfs file system image.
Current versions included are: 2.1-r2, 3.0.</td>
</tr>
<tr>
<td height="25"><b>MKCRAMFS</b></td>
<td width="1457" height="25">Builds a cramfs file system image. Coming
in next version. Current versions included are: 2.4x.</td>
</tr>
<tr>
<td><b>MOTOROLA_BIN</b></td>
<td width="1457">A utility that prepends 8 byte headers to TRX images
for Motorola devices WR850G, WA840G, WE800G. Current version:
unversioned.</td>
</tr>
<tr>
<td><b>UNCRAMFS</b></td>
<td width="1457">Alternate tool to extracts a cramfs file system image.
Use cramfsck instead whenever possible as it seems to be more reliable. Current versions
included are: 0.7 (for cramfs v2.x).</td>
</tr>
<tr>
<td><b>UNCRAMFS-LZMA</b></td>
<td width="1457">Extracts an lzma cramfs file system image, specifically
those included in OpenRG based firmware. Current version included is 0.7rg.</td>
</tr>
<tr>
<td><b>UNSQUASHFS</b></td>
<td width="1457">Extracts a zlib squashfs file system image. Current
versions included are 1.0 for 3.0 images and 1.0 for 2.x images (my own
blend).</td>
</tr>
<tr>
<td><b>UNSQUASHFS-LZMA</b></td>
<td width="1457">Extracts an lzma squashfs file system image. Current
versions included are 1.0 for 3.0 images and 1.0 for 2.x images (my own
blend). <i>Note: Not all squashfs-lzma patches are compatible with one
another. I'm working on adding support for all common squashfs-lzma
variations.</i></td>
</tr>
<tr>
<td><b>UNTRX</b></td>
<td width="1457">Splits TRX style firmwares into their component
parts. Also supports pre-pended addpattern HDR0 style headers. This was
developed exclusively for this kit. Current versions included are: 0.45.</td>
</tr>
<tr>
<td height="23"><b>WRT_VX_IMGTOOL</b></td>
<td width="1457" height="23">Utility to generate VxWorks compatible
firmware images for the WRT54G(S) v5 series.</td>
</tr>
</table>
<p> </p>
<p><b><font size="4">Tools/changes unique to this kit</font></b></p>
<p>This kit doesn't just collect existing tools, it also offers new ones and
modifications to existing ones. Custom code currently is:</p>
<p><b>ASUSTRX</b> - Modified to allow '-b' switch to force segment offsets
(needed for some devices, like the WL-530g).<br />
<b>CRCALC</b> - A new tool to re-calculate and patch the checksum fields for common
firmware headers. Currently TRX and uImage headers are supported.<br />
<b>UNTRX</b> - A new tool to extract the contents of a TRX image into its component
parts.<br />
<b>UNSQUASHFS</b> - Custom blend that supports extraction of 2.x squashfs
images. This tool wasn't officially made available until squashfs 3.0, so up
until now it wasn't available for 2.x images.<br />
<b>WRT-VX-IMGTOOL</b> - A new tool to view, extract, build, and fix VxWorks
compatible firmware images for the WRT54G(S) v5 series.<br />
<b>SPLITTER3</b> - Custom file splitter for certain types of linux firmware images.
</p>
<p><b><font size="5">II. <a name="Why_is_this_useful">Why is this useful?</a></font></b><br />
<br />
A list of some of the many reasons this might be desired are:</p>
<ul>
<li>add initialization scripts</li>
<li>install new packages</li>
<li>extend/change HTTP managed console</li>
<li>remove un-needed packages</li>
<li>mix-and-match packages from various flavors of the firmware image.</li>
</ul>
<p>
<br />
</p>
<p><b><font size="5">III. <a name="Where_to_get_the_kit">Where to get the ki</a>t</font></b></p>
<p>The best way to download and use this kit is to check out the sources from
the repository. The automated scripts all automatically build the executables,
and the sources. It is easy as downloading something and using it that way. Also, if you are unable to use a simple SVN checkout, then
it is likely that this kit is a danger to you because it is for advanced users. </p>
<p>To anonymously check out the firmware-mod-kit:</p>
<table border="0" width="100%" id="table9" bgcolor="#F6F4EC">
<tr>
<td><font face="Courier New"> mkdir firmware_mod_kit<br />
cd firmware_mod_kit<br />
svn checkout http://firmware-mod-kit.googlecode.com/svn/trunk/ firmware-mod-kit-read-only</font></td>
</tr>
</table>
<p><br />
<b><font size="4">Kit downloads and links:</font></b></p>
<p>Project hosting and repository (new):
<a href="http://code.google.com/p/firmware-mod-kit/">
http://code.google.com/p/firmware-mod-kit/</a><br />
Guest SVN Checkout: <i>svn checkout http://firmware-mod-kit.googlecode.com/svn/trunk/ firmware-mod-kit-read-only</i><br />
User forums can be found <a href="http://www.bitsum.com/forum/index.php?board=12.0">
here</a>.</p>
<p><b><font size="4">Packages:</font></b></p>
<p>All of the many OpenWrt packages should work with OpenWrt images and many
other firmware images.</p>
<p>An old (2009) specific collection of DD-WRT packages for use with the kit:
<a href="http://www.bitsum.com/files/ddwrt_packages.tar.gz">
http://www.bitsum.com/files/ddwrt_packages.tar.gz</a> .<br />
</p>
<p> </p>
<p><b><font size="5">IV. <a name="Requirements">Requirements</a></font></b></p>
<p>I've worked to make sure the requirements are low enough for anyone to
use this kit. However, to reduce distribution costs and better represent the
multi-platform capabilities of this kit, the binary tools in the kit do
automatically build themselves the first time you run one of the scripts. Any
machine set up to build anything C or C++ on the machine will probably be ready.
The few requirements are all basic items that everyone has easy access to:</p>
<ul>
<li>A compatible platform. The following are specifically supported (or
specifically unsupported):<ul>
<li><b>LINUX </b>(recommended)</li>
<li><b>OS X </b> <i> **warning:
I don't test every build under OS X. It's up to you to email me if you have
problems under it. Current builds may have issues.**</i></li>
<li>CYGWIN <i>**alpha stage testing (!! built firmwares may not boot
!!)**</i></li>
</ul>
</li>
<li>GNU C (gcc)</li>
<li>GNU C++ (g++)</li>
<li>GNU make</li>
<li>Standard C runtime library development</li>
<li>Standard C++ runtime library development</li>
<li>Zlib library development (for Ubuntu it is zlib1g-dev)</li>
<li>TAR and GZIP (optional, used by ipkg_install.sh)</li>
</ul>
<p>OS/X is not supported at this time. The kit is probably not far from compatibility, but easier to just install a linux VM.</p>
<p></p>
<p><b><font size="5">V. <a name="Compatibility">Compatibility</a></font></b></p>
<p>Any TRX style firmware image format should that uses squashfs-lzma as a root
file system work fine. Firmwares that use regular zlib squashfs or unsupported
file systems will work if the steps that extract the file system and rebuild the
file system are tweaked. </p>
<p>The kit can build firmware images for the following devices, amongst <u>many
others</u>:</p>
<ul>
<li>WRT54G v1 - v6</li>
<li>WRT54GS v1 - v6</li>
<li>WRTSL54G v?</li>
<li>ASUS WL-330g</li>
<li>ASUS WL-500g/p</li>
<li>ASUS WL-520g</li>
<li>ASUS WL-530g</li>
<li>Belkin 7230-4 (some versions)</li>
<li>Belkin 7231-4 (?)</li>
<li>Buffalo WHR-G54S</li>
<li>Buffalo WHR-HP-G54</li>
<li>Siemens SE505</li>
<li>Trendnet TEW-632BRP</li>
<li>D-Link DIR-615 (maybe)</li>
<li>... lots of others<font size="2">*</font> ...</li>
</ul>
<p>The kit is known (or thought) to be compatible with the following firmwares:</p>
<table border="0" width="100%" id="table3">
<tr>
<td width="187">DD-WRT v23</td>
<td>tested - versions v23 SP1 and later are compatible (soon older
versions too). <b>WARNING:</b> <i>Builds of
DD-WRT later than 08/04/2006 (v23 SP2) have some protections against
changing the web UI.</i></td>
</tr>
<tr>
<td width="187">DD-WRT v24</td>
<td>tested</td>
</tr>
<tr>
<td width="187">OpenWrt White Russian</td>
<td>tested</td>
</tr>
<tr>
<td width="187">OpenWrt Kamikaze</td>
<td><i>untested (should work) </i>- not really necessary, based on
OpenWrt has its Image Builder.</td>
</tr>
<tr>
<td width="187">FreeWrt</td>
<td><i>untested - should work ok</i></td>
</tr>
<tr>
<td width="187">HyperWrt</td>
<td><i>untested </i></td>
</tr>
<tr>
<td width="187">Ewrt</td>
<td><i>untested</i></td>
</tr>
<tr>
<td width="187">Sveasoft Alchemy</td>
<td><i>untested </i></td>
</tr>
<tr>
<td width="187">Sveasoft Talisman</td>
<td><i>untested </i></td>
</tr>
<tr>
<td width="187">Linksys / other vendor</td>
<td>not supported by scripts yet - haven't added cramfs handling</td>
</tr>
<tr>
<td width="187">ASUS WL-330G</td>
<td><i>untested - should work ok</i></td>
</tr>
<tr>
<td width="187">ASUS WL-520G</td>
<td><i>untested - should work ok</i></td>
</tr>
<tr>
<td width="187">ASUS WL-530G</td>
<td>supported</td>
</tr>
<tr>
<td width="187">ASUS WL-550G</td>
<td><i>untested - should work ok</i></td>
</tr>
<tr>
<td width="187">Trendnet TEW-632BRP</td>
<td>tested</td>
</tr>
<tr>
<td width="187">DLink DIR-615</td>
<td><i>untested</i></td>
</tr>
<tr>
<td width="187">many others<font size="2">*</font></td>
<td><i>untested </i></td>
</tr>
</table>
<p><b><i>* Even if the kit doesn't automatically support the firmware or device you want,
you can manually use the tools inside to manipulate many firmware images, or
request support be added.</i></b></p>
<p> </p>
<p><b><font size="5">VI. <a name="Instructions">Instructions</a><br />
</font></b><br />
I've scripts that simply and abstract the firmware modification process. Basically, it's a
one-step process to extract the firmware, and a one-step process to rebuild the
firmware. There are also scripts to install or remove individual packages or
entire directories of packages.</p>
<p>The procedure of calls is:</p>
<ol>
<li>extract_firmware.sh ....</li>
<li>(optional) ipkg_install[_all]).sh ...</li>
<li>(optional) ipkg_remove[_all].sh ...</li>
<li>build_firmware.sh</li>
</ol>
<p> </p>
<p><u><b><font size="4">A.
<a name="Extracting_the_firmware_(extract_firmware.sh)">Extracting the firmware
(extract_firmware.sh, extract-ng.sh)</a></font></b></u></p>
<blockquote>
<p>Simply run extract_firmware.sh with the following parameters. <i><b>You must
run this tool from inside the directory it exists in.</b></i></p>
<table border="0" width="100%" bgcolor="#F6F4EC" id="table1">
<tr>
<td><br />$ ./extract_firmware.sh firmware.bin working_directory/<br /> </td>
</tr>
</table>
<p><br /><b>- firmware.bin</b> is the firmware image you want to extract, i.e.
DD-WRT.v23_MICRO_GENERIC.BIN. <br /><b>- working_directory</b> is the working directory you want to use. This is
where the intermediate files and the extracted file system will be stored. Note
that files in the working directory may be deleted!<br /><br />It doesn't matter which firmware image you supply, i.e. for a WRT54G or an ASUS
WL-500G. These images are usually all the same and differ only in the header
format. The rebuilding process will create images for the various models.<br />
<br />An extraction log is created as <i>extract.log</i>.</p>
<p>If extract_firmware.sh fails, the newer extract-ng.sh can be used. Although newer and
less thoroughly tested than extract_firmware.sh, it is more flexible and can often
extract file systems that extract_firmware.sh cannot:
</p>
<table border="0" width="100%" bgcolor="#F6F4EC" id="table3">
<tr>
<td><br />$ ./extract-ng.sh firmware.bin working_directory/<br /> </td>
</tr>
</table>
</blockquote>
<p> </p>
<p><b><font size="4"><u>B.
<a name="Modifying_the_firmware_(manual_and/or_ipkg_install.sh)">Making changes
to the firmware's file system</a></u></font></b></p>
<blockquote>
<p>Modifying the firmware is simple. The file system is stored in the working
directory you supplied to extract_firmware.sh. Here are the subfolders of this
directory:<br /><br /> <b>rootfs/ <br />
</b>This is where the file system is.
Make modifications here.<br /> <b>image_parts/ <br />
</b>This is where intermediate files are stored. If you need to replace the
kernel (not at all recommended), you can do so by replacing the appropriate
file here (usually segment2).<br />
<b> installed_packages/<br />
</b>If you use the ipkg_install.sh
tool, this is where packages you've installed after firmware extraction will
reside.<br /><br />One can manually change the files in rootfs and/or use the
automated package scripts.</p>
<p> </p>
<p><b><a name="Installing_packages">Installing packages</a> (.IPK)</b></p>
<blockquote>
<p>In compliment to manually making changes, one can use pre-built IPKG
format package files with the ipkg_install/remove scripts. Although not
all will work and a repository for packages verified to work has not yet
been produced, many packages work just fine.</p>
<p>Packages are pre-built collections of files pertaining to a set of software.
OpenWrt and DD-WRT both use packages, and most are cross-compatible. These
packages are stored in a tar/gzip archive of a pre-defined structure that
includes some control files. You can extract and copy the files manually, or use
the ipkg_install.sh script included with this kit. For a list of some of the
available packages (not all may work), see
<a href="http://downloads.openwrt.org/whiterussian/packages/">
http://downloads.openwrt.org/whiterussian/packages/</a> and
<a href="http://ftp.selfnet.de/pub/openwrt/backports/rc5/">http://ftp.selfnet.de/pub/openwrt/backports/rc5/</a> .
<i>We are currently in the process of compiling a set of packages known
to be good for DD-WRT ... to help in this matter please visit
<a href="http://www.dd-wrt.com/phpBB2/viewtopic.php?t=2844">here</a>.
</i></p>
<p><i>For information on how to create IPKs, see the
<a href="creating_ipk_packages.htm">IPK Creation Kit</a>.</i></p>
<p>Example use:</p>
<table border="0" width="100%" bgcolor="#F6F4EC" id="table6">
<tr>
<td><br />$ ./ipkg_install.sh some_package-1.2.5.ipk working_directory/<br /> </td>
</tr>
</table>
<p><b>some_package-1.2.5.ipkg </b>would be the filename of the package.<br />
<b>working_directory</b> is the same working directory you supplied to the
extract_firmware.sh script.</p>
<p><b>Notes:</b></p>
<p>A script, ipkg_install_all.sh is also available to install an entire
folder of packages.</p>
<p>The collection of installed packages will be stored in <b><i>
working_directory/installed_packages </i></b>.</p>
</blockquote>
<p> </p>
<p><b><a name="Removing_packages">Removing packages</a> (.IPK)</b></p>
<blockquote>
<p>To remove packages there is the ipkg_remove.sh script. </p>
<p>Example use:</p>
<table border="0" width="100%" bgcolor="#F6F4EC" id="table7">
<tr>
<td><br />$ ./ipkg_remove.sh some_package-1.2.5.ipk working_directory/<br /> </td>
</tr>
</table>
<p><b>some_package-1.2.5.ipkg </b>would be the filename of the package.<br />
<b>working_directory</b> is the same working directory you supplied to the
extract_firmware.sh script.</p>
<p><b>Notes:</b></p>
<p>A script, ipkg_remove_all.sh is also available to install an entire
folder of packages.</p>
<p>The collection of installed packages stored <b><i>
working_directory/installed_packages </i></b>will be updated to reflect
the change if successful.</p>
</blockquote>
<p> </p>
</blockquote>
<p><b><font size="4"><u>C.
<a name="Re-building_the_firmware_(build_firmware.sh)">Re-building the firmware
(build_firmware.sh, build-ng.sh)</a></u></font></b></p>
<blockquote>
<p>Rebuilding the firmware is as easy as extracting it. Use the
build_firmware.sh script to automate the process. <i><b>You must run this
tool from inside the directory it exists in.</b></i></p>
<p>Example use:</p>
<table border="0" width="100%" bgcolor="#F6F4EC" id="table2">
<tr>
<td><br />$ ./build_firmware.sh output_directory/ working_directory/<br /> </td>
</tr>
</table>
<p><b>- output_directory</b> is the path to which the created firmware images
should be stored. If images already exist here, they will be over-written.
Firmware images for various models will be emitted (these images are all the
same but have different header patterns so they are accepted by the target
models).<br /><b>- working_directory</b> is the working directory supplied to
extract_firmware.sh.</p>
<p>A building log is created as <i>build.log</i>.</p>
<p>
If extract-ng.sh was used to extract the firmware image, build-ng.sh must be used
to rebuild it:
</p>
<table border="0" width="100%" bgcolor="#F6F4EC" id="table4">
<tr>
<td><br />$ ./build-ng.sh working_directory/<br /> </td>
</tr>
</table>
</blockquote>
<p> </p>
<p><font size="5"><b>VIII. <a name="Caveats">Caveats</a></b></font></p>
<p>There are a few things to watch out for when modifying firmware images. If
you make reasonable changes these problems will probably never affect you. Be
warned, this section may be technical in parts.</p>
<p><b>A. <a name="Binary_compatibility_issues">Binary compatibility issues</a></b></p>
<ul>
<li>If installing a <b>binary</b> package:
<ul>
<li>It is possible the uclibc or glibc library was pruned (unused
objects removed). In the unlikely event the binary package requires some of these
previously unused (and now missing) functions, you may need to install
to the firmware file system a new uclibc or glibc library. If you are
installing another pruned uclibc or glibc library, then it is remotely
possible some pre-existing package requires objects not found in this
new library. In such a very rare case you can re-link the library or
find a full copy of the library to install.</li>
<li>Different firmwares may use different kernel versions, or have
different kernel modules installed. If you get too wild with your
mix-and-matching (i.e. use older versions with newer, or mixtures of
different firmwares all-together), problems can result. To install a new
kernel (not at all recommended), replace the segment2 (or other) file found found in
the intermediate directory with an appropriate one (can be from another
firmware as long as lzma compression is used).</li>
<li>Make sure any dependencies are also installed to the file system,
along with initialization scripts.</li>
</ul></li>
<li>If making web UI changes:<ul>
<li><b>WARNING:</b> DD-WRT builds dated later than 08/04/2006
have some protections against modifying the web UI.</li>
</ul>
<p> </p></li>
</ul>
<p><b>B. <a name="Maximum_firmware_size">Maximum firmware size</a></b></p>
<p>Currently, the maximum firmware image size supported by this kit is 5,898,240
(0x5A0000) bytes, but can be adjusted through the "-m [size]" parameter of the
asustrx tool.</p>
<p><br />
<b>C. <a name="Solutions_to_case_sensitivity">Solutions to file system
incompatibilities</a></b></p>
<p><b>! This section is very much a work in progress !</b></p>
<p>The squashfs file system is case sensitive (i.e. teSt.bin ! = test.bin) and
adheres to EXT2 naming rules. To support proper extraction of the file system,
the working directory should be on a case sensitive file system and support
symbolic links. The scripts
will warn you if you attempt to use as working directory on a case INsensitive
file system. You'll see a number of errors if you extract to a file system that
doesn't support symbolic links.</p>
<p><b>Note:</b> <i>Case insensitivity doesn't always cause problems,</i> especially if the file
system preserves case ok. It depends on the firmware and version. Most of the
time for DD-WRT as long as a case preserving file system is used as a working
directory, all should work fine.</p>
<p>These solutions apply to those using CYGWIN, or some other environment
that may not have a case sensitive file system by default. Linux users typically
do not have this problem since EXT2 and EXT3 file systems are case sensitive.
</p>
<p><br />
<b>WARNING: THESE ARE IN EARLY STAGES OF TESTING AND MAY NOT WORK.</b></p>
<table border="1" width="100%" id="table4" cellpadding="5">
<tr>
<td width="127" height="33"> </td>
<td width="162" height="33"><b>Applies to</b></td>
<td height="33"><b>Description</b></td>
</tr>
<tr>
<td width="127" valign="top"><b>SOLUTION 1</b></td>
<td width="162" height="30" valign="top">CYGWIN, OTHER</td>
<td height="30" valign="top"><b>It's reported this does not work under
CYGWIN</b> due to the CYGWIN utilities all being case INsensitive
(thanks pagedude).<br />
<br />
Use a network share to a case sensitive file system. This is, by far,
the easiest solution. Simply use an appropriate network share for the
working directory.<br />
</td>
</tr>
<tr>
<td width="127" height="30" valign="top"><b>SOLUTION 2</b></td>
<td width="162" valign="top">CYGWIN</td>
<td valign="top"><br />
For NT partitions it's reported you can enable case sensitivity through
the following registry key, but <b>I do not know if this works or not</b>.<p> \HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\kernel\obcaseinsensitive [REG_DWORD] = 0<br />
</td>
</tr>
<tr>
<td width="127" height="31" valign="top"><b>SOLUTION 3</b></td>
<td width="162" height="31" valign="top">OS X (not usually needed, at
least for DD-WRT)</td>
<td height="31" valign="top"><br />
One can either
<a href="http://www.macosxhints.com/article.php?story=200502011939237">
Turn on HSFX</a> for the boot disk, or (more easily) create a temporary
HSFX case sensitive file system to use as a working directory.<p>Example
of how to create a temporary HSFX case sensitive file system:<br />
<br />
<i>to create:<br />
</i>$ hdiutil create -size 20m -fs HFSX -volname db90h -nouuid
test-image <br />
<i>to mount:<br />
</i>$ hdiutil attach test-image.dmg <br />
<i>to un-mount:</i><br />
$ hdiutil detach /Volumes/db90h </p>
<p>(thanks solarflare for this information)<br />
</td>
</tr>
<tr>
<td width="127" valign="top"><b>SOLUTION 4</b></td>
<td width="162" valign="top">CYGWIN<br />
</td>
<td valign="top"><br />
Mount an ext2 files system. Eko, of DD-WRT forums, contributes this tip.
Make a partition on a hard drive or USB thumb drive, then install "<a href="http://www.fs-driver.org/">Ext2
Installable File System For Windows</a>". 10MB should generally be
plenty of working directory space, but 20MB is suggested for more
optimal file system performance.<br />
</td>
</tr>
</table>
<p> <b> </b></p>
<p><font size="5"><b>IV</b></font><b><font size="5">. <a name="Acknowledgments">
Acknowledgments</a> and more </font></b></p>
<p>The authors and maintainers of this kit are Jeremy Collake (db90h) and Craig Heffner.
Special thanks to Solarflare, TexHex <<a href="mailto:[email protected]">[email protected]</a>>,
and others.</p>
<p>If YOU would like to contribute to this kit, send me an email at
<a href="mailto:[email protected]">[email protected]</a> or visit
the current project hosting at
<a href="http://code.google.com/p/firmware-mod-kit/">
http://code.google.com/p/firmware-mod-kit/</a> . Developers are welcome.</p>
<p> </p>
<p><b><font size="5">X. <a name="Links">Links</a></font></b></p>
<ul>
<li><i> <a href="creating_ipk_packages.htm">IPK Creation Kit</a> (alpha
testing)</i></li>
</ul>
<p> </p>
<p><b><font size="5">X. <a name="Revision_history">Revision history</a></font></b></p>
<p>0.73</p>
<ul>
<li>New pre-req check and more modern build system (by Craig)</li>
</ul>
<p>0.72</p>
<ul>
<li>Fix for recent updates to linux build tools that mandated different command line ordering (by Craig)</li>
</ul>
<p>0.64-0.71</p>
<ul>
<li>See Google Code</li>
<li>NG edition created by Craig Heffner (total new generation of kit)</li>
</ul>
<p>0.63</p>
<ul>
<li>Added support for a new raw linux type of firmware (completely untested on the rebuild side flash, so beware)</li>
<li>Added new splitter3.cc to split up this linux raw firmware type into its segments</li>
<li>Other misc tweaks</li>
</ul>
<p>0.60</p>
<ul>
<li>Fixed issue with non-standard du switches, i.e. under OS X.</li>
<li>Fixed untrx inability to recognize squashfs signatures on big endian systems (patch from Jaifu Gao)</li>
</ul>
<p>0.58</p>
<ul>
<li>Removed multi-threaded brute testing of LZMA compression params from the 'damn small' variant DD-WRT v24 uses. This may fix some
reported problems of failed thread creation.</li>
</ul>
<p>0.56</p>
<ul>
<li>Add support DD-WRT v24 firmware images</li>
<li>New unsquashfs variant written for DD-WRT v24</li>
<li>Cleanup script output indentation, it was quite sloppy</li>
<li>Apply some fixes and other tweaks</li>
</ul>
<p>0.54</p>
<ul>
<li>Add support for Trendnet TEW-632BRP images</li>
<li>Add support for OpenWrt White Russian images</li>
<li>Don't force root user, just warn</li>
<li>Other maintenance and tweaks</li>
</ul>
<p>0.51</p>
<ul>
<li>Increased maximum supported size of TRX images (now can handle > 4MB images).</li>
</ul>
<p>0.50</p>
<ul>
<li>Removed unnecessary -lz parameter (zlib) from gcc.</li>
</ul>
<p>0.49</p>
<ul>
<li>unsquashfs: created first ever (afaik) blend of unsquashfs for squashfs
2.x images.</li>
<li>mksquashfs: added 2-1.r2. Script support remains todo.</li>
<li>other misc. changes.</li>
</ul>
<p>0.48</p>
<ul>
<li>scripts: now use cramfsck -x to extract cramfs images instead of
uncramfs. uncramfs proved to fail to extract some images.</li>
<li>dirs: renamed cramfs-1.1 to cramfs-2.x to reflect the accurate version
number.</li>
</ul>
<p>0.471</p>
<ul>
<li>motorola_bin: added source code.</li>
</ul>
<p>0.47</p>
<ul>
<li>wrt_vx_imgtool: added this utility, which can build, extract, view, and
fix firmware images for WRT54G(s) v5/v6 series running VxWorks.</li>
<li>motorola_bin: added this binary only (linux) utility. Build script
doesn't invoke it yet, but it's easy to use for those who need it.</li>
<li>untrx: minor memory leak fixed.</li>
<li>docs: added some device compatibility notes and other edits.</li>
</ul>
<p>0.46:</p>
<ul>
<li>scripts: added support for cramfs (testing)</li>
<li>scripts: added support for WL-520/530/550G images (only 530g tested).</li>
<li>sources: added cramfs 1.1 tools (mkcramfs, cramfsck)</li>
<li>images: a symlink is now used between the TRX and generic image.
Previously, the intermediate TRX image was just renamed to the generic
image.</li>
<li>scripts: no longer show untrx output</li>
<li>docs: minor additions</li>
</ul>
<p>0.45:</p>
<ul>
<li>untrx: added support for attempted detection of file system and version
and emission of appropriately named segment.</li>
<li>untrx: can now handle trx's that have less than 3 segments.</li>
<li>untrx: complete overhauled (needed it). many changes.</li>
<li>sources: moved squashfs 3.0 stuff to a dedicated directory.</li>
<li>packages: added dd-wrt package for Samba. thanks TexHex <<a href="mailto:[email protected]">[email protected]</a>>.</li>
<li>asustrx: updated to add -b switch for padding segments (used by
ASUS).</li>
<li>asustrx: other misc. enhancements.</li>
<li>scripts: added check_for_upgrade.sh which automatically checks for a
newer version of the kit. It's launched when you use extract or build
firmware.</li>
<li>scripts: many other fixes and enhancements.</li>
</ul>
<p>0.43:</p>
<ul>
<li>scripts: ipkg_remove.sh - rewritten core templated file removal. It
actually works now.</li>
<li>scripts: moved build stuff to shared.inc, as appropriate.</li>
<li>packages: added dd-wrt package KAID, mainly for removal of this
gargantuan (nearly 1MB uncompressed) package. Note: you can easily create
your own packages for easier removal of things you don't want by using the
IPK template.</li>
</ul>
<p>0.42:</p>
<ul>
<li>ipk_template: added new ipk_template directory and make_ipk.sh script to
create IPKG format packages (.IPK).</li>
<li>packages: added my newly created ssmtp package with nvram->conf file
startup script. Installs completely into the DD-WRT file system.</li>
<li>packages: added ddwrt_packages subdirectory which will include pre-built
packages custom tailored or known to work</li>
<li>scripts: ipkg_install.sh numerous improvements and fixes.</li>
<li>scripts: ipkg_remove.sh numerous improvements and fixes.</li>
<li>scripts: ipkg_install.sh has new untested/alpha stage capabilities to
handle IPKs with remote sources.</li>
<li>docs: several updates</li>
</ul>
<p>0.40 beta (md5: 786472cfa03fb1cd70e1b025d091168b)</p>
<ul>
<li>scripts: ipkg_remove.sh - new script for basic IPK package removal</li>
<li>scripts: ipkg_install.sh possible OS X fixes</li>
<li>scripts: ipkg_install.sh changed technique of recording installed
packages</li>
<li>scripts: ipkg_install.sh outputs control file so user can see
dependencies and more</li>
<li>scripts: several improvements</li>
<li>docs: hopefully more readable format in places</li>
<li>docs: many mods and extensions</li>
</ul>
<p>0.33 beta</p>
<ul>
<li>structure: moved tool source codes to src subfolder</li>
<li>scripts: added ipkg_install_all.sh to install an entire folder of
packages.</li>
<li>scripts: consolidated shared code into an 'include' script</li>
<li>scripts: added forgotten parameter count check to ipkg_install.sh</li>
<li>scripts other minor changes</li>
</ul>
<p>0.31 beta</p>
<ul>
<li>new tests indicate OS X with native HFS+ file system results in firmware
images that work just fine! This build should be fully compatible with OS X
without even necessitating HSFX use for most firmwares.</li>
<li>mksquashfs: fix for big endian machines (specifically ppc / OS X)
resulting from change to support dd-wrt 08/10/06+ builds.</li>
</ul>
<p>0.30 beta</p>
<ul>
<li>scripts: created symlinks that omit the .sh extension</li>
<li>scripts: expanded build success check</li>
<li>scripts: fixed failure to exit if tools build failed</li>
<li>scripts: other minor cosmetic improvements</li>
<li>untrx: fixed a file handle leak in v0.28 beta</li>
<li>docs: added example procedure to install SSMTP into DD-WRT image</li>
<li>docs: added table of contents</li>
<li>docs: misc. additions and revisions</li>
</ul>
<p>0.29 beta</p>
<ul>
<li>scripts: added ipkg_install.sh to install .IPK format packages.</li>
</ul>
<p>0.28 beta</p>
<ul>
<li>the v0.26 fix for changed signature of 08/10/06 builds was
incomplete (test was flawed), resulting in builds that wouldn't run. fixed
properly now.</li>
<li>mksquashfs: added -magic [file] parameter to embed whichever is used in
the original firmware</li>
<li>untrx: added extraction of squashfs signature/magic for passing to
mksquashfs</li>
<li>docs: added more stuff</li>
</ul>
<p>0.27 beta</p>
<ul>
<li>scripts: changed warning about file system.</li>
</ul>
<p>0.26 beta</p>
<ul>
<li>Fixed compatibility with DD-WRT builds 08/10/06 and higher. Brainslayer
played a joke on me. </li>
</ul>
<p>0.25 beta</p>
<ul>
<li>OS X now works. When using case insensitive file system though built
firmwares might have errata.</li>
<li>trx: removed this tool due to odd command line parsing bug on (big
endian?) OS X systems. asustrx now used in its place.</li>
<li>scripts: file system case insensitive now warning, can be continued in
default settings.</li>
<li>untrx: fixed some endian problems. </li>
<li>untrx: fixed a problem with U2ND headers (previous version only worked
on trx/generic firmwares).</li>
<li>docs: minor additions.</li>
</ul>
<p>0.23 beta</p>
<ul>
<li>package: removed linux executables, download now half size. Surely
everyone can install basic build tools..</li>
<li>scripts: added working directory file system test for case insensitivity
and write access</li>
<li>scripts: added option to continue on after warning when OS X or CYGWIN
present</li>
<li>scripts: removed pre-fixed script name, much cleaner looking output now</li>
<li>scripts: added variable to choose whether or not to abort if file system
found incompatible</li>
<li>scripts: added cleanup.sh script to clean tools and logs.</li>
<li>untrx: renamed extfirmware to untrx, much more intuitive name</li>
</ul>
<p>0.22 beta</p>
<ul>
<li>scripts: added support for OS X</li>
<li>scripts: added support for CYGWIN</li>
<li>scripts: minor cosmetic work</li>
<li>extfirmware: added endian neutrality</li>
<li>trx: fixed OS X support</li>
<li>asustrx: fixed OS X support</li>
</ul>
<p>0.20 beta</p>
<ul>
<li>scripts: added check for Linux and OS X and appropriate compatibility
messages</li>
<li>extfirmware: added GNU license header</li>
<li>extfirmware: removed some unnecessary header includes</li>
<li>extfirmware: switched to u_int32_t for wider compatibility</li>
<li>extfirmware: other minor improvements</li>
<li>trx: increased maximum firmware size to 0x5A0000 (OpenWrt) from 0x3A0000
(DD-WRT).</li>
<li>trx: switched to u_int32_t for wider compatibility</li>
<li>makefile: uses gcc instead of cc now</li>
<li>docs: several updates</li>
</ul>
<p>v0.15 beta</p>
<ul>
<li>Reworked scripts so they have cleaner, clearer output and use a log file
(build.log and extract.log)</li>
<li>Added more sanity checks in the scripts</li>
<li>Documentation additions</li>
<li>Misc. polishing</li>
</ul>
<p>v0.13 alpha: Documentation updates, re-included pre-built executables<br />
v0.10 alpha: First decent public release.</p>
<p> </p>
<p> </p>
<p><font size="2">This document (c)2006-2011 Jeremy Collake and Craig Heffner. <br />
All Rights reserved. This document may be freely republished in its unaltered
and whole form only. Alterations or partial publishing requires approval of
creator(s).</font></p>
<p><i><font size="2"> This kit is free software; you can redistribute it
and/or modify<br />
it under the terms of the GNU General Public License as published by<br />
the Free Software Foundation; either version 2 of the License, or<br />
(at your option) any later version.<br />
<br />
This program is distributed in the hope that it will be useful,<br />
but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br />
General Public License for more details.<br />
<br />
You should have received a copy of the GNU General Public License<br />
along with this program; if not, write to the Free Software<br />
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</font></i></p>
</body>
</html>