Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ VERSION?=$(DATE)_$(REV)
# Default target - build the board's EC firmware
all: $(BUILD)/ec.rom
$(info Built $(VERSION) for $(BOARD))
./scripts/check-home-segment.sh

# Include common source
COMMON_DIR=src/common
Expand Down
27 changes: 27 additions & 0 deletions scripts/check-home-segment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only

# SDCC 4.5.0 will incorrectly move the HOME segment, which contains the
# compiler-generated interrupt vector table, to code address 0x50 with ITE
# chips that declare the 16-byte signature at the default address of 0x40.
#
# Ref: https://github.com/system76/ec/issues/518

BUILD_DIR="${BUILD_DIR:-build}"
MAP_FILE="${BUILD_DIR}/ec.map"

if [ ! -d "${BUILD_DIR}" ]; then
exit 0
fi

if [ ! -f "${MAP_FILE}" ]; then
exit 0
fi

SEG_EXPECTED="00000000"
SEG_START=$(grep 's_HOME' "${MAP_FILE}" | awk '{ print $2 }')

if [ "${SEG_START}" != "${SEG_EXPECTED}" ]; then
printf "\x1B[31mHOME segment starts at %s; image will not boot\x1B[0m\n" "${SEG_START}"
exit 1
fi