Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject Heads version string into coreboot LOCALVERSION... #859

Merged
merged 4 commits into from
Oct 21, 2020

Conversation

MrChromebox
Copy link
Contributor

and produce coreboot output file in format:

heads-$(BOARD)-$(VERSION)[-dirty].rom

Signed-off-by: Matt DeVillier [email protected]

@MrChromebox
Copy link
Contributor Author

this is mostly a POC at the moment, we can adjust as desired from here

@tlaurion
Copy link
Collaborator

@MrChromebox away from computer but ci build failed. Will check

@MrChromebox
Copy link
Contributor Author

@tlaurion probably a few dependencies on the literal coreboot.rom that I missed, looks like one for flash-x230. I'll clean it up later tonight or tomorrow

@Asiderr
Copy link

Asiderr commented Oct 18, 2020

@MrChromebox @tlaurion I built and flashed the rom image for x230. Hwids log looks good:

# fwupdmgr hwids 
Computer Information
--------------------
BiosVendor: coreboot
BiosVersion: CBET4000 Heads-v0.2.0-917-g19f0e65
Manufacturer: LENOVO
Family: 
ProductName: 23245QU
ProductSku: 
EnclosureKind: 9
BaseboardManufacturer: LENOVO
BaseboardProduct: 23245QU

Hardware IDs
------------
not available as 'BiosMajorRelease' unknown
not available as 'BiosMajorRelease' unknown
not available as 'BiosMajorRelease' unknown
{d9a4a057-6a3b-5661-8f47-f4ebd87946cc}   <- Manufacturer + Family + ProductName + ProductSku + BaseboardManufacturer + BaseboardProduct
{4773e7f1-ce42-5f3c-a22c-c88719824222}   <- Manufacturer + Family + ProductName + ProductSku
{8a637c26-6795-5d54-b27e-cc1aae36e675}   <- Manufacturer + Family + ProductName
{6d1ebd4f-56c7-55f6-87fb-51ff4ee91372}   <- Manufacturer + ProductSku + BaseboardManufacturer + BaseboardProduct
{5b5a18ca-c3f4-58c6-aa2e-a0feb7e5bb30}   <- Manufacturer + ProductSku
{596c3466-0506-5ca5-a68f-dc34532a93d3}   <- Manufacturer + ProductName + BaseboardManufacturer + BaseboardProduct
{ab1f65f9-7307-5f24-8a8e-b5204f6f2265}   <- Manufacturer + ProductName
{6d1ebd4f-56c7-55f6-87fb-51ff4ee91372}   <- Manufacturer + Family + BaseboardManufacturer + BaseboardProduct
{5b5a18ca-c3f4-58c6-aa2e-a0feb7e5bb30}   <- Manufacturer + Family
{ce0fc7a9-4b3f-57e6-b68e-cf50fc0738e8}   <- Manufacturer + EnclosureKind
{ece3da41-b1aa-5abb-a39e-0eda5821d675}   <- Manufacturer + BaseboardManufacturer + BaseboardProduct
{6de5d951-d755-576b-bd09-c5cf66b27234}   <- Manufacturer

@tlaurion tlaurion mentioned this pull request Oct 18, 2020
@tlaurion
Copy link
Collaborator

linked to #834 and #839

@tlaurion
Copy link
Collaborator

tlaurion commented Oct 18, 2020

@MrChromebox @tlaurion I built and flashed the rom image for x230. Hwids log looks good:

# fwupdmgr hwids 
Computer Information
--------------------
BiosVendor: coreboot
BiosVersion: CBET4000 Heads-v0.2.0-917-g19f0e65
Manufacturer: LENOVO
Family: 
ProductName: 23245QU
ProductSku: 
EnclosureKind: 9
BaseboardManufacturer: LENOVO
BaseboardProduct: 23245QU

