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

Add Qemu adn UEFI Capsule Update support #26

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft

Conversation

DaniilKl
Copy link
Contributor

This PR adds support for Qemu so to be able to test DTS and its features more easily. Additionally, this PR adds support for Dasharo firmware updates provided via UEFI capsules.

@DaniilKl DaniilKl self-assigned this Aug 19, 2024
@DaniilKl
Copy link
Contributor Author

DaniilKl commented Aug 21, 2024

@macpijan, thought it is not a part of this PR, I have a question about EC firmware installation process.

Currently in scripts/dasharo-deploy, in function install we have a code, which installs EC firmware:

(...)
  if [ "$HAVE_EC" == "true" ]; then
    echo "Checking for Open Source Embedded Controller firmware"
    $DASHARO_ECTOOL info >> $ERR_LOG_FILE 2>&1
    if [ $? -eq 0 ]; then
      echo "Device has already Open Source Embedded Controller firmware, do not flash EC..."
    else
      _ec_fw_version=$($FLASHROM -p "$PROGRAMMER_EC" ${FLASH_CHIP_SELECT} | grep "Mainboard EC Version" | tr -d ' ' | cut -d ':' -f 2)
      if [ "$_ec_fw_version" != "$COMPATIBLE_EC_FW_VERSION" ]; then
        print_warning "EC version: $_ec_fw_version is not supported, update required"
        install_ec
      fi
    fi
  fi
(...)

IIUC, we want EC firmware version to match COMPATIBLE_EC_FW_VERSION which is an EC firmware version needed by Dasharo firmware. If it so, why we skip checking version of the EC firmware in case Device has already Open Source Embedded Controller firmware, do not flash EC... ? If a device already has some "Open Source Embedded Controller firmware", it does not mean it has the right version.

@macpijan
Copy link
Contributor

If it so, why we skip checking version of the EC firmware in case Device has already Open Source Embedded Controller firmware, do not flash EC... ? If a device already has some "Open Source Embedded Controller firmware", it does not mean it has the right version.

If a device already has open-source EC, then it most likely already has Dasharo as well, and the install function would not be called at all, as this is for initial deployment mostly, IIRC?

@DaniilKl
Copy link
Contributor Author

DaniilKl commented Aug 22, 2024

as this is for initial deployment mostly, IIRC?

It is.

If a device already has open-source EC, then it most likely already has Dasharo as well, and the install function would not be called at all

Ok then, but nobody stops a user with Dasharo installed to choose install Dasharo to install another version (e.g. intentionally downgrade) that will lead him to not installing proper version of EC firmware, I cannot find any code which will restrict such case.

@macpijan
Copy link
Contributor

macpijan commented Aug 22, 2024

Ok then, but nobody stops a user with Dasharo installed to choose install Dasharo to install another version (e.g. intentionally downgrade) that will lead him to not installing proper version of EC firmware, I cannot find any code which will restrict such case.

If Dasharo is displayed, Install Dasharo option is not visible in the menu. Only option to update Dasahro should be visible at this point.

@DaniilKl
Copy link
Contributor Author

If Dasharo is displayed, Install Dasharo option is not visible in the menu. Only option to update Dasahro should be visible at this point.

My bad, have forgotten about it.

Signed-off-by: Daniil Klimuk <[email protected]>
CMD_DASHARO_DEPLOY is already defined in /usr/sbin/dts-environment.sh
and included in the beginning og the dasharo-hcl-report.

Signed-off-by: Daniil Klimuk <[email protected]>
QEMU q35 will use UEFI Capsule Update only.

Signed-off-by: Daniil Klimuk <[email protected]>
Configurations of all the supported platforms are done insinde
board_config function as switch/case Bash statemansts. The list of
supported platforms has grown a lot since then, and the function became
unreadable, so adding and managing configurations became difficult and
error-prone.

This commit adds some default configuration values as well as tries to
reuse some configuration code.

Signed-off-by: Daniil Klimuk <[email protected]>
Variables with links to hashes of the firmware binaries are always set,
use variables with links to firmware binaries instead.

Signed-off-by: Daniil Klimuk <[email protected]>
"test -v" checks whether a variable has been declared, it does not check
its value. We sometimes use "unset" for some variables, and then check
again with "test -v". The problem is, "unset" takes variable value, but
the variable still exists, so the "test -v" will be true before, as well
as after the "unset".

We must use "test -n" (whether a variable holds non-zero length
string value) and "test -z" (whether a variable holds zero length string
value) to check string values of variables. This way the "unset" will
work.

Signed-off-by: Daniil Klimuk <[email protected]>
This function is useful not unly during update workflow, but every time
firmware is being deployed

Signed-off-by: Daniil Klimuk <[email protected]>
Before deploing we do some configuration based on the list of the
firmware versions the target supports and on DPP subscription user
has.

Previously this configuration lived beside the code responsible for
deploying, as a result, the deploying workflows was messy, had nesting
levels over 3, and nonlinear and complex logic.

This commit tries to separate this configuration and deploying to make
it more readable and scallable.

Signed-off-by: Daniil Klimuk <[email protected]>
The installation workflows must be as linear as possbile for better
readability and scalability.

Signed-off-by: Daniil Klimuk <[email protected]>
These veriables are already defined in dts-environment.sh, and the
ec_transition sources it.

Signed-off-by: Daniil Klimuk <[email protected]>
This code is currently used inside dasharo-deploy only.

Signed-off-by: Daniil Klimuk <[email protected]>
@DaniilKl DaniilKl force-pushed the add-qemu-support branch 4 times, most recently from 1bc2bc9 to 8d55bcd Compare September 30, 2024 09:13
Before:

*********************************************************
R to reboot  P to poweroff  S to enter shell
K to launch SSH server  L to enable sending DTS logs V to enable verbose mode
Enter an option:

Now:

*********************************************************
R to reboot  P to poweroff  S to enter shell
K to launch SSH server  L to enable sending DTS logs
V to enable verbose mode
Enter an option:

Signed-off-by: Daniil Klimuk <[email protected]>
Signed-off-by: Daniil Klimuk <[email protected]>
Not all platforms are supported by flashrom, but some of them may use
other deploying means (e.g. QEMU and UEFI Capsule Update). So, the code
that uses flashrom should only be executed in case it is possible, to
avoid surplus issues.

Signed-off-by: Daniil Klimuk <[email protected]>
We only have community EC firmware, no need to check credentials.

Signed-off-by: Daniil Klimuk <[email protected]>
Some menu options depend on hardware configuration.

Signed-off-by: Daniil Klimuk <[email protected]>
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.

2 participants