Originally Posted by amgra
What I did successfully mounting it was this
mount -t romfs -o loop /pathtoBINfile /whereiwantedtomountit (I forgot how the syntaxis is, but I did it also as a readonly)
with no problems, of course first I had to remove the BEFORE 1f8b, then I could open it as a file.gz, I renamed it to gz just in case it is not obvious. inside the .gz there is a bin file, this is the file I mounted (as i do with cd/dvd images) with the command/syntaxis I wrote above and taraaaa in /whereiwantedtomountit it was the whole cmlinux directories. So far I haven't done anything, I was just curious to see what was inside. To be honest with you I have NO CLUE how to recompile it to bin again once you are done with the modifications. I kind of read somewhere it should be done with genromfs but as I said. No idea yet. If you figure it out, please do tell me. Never is enough knowledge
Good timing my friend..I was missing the last step and I did actually figure this out..Once I ran my DD to get rid of the header bytes I then ran it through "gzip -d" and them mounted it as a loop!
I now see the structure:
[root@Fedora5 lx350hd]# ls -l
drwxr-xr-x 1 root root 32 Dec 31 1969 bin
-rw-r--r-- 1 root root 77908 Dec 31 1969 bitmap.bin.gz
drwxr-xr-x 1 root root 32 Dec 31 1969 dev
drwxr-xr-x 1 root root 32 Dec 31 1969 etc
drwxr-xr-x 1 root root 32 Dec 31 1969 home
-rwxr-xr-x 1 root root 45963 Dec 31 1969 irqhandler.bin.gz
drwxr-xr-x 1 root root 32 Dec 31 1969 lib
-rwxr-xr-x 1 root root 1604179 Dec 31 1969 linux.bin.gz
drwxr-xr-x 1 root root 32 Dec 31 1969 mnt
drwxr-xr-x 1 root root 32 Dec 31 1969 opt
drwxr-xr-x 1 root root 32 Dec 31 1969 proc
drwxr-xr-x 1 root root 32 Dec 31 1969 root
drwxr-xr-x 1 root root 32 Dec 31 1969 sbin
drwxr-xr-x 1 root root 32 Dec 31 1969 tmp
drwxr-xr-x 1 root root 32 Dec 31 1969 usr
drwxr-xr-x 1 root root 32 Dec 31 1969 var
Here is the steps to build new Firmware for LX350HD. Antivirus, please correct me if I have wrong step someplace:
# Install a Linux of your choice - ie Fedora
# copy the PKG file to your Linux ie. romfs-sdt-LX350HD-1-1-1-1-132.pkg (lastest firmware for LX350HD)
# Extract the gzip file
dd if=romfs-sdt-LX350HD-1-1-1-1-132.pkg of=rompkg_pack_tmp.bin.gz bs=1 skip=108
# Unzip it
gzip -d rompkg_pack_tmp.bin.gz
# Extract the boot header
dd if=romfs-sdt-LX350HD-1-1-1-1-132.pkg of=romfs-sdt-LX350HD-1-1-1-1-132BootHeader.pkg bs=1 count=108
# Mount the clinux files on your linux box
mount -t romfs -o loop=/dev/loop1 rompkg_pack_tmp.bin /lx350hd
# make copy of the read-only files so you can mod them
# Change files with vi under the writable structure /lx350hd_write
# download and install rpm for genromfs for your Linux - http://rpmfind.net/linux/RPM/mandri...1-3mdk.ppc.html
rpm -i genromfs-0.5.1-3mdk.ppc.rpm
# Genromfs to new romfs - small correction Feb 22 on byte alignment
genromfs -d /lx350hd_write -f rompkg_pack_tmp.bin -V 'mambo'
# Gzip it back up
# Concatenate the header and gzipped romfs back again for final Firmware
cat romfs-sdt-LX350HD-1-1-1-1-132BootHeader.pkg rompkg_pack_tmp.bin.gz >romfs-sdt-LX350HD-1-1-1-1-132NEW.pkg
# Load the new firmware to your LX350HD - romfs-sdt-LX350HD-1-1-1-1-132NEW.pkg
Of interest here is the format of a gzip file:
Compressed bytes in hexadecimal hexample:
1f8b 0808 62ab 1d45 0003 7465 7374 2e74 7874 000b c948 5528 2ccd 4cce 5648 2aca 2fcf 5348 cbaf 50c8 2acd 2d28 56c8 2f4b 2d52 2801 4ae7 2456 552a a4e4 a7eb 7101 006a cc50 eb2d 0000 00
Bytes are packed with the least significant bit first. For example, the number 1810 would be packed as 01001000 and would appear in hexidecimal as 48.
1f8b 0808 62ab 1d45 0003
These ten bits are the header. We can see that the compression method is 08, and that the flags value is 08, eg bit 3 is set, thus the next field will be the original file name. The modification time is 62ab 1d45 (least significant byte first) = 1,159,572,322 seconds.
7465 7374 2e74 7874 00
This Zero-Terminated sting can be seen to encode test.txt and be terminated by 00
0b c948 5528 2ccd 4cce 5648 2aca 2fcf 5348 cbaf 50c8 2acd 2d28 56c8 2f4b 2d52 2801 4ae7 2456 552a a4e4 a7eb 7101 00
The compressed data. The first byte, 0b is packed in reverse order, and represents the bit order 1100000. The first bit indicates that this is the last block or compressed data. The next two bits indicate the compression method (00-uncompressed, 01-static hauffman coding, 10-dynamic hauffman coding, 11-reserved). This file has the bits 10, and thus uses dynamic hauffman coding.
NOTES(should have a new page):
compression method 00, as determined by the first byte, indicates that the data is stored in the following set of bytes. The data has two header fields: 2 bytes of length variable, and two bytes of the length variable's 1's compliment. This is folowed by bytes of data.
6a cc50 eb2d 0000 00
This is the CRC32 value and filesize (both encoded with least significant byte first). The filesize is 2d 0000 00 = 45 bytes of input data.