Hardware IDs
------------
not available as 'BiosMajorRelease' unknown
not available as 'BiosMajorRelease' unknown
not available as 'BiosMajorRelease' unknown
{d9a4a057-6a3b-5661-8f47-f4ebd87946cc}   <- Manufacturer + Family + ProductName + ProductSku + BaseboardManufacturer + BaseboardProduct
{4773e7f1-ce42-5f3c-a22c-c88719824222}   <- Manufacturer + Family + ProductName + ProductSku
{8a637c26-6795-5d54-b27e-cc1aae36e675}   <- Manufacturer + Family + ProductName
{6d1ebd4f-56c7-55f6-87fb-51ff4ee91372}   <- Manufacturer + ProductSku + BaseboardManufacturer + BaseboardProduct
{5b5a18ca-c3f4-58c6-aa2e-a0feb7e5bb30}   <- Manufacturer + ProductSku
{596c3466-0506-5ca5-a68f-dc34532a93d3}   <- Manufacturer + ProductName + BaseboardManufacturer + BaseboardProduct
{ab1f65f9-7307-5f24-8a8e-b5204f6f2265}   <- Manufacturer + ProductName
{6d1ebd4f-56c7-55f6-87fb-51ff4ee91372}   <- Manufacturer + Family + BaseboardManufacturer + BaseboardProduct
{5b5a18ca-c3f4-58c6-aa2e-a0feb7e5bb30}   <- Manufacturer + Family
{ce0fc7a9-4b3f-57e6-b68e-cf50fc0738e8}   <- Manufacturer + EnclosureKind
{ece3da41-b1aa-5abb-a39e-0eda5821d675}   <- Manufacturer + BaseboardManufacturer + BaseboardProduct
{6de5d951-d755-576b-bd09-c5cf66b27234}   <- Manufacturer

@Asiderr PrivacyBeast and Nitropad will have some problems going that path, if the sole version of the ROM board version (LOCAL_VERSION = ProductName -> Heads-x230-hotp-v0.2.0-917-g19f0e65) alone isn't enough for fwupd to determine firmware upgrade applicable, since x230 ProductName SEEMS to be considered in the equation. So to speak, a coreboot BiosVersion (CBET4000 Heads-x230-hotp-v0.2.0-917-g19f0e65) SHOULD serve alone to differentiate a BiosVersion to be applicable for fwupd, without considering ProductName. There is more then 30 different ProductName variants for x230 boards (including x230t), while Heads supports all of them without internal differences.

If some differences applies between boards, they would be covered in different $BOARD in Heads parlance, to support more or less features, rquiring more or less SPI freed (available CBFS space), also differentiating how flashrom should deal with rom upgrades in the board config (should that board flash only the BIOS ifd region or flash the whole 12mb flash region?) since we are not producers of the boards themselves and do not know prior of the fact which ProductName the Heads board configuration supports (and we sell), which will vary from machine to machines supported by the same board config (x230-htop, x230, x230-external-flash, etc)

Is that a problem? (impacts NitroPads from Nitrokey also : @jans23)

@MrChromebox
Copy link
Contributor Author

pondering this a bit, thinking that we should probably drop setting the LOCALVERSION from the coreboot configs, since it could be confusing to have a value there that's overwritten. What would probably make the most sense is to only set LOCALVERSION if it doesn't already exist in the config -- so default to injecting $(HEADS_GIT_VERSION) but still allow the user to be override via coreboot config.

thoughts?

@tlaurion
Copy link
Collaborator

tlaurion commented Oct 18, 2020

pondering this a bit, thinking that we should probably drop setting the LOCALVERSION from the coreboot configs, since it could be confusing to have a value there that's overwritten.

@agreed that that would confuse users to have a value and not understand easily where that comes from. Would be better to not set LOCAL_VERSION into coreboot config but inject it prior of building coreboot.

What would probably make the most sense is to only set LOCALVERSION if it doesn't already exist in the config -- so default to injecting $(HEADS_GIT_VERSION) but still allow the user to be override via coreboot config.

I do not think $(HEADS_GIT_VERSION) is enough.

