Skip to contentSkip to conversation

fastboot: Add board_fastboot_flash/erase/get_part_info hooks

PATCH Mattijs Korpershoek 3 participants 8 messages Nov 18 – Nov 23 5 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAPVz0n3HUqT+TqyRrkyc83r-sDXMcMEXpqPPYxhinvp1rs8pDQ@mail.gmail.com

#5 lore raw

Hi Svyatoslav,

Sorry for the delay in replying,

Quoted 20 lines · Svyatoslav Ryhel

пн, 19 жовт. 2026 р. о 11:33 Mattijs Korpershoek <[email protected]> пише:

Quoted 19 lines · Mattijs Korpershoek
Quoted 13 lines

Hi Svyatoslav,

Thank you for the patch.

Quoted 6 lines · Svyatoslav Ryhel

From: Ion Agorria <[email protected]>

This allows boards to intercept fastboot flash/erase and modify/change behavior according to board specifics like AES encryption or RSA signing. Add board_fastboot_get_part_info to provide info as fastboot tool queries during flash/erase.

I've given this some more thought over the weekend. We already have an 'oem board' command in fastboot.

Quoted 8 lines
Quoted 5 lines

See:
https://docs.u-boot-project.org/en/latest/android/fastboot.html#overview

Have we considered using the 'oem board' command instead of adding another board specific command?

You are mixing up. This patch does not add any vendor commands. It allows using native commands with vendor quirks seamlessly.

I know it's not exactly the same thing. I'm just worried these extra hooks will make stuff less maintainable in the long run.

Quoted 7 lines

For example. Tegra devices require bootloader and bct to be encrypted and bct to be updated every time bootloader is flashed.

$ fastboot stage bootloader.img
$ fastboot oem board:write_bootloader
Quoted 8 lines

Used has to stage bootloader, then write is with some custom vendor bootloader flashing command which we have to make, document etc etc.

This series allows intercept native fastboot commands of flashing some partitions and apply vendor specific adjustments directly. So I can flash bootloader, boot and system with native command fastboot flash but bootloader flashing will be performed with encryption and does not require from user any additional movements.

I understand, that it might be easier from a user experience point of view (just fastboot flash <whatever partition>)

But adding extra vendor hooks also means having a specification of what vendors should do in these hooks: adding docstrings, adding documentation in the fastboot.rst page and such.

I'm not NACKING this series, I just wish to discuss in more detail why 'oem board' is a wrong idea.

For example, do you have a closed-source userspace that forces you to use 'fastboot flash' on tegra devices?

Quoted 141 lines

board_fastboot_get_part_info allows filtering partitions to flash sent by fastboot flash command and board_fastboot_flash implements vendor hook to flash this partition.

And this is not restricted to bootloader partition only.

Quoted 134 lines

The documentation also gives an example on custom flashing, see:
https://docs.u-boot-project.org/en/latest/android/fastboot.html#running-custom-vendor-code

Quoted 130 lines
Quoted 3 lines

This patch does not apply on main
commit fed92546960a ("Gitlab CI: sage: Update for labgrid 26.0 behavior")

I'll try to review it anyways, but please consider resubmitting it after rebasing.

drivers/fastboot/fb_command.c line 19

Quoted 13 lines
---
 drivers/fastboot/fb_command.c | 20 ++++++++++++++++++++
 drivers/fastboot/fb_getvar.c  | 12 ++++++++++++
 2 files changed, 32 insertions(+)
drivers/fastboot/fb_command.c +0 -0
index 18d86988f4c..284d771fe31 100644
@@ -17,6 +17,17 @@
 #include <vsprintf.h>
 #include <linux/printk.h>
 

Please document the function. Especially the return code so that board-specific implementations know what to do.

drivers/fastboot/fb_command.c line 23

Quoted 4 lines
drivers/fastboot/fb_command.c +4 -0
+__weak int board_fastboot_flash(char *cmd_parameter, void *download_buffer,
+                            u32 download_bytes, char *response)
+{
+    return 0;

Why 0?

Can we please use a more meaningful error code here? -ENOTSUPP for example.

drivers/fastboot/fb_command.c line 28

Quoted 5 lines
drivers/fastboot/fb_command.c +5 -0
+}
+
+__weak int board_fastboot_erase(char *cmd_parameter, char *response)
+{
+    return 0;

Same.

Quoted 33 lines
drivers/fastboot/fb_command.c +11 -0
+}
+
 /**
  * image_size - final fastboot image size
  */
