Author: jcrouse Date: 2008-09-24 00:15:47 +0200 (Wed, 24 Sep 2008) New Revision: 234
Added: buildrom-devel/bin/construct-rom.sh Modified: buildrom-devel/config/platforms/dbm690t.conf buildrom-devel/config/platforms/platforms.conf buildrom-devel/packages/coreboot-v2/coreboot.inc Log: buildrom: Add script to automatically pad ROMs
Many ROMs may need to be padded before use. This script tries to do this somewhat automatically. If the platform needs the payload to be padded to a power of 2, then it should set PAYLOAD_DOPAD to '-p'. Otherwise, the script behaves as it normally does.
Signed-off-by: Jordan Crouse jordan.crouse@amd.com Acked-by: Ward Vandewege ward@gnu.org
Added: buildrom-devel/bin/construct-rom.sh =================================================================== --- buildrom-devel/bin/construct-rom.sh (rev 0) +++ buildrom-devel/bin/construct-rom.sh 2008-09-23 22:15:47 UTC (rev 234) @@ -0,0 +1,51 @@ +#!/bin/sh -e +# Usage: ./construct-rom.sh [-p] components ... + +DOPAD=0 + +if [ "$1" == "-p" ]; then + DOPAD=1 + shift +fi + +COMPONENTS=$* + +if [ $DOPAD -eq 1 ]; then + + ROMSIZE=0 + + # Get the size of all the components together + + for c in $COMPONENTS; do + size=`du -b $c | cut -f1` + ROMSIZE=`expr $ROMSIZE + $size` || true + done + + # Pad to a power of 2, starting with 128k + RSIZE=131072 + + while true; do + PAD=0 + + if [ $ROMSIZE -gt $RSIZE ]; then + RSIZE=`expr $RSIZE "*" 2` + continue + fi + + if [ $ROMSIZE -lt $RSIZE ]; then + PAD=`expr $RSIZE - $ROMSIZE` + fi + + break + done + + PADFILE=`mktemp` + dd if=/dev/zero of=$PADFILE bs=1 count=$PAD > /dev/null 2>&1 + COMPONENTS="$PADFILE $COMPONENTS" +fi + +cat $COMPONENTS + +if [ $DOPAD -eq 1 ]; then + rm -rf $PADFILE +fi
Modified: buildrom-devel/config/platforms/dbm690t.conf =================================================================== --- buildrom-devel/config/platforms/dbm690t.conf 2008-09-23 22:02:55 UTC (rev 233) +++ buildrom-devel/config/platforms/dbm690t.conf 2008-09-23 22:15:47 UTC (rev 234) @@ -51,6 +51,9 @@ CBV2_TDIR=dbm690t CBV2_TAG=3590
+# Tell construct-rom.sh to pad the ROM to a power of 2 +PLATFORM_DOPAD := -p + # FILO configuration
FILO_CONFIG=dbm690t-Config
Modified: buildrom-devel/config/platforms/platforms.conf =================================================================== --- buildrom-devel/config/platforms/platforms.conf 2008-09-23 22:02:55 UTC (rev 233) +++ buildrom-devel/config/platforms/platforms.conf 2008-09-23 22:15:47 UTC (rev 234) @@ -6,6 +6,11 @@ STRIP=strip AS=as
+# Each individual platform needs to decide if they want to pad the +# ROM or not + +PLATFORM_DOPAD := + ##Include the correct platform configuration
PLATFORM-y=
Modified: buildrom-devel/packages/coreboot-v2/coreboot.inc =================================================================== --- buildrom-devel/packages/coreboot-v2/coreboot.inc 2008-09-23 22:02:55 UTC (rev 233) +++ buildrom-devel/packages/coreboot-v2/coreboot.inc 2008-09-23 22:15:47 UTC (rev 234) @@ -150,7 +150,7 @@
$(OUTPUT_DIR)/$(TARGET_ROM): $(CBV2_COMPONENTS) @ mkdir -p $(OUTPUT_DIR) - @ cat $(CBV2_COMPONENTS) > $@ + @ $(BIN_DIR)/construct-rom.sh $(PLATFORM_DOPAD) $(CBV2_COMPONENTS) > $@
generic-coreboot: $(OUTPUT_DIR)/$(TARGET_ROM)