@MrChromebox I restate the need to have something like Heads-$BOARD-$TAG-$$(HEADS_GIT_VERSION-$dirty as proposed previously, while @Asiderr input is mandatory to have something FWUPD will be able to deal with to compare versions, to not go further before #859 (comment) is understood and consensus is obtained on proper versioning for Heads, dealt with by FWUPD. Else my understanding is that coreboot will need to be patched with custom vendors for Insurgo and Nitrokey and others and really complexifying board and coreboot configs.

thoughts?

Short future is Heads having versioning from releases tags again, so artifacts are injected by CIs and hashes confirmed for reproducibility by different docker image building the same commit. So an artifact should clearly differenciate that we are talking about:

  • Heads (vs coreboot, both from a LocalVersion (ProductName) and filename to ease testing and rom name easy differenciation on local collection for testing)
  • LocalVersion should inject $BOARD name both into filename and LocalVersion
  • $GIT_TAG should be the main differenciation between versions of rom from a filename and LocalVersion perspective for FWUPD differenciation from a same reported $BOARD name for easy >= version for applicable upgrades
  • $GIT_VERSION is impossible to compare for version >= between local rom collection, while GIT_TAB is. Should be differenciating both in LocalVersion for fwupd and in filename, stillm to know which commit that ROM was coming from, and for bissecting in case of regressions.
  • $dirty flag is really usefull when developping locally, to differenciate what was official from locally built.

That's at least my 2 cents until @Asiderr gives his input, since the real importance here is how FWUPD and LVFS will deal with firmware upgrade calls and storage and differenciate them.

@MrChromebox
Copy link
Contributor Author

agreed that that would confuse users to have a value and not understand easily where that comes from. Would be better to not set LOCAL_VERSION into coreboot config but inject it prior of building coreboot.

will drop and modify to inject only if not present in board's coreboot config

@MrChromebox I restate the need to have something like Heads-$BOARD-$TAG-$$(HEADS_GIT_VERSION-$dirty as proposed previously

@tlaurion $(HEADS_GIT_VERSION) already contains the tag, # of commits on top, short hash, and dirty status -- there's no need to duplicate that. Putting the board name in the version string is redundant as fwupd will pull that from SMBIOS already.

@tlaurion
Copy link
Collaborator

agreed that that would confuse users to have a value and not understand easily where that comes from. Would be better to not set LOCAL_VERSION into coreboot config but inject it prior of building coreboot.

will drop and modify to inject only if not present in board's coreboot config

@MrChromebox I restate the need to have something like Heads-$BOARD-$TAG-$$(HEADS_GIT_VERSION-$dirty as proposed previously

@tlaurion $(HEADS_GIT_VERSION) already contains the tag, # of commits on top, short hash, and dirty status -- there's no need to duplicate that. Putting the board name in the version string is redundant as fwupd will pull that from SMBIOS already.

@MrChromebox awesome!
$BOARD injection is what is missing in LocalVersion and filenames until FWUPD team replies :)

@MrChromebox
Copy link
Contributor Author

$BOARD injection is what is missing in LocalVersion and filenames until FWUPD team replies :)

I already added $(BOARD) to the output filenames, just not to LOCALVERSION :)

@tlaurion
Copy link
Collaborator

tlaurion commented Oct 18, 2020

Putting the board name in the version string is redundant as fwupd will pull that from SMBIOS already.

@MrChromebox i'm confused here. Board name, as explained and showed in @Asiderr output, shows that LocalVersion SHOULD have this information else #859 (comment)

# fwupdmgr hwids 
Computer Information
--------------------
BiosVendor: coreboot
BiosVersion: CBET4000 Heads-v0.2.0-917-g19f0e65
Manufacturer: LENOVO
Family: 
ProductName: 23245QU
ProductSku: 
EnclosureKind: 9
BaseboardManufacturer: LENOVO
BaseboardProduct: 23245QU

Here, we do not know if boardname is x230, x230-hotp-verification, x230-external-flash etc. And that would be totally different firmwares and functionalities, and should differentiate which firmware is to be the upgrade to current locally deployed firmware. Not the ProductName, BaseboardProduct.

Short:
If BiosVersion: CBET4000 Heads-v0.2.0-917-g19f0e65 was:

  • BiosVersion: CBET4000 Heads-x230-external-flash-v0.2.0-917-g19f0e65 we would know that firmware is coming from x230-external-flash board (full x230 externally and internally flashable ROM, not only BIOS region, which should not be upgraded by any other ROM then x230-external-flash build roms unless resulting of a brick because fake IFD etc)
  • BiosVersion: CBET4000 Heads-x230-v0.2.0-917-g19f0e65 we would know that firmware is coming from the x230 board. IF user wants to switch from that board to x230-hotp-verification, he will have to do manually prior of FWUPD proposing x230-hotp-verification upgrades

Hope this clarifies the use case and the reasoning behind all of this.

@MrChromebox
Copy link
Contributor Author

