Hi Patrick,

I believe that the first two patches in this series can be replicated
with [1]. For example, if you currently use FASTBOOT_MMC_BOOT_SUPPORT
with FASTBOOT_MMC_BOOT1_NAME set to "mmc0boot1", leading to commands
like

$ fastboot erase mmc0boot1

You could instead do

$ fastboot erase 0.1:0

And the first behavior could be emulated by setting the environmental
variable "fastboot_partition_alias_mmc0boot1" to "0.1:0".

I would like to work towards deprecating Kconfigs for achieving this
particular use case. This is because everything is set at compile-time,
but we have existing tools which make this easy to do at run-time.
Favoring run-time configuration makes it easier to use one U-Boot for
different boards, and also makes it easier for users to modify U-Boot.

For the latter two patches, I think there are two existing solutions.
First, there is the patch to add "ucmd" support to fastboot. This allows
running arbitrary commands on the U-Boot side. However, this may be
unsuitable for systems which need to maintain a chain of trust (since
allowing arbitrary commands would allow arbitrary software to run).

With this in mind, FIT images allow for script sections. For example,
one could create an image tree source file like

/dts-v1/;

/ {
        description = "Configuration script";
        #address-cells = <1>;

        images {
                default = "script-1";
                script-1 {
                        data = /incbin/("mmc.scr");
                        type = "script";
                        compression = "none";
                        signature {
                                algo = "sha1,rsa2048";
                                key-name-hint = "dev";
                        };
                };
        };
};

(or something similar; I haven't tested this). This would create a fit
with containing "mmc.scr". On the U-Boot side, running

fastboot 0
source

Would source any script contained within the FIT image (if it was
downloaded e.g. with "fastboot boot mmc.itb". I think this process would
work well for "run once" scripts like setting the mmc boot partitions.

Please let me know if any of the above suggestions would achieve the
functionality you need.

--Sean

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=223198
[2] 
https://patchwork.ozlabs.org/project/uboot/patch/20210111101919.228555-1...@denx.de/

On 1/27/21 8:46 AM, Patrick Delaunay wrote:

Hi,

It is a rebased V2 version of the serie [1].

This serie adds a lot of new #if and doesn't respect the last
U-Boot coding rules with 14 warnings detected by checkpatch:

   warning: Use 'if (IS_ENABLED(CONFIG...))'
            instead of '#if or #ifdef' where possible

But I chose to copy the existing code of the fastboot files
fb_command.c to a have an easier review.

So I prefer sent a patch (if it is required) to remove all the
#ifdef in this file when the serie will be accepted.

I check compilation of the added features on stm32mp1 platform
with the serie [2].

The compilation for modified boards (with already activated config
CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT) is verified with buildman:

tools/buildman/buildman mt8512_bm1_emmc mt8518_ap1_emmc pumpkin
Building current source for 3 boards (3 threads, 4 jobs per thread)
    aarch64:  w+   pumpkin
+===================== WARNING ======================
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================
    aarch64:  w+   mt8518_ap1_emmc
+===================== WARNING ======================
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================
    aarch64:  w+   mt8512_bm1_emmc
+===================== WARNING ======================
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================
     0    3    0 /3              0:00:07  : mt8512_bm1_emmc
Completed: 3 total built, duration 0:00:23, rate 0.13

[1] "fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT"
     http://patchwork.ozlabs.org/project/uboot/list/?series=200509&state=*

[2] "configs: stm32mp1: enable fastboot support of eMMC boot partition"
     http://patchwork.ozlabs.org/project/uboot/list/?series=200510

Regards

Patrick


Changes in v2:
- rebase on master branch
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig

Patrick Delaunay (4):
   fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT
   fastboot: mmc: extend flash/erase for both emmc hwpart 1 and 2
   fastboot: add command to select the default emmc hwpart for boot
   fastboot: add command to select the eMMC boot configuration

  configs/mt8512_bm1_emmc_defconfig |  3 +-
  configs/mt8518_ap1_emmc_defconfig |  3 +-
  configs/pumpkin_defconfig         |  3 +-
  doc/android/fastboot.rst          |  3 ++
  drivers/fastboot/Kconfig          | 62 ++++++++++++++++++++------
  drivers/fastboot/fb_command.c     | 72 +++++++++++++++++++++++++++++++
  drivers/fastboot/fb_mmc.c         | 52 ++++++++++++++--------
  include/fastboot.h                |  6 +++
  8 files changed, 171 insertions(+), 33 deletions(-)


Reply via email to