enable flashrom and pciutils to allow the boot ROM to be re-written (issue #17)

This commit is contained in:
Trammell Hudson 2017-03-30 14:35:30 -04:00
parent 9666f52e44
commit 9feb094701
No known key found for this signature in database
GPG Key ID: C7CFA251FF608213
6 changed files with 90 additions and 22 deletions

View File

@ -231,7 +231,8 @@ endef
$(foreach _, $(call bins,kexec), $(eval $(call initrd_bin_add,$_)))
$(foreach _, $(call bins,tpmtotp), $(eval $(call initrd_bin_add,$_)))
$(foreach _, $(call bins,bioswrite), $(eval $(call initrd_bin_add,$_)))
$(foreach _, $(call bins,pciutils), $(eval $(call initrd_bin_add,$_)))
$(foreach _, $(call bins,flashrom), $(eval $(call initrd_bin_add,$_)))
$(foreach _, $(call bins,cryptsetup), $(eval $(call initrd_bin_add,$_)))
$(foreach _, $(call bins,gpg), $(eval $(call initrd_bin_add,$_)))
$(foreach _, $(call bins,lvm2), $(eval $(call initrd_bin_add,$_)))

View File

@ -617,7 +617,7 @@ CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
# CONFIG_IPCRM is not set
# CONFIG_IPCS is not set
CONFIG_LOSETUP=y
CONFIG_LSPCI=y
# CONFIG_LSPCI is not set
CONFIG_LSUSB=y
# CONFIG_MKSWAP is not set
# CONFIG_FEATURE_MKSWAP_UUID is not set

View File

@ -1,20 +0,0 @@
modules += bioswrite
bioswrite_depends := $(musl_dep)
bioswrite_version := git
bioswrite_repo := https://github.com/osresearch/bioswrite
#bioswrite_version := 0.2.1
bioswrite_dir := bioswrite-$(bioswrite_version)
bioswrite_tar := bioswrite-$(bioswrite_version).tar.gz
bioswrite_url := https://github.com/osresearch/bioswrite/archive/v$(bioswrite_version).tar.gz
bioswrite_hash := e8205aa3d19e536080f5974ed06ab9a88c4c3f37870c2f6a3a08a2f39302c22c
bioswrite_target := \
CC="$(heads_cc)" \
bioswrite_output := \
bioswrite \
bioswrite_configure :=

24
modules/flashrom Normal file
View File

@ -0,0 +1,24 @@
modules += flashrom
flashrom_depends := pciutils $(musl_dep)
#flashrom_version := git
#flashrom_repo := https://github.com/osresearch/flashrom
flashrom_version := 0.9.9
flashrom_dir := flashrom-$(flashrom_version)
flashrom_tar := flashrom-$(flashrom_version).tar.bz2
flashrom_url := http://download.flashrom.org/releases/$(flashrom_tar)
flashrom_hash := cb3156b0f63eb192024b76c0814135930297aac41f80761a5d293de769783c45
flashrom_target := \
CC="$(heads_cc)" \
CONFIG_ENABLE_LIBUSB0_PROGRAMMERS=no \
CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no \
flashrom_output := \
flashrom
flashrom_libraries := \
flashrom_configure :=

30
modules/pciutils Normal file
View File

@ -0,0 +1,30 @@
modules += pciutils
pciutils_depends := $(musl_dep)
#pciutils_version := git
#pciutils_repo := https://github.com/osresearch/pciutils
pciutils_version := 3.5.4
pciutils_dir := pciutils-$(pciutils_version)
pciutils_tar := pciutils-$(pciutils_version).tar.xz
pciutils_url := https://www.kernel.org/pub/software/utils/pciutils/$(pciutils_tar)
pciutils_hash := 64293c6ab9318c40ef262b76d87bd9097531759752bac556e50979b1e63cfe66
pciutils_target := \
$(MAKE_JOBS) \
CC="$(heads_cc)" \
ZLIB=no \
HWDB=no \
SHARED=yes \
PREFIX=$(INSTALL) \
install \
install-lib \
pciutils_output := \
lspci \
pciutils_libraries := \
../../install/lib/libpci.so.3 \
pciutils_configure :=

View File

@ -0,0 +1,33 @@
diff -u --recursive ../clean/flashrom-0.9.9/spi.c flashrom-0.9.9/spi.c
--- ../clean/flashrom-0.9.9/spi.c 2014-07-19 18:03:29.000000000 -0400
+++ flashrom-0.9.9/spi.c 2017-03-30 13:50:15.007897599 -0400
@@ -100,6 +100,20 @@
return spi_write_chunked(flash, buf, start, len, max_data);
}
+static int my_ffs(int x)
+{
+ int rc = 0;
+ while(x)
+ {
+ if (x & 1)
+ return rc;
+ rc++;
+ x >>= 1;
+ }
+
+ return 0;
+}
+
int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start,
unsigned int len)
{
@@ -119,7 +133,7 @@
/* Check if alignment is native (at least the largest power of two which
* is a factor of the mapped size of the chip).
*/
- if (ffs(flash->chip->total_size * 1024) > (ffs(addrbase) ? : 33)) {
+ if (my_ffs(flash->chip->total_size * 1024) > (my_ffs(addrbase) ? : 33)) {
msg_perr("Flash chip is not aligned natively in the allowed "
"access window.\n");
msg_perr("Read will probably return garbage.\n");