From 260830bbf67069e7684d64c7a5321822c153a262 Mon Sep 17 00:00:00 2001 From: leecher1337 Date: Thu, 10 Feb 2022 19:19:47 +0000 Subject: [PATCH] Adding support for Thinkpad E330 --- Descriptions.txt | 12 ++++++- Makefile | 15 ++++----- e330.H3EC35WW.img.d/001_keysym.patch | 0 e330.H3EC35WW.img.d/002_dead_keys.patch | 0 .../003_keysym_replacements.patch | 0 e330.H3EC35WW.img.d/004_fn_keys.patch | 0 e330.H3EC35WW.img.d/005_fn_key_swap.patch | 0 .../006_battery_validate.patch | 32 +++++++++++++++++++ scripts/FL2_copyIMG | 7 ++-- scripts/ISO_copyFL2 | 16 +++++----- scripts/geteltorito | 8 ++++- 11 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 e330.H3EC35WW.img.d/001_keysym.patch create mode 100644 e330.H3EC35WW.img.d/002_dead_keys.patch create mode 100644 e330.H3EC35WW.img.d/003_keysym_replacements.patch create mode 100644 e330.H3EC35WW.img.d/004_fn_keys.patch create mode 100644 e330.H3EC35WW.img.d/005_fn_key_swap.patch create mode 100644 e330.H3EC35WW.img.d/006_battery_validate.patch diff --git a/Descriptions.txt b/Descriptions.txt index 16a9a95..e64773e 100644 --- a/Descriptions.txt +++ b/Descriptions.txt @@ -127,6 +127,13 @@ g3uj30us.iso sha1:c51b1966ecc302b1a20a08f7f6b98064659abb2f l430,l530 BIOS 2.73 g3uj31us.iso sha1:76ff99d2a5bbffa228bba98b2fc13acd4d183e48 l430,l530 BIOS 2.74 (G3ETB4WW) EC 1.14 (G3HT40WW) g3uj32us.iso sha1:ae4bf2fc7441bfaa041ae3f1dff01a7d0d5142e6 l430,l530 BIOS 2.75 (G3ETB5WW) EC 1.14 (G3HT40WW) g3uj33us.iso sha1:cd712f3ff97169f904ed298c1cc770f5064005a1 l430,l530 BIOS 2.76 (G3ETB6WW) EC 1.14 (G3HT40WW) +h3uj52wd.iso sha1:d5812f96df663ae2d5e86df50fdfe8b02145970a e330 BIOS 1.06 (H3ET69WW) EC 1.17 (H3EC34WW) +h3uj54wd.iso sha1:854e4bcd7d51036296b0182be39265269ff24816 e330 BIOS 1.09 (H3ET72WW) EC 1.17 (H3EC34WW) +h3uj75wd.iso sha1:7073a59aa52d8d2adc8da1f7097bdfc5c6b6a676 e330 BIOS 1.12 (H3ET75WW) EC 1.18 (H3EC34WW) +h3uj76wd.iso sha1:8c8f46e117ee5423b62e421423531e3c11d9a40c e330 BIOS 1.14 (H3ET76WW) EC 1.18 (H3EC34WW) +h3uj77wd.iso sha1:079a1a3c77fd5ac6a59e68235d5e5e9b326deae2 e330 BIOS 1.14 (H3ET77WW) EC 1.18 (H3EC35WW) +h3uj78wd.iso sha1:d96a7c3c740eab23f7f1287b28c95df1d60467f2 e330 BIOS 1.15 (H3ET78WW) EC 1.18 (H3EC35WW) +h3uj79wd.iso sha1:f1404fd6724c0faa5b57aee0d81c60908b9917c6 e330 BIOS 1.16 (H3ET79WW) EC 1.18 (H3EC35WW) g4uj30us.iso sha1:8673a448abd5cba1a8d7d1cb2eeb7935c7a252cd t530 and t530i BIOS 2.66 (G4ETA6WW) EC 1.13 (G4HT39WW) g4uj32us.iso sha1:f86c7402fb57038143c81aa90ced615e95369844 t530 and t530i BIOS 2.68 (G4ETA8WW) EC 1.13 (G4HT39WW) g4uj34us.iso sha1:TODO @@ -223,6 +230,7 @@ j4uj75wd.iso sha1:3ff5025a4a5f62f461467f7726e5b2c1fa119b5b L440, L540 BIOS 1.93 # - update the tools to automatically determine the FAT_OFFSET # The firmware files from inside the ISO images +e330.H3EC35WW.s01H3000.FL1 rule:FL2,dep:h3uj79wd.iso,depi:h3uj79wd.iso.bat1,param:01H3000.FL1 e330 BIOS 1.16 Flash File l430.G3HT40WW.s01D4000.FL1 rule:FL2,dep:g3uj13us.iso,depi:g3uj13us.iso.bat1,param:01D4000.FL1 l430 BIOS 2.54 Flash File l440.J4HT27WW.s0AJ4000.FL1 rule:FL2,dep:j4uj62wd.iso,param:0AJ4000.FL1 l440 BIOS 1.73 Flash File l440.J4HT28WW.s0AJ4000.FL1 rule:FL2,dep:j4uj64wd.iso,param:0AJ4000.FL1 l440 BIOS 1.78 Flash File @@ -278,7 +286,8 @@ x61.7MHT25WW.s01B2000.FL2 rule:oldISO,dep:7nuj22uc.iso,param:01B2000.FL2 # The actual EC firmware extracted from the BIOS firmware file -l430.G3HT40WW.img rule:IMGnuvoton,dep:l430.G3HT40WW.s01D4000.FL1 l430 EC 1.14 (may be wrong) +e330.H3EC35WW.img rule:IMGnuvoton,dep:e330.H3EC35WW.s01H3000.FL1 e330 EC 1.18 (not encrypted) (CR16CPlus cpu) +l430.G3HT40WW.img rule:IMGnuvoton,dep:l430.G3HT40WW.s01D4000.FL1 l430 EC 1.14 (not encrypted) (CR16CPlus cpu) l440.J4HT29WW.img rule:IMGnoenc,dep:l440.J4HT29WW.s0AJ4000.FL1 l440 EC 1.10 l440.J4HT30WW.img rule:IMGnoenc,dep:l440.J4HT30WW.s0AJ4000.FL1 l440 EC 1.11 p51.N1UHT24W.img rule:IMGnoenc,dep:p51.N1UHT24W.s0AN1U00.FL2 p51 EC 1.07 @@ -330,3 +339,4 @@ patched.w530.iso rule:niceISO,dep:g5uj37us.iso,suffix:0,insert:0 for patching patched.x230.iso rule:niceISO,dep:g2uj31us.iso,suffix:0,insert:0 for patching Thinkpad X230 patched.x230t.iso rule:niceISO,dep:gcuj32us.iso,suffix:0,insert:0 for patching Thinkpad X230t patched.l430.iso rule:niceISO,dep:g3uj13us.iso,suffix:0,insert:0 for patching Thinkpad L430, L530 +patched.e330.iso rule:niceISO,dep:h3uj79wd.iso,suffix:0,insert:0 for patching Thinkpad E330 diff --git a/Makefile b/Makefile index a2a8df5..1ae57a8 100644 --- a/Makefile +++ b/Makefile @@ -100,15 +100,6 @@ list_images: .PHONY: list_images -# All the bios update iso images I have checked have had a fat16 filesystem -# embedded in a dos mbr image as the el-torito ISO payload. Most of them -# had the same offset to this fat filesystem, so hardcode that offset here. -# FIXME: -# - checking the E330 image showed a different FAT_OFFSET, need to handle that - -# The offset value is bytes in decimal. -FAT_OFFSET := 71680 - # Some versions of mtools need this flag set to allow them to work with the # dosfs images used by Lenovo - from my tests, it may be that Debian has # applied some patch @@ -210,10 +201,12 @@ patch_disable_keyboard: # my mind to it.. # %.iso.bat: %.iso.orig autoexec.bat.template + $(eval FAT_OFFSET := $(shell scripts/geteltorito -c $< 2>/dev/null)) @sed -e "s%__DIR%`mdir -/ -b -i $<@@$(FAT_OFFSET) |grep FL2 |head -1|cut -d/ -f3`%; s%__FL2%`mdir -/ -b -i $<@@$(FAT_OFFSET) |grep FL2 |head -1|cut -d/ -f4`%" autoexec.bat.template >$@.tmp @mv $@.tmp $@ %.iso.bat1: %.iso.orig autoexec.bat.template + $(eval FAT_OFFSET := $(shell scripts/geteltorito -c $< 2>/dev/null)) @sed -e "s%__DIR%`mdir -/ -b -i $<@@$(FAT_OFFSET) |grep FL1 |head -1|cut -d/ -f3`%; s%__FL2%`mdir -/ -b -i $<@@$(FAT_OFFSET) |grep FL1 |head -1|cut -d/ -f4`%" autoexec.bat.template >$@.tmp @mv $@.tmp $(subst .bat1,.bat,$@) @@ -237,12 +230,15 @@ patch_disable_keyboard: # If we ever want a copy of the dosflash.exe, just get it from the iso image %.dosflash.exe.orig: %.iso.orig + $(eval FAT_OFFSET := $(shell scripts/geteltorito -c $^ 2>/dev/null)) mcopy -m -i $^@@$(FAT_OFFSET) ::FLASH/DOSFLASH.EXE $@ # Extract the "embedded" fat file system from a given iso. %.iso.extract: %.iso + $(eval FAT_OFFSET := $(shell scripts/geteltorito -c $^ 2>/dev/null)) mcopy -n -s -i $^@@$(FAT_OFFSET) :: $@ %.iso.orig.extract: %.iso.orig + $(eval FAT_OFFSET := $(shell scripts/geteltorito -c $^ 2>/dev/null)) mcopy -n -s -i $^@@$(FAT_OFFSET) :: $@ ## Use the system provided geteltorito script, if there is one @@ -358,6 +354,7 @@ define rule_FL2_insert @# TODO - datestamp here could be the lastcommitdatestamp ./scripts/ISO_copyFL2 to_iso $@.tmp $<.tmp $(1) + $(eval FAT_OFFSET := $(shell scripts/geteltorito -c $@.orig 2>/dev/null)) mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $@.report.tmp ::report.txt mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $@.bat.tmp ::AUTOEXEC.BAT -mdel -i $@.tmp@@$(FAT_OFFSET) ::EFI/Boot/BootX64.efi diff --git a/e330.H3EC35WW.img.d/001_keysym.patch b/e330.H3EC35WW.img.d/001_keysym.patch new file mode 100644 index 0000000..e69de29 diff --git a/e330.H3EC35WW.img.d/002_dead_keys.patch b/e330.H3EC35WW.img.d/002_dead_keys.patch new file mode 100644 index 0000000..e69de29 diff --git a/e330.H3EC35WW.img.d/003_keysym_replacements.patch b/e330.H3EC35WW.img.d/003_keysym_replacements.patch new file mode 100644 index 0000000..e69de29 diff --git a/e330.H3EC35WW.img.d/004_fn_keys.patch b/e330.H3EC35WW.img.d/004_fn_keys.patch new file mode 100644 index 0000000..e69de29 diff --git a/e330.H3EC35WW.img.d/005_fn_key_swap.patch b/e330.H3EC35WW.img.d/005_fn_key_swap.patch new file mode 100644 index 0000000..e69de29 diff --git a/e330.H3EC35WW.img.d/006_battery_validate.patch b/e330.H3EC35WW.img.d/006_battery_validate.patch new file mode 100644 index 0000000..c2b5654 --- /dev/null +++ b/e330.H3EC35WW.img.d/006_battery_validate.patch @@ -0,0 +1,32 @@ +--- /tmp/$01H3000.FL1.hex 2022-02-10 16:47:23.957715840 +0000 ++++ /tmp/$01H3000.FL1.bat.hex 2022-02-10 16:47:24.053718365 +0000 +@@ -4150,14 +4150,14 @@ + 00010730 20 f1 3a 02 ff c0 63 a1 00 50 00 18 ec 04 70 5d | .:...c..P....p]| + 00010740 00 5f 04 55 24 4c 04 61 34 4c 24 00 01 00 82 00 |._.U$L.a4L$.....| + 00010750 14 90 81 49 b1 22 1f 00 04 90 b0 22 e0 ff 10 27 |...I."....."...'| +-00010760 04 d0 e0 18 c4 04 00 c0 5a 97 00 50 00 18 ba 04 |........Z..P....| ++00010760 04 d0 e0 18 c4 04 00 c0 5a 97 00 50 e0 18 54 00 |........Z..P..T.| + 00010770 70 5d 00 5f 02 55 22 4c 02 61 32 4c 22 00 01 00 |p]._.U"L.a2L"...| + 00010780 86 00 00 c0 3c 9a 72 59 ff c0 2b fe 00 01 10 58 |....<.rY..+....X| + 00010790 00 01 72 5d 22 5f 20 55 20 4c 20 61 30 4c 20 00 |..r]"_ U L a0L .| + 000107a0 01 00 86 00 10 01 b5 58 11 00 b4 58 27 00 b3 58 |.......X...X'..X| + 000107b0 16 00 72 59 ff c0 15 99 8f 60 00 50 00 18 6a 04 |..rY.....`.P..j.| + 000107c0 70 5d 00 5f 02 55 22 4c 02 61 32 4c 22 00 01 00 |p]._.U"L.a2L"...| +-000107d0 82 00 02 90 b0 22 e0 ff 30 26 e0 18 4a 04 70 5d |....."..0&..J.p]| ++000107d0 82 00 02 90 b0 22 e0 ff c0 26 e0 18 4a 04 70 5d |....."...&..J.p]| + 000107e0 00 5f 02 55 22 4c 02 61 32 4c 22 00 01 00 82 00 |._.U"L.a2L".....| + 000107f0 b0 58 20 00 02 f3 14 01 72 59 ff c0 b9 fd 0f f0 |.X .....rY......| + 00010800 72 5d 22 5f 20 55 20 4c 20 61 30 4c 20 00 01 00 |r]"_ U L a0L ...| +@@ -4182,9 +4182,9 @@ + 00010930 02 55 22 4c 02 61 32 4c 22 00 01 00 82 00 02 90 |.U"L.a2L".......| + 00010940 b0 22 e0 ff b0 26 09 00 e0 18 dc 02 72 5d 22 5f |."...&......r]"_| + 00010950 20 55 20 4c 20 61 30 4c 20 00 01 00 82 00 30 7b | U L a0L .....0{| +-00010960 02 00 80 18 c4 02 20 55 22 4c 02 61 32 4c 22 00 |...... U"L.a2L".| +-00010970 01 00 82 00 12 00 00 71 a6 04 62 7b 01 00 94 10 |.......q..b{....| +-00010980 b0 20 fe ff e2 10 10 24 13 00 00 71 a6 04 72 5d |. .....$...q..r]| ++00010960 02 00 00 2c 00 2c 20 55 22 4c 02 61 32 4c 22 00 |...,., U"L.a2L".| ++00010970 01 00 82 00 12 00 00 71 a6 04 62 73 01 00 52 73 |.......q..bs..Rs| ++00010980 01 00 00 2c 00 2c 10 24 13 00 00 71 a6 04 72 5d |...,.,.$...q..r]| + 00010990 22 5f 20 55 20 4c 20 61 30 4c 20 00 01 00 82 00 |"_ U L a0L .....| + 000109a0 00 71 02 00 20 55 24 55 44 61 24 61 64 4c 24 00 |.q.. U$UDa$adL$.| + 000109b0 01 00 86 05 20 4c 20 61 30 4c 20 00 01 00 82 00 |.... L a0L .....| diff --git a/scripts/FL2_copyIMG b/scripts/FL2_copyIMG index 7025d2b..95804b7 100755 --- a/scripts/FL2_copyIMG +++ b/scripts/FL2_copyIMG @@ -587,9 +587,9 @@ use base qw(FL2::base); sub _find_pfh { my $self = shift; - my $offset = 0; + my $offset = $self->{filesize}-4; - while ($offset < $self->{filesize}) { + while ($offset > 0) { my $buf = $self->get_block($offset, 4); return undef if (!defined($buf)); $buf = $$buf; @@ -599,7 +599,7 @@ sub _find_pfh { return $offset; } - $offset+=0x08; + $offset-=0x04; } log::add("no PFH found"); @@ -613,6 +613,7 @@ sub _check { my $known = { 4681808 => 1, # l440 9437264 => 1, # l430 + 13631568 => 1, # e330 12587008 => 1, }; diff --git a/scripts/ISO_copyFL2 b/scripts/ISO_copyFL2 index 231b4f2..bc14004 100755 --- a/scripts/ISO_copyFL2 +++ b/scripts/ISO_copyFL2 @@ -5,14 +5,6 @@ # Deal with copying the FL2 file from and to the ISO image # -# All the bios update iso images I have checked have had a fat16 filesystem -# embedded in a dos mbr image as the el-torito ISO payload. They also all -# had the same offset to this fat filesystem, so hardcode that offset here. -# The offset value is bytes in decimal. -# TODO - one day, this offset will be wrong. (geteltorito could be taught -# to output the starting sector it found as a starting point) -FAT_OFFSET=71680 - DIR="$1" case "$DIR" in from_iso) ;; @@ -37,6 +29,14 @@ if ! which mdir >/dev/null; then exit 1 fi +# All the bios update iso images I have checked have had a fat16 filesystem +# embedded in a dos mbr image as the el-torito ISO payload. +# The offset value is bytes in decimal. +FAT_OFFSET=$(scripts/geteltorito -c $ISO 2>/dev/null) +if [ -z $FAT_OFFSET ]; then + FAT_OFFSET=71680 +fi + # If we just want to look at the contents, do that if [ "$DIR" = "ls" ]; then mdir -i "$ISO"@@"$FAT_OFFSET" -/ -b diff --git a/scripts/geteltorito b/scripts/geteltorito index c64525f..6e59c77 100755 --- a/scripts/geteltorito +++ b/scripts/geteltorito @@ -94,6 +94,7 @@ sub usage{ "the data extracted to STDOUT or to a file.\n", " -h: This help. \n", " -v: Print version of script and exit.\n", + " -c: Calculate start of FAT in HDD image\n", " -o : Write extracted data to file instead of STDOUT.\n", "\n\n"; exit 0; @@ -101,7 +102,7 @@ sub usage{ # --------------------------------------------------------------------- -$ret=getopts('hvo:'); +$ret=getopts('hvco:'); if( defined($opt_v) ){ warn "Version: $utilVersion \n"; @@ -215,6 +216,11 @@ $cnt=$count==0?$sCount:$count; print STDERR "El Torito image starts at sector $imgStart and has $cnt sector(s) of $vSecSize Bytes\n"; +if( defined($opt_c) and $media == 4 ) { + print STDOUT ($imgStart * $secSize) + ($firstSector * $vSecSize); + exit +} + # We are there: # Now read the bootimage to stdout $image=getSector($imgStart, $cnt, $imageFile);