On Fri, Oct 2, 2020 at 3:51 AM Andy Pont <andy.pont@sdcsystems.com> wrote:
Hello,

I have a binary file that is the firmware for the embedded controller on
the laptop platform that I am working on.  In the regular BIOS provided
by the hardware vendor this 128KB binary is located at offset 0x400000
in the BIOS image.

Is there any documentation or instructions anywhere on how I include
this into the Coreboot image that I am creating?


Hi Andy,

You can enable CONFIG_HAVE_EC_BIN and define CONFIG_EC_BIN_PATH (https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/src/southbridge/intel/common/firmware/Kconfig#115) to point to the EC binary and the build system will use ifdtool to inject the binary at the EC region that is defined in the descriptor. (https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/src/southbridge/intel/common/firmware/Makefile.inc#64)

If you are creating a descriptor layout from scratch you will need to define the EC region in FLREG8: (example from google/drallion mainboard, which matches the layout in chromeos.fmd)
00000000:00000fff fd
00438000:01ffffff bios
00101000:00433fff me
00434000:00437fff pd
00001000:00100fff ec

As well as likely a pointer to the actual start of the EC binary in the image.  This part is not really documented by Intel and is likely EC vendor specific.  The Drallion example has 2 pointers starting at offset 0 of the descriptor, one for default loading and a second for a backup in case the first one is corrupt or fails to boot:

00000000:  10 00 00 f7 10 08 00 5f
In this example bits [22:0] correspond to bits [30:8] of the address, so the EC is always on a 256 byte boundary.  bits [31:24] contain a CRC8-ITU checksum of bits [0-23].

If you're working with an unknown EC it is probably best to try and copy what is in the existing image, including the location of the EC image in flash as the firmware may expect to execute out of that specific address region and not tolerate relocation.

-duncan