Skip to content

driver/bareboxdriver.py: Add parameter 'boot_command' #1071

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

meuren
Copy link

@meuren meuren commented Jan 18, 2023

To adapt the BareboxDriver and be consistent with the UBootDriver, the parameter 'boot_command' is added. Now you can set the boot source and do something like this:

targets:
main:
drivers:
BareboxDriver:
boot_command: "boot net"

Signed-off-by: Fabian Meuren [email protected]

Emantor
Emantor previously approved these changes Jan 25, 2023
@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Base: 63.2% // Head: 63.2% // No change to project coverage 👍

Coverage data is based on head (dd43a97) compared to base (dd43a97).
Patch has no changes to coverable lines.

❗ Current head dd43a97 differs from pull request most recent head 6f3e055. Consider uploading reports for the commit 6f3e055 to get more accurate results

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1071   +/-   ##
======================================
  Coverage    63.2%   63.2%           
======================================
  Files         152     152           
  Lines       11330   11330           
======================================
  Hits         7169    7169           
  Misses       4161    4161           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@Bastian-Krause Bastian-Krause left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but boot_command should be documented in doc/configuration.rst.

@@ -1595,6 +1595,7 @@ Arguments:
- bootstring (regex, default="Linux version \\d"): regex that indicating that the Linux Kernel is
booting
- password (str): optional, password to use for access to the shell
- boot_command (str, default="boot -v"): optional, boot command to boot target
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@@ -206,4 +208,4 @@ def boot(self, name: str):
if name:
self.console.sendline(f"boot -v {name}")
else:
self.console.sendline("boot -v")
self.console.sendline(self.boot_command)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking at this again: I think this can be quite confusing. self.boot_command is only used if name is set to an empty string. I don't think that's right. At the very least, this should be documented.

Copy link
Author

@meuren meuren Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, it's like: With boot_command you can overwrite the global default 'boot -v' and thus set a 'new' global default. This in turn can be overwritten with name if necessary. def boot(self, name: str = ""):
Do you have a suggestion on how it might be more intuitive?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Letting name default to an empty string looks good to me and should be adopted also by the UBootDriver.

Is setting boot_command and calling barebox.boot("mmc0") a valid use case? If it isn't, we could raise an exception in that case. This also applies to the UBootDriver.