@MrChromebox i'm confused here. Board name, as explained and showed in @Asiderr output, shows that LocalVersion SHOULD have this information else #859 (comment)

IMO, we should patch coreboot to not overwrite the product name, unless doing so breaks something on the OS side. All non-thinkpad boards properly have the board name set by coreboot and can be identified that way

@tlaurion
Copy link
Collaborator

tlaurion commented Oct 18, 2020

@MrChromebox I tried to reach you over slack to clarify incomprehension and reduce issue cluttering.
I emptied my brain over private slack messages.

@Asiderr
Copy link

Asiderr commented Oct 18, 2020

@tlaurion @MrChromebox From the fwupd wrapper point of view, a user is passing the device flag, which is equivalent to the BOARD variable. It's compared with the update id, which specifies update type. The whole update process is based on the metadata file, which describes the update. This is an example of the metadata that I’ve used during the development stage:

<?xml version="1.0" encoding="UTF-8"?>
<component type="firmware">
  <id>com.3mdeb.heads.x230.firmware</id>
  <name>Heads x230</name>
  <summary>x230 heads system firmware</summary>
  <description>
    <p>x230 heads system firmware</p>
  </description>
  <provides>
    <firmware type="flashed">596c3466-0506-5ca5-a68f-dc34532a93d3</firmware>
  </provides>
  <url type="homepage">http://osresearch.net/</url>
  <metadata_license>CC0-1.0</metadata_license>
  <project_license>GPLv2</project_license>
  <developer_name>coreboot</developer_name>
  <categories>
    <category>X-System</category>
  </categories>
  <releases>
    <release version="0.2.4" date="2020-09-09" urgency="high">
      <checksum type="sha1" filename="firmware.rom" target="content">14f3aa7d4821bbe2133754868d854bd629e6f4c6</checksum>
      <checksum type="sha256" filename="firmware.rom" target="content">776ca9a1274ccf914753ca4a07e494fb828e63905a8525c1e992064700d9caad</checksum>
      <description>
        <p>Fixes flash-gui issue.</p>
      </description>
      <size type="installed">12582912</size>
    </release>
  </releases>
</component>

IMHO we want to place an update type and a device name in the id tag. The CI should generate a proper metadata file for each ROM image and pack that into the cab archive, as it is presented in the LVFS documentation. So it’s not obligatory to add the board name to the version tag.

@MrChromebox
Copy link
Contributor Author

@Asiderr the question remains, how does the proper device flag get passed to fwupd? If the OS is doing that, then it needs to be pulled from somewhere, and the SMBIOS ProductName seems like a reasonable place to do so (vs embedded in the BIOS VERSION and having to extract from a longer string)

@MrChromebox MrChromebox force-pushed the inject_heads_version branch 2 times, most recently from ecb678e to dda913c Compare October 18, 2020 23:07
@Asiderr
Copy link

Asiderr commented Oct 19, 2020

@MrChromebox @tlaurion For now, this depends only on the user choice - fwupd looks for the updates for the --device. For example, if the command looks like this:

# qubes-fwupdmgr update-heads --device=x230-htop

fwupd will look for x230-hotp updates. If the update exists, fwupd will download the ROM image and will place it in the /boot. The update process is executed by Heads.
But I agree that SMBIOS ProductName is a good way to pass device information. The --device flag should be only optional. If it's not present, the fwupd should check SMBIOS ProductName and should look for updates for the current device.

@alex-nitrokey
Copy link
Contributor

Is that a problem? (impacts NitroPads from Nitrokey also : @jans23)

I already talked with @jans23 about this topic. As I always try to upstream our additions, our NitroPad builds differ only in a few things to default heads builds. If it is necessary to drop these differences for a fwupd support, we would probably just go with a "standard" heads build. Anything useful/important should be included in osresearch/heads anyway. That is to say, anything necessary to change would probably be fine for us.

@tlaurion
Copy link
Collaborator

tlaurion commented Oct 20, 2020

@MrChromebox :
From https://circleci.com/api/v1.1/project/github/MrChromebox/heads/34/output/111/0?file=true&allocation-id=5f8cca9798b7110f5f819977-0-build%2F5447C0B2

(Tip: search in screen for <== markers. First occurrence is delimiting (above) where the build failed, after is individual logs that got modified in the last minute)

