feat: big refactor to also support x60 config

main
Ricard Illa 2023-08-15 20:08:20 +02:00
parent 5d950fc295
commit 3414c1b47b
Signed by: rilla
GPG Key ID: 525307BD467E4205
16 changed files with 107 additions and 183 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
build
coreboot
x230/x230_seabios.rom
x60/x60_seabios.rom

View File

@ -1,58 +0,0 @@
COMMIT=db4b71ff10
SDK_VERSION=2022-12-18_3b32af950d
CONFIG=nonfree-defconfig-$(COMMIT)
BOOTSPLASH=bootsplash.jpg
REPO_URL=https://github.com/coreboot/coreboot.git
COREBOOT_CONFIG=coreboot/.config
BUILDER=./coreboot-sdk.sh \
--config $(CONFIG) \
--sdk-version $(SDK_VERSION) \
--bootsplash $(BOOTSPLASH)
.PHONY: clean nuke defconfig checkout flash
build/coreboot_top_prepared_12mb.rom: build/coreboot_top.rom
dd if=/dev/zero of="$@" bs=4M count=2 status=none
dd if="$<" oflag=append conv=notrunc of="$@" bs=4M status=none
build/coreboot_top.rom.sha256: build/coreboot_top.rom
sha256sum "$<" > "$@"
build/coreboot_top.rom: build/coreboot.rom
dd if="$<" of="$@" bs=1M skip=8
build/coreboot.rom: $(COREBOOT_CONFIG) $(BOOTSPLASH) vgabios.bin
mkdir -p build
$(BUILDER) make
$(COREBOOT_CONFIG): $(CONFIG) checkout
mkdir -p build
$(BUILDER) make defconfig
defconfig: $(COREBOOT_CONFIG)
coreboot: # clone
git clone $(REPO_URL) $@
git -C coreboot submodule update --init --recursive --remote
checkout: coreboot
git -C coreboot checkout $(COMMIT)
git -C coreboot submodule update --recursive --remote
clean:
rm -rf coreboot/.config
rm -rf build
nuke: clean
rm -rf coreboot
flash: build/coreboot_top_prepared_12mb.rom layout.txt
flashrom \
--force \
--noverify-all\
-p internal \
--layout layout.txt \
--image bios \
-w build/coreboot_top_prepared_12mb.rom

View File

@ -1,63 +0,0 @@
# coreboot-builder
This is what I use to build my coreboot images. It is heavily based on the
scripts and configurations used by [skulls](https://github.com/merge/skulls).
But simplified to support only my very specific hardware and preferences. This
makes it leaner to use and easier for me to understand it, so it's easier to
customize (for example, if I want to change the boot order).
Currently I have only one config for my Thinkpad X230; `capibara`, and I use a
the "free" config (with the VGA BIOS SeaVGABIOS instead of the Intel one).
## Build process
I use a Makefile to orchestrate cloning the coreboot code, checking out the
right commit, compiling the image, flashing it, etc.
The coreboot SDK is run from a docker image because I couldn't manage to
compile everything otherwise.
## Splash screen
For an X230 the splash screen image needs to be a JPEG using:
* with "progressive" turned off
* "4:2:0 (chroma quartered)" Subsampling
* 1024px wide and 768px tall
But the X230 screen happens to be 16:9 (1366px wide, 768px tall). When the
SaBIOSVABIOS is used, the image is just shown centered in the screen, with
black blocks on each side. When the Intel VGA is used, the image is stretched
to fill the whole 1366 x 768 screen. So make sure to plan accordingly to make
the image look right.
Also, the SeaBIOS VGA seems to show weird colors when booting. I don't know
how to fix that, so I just keep the image pure black and white to make it look
decent.
## Updates
I try to follow skull's releases and update the coreboot commit, sdk version
and config as they do it.
Last release happened on 2022/05/03.
## Flashing
Before flashing, the system needs to boot with the kernel parameter
`iomem=relaxed`.
* Reboot the computer
* When the GRUB screen appears, press `e` to edit the startup command
* Append `iomem=relaxed` to the kernel command
* Press `ctrl-x` or `F2` to boot the system with the modification
* Then flash the new image with:
```sh
flashrom \
--force \
--noverify-all\
-p internal \
--layout layout.txt \
--image bios \
-w build/coreboot_top_prepared_12mb.rom
```

33
common.make Normal file
View File

@ -0,0 +1,33 @@
# note: to produce `defconfig`, you can do the following:
# 1. run `make menuconfig` to create a .config
# 2. run `make savedefconfig` to strip out the default values from .config
# and be left with defconfig
SDK_VERSION=2022-12-18_3b32af950d
COREBOOT_COMMIT=aa1efece74
REPO_URL=https://github.com/coreboot/coreboot.git
UID:=$(shell id -u)
GID:=$(shell id -g)
WD:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
define coreboot_sdk
podman run --rm -it \
--userns=keep-id \
--user=$(UID):$(GID) \
--workdir="/home/coreboot/cb_build" \
--volume="$(WD)/coreboot:/home/coreboot/cb_build" \
$(1) \
coreboot/coreboot-sdk:$(SDK_VERSION)
endef
coreboot:
echo "cloning coreboot code"
git clone $(REPO_URL) $@
git -C $@ submodule update --init --recursive --remote
git -C $@ checkout $(COREBOOT_COMMIT)
git -C $@ submodule update --recursive --remote
# vi: ft=make

View File

@ -1,43 +0,0 @@
#!/bin/sh
while :; do
case "$1" in
--config)
CONFIG="$2"
shift 2
;;
--sdk-version)
SDK_VERSION="$2"
shift 2
;;
--bootsplash)
BOOTSPLASH="$2"
shift 2
;;
--vgabios)
VGABIOS="$2"
shift 2
;;
*)
break
;;
esac
done
[ -e "${VGABIOS}" ] &&
VGABIOS_MNT="-v $(pwd)/${VGABIOS}:/home/coreboot/cb_build/vgabios.bin:ro"
uid=$(id -u)
gid=$(id -g)
podman run --rm -it \
--userns=keep-id \
--user "$uid:$gid" \
--workdir "/home/coreboot/cb_build" \
-v "$(pwd)/coreboot:/home/coreboot/cb_build" \
-v "$(pwd)/build:/home/coreboot/cb_build/build" \
-v "$(pwd)/${CONFIG}:/home/coreboot/cb_build/configs/defconfig:ro" \
-v "$(pwd)/${BOOTSPLASH}:/home/coreboot/cb_build/bootsplash.jpg:ro" \
$VGABIOS_MNT \
coreboot/coreboot-sdk:"$SDK_VERSION" \
"$@"

