Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindbohler committed Jun 7, 2024
0 parents commit 1f11829
Show file tree
Hide file tree
Showing 11,609 changed files with 2,907,636 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.swp
*.pyc
.DS_Store
/coreboot/util/crossgcc/xgcc
/coreboot/.config*
/coreboot/.xcompile
/coreboot/build
/seabios/.config*
/seabios/out
/out/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: all clean

all:
./build-target.sh

clean:
rm -rf out
cd seabios && ../xgcc-seabios-make.sh distclean
cd coreboot && make distclean
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ITX-Llama BIOS

This repo contains the tools necessary to build the [ITX-Llama](https://github.com/eivindbohler/itxllama) BIOS (Coreboot/SeaBIOS).
Based on the 86Duino project from https://github.com/roboard/build-coreboot

For help or feedback, try the [ITX-Llama thread on Vogons](https://www.vogons.org/viewtopic.php?t=93480)!

Tested on:
* Ubuntu 16.04 i386

Other operating systems and architectures are likely simple to get working as well, but your mileage may vary.
The easiest option is probably to spin up a virtual machine of some kind, and install Ubuntu 16.04 i386 on that.

### Prerequisites
#### Ubuntu
Install tools:
```
$ sudo apt install git build-essential m4 bison flex python texinfo gnat
```
### Build the cross compiler
```
$ ./build-xgcc.sh
```

### Build the ROM file
```
$ make
```

If building is successful, the 2 MB output ROM file will be in the `out/` directory.
Another file is also made - `out/xxx-padded.rom` - padded with `0xFF` to fit 8 MB, for flashing directly to the SPI ROM using a hardware programmer. The Coreboot/SeaBIOS ROM will be located at the end of this 8 MB file.

168 changes: 168 additions & 0 deletions build-target.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/bin/bash

ITX_LLAMA_BOARD_REVISION="v1-rev-E"

ADD_SEABIOS_CONFIG=1

IGNORE_COREBOOT_SEABIOS_CONFIG_CONFLICT=1

BUILD_DATE=`date +"%Y%m%d-%H%M%S"`
OUTPUT_NAME="itx-llama-$ITX_LLAMA_BOARD_REVISION-$BUILD_DATE"
CROSSBAR="crossbar-itx-llama-$ITX_LLAMA_BOARD_REVISION.bin"
MAC_ADDRESS="mac-address.bin"

BOOTORDER="bootorder-sd-usb"
BOOT_MENU_WAIT=5000
#SCREEN_AND_DEBUG=1
#PS2_KEYBOARD_SPINUP=500

BASE_DIR=`dirname $0`

(cd ${BASE_DIR} && cp config/coreboot/coreboot.config coreboot/.config) || exit 1
(cd ${BASE_DIR} && cp config/seabios/seabios.config seabios/.config) || exit 1

. ${BASE_DIR}/cbfs-func || exit 1

if ! [ -z ITX_LLAMA_BOARD_REVISION ]; then
echo "$ITX_LLAMA_BOARD_REVISION" > seabios/.boardrevision
fi

if ! [ -z BUILD_DATE ]; then
echo "$BUILD_DATE" > seabios/.builddate
fi

# coreboot .config set payload to none, payload is selected by option file.
if grep ^"CONFIG_PAYLOAD_NONE=y"$ ${BASE_DIR}/coreboot/.config > /dev/null; then
# get CONFIG_CBFS_PREFIX setting from coreboot config file.
if ! S=`grep ^CONFIG_CBFS_PREFIX= ${BASE_DIR}/coreboot/.config` > /dev/null; then
echo "Missing CONFIG_CBFS_PREFIX in coreboot .config"
exit 1
fi
eval $S
# Add SeaBIOS payload by option file.
if ! [ -z $PAYLOAD_SEABIOS ]; then
# if [ -z $SEABIOS_COMMIT ]; then
# echo "Missing SEABIOS_COMMIT setting."
# exit 1
# fi
NEED_BUILD_SEABIOS_LATER=1
fi
else
# coreboot .config set payload is not none, PAYLOAD_* in target file is invalid.
if ! [ -z $PAYLOAD_SEABIOS ]; then
echo "PAYLOAD_SEABIOS is set, and payload in coreboot .config file is not none."
exit 1
fi
if ! [ -z $PAYLOAD_ELF ]; then
echo "PAYLOAD_ELF is set, and payload in coreboot .config file is not none."
exit 1
fi
fi

# coreboot .config set payload to ./seabios directory, need to build SeaBIOS before coreboot.
if grep ^"CONFIG_PAYLOAD_FILE=\"../seabios/out/bios.bin.elf"\"$ ${BASE_DIR}/coreboot/.config > /dev/null; then
# if [ -z $SEABIOS_COMMIT ]; then
# echo "Missing SEABIOS_COMMIT setting."
# exit 1
# fi
NEED_BUILD_SEABIOS_FIRST=1
fi

# if need to build SeaBIOS, check if coreboot has conflict option with SeaBIOS.
if [ -z $IGNORE_COREBOOT_SEABIOS_CONFIG_CONFLICT ]; then
if ! [ -z $NEED_BUILD_SEABIOS_FIRST ] || ! [ -z $NEED_BUILD_SEABIOS_LATER ] ;then
if grep ^"CONFIG_VGA_ROM_RUN=y"$ ${BASE_DIR}/coreboot/.config > /dev/null; then
echo "Error : coreboot CONFIG_VGA_ROM_ROM=y is conflict with SeaBIOS."
exit 1
fi
if grep ^"CONFIG_ON_DEVICE_ROM_RUN=y"$ ${BASE_DIR}/coreboot/.config > /dev/null; then
echo "Error : coreboot CONFIG_ON_DEVICE_ROM_RUN=y is conflict with SeaBIOS."
exit 1
fi
fi
fi

(
cd ${BASE_DIR} || exit 1
if ! [ -z $NEED_BUILD_SEABIOS_FIRST ]; then
echo "Building SeaBIOS..."
(cd seabios && ../xgcc-seabios-make.sh) || exit 1
echo
fi
echo "Building coreboot..."
(cd coreboot && make) || exit 1
echo
if ! [ -z $NEED_BUILD_SEABIOS_LATER ]; then
echo "Building SeaBIOS..."
(cd seabios && ../xgcc-seabios-make.sh) || exit 1
echo
if [ -z $PAYLOAD_COMPRESS ]; then
echo "Add SeaBIOS payload."
cbfs_add_payload seabios/out/bios.bin.elf -n ${CONFIG_CBFS_PREFIX}/payload
else
echo "Add SeaBIOS payload (compressed)."
cbfs_add_payload seabios/out/bios.bin.elf -n ${CONFIG_CBFS_PREFIX}/payload -c $PAYLOAD_COMPRESS
fi
echo
fi
if ! [ -z $PAYLOAD_ELF ]; then
echo "Add ELF payload."
cbfs_add_payload $PAYLOAD_ELF -n ${CONFIG_CBFS_PREFIX}/payload -c $PAYLOAD_COMPRESS
fi

# if need to add SeaBIOS config into CBFS.
if ! [ -z $ADD_SEABIOS_CONFIG ]; then
if ! [ -z $NEED_BUILD_SEABIOS_FIRST ] || ! [ -z $NEED_BUILD_SEABIOS_LATER ] ;then
echo "Add SeaBIOS config file."
echo "# This image was built using git revision" `cd seabios && git rev-parse HEAD` > seabios/out/config.tmp
# Add git revision info and remove comment line in SeaBIOS config file.
# Copied from coreboot src/arch/x86/Makefile.inc .
sed -e '/^#/d' -e '/^ *$$/d' seabios/.config >> seabios/out/config.tmp
cbfs_add seabios/out/config.tmp -n seabios_config
rm -f seabios/out/config.tmp
fi
fi

# Add floppy image as ramdisk
echo "Adding ramdisk floppy image"
cbfs_add ./win98_1440k.img.lzma -n floppyimg/win98_1440k.img.lzma -t raw

echo "Writing crossbar data..."
./write-crossbar.py coreboot/build/coreboot.rom crossbar/${CROSSBAR} && \
echo "Writing MAC address data..." && \
./write-mac-address.py coreboot/build/coreboot.rom ${MAC_ADDRESS} && \
echo "Adding coreboot bootorder/flags/roms..."
(
[ -z "$BOOTORDER" ] || \
cbfs_add seabios-etc/${BOOTORDER} -n bootorder
) && \
(
[ -z "$BOOT_MENU_WAIT" ] || \
cbfs_add_int ${BOOT_MENU_WAIT} etc/boot-menu-wait
) && \
(
[ -z "$SCREEN_AND_DEBUG" ] || \
cbfs_add_int ${SCREEN_AND_DEBUG} etc/screen-and-debug
) && \
(
[ -z "$PS2_KEYBOARD_SPINUP" ] || \
cbfs_add_int ${PS2_KEYBOARD_SPINUP} etc/ps2-keyboard-spinup
) && \
echo "Copy output ROM file to out/${OUTPUT_NAME}.rom" && \
mkdir -p out && \
cp coreboot/build/coreboot.rom out/${OUTPUT_NAME}.rom && \
cbfs_print out/${OUTPUT_NAME}.rom
echo ""
echo "Padding rom file to 8 MB..."
if [ `uname` == 'Darwin' ]; then
ROM_FILE_SIZE=`stat -f%z "out/${OUTPUT_NAME}.rom"`
else
ROM_FILE_SIZE=`du -b "out/${OUTPUT_NAME}.rom" | cut -f1`
fi
PADDING_SIZE=$((0x800000-ROM_FILE_SIZE)) && \
dd if=/dev/zero ibs=1 count=$PADDING_SIZE | LC_ALL=C tr "\000" "\377" >out/padding.bin && \
cat out/padding.bin out/${OUTPUT_NAME}.rom >out/${OUTPUT_NAME}-padded.rom && \
rm out/padding.bin && \
echo ""
echo "Done!"
)
14 changes: 14 additions & 0 deletions build-xgcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/sh

if ! [ -d coreboot/util/crossgcc/ ]; then
echo No crossgcc source directory.
exit 1
fi

if [ -d coreboot/util/crossgcc/xgcc/ ]; then
echo crossgcc already exist.
exit 1
fi

echo Build crossgcc.
(cd coreboot/util/crossgcc/ && ./buildgcc -p i386-elf -j 12)
73 changes: 73 additions & 0 deletions cbfs-func
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#! /bin/sh
CBFSTOOL=coreboot/build/cbfstool
ROMFILE=coreboot/build/coreboot.rom

function cbfs_add {
filename=${1:?no filename}
filetype="raw"
targetname=`basename $filename`
compressflag="none"
# first argument is filename, skip it
OPTIND=2
while getopts "n:t:c:" opt;do
case $opt in
n)
#echo "target name="$OPTARG
targetname=$OPTARG
;;
t)
#echo "type="$OPTARG
filetype=$OPTARG
;;
c)
compressflag=$OPTARG
;;
\?)
echo "Invalid argument"
exit 1
;;
esac
done
if [ "$compressflag" == "none" ]; then
$CBFSTOOL $ROMFILE add -f $filename -n $targetname -t $filetype
else
$CBFSTOOL $ROMFILE add -f $filename -n $targetname -t $filetype -c $compressflag
fi
}

function cbfs_add_payload {
filename=${1:?no filename}
targetname=payload
compressflag=none
# first argument is filename, skip it
OPTIND=2
while getopts "n:c:" opt;do
case $opt in
n)
#echo "target name="$OPTARG
targetname=$OPTARG
;;
c)
compressflag=$OPTARG
;;
\?)
echo "Invalid argument"
exit 1
;;
esac
done
$CBFSTOOL $ROMFILE add-payload -f $filename -n $targetname -c $compressflag
}

function cbfs_remove {
filename=${1:?no filename}
$CBFSTOOL $ROMFILE remove -n $filename
}

function cbfs_add_int {
$CBFSTOOL $ROMFILE add-int -i $1 -n $2
}

function cbfs_print {
$CBFSTOOL $ROMFILE print
}
Loading

0 comments on commit 1f11829

Please sign in to comment.