@@ -339,6 +350,11 @@ void fastboot_data_complete(char *response)
  */
 static void __maybe_unused flash(char *cmd_parameter, char *response)
 {
+    if (IS_ENABLED(CONFIG_FASTBOOT_FLASH) &&
+        board_fastboot_flash(cmd_parameter, fastboot_buf_addr,
+                             image_size, response))
+            return;
+
     if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_BLOCK))
             fastboot_block_flash_write(cmd_parameter, fastboot_buf_addr,
                                        image_size, response);
@@ -367,6 +383,10 @@ static void __maybe_unused flash(char *cmd_parameter, char *response)
  */
 static void __maybe_unused erase(char *cmd_parameter, char *response)
 {
+    if (IS_ENABLED(CONFIG_FASTBOOT_FLASH) &&
+        board_fastboot_erase(cmd_parameter, response))
+            return;
+
     if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_BLOCK))
             fastboot_block_erase(cmd_parameter, response);
 
drivers/fastboot/fb_getvar.c +0 -0
index e8aa0e09aa6..af65fca548f 100644

drivers/fastboot/fb_getvar.c static void getvar_partition_type(char *part_name, char *response); · line 35

Quoted 7 lines
drivers/fastboot/fb_getvar.c +4 -0
@@ -29,6 +29,12 @@ static void getvar_partition_type(char *part_name, char *response);
 static void getvar_partition_size(char *part_name, char *response);
 static void getvar_is_userspace(char *var_parameter, char *response);
 