21
justfile Normal file
View File

@ -0,0 +1,21 @@
SDK_VERSION := "2022-12-18_3b32af950d"
COMMIT := "aa1efece74"
uid := `id -u`
gid := `id -g`
clone:
git clone https://github.com/coreboot/coreboot.git coreboot
git -C coreboot submodule update --init --recursive --remote
git -C coreboot checkout {{ COMMIT }}
git -C coreboot submodule update --recursive --remote
make *ARGS:
docker run -it \
--userns=keep-id \
--user {{ uid }}:{{ gid }} \
--workdir "/home/coreboot/cb_build" \
-v "$(pwd)/coreboot:/home/coreboot/cb_build" \
-v "$(pwd)/build:/home/coreboot/cb_build/build" \
coreboot/coreboot-sdk:{{ SDK_VERSION }} \
make {{ARGS}}

27
x230/Makefile Normal file
View File

@ -0,0 +1,27 @@
x230_seabios.rom: build/coreboot_top_prepared_12mb.rom
install $< $@
include ../common.make
build/coreboot_top_prepared_12mb.rom: build/coreboot_top.rom
dd if=/dev/zero of="$@" bs=4M count=2 status=none
dd if="$<" oflag=append conv=notrunc of="$@" bs=4M status=none
build/coreboot_top.rom: build/coreboot.rom
dd if="$<" of="$@" bs=1M skip=8
build/coreboot.rom: coreboot/.config bootorder bootsplash.jpg vgabios.bin coreboot
echo "building rom"
mkdir -p $(@D)
$(call coreboot_sdk,\
--volume="$(WD)/$(@D):/home/coreboot/cb_build/build" \
--volume="$(WD)/bootorder:/home/coreboot/cb_build/bootorder:ro" \
--volume="$(WD)/bootsplash.jpg:/home/coreboot/cb_build/bootsplash.jpg:ro" \
--volume="$(WD)/vgabios.bin:/home/coreboot/cb_build/vgabios.bin:ro" \
) make
coreboot/.config: defconfig coreboot
echo "building config out of defconfig"
$(call coreboot_sdk,\
--volume="$(WD)/$<:/home/coreboot/cb_build/configs/defconfig:ro" \
) make defconfig

3
x230/bootorder Normal file
View File

