UBI: ignore/overwrite old data/PEBs after flashing

Rafał Miłecki zajec5 at gmail.com
Mon Oct 20 11:40:17 PDT 2014


On 20 October 2014 15:47, Artem Bityutskiy <dedekind1 at gmail.com> wrote:
> On Thu, 2014-10-16 at 15:51 +0200, Rafał Miłecki wrote:
>> Unfortunately this won't work if we flash the same firmware twice (it
>> will contain the same sequence). Imagine someone flashing a stable
>> OpenWrt release, then breaking something and flashing the same image
>> again. It'll contain the same sequence number and my magic driver
>> won't clean the old data :(
>
> Yes, flashing with ubiformat would be fine, because it changes the
> sequence number on-the-fly. With industial flashers, you'd need to erase
> the flash.
>
> Now you say you do not have the erase operation. You idea of a
> "IMAGE_ENDS_HERE" bit seems to be nice, and you could implement it, but
> you should think about the fastmap case too. Probably you need to do
> nothing, because fastmap will only refer the PEBs within the image, and
> the PEBs outside of the image will be scheduled for erasure. But you
> should verify this.

So far I've implemented it for OpenWrt needs with a hacky patch you
can see there:
http://git.openwrt.org/?p=openwrt.git;a=commitdiff;h=21741f060cab636c04d61ae696cd933adfea6e16
(it expects a PEB with 0xdeadc0de in place of UBI's magic).

I'll try to work on a clean solution when a find a bit of time. I
still need to learn about fastmap.

-- 
Rafał



More information about the linux-mtd mailing list