if cmp --quiet "/root/project/build/linuxboot-git/build/x230-flash/linuxboot.rom" "/root/project/build/x230-flash/" ; then echo "`date --rfc-3339=seconds` UNCHANGED build/linuxboot-git/build/x230-flash/linuxboot.rom" ; fi ; cp -a "/root/project/build/linuxboot-git/build/x230-flash/linuxboot.rom" "/root/project/build/x230-flash/" ; 
cp: cannot stat '/root/project/build/linuxboot-git/build/x230-flash/linuxboot.rom': No such file or directory
make: *** [modules/linuxboot:63: /root/project/build/x230-flash/] Error 

@MrChromebox
Copy link
Contributor Author

@tlaurion I'm confused as to why it would be trying to build linuxboot at all

@tlaurion
Copy link
Collaborator

Ok. I'll use x230-flash build output to compare master and this PR failed builds.

  1. osresearch/master latest successful build log

  2. this PR actual failed build log

In 1:

2020-10-19 18:50:08+00:00 INSTALL   build/coreboot-4.8.1/x230-flash/coreboot.rom => build/x230-flash/coreboot.rom
if cmp --quiet "/root/project/build/coreboot-4.8.1/x230-flash/coreboot.rom" "/root/project/build/x230-flash/coreboot.rom" ; then echo "`date --rfc-3339=seconds` UNCHANGED build/coreboot-4.8.1/x230-flash/coreboot.rom" ; fi ; cp -a "/root/project/build/coreboot-4.8.1/x230-flash/coreboot.rom" "/root/project/build/x230-flash/coreboot.rom" ; 
9e1e2656b7ba96bb98b8f7ef72d590dcc00fa5c60bad9a4cc2600060d5192880  build/x230-flash/coreboot.rom
dd of=/root/project/build/x230-flash/x230-flash.rom if=/root/project/build/x230-flash/coreboot.rom bs=65536 count=64 skip=128
64+0 records in
64+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.00384138 s, 1.1 GB/s
sha256sum /root/project/build/x230-flash/x230-flash.rom
0d8e75b41593fd1e745c6dc42590987b22a3a60134062a270f9957dc91c61ccc  /root/project/build/x230-flash/x230-flash.rom

In 2:

/root/project/crossgcc/bin/x86_64-linux-musl-strip --preserve-dates -o "/tmp/tmp.fVLQQay8PI/lib/libz.so.1" "/root/project/build/zlib-1.2.11/libz.so.1"
2020-10-19 00:48:48+00:00 INSTALL boards/x230-flash/x230-flash.config
export | grep ' CONFIG_' | sed -e 's/^declare -x /export /' -e 's/\\\"//g' > /tmp/tmp.fVLQQay8PI/etc/config 
2020-10-19 00:48:48+00:00 HASH dda913cd38e97e564b5bfc96358dc12259abe727 clean x230-flash
echo export GIT_HASH=\'dda913cd38e97e564b5bfc96358dc12259abe727\' >> /tmp/tmp.fVLQQay8PI/etc/config ; echo export GIT_STATUS=clean >> /tmp/tmp.fVLQQay8PI/etc/config ; echo export CONFIG_BOARD=x230-flash >> /tmp/tmp.fVLQQay8PI/etc/config ; 
2020-10-19 00:48:48+00:00 CPIO      build/x230-flash/tools.cpio
( cd "/tmp/tmp.fVLQQay8PI"; find . | cpio --quiet -H newc -o ) | ./bin/cpio-clean > "/root/project/build/x230-flash/tools.cpio.tmp" 
9cd5056f8ed5666c47c71c37ddf16c86ba813d59f0b08cffcfb14f49bf263294  /root/project/build/x230-flash/tools.cpio
2020-10-19 00:48:48+00:00 HASHES    build/x230-flash/tools.cpio
( cd "/tmp/tmp.fVLQQay8PI"; echo "-----" ; find . -type f -print0 | xargs -0 sha256sum ; echo "-----" ; ) >> "/root/project/build/x230-flash/hashes.txt" 
2020-10-19 00:48:48+00:00 CPIO      build/x230-flash/heads.cpio
( cd "/root/project/initrd"; find . | cpio --quiet -H newc -o ) | ./bin/cpio-clean > "/root/project/build/x230-flash/heads.cpio.tmp" 
bf59384d066d47f2d3f9b22eee91d67ef6cb1699a986760f2777f2ddbda6462b  /root/project/build/x230-flash/heads.cpio
2020-10-19 00:48:48+00:00 HASHES    build/x230-flash/heads.cpio
( cd "/root/project/initrd"; echo "-----" ; find . -type f -print0 | xargs -0 sha256sum ; echo "-----" ; ) >> "/root/project/build/x230-flash/hashes.txt" 
2020-10-19 00:48:48+00:00 CPIO-XZ   build/x230-flash/initrd.cpio.xz
/root/project/bin/cpio-clean /root/project/blobs/dev.cpio /root/project/build/x230-flash/modules.cpio /root/project/build/x230-flash/tools.cpio /root/project/build/x230-flash/heads.cpio | xz --check=crc32 --lzma2=dict=1MiB -9 | dd bs=512 conv=sync status=none > "/root/project/build/x230-flash/initrd.cpio.xz.tmp" 
fbca655363f8c262c606eb7f0e77b7b471de7db465b8bfbe0cf4d8a82157bc34  build/x230-flash/initrd.cpio.xz
2020-10-19 00:48:49+00:00 INSTALL   build/linuxboot-git/build/x230-flash/linuxboot.rom => build/x230-flash/
if cmp --quiet "/root/project/build/linuxboot-git/build/x230-flash/linuxboot.rom" "/root/project/build/x230-flash/" ; then echo "`date --rfc-3339=seconds` UNCHANGED build/linuxboot-git/build/x230-flash/linuxboot.rom" ; fi ; cp -a "/root/project/build/linuxboot-git/build/x230-flash/linuxboot.rom" "/root/project/build/x230-flash/" ; 
cp: cannot stat '/root/project/build/linuxboot-git/build/x230-flash/linuxboot.rom': No such file or directory
make: *** [modules/linuxboot:63: /root/project/build/x230-flash/] Error 1