@ -0,0 +1,3 @@
/pci@i0cf8/*@1f,2/drive@2/disk@0
/pci@i0cf8/*@1f,2/drive@0/disk@0
/rom@img/nvramcui

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -3,11 +3,6 @@ CONFIG_VENDOR_LENOVO=y
CONFIG_NO_POST=y
CONFIG_CBFS_SIZE=0x400000
CONFIG_VGA_BIOS=y
CONFIG_SEABIOS_PS2_TIMEOUT=5000
CONFIG_CONSOLE_CBMEM_BUFFER_SIZE=0x20000
CONFIG_PCIEXP_HOTPLUG_BUSES=8
CONFIG_PCIEXP_HOTPLUG_MEM=0x800000
CONFIG_PCIEXP_HOTPLUG_PREFETCH_MEM=0x10000000
CONFIG_BOARD_LENOVO_X230=y
# CONFIG_S3_VGA_ROM_RUN is not set
# CONFIG_H8_BEEP_ON_DEATH is not set
@ -15,16 +10,12 @@ CONFIG_H8_SUPPORT_BT_ON_WIFI=y
CONFIG_BOOTBLOCK_NORMAL=y
CONFIG_VGA_ROM_RUN=y
CONFIG_PCI_OPTION_ROM_RUN_YABEL=y
CONFIG_YABEL_VIRTMEM_LOCATION=0x1000000
CONFIG_YABEL_DIRECTHW=y
CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
CONFIG_VBE_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y
CONFIG_PCIEXP_HOTPLUG_IO=0x2000
CONFIG_SUBSYSTEM_VENDOR_ID=0x0000
CONFIG_SUBSYSTEM_DEVICE_ID=0x0000
CONFIG_I2C_TRANSFER_TIMEOUT_US=500000
CONFIG_DEFAULT_CONSOLE_LOGLEVEL_8=y
CONFIG_SEABIOS_DEBUG_LEVEL=-1
CONFIG_COREINFO_SECONDARY_PAYLOAD=y
CONFIG_NVRAMCUI_SECONDARY_PAYLOAD=y
CONFIG_SEABIOS_BOOTORDER_FILE="bootorder"

View File

@ -4,11 +4,6 @@ CONFIG_NO_POST=y
CONFIG_CBFS_SIZE=0x400000
CONFIG_LINEAR_FRAMEBUFFER_MAX_HEIGHT=768
CONFIG_LINEAR_FRAMEBUFFER_MAX_WIDTH=1024
CONFIG_SEABIOS_PS2_TIMEOUT=5000
CONFIG_CONSOLE_CBMEM_BUFFER_SIZE=0x20000
CONFIG_PCIEXP_HOTPLUG_BUSES=8
CONFIG_PCIEXP_HOTPLUG_MEM=0x800000
CONFIG_PCIEXP_HOTPLUG_PREFETCH_MEM=0x10000000
CONFIG_BOARD_LENOVO_X230=y
# CONFIG_H8_BEEP_ON_DEATH is not set
CONFIG_H8_SUPPORT_BT_ON_WIFI=y
@ -16,10 +11,7 @@ CONFIG_BOOTBLOCK_NORMAL=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y
CONFIG_PCIEXP_HOTPLUG_IO=0x2000
CONFIG_SUBSYSTEM_VENDOR_ID=0x0000
CONFIG_SUBSYSTEM_DEVICE_ID=0x0000
CONFIG_I2C_TRANSFER_TIMEOUT_US=500000
CONFIG_DEFAULT_CONSOLE_LOGLEVEL_8=y
CONFIG_SEABIOS_DEBUG_LEVEL=-1
CONFIG_COREINFO_SECONDARY_PAYLOAD=y
CONFIG_NVRAMCUI_SECONDARY_PAYLOAD=y
CONFIG_SEABIOS_BOOTORDER_FILE="bootorder"

17
x60/Makefile Normal file
View File

@ -0,0 +1,17 @@
x60_seabios.rom: build/coreboot.rom
install $< $@
include ../common.make
build/coreboot.rom: coreboot/.config coreboot
echo "building rom"
mkdir -p $(@D)
$(call coreboot_sdk,\
--volume="$(WD)/$(@D):/home/coreboot/cb_build/build" \
) make
coreboot/.config: defconfig coreboot
echo "building config out of defconfig"
$(call coreboot_sdk,\
--volume="$(WD)/$<:/home/coreboot/cb_build/configs/defconfig:ro" \
) make defconfig

2
x60/defconfig Normal file
View File

@ -0,0 +1,2 @@
CONFIG_VENDOR_LENOVO=y
CONFIG_BOARD_LENOVO_X60=y