mbox series

[RFT,v2,0/3] fastboot: add support for generic block flashing

Message ID 20250409-topic-fastboot-blk-v2-0-c676f21d414f@linaro.org
Headers show
Series fastboot: add support for generic block flashing | expand

Message

Neil Armstrong April 9, 2025, 7:58 a.m. UTC
This serie permits using any block device as target
for fastboot by moving the generic block logic into
a common set of helpers and also use them as generic
backend.

The erase logic has been extended to support software
erase since only 2 block drivers exposes the erase
operation.

Tests are welcome to make sure this series doesn't
introduce any regressions on the emmc backend.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
Changes in v2:
- Dropped applied virtio erase patch
- Reorganize patches, introducing helpers first, using them in mmc afterwards
- Added soft-erase logic
- Added move helpers to handle the partitions erase & flash from emmc
- Fixed const var on last patch
- Link to v1: https://lore.kernel.org/all/20240306185921.1854109-1-dimorinny@google.com/

---
Dmitrii Merkurev (3):
      fastboot: blk: introduce fastboot block flashing support
      fastboot: blk: switch emmc to use the block helpers
      fastboot: integrate block flashing back-end

 drivers/fastboot/Kconfig      |  20 ++-
 drivers/fastboot/Makefile     |   4 +-
 drivers/fastboot/fb_block.c   | 313 ++++++++++++++++++++++++++++++++++++++++++
 drivers/fastboot/fb_command.c |   8 ++
 drivers/fastboot/fb_common.c  |  16 ++-
 drivers/fastboot/fb_getvar.c  |   8 +-
 drivers/fastboot/fb_mmc.c     | 210 ++--------------------------
 include/fb_block.h            | 104 ++++++++++++++
 8 files changed, 477 insertions(+), 206 deletions(-)
---
base-commit: f892a7f397a66d8d09f418d1e0e06dfb48bac27d
change-id: 20250408-topic-fastboot-blk-c5e14cd59224

Best regards,

Comments

Neil Armstrong April 14, 2025, 9:13 a.m. UTC | #1
Hi Mattijs,

On 09/04/2025 09:58, neil.armstrong@linaro.org wrote:
> This serie permits using any block device as target
> for fastboot by moving the generic block logic into
> a common set of helpers and also use them as generic
> backend.
> 
> The erase logic has been extended to support software
> erase since only 2 block drivers exposes the erase
> operation.
> 
> Tests are welcome to make sure this series doesn't
> introduce any regressions on the emmc backend.

Could you get an eye on this v2 ?

Thanks,
Neil

> 
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
> Changes in v2:
> - Dropped applied virtio erase patch
> - Reorganize patches, introducing helpers first, using them in mmc afterwards
> - Added soft-erase logic
> - Added move helpers to handle the partitions erase & flash from emmc
> - Fixed const var on last patch
> - Link to v1: https://lore.kernel.org/all/20240306185921.1854109-1-dimorinny@google.com/
> 
> ---
> Dmitrii Merkurev (3):
>        fastboot: blk: introduce fastboot block flashing support
>        fastboot: blk: switch emmc to use the block helpers
>        fastboot: integrate block flashing back-end
> 
>   drivers/fastboot/Kconfig      |  20 ++-
>   drivers/fastboot/Makefile     |   4 +-
>   drivers/fastboot/fb_block.c   | 313 ++++++++++++++++++++++++++++++++++++++++++
>   drivers/fastboot/fb_command.c |   8 ++
>   drivers/fastboot/fb_common.c  |  16 ++-
>   drivers/fastboot/fb_getvar.c  |   8 +-
>   drivers/fastboot/fb_mmc.c     | 210 ++--------------------------
>   include/fb_block.h            | 104 ++++++++++++++
>   8 files changed, 477 insertions(+), 206 deletions(-)
> ---
> base-commit: f892a7f397a66d8d09f418d1e0e06dfb48bac27d
> change-id: 20250408-topic-fastboot-blk-c5e14cd59224
> 
> Best regards,
Mattijs Korpershoek April 14, 2025, 9:21 a.m. UTC | #2
Hey Neil,

On lun., avril 14, 2025 at 11:13, Neil Armstrong <neil.armstrong@linaro.org> wrote:

> Hi Mattijs,
>
> On 09/04/2025 09:58, neil.armstrong@linaro.org wrote:
>> This serie permits using any block device as target
>> for fastboot by moving the generic block logic into
>> a common set of helpers and also use them as generic
>> backend.
>> 
>> The erase logic has been extended to support software
>> erase since only 2 block drivers exposes the erase
>> operation.
>> 
>> Tests are welcome to make sure this series doesn't
>> introduce any regressions on the emmc backend.
>
> Could you get an eye on this v2 ?

Yes, it's on my radar. I plan to test the emmc backend on Khadas VIM3. I
have not gotten to it yet, but will do this week.

