Message ID | 20180417153459.32395-1-arnout@mind.be |
---|---|
State | Accepted |
Headers | show |
Series | UBI handler: support static volumes | expand |
Hi Arnout, On 17/04/2018 17:34, Arnout Vandecappelle (Essensium/Mind) wrote: > UBI volumes can be static or dynamic. Static volumes have a CRC > checksum that is checked when the UBI partition is attached. This gives > additional protection against e.g. accidental overwrites of the MTD > partition. > > To support creation of static volumes in SWUpdate, use the handler's > "data" string to indicate whether the volume should be static or > dynamic. If "data" is the literal string "static", a static volume is > created. If it is anything else, a dynamic volume is created. > > Note that if the existing volume already has the correct size, nothing > is done. This is normally the right thing to do (the assumption is that > if a static volume is desired, the original image already contains it > as a static volume). > > Also update the documentation to reflect this. > Thanks ! > Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> > --- > doc/source/handlers.rst | 3 +++ > handlers/ubivol_handler.c | 5 ++++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst > index 5bc3dd3..5e3b260 100644 > --- a/doc/source/handlers.rst > +++ b/doc/source/handlers.rst > @@ -118,6 +118,9 @@ preserved and not lost after an update. The way for updating > is identical to the "ubiupdatevol" from the mtd-utils. In fact, > the same library from mtd-utils (libubi) is reused by SWUpdate. > > +SWUpdate normally creates dynamic volumes. If a static volume is > +desired, set the handler's data field to "static". > + > If the storage is empty, it is required to setup the layout > and create the volumes. This can be easy done with a > preinstall script. Building with meta-SWUpdate, the original > diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c > index 8ba5958..0c6fcbf 100644 > --- a/handlers/ubivol_handler.c > +++ b/handlers/ubivol_handler.c > @@ -215,7 +215,10 @@ static int adjust_volume(struct img_type *cfg, > * Volumes are empty, and they are filled later by the update procedure > */ > memset(&req, 0, sizeof(req)); > - req.vol_type = UBI_DYNAMIC_VOLUME; > + if (!strcmp(cfg->type_data, "static")) > + req.vol_type = UBI_STATIC_VOLUME; > + else > + req.vol_type = UBI_DYNAMIC_VOLUME; > req.vol_id = UBI_VOL_NUM_AUTO; > req.alignment = 1; > req.bytes = cfg->partsize; > Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst index 5bc3dd3..5e3b260 100644 --- a/doc/source/handlers.rst +++ b/doc/source/handlers.rst @@ -118,6 +118,9 @@ preserved and not lost after an update. The way for updating is identical to the "ubiupdatevol" from the mtd-utils. In fact, the same library from mtd-utils (libubi) is reused by SWUpdate. +SWUpdate normally creates dynamic volumes. If a static volume is +desired, set the handler's data field to "static". + If the storage is empty, it is required to setup the layout and create the volumes. This can be easy done with a preinstall script. Building with meta-SWUpdate, the original diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c index 8ba5958..0c6fcbf 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -215,7 +215,10 @@ static int adjust_volume(struct img_type *cfg, * Volumes are empty, and they are filled later by the update procedure */ memset(&req, 0, sizeof(req)); - req.vol_type = UBI_DYNAMIC_VOLUME; + if (!strcmp(cfg->type_data, "static")) + req.vol_type = UBI_STATIC_VOLUME; + else + req.vol_type = UBI_DYNAMIC_VOLUME; req.vol_id = UBI_VOL_NUM_AUTO; req.alignment = 1; req.bytes = cfg->partsize;
UBI volumes can be static or dynamic. Static volumes have a CRC checksum that is checked when the UBI partition is attached. This gives additional protection against e.g. accidental overwrites of the MTD partition. To support creation of static volumes in SWUpdate, use the handler's "data" string to indicate whether the volume should be static or dynamic. If "data" is the literal string "static", a static volume is created. If it is anything else, a dynamic volume is created. Note that if the existing volume already has the correct size, nothing is done. This is normally the right thing to do (the assumption is that if a static volume is desired, the original image already contains it as a static volume). Also update the documentation to reflect this. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> --- doc/source/handlers.rst | 3 +++ handlers/ubivol_handler.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-)