+__weak int board_fastboot_get_part_info(const char *part_name, char *response,
+                                    size_t *size)
+{
+    return 1;

Why 1?

What happens if a board_fastboot_get_part_info() returns 1 here?

Also if we look at the documentation of part_get_info_by_name():
"""
* part_get_info_by_name() - Search for a partition by name
* among all available registered partitions
*

 * @desc:     block device descriptor
 * @name:     the specified table entry name
 * @info:     returns the disk partition info

*
* Return: the partition number on match (starting on 1), -1 on no match,
* otherwise error
*/
int part_get_info_by_name(struct blk_desc *desc, const char *name,

                        struct disk_partition *info);

"""

So 1 can be confusing.

Can't we return something like -ENOTSUPP instead?
That makes it more clear that this is a stub operation that can be re-implemented by each board.

Quoted 20 lines
drivers/fastboot/fb_getvar.c +8 -1
+}
+
 static const struct {
     const char *variable;
     bool list;
@@ -116,6 +122,12 @@ static int getvar_get_part_info(const char *part_name, char *response,
     struct disk_partition disk_part;
     struct part_info *part_info;
 
+    if (IS_ENABLED(CONFIG_FASTBOOT_FLASH)) {
+            r = board_fastboot_get_part_info(part_name, response, size);
+            if (r != 1)
+                    return r;
+    }
+
     if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_BLOCK)) {
             r = fastboot_block_get_part_info(part_name, &dev_desc, &disk_part,
                                              response);
--

2.53.0

#6 lore raw
Quoted 29 lines
Quoted 2 lines

You are mixing up. This patch does not add any vendor commands. It allows using native commands with vendor quirks seamlessly.

I know it's not exactly the same thing. I'm just worried these extra hooks will make stuff less maintainable in the long run.

Quoted 7 lines

For example. Tegra devices require bootloader and bct to be encrypted and bct to be updated every time bootloader is flashed.

$ fastboot stage bootloader.img
$ fastboot oem board:write_bootloader
Quoted 8 lines

Used has to stage bootloader, then write is with some custom vendor bootloader flashing command which we have to make, document etc etc.

This series allows intercept native fastboot commands of flashing some partitions and apply vendor specific adjustments directly. So I can flash bootloader, boot and system with native command fastboot flash but bootloader flashing will be performed with encryption and does not require from user any additional movements.

I understand, that it might be easier from a user experience point of view (just fastboot flash <whatever partition>)

But adding extra vendor hooks also means having a specification of what vendors should do in these hooks: adding docstrings, adding documentation in the fastboot.rst page and such.

Quoted 6 lines

I'm not NACKING this series, I just wish to discuss in more detail why 'oem board' is a wrong idea.

For example, do you have a closed-source userspace that forces you to use 'fastboot flash' on tegra devices?

On production tegra20 and tegra30 devices bootloader must be encrypted with aes engine before flashing, and bct must be decrypted, updated and re-encrypted before flashing. We decided to use hardware boot partitions to store bct and bootloader, so we do not have traditional boot partition. Hence we are using fastboot flash to intercept "bootloader" or "ebt" and "bct" commands to flash partition and use our own implementations for them (for emmc and spi). All other partitions can be flashed by default and need no special handling.

#7 lore raw

ср, 18 лист. 2026 р. о 12:44 Svyatoslav Ryhel <[email protected]> пише:

Quoted 37 lines
Quoted 30 lines
Quoted 3 lines

You are mixing up. This patch does not add any vendor commands. It allows using native commands with vendor quirks seamlessly.

I know it's not exactly the same thing. I'm just worried these extra hooks will make stuff less maintainable in the long run.

Quoted 7 lines

For example. Tegra devices require bootloader and bct to be encrypted and bct to be updated every time bootloader is flashed.

$ fastboot stage bootloader.img
$ fastboot oem board:write_bootloader
Quoted 8 lines

Used has to stage bootloader, then write is with some custom vendor bootloader flashing command which we have to make, document etc etc.

This series allows intercept native fastboot commands of flashing some partitions and apply vendor specific adjustments directly. So I can flash bootloader, boot and system with native command fastboot flash but bootloader flashing will be performed with encryption and does not require from user any additional movements.

I understand, that it might be easier from a user experience point of view (just fastboot flash <whatever partition>)

But adding extra vendor hooks also means having a specification of what vendors should do in these hooks: adding docstrings, adding documentation in the fastboot.rst page and such.

Quoted 6 lines

I'm not NACKING this series, I just wish to discuss in more detail why 'oem board' is a wrong idea.

For example, do you have a closed-source userspace that forces you to use 'fastboot flash' on tegra devices?

Quoted 5 lines

On production tegra20 and tegra30 devices bootloader must be encrypted with aes engine before flashing, and bct must be decrypted, updated and re-encrypted before flashing. We decided to use hardware boot partitions to store bct and bootloader, so we do not have traditional boot partition. Hence we are using fastboot flash to intercept

boot > bootloader (typo)

Quoted 3 lines

"bootloader" or "ebt" and "bct" commands to flash partition and use our own implementations for them (for emmc and spi). All other partitions can be flashed by default and need no special handling.

#8 lore raw

Hi,

Le 18/11/2026 à 11:45, Svyatoslav Ryhel a écrit :

Quoted 33 lines

ср, 18 лист. 2026 р. о 12:44 Svyatoslav Ryhel <[email protected]> пише:

Quoted 32 lines
Quoted 32 lines
Quoted 2 lines

You are mixing up. This patch does not add any vendor commands. It allows using native commands with vendor quirks seamlessly.

I know it's not exactly the same thing. I'm just worried these extra hooks will make stuff less maintainable in the long run.

Quoted 6 lines

For example. Tegra devices require bootloader and bct to be encrypted and bct to be updated every time bootloader is flashed.

$ fastboot stage bootloader.img
$ fastboot oem board:write_bootloader
Quoted 8 lines

Used has to stage bootloader, then write is with some custom vendor bootloader flashing command which we have to make, document etc etc.

This series allows intercept native fastboot commands of flashing some partitions and apply vendor specific adjustments directly. So I can flash bootloader, boot and system with native command fastboot flash but bootloader flashing will be performed with encryption and does not require from user any additional movements.

I understand, that it might be easier from a user experience point of view (just fastboot flash <whatever partition>)

But adding extra vendor hooks also means having a specification of what vendors should do in these hooks: adding docstrings, adding documentation in the fastboot.rst page and such.

I'm not NACKING this series, I just wish to discuss in more detail why 'oem board' is a wrong idea.

For example, do you have a closed-source userspace that forces you to use 'fastboot flash' on tegra devices?

Quoted 10 lines
Quoted 5 lines

On production tegra20 and tegra30 devices bootloader must be encrypted with aes engine before flashing, and bct must be decrypted, updated and re-encrypted before flashing. We decided to use hardware boot partitions to store bct and bootloader, so we do not have traditional boot partition. Hence we are using fastboot flash to intercept

boot > bootloader (typo)

Quoted 3 lines

"bootloader" or "ebt" and "bct" commands to flash partition and use our own implementations for them (for emmc and spi). All other partitions can be flashed by default and need no special handling.

  I'm rather ok with the patch and with intercepting the native flash command through hooks, it's already done this way elsewhere in fastboot (fb_nand.c, fb_spi_flash.c).

  Some small comments for v2:

  - board_fastboot_flash() returns 0 when not handled and board_fastboot_get_part_info() returns 1, it would be nice to have the same value for both .

  - When you rebase: flash() now starts with flashing_refuse_if_locked(), please call the board hook after it, otherwise a locked device can still be flashed.

  - A small update of the fastboot doc would be nice too.

Regards
Guillaume

#9 lore raw

Hi Svyatoslav,

Quoted 46 lines · Guillaume La Roque

Hi,

Le 18/11/2026 à 11:45, Svyatoslav Ryhel a écrit :

Quoted 43 lines

ср, 18 лист. 2026 р. о 12:44 Svyatoslav Ryhel <[email protected]> пише:

Quoted 29 lines
Quoted 29 lines
Quoted 2 lines

You are mixing up. This patch does not add any vendor commands. It allows using native commands with vendor quirks seamlessly.

I know it's not exactly the same thing. I'm just worried these extra hooks will make stuff less maintainable in the long run.

Quoted 6 lines

For example. Tegra devices require bootloader and bct to be encrypted and bct to be updated every time bootloader is flashed.

$ fastboot stage bootloader.img
$ fastboot oem board:write_bootloader
Quoted 8 lines

Used has to stage bootloader, then write is with some custom vendor bootloader flashing command which we have to make, document etc etc.

This series allows intercept native fastboot commands of flashing some partitions and apply vendor specific adjustments directly. So I can flash bootloader, boot and system with native command fastboot flash but bootloader flashing will be performed with encryption and does not require from user any additional movements.

I understand, that it might be easier from a user experience point of view (just fastboot flash <whatever partition>)

But adding extra vendor hooks also means having a specification of what vendors should do in these hooks: adding docstrings, adding documentation in the fastboot.rst page and such.

I'm not NACKING this series, I just wish to discuss in more detail why 'oem board' is a wrong idea.

Quoted 8 lines
Quoted 3 lines

For example, do you have a closed-source userspace that forces you to use 'fastboot flash' on tegra devices?

On production tegra20 and tegra30 devices bootloader must be encrypted with aes engine before flashing, and bct must be decrypted, updated and re-encrypted before flashing. We decided to use hardware boot partitions to store bct and bootloader, so we do not have traditional boot partition. Hence we are using fastboot flash to intercept

boot > bootloader (typo)

Quoted 3 lines

"bootloader" or "ebt" and "bct" commands to flash partition and use our own implementations for them (for emmc and spi). All other partitions can be flashed by default and need no special handling.

Ok, let's go ahead with this. It is indeed a more elegant solution on the user side (just using fastboot flash <partition> and let U-Boot handle complex cases (like bootloader/ebt/bct).

Quoted 4 lines

  I'm rather ok with the patch and with intercepting the native flash command through hooks, it's already done this way elsewhere in fastboot (fb_nand.c, fb_spi_flash.c).

Please also look at how it's done in fb_nand and fb_spi_flash to see if we can have similar return codes (if that makes sense)

Quoted 7 lines

  Some small comments for v2:

  - board_fastboot_flash() returns 0 when not handled and board_fastboot_get_part_info() returns 1, it would be nice to have the same value for both .

Quoted 5 lines

  - When you rebase: flash() now starts with flashing_refuse_if_locked(), please call the board hook after it, otherwise a locked device can still be flashed.

  - A small update of the fastboot doc would be nice too.

Please address Guillaume's feedback (as well as mine I posted previously) for v2.

Thanks for your patience

Regards
Mattijs

Quoted 4 lines

Regards
Guillaume

#10 lore raw

пн, 23 лист. 2026 р. о 15:56 Mattijs Korpershoek <[email protected]> пише:

Quoted 48 lines

Hi Svyatoslav,

Quoted 43 lines · Guillaume La Roque

Hi,

Quoted 40 lines · Svyatoslav Ryhel

ср, 18 лист. 2026 р. о 12:44 Svyatoslav Ryhel <[email protected]> пише:

Quoted 29 lines
Quoted 29 lines
Quoted 2 lines

You are mixing up. This patch does not add any vendor commands. It allows using native commands with vendor quirks seamlessly.

I know it's not exactly the same thing. I'm just worried these extra hooks will make stuff less maintainable in the long run.

Quoted 6 lines

For example. Tegra devices require bootloader and bct to be encrypted and bct to be updated every time bootloader is flashed.

$ fastboot stage bootloader.img
$ fastboot oem board:write_bootloader
Quoted 8 lines

Used has to stage bootloader, then write is with some custom vendor bootloader flashing command which we have to make, document etc etc.

This series allows intercept native fastboot commands of flashing some partitions and apply vendor specific adjustments directly. So I can flash bootloader, boot and system with native command fastboot flash but bootloader flashing will be performed with encryption and does not require from user any additional movements.

I understand, that it might be easier from a user experience point of view (just fastboot flash <whatever partition>)

But adding extra vendor hooks also means having a specification of what vendors should do in these hooks: adding docstrings, adding documentation in the fastboot.rst page and such.

I'm not NACKING this series, I just wish to discuss in more detail why 'oem board' is a wrong idea.

Quoted 8 lines
Quoted 3 lines

For example, do you have a closed-source userspace that forces you to use 'fastboot flash' on tegra devices?

On production tegra20 and tegra30 devices bootloader must be encrypted with aes engine before flashing, and bct must be decrypted, updated and re-encrypted before flashing. We decided to use hardware boot partitions to store bct and bootloader, so we do not have traditional boot partition. Hence we are using fastboot flash to intercept

boot > bootloader (typo)

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

"bootloader" or "ebt" and "bct" commands to flash partition and use our own implementations for them (for emmc and spi). All other partitions can be flashed by default and need no special handling.

Ok, let's go ahead with this. It is indeed a more elegant solution on the user side (just using fastboot flash <partition> and let U-Boot handle complex cases (like bootloader/ebt/bct).

Perfect.

Quoted 8 lines
Quoted 4 lines

I'm rather ok with the patch and with intercepting the native flash command through hooks, it's already done this way elsewhere in fastboot (fb_nand.c, fb_spi_flash.c).

Please also look at how it's done in fb_nand and fb_spi_flash to see if we can have similar return codes (if that makes sense)

They return 0 while you asked for -ENOTSUPP

Quoted 25 lines
Quoted 7 lines

Some small comments for v2:

- board_fastboot_flash() returns 0 when not handled and board_fastboot_get_part_info() returns 1, it would be nice to have the same value for both .

Quoted 5 lines

- When you rebase: flash() now starts with flashing_refuse_if_locked(), please call the board hook after it, otherwise a locked device can still be flashed.

- A small update of the fastboot doc would be nice too.

Please address Guillaume's feedback (as well as mine I posted previously) for v2.

Thanks for your patience

Regards
Mattijs

Quoted 4 lines

Regards
Guillaume

#11 lore raw

пн, 23 лист. 2026 р. о 16:05 Svyatoslav Ryhel <[email protected]> пише:

Quoted 66 lines

пн, 23 лист. 2026 р. о 15:56 Mattijs Korpershoek <[email protected]> пише:

Quoted 48 lines

Hi Svyatoslav,

Quoted 43 lines · Guillaume La Roque

Hi,

Quoted 40 lines · Svyatoslav Ryhel

ср, 18 лист. 2026 р. о 12:44 Svyatoslav Ryhel <[email protected]> пише:

Quoted 29 lines
Quoted 29 lines
Quoted 2 lines

You are mixing up. This patch does not add any vendor commands. It allows using native commands with vendor quirks seamlessly.

I know it's not exactly the same thing. I'm just worried these extra hooks will make stuff less maintainable in the long run.

Quoted 6 lines

For example. Tegra devices require bootloader and bct to be encrypted and bct to be updated every time bootloader is flashed.

$ fastboot stage bootloader.img
$ fastboot oem board:write_bootloader
Quoted 8 lines

Used has to stage bootloader, then write is with some custom vendor bootloader flashing command which we have to make, document etc etc.

This series allows intercept native fastboot commands of flashing some partitions and apply vendor specific adjustments directly. So I can flash bootloader, boot and system with native command fastboot flash but bootloader flashing will be performed with encryption and does not require from user any additional movements.

I understand, that it might be easier from a user experience point of view (just fastboot flash <whatever partition>)

But adding extra vendor hooks also means having a specification of what vendors should do in these hooks: adding docstrings, adding documentation in the fastboot.rst page and such.

I'm not NACKING this series, I just wish to discuss in more detail why 'oem board' is a wrong idea.

Quoted 8 lines
Quoted 3 lines

For example, do you have a closed-source userspace that forces you to use 'fastboot flash' on tegra devices?

On production tegra20 and tegra30 devices bootloader must be encrypted with aes engine before flashing, and bct must be decrypted, updated and re-encrypted before flashing. We decided to use hardware boot partitions to store bct and bootloader, so we do not have traditional boot partition. Hence we are using fastboot flash to intercept

boot > bootloader (typo)

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

"bootloader" or "ebt" and "bct" commands to flash partition and use our own implementations for them (for emmc and spi). All other partitions can be flashed by default and need no special handling.

Ok, let's go ahead with this. It is indeed a more elegant solution on the user side (just using fastboot flash <partition> and let U-Boot handle complex cases (like bootloader/ebt/bct).

Perfect.

Quoted 5 lines
Quoted 4 lines

I'm rather ok with the patch and with intercepting the native flash command through hooks, it's already done this way elsewhere in fastboot (fb_nand.c, fb_spi_flash.c).

Quoted 29 lines
Quoted 3 lines

Please also look at how it's done in fb_nand and fb_spi_flash to see if we can have similar return codes (if that makes sense)

They return 0 while you asked for -ENOTSUPP

Quoted 23 lines
Quoted 7 lines

Some small comments for v2:

- board_fastboot_flash() returns 0 when not handled and board_fastboot_get_part_info() returns 1, it would be nice to have the same value for both .

Quoted 5 lines

- When you rebase: flash() now starts with flashing_refuse_if_locked(), please call the board hook after it, otherwise a locked device can still be flashed.

- A small update of the fastboot doc would be nice too.

Please address Guillaume's feedback (as well as mine I posted previously) for v2.

Thanks for your patience

Regards
Mattijs

Quoted 2 lines

Regards
Guillaume

Oh, btw, Mattijs, Guillaume, you can check preliminary v2 in here [1] if you like. It is not final yet though.

[1] https://git.u-boot-project.org/u-boot/custodians/u-boot-tegra/-/commits/staging?ref_type=heads

#12 lore raw
In reply to Guillaume La Roque

пн, 23 лист. 2026 р. о 15:37 Guillaume La Roque <[email protected]> пише:

Quoted 52 lines

Hi,

Quoted 33 lines · Svyatoslav Ryhel

ср, 18 лист. 2026 р. о 12:44 Svyatoslav Ryhel <[email protected]> пише:

Quoted 32 lines
Quoted 32 lines
Quoted 2 lines

You are mixing up. This patch does not add any vendor commands. It allows using native commands with vendor quirks seamlessly.

I know it's not exactly the same thing. I'm just worried these extra hooks will make stuff less maintainable in the long run.

Quoted 6 lines

For example. Tegra devices require bootloader and bct to be encrypted and bct to be updated every time bootloader is flashed.

$ fastboot stage bootloader.img
$ fastboot oem board:write_bootloader
Quoted 8 lines

Used has to stage bootloader, then write is with some custom vendor bootloader flashing command which we have to make, document etc etc.

This series allows intercept native fastboot commands of flashing some partitions and apply vendor specific adjustments directly. So I can flash bootloader, boot and system with native command fastboot flash but bootloader flashing will be performed with encryption and does not require from user any additional movements.

I understand, that it might be easier from a user experience point of view (just fastboot flash <whatever partition>)

But adding extra vendor hooks also means having a specification of what vendors should do in these hooks: adding docstrings, adding documentation in the fastboot.rst page and such.

I'm not NACKING this series, I just wish to discuss in more detail why 'oem board' is a wrong idea.

For example, do you have a closed-source userspace that forces you to use 'fastboot flash' on tegra devices?

Quoted 10 lines
Quoted 5 lines

On production tegra20 and tegra30 devices bootloader must be encrypted with aes engine before flashing, and bct must be decrypted, updated and re-encrypted before flashing. We decided to use hardware boot partitions to store bct and bootloader, so we do not have traditional boot partition. Hence we are using fastboot flash to intercept

boot > bootloader (typo)

Quoted 3 lines

"bootloader" or "ebt" and "bct" commands to flash partition and use our own implementations for them (for emmc and spi). All other partitions can be flashed by default and need no special handling.

I'm rather ok with the patch and with intercepting the native flash command through hooks, it's already done this way elsewhere in fastboot (fb_nand.c, fb_spi_flash.c).

Quoted 6 lines

Some small comments for v2:

- board_fastboot_flash() returns 0 when not handled and board_fastboot_get_part_info() returns 1, it would be nice to have the same value for both .

I have defaulted to -ENOTSUPP if hook is not implemented as Mattijs asked.

Quoted 4 lines

- When you rebase: flash() now starts with flashing_refuse_if_locked(), please call the board hook after it, otherwise a locked device can still be flashed.

Yes, I have already rebased. I noticed this change and adjusted this patchset properly.

Quoted 2 lines

- A small update of the fastboot doc would be nice too.

Yes, agreed.

Quoted 4 lines

Regards
Guillaume