part with role='mbr' should be stricter about its parameters

Bug #1630769 reported by Barry Warsaw
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Ubuntu Image
Fix Released
High
Barry Warsaw

Bug Description

During test writing I discovered that a partition with the special type 'mbr' and an offset of 6MiB causes the root partition to be written at an unexpected location. If this partition is the last of three f.e., then the root should be written at least 1MiB past that. Instead, the root partition is written 1MiB past the last non-mbr type partition.

In a way this makes sense since mbr is by definition the 446 bytes at the front of the disk before the partition table, so the disk image builder (make_disk() in builder.py) is not expecting these bogus parameters.

However, we do need to tighten up the documentation around type='mbr' and reject invalid parameters.

Barry Warsaw (barry)
tags: added: tech-debt
tags: removed: tech-debt
Barry Warsaw (barry)
Changed in ubuntu-image:
milestone: none → 0.11
assignee: nobody → Barry Warsaw (barry)
importance: Undecided → High
Barry Warsaw (barry)
Changed in ubuntu-image:
milestone: 0.11 → 0.12
Barry Warsaw (barry)
summary: - part with type='mbr' should be stricter about its parameters
+ part with role='mbr' should be stricter about its parameters
Revision history for this message
Barry Warsaw (barry) wrote :

Okay, we'll make this easy. After discussion with slangasek, we agree that a role:mbr at anything other than offset 0 doesn't make sense, so we'll just disallow that at the parsing/sanity checking phase.

If a user needs it to be different, they can pad the image written to the mbr structure. If someone else has a use case for an mbr structure at any other weird offset, file a future bug!

Changed in ubuntu-image:
status: New → In Progress
Barry Warsaw (barry)
Changed in ubuntu-image:
status: In Progress → Fix Committed
Barry Warsaw (barry)
Changed in ubuntu-image:
status: Fix Committed → Fix Released
Revision history for this message
Shuduo Sang (sangshuduo) wrote :

bubblegum96 board uses 8MB mbr to store uboot. Latest ubuntu-image now can't generate image for this platform. Please advice what workaround can be.

Revision history for this message
Shuduo Sang (sangshuduo) wrote :
Revision history for this message
Barry Warsaw (barry) wrote : Re: [Bug 1630769] Re: part with role='mbr' should be stricter about its parameters

On Jan 06, 2017, at 09:07 AM, Shuduo Sang wrote:

>bubblegum96 board uses 8MB mbr to store uboot. Latest ubuntu-image now
>can't generate image for this platform. Please advice what workaround
>can be.

Can you use a role:bare section with an offset of 0 and a size of 8MBR?

Revision history for this message
Steve Langasek (vorlon) wrote :

On Fri, Jan 06, 2017 at 08:17:07PM -0000, Barry Warsaw wrote:
> On Jan 06, 2017, at 09:07 AM, Shuduo Sang wrote:

> >bubblegum96 board uses 8MB mbr to store uboot. Latest ubuntu-image now
> >can't generate image for this platform. Please advice what workaround
> >can be.

> Can you use a role:bare section with an offset of 0 and a size of 8MBR?

In fact, the gadget.yaml shows that the content is being written at an
offset of 2MB within the mbr structure. So this isn't an 'MBR' at all and
should be described differently, either with role:bare or just with a
partition starting at the 2MiB mark.

Revision history for this message
hangjun (alephman) wrote :

hi,
The "role:bare" section may cause error, I use type: bare section instead. The generated image still doesn't work in my bubblegum96 board. BTW, what does the type: 0C mean, I have't been found out any document about it? Here is the gadget.yaml file I wrote:

device-tree: s900-96board.dtb
volumes:
  lemaker-guitar:
    schema: mbr
    bootloader: u-boot
    structure:
      - name: Bootstrap
 type: bare
        size: 6M
        content:
          - image: bootloader.bin
            offset: 2097664
          - image: u-boot.bin
            offset: 3145728
      - name: system-boot
        type: 0C
        filesystem: vfat
        filesystem-label: system-boot
        offset: 8388608
        size: 128M
        content:
          - source: boot-assets/
            target: /

Revision history for this message
Barry Warsaw (barry) wrote :

On Jan 09, 2017, at 01:41 PM, hangjun wrote:

>The "role:bare" section may cause error, I use type: bare section instead.

Yes, sorry that was a typo. `type: bare` is the right thing to use. See the
gadget.yaml spec here:

https://github.com/snapcore/snapd/wiki/Gadget-snap#gadget.yaml

>The generated image still doesn't work in my bubblegum96 board. BTW, what
>does the type: 0C mean, I have't been found out any document about it?

MBR partition types were defined rather ad-hoc so there's no definitive
specification. The wikipedia page has a pretty good list of the de-facto
values.

https://en.wikipedia.org/wiki/Partition_type

0c is FAT32 w/LBA.

Can you explain how your image fails?

Revision history for this message
Steve Langasek (vorlon) wrote :

On Mon, Jan 09, 2017 at 01:41:05PM -0000, hangjun wrote:
> hi,

> The "role:bare" section may cause error, I use type: bare section instead.
> The generated image still doesn't work in my bubblegum96 board. BTW, what
> does the type: 0C mean, I have't been found out any document about it?
> Here is the gadget.yaml file I wrote:

> device-tree: s900-96board.dtb
> volumes:
> lemaker-guitar:
> schema: mbr
> bootloader: u-boot
> structure:
> - name: Bootstrap
> type: bare
> size: 6M

You have not declared an offset for the structure element, only for the
content elements. You must tell ubuntu-image where on the disk this
structure element is supposed to start (i.e., at a 2M offset).

> content:
> - image: bootloader.bin
> offset: 2097664
> - image: u-boot.bin
> offset: 3145728

The offsets should then be relative to the start of the structure element.
So the offsets need to be 512 and 1048576.

Revision history for this message
hangjun (alephman) wrote :

Thanks for your quick reply.
I burn the generated image to SD card, then plugin into bubblegum. But I power up the board, no messages output from console, which means the u-boot or bootloader.bin may not be invoked. It works using ubuntu-image(old version 0.10) and https://github.com/uCRDev/Bubblegum96-Snappy/blob/master/gadget/gadget/meta/gadget.yaml.

Revision history for this message
hangjun (alephman) wrote :

@ Steve Langasek and Barry Warsaw (barry) , is there any workaround for the bubblegum96 gadget issue?

Revision history for this message
Steve Langasek (vorlon) wrote :

Do you have a new gadget.yaml for us to look at, that incorporates the feedback from my last message?

If you examine the raw disk image, do the files you expect to be there show up at the right absolute offsets?

Revision history for this message
hangjun (alephman) wrote :

hi Steve Langasek (vorlon),
Thanks for a lot for your help, following your guide, I added the offset item in gadget.yaml file, it works, thanks again.
The workable gadget.yaml is here : https://github.com/uCRDev/Bubblegum96-Snappy/blob/master/gadget/gadget/meta/gadget.yaml

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.