From 7ff25fd1932471a23827ef821be97fc4969910e1 Mon Sep 17 00:00:00 2001
From: Francis Rowe
Date: Mon, 24 Nov 2014 21:32:35 -0500
Subject: libreboot_bin.tar.xz: Include utils as statically linked binaries
This means that the user does not have to install build dependency
or build from source anymore.
---
diff --git a/addseabios b/addseabios
index 1d9147e..1cc1aad 100755
--- a/addseabios
+++ b/addseabios
@@ -30,8 +30,24 @@ if [ -f "DEBLOB" ]; then
exit 1
fi
-if [ ! -f "cbfstool" ]; then
- echo "cbfstool not found. Please run ./builddeps-cbfstool first. Check the docs for how to get build dependencies."
+if [ $(uname -i) = "i686" ] || [ $(uname -i) = "i686" ]
+ then
+ echo "You are on an i686 host"
+ if [ ! -f "cbfstool/i686/cbfstool" ]; then
+ echo "cbfstool binary not found. You will need to build it from source and put it in cbfstool/i686/"
+ exit 1
+ fi
+ $cbfstool = "../cbfstool/i686/cbfstool"
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -i) = "x86_64" ]
+ then
+ echo "You are on an x86_64 host"
+ if [ ! -f "cbfstool/x86_64/cbfstool" ]; then
+ echo "cbfstool binary not found. You will need to build it from source and put it in cbfstool/x86_64/"
+ exit 1
+ fi
+ $cbfstool = "../cbfstool/x86_64/cbfstool"
+else
+ echo "You need to run this script on an i686 or x86_64 host"
exit 1
fi
@@ -40,23 +56,23 @@ cd bin/
for rom in $(find -type f)
do
# Add them
- ../cbfstool $rom add -f ../vgabios.bin -n vgaroms/vgabios.bin -t raw
- ../cbfstool $rom add -f ../bios.bin.elf -n bios.bin.elf -t raw
+ $cbfstool $rom add -f ../vgabios.bin -n vgaroms/vgabios.bin -t raw
+ $cbfstool $rom add -f ../bios.bin.elf -n bios.bin.elf -t raw
# Modify the GRUB configuration
for config in grub.cfg grubtest.cfg
do
# Extract (dump) the config
- ../cbfstool $rom extract -n $config -f $config
+ $cbfstool $rom extract -n $config -f $config
# Delete it from the ROM
- ../cbfstool $rom remove -n $config
+ $cbfstool $rom remove -n $config
# Add the menuentry for loading SeaBIOS
- cat ../resources/grub/config/seabios.cfg >> $config
+ cat seabios.cfg >> $config
# Re-add the newly modified GRUB configuration to the ROM
- ../cbfstool $rom add -f $config -n $config -t raw
+ $cbfstool $rom add -f $config -n $config -t raw
# The GRUB configuration is no longer needed
rm -rf $config
diff --git a/build-release b/build-release
index 82cb065..3879e45 100755
--- a/build-release
+++ b/build-release
@@ -21,10 +21,23 @@
set -u -e -v
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ echo "Running on i686. ok."
+ sleep 5
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ echo "Running on x86_64. ok."
+ sleep 5
+else
+ echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
+ exit 1
+fi
+
# MAKE SURE THAT YOU RAN "buildall" OR "builddeps" *AT LEAST ONCE*
# You should also run the 'build' script before running this
-# Delete old archives before continuing
+# ### Delete old archives before continuing
# ----------------------------------------------------------------------------------------------------------------------------
echo "Deleting old release archives"
@@ -35,7 +48,7 @@ rm -rf libreboot_bin.tar.xz
# Get manifest which will be used to copy everything
ls > releasefilelist
-# Prepare libreboot_src archive ready for release
+# ### Prepare libreboot_src archive ready for release
# ----------------------------------------------------------------------------------------------------------------------------
echo "Preparing libreboot_src release archive"
@@ -47,7 +60,7 @@ do
cp -r $resource libreboot_src
done
-cd libreboot_src
+cd libreboot_src/
# clean everything
./cleandeps
@@ -55,12 +68,12 @@ cd libreboot_src
# back to main checkout directory
cd ../
-# Further work in libreboot_src: delete *.git and *.svn
-# To save space since they are not useful in the release archives
-# Changes to these projects should be submitted upstream
+# ### Further work in libreboot_src: delete *.git and *.svn
+# ### To save space since they are not useful in the release archives
+# ### Changes to these projects should be submitted upstream
# ----------------------------------------------------------------------------------------------------------------------------
-cd libreboot_src
+cd libreboot_src/
# These instructions will also work even if .git or .svn are already deleted
# because "rm -rf" won't complain if they are missing. It is still useful on
@@ -86,7 +99,7 @@ rm -rf .git*
# that libreboot would be distributing blobs)
# Flashrom:
-cd flashrom
+cd flashrom/
rm -rf .svn
cd ../
@@ -97,91 +110,190 @@ rm -rf .gitignore
cd ../
# SeaBIOS:
-cd seabios
+cd seabios/
rm -rf .git
rm -rf .gitignore
cd ../
cd ../
-# Prepare libreboot_bin archive ready for release
+# ### Prepare libreboot_bin archive ready for release
# ----------------------------------------------------------------------------------------------------------------------------
echo "Preparing libreboot_bin release archive"
mkdir libreboot_bin
+# ---------------------------------------
# Include the ROM's in the binary archive
+# ---------------------------------------
cp -r bin libreboot_bin/
+# ---------------
+# SeaBIOS related
+# ---------------
# Include SeaBIOS and SeaVGABIOS option ROM in the binary archive
cp seabios/out/vgabios.bin libreboot_bin/
cp seabios/out/bios.bin.elf libreboot_bin/
# Add the script for it
cp addseabios libreboot_bin/
+# Menu entry to be added to grub configs
+cp resources/grub/config/seabios.cfg libreboot_bin/
+# --------------
+# BUC.TS related
+# --------------
+# X60/T60: BUC.TS utility is needed to flash libreboot while Lenovo BIOS is running
+# Include it statically compiled
+cp -r bucts bucts_
+cd bucts/
+# make it statically compile
+git apply ../resources/bucts/patch/staticlink.diff
+make clean
+make
+mkdir ../libreboot_bin/bucts
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ mkdir ../libreboot_bin/bucts/i686
+ mv bucts ../libreboot_bin/bucts/i686
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ mkdir ../libreboot_bin/bucts/x86_64
+ mv bucts ../libreboot_bin/bucts/x86_64
+fi
+cd ../
+rm -rf bucts
+mv bucts_ bucts
+
+# ----------------
+# Flashrom related
+# ----------------
# Include flashrom utility in binary archive
# (source only, no binaries. To eliminate cross-distro dependency issue)
-cp -r libreboot_src/flashrom libreboot_bin/
-
-# For installing build dependencies
-cp deps-trisquel libreboot_bin/
-cp deps-parabola libreboot_bin/
-
-# Build scripts for flashrom and bucts
-cp builddeps-flashrom libreboot_bin/
-cp builddeps-bucts libreboot_bin/
+# cp -r libreboot_src/flashrom libreboot_bin/
+
+# Flashrom is used to install libreboot on supported targets
+# Include it statically compiled
+cp -r flashrom flashrom_
+# make it statically compile
+./builddeps-flashrom static
+mkdir libreboot_bin/flashrom
+cd flashrom/
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ mkdir ../libreboot_bin/flashrom/i686
+ mv flashrom ../libreboot_bin/flashrom/i686
+ mv flashrom_lenovobios_sst ../libreboot_bin/flashrom/i686
+ mv flashrom_lenovobios_macronix ../libreboot_bin/flashrom/i686
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ mkdir ../libreboot_bin/flashrom/x86_64
+ mv flashrom ../libreboot_bin/flashrom/x86_64
+ mv flashrom_lenovobios_sst ../libreboot_bin/flashrom/x86_64
+ mv flashrom_lenovobios_macronix ../libreboot_bin/flashrom/x86_64
+fi
+cd ../
+rm -rf flashrom
+mv flashrom_ flashrom
+
+# ----------------
+# cbfstool related
+# ----------------
+# build cbfstool, compiled (statically linked) and include the binary
+cd coreboot/util/
+cp -r cbfstool cbfstool_
+cd cbfstool
+make clean
+make SHARED=0 CC='gcc -static'
+mkdir ../../../libreboot_bin/cbfstool
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # User is building on 32-bit host. Build only 32-bit binaries
+ mkdir ../../../libreboot_bin/cbfstool/i686
+ mv cbfstool ../../../libreboot_bin/cbfstool/i686/
+ mv rmodtool ../../../libreboot_bin/cbfstool/i686/
+elif [ $(uname -i) = "x86_64" ] || $(uname -m) = "x86_64"
+ then
+ # Build the 64-bit binaries
+ mkdir ../../../libreboot_bin/cbfstool/x86_64
+ mv cbfstool ../../../libreboot_bin/cbfstool/x86_64/
+ mv rmodtool ../../../libreboot_bin/cbfstool/x86_64/
+ # Now build 32-bit binaries
+ make clean
+ make SHARED=0 CC='gcc -static -m32'
+ mkdir ../../../libreboot_bin/cbfstool/i686
+ mv cbfstool ../../../libreboot_bin/cbfstool/i686/
+ mv rmodtool ../../../libreboot_bin/cbfstool/i686/
+fi
+cd ../
+rm -rf cbfstool
+mv cbfstool_ cbfstool
+cd ../../
+
+# -----------------
+# nvramtool related
+# -----------------
+# build nvramtool, compiled (statically linked) and include the binary
+cd coreboot/util/
+cp -r nvramtool nvramtool_
+cd nvramtool
+make clean
+make SHARED=0 CC='gcc -static'
+mkdir ../../../libreboot_bin/nvramtool
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # User is building on 32-bit host. Build only 32-bit binaries
+ mkdir ../../../libreboot_bin/nvramtool/i686
+ mv nvramtool ../../../libreboot_bin/nvramtool/i686/
+elif [ $(uname -i) = "x86_64" ] || $(uname -m) = "x86_64"
+ then
+ # Build the 64-bit binaries
+ mkdir ../../../libreboot_bin/nvramtool/x86_64
+ mv nvramtool ../../../libreboot_bin/nvramtool/x86_64/
+ # Now build 32-bit binaries
+ make clean
+ make SHARED=0 CC='gcc -static -m32'
+ mkdir ../../../libreboot_bin/nvramtool/i686
+ mv nvramtool ../../../libreboot_bin/nvramtool/i686/
+fi
+cd ../
+rm -rf nvramtool
+mv nvramtool_ nvramtool
+cd ../../
-# Include the same documentation in binary archive
+# ---------------------
+# Include documentation
+# ---------------------
cp -r docs libreboot_bin/
-# include X60 cmos.layout file
-cp coreboot/src/mainboard/lenovo/x60/cmos.layout libreboot_bin/x60cmos.layout
-cp coreboot/src/mainboard/lenovo/t60/cmos.layout libreboot_bin/t60cmos.layout
-cp coreboot/src/mainboard/apple/macbook21/cmos.layout libreboot_bin/macbook21cmos.layout
-
-# X60/T60: BUC.TS utility is needed to flash libreboot while Lenovo BIOS is running
-# (source only, no binaries. To eliminate cross-distro dependency issue)
-cp -r libreboot_src/bucts libreboot_bin/
-
-# Include a copy of nvramtool in libreboot_bin
-# (source only, no binaries. To eliminate cross-distro dependency issue)
-cp -r libreboot_src/coreboot/util/nvramtool libreboot_bin/
-
+# -----------------------------------------------------------------------
# X60/X60T/T60: Script for setting up powertop (kills high pitched noise)
+# -----------------------------------------------------------------------
cp powertop.trisquel6 libreboot_bin/
cp powertop.trisquel6.init libreboot_bin/
+cp powertop.trisquel7 libreboot_bin/
+cp powertop.trisquel7.init libreboot_bin/
-cp macbook21_firstflash ../libreboot_bin
-
-# (lazy hack) to make builddep-flashrom work in libreboot_bin:
-cp -r resources libreboot_bin/
-
-# X60/T60: so that the user can use libreboot_bin to overwrite lenovo bios with libreboot
-cp lenovobios_firstflash libreboot_bin/
-cp lenovobios_secondflash libreboot_bin/
+# -------------
+# Miscellaneous
+# -------------
+# include X60 cmos.layout file
+cp coreboot/src/mainboard/lenovo/x60/cmos.layout libreboot_bin/x60cmos.layout
+cp coreboot/src/mainboard/lenovo/t60/cmos.layout libreboot_bin/t60cmos.layout
+cp coreboot/src/mainboard/apple/macbook21/cmos.layout libreboot_bin/macbook21cmos.layout
+# FLASHING SCRIPTS
# Flashrom script (makes flashing easier: ./flash path/to/libreboot.rom)
cp flash libreboot_bin/
-
# For those upgrading from libreboot 5th release (or lower) to latest, on the X60
cp x60flashfrom5 libreboot_bin/
+# X60/T60: so that the user can use libreboot_bin to overwrite lenovo bios with libreboot
+cp lenovobios_firstflash libreboot_bin/
+cp lenovobios_secondflash libreboot_bin/
+# For initial flashing on macbook21/11
+cp macbook21_firstflash libreboot_bin/
-# patch the version of cbfstool included in libreboot_bin,
-# so that it can be built/executed standalone
-# this modification is only suitable for the version included in libreboot_bin
-# do not patch the one in libreboot_src with this
-# (source only, no binaries. To eliminate cross-distro dependency issue)
-cp -r libreboot_src/coreboot/util/cbfstool libreboot_bin/cbfstool_standalone
-# Patching libreboot_bin/cbfstool_standalone to be buildable (and executable) without residing in coreboot source tree
-rm -rf libreboot_bin/cbfstool_standalone/rmodule.c
-cp resources/cbfstool/patch/rmodule.c libreboot_bin/cbfstool_standalone/rmodule.c
-cp libreboot_src/coreboot/src/include/rmodule-defs.h libreboot_bin/cbfstool_standalone/rmodule-defs.h
-
-# Include builddeps-cbfstool in binary release archive
-cp builddeps-cbfstool libreboot_bin/
-
-# Create the release tarballs
+# ### Create the release tarballs
# ----------------------------------------------------------------------------------------------------------------------------
# Also delete the manifest
@@ -189,6 +301,11 @@ rm -rf libreboot_src/releasefilelist
rm -rf libreboot_bin/releasefilelist
rm -rf releasefilelist
+# We don't want to encourage development
+# to happen on the release archives.
+# Development goes in git.
+rm -rf libreboot_src/build-release
+
echo "Creating compressed libreboot_src release archive"
# create lzma compressed src archive
@@ -199,7 +316,7 @@ echo "Creating compressed libreboot_bin release archive"
# create lzma compressed bin archive
tar cfJ libreboot_bin.tar.xz libreboot_bin
-# Delete the uncompressed release directories
+# ### Delete the uncompressed release directories
# ----------------------------------------------------------------------------------------------------------------------------
echo "Deleted the uncompressed release archives"
diff --git a/builddeps-cbfstool b/builddeps-cbfstool
deleted file mode 100755
index 57d903f..0000000
--- a/builddeps-cbfstool
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-
-# builddeps-cbfstool script: builds cbfstool (this script is for libreboot_bin)
-#
-# Copyright (C) 2014 Francis Rowe
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-
-set -u -e -v
-
-# DO NOT RUN THIS IN libreboot_src OR libreboot_meta
-# THIS IS FOR libreboot_bin
-
-# Because the DEBLOB script isn't included in the binary archives.
-# This is how we know.
-if [ -f "DEBLOB" ]; then
- echo "Do not run this in meta/src directory. Do it in binary archive, either with libreboot-supplied ROM images or your own binary archive created with 'build-release'."
- exit 1
-fi
-
-cd cbfstool_standalone
-make clean
-make
-rm -rf ../cbfstool
-rm -rf ../rmodtool
-mv cbfstool ..
-mv rmodtool ..
-make clean
-cd ..
diff --git a/builddeps-flashrom b/builddeps-flashrom
index e659b3c..d630827 100755
--- a/builddeps-flashrom
+++ b/builddeps-flashrom
@@ -42,7 +42,11 @@ rm -rf flashrom_lenovobios_macronix
mv flashchips.c flashchips.c_
cp ../resources/flashrom/patch/flashchips.c .
# build flashrom
-make
+if (( $# != 1 )); then
+ make
+else
+ make SHARED=0 CC='gcc -static'
+fi
# restore default flashchips.c
rm -rf flashchips.c
mv flashchips.c_ flashchips.c
@@ -53,13 +57,21 @@ mv flashchips.c flashchips.c_
# build patched version for MX25L1605D flash chip on Lenovo BIOS X60/T60
cp ../resources/flashrom/patch/flashchips.c_lenovobios_macronix flashchips.c
-make
+if (( $# != 1 )); then
+ make
+else
+ make SHARED=0 CC='gcc -static'
+fi
mv flashrom flashrom_lenovobios_macronix
rm -rf flashchips.c
# build patched version for SST25VF016B flash chip on Lenovo BIOS X60/T60
cp ../resources/flashrom/patch/flashchips.c_lenovobios_sst flashchips.c
-make
+if (( $# != 1 )); then
+ make
+else
+ make SHARED=0 CC='gcc -static'
+fi
mv flashrom flashrom_lenovobios_sst
rm -rf flashchips.c
diff --git a/docs/git/index.html b/docs/git/index.html
index 8858af5..ef16ce2 100644
--- a/docs/git/index.html
+++ b/docs/git/index.html
@@ -122,6 +122,10 @@
"BUC" means "Backup Control" (it's a register) and "TS" means "Top Swap"
(it's a status bit). Hence "bucts" (BUC.TS). TS 1 and TS 0 corresponds to bucts 1 and bucts 0.
+
+
+ If you have the binary release archive, you'll find executables under ./bucts/. Otherwise if you need to build from source, continue reading.
+
First, install the build dependencies.
@@ -150,6 +154,12 @@
Flashrom source code is included in libreboot_src.tar.gz and libreboot_bin.tar.gz.
If you downloaded from git, follow #build_meta before you proceed.
+
+
+ If you are using the binary release archive, then there are already binaries included
+ under ./bin/. The flashing scripts will try to choose the correct one for you. Otherwise
+ if you wish to re-build flashrom from source, continue reading.
+
First, install the build dependencies.
@@ -422,6 +432,13 @@
You don't need to do much, as there are scripts already written for you that can build everything automatically.
+ You can build libreboot from source on a 32-bit (i686) or 64-bit (x86_64) system. Recommended (if possible): x86_64.
+ On a ThinkPad T60, you can replace the CPU (Core 2 Duo T5600, T7200 or T7600. T5600 recommended) for 64-bit support.
+ On an X60s, you can replace the board with one that has a Core 2 Duo L7400 (you could also use an X60 Tablet board with the same CPU).
+ On an X60, you can replace the board with one that has a Core 2 Duo T5600 or T7200 (T5600 is recommended).
+
+
+
First, install the build dependencies.
@@ -453,6 +470,22 @@
+ If you are building on an i686 host, this will include statically linked 32-bit binaries in the binary release archive that you created,
+ for: nvramtool, cbfstool, bucts, flashrom.
+
+
+
+ If you are building on an x86_64 host, this will include statically linked 32- and 64-bit binaries for cbfstool and nvramtool, while flashrom
+ and bucts will be included only as 64-bit statically linked binaries. To include a statically linked flashrom and bucts for i686, you
+ will need to build them on a chroot, a virtual machine or a real 32-bit system. You can find the build dependencies for these packages listed in deps-*
+
+
+
+ If you are building 32-bit binaries on a live system or chroot (for flashrom/bucts), you can use the following to statically link them:
+ $ make SHARED=0 CC='gcc -static'
+
+
+
You'll find that the files libreboot_bin.tar.xz and libreboot_src.tar.xz have been created.
@@ -479,8 +512,8 @@
- Build cbfstool:
- $ ./builddeps-cbfstool
+ Binaries for cbfstool are provided (built from libreboot_src) statically linked under cbfstool/ and the addseabios
+ script (see below) will try to automatically select the right one to use.
diff --git a/docs/gnulinux/grub_cbfs.html b/docs/gnulinux/grub_cbfs.html
index 63b9551..8b5a8a6 100644
--- a/docs/gnulinux/grub_cbfs.html
+++ b/docs/gnulinux/grub_cbfs.html
@@ -90,9 +90,7 @@
executable.
- Alternatively if you are working with libreboot_bin, then you can run ./builddeps-cbfstool
- command inside libreboot_bin/; a cbfstool and rmodtool
- executable will appear under libreboot_bin/
+ Alternatively if you are working with libreboot_bin, you will find binaries under ./cbfstool/
diff --git a/flash b/flash
index fdc13d6..2c6e800 100755
--- a/flash
+++ b/flash
@@ -22,6 +22,19 @@
# set -u -e -v
set -v
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ echo "Running on i686. ok."
+ sleep 5
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ echo "Running on x86_64. ok."
+ sleep 5
+else
+ echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
+ exit 1
+fi
+
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
@@ -41,8 +54,15 @@ if [ ! -f $1 ]; then
exit 1
fi
-# boardmismatch=force is for people upgrading from libreboot 5th release, where the new ROM's are "ThinkPad X60 / X60s / X60t"
-# and the old ones are "ThinkPad X60 / X60s" and flashrom complains otherwise
-
-./flashrom/flashrom -p internal -w $1
-
+if [ -f "DEBLOB" ]; then
+ # Means we are in src archive or git
+ ./flashrom/flashrom -p internal -w $1
+elif [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # Means we are in bin archive and on an i686 host
+ ./flashrom/i686/flashrom -p internal -w $1
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ # Means we are in bin archive and on an x86_64 host
+ ./flashrom/x86_64/flashrom -p internal -w $1
+fi
diff --git a/getbucts b/getbucts
index f839730..03216ed 100755
--- a/getbucts
+++ b/getbucts
@@ -43,8 +43,6 @@ cd bucts
git reset --hard dc27919d7a66a6e8685ce07c71aefa4f03ef7c07
-# no patches required
-
# we're done
cd ../
diff --git a/lenovobios_firstflash b/lenovobios_firstflash
index b3084c1..ca58440 100755
--- a/lenovobios_firstflash
+++ b/lenovobios_firstflash
@@ -22,11 +22,37 @@
# set -u -e -v
set -v
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ echo "Running on i686. ok."
+ sleep 5
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ echo "Running on x86_64. ok."
+ sleep 5
+else
+ echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
+ exit 1
+fi
+
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ echo "Running on i686. ok."
+ sleep 5
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ echo "Running on x86_64"
+ sleep 5
+else
+ echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
+ exit 1
+fi
+
# USE ROOT OR SUDO WHEN EXECUTING THIS
# for T60 or X60 owners with Lenovo BIOS
@@ -43,16 +69,58 @@ if [ ! -f $1 ]; then
exit 1
fi
-# needed for first flashing, otherwise machine will be bricked
-{ # try
- ./bucts/bucts 1
-} || { # catch
- echo "BUCTS issue (most likely not compiled). Make sure BUC.TS is 1, or else you will brick your machine."
- echo "ABORTING so as to protect against bricking the machine."
- exit 1
-}
+$errOut = " \
+ BUCTS failed. Make sure BUC.TS is 1, or else you will brick your machine. \
+ ABORTING so as to protect against bricking the machine. \
+ "
+if [ ! -f "DEBLOB" ]
+ then
+ # this means we are working in bin
+ if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # i686
+ # needed for first flashing, otherwise machine will be bricked
+ { # try
+ ./bucts/i686/bucts 1
+ } || { # catch
+ echo "$errOut"
+ exit 1
+ }
+ else
+ # x86_64
+ # needed for first flashing, otherwise machine will be bricked
+ { # try
+ ./bucts/x86_64/bucts 1
+ } || { # catch
+ echo "$errOut"
+ exit 1
+ }
+else
+ # this means we are working in src
+ # needed for first flashing, otherwise machine will be bricked
+ { # try
+ ./bucts/bucts 1
+ } || { # catch
+ echo "$errOut"
+ exit 1
+ }
+fi
# run both. one will fail (and be harmless), the other will succeed.
-./flashrom/flashrom_lenovobios_sst -p internal -w $1
-./flashrom/flashrom_lenovobios_macronix -p internal -w $1
+
+if [ -f "DEBLOB" ]; then
+ # Means we are in src archive or git
+ ./flashrom/flashrom_lenovobios_sst -p internal -w $1
+ ./flashrom/flashrom_lenovobios_macronix -p internal -w $1
+elif [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # Means we are in bin archive and on an i686 host
+ ./flashrom/i686/flashrom_lenovobios_sst -p internal -w $1
+ ./flashrom/i686/flashrom_lenovobios_macronix -p internal -w $1
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ # Means we are in bin archive and on an x86_64 host
+ ./flashrom/x86_64/flashrom_lenovobios_sst -p internal -w $1
+ ./flashrom/x86_64/flashrom_lenovobios_macronix -p internal -w $1
+fi
diff --git a/lenovobios_secondflash b/lenovobios_secondflash
index 9c5ec10..25d70f5 100755
--- a/lenovobios_secondflash
+++ b/lenovobios_secondflash
@@ -22,6 +22,19 @@
# set -u -e -v
set -v
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ echo "Running on i686. ok."
+ sleep 5
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ echo "Running on x86_64. ok."
+ sleep 5
+else
+ echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
+ exit 1
+fi
+
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
@@ -44,13 +57,55 @@ if [ ! -f $1 ]; then
fi
# Flash it a 2nd time, to write upper 64K block
-./flashrom/flashrom -p internal -w $1
-
-# Advised. Reset back to 0.
-{ # try
- ./bucts/bucts 0
-} || { # catch
- echo "WARNING: bucts not found, but if the image was flashed then it's probably safe."
- echo "A dd'd image (like libreboot's images) flashed with bucts=1 is ok. If the image is not dd'd and bucts=1,"
- echo "then you should run ./bucts 0 now, or remove the yellow cmos/nvram battery for a minute."
-}
+if [ -f "DEBLOB" ]; then
+ # Means we are in src archive or git
+ ./flashrom/flashrom -p internal -w $1
+elif [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # Means we are in bin archive and on an i686 host
+ ./flashrom/i686/flashrom -p internal -w $1
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ # Means we are in bin archive and on an x86_64 host
+ ./flashrom/x86_64/flashrom -p internal -w $1
+fi
+
+# Reset bucts back to zero
+$errOut = " \
+ WARNING: bucts not found, but if the image was flashed then it's probably safe \
+ A dd'd image (like libreboot's images) flashed with bucts=1 is ok. If the image is not dd'd and bucts=1, \
+ then you should run ./bucts 0 now, or remove the yellow cmos/nvram battery for a minute. \
+ "
+if [ ! -f "DEBLOB" ]
+ then
+ # this means we are working in bin
+ if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # i686
+ # needed for first flashing, otherwise machine will be bricked
+ { # try
+ ./bucts/i686/bucts 0
+ } || { # catch
+ echo "$errOut"
+ exit 1
+ }
+ else
+ # x86_64
+ # needed for first flashing, otherwise machine will be bricked
+ { # try
+ ./bucts/x86_64/bucts 0
+ } || { # catch
+ echo "$errOut"
+ exit 1
+ }
+else
+ # this means we are working in src
+ # needed for first flashing, otherwise machine will be bricked
+ { # try
+ ./bucts/bucts 0
+ } || { # catch
+ echo "$errOut"
+ exit 1
+ }
+fi
+
diff --git a/macbook21_firstflash b/macbook21_firstflash
index 0a471f9..507bb73 100755
--- a/macbook21_firstflash
+++ b/macbook21_firstflash
@@ -22,6 +22,19 @@
# set -u -e -v
set -v
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ echo "Running on i686. ok."
+ sleep 5
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ echo "Running on x86_64. ok."
+ sleep 5
+else
+ echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
+ exit 1
+fi
+
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
@@ -44,5 +57,15 @@ fi
# flashrom doesn't recognize the machine unless you use that switch: laptop=force_I_want_a_brick
# after flashing libreboot and booting the machine, flashing normally will just work.
-./flashrom/flashrom -p internal:laptop=force_I_want_a_brick -w $1
-
+if [ -f "DEBLOB" ]; then
+ # Means we are in src archive or git
+ ./flashrom/flashrom -p internal:laptop=force_I_want_a_brick -w $1
+elif [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # Means we are in bin archive and on an i686 host
+ ./flashrom/i686/flashrom -p internal:laptop=force_I_want_a_brick -w $1
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ # Means we are in bin archive and on an x86_64 host
+ ./flashrom/x86_64/flashrom -p internal:laptop=force_I_want_a_brick -w $1
+fi
diff --git a/resources/bucts/patch/staticlink.diff b/resources/bucts/patch/staticlink.diff
new file mode 100644
index 0000000..52da8cc
--- /dev/null
+++ b/resources/bucts/patch/staticlink.diff
@@ -0,0 +1,13 @@
+diff --git a/Makefile b/Makefile
+index 68541e6..b8579eb 100644
+--- a/Makefile
++++ b/Makefile
+@@ -10,7 +10,7 @@ endif
+ all: bucts
+
+ bucts: $(OBJ)
+- $(CC) -o $@ $(OBJ) $(LDFLAGS) -lpci
++ $(CC) -o $@ $(OBJ) $(LDFLAGS) -lpci -lz -static
+
+ %.o: %.c
+ $(CC) $(CFLAGS) -DVERSION='"$(VERSION)"' -c $<
diff --git a/resources/cbfstool/patch/COPYING b/resources/cbfstool/patch/COPYING
deleted file mode 100644
index c4c97fc..0000000
--- a/resources/cbfstool/patch/COPYING
+++ /dev/null
@@ -1,2 +0,0 @@
-rmodule.c is from and part of the coreboot project.
-Check coreboot's copyright information to see what conditions apply.
diff --git a/resources/cbfstool/patch/rmodule.c b/resources/cbfstool/patch/rmodule.c
deleted file mode 100644
index 3bee1e0..0000000
--- a/resources/cbfstool/patch/rmodule.c
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- ;* Copyright (C) 2014 Google, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-#include
-#include
-#include
-
-#include "elfparsing.h"
-#include "rmodule.h"
-#include "rmodule-defs.h"
-
-struct rmod_context;
-
-struct arch_ops {
- int arch;
- /* Determine if relocation is a valid type for the architecture. */
- int (*valid_type)(struct rmod_context *ctx, Elf64_Rela *rel);
- /* Determine if relocation should be emitted. */
- int (*should_emit)(struct rmod_context *ctx, Elf64_Rela *rel);
-};
-
-struct rmod_context {
- /* Ops to process relocations. */
- struct arch_ops *ops;
-
- /* endian conversion ops */
- struct xdr *xdr;
-
- /* Parsed ELF sturcture. */
- struct parsed_elf pelf;
- /* Program segment. */
- Elf64_Phdr *phdr;
-
- /* Collection of relocation addresses fixup in the module. */
- Elf64_Xword nrelocs;
- Elf64_Addr *emitted_relocs;
-
- /* The following fields are addresses within the linked program. */
- Elf64_Addr link_addr;
- Elf64_Addr entry;
- Elf64_Addr parameters_begin;
- Elf64_Addr parameters_end;
- Elf64_Addr bss_begin;
- Elf64_Addr bss_end;
- Elf64_Xword size;
-};
-
-/*
- * Architecture specific support operations.
- */
-static int valid_reloc_386(struct rmod_context *ctx, Elf64_Rela *rel)
-{
- int type;
-
- type = ELF64_R_TYPE(rel->r_info);
-
- /* Only these 2 relocations are expected to be found. */
- return (type == R_386_32 || type == R_386_PC32);
-}
-
-static int should_emit_386(struct rmod_context *ctx, Elf64_Rela *rel)
-{
- int type;
-
- type = ELF64_R_TYPE(rel->r_info);
-
- /* R_386_32 relocations are absolute. Must emit these. */
- return (type == R_386_32);
-}
-
-static int valid_reloc_arm(struct rmod_context *ctx, Elf64_Rela *rel)
-{
- int type;
-
- type = ELF64_R_TYPE(rel->r_info);
-
- /* Only these 3 relocations are expected to be found. */
- return (type == R_ARM_ABS32 || type == R_ARM_THM_PC22 ||
- type == R_ARM_THM_JUMP24);
-}
-
-static int should_emit_arm(struct rmod_context *ctx, Elf64_Rela *rel)
-{
- int type;
-
- type = ELF64_R_TYPE(rel->r_info);
-
- /* R_ARM_ABS32 relocations are absolute. Must emit these. */
- return (type == R_ARM_ABS32);
-}
-
-static struct arch_ops reloc_ops[] = {
- {
- .arch = EM_386,
- .valid_type = valid_reloc_386,
- .should_emit = should_emit_386,
- },
- {
- .arch = EM_ARM,
- .valid_type = valid_reloc_arm,
- .should_emit = should_emit_arm,
- },
-};
-
-/*
- * Relocation processing loops.
- */
-
-static int for_each_reloc(struct rmod_context *ctx, int do_emit)
-{
- Elf64_Half i;
- struct parsed_elf *pelf = &ctx->pelf;
-
- for (i = 0; i < pelf->ehdr.e_shnum; i++) {
- Elf64_Shdr *shdr;
- Elf64_Rela *relocs;
- Elf64_Xword nrelocs;
- Elf64_Xword j;
-
- relocs = pelf->relocs[i];
-
- /* No relocations in this section. */
- if (relocs == NULL)
- continue;
-
- shdr = &pelf->shdr[i];
- nrelocs = shdr->sh_size / shdr->sh_entsize;
-
- for (j = 0; j < nrelocs; j++) {
- Elf64_Rela *r = &relocs[j];
-
- if (!ctx->ops->valid_type(ctx, r)) {
- ERROR("Invalid reloc type: %u\n",
- (unsigned int)ELF64_R_TYPE(r->r_info));
- return -1;
- }
-
- if (ctx->ops->should_emit(ctx, r)) {
- int n = ctx->nrelocs;
- if (do_emit)
- ctx->emitted_relocs[n] = r->r_offset;
- ctx->nrelocs++;
- }
- }
- }
-
- return 0;
-}
-
-static int find_program_segment(struct rmod_context *ctx)
-{
- int i;
- int nsegments;
- struct parsed_elf *pelf;
- Elf64_Phdr *phdr;
-
- pelf = &ctx->pelf;
-
- /* There should only be a single loadable segment. */
- nsegments = 0;
- for (i = 0; i < pelf->ehdr.e_phnum; i++) {
- if (pelf->phdr[i].p_type != PT_LOAD)
- continue;
- phdr = &pelf->phdr[i];
- nsegments++;
- }
-
- if (nsegments != 1) {
- ERROR("Unexepcted number of loadable segments: %d.\n",
- nsegments);
- return -1;
- }
-
- INFO("Segment at 0x%0llx, file size 0x%0llx, mem size 0x%0llx.\n",
- (long long)phdr->p_vaddr, (long long)phdr->p_filesz,
- (long long)phdr->p_memsz);
-
- ctx->phdr = phdr;
-
- return 0;
-}
-
-static int
-filter_relocation_sections(struct rmod_context *ctx)
-{
- int i;
- const char *shstrtab;
- struct parsed_elf *pelf;
- const Elf64_Phdr *phdr;
-
- pelf = &ctx->pelf;
- phdr = ctx->phdr;
- shstrtab = buffer_get(pelf->strtabs[pelf->ehdr.e_shstrndx]);
-
- /*
- * Find all relocation sections that contain relocation entries
- * for sections that fall within the bounds of the segment. For
- * easier processing the pointer to the relocation array for the
- * sections that don't fall within the loadable program are NULL'd
- * out.
- */
- for (i = 0; i < pelf->ehdr.e_shnum; i++) {
- Elf64_Shdr *shdr;
- Elf64_Word sh_info;
- const char *section_name;
-
- shdr = &pelf->shdr[i];
-
- /* Ignore non-relocation sections. */
- if (shdr->sh_type != SHT_RELA && shdr->sh_type != SHT_REL)
- continue;
-
- /* Obtain section which relocations apply. */
- sh_info = shdr->sh_info;
- shdr = &pelf->shdr[sh_info];
-
- section_name = &shstrtab[shdr->sh_name];
- DEBUG("Relocation section found for '%s' section.\n",
- section_name);
-
- /* Do not process relocations for debug sections. */
- if (strstr(section_name, ".debug") != NULL) {
- pelf->relocs[i] = NULL;
- continue;
- }
-
- /*
- * If relocations apply to a non program section ignore the
- * relocations for future processing.
- */
- if (shdr->sh_type != SHT_PROGBITS) {
- pelf->relocs[i] = NULL;
- continue;
- }
-
- if (shdr->sh_addr < phdr->p_vaddr ||
- ((shdr->sh_addr + shdr->sh_size) >
- (phdr->p_vaddr + phdr->p_memsz))) {
- ERROR("Relocations being applied to section %d not "
- "within segment region.\n", sh_info);
- return -1;
- }
- }
-
- return 0;
-}
-
-static int vaddr_cmp(const void *a, const void *b)
-{
- const Elf64_Addr *pa = a;
- const Elf64_Addr *pb = b;
-
- if (*pa < *pb)
- return -1;
- if (*pa > *pb)
- return 1;
- return 0;
-}
-
-static int collect_relocations(struct rmod_context *ctx)
-{
- int nrelocs;
-
- /*
- * The relocs array in the pelf should only contain relocations that
- * apply to the program. Count the number relocations. Then collect
- * them into the allocated buffer.
- */
- if (for_each_reloc(ctx, 0))
- return -1;
-
- nrelocs = ctx->nrelocs;
- INFO("%d relocations to be emitted.\n", nrelocs);
- if (!nrelocs)
- return 0;
-
- /* Reset the counter for indexing into the array. */
- ctx->nrelocs = 0;
- ctx->emitted_relocs = calloc(nrelocs, sizeof(Elf64_Addr));
- /* Write out the relocations into the emitted_relocs array. */
- if (for_each_reloc(ctx, 1))
- return -1;
-
- if (ctx->nrelocs != nrelocs) {
- ERROR("Mismatch counted and emitted relocations: %zu vs %zu.\n",
- (size_t)nrelocs, (size_t)ctx->nrelocs);
- return -1;
- }
-
- /* Sort the relocations by their address. */
- qsort(ctx->emitted_relocs, nrelocs, sizeof(Elf64_Addr), vaddr_cmp);
-
- return 0;
-}
-
-static int
-populate_sym(struct rmod_context *ctx, const char *sym_name, Elf64_Addr *addr,
- int nsyms, const char *strtab)
-{
- int i;
- Elf64_Sym *syms;
-
- syms = ctx->pelf.syms;
-
- for (i = 0; i < nsyms; i++) {
- if (syms[i].st_name == 0)
- continue;
- if (strcmp(sym_name, &strtab[syms[i].st_name]))
- continue;
- DEBUG("%s -> 0x%llx\n", sym_name, (long long)syms[i].st_value);
- *addr = syms[i].st_value;
- return 0;
- }
- ERROR("symbol '%s' not found.\n", sym_name);
- return -1;
-}
-
-static int populate_program_info(struct rmod_context *ctx)
-{
- int i;
- const char *strtab;
- struct parsed_elf *pelf;
- Elf64_Ehdr *ehdr;
- int nsyms;
-
- pelf = &ctx->pelf;
- ehdr = &pelf->ehdr;
-
- /* Obtain the string table. */
- strtab = NULL;
- for (i = 0; i < ehdr->e_shnum; i++) {
- if (ctx->pelf.strtabs[i] == NULL)
- continue;
- /* Don't use the section headers' string table. */
- if (i == ehdr->e_shstrndx)
- continue;
- strtab = buffer_get(ctx->pelf.strtabs[i]);
- break;
- }
-
- if (strtab == NULL) {
- ERROR("No string table found.\n");
- return -1;
- }
-
- /* Determine number of symbols. */
- nsyms = 0;
- for (i = 0; i < ehdr->e_shnum; i++) {
- if (pelf->shdr[i].sh_type != SHT_SYMTAB)
- continue;
-
- nsyms = pelf->shdr[i].sh_size / pelf->shdr[i].sh_entsize;
- break;
- }
-
- if (populate_sym(ctx, "_module_params_begin", &ctx->parameters_begin,
- nsyms, strtab))
- return -1;
-
- if (populate_sym(ctx, "_module_params_end", &ctx->parameters_end,
- nsyms, strtab))
- return -1;
-
- if (populate_sym(ctx, "_bss", &ctx->bss_begin, nsyms, strtab))
- return -1;
-
- if (populate_sym(ctx, "_ebss", &ctx->bss_end, nsyms, strtab))
- return -1;
-
- if (populate_sym(ctx, "__rmodule_entry", &ctx->entry, nsyms, strtab))
- return -1;
-
- /* Link address is the virtual address of the program segment. */
- ctx->link_addr = ctx->phdr->p_vaddr;
-
- /* The program size is the memsz of the program segment. */
- ctx->size = ctx->phdr->p_memsz;
-
- return 0;
-}
-
-static int
-add_section(struct elf_writer *ew, struct buffer *data, const char *name,
- Elf64_Addr addr, Elf64_Word size)
-{
- Elf64_Shdr shdr;
- int ret;
-
- memset(&shdr, 0, sizeof(shdr));
- if (data != NULL) {
- shdr.sh_type = SHT_PROGBITS;
- shdr.sh_flags = SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR;
- } else {
- shdr.sh_type = SHT_NOBITS;
- shdr.sh_flags = SHF_ALLOC;
- }
- shdr.sh_addr = addr;
- shdr.sh_offset = addr;
- shdr.sh_size = size;
-
- ret = elf_writer_add_section(ew, &shdr, data, name);
-
- if (ret)
- ERROR("Could not add '%s' section.\n", name);
-
- return ret;
-}
-
-static int
-write_elf(const struct rmod_context *ctx, const struct buffer *in,
- struct buffer *out)
-{
- int i;
- int ret;
- int bit64;
- size_t loc;
- size_t rmod_data_size;
- struct elf_writer *ew;
- struct buffer rmod_data;
- struct buffer rmod_header;
- struct buffer program;
- struct buffer relocs;
- Elf64_Xword total_size;
- Elf64_Addr addr;
- Elf64_Ehdr ehdr;
-
- bit64 = ctx->pelf.ehdr.e_ident[EI_CLASS] == ELFCLASS64;
-
- /*
- * 3 sections will be added to the ELF file.
- * +------------------+
- * | rmodule header |
- * +------------------+
- * | program |
- * +------------------+
- * | relocations |
- * +------------------+
- */
-
- /* Create buffer for header and relocations. */
- rmod_data_size = sizeof(struct rmodule_header);
- if (bit64)
- rmod_data_size += ctx->nrelocs * sizeof(Elf64_Addr);
- else
- rmod_data_size += ctx->nrelocs * sizeof(Elf32_Addr);
-
- if (buffer_create(&rmod_data, rmod_data_size, "rmod"))
- return -1;
-
- buffer_splice(&rmod_header, &rmod_data,
- 0, sizeof(struct rmodule_header));
- buffer_clone(&relocs, &rmod_data);
- buffer_seek(&relocs, sizeof(struct rmodule_header));
-
- /* Reset current location. */
- buffer_set_size(&rmod_header, 0);
- buffer_set_size(&relocs, 0);
-
- /* Program contents. */
- buffer_splice(&program, in, ctx->phdr->p_offset, ctx->phdr->p_filesz);
-
- /* Create ELF writer with modified entry point. */
- memcpy(&ehdr, &ctx->pelf.ehdr, sizeof(ehdr));
- ehdr.e_entry = ctx->entry;
- ew = elf_writer_init(&ehdr);
-
- if (ew == NULL) {
- ERROR("Failed to create ELF writer.\n");
- buffer_delete(&rmod_data);
- return -1;
- }
-
- /* Write out rmodule_header. */
- ctx->xdr->put16(&rmod_header, RMODULE_MAGIC);
- ctx->xdr->put8(&rmod_header, RMODULE_VERSION_1);
- ctx->xdr->put8(&rmod_header, 0);
- /* payload_begin_offset */
- loc = sizeof(struct rmodule_header);
- ctx->xdr->put32(&rmod_header, loc);
- /* payload_end_offset */
- loc += ctx->phdr->p_filesz;
- ctx->xdr->put32(&rmod_header, loc);
- /* relocations_begin_offset */
- ctx->xdr->put32(&rmod_header, loc);
- /* relocations_end_offset */
- if (bit64)
- loc += ctx->nrelocs * sizeof(Elf64_Addr);
- else
- loc += ctx->nrelocs * sizeof(Elf32_Addr);
- ctx->xdr->put32(&rmod_header, loc);
- /* module_link_start_address */
- ctx->xdr->put32(&rmod_header, ctx->link_addr);
- /* module_program_size */
- ctx->xdr->put32(&rmod_header, ctx->size);
- /* module_entry_point */
- ctx->xdr->put32(&rmod_header, ctx->entry);
- /* parameters_begin */
- ctx->xdr->put32(&rmod_header, ctx->parameters_begin);
- /* parameters_end */
- ctx->xdr->put32(&rmod_header, ctx->parameters_end);
- /* bss_begin */
- ctx->xdr->put32(&rmod_header, ctx->bss_begin);
- /* bss_end */
- ctx->xdr->put32(&rmod_header, ctx->bss_end);
- /* padding[4] */
- ctx->xdr->put32(&rmod_header, 0);
- ctx->xdr->put32(&rmod_header, 0);
- ctx->xdr->put32(&rmod_header, 0);
- ctx->xdr->put32(&rmod_header, 0);
-
- /* Write the relocations. */
- for (i = 0; i < ctx->nrelocs; i++) {
- if (bit64)
- ctx->xdr->put64(&relocs, ctx->emitted_relocs[i]);
- else
- ctx->xdr->put32(&relocs, ctx->emitted_relocs[i]);
- }
-
- total_size = 0;
- addr = 0;
-
- /*
- * There are 2 cases to deal with. The program has a large NOBITS
- * section and the relocations can fit entirely within occupied memory
- * region for the program. The other is that the relocations increase
- * the memory footprint of the program if it was loaded directly into
- * the region it would run. The rmdoule header is a fixed cost that
- * is considered a part of the program.
- */
- total_size += buffer_size(&rmod_header);
- if (buffer_size(&relocs) + ctx->phdr->p_filesz > ctx->phdr->p_memsz) {
- total_size += buffer_size(&relocs);
- total_size += ctx->phdr->p_filesz;
- } else {
- total_size += ctx->phdr->p_memsz;
- }
-
- ret = add_section(ew, &rmod_header, ".header", addr,
- buffer_size(&rmod_header));
- if (ret < 0)
- goto out;
- addr += buffer_size(&rmod_header);
-
- ret = add_section(ew, &program, ".program", addr, ctx->phdr->p_filesz);
- if (ret < 0)
- goto out;
- addr += ctx->phdr->p_filesz;
-
- if (ctx->nrelocs) {
- ret = add_section(ew, &relocs, ".relocs", addr,
- buffer_size(&relocs));
- if (ret < 0)
- goto out;
- addr += buffer_size(&relocs);
- }
-
- if (total_size != addr) {
- ret = add_section(ew, NULL, ".empty", addr, total_size - addr);
- if (ret < 0)
- goto out;
- }
-
- /*
- * Ensure last section has a memory usage that meets the required
- * total size of the program in memory.
- */
-
- ret = elf_writer_serialize(ew, out);
- if (ret < 0)
- ERROR("Failed to serialize ELF to buffer.\n");
-
-out:
- buffer_delete(&rmod_data);
- elf_writer_destroy(ew);
-
- return ret;
-}
-
-int rmodule_create(const struct buffer *elfin, struct buffer *elfout)
-{
- struct rmod_context ctx;
- struct parsed_elf *pelf;
- int i;
- int ret;
-
- ret = -1;
- memset(&ctx, 0, sizeof(ctx));
- pelf = &ctx.pelf;
-
- if (parse_elf(elfin, pelf, ELF_PARSE_ALL)) {
- ERROR("Couldn't parse ELF!\n");
- return -1;
- }
-
- /* Only allow executables to be turned into rmodules. */
- if (pelf->ehdr.e_type != ET_EXEC) {
- ERROR("ELF is not an executable: %u.\n", pelf->ehdr.e_type);
- goto out;
- }
-
- /* Determine if architecture is supported. */
- for (i = 0; i < ARRAY_SIZE(reloc_ops); i++) {
- if (reloc_ops[i].arch == pelf->ehdr.e_machine) {
- ctx.ops = &reloc_ops[i];
- break;
- }
- }
-
- if (ctx.ops == NULL) {
- ERROR("ELF is unsupported arch: %u.\n", pelf->ehdr.e_machine);
- goto out;
- }
-
- /* Set the endian ops. */
- if (ctx.pelf.ehdr.e_ident[EI_DATA] == ELFDATA2MSB)
- ctx.xdr = &xdr_be;
- else
- ctx.xdr = &xdr_le;
-
- if (find_program_segment(&ctx))
- goto out;
-
- if (filter_relocation_sections(&ctx))
- goto out;
-
- if (collect_relocations(&ctx))
- goto out;
-
- if (populate_program_info(&ctx))
- goto out;
-
- if (write_elf(&ctx, elfin, elfout))
- goto out;
-
- ret = 0;
-
-out:
- free(ctx.emitted_relocs);
- parsed_elf_destroy(pelf);
- return ret;
-}
diff --git a/x60flashfrom5 b/x60flashfrom5
index 5276615..268c9c0 100755
--- a/x60flashfrom5
+++ b/x60flashfrom5
@@ -22,6 +22,19 @@
# set -u -e -v
set -v
+if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ echo "Running on i686. ok."
+ sleep 5
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ echo "Running on x86_64. ok."
+ sleep 5
+else
+ echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
+ exit 1
+fi
+
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
@@ -44,5 +57,16 @@ fi
# boardmismatch=force is for people upgrading from libreboot 5th release, where the new ROM's are "ThinkPad X60 / X60s / X60t"
# and the old ones are "ThinkPad X60 / X60s" and flashrom complains otherwise
-./flashrom/flashrom -p internal:boardmismatch=force -w $1
+if [ -f "DEBLOB" ]; then
+ # Means we are in src archive or git
+ ./flashrom/flashrom -p internal:boardmismatch=force -w $1
+elif [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
+ then
+ # Means we are in bin archive and on an i686 host
+ ./flashrom/i686/flashrom -p internal:boardmismatch=force -w $1
+elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
+ then
+ # Means we are in bin archive and on an x86_64 host
+ ./flashrom/x86_64/flashrom -p internal:boardmismatch=force -w $1
+fi
--
cgit v0.9.1