Thank you for your patience.
Mattijs

>
> Thanks,
> Neil
>
>> 
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>> ---
>> Changes in v2:
>> - Dropped applied virtio erase patch
>> - Reorganize patches, introducing helpers first, using them in mmc afterwards
>> - Added soft-erase logic
>> - Added move helpers to handle the partitions erase & flash from emmc
>> - Fixed const var on last patch
>> - Link to v1: https://lore.kernel.org/all/20240306185921.1854109-1-dimorinny@google.com/
>> 
>> ---
>> Dmitrii Merkurev (3):
>>        fastboot: blk: introduce fastboot block flashing support
>>        fastboot: blk: switch emmc to use the block helpers
>>        fastboot: integrate block flashing back-end
>> 
>>   drivers/fastboot/Kconfig      |  20 ++-
>>   drivers/fastboot/Makefile     |   4 +-
>>   drivers/fastboot/fb_block.c   | 313 ++++++++++++++++++++++++++++++++++++++++++
>>   drivers/fastboot/fb_command.c |   8 ++
>>   drivers/fastboot/fb_common.c  |  16 ++-
>>   drivers/fastboot/fb_getvar.c  |   8 +-
>>   drivers/fastboot/fb_mmc.c     | 210 ++--------------------------
>>   include/fb_block.h            | 104 ++++++++++++++
>>   8 files changed, 477 insertions(+), 206 deletions(-)
>> ---
>> base-commit: f892a7f397a66d8d09f418d1e0e06dfb48bac27d
>> change-id: 20250408-topic-fastboot-blk-c5e14cd59224
>> 
>> Best regards,
Mattijs Korpershoek April 17, 2025, 2:58 p.m. UTC | #3
Hey Neil,

Thank you for the series.

On mer., avril 09, 2025 at 09:58, neil.armstrong@linaro.org wrote:

> This serie permits using any block device as target
> for fastboot by moving the generic block logic into
> a common set of helpers and also use them as generic
> backend.
>
> The erase logic has been extended to support software
> erase since only 2 block drivers exposes the erase
> operation.
>
> Tests are welcome to make sure this series doesn't
> introduce any regressions on the emmc backend.
>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>

On top of master (commit 5b4ae0f3f040 ("mailmap: update my name and email")),
Using khadas-vim3_android_defconfig, I did the following:

boot the newly generated U-Boot with boot-g12.py:
$ boot-g12.py ~/work/upstream/yukawa/bootloader/u-boot_kvim3_noab.bin

Run fastboot from U-Boot console:
=> fastboot usb 0
crq->brequest:0x0

Then, on the host, reflash the bootloader:
$ fastboot flash bootloader u-boot_kvim3_noab.bin

In U-Boot, everything seems fine:
** Bad device specification mmc bootloader_a **
** Bad device specification mmc bootloader_a **
Couldn't find partition mmc bootloader_a
Starting download of 1288048 bytes
.........
downloading of 1288048 bytes finished
Flashing Raw Image
........ wrote 1288192 bytes to 'bootloader'
resetting ...
bl31 reboot reason: 0xd
bl31 reboot reason: 0x0
system cmd  1.
G12B:BL:6e7c85:2a3b91;FEAT:E0F83180:402000;POC:D;RCY:0;USB:0;

And after rebooting the board, we are on the newly flashed bootloader.

So, to me:

Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

I do need some more time to review, though.
Thank you for your patience!

> ---
> Changes in v2:
> - Dropped applied virtio erase patch
> - Reorganize patches, introducing helpers first, using them in mmc afterwards
> - Added soft-erase logic
> - Added move helpers to handle the partitions erase & flash from emmc
> - Fixed const var on last patch
> - Link to v1: https://lore.kernel.org/all/20240306185921.1854109-1-dimorinny@google.com/
>
> ---
> Dmitrii Merkurev (3):
>       fastboot: blk: introduce fastboot block flashing support
>       fastboot: blk: switch emmc to use the block helpers
>       fastboot: integrate block flashing back-end
>
>  drivers/fastboot/Kconfig      |  20 ++-
>  drivers/fastboot/Makefile     |   4 +-
>  drivers/fastboot/fb_block.c   | 313 ++++++++++++++++++++++++++++++++++++++++++
>  drivers/fastboot/fb_command.c |   8 ++
>  drivers/fastboot/fb_common.c  |  16 ++-
>  drivers/fastboot/fb_getvar.c  |   8 +-
>  drivers/fastboot/fb_mmc.c     | 210 ++--------------------------
>  include/fb_block.h            | 104 ++++++++++++++
>  8 files changed, 477 insertions(+), 206 deletions(-)
> ---
> base-commit: f892a7f397a66d8d09f418d1e0e06dfb48bac27d
> change-id: 20250408-topic-fastboot-blk-c5e14cd59224
>
> Best regards,
> -- 
> Neil Armstrong <neil.armstrong@linaro.org>