in 1 Makefile:

ifeq "$(CONFIG_COREBOOT)" "y"
all: $(build)/$(BOARD)/coreboot.rom
else ifeq "$(CONFIG_LINUXBOOT)" "y"
all: $(build)/$(BOARD)/linuxboot.rom
else
$(error "$(BOARD): neither CONFIG_COREBOOT nor CONFIG_LINUXBOOT is set?")
endif

in 2 Makefile:

ifeq "$(CONFIG_COREBOOT)" "y"
CB_OUTPUT_FILE := heads-$(BOARD)-$(HEADS_GIT_VERSION).rom
all: $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
else ifeq "$(CONFIG_LINUXBOOT)" "y"
LB_OUTPUT_FILE := linuxboot-$(BOARD)-$(HEADS_GIT_VERSION).rom
all: $(build)/$(BOARD)/$(LB_OUTPUT_FILE)
else
$(error "$(BOARD): neither CONFIG_COREBOOT nor CONFIG_LINUXBOOT is set?")
endif

in 1 boards/x230-flash/x230-flash.config:

all: $(build)/$(BOARD)/$(BOARD).rom
$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/coreboot.rom
	dd of=$@ if=$< bs=65536 count=64 skip=128
	sha256sum $@

in 2 boards/x230-flash/x230-flash.config:

all: $(build)/$(BOARD)/$(BOARD).rom
$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
	dd of=$@ if=$< bs=65536 count=64 skip=128
	sha256sum $@

@tlaurion
Copy link
Collaborator

@MrChromebox :
*-flash boards are special since they expect to play with the coreboot.rom image directly.

On x230 board, there is no specification for all, so the upper Makefile specifies the location of the image.
In the case of *flash boards, that all statement is redefined under board configs. Still no idea why linuxboot overrides here...

@tlaurion
Copy link
Collaborator

Seems like the all: statement of board config overrides totally the Makefile statement. Duplicate?

@tlaurion
Copy link
Collaborator

tlaurion commented Oct 20, 2020

@MrChromebox applied on top of this branch:

diff --git a/boards/x230-flash/x230-flash.config b/boards/x230-flash/x230-flash.config
index 283c8fb..9d7da08 100644
--- a/boards/x230-flash/x230-flash.config
+++ b/boards/x230-flash/x230-flash.config
@@ -25,7 +25,9 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image
 # for flashing into SPI flash 1 on the mainboard.  This is enough to
 # allow the board to boot into a minimal Heads and read the full
 # ROM from an external USB media.