In general: I don't really understand why you'd want to set a custom boot command and use the boot method, neither in barebox nor in U-Boot (and I know that boot_command is already implemented in the UBootDriver, but still). If you don't use the standard boot command, what keeps you from simply calling barebox.console.sendline("bootm ..") in your strategy/script? What's the benefit here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we have 2 usecases:

  1. Set a default boot source in the config using it the complete test. This works for UbootDriver via boot_command, but not with the BareboxDriver. The BareboxStrategy calls the BareboxDriver,boot("") so you need to configure the barebox itself. It would be nice to do this in the config with the supposed change.
  2. With GraphStrategy we can define different boot scenarios and go with "via" to a shell booted from the selected source. For this a direct choose through BareboxDriver,boot(SOURCE) would be helpful. This works for BareboxDriver, but not for UbootDriver. (U-Boot boot commands Support #1082)

Is there a prefer Way to select the boot_command? Should we get rid of the Driver.boot functions and set the drivers boot source only via strategy?

The difference between the barebox "boot -v NAME" and uboot "COMMAND" was choosen because we consider the barebox interface to be more stable. If needed we could remove the "run" from the uboot boot_command and also select a target (environment script).

Copy link
Member

@Bastian-Krause Bastian-Krause Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we have 2 usecases:

  1. Set a default boot source in the config using it the complete test. This works for UbootDriver via boot_command, but not with the BareboxDriver. The BareboxStrategy calls the BareboxDriver,boot("") so you need to configure the barebox itself. It would be nice to do this in the config with the supposed change.
  2. With GraphStrategy we can define different boot scenarios and go with "via" to a shell booted from the selected source. For this a direct choose through BareboxDriver,boot(SOURCE) would be helpful. This works for BareboxDriver, but not for UbootDriver. (Wip/uboot boot #1082)

This does not really answer my question, does it? I see the boot methods as a convenience feature to boot the regular way (i.e. boot [<name>]) . If you need anything special, you could just do it yourself (see my suggestion). I see no downside to this.

Is there a prefer Way to select the boot_command? Should we get rid of the Driver.boot functions and set the drivers boot source only via strategy?

I think for the regular case, they are convenient, see above. Everything else could be handled in a strategy.

The difference between the barebox "boot -v NAME" and uboot "COMMAND" was choosen because we consider the barebox interface to be more stable. If needed we could remove the "run" from the uboot boot_command and also select a target (environment script).

I don't really understand this.

Don't get me wrong here, I'm not strictly against the PR, especially since we have the same in the UBootDriver, but I'd like to prevent implementing special cases and overcomplicating the code if the alternative has no obvious downside and does not involve patching the driver.

I guess @Emantor and @jluebbe should weigh in because they reviewed #621.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we have 2 usecases:

  1. Set a default boot source in the config using it the complete test. This works for UbootDriver via boot_command, but not with the BareboxDriver. The BareboxStrategy calls the BareboxDriver,boot("") so you need to configure the barebox itself. It would be nice to do this in the config with the supposed change.
  2. With GraphStrategy we can define different boot scenarios and go with "via" to a shell booted from the selected source. For this a direct choose through BareboxDriver,boot(SOURCE) would be helpful. This works for BareboxDriver, but not for UbootDriver. (Wip/uboot boot #1082)

This does not really answer my question, does it? I see the boot methods as a convenience feature to boot the regular way (i.e. boot [<name>]) . If you need anything special, you could just do it yourself (see my suggestion). I see no downside to this.

We currently work with a static strategy for most tests, like

self.barebox.boot("")

The idea was to handle the boot source via the driver. def boot seams to be place to do this.
Adding it as a strategy parameter would also work. I would be nice to have the same API for barebox and u-boot driver.

Is there a prefer Way to select the boot_command? Should we get rid of the Driver.boot functions and set the drivers boot source only via strategy?

I think for the regular case, they are convenient, see above. Everything else could be handled in a strategy.

The difference between the barebox "boot -v NAME" and uboot "COMMAND" was choosen because we consider the barebox interface to be more stable. If needed we could remove the "run" from the uboot boot_command and also select a target (environment script).

I don't really understand this.

This was mostly about #1082

Don't get me wrong here, I'm not strictly against the PR, especially since we have the same in the UBootDriver, but I'd like to prevent implementing special cases and overcomplicating the code if the alternative has no obvious downside and does not involve patching the driver.

I guess @Emantor and @jluebbe should weigh in because they reviewed #621.

@meuren meuren force-pushed the bareboxdriver_boot_command branch from 6c4b3ad to 8fbc6de Compare January 25, 2023 15:01
@meuren meuren requested review from Bastian-Krause and Emantor and removed request for Bastian-Krause and Emantor January 25, 2023 15:01
@meuren
Copy link
Author

meuren commented Jan 26, 2023

Sorry, I am not yet familiar with your processes.

@meuren meuren force-pushed the bareboxdriver_boot_command branch 2 times, most recently from 5972615 to 72ff289 Compare January 26, 2023 10:07
@meuren meuren requested review from Emantor and Bastian-Krause and removed request for Bastian-Krause and Emantor February 3, 2023 13:44
To adapt the BareboxDriver and be consistent with the
UBootDriver, the parameter 'boot_command' is added.
Now you can do something like this:

targets:
  main:
    drivers:
      BareboxDriver:
        boot_command: "boot net"

Signed-off-by: Fabian Meuren <[email protected]>
Add 'test_barebox_boot' test to meet code coverage
and maintain related documentation

Signed-off-by: Fabian Meuren <[email protected]>
@meuren meuren force-pushed the bareboxdriver_boot_command branch from 72ff289 to 6f3e055 Compare February 6, 2023 10:07
@meuren meuren requested review from Emantor and removed request for Bastian-Krause February 6, 2023 10:35
@Emantor
Copy link
Member

Emantor commented Feb 23, 2023

Is this still relevant since we now have proper boot command support for the UBootDriver?

@Emantor Emantor added the needs author info Requires more information from the PR/Issue author label Feb 23, 2023
@jremmet
Copy link
Contributor

jremmet commented Feb 23, 2023

Is this still relevant since we now have proper boot command support for the UBootDriver?

Yes this is the equivalent default boot command for the BareboxDriver

@Emantor Emantor removed the needs author info Requires more information from the PR/Issue author label Feb 24, 2023
@jremmet
Copy link
Contributor

jremmet commented Mar 30, 2023

gently ping

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

Successfully merging this pull request may close these issues.

4 participants