Pull request: u-boot-dfu (26.01.2020)
Dear Marek,
The following changes since commit40521a6c90d4adfb7f3041033c8cbbeff087a5ca:
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq
(2020-01-25 12:20:51 -0500)
are available in the Git repository at:
git at gitlab.denx.de:u-boot/custodians/u-boot-dfu.git
for you to fetch changes up to d34375267f521dc76b1875a905cec914a47b0712:
dfu: Add option to skip empty pages when flashing UBI images to NAND (2020-01-26 11:44:15 +0100)
----------------------------------------------------------------
Guillermo RodrÃguez (1):
dfu: Add option to skip empty pages when flashing UBI images to
NAND
drivers/dfu/Kconfig | 7 +++++++ drivers/dfu/dfu_nand.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
BRANCH: master
https://gitlab.denx.de/u-boot/custodians/u-boot-dfu/commits/master
Merge tag info:
- Add option to DFU NAND to skip empty pages when flashing UBI images
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/618507384
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200126/d29ebb80/attachment.sig>
On 1/26/20 9:26 PM, Lukasz Majewski wrote:
Hi,
[...]
Quoted 3 lines
----------------------------------------------------------------
Guillermo RodrÃguez (1):
dfu: Add option to skip empty pages when flashing UBI images to
Can that option be enabled/disabled at runtime instead of being hardcoded?
Hi Marek,
Quoted 5 lines · Lukasz Majewski
Hi,
[...]
Quoted 7 lines
Quoted 4 lines
----------------------------------------------------------------
Guillermo RodrÃguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toCan that option be enabled/disabled at runtime instead of being hardcoded?
It has been designed in a similar way to Android's existing FASTBOOT_FLASH_NAND_TRIMFFS option.
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/ee70c739/attachment.sig>
Hi Marek,
Quoted 13 lines · Lukasz Majewski
Hi Marek,
Quoted 10 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
to
Quoted 5 lines
Quoted 2 lines
Can that option be enabled/disabled at runtime instead of being hardcoded?
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.
Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.
In other words, enabling this option at buildtime has no countereffects. So there is no point in making it configurable at runtime, if support has been built into U-boot.
[1]: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_free_space_fixup
Best regards,
Guillermo Rodriguez Garcia
guille.rodriguez at gmail.com
Quoted 1 line · Guillermo Rodriguez Garcia
Hi Marek,
Hi,
Quoted 17 lines · Lukasz Majewski
Quoted 16 lines
Hi Marek,
Quoted 12 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toCan that option be enabled/disabled at runtime instead of being hardcoded?
Quoted 8 lines
Quoted 2 lines
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.
Does NAND.TRIMFFS preserve UBI erase counters in the NAND ? I don't think so, so I don't think "correctly flash UBI images" is the correct formulation here.
Quoted 5 lines
In other words, enabling this option at buildtime has no countereffects. So there is no point in making it configurable at runtime, if support has been built into U-boot.
[1]: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_free_space_fixup
So what if I want to write raw NAND image without "trimffs" on such a system via DFU, e.g. a bootloader ? How can I do that ?
Hi,
Quoted 43 lines · Marek Vasut
Quoted 1 line · Guillermo Rodriguez Garcia
Hi Marek,
Hi,
Quoted 1 line
El lun., 27 ene. 2020 a las 8:52, Lukasz Majewski (<[email protected]>)
Quoted 16 lines · escribió:
Quoted 16 lines
Hi Marek,
Quoted 12 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toCan that option be enabled/disabled at runtime instead of being hardcoded?
Quoted 8 lines
Quoted 2 lines
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.Does NAND.TRIMFFS preserve UBI erase counters in the NAND ? I don't think so, so I don't think "correctly flash UBI images" is the correct formulation here.
Yes, you are right.
Quoted 4 lines
In other words, enabling this option at buildtime has no countereffects. So there is no point in making it configurable at runtime, if support has been built into U-boot.
Quoted 6 lines
Quoted 1 line
L_free_space_fixupSo what if I want to write raw NAND image without "trimffs" on such a system via DFU, e.g. a bootloader ? How can I do that ?
You mean on a non-ubi partition? Then you don't need to do anything special. This code is only triggered for ubi partitions.
BR,
Guillermo
Quoted 1 line · Guillermo Rodriguez
Hi,
Hi,
Quoted 46 lines · Marek Vasut
Quoted 45 lines · Guillermo Rodriguez Garcia
Quoted 1 line
Hi Marek,
Hi,
Quoted 1 line
El lun., 27 ene. 2020 a las 8:52, Lukasz Majewski (<[email protected]>)
Quoted 16 lines · escribió:
Quoted 16 lines
Hi Marek,
Quoted 12 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toCan that option be enabled/disabled at runtime instead of being hardcoded?
Quoted 8 lines
Quoted 2 lines
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.Does NAND.TRIMFFS preserve UBI erase counters in the NAND ? I don't think so, so I don't think "correctly flash UBI images" is the correct formulation here.
Yes, you are right.
Quoted 5 lines
In other words, enabling this option at buildtime has no countereffects. So there is no point in making it configurable at runtime, if support has been built into U-boot.
Quoted 8 lines
Quoted 5 lines
L_free_space_fixupSo what if I want to write raw NAND image without "trimffs" on such a system via DFU, e.g. a bootloader ? How can I do that ?
You mean on a non-ubi partition? Then you don't need to do anything special. This code is only triggered for ubi partitions.
And what about partitions which were already built with the --space-fixup ?
Quoted 54 lines · Marek Vasut
Quoted 1 line · Guillermo Rodriguez
Hi,
Hi,
Quoted 34 lines · Marek Vasut
Quoted 33 lines · Guillermo Rodriguez Garcia
Quoted 1 line
Hi Marek,
Hi,
Quoted 1 line
El lun., 27 ene. 2020 a las 8:52, Lukasz Majewski (<[email protected]>)
Quoted 24 lines · escribió:
Quoted 13 lines
Hi Marek,
Quoted 10 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toQuoted 5 lines
Quoted 2 lines
Can that option be enabled/disabled at runtime instead of being hardcoded?
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.Quoted 8 lines
Quoted 8 lines
Does NAND.TRIMFFS preserve UBI erase counters in the NAND ? I don't think so, so I don't think "correctly flash UBI images" is the correct formulation here.
Yes, you are right.
Quoted 1 line
In other words, enabling this option at buildtime has no
countereffects.
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
So there is no point in making it configurable at runtime, if support has been built into U-boot.
L_free_space_fixup
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
So what if I want to write raw NAND image without "trimffs" on such a system via DFU, e.g. a bootloader ? How can I do that ?
You mean on a non-ubi partition? Then you don't need to do anything special. This code is only triggered for ubi partitions.
And what about partitions which were already built with the --space-fixup ?
What do you mean with "partitions built with --space-fixup"? If you mean ubi *images* built with --space-fixup, these will still work fine. Otherwise, could you please clarify?
Guillermo
Quoted 63 lines · Guillermo Rodriguez
Quoted 61 lines · Marek Vasut
Quoted 1 line · Guillermo Rodriguez
Hi,
Hi,
Quoted 34 lines · Marek Vasut
Quoted 33 lines · Guillermo Rodriguez Garcia
Quoted 1 line
Hi Marek,
Hi,
Quoted 1 line
El lun., 27 ene. 2020 a las 8:52, Lukasz Majewski (<[email protected]>)
Quoted 24 lines · escribió:
Quoted 13 lines
Hi Marek,
Quoted 10 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toQuoted 5 lines
Quoted 2 lines
Can that option be enabled/disabled at runtime instead of being hardcoded?
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.Quoted 8 lines
Quoted 8 lines
Does NAND.TRIMFFS preserve UBI erase counters in the NAND ? I don't think so, so I don't think "correctly flash UBI images" is the correct formulation here.
Yes, you are right.
Quoted 1 line
In other words, enabling this option at buildtime has no
countereffects.
Quoted 12 lines
Quoted 9 lines
Quoted 4 lines
So there is no point in making it configurable at runtime, if support has been built into U-boot.
L_free_space_fixupSo what if I want to write raw NAND image without "trimffs" on such a system via DFU, e.g. a bootloader ? How can I do that ?
You mean on a non-ubi partition? Then you don't need to do anything special. This code is only triggered for ubi partitions.
Quoted 6 lines
Quoted 2 lines
And what about partitions which were already built with the --space-fixup ?
What do you mean with "partitions built with --space-fixup"? If you mean ubi *images* built with --space-fixup, these will still work fine. Otherwise, could you please clarify?
I'm just curious whether we're changing behavior here, which might pose a problem. I am also not super fond of hard-coding things this way, but maybe this is fine in this case ?
Quoted 68 lines · Marek Vasut
Quoted 66 lines · Guillermo Rodriguez
Quoted 63 lines · Marek Vasut
Quoted 1 line · Guillermo Rodriguez
Hi,
Hi,
Quoted 34 lines · Marek Vasut
Quoted 33 lines · Guillermo Rodriguez Garcia
Quoted 1 line
Hi Marek,
Hi,
Quoted 1 line
El lun., 27 ene. 2020 a las 8:52, Lukasz Majewski (<[email protected]>)
Quoted 24 lines · escribió:
Quoted 13 lines
Hi Marek,
Quoted 10 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toQuoted 5 lines
Quoted 2 lines
Can that option be enabled/disabled at runtime instead of being hardcoded?
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.Quoted 8 lines
Quoted 8 lines
Does NAND.TRIMFFS preserve UBI erase counters in the NAND ? I don't think so, so I don't think "correctly flash UBI images" is the correct formulation here.
Yes, you are right.
Quoted 1 line
In other words, enabling this option at buildtime has no
countereffects.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
So there is no point in making it configurable at runtime, if support has been built into U-boot.
Quoted 8 lines
Quoted 5 lines
L_free_space_fixupSo what if I want to write raw NAND image without "trimffs" on such a system via DFU, e.g. a bootloader ? How can I do that ?
You mean on a non-ubi partition? Then you don't need to do anything special. This code is only triggered for ubi partitions.
And what about partitions which were already built with the --space-fixup ?
Quoted 7 lines
Quoted 3 lines
What do you mean with "partitions built with --space-fixup"? If you mean ubi *images* built with --space-fixup, these will still work fine. Otherwise, could you please clarify?
I'm just curious whether we're changing behavior here, which might pose a problem. I am also not super fond of hard-coding things this way, but maybe this is fine in this case ?
OK, let me try to summarize what we're doing here.
The recommended way to flash UBI images is using ubiformat [1]. When this is not possible, then the UBI FAQ describes how UBI images should be flashed to NAND [2]. Basically you need to make sure that any trailing all-0xFF pages in each eraseblock are dropped (i.e. not written to flash). This is what "nand write.trimffs" does (see description in [3])
If you cannot do that, then an alternative is to make sure that the UBI image is built with --space-fixup [4]; this sets a flag so that the Linux kernel will "fix" the NAND on first mount. This is somewhat expensive, though, as the kernel may need to rewrite several PEBs.
In the current u-boot, dfu does not follow the procedure stated in the UBI FAQ. This forces you to make sure UBI images are always built with --space-fixup.
With this patch, when dfu writes to a UBI partition it will use the procedure outlined in the UBI FAQ. So --space-fixup is no longer required.
Two important things to note here:
- This only makes a difference for UBI partitions (see check in dfu_nand [5]). Behaviour for non-UBI partitions does not change.
- Images built with --space-fixup will continue to work just fine (the kernel will do just its stuff the first time the file system is mounted. This is unnecessary, but also harmless).
So, to summarize:
1. Without the patch dfu only works if --space-fixup was used when
the UBI image was generated; with the patch it will work for images with and without --space-fixup
2. Nothing changes for non-UBI partitions
[1]: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_why_ubiformat
[2]: http://www.linux-mtd.infradead.org/doc/ubi.html#L_flasher_algo
[3]: https://gitlab.com/u-boot/u-boot/blob/master/doc/README.nand#L65
[4]: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_free_space_fixup
[5]: https://gitlab.com/u-boot/u-boot/blob/master/drivers/dfu/dfu_nand.c#L231
Let me know if you have any other questions.
Thanks,
Guillermo
Quoted 110 lines · Guillermo Rodriguez
Quoted 68 lines · Marek Vasut
Quoted 66 lines · Guillermo Rodriguez
Quoted 63 lines · Marek Vasut
Quoted 1 line · Guillermo Rodriguez
Hi,
Hi,
Quoted 34 lines · Marek Vasut
Quoted 33 lines · Guillermo Rodriguez Garcia
Quoted 1 line
Hi Marek,
Hi,
Quoted 1 line
El lun., 27 ene. 2020 a las 8:52, Lukasz Majewski (<[email protected]>)
Quoted 24 lines · escribió:
Quoted 13 lines
Hi Marek,
Quoted 10 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toQuoted 5 lines
Quoted 2 lines
Can that option be enabled/disabled at runtime instead of being hardcoded?
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.Quoted 8 lines
Quoted 8 lines
Does NAND.TRIMFFS preserve UBI erase counters in the NAND ? I don't think so, so I don't think "correctly flash UBI images" is the correct formulation here.
Yes, you are right.
Quoted 1 line
In other words, enabling this option at buildtime has no
countereffects.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
So there is no point in making it configurable at runtime, if support has been built into U-boot.
Quoted 8 lines
Quoted 5 lines
L_free_space_fixupSo what if I want to write raw NAND image without "trimffs" on such a system via DFU, e.g. a bootloader ? How can I do that ?
You mean on a non-ubi partition? Then you don't need to do anything special. This code is only triggered for ubi partitions.
And what about partitions which were already built with the --space-fixup ?
Quoted 7 lines
Quoted 3 lines
What do you mean with "partitions built with --space-fixup"? If you mean ubi *images* built with --space-fixup, these will still work fine. Otherwise, could you please clarify?
I'm just curious whether we're changing behavior here, which might pose a problem. I am also not super fond of hard-coding things this way, but maybe this is fine in this case ?
OK, let me try to summarize what we're doing here.
The recommended way to flash UBI images is using ubiformat [1]. When this is not possible, then the UBI FAQ describes how UBI images should be flashed to NAND [2]. Basically you need to make sure that any trailing all-0xFF pages in each eraseblock are dropped (i.e. not written to flash). This is what "nand write.trimffs" does (see description in [3])
If you cannot do that, then an alternative is to make sure that the UBI image is built with --space-fixup [4]; this sets a flag so that the Linux kernel will "fix" the NAND on first mount. This is somewhat expensive, though, as the kernel may need to rewrite several PEBs.In the current u-boot, dfu does not follow the procedure stated in the UBI FAQ. This forces you to make sure UBI images are always built with --space-fixup.
With this patch, when dfu writes to a UBI partition it will use the procedure outlined in the UBI FAQ. So --space-fixup is no longer required.Two important things to note here:
- This only makes a difference for UBI partitions (see check indfu_nand[5]). Behaviour for non-UBI partitions does not change.
- Images built with --space-fixup will continue to work just fine (the kernel will do just its stuff the first time the file system is mounted. This is unnecessary, but also harmless).So, to summarize:
1. Without the patch dfu only works if --space-fixup was used when
the UBI image was generated; with the patch it will work for images with and without --space-fixup
2. Nothing changes for non-UBI partitions
Quoted 7 lines
[1]: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_why_ubiformat
[2]: http://www.linux-mtd.infradead.org/doc/ubi.html#L_flasher_algo
[3]: https://gitlab.com/u-boot/u-boot/blob/master/doc/README.nand#L65
[4]: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_free_space_fixup
[5]: https://gitlab.com/u-boot/u-boot/blob/master/drivers/dfu/dfu_nand.c#L231Let me know if you have any other questions.
As I've just been reading along, thanks for the detailed summary of the issues!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/5ad9edc9/attachment.sig>
Marek Vasut
AppliedQuoted 110 lines · Guillermo Rodriguez
Quoted 68 lines · Marek Vasut
Quoted 66 lines · Guillermo Rodriguez
Quoted 63 lines · Marek Vasut
Quoted 1 line · Guillermo Rodriguez
Hi,
Hi,
Quoted 34 lines · Marek Vasut
Quoted 33 lines · Guillermo Rodriguez Garcia
Quoted 1 line
Hi Marek,
Hi,
Quoted 1 line
El lun., 27 ene. 2020 a las 8:52, Lukasz Majewski (<[email protected]>)
Quoted 24 lines · escribió:
Quoted 13 lines
Hi Marek,
Quoted 10 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo Rodríguez (1):
dfu: Add option to skip empty pages when flashing UBI images
toQuoted 5 lines
Quoted 2 lines
Can that option be enabled/disabled at runtime instead of being hardcoded?
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.Without this option, UBI images need to be built with --space-fixup
[1] so that the kernel can "fix" the NAND on first mount. When this option is used, --space-fixup is no longer necessary because dfu knows how to correctly flash UBI images. However, UBI images built with --space-fixup will still work fine.Quoted 8 lines
Quoted 8 lines
Does NAND.TRIMFFS preserve UBI erase counters in the NAND ? I don't think so, so I don't think "correctly flash UBI images" is the correct formulation here.
Yes, you are right.
Quoted 1 line
In other words, enabling this option at buildtime has no
countereffects.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
So there is no point in making it configurable at runtime, if support has been built into U-boot.
Quoted 8 lines
Quoted 5 lines
L_free_space_fixupSo what if I want to write raw NAND image without "trimffs" on such a system via DFU, e.g. a bootloader ? How can I do that ?
You mean on a non-ubi partition? Then you don't need to do anything special. This code is only triggered for ubi partitions.
And what about partitions which were already built with the --space-fixup ?
Quoted 7 lines
Quoted 3 lines
What do you mean with "partitions built with --space-fixup"? If you mean ubi *images* built with --space-fixup, these will still work fine. Otherwise, could you please clarify?
I'm just curious whether we're changing behavior here, which might pose a problem. I am also not super fond of hard-coding things this way, but maybe this is fine in this case ?
OK, let me try to summarize what we're doing here.
The recommended way to flash UBI images is using ubiformat [1]. When this is not possible, then the UBI FAQ describes how UBI images should be flashed to NAND [2]. Basically you need to make sure that any trailing all-0xFF pages in each eraseblock are dropped (i.e. not written to flash). This is what "nand write.trimffs" does (see description in [3])
If you cannot do that, then an alternative is to make sure that the UBI image is built with --space-fixup [4]; this sets a flag so that the Linux kernel will "fix" the NAND on first mount. This is somewhat expensive, though, as the kernel may need to rewrite several PEBs.In the current u-boot, dfu does not follow the procedure stated in the UBI FAQ. This forces you to make sure UBI images are always built with --space-fixup.
With this patch, when dfu writes to a UBI partition it will use the procedure outlined in the UBI FAQ. So --space-fixup is no longer required.Two important things to note here:
- This only makes a difference for UBI partitions (see check indfu_nand[5]). Behaviour for non-UBI partitions does not change.
- Images built with --space-fixup will continue to work just fine (the kernel will do just its stuff the first time the file system is mounted. This is unnecessary, but also harmless).So, to summarize:
1. Without the patch dfu only works if --space-fixup was used when
the UBI image was generated; with the patch it will work for images with and without --space-fixup
2. Nothing changes for non-UBI partitions
Quoted 7 lines
[1]: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_why_ubiformat
[2]: http://www.linux-mtd.infradead.org/doc/ubi.html#L_flasher_algo
[3]: https://gitlab.com/u-boot/u-boot/blob/master/doc/README.nand#L65
[4]: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_free_space_fixup
[5]: https://gitlab.com/u-boot/u-boot/blob/master/drivers/dfu/dfu_nand.c#L231Let me know if you have any other questions.
I think it's OK. I just wanted to be sure we're not breaking anything there. Thanks!
Applied.
Quoted 1 line · Lukasz Majewski
Hi Marek,
Hi,
Quoted 10 lines
Quoted 10 lines · Lukasz Majewski
Hi,
[...]
Quoted 4 lines
----------------------------------------------------------------
Guillermo RodrÃguez (1):
dfu: Add option to skip empty pages when flashing UBI images
to
Quoted 5 lines
Quoted 2 lines
Can that option be enabled/disabled at runtime instead of being hardcoded?
It has been designed in a similar way to Android's existing
FASTBOOT_FLASH_NAND_TRIMFFSoption.
Which doesn't really answer my question, it only shows that another piece of code suffers from the same problem.