-all: $(build)/$(BOARD)/$(BOARD).rom
+HEADS_GIT_VERSION      := $(shell git describe --tags --dirty)
+CB_OUTPUT_FILE := heads-$(BOARD)-$(HEADS_GIT_VERSION).rom
+all: $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
 $(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
        dd of=$@ if=$< bs=65536 count=64 skip=128
        sha256sum $@

Passes....

@tlaurion
Copy link
Collaborator

diff --git a/boards/x230-flash/x230-flash.config b/boards/x230-flash/x230-flash.config
index 283c8fb..9d7da08 100644
--- a/boards/x230-flash/x230-flash.config
+++ b/boards/x230-flash/x230-flash.config
@@ -25,7 +25,9 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image
 # for flashing into SPI flash 1 on the mainboard.  This is enough to
 # allow the board to boot into a minimal Heads and read the full
 # ROM from an external USB media.
-all: $(build)/$(BOARD)/$(BOARD).rom
+HEADS_GIT_VERSION      := $(shell git describe --tags --dirty)
+CB_OUTPUT_FILE := heads-$(BOARD)-$(HEADS_GIT_VERSION).rom
+all: $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
 $(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
        dd of=$@ if=$< bs=65536 count=64 skip=128
        sha256sum $@

diff --git a/boards/x230-flash/x230-flash.config b/boards/x230-flash/x230-flash.config
index 283c8fb..7ebce20 100644
--- a/boards/x230-flash/x230-flash.config
+++ b/boards/x230-flash/x230-flash.config
@@ -25,7 +25,9 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image
 # for flashing into SPI flash 1 on the mainboard.  This is enough to
 # allow the board to boot into a minimal Heads and read the full
 # ROM from an external USB media.
-all: $(build)/$(BOARD)/$(BOARD).rom
-$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
+HEADS_GIT_VERSION      := $(shell git describe --tags --dirty)
+CB_OUTPUT_FILE := heads-$(BOARD)-$(HEADS_GIT_VERSION).rom
+all: $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
+$(build)/$(BOARD)/$(CB_OUTPUT_FILE): $(build)/$(BOARD)/$(CB_OUTPUT_FILE)
        dd of=$@ if=$< bs=65536 count=64 skip=128
        sha256sum $@

Produces:

2020-10-20 15:39:26-04:00 INSTALL   build/coreboot-4.8.1/x230-flash/coreboot.rom => build/x230-flash/heads-x230-flash-v0.2.0-920-gdda913c-dirty.rom
6e5d7559c121b5d2e350b3f8788312e839ae0d34a3d2b8f5e03b33f4029d8689  build/x230-flash/heads-x230-flash-v0.2.0-920-gdda913c-dirty.rom
4b3be2b552ab6b60df7291bfbd819d9b92f88641662472e0ebd8ca7fc27a4c63  /home/user/heads/build/gawk-4.2.1/gawk

Will be injected as part of the build using $(HEADS_GIT_VERSION)

Signed-off-by: Matt DeVillier <[email protected]>
Needed for fwupd to handle board updates

Signed-off-by: Matt DeVillier <[email protected]>
makes builds uniquely identifiable based on board and version.

Signed-off-by: Matt DeVillier <[email protected]>
@MrChromebox
Copy link
Contributor Author

@tlaurion seems like we came to same conclusion but slightly different implementation

@tlaurion tlaurion merged commit bd7a945 into linuxboot:master Oct 21, 2020
@MrChromebox MrChromebox deleted the inject_heads_version branch October 21, 2020 21:18
MrChromebox added a commit to MrChromebox/heads that referenced this pull request Oct 21, 2020
PR linuxboot#859 should have included this after linuxboot#858 was merged,
but was missed

Signed-off-by: Matt DeVillier <[email protected]>
tlaurion pushed a commit that referenced this pull request Oct 21, 2020
PR #859 should have included this after #858 was merged,
but was missed

Signed-off-by: Matt DeVillier <[email protected]>
@tlaurion
Copy link
Collaborator

Note because I din't know myself:
heads-qemu-coreboot-v0.2.0-938-geea3401.rom corresponds to commit eea3401 with a g prepended as per github (g)+commit ID.

https://git-scm.com/docs/git-describe#_examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants