Merge branch 'leecher1337-Lx30'

master
Hamish Coleman 2 years ago
commit e0fba155d8

@ -20,6 +20,8 @@ jobs:
- run: sudo make build-deps
- run: make patch_enable_battery
- run: make test
- run: make patch_disable_keyboard
- run: make test.batteryonly
- run: rm -f .config
- run: make test
- run: make test.img.orig

10
.gitignore vendored

@ -8,15 +8,25 @@
*.img.orig
*.img.enc
*.img.enc.orig
*.FL1
*.FL1.orig
*.FL2
*.FL2.orig
*.EXE
*.EXE.orig
*.exe.orig
*.CAP
*.CAP.orig
# ignore generated files
*.bat
*.bat1
*.report
.d
*.pgm
# The destination of the wget hack
nuvoton-tools/
# Temp are (should be) just junk
*.tmp

@ -106,8 +106,27 @@ g2uj30us.iso sha1:b2ce7c604850d263ead783550ab15c517e18bc58 x230 BIOS 2.74 (G2ET
g2uj31us.iso sha1:971a9d57a179f4c368c827fd23c6fd5c86a52df7 x230 BIOS 2.75 (G2ETB5WW) EC 1.14 (G2HT35WW)
g2uj32us.iso sha1:ee434746cabdb7d8bb8077f79be1429d6dec5696 x230 BIOS 2.76 (G2ETB6WW) EC 1.14 (G2HT35WW)
g2uj33us.iso sha1:2a5ba87f9a0128ae4ae1a7f006b5a4ec515d870f x230 BIOS 2.77 (G2ETB7WW) EC 1.15 (G2HT36WW)
g3uj13us.iso sha1:433c7e88a6fd690b4aac57b473bb7baf51475d34 l430,l530 BIOS 2.54 (G3ET94WW) EC 1.14 (G3HT40WW)
g3uj14us.iso sha1:72d5b5a63354124c02f2c0a22ce35aac0dfc0012 l430,l530 BIOS 2.56 (G3ET96WW) EC 1.14 (G3HT40WW)
g3uj15us.iso sha1:c1a7f055fd2765af82b4698b388e56c2f77699b1 l430,l530 BIOS 2.57 (G3ET97WW) EC 1.14 (G3HT40WW)
g3uj16us.iso sha1:bf94a1e8e0caa99983c801d747bd4517f905b889 l430,l530 BIOS 2.58 (G3ET98WW) EC 1.14 (G3HT40WW)
g3uj17us.iso sha1:68a11ff3f3a2c04fded329312087104eda4af101 l430,l530 BIOS 2.60 (G3ETA0WW) EC 1.14 (G3HT40WW)
g3uj18us.iso sha1:8c420932ea9b4c3ced6a3b11e8022e3e165b0e9a l430,l530 BIOS 2.61 (G3ETA1WW) EC 1.14 (G3HT40WW)
g3uj19us.iso sha1:d1c39a51253a025383173669dc898ed9b3f4f389 l430,l530 BIOS 2.62 (G3ETA2WW) EC 1.14 (G3HT40WW)
g3uj20us.iso sha1:dd01d80656826779c5aba8af8c7ab07cf36753b0 l430,l530 BIOS 2.63 (G3ETA3WW) EC 1.14 (G3HT40WW)
g3uj21us.iso sha1:20a619b6aa0d22e9d7883c805e9423712ba2ed12 l430,l530 BIOS 2.64 (G3ETA4WW) EC 1.14 (G3HT40WW)
g3uj22us.iso sha1:883ef99c1c934a563a3e119449b108cd0ad35180 l430,l530 BIOS 2.65 (G3ETA5WW) EC 1.14 (G3HT40WW)
g3uj23us.iso sha1:656c8bdfb8a185b5757c15ab3a1179d323cf366f l430,l530 BIOS 2.66 (G3ETA6WW) EC 1.14 (G3HT40WW)
g3uj24us.iso sha1:f88f7b6b530ad6747405ab8a998055ff978ac9ed l430,l530 BIOS 2.67 (G3ETA7WW) EC 1.14 (G3HT40WW)
g3uj25us.iso sha256:caa5494ea71206f253027bea3ae9336c942c4d6f7f041c58f6972a54227cea6d l430,l530 BIOS 2.68 (G3ETA8WW) EC 1.14 (G3HT40WW)
g3uj26us.iso sha1:96e14347b7587f42951e49eb2f5fea3123ab56d3 l430,l530 BIOS 2.69 (G3ETA9WW) EC 1.14 (G3HT40WW)
g3uj27us.iso sha1:150d158dc6f34dc9b0a7d43faf2ee0d0fab8342e l430,l530 BIOS 2.70 (G3ETB0WW) EC 1.14 (G3HT40WW)
g3uj28us.iso sha1:529ba7a4b3d9aa1b0507c6d5dcc5a047ed82c4aa l430,l530 BIOS 2.71 (G3ETB1WW) EC 1.14 (G3HT40WW)
g3uj29us.iso sha1:34c6d9ad0f6eb394d3351495398363b907320444 l430,l530 BIOS 2.72 (G3ETB2WW) EC 1.14 (G3HT40WW)
g3uj30us.iso sha1:c51b1966ecc302b1a20a08f7f6b98064659abb2f l430,l530 BIOS 2.73 (G3ETB3WW) EC 1.14 (G3HT40WW)
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)
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
@ -156,7 +175,17 @@ giuj29us.iso sha1:6a87e3377140620130e154f488d9116e18f55ec4 x240 BIOS 2.42 (GIET
gluj42us.iso sha1:5d56eddac59df8b0fe2dda5f8f8d8ea540b85075 t440p BIOS 2.54 (GLETA0WW) EC 1.13 (GLHT30WW)
gluj43us.iso sha1:353f1f993743a1c4a1da96a098b61a77873aa024 t440p BIOS 2.55 (GLETA1WW) EC 1.13 (GLHT30WW)
gruj26us.iso sha1:89a3b3e364f37694bf514e01f9c3e2eda33a59e8 x1 Carbon (Type 20A7, 20A8) BIOS 1.29 (GRET52WW) EC 1.19 (GRHT38WW)
h1uj53us.exe sha1:8056b5c5867a16797ae9e62e7cd968d09284ff42 b480,b580 BIOS 1.16 (H1ET73WW,H5ET73WW) EC 1.13 (H1EC33WW,H5EC33WW)
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 (H3EC35WW)
h3uj76wd.iso sha1:8c8f46e117ee5423b62e421423531e3c11d9a40c e330 BIOS 1.14 (H3ET76WW) EC 1.18 (H3EC35WW)
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)
h6uja0wd.iso sha1:19a05355c793b3f776c3130caa5f10e371f530c0 T430u BIOS 2.18 (H6ETA0WW) EC 2.01 (H6HT54WW)
h9et75ww.zip sha1:d81c145b371cf77abe6ae00d35d37491715feecd b590,b490 BIOS ?.? (H9ET75WW) EC 1.01 (H9EC08WW)
h9et92ww.exe sha1:c1a3ba9282fe48a9e6f69e4dd32537c10a710e78 b590,b490 BIOS ?.? (H9ET92WW) EC 1.02 (H9EC09WW)
n10ur10w.iso sha1:0e4c4ffb99146e50867dc1345ee2ef88c60ea192 x250 BIOS 1.21 (N10ET42W) EC 1.16 (N10HT17W)
n14ur15w.iso sha1:e106b024b1d448234e5ea958b0e8e93bbda1a543 x1 Carbon (Type 20BS, 20BT) BIOS 1.16 (N14ET38W) EC 1.09 (N14HT36W)
n1mur06w.iso sha1:e2bed755c065daf83cabc130b8d65c08e6a6a391 x1 Carbon (Type 20HQ, 20HR, 20K3, 20K4) BIOS 1.20 (N1MET35W) EC 1.14 (N1MHT25W)
@ -167,8 +196,6 @@ n1qur12w.iso sha1:FIXME T470, 25 BIOS 1.43 (
n1qur13w.iso sha1:FIXME T470, 25 BIOS 1.44 (N1QET69W) EC 1.30 (N1QHT48W)
n1qur14w.iso sha1:fea0d271a23548adb5d11f3c16b4e016be3869a5 T470, 25 BIOS 1.46 (N1QET71W) EC 1.30 (N1QHT48W)
n1uur12w.iso sha1:82628c7b7ed2064f4c272440b72cbb38a88b18d8 P51 BIOS 1.20 (N1UET46W) EC 1.07 (N1UHT24W)
n2jur16w.iso sha1:FIXME T490s, X390 BIOS 1.51 (N2JET73W) EC 1.12 (N2JHT28W)
n2jur17w.iso sha1:be7598ac64e9c3f2aab60ca890175d0adac010b9 T490s, X390 BIOS 1.55 (N2JET77W) EC 1.13 (N2JHT29W)
n20ur02w.iso sha1:FIXME x280 BIOS 1.08 (N20ET23W) EC 1.03 (N20HT16W)
n20ur03w.iso sha1:FIXME x280 BIOS 1.12 (N20ET27W) EC 1.04 (N20HT17W)
n20ur04w.iso sha1:8ca1d873aeca5ce87d67f795739f8cc95f0c519f x280 BIOS 1.14 (N20ET29W) EC 1.04 (N20HT17W)
@ -176,6 +203,8 @@ n22ur04w.iso sha1:b557d7bbe881cc682b7504364097b64c0dec1c01 t480s BIOS 1.11 (N22
n24ur01w.iso sha1:FIXME t480 BIOS 1.07 (N24ET32W) EC 1.06 (N24HT21W)
n24ur03w.iso sha1:FIXME t480 BIOS 1.11 (N24ET36W) EC 1.08 (N24HT23W)
n24ur04w.iso sha1:134b239e4ce4c9c2d1f5f8f645f279c162fc5f3e t480 BIOS 1.12 (N24ET37W) EC 1.08 (N24HT23W)
n2jur16w.iso sha1:FIXME T490s, X390 BIOS 1.51 (N2JET73W) EC 1.12 (N2JHT28W)
n2jur17w.iso sha1:be7598ac64e9c3f2aab60ca890175d0adac010b9 T490s, X390 BIOS 1.55 (N2JET77W) EC 1.13 (N2JHT29W)
r02uj46d.iso sha1:876a68add32d9c961cbdf80c74b88f92a66443cf x260 BIOS 1.19 (R02ET46W) EC 1.11 (R02HT29W)
r0fuj15wd.iso sha1:bab0722d72375d1c9190b2c47ab7b4eb4c0dfde0 t470p BIOS 1.22 (R0FET42W) EC 1.04 (R0FHT16W)
r0iuj09wd.iso sha1:21b3abf69b9ee7ecf12fe0880564312122b1ff75 x270 BIOS 1.16 (R0IET38W) EC 1.12 (R0IHT30W)
@ -200,11 +229,11 @@ j4uj64wd.iso sha1:4b2682bf11d31e0ff9e4cf4ec5e3372b715c7841 L440, L540 BIOS 1.78
j4uj65wd.iso sha1:386353b39ec54f0feb5160cc6edc41b3def14dca L440, L540 BIOS 1.81 (J4ET81WW) EC 1.10 (J4EHT29WW, maybe J4HT29WW)
j4uj75wd.iso sha1:3ff5025a4a5f62f461467f7726e5b2c1fa119b5b L440, L540 BIOS 1.93 (J4ET93WW) EC 1.11 (J4EHT30WW, maybe J4HT30WW)
# TODO
# - update the tools to automatically determine the FAT_OFFSET
# The firmware files from inside the ISO images
l430.G3HT40WW.s01D4000.FL1 rule:FL2,dep:g3uj25us.iso,param:01D4000.FL1 l430 BIOS 2.68 Flash File
b580.h1et73ww.s0AH1000.EXE rule:EXE,dep:h1uj53us.exe,depi:h1uj53us.exe.bat1;g3uj13us.iso.orig,param:\$$0AH1000.FL1;g3uj13us.iso b580 BIOS H1ET73WW Flash File
b590.H9ET92WW.CAP rule:CAP,dep:h9et92ww.exe,depi:h9et92ww.exe.bat;g3uj13us.iso.orig;h9et75ww.zip.orig,param:H9ET92WW.CAP;g3uj13us.iso;h9et75ww.zip b590 BIOS H9ET75WW Flash File
e330.H3EC35WW.s01H3000.FL1 rule:FL2,dep:h3uj76wd.iso,depi:h3uj76wd.iso.bat1;h3uj52wd.iso.orig,param:01H3000.FL1;h3uj52wd.iso 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
l440.J4HT29WW.s0AJ4000.FL1 rule:FL2,dep:j4uj65wd.iso,param:0AJ4000.FL1 l440 BIOS 1.81 Flash File
@ -259,7 +288,10 @@ 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:IMGnoenc,dep:l430.G3HT40WW.s01D4000.FL1 l430 EC 1.14 (may be wrong)
b580.H1ET73WW.img rule:IMGnuvoton,dep:b580.h1et73ww.s0AH1000.EXE b580 EC 1.13 (not encrypted) (CR16CPlus cpu)
b590.H9ET92WW.img rule:IMGnuvoton,dep:b590.H9ET92WW.CAP b590 EC 1.02 (not encrypted) (CR16CPlus cpu)
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
@ -303,6 +335,10 @@ x61.7MHT25WW.img rule:IMGnoenc,dep:x61.7MHT25WW.s01B2000.FL2 x61 EC 1.03
# The end-user visible, nicely named iso images
patched.b580.iso rule:niceISO,dep:h1uj53us.exe,suffix:0,insert:0 for patching Thinkpad B480, B580, V480, V480c, V580, V580c (Battery only)
patched.b590.iso rule:niceISO,dep:h9et92ww.exe,suffix:0,insert:0 for patching Thinkpad B490, B590 (Battery only)
patched.e330.iso rule:niceISO,dep:h3uj76wd.iso,suffix:0,insert:0 for patching Thinkpad E330, V480s (Battery only)
patched.l430.iso rule:niceISO,dep:g3uj13us.iso,suffix:0,insert:0 for patching Thinkpad L430, L530
patched.t430.iso rule:niceISO,dep:g1uj48us.iso,suffix:0,insert:0 for patching Thinkpad T430
patched.t430s.iso rule:niceISO,dep:g7uj28us.iso,suffix:0,insert:0 for patching Thinkpad T430s
patched.t530.iso rule:niceISO,dep:g4uj38us.iso,suffix:0,insert:0 for patching Thinkpad T530

@ -17,7 +17,8 @@ QEMU_OPTIONS ?= -enable-kvm
GITVERSION = $(shell git describe --dirty --abbrev=6 ) ($(shell date +%Y%m%d))
BUILDINFO = $(GITVERSION) $(MAKECMDGOALS)
LIST_PATCHED = $(basename $(shell grep ^patched Descriptions.txt |cut -d" " -f1))
LIST_PATCHED = $(basename $(shell grep ^patched Descriptions.txt |grep -v Battery |cut -d" " -f1))
LIST_PATCHED_BO = $(basename $(shell grep ^patched Descriptions.txt |grep Battery |cut -d" " -f1))
list_laptops:
$(info )
@ -34,6 +35,7 @@ DEPSDIR := .d
$(shell mkdir -p $(DEPSDIR))
test: $(addsuffix .iso,$(LIST_PATCHED)) $(addsuffix .img,$(LIST_PATCHED))
test.batteryonly: $(addsuffix .iso,$(LIST_PATCHED_BO)) $(addsuffix .img,$(LIST_PATCHED_BO))
ALL_IMG_ORIG := $(addsuffix .orig,$(shell grep rule:IMG Descriptions.txt |cut -d" " -f1))
test.img.orig: $(ALL_IMG_ORIG)
@ -63,7 +65,7 @@ test.report:
# images) and any small downloads
clean:
rm -f $(CLEAN_FILES) \
patched.*.iso patched.*.img *.FL2 *.FL2.orig *.img.enc \
patched.*.iso patched.*.img *.FL? *.FL?.orig *.img.enc \
*.img.enc.orig *.img.orig *.bat *.report \
*.img \
*.txt.orig
@ -100,15 +102,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
@ -119,7 +112,7 @@ export MTOOLS_SKIP_CHECK=1
export MTOOLS_LOWER_CASE=0
build-deps:
apt -y install git mtools libssl-dev build-essential xorriso
apt -y install git mtools libssl-dev build-essential xorriso unzip innoextract
#
# Radare didnt seem to let me specify the directory to store the project file,
@ -175,7 +168,9 @@ patch_disable_keyboard:
# Download any ISO image that we have a checksum for
# NOTE: makes an assumption about the Lenovo URL not changing
.PRECIOUS: %.iso.orig
%.iso.orig:
.PRECIOUS: %.exe.orig
.PRECIOUS: %.zip.orig
%.iso.orig %.exe.orig %.zip.orig:
@echo -n "Downloading "
@scripts/describe $(basename $@)
@wget -nv -O $@ https://download.lenovo.com/pccbbs/mobiles/$(basename $@)
@ -210,9 +205,28 @@ 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 $@
# FIXME:
# - the following bat file generators are all basically duplicates of the
# above original one. They should be deduplicated
# - the "bat1" construct is ugly. Find a nicer way to do this.
%.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,$@)
%.exe.bat: %.exe.orig autoexec.bat.template
@sed -e "s%__DIR%.%; s%__FL2%`basename \`innoextract -l $< | grep -i .CAP | cut -d'"' -f2\``%" autoexec.bat.template >$@.tmp
@mv $@.tmp $@
%.exe.bat1: %.exe.orig autoexec.bat.template
@sed -e "s%__DIR%.%; s%__FL2%`basename \`innoextract -l $< | grep -i .FL1 | cut -d'"' -f2\``%" autoexec.bat.template >$@.tmp
@mv $@.tmp $@
# helper to write the ISO onto a cdrw
%.iso.blank_burn: %.iso
wodim -eject -v speed=40 -tao gracetime=0 blank=fast $<
@ -233,14 +247,26 @@ 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) :: $@
%.zip.extract: %.zip
unzip $^ -d $@
%.zip.orig.extract: %.zip
unzip $^ -d $@
%.exe.extract: %.exe
innoextract $^ -d $@
%.exe.orig.extract: %.exe.orig
innoextract $^ -d $@
## Use the system provided geteltorito script, if there is one
#GETELTORITO := $(shell if type geteltorito >/dev/null; then echo geteltorito; else echo ./geteltorito; fi)
@ -299,6 +325,14 @@ mec-tools/mec_encrypt: mec-tools/Makefile
git submodule update
make -C mec-tools
# FIXME:
# - There is no version tracking in this wget, so it is basically an untrusted
# execution vector. Either import this file to this repo or use a submodule.
nuvoton-tools/npce885crc:
-mkdir nuvoton-tools
wget -O nuvoton-tools/npce885crc.c https://raw.githubusercontent.com/leecher1337/thinkpad-Lx30-ec/main/fwpat/util/npce885crc.c
gcc -o nuvoton-tools/npce885crc nuvoton-tools/npce885crc.c
# Simple Visualisation
%.pgm: %
(echo "P5 256 $$(($(shell stat -c %s $<)/265)) 255" ; cat $< ) > $@
@ -333,15 +367,48 @@ define rule_IMG_extract
endef
rule_IMG_extract_DEPS = scripts/FL2_copyIMG mec-tools/mec_encrypt mec-tools/mec_csum_flasher mec-tools/mec_csum_boot
# TODO:
# - the prepare_iso_from_tpl looks like it is entirely needed due to some
# Lenovo images being broken. Look into what is broken and see if it is
# patchable without a template.
# $@ is the ISO to create
# $< is the FL2
# $1 is the pattern to match FL2 file in ISO image
# $2 FAT offset in ISO image
define prepare_iso_from_tpl
$(eval FAT_OFFSET_FL1SRC := $(shell scripts/geteltorito -c $@.orig 2>/dev/null))
$(eval FLASH_FILE := $(subst $$,\$$$$,$(shell mdir -/ -b -i $@.orig@@$(FAT_OFFSET_FL1SRC) | grep -i $(1) | head -1)))
$(eval DOSFLASH := $(shell mdir -/ -b -i $@.orig@@$(FAT_OFFSET_FL1SRC) | grep DOSFLASH | head -1))
$(eval FILE_DIR := $(shell basename $(dir $(FLASH_FILE:::%=%))))
mdeltree -i $@.tmp@@$(2) FLASH/
mmd -i $@.tmp@@$(2) FLASH FLASH/$(FILE_DIR)
-mkdir -p $@.orig.extract.tmp
mcopy -n -s -m -i $@.orig@@$(FAT_OFFSET_FL1SRC) $(FLASH_FILE) $(DOSFLASH) $@.orig.extract.tmp
mcopy -o -s -m -i $@.tmp@@$(2) $@.orig.extract.tmp/DOSFLASH.EXE ::/FLASH/
mcopy -o -s -m -i $@.tmp@@$(2) $@.orig.extract.tmp/$(subst $$,\$$,$(shell basename $(FLASH_FILE:::%=%))) ::/FLASH/$(FILE_DIR)/
rm -r $@.orig.extract.tmp
endef
# FIXME:
# - the logic using the optional $2 below feels really clunky, try and
# improve it. See above for a related TODO for prepare_iso_from_tpl
# Create a new ISO image with patches applied
#
# $@ is the ISO to create
# $< is the FL2
# $1 is the pattern to match FL2 file in ISO image
# $2 optional: Name of other ISO that should be taken as a template with a working DOS on it
define rule_FL2_insert
$(call buildinfo_ISO)
@cp --reflink=auto $@.orig $@.tmp
$(eval SRC := $(or $(2),$@))
@cp --reflink=auto $(SRC).orig $@.tmp
$(eval FAT_OFFSET := $(shell scripts/geteltorito -c $(SRC).orig 2>/dev/null))
$(if $(2),$(call prepare_iso_from_tpl,$(1),$(FAT_OFFSET)))
@cp --reflink=auto $< $<.tmp
@cp --reflink=auto $@.report $@.report.tmp
@ -351,6 +418,7 @@ define rule_FL2_insert
./scripts/ISO_copyFL2 to_iso $@.tmp $<.tmp $(1)
mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $@.report.tmp ::report.txt
-mattrib -i $@.tmp@@$(FAT_OFFSET) -r -s -h ::AUTOEXEC.BAT
mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $@.bat.tmp ::AUTOEXEC.BAT
-mdel -i $@.tmp@@$(FAT_OFFSET) ::EFI/Boot/BootX64.efi
-mattrib -i $@.tmp@@$(FAT_OFFSET) -r ::FLASH/README.TXT
@ -369,6 +437,117 @@ rule_FL2_insert_DEPS = scripts/ISO_copyFL2 # TODO - bat file
# - provide a simple mechanism for selecting the flash command to run, to
# allow for autoexec bat files that do not use dosflash
# Extract the CAP file from an EXE image
#
# $@ is the CAP file to create
# $< is the EXE file
# $1 is the pattern to match CAP file in EXE file
define rule_CAP_extract
innoextract $< -I $(1) -d tmp.inno
mv `find tmp.inno -type f` $@
touch $@
rm -rf tmp.inno
endef
rule_CAP_extract_DEPS = # no extra local dependancies
define rule_EXE_extract
$(call rule_CAP_extract,$1)
endef
rule_EXE_extract_DEPS = # no extra local dependancies
# TODO:
# - the following two rule_CAP_insert and rule_EXE_insert replicate a lot of
# logic included in rule_FL2_insert. See if we can refactor to share logic.
# Create a new CAP image with patches applied
# This is specifically for B590 firmware where we have to combine a bootable DOS
# ISO with the Flash-updater tool from an older .ZIP archive and a new capsule
# from an Innosetup .EXE and combine it together into an ISO image
#
# $@ is the CAP to create
# $< is the CAP
# $1 is the pattern to match CAP file in EXE file
# $2 Name of other ISO that should be taken as a template with a working DOS on it
# $3 ZIP file where to take the DOS flash updater program from
define rule_CAP_insert
$(call buildinfo_ISO)
@cp --reflink=auto $(2).orig $@.tmp
$(eval FAT_OFFSET := $(shell scripts/geteltorito -c $(2).orig 2>/dev/null))
-mkdir -p $@.orig.extract.tmp
unzip -o $(3).orig DOS/\* -x \*.cap \*.IMC \*.BAT -d $@.orig.extract.tmp/
-mattrib -i $@.tmp@@$(FAT_OFFSET) -r -/ ::FLASH/
mdeltree -i $@.tmp@@$(FAT_OFFSET) FLASH/
mmd -i $@.tmp@@$(FAT_OFFSET) FLASH
mcopy -o -s -m -i $@.tmp@@$(FAT_OFFSET) $@.orig.extract.tmp/DOS/* ::/FLASH/
@rm -r $@.orig.extract.tmp
@cp --reflink=auto $< $<.tmp
@cp --reflink=auto $@.report $@.report.tmp
@cp --reflink=auto $@.bat $@.bat.tmp
@touch --date="1980-01-01 00:00:01Z" $<.tmp $@.report.tmp $@.bat.tmp
@# TODO - datestamp here could be the lastcommitdatestamp
mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $<.tmp ::/FLASH/$<
mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $@.report.tmp ::report.txt
-mattrib -i $@.tmp@@$(FAT_OFFSET) -r -s -h ::AUTOEXEC.BAT
mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $@.bat.tmp ::AUTOEXEC.BAT
@rm $<.tmp $@.report.tmp $@.bat.tmp
@mv $@.tmp $@
endef
rule_CAP_insert_DEPS =
# TODO:
# - it is unclear if the dependancies for the $2 ISO image used below are
# handled
# - Similar to the prepare_iso_from_tpl, this looks like it has a bunch of
# logic due to some Lenovo images being broken. Look into what is broken
# and see if it is patchable without a template.
# Create a new EXE image with patches applied
# This is specifically for B580 firmware where we have to combine a bootable DOS
# ISO with a patched FL2 together into an ISO image
#
# $@ is the EXE to create
# $< is the CAP
# $1 is the pattern to match FL1 file in EXE file
# $2 Name of other ISO that should be taken as a template with DOS and DOSFLASH
define rule_EXE_insert
$(call buildinfo_ISO)
@cp -f --reflink=auto $(2).orig $@.tmp
$(eval FAT_OFFSET := $(shell scripts/geteltorito -c $(2).orig 2>/dev/null))
$(eval DOSFLASH := $(shell mdir -/ -b -i $(2).orig@@$(FAT_OFFSET) | grep -i DOSFLASH | head -1))
-rm -rf $@.orig.extract.tmp
mkdir $@.orig.extract.tmp
mcopy -n -s -m -i $@.tmp@@$(FAT_OFFSET) $(DOSFLASH) $@.orig.extract.tmp/
-mattrib -i $@.tmp@@$(FAT_OFFSET) -r -/ ::FLASH/
mdeltree -i $@.tmp@@$(FAT_OFFSET) FLASH/
mmd -i $@.tmp@@$(FAT_OFFSET) FLASH
mcopy -o -s -m -i $@.tmp@@$(FAT_OFFSET) $@.orig.extract.tmp/DOSFLASH.EXE ::/FLASH/
mcopy -o -s -m -i $@.tmp@@$(FAT_OFFSET) $< ::/FLASH/$(1)
rm -r $@.orig.extract.tmp
cp --reflink=auto $< $<.tmp
cp --reflink=auto $@.report $@.report.tmp
cp --reflink=auto $@.bat1 $@.bat.tmp
touch --date="1980-01-01 00:00:01Z" $<.tmp $@.report.tmp $@.bat.tmp
@# TODO - datestamp here could be the lastcommitdatestamp
./scripts/ISO_copyFL2 to_iso $@.tmp $<.tmp $(1)
-mdel -i $@.tmp@@$(FAT_OFFSET) ::EFI/Boot/BootX64.efi
mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $@.report.tmp ::report.txt
-mattrib -i $@.tmp@@$(FAT_OFFSET) -r -s -h ::AUTOEXEC.BAT
mcopy -t -m -o -i $@.tmp@@$(FAT_OFFSET) $@.bat.tmp ::AUTOEXEC.BAT
@rm $<.tmp $@.report.tmp $@.bat.tmp
@mv $@.tmp $@
endef
rule_EXE_insert_DEPS =
# Insert the new firmware into the FL2 file
#
# $@ is the FL2 to create
@ -406,6 +585,10 @@ define rule_IMGnoenc_extract
endef
rule_IMGnoenc_extract_DEPS = scripts/FL2_copyIMG
# TODO:
# - the rule_IMGnoenc_insert and rule_IMGnuvoton_insert share much of their
# logic. See if we can refactor them to remove duplication.
# Insert the new firmware into the FL2 file - special case, without encryption
#
# $@ is the FL2 to create
@ -418,6 +601,29 @@ define rule_IMGnoenc_insert
endef
rule_IMGnoenc_insert_DEPS = scripts/FL2_copyIMG
# Extract the IMG file from an FL1 file - special case, for NUVOTON controllers
#
# $@ is the IMG to create
# $< is the FL2
define rule_IMGnuvoton_extract
./scripts/FL2_copyIMG from_fl2 $< $@
endef
rule_IMGnuvoton_extract_DEPS = scripts/FL2_copyIMG
# Insert the new firmware into the FL2 file - special case, for NUVOTON controllers
#
# $@ is the FL1 to create
# $< is the IMG
define rule_IMGnuvoton_insert
./nuvoton-tools/npce885crc -o 0x8000 -u $<
cp --reflink=auto $@.orig $@.tmp
./scripts/FL2_copyIMG to_fl2 $@.tmp $<
mv $@.tmp $@
$(call buildinfo_FL2)
endef
rule_IMGnuvoton_insert_DEPS = scripts/FL2_copyIMG nuvoton-tools/npce885crc
# Extract the FL2 file from an ISO image with two FL2 files
#

@ -36,12 +36,6 @@ With the patches included here, you can install the classic keyboard
hardware on many xx30 series laptops and make almost every key work properly.
The only keys that are not working are Fn+F3 (Battery) and Fn+F12 (Hibernate)
Unfortunately, there are a small number of thinkpads with a model number
from the "xx30" series that are using a completely different EC CPU and
a different BIOS update strategy. Thus they are not currently able to
be patched. This is known to be the case for at least the L430, L530
and E330.
* A full writeup of the hardware modifications needed can be found at:
http://www.thinkwiki.org/wiki/Install_Classic_Keyboard_on_xx30_Series_ThinkPads
@ -50,6 +44,12 @@ and E330.
* A video presenting how these thinkpad laptops were hacked is online:
https://www.youtube.com/watch?v=Fzmm87oVQ6c
* Reverse engineering details for the L430, L530, B580, V480, V480c, V580,
V580c and E330 models can be found in the [thinkpad-Lx30-ec project](https://github.com/leecher1337/thinkpad-Lx30-ec).
Patches for patching the genuine battery check on these have been
contributed from that project. (These all have an Nuvotron EC, with a
different architecture to the original "classic" thinkpad models).
Step-by-step instructions:
--------------------------

@ -0,0 +1,39 @@
--- /tmp/$0AH1000.FL1.hex 2022-05-14 18:56:43.880739098 +0200
+++ /tmp/$0AH1000.FL1.bat.hex 2022-05-14 18:56:44.124742666 +0200
@@ -4197,14 +4197,14 @@
00010980 ff c0 97 a0 00 50 00 18 6a 05 70 5d 00 5f 04 55 |.....P..j.p]._.U|
00010990 24 4c 04 61 34 4c 24 00 01 00 82 00 14 90 81 49 |$L.a4L$........I|
000109a0 b1 22 1f 00 04 90 b0 22 e0 ff 10 27 04 d0 e0 18 |."....."...'....|
-000109b0 42 05 00 c0 72 8e 00 50 00 18 38 05 70 5d 00 5f |B...r..P..8.p]._|
+000109b0 42 05 00 c0 72 8e 00 50 e0 18 54 00 70 5d 00 5f |B...r..P..T.p]._|
000109c0 02 55 22 4c 02 61 32 4c 22 00 01 00 86 00 00 c0 |.U"L.a2L".......|
000109d0 54 91 72 59 ff c0 2b fe 00 01 10 58 00 01 72 5d |T.rY..+....X..r]|
000109e0 22 5f 20 55 20 4c 20 61 30 4c 20 00 01 00 86 00 |"_ U L a0L .....|
000109f0 10 01 b5 58 11 00 b4 58 27 00 b3 58 16 00 72 59 |...X...X'..X..rY|
00010a00 ff c0 49 98 8f 60 00 50 00 18 e8 04 70 5d 00 5f |..I..`.P....p]._|
00010a10 02 55 22 4c 02 61 32 4c 22 00 01 00 82 00 02 90 |.U"L.a2L".......|
-00010a20 b0 22 e0 ff 30 26 e0 18 c8 04 70 5d 00 5f 02 55 |."..0&....p]._.U|
+00010a20 b0 22 e0 ff c0 26 e0 18 c8 04 70 5d 00 5f 02 55 |."...&....p]._.U|
00010a30 22 4c 02 61 32 4c 22 00 01 00 82 00 b0 58 20 00 |"L.a2L"......X .|
00010a40 02 f3 14 01 72 59 ff c0 b9 fd 0f f0 72 5d 22 5f |....rY......r]"_|
00010a50 20 55 20 4c 20 61 30 4c 20 00 01 00 86 00 10 01 | U L a0L .......|
@@ -4228,8 +4228,8 @@
00010b70 cf 60 00 50 00 18 7c 03 70 5d 00 5f 02 55 22 4c |.`.P..|.p]._.U"L|
00010b80 02 61 32 4c 22 00 01 00 82 00 02 90 b0 22 e0 ff |.a2L"........"..|
00010b90 b0 26 09 00 e0 18 5a 03 72 5d 22 5f 20 55 20 4c |.&....Z.r]"_ U L|
-00010ba0 20 61 30 4c 20 00 01 00 82 00 30 7b 02 00 80 18 | a0L .....0{....|
-00010bb0 42 03 72 5d 22 5f 20 55 20 4c 20 61 30 4c 20 00 |B.r]"_ U L a0L .|
+00010ba0 20 61 30 4c 20 00 01 00 82 00 30 7b 02 00 e0 18 | a0L .....0{....|
+00010bb0 7e 00 72 5d 22 5f 20 55 20 4c 20 61 30 4c 20 00 |~.r]"_ U L a0L .|
00010bc0 01 00 82 00 60 7b 01 00 82 13 20 55 22 4c 02 61 |....`{.... U"L.a|
00010bd0 32 4c 22 00 01 00 a6 00 02 b1 20 50 a8 12 72 5d |2L"....... P..r]|
00010be0 22 5f 20 55 20 4c 20 61 30 4c 20 00 01 00 82 00 |"_ U L a0L .....|
@@ -4238,7 +4238,7 @@
00010c10 00 5f 02 55 22 4c 02 61 32 4c 22 00 01 00 82 00 |._.U"L.a2L".....|
00010c20 02 90 b0 22 e0 ff 20 26 e0 18 c6 02 70 5d 00 5f |...".. &....p]._|
00010c30 02 55 22 4c 02 61 32 4c 22 00 01 00 82 00 12 00 |.U"L.a2L".......|
-00010c40 00 71 96 04 62 7b 01 00 94 10 b0 20 fe ff e2 10 |.q..b{..... ....|
+00010c40 00 71 96 04 62 73 01 00 52 73 01 00 00 2c 00 2c |.q..bs..Rs...,.,|
00010c50 10 24 13 00 00 71 96 04 72 5d 22 5f 20 55 20 4c |.$...q..r]"_ U L|
00010c60 20 61 30 4c 20 00 01 00 82 00 00 71 02 00 20 55 | a0L ......q.. U|
00010c70 24 55 44 61 24 61 64 4c 24 00 01 00 76 05 20 4c |$UDa$adL$...v. L|

@ -0,0 +1,37 @@
--- /tmp/H9ET92WW.cap.hex 2022-02-13 00:08:42.554196371 +0000
+++ /tmp/H9ET92WW.cap.bat.hex 2022-02-13 00:08:42.642198385 +0000
@@ -4178,14 +4178,14 @@
00010850 c9 a1 00 50 00 18 6a 05 70 5d 00 5f 04 55 24 4c |...P..j.p]._.U$L|
00010860 04 61 34 4c 24 00 01 00 82 00 14 90 81 49 b1 22 |.a4L$........I."|
00010870 1f 00 04 90 b0 22 e0 ff 10 27 04 d0 e0 18 42 05 |....."...'....B.|
-00010880 00 c0 cc 8d 00 50 00 18 38 05 70 5d 00 5f 02 55 |.....P..8.p]._.U|
+00010880 00 c0 cc 8d 00 50 e0 18 54 00 70 5d 00 5f 02 55 |.....P..T.p]._.U|
00010890 22 4c 02 61 32 4c 22 00 01 00 86 00 00 c0 ae 90 |"L.a2L".........|
000108a0 72 59 ff c0 2b fe 00 01 10 58 00 01 72 5d 22 5f |rY..+....X..r]"_|
000108b0 20 55 20 4c 20 61 30 4c 20 00 01 00 86 00 10 01 | U L a0L .......|
000108c0 b5 58 11 00 b4 58 27 00 b3 58 16 00 72 59 ff c0 |.X...X'..X..rY..|
000108d0 7b 99 8f 60 00 50 00 18 e8 04 70 5d 00 5f 02 55 |{..`.P....p]._.U|
000108e0 22 4c 02 61 32 4c 22 00 01 00 82 00 02 90 b0 22 |"L.a2L"........"|
-000108f0 e0 ff 30 26 e0 18 c8 04 70 5d 00 5f 02 55 22 4c |..0&....p]._.U"L|
+000108f0 e0 ff c0 26 e0 18 c8 04 70 5d 00 5f 02 55 22 4c |...&....p]._.U"L|
00010900 02 61 32 4c 22 00 01 00 82 00 b0 58 20 00 02 f3 |.a2L"......X ...|
00010910 14 01 72 59 ff c0 b9 fd 0f f0 72 5d 22 5f 20 55 |..rY......r]"_ U|
00010920 20 4c 20 61 30 4c 20 00 01 00 86 00 10 01 72 5d | L a0L .......r]|
@@ -4209,7 +4209,7 @@
00010a40 00 50 00 18 7c 03 70 5d 00 5f 02 55 22 4c 02 61 |.P..|.p]._.U"L.a|
00010a50 32 4c 22 00 01 00 82 00 02 90 b0 22 e0 ff b0 26 |2L"........"...&|
00010a60 09 00 e0 18 5a 03 72 5d 22 5f 20 55 20 4c 20 61 |....Z.r]"_ U L a|
-00010a70 30 4c 20 00 01 00 82 00 30 7b 02 00 80 18 42 03 |0L .....0{....B.|
+00010a70 30 4c 20 00 01 00 82 00 30 7b 02 00 e0 18 7e 00 |0L .....0{....~.|
00010a80 72 5d 22 5f 20 55 20 4c 20 61 30 4c 20 00 01 00 |r]"_ U L a0L ...|
00010a90 82 00 60 7b 01 00 82 13 20 55 22 4c 02 61 32 4c |..`{.... U"L.a2L|
00010aa0 22 00 01 00 a6 00 02 b1 20 50 a8 12 72 5d 22 5f |"....... P..r]"_|
@@ -4219,7 +4219,7 @@
00010ae0 02 55 22 4c 02 61 32 4c 22 00 01 00 82 00 02 90 |.U"L.a2L".......|
00010af0 b0 22 e0 ff 20 26 e0 18 c6 02 70 5d 00 5f 02 55 |.".. &....p]._.U|
00010b00 22 4c 02 61 32 4c 22 00 01 00 82 00 12 00 00 71 |"L.a2L"........q|
-00010b10 96 04 62 7b 01 00 94 10 b0 20 fe ff e2 10 10 24 |..b{..... .....$|
+00010b10 96 04 62 73 01 00 52 73 01 00 00 2c 00 2c 10 24 |..bs..Rs...,.,.$|
00010b20 13 00 00 71 96 04 72 5d 22 5f 20 55 20 4c 20 61 |...q..r]"_ U L a|
00010b30 30 4c 20 00 01 00 82 00 00 71 02 00 20 55 24 55 |0L ......q.. U$U|
00010b40 44 61 24 61 64 4c 24 00 01 00 76 05 20 4c 20 61 |Da$adL$...v. L a|

@ -42,7 +42,7 @@ ThinkPad xx30 series:
(see discussion: http://notebook1.ru/forma1/viewtopic.php?f=70&t=109179)
The procedure for doing this is documented here: https://github.com/taglour/x230-ec-jtag
ThinkPad l430:
ThinkPad l420:
--------------
IT8511TE
@ -50,9 +50,15 @@ ThinkPad l430:
(source: schematics - http://www.informaticanapoli.it/download/SCHEMIELETTRICI/IBM-LENOVO/Lenovo%20laptop%20motherboard%20schematic%20diagram.pdf)
Thinkpad l430/l530:
-------------------
Nuvoton NPCE885G
This is a CR16C core CPU.
ThinkPad e330:
--------------
This is a 8051 core CPU, so probably a IT8511TE or similar
Nuvoton NPCE885G
(source: EC firmware similarity to the l430)

@ -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 .....|

@ -0,0 +1,51 @@
--- /tmp/$01D4000.FL1.hex 2021-12-23 23:34:53.026586003 +0000
+++ /tmp/$01D4000.FL1.kb.hex 2021-12-23 23:34:53.114588324 +0000
@@ -7541,8 +7541,8 @@
0001de60 4a 9f 4c 79 45 7c 4d 7b 5a 81 4e 7b 54 81 4a 79 |J.LyE|M{Z.N{T.Jy|
0001de70 4c 7b 45 9f 4d 7c 00 00 00 00 00 00 83 00 5a 01 |L{E.M|........Z.|
0001de80 1f 01 27 01 2f 01 37 01 3f 01 5e 01 02 05 04 05 |..'./.7.?.^.....|
-0001de90 08 05 08 06 10 05 10 06 40 05 20 05 00 00 00 04 |........@. .....|
-0001dea0 01 04 84 00 7c 01 7c 03 4a 01 4a 02 70 01 70 02 |....|.|.J.J.p.p.|
+0001de90 08 05 08 06 10 05 10 06 40 05 20 05 00 00 38 01 |........@. ...8.|
+0001dea0 30 01 84 00 7c 01 7c 03 4a 01 4a 02 70 01 70 02 |0...|.|.J.J.p.p.|
0001deb0 70 03 71 01 71 02 71 03 6c 01 6c 02 6c 03 69 01 |p.q.q.q.l.l.l.i.|
0001dec0 69 02 69 03 7d 01 7d 02 7d 03 7a 01 7a 02 7a 03 |i.i.}.}.}.z.z.z.|
0001ded0 6b 01 6b 02 6b 03 75 01 75 02 75 03 72 01 72 02 |k.k.k.u.u.u.r.r.|
@@ -7651,22 +7651,22 @@
0001e590 2d 36 36 36 36 36 36 36 2a 36 36 36 36 36 36 36 |-6666666*6666666|
0001e5a0 36 36 36 36 36 36 36 36 36 00 00 00 00 00 00 00 |666666666.......|
0001e5b0 00 00 00 00 00 00 00 00 00 00 00 00 54 0e 05 0a |............T...|
-0001e5c0 2e 36 55 16 4e 18 00 a2 a1 00 00 00 8c 16 1e 26 |.6U.N..........&|
-0001e5d0 25 3d 3e 46 45 1a 1e 1c a0 a3 00 00 00 15 1d 24 |%=>FE..........$|
-0001e5e0 2d 3c 43 44 28 6a 00 04 00 00 00 00 00 0d 58 0c |-<CD(j........X.|
-0001e5f0 2c 35 5b 14 54 66 82 02 00 00 00 88 00 1c 24 23 |,5[.Tf........$#|
-0001e600 2b 3b 26 4b 4c 5d 00 00 9d 00 00 00 00 76 61 0e |+;&KL].......va.|
-0001e610 34 33 12 64 52 10 00 08 00 a7 8a 00 00 1a 22 21 |43.dR........."!|
-0001e620 2a 3a 41 49 5d 5a 00 06 a4 00 00 89 8d 67 8e 00 |*:AI]Z.......g..|
-0001e630 22 31 51 13 4a 20 a9 a8 a5 a6 8b 00 00 00 00 00 |"1Q.J ..........|
-0001e640 00 00 00 00 00 00 00 00 00 00 00 00 00 44 01 00 |.............D..|
-0001e650 07 80 04 44 04 22 04 24 05 00 04 08 01 00 00 c1 |...D.".$........|
+0001e5c0 2e 36 55 0a 4e 01 a0 a1 20 18 00 00 8c 16 1e 26 |.6U.N... ......&|
+0001e5d0 25 aa ab ac be 09 07 78 a5 16 24 00 00 15 1d 24 |%......x..$....$|
+0001e5e0 2d ad ae af bf 6a 00 04 00 00 0c 00 00 0d 58 04 |-....j........X.|
+0001e5f0 2c 35 5b 14 54 66 82 02 00 00 00 88 00 1c 1b 23 |,5[.Tf.........#|
+0001e600 2b b0 b1 b2 bd 5d 00 00 84 00 00 00 00 76 61 0e |+....].......va.|
+0001e610 34 33 12 64 52 10 00 08 00 26 8a 00 00 1a 22 21 |43.dR....&...."!|
+0001e620 2a b3 41 b4 5d 5a 00 06 91 22 00 89 8d 67 8e 00 |*.A.]Z..."...g..|
+0001e630 32 31 51 13 bc 29 1e 1c 92 1a 8b 00 00 00 00 00 |21Q..)..........|
+0001e640 00 00 00 00 00 00 00 00 00 00 00 00 00 04 18 00 |................|
+0001e650 30 00 24 40 04 00 04 24 15 00 14 00 16 00 00 c1 |0.$@...$........|
0001e660 c1 10 b0 c3 c3 30 b1 c5 c5 30 b2 c7 c7 10 b3 c9 |.....0...0......|
-0001e670 c9 30 b4 06 cb 10 c2 04 cd 10 c3 0c cf 10 c4 03 |.0..............|
-0001e680 d1 10 c5 0b d3 10 c6 80 d5 10 c7 0a d7 30 bb 01 |.............0..|
-0001e690 d9 30 bc 09 db 30 b9 78 dd 10 b8 07 df 30 ba 29 |.0...0.x.....0.)|
-0001e6a0 e1 10 b6 32 e3 10 d0 1b e5 10 d1 42 e7 10 d2 4d |...2.......B...M|
-0001e6b0 e9 10 d3 00 5c 0e 05 1e 2e 36 55 2a 4e 01 a0 a1 |....\....6U*N...|
+0001e670 c9 30 b4 06 cb 10 c3 e7 cd 10 bd 0c cf 10 c4 03 |.0..............|
+0001e680 d1 10 c5 0b d3 10 c6 80 d5 10 c7 a3 d7 30 bb a2 |.............0..|
+0001e690 d9 30 bc a6 db 30 b9 a8 dd 10 b8 a9 df 30 ba a4 |.0...0.......0..|
+0001e6a0 e1 10 b6 e9 e3 10 d0 9d e5 10 d1 a7 e8 10 d2 10 |................|
+0001e6b0 b7 10 d3 00 5c 0e 05 1e 2e 36 55 2a 4e 01 a0 a1 |....\....6U*N...|
0001e6c0 0c 1a 00 00 8c 16 1e 26 25 aa ab ac 45 09 2c 78 |.......&%...E.,x|
0001e6d0 a5 18 00 00 00 15 1d 24 2d ad ae af 4d 00 00 06 |.......$-...M...|
0001e6e0 00 00 1c 00 00 0d 58 20 2c 35 5b 28 54 66 82 04 |......X ,5[(Tf..|

@ -0,0 +1,38 @@
--- /tmp/$01D4000.FL1.hex 2021-12-23 23:34:53.026586003 +0000
+++ /tmp/$01D4000.FL1.bat.hex 2021-12-23 23:34:53.210590857 +0000
@@ -4151,13 +4151,13 @@
00010940 00 18 1e 07 70 5d 00 5f 04 55 24 4c 04 61 34 4c |....p]._.U$L.a4L|
00010950 24 00 01 00 4a 00 14 90 81 49 b1 22 1f 00 04 90 |$...J....I."....|
00010960 b0 22 e0 ff 10 27 04 d0 e0 18 f6 06 00 c0 a2 8b |."...'..........|
-00010970 00 50 00 18 ec 06 70 5d 00 5f 02 55 22 4c 02 61 |.P....p]._.U"L.a|
+00010970 00 50 e0 18 54 00 70 5d 00 5f 02 55 22 4c 02 61 |.P..T.p]._.U"L.a|
00010980 32 4c 22 00 01 00 4e 00 00 c0 84 8e 72 59 ff c0 |2L"...N.....rY..|
00010990 15 fe 00 01 10 58 00 01 72 5d 22 5f 20 55 20 4c |.....X..r]"_ U L|
000109a0 20 61 30 4c 20 00 01 00 4e 00 10 01 b5 58 11 00 | a0L ...N....X..|
000109b0 b4 58 27 00 b3 58 16 00 72 59 ff c0 cd 96 8f 60 |.X'..X..rY.....`|
000109c0 00 50 00 18 9c 06 70 5d 00 5f 02 55 22 4c 02 61 |.P....p]._.U"L.a|
-000109d0 32 4c 22 00 01 00 4a 00 02 90 b0 22 e0 ff 30 26 |2L"...J...."..0&|
+000109d0 32 4c 22 00 01 00 4a 00 02 90 b0 22 e0 ff c0 26 |2L"...J...."...&|
000109e0 e0 18 7c 06 70 5d 00 5f 02 55 22 4c 02 61 32 4c |..|.p]._.U"L.a2L|
000109f0 22 00 01 00 4a 00 b0 58 20 00 02 f3 1e 01 72 59 |"...J..X .....rY|
00010a00 ff c0 a3 fd 0f f0 72 5d 22 5f 20 55 20 4c 20 61 |......r]"_ U L a|
@@ -4182,7 +4182,7 @@
00010b30 30 05 70 5d 00 5f 02 55 22 4c 02 61 32 4c 22 00 |0.p]._.U"L.a2L".|
00010b40 01 00 4a 00 02 90 b0 22 e0 ff b0 26 09 00 e0 18 |..J...."...&....|
00010b50 0e 05 72 5d 22 5f 20 55 20 4c 20 61 30 4c 20 00 |..r]"_ U L a0L .|
-00010b60 01 00 4a 00 30 7b 02 00 80 18 f6 04 20 55 22 4c |..J.0{...... U"L|
+00010b60 01 00 4a 00 30 7b 02 00 e0 18 5a 00 20 55 22 4c |..J.0{....Z. U"L|
00010b70 02 61 32 4c 22 00 01 00 6e 00 02 b1 00 50 12 12 |.a2L"...n....P..|
00010b80 72 59 ff c0 cd f3 00 50 1d 11 70 5d 00 5f 02 55 |rY.....P..p]._.U|
00010b90 22 4c 02 61 32 4c 22 00 01 00 4a 00 02 90 b0 22 |"L.a2L"...J...."|
@@ -4190,8 +4190,8 @@
00010bb0 34 4c 24 00 01 00 6e 00 04 b1 10 30 04 f1 e0 18 |4L$...n....0....|
00010bc0 a0 04 72 5d 22 5f 20 55 20 4c 20 61 30 4c 20 00 |..r]"_ U L a0L .|
00010bd0 01 00 6e 00 00 83 01 00 72 5d 22 5f 20 55 20 4c |..n.....r]"_ U L|
-00010be0 20 61 30 4c 20 00 01 00 4a 00 60 7b 01 00 9c 11 | a0L ...J.`{....|
-00010bf0 72 5d 22 5f 20 55 20 4c 20 61 30 4c 20 00 01 00 |r]"_ U L a0L ...|
+00010be0 20 61 30 4c 20 00 01 00 4a 00 60 73 01 00 50 73 | a0L ...J.`s..Ps|
+00010bf0 01 00 e0 18 2c 00 20 4c 20 61 30 4c 20 00 01 00 |....,. L a0L ...|
00010c00 4a 00 50 7b 01 00 8c 10 20 55 22 4c 02 61 32 4c |J.P{.... U"L.a2L|
00010c10 22 00 01 00 4a 00 02 90 10 49 00 50 05 10 10 00 |"...J....I.P....|
00010c20 00 71 84 04 e4 10 10 00 00 b1 84 04 72 5d 22 5f |.q..........r]"_|

@ -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,
};

@ -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

@ -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 <file>: Write extracted data to file <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);

@ -258,6 +258,14 @@ sub main() {
next;
}
if (-z $patchfile) {
warn("Patchfile $patchfile is zero bytes, skipping\n");
if ($fail_on_missing) {
exit(1);
}
next;
}
my $db = read_patchfile($patchfile);
if (!defined($db)) {

Loading…
Cancel
Save