Skip to content

Commit

Permalink
init: Dynamically set CONFIG_TPM at boot
Browse files Browse the repository at this point in the history
Dynamically set CONFIG_TPM at boot based on the presence of /dev/tpm0.
This allows the same board/device with and without a TPM to be handled
by a single board definition and single firmware image. It also eliminates
the need to explictly define CONFIG_TPM in board config files.

Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
  • Loading branch information
MrChromebox committed Sep 16, 2020
1 parent 53c74fa commit aeec903
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions initrd/init
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ hwclock -l -s
. /etc/functions
. /etc/config

# set CONFIG_TPM dynamically before init
if [ -e /dev/tpm0 ]; then
export CONFIG_TPM='y'
else
export CONFIG_TPM='n'
fi

if [ "$CONFIG_COREBOOT" = "y" ]; then
/bin/cbfs-init
fi
Expand Down Expand Up @@ -89,6 +96,13 @@ if [ "$boot_option" = "r" ]; then
exit
fi

# Override CONFIG_TPM and persist via user config
if [ -e /dev/tpm0 ]; then
echo "CONFIG_TPM=y" >> /etc/config.user
else
echo "CONFIG_TPM=n" >> /etc/config.user
fi

combine_configs
. /tmp/config

Expand Down

0 comments on commit aeec903

Please sign in to comment.