20 Aug, 2018

1 commit

  • Move the A/B slot check to SPL, the A/B slot switch
    workflow is just like what we have in libavb_ab.

    Test: A/B select works fine on imx8m.

    Change-Id: Ie3d827a9be0298b491bf2bc8d48833597fd70e90
    Signed-off-by: Luo Ji

    Luo Ji
     

13 Jun, 2018

1 commit


09 Feb, 2018

1 commit

  • config_fallbacks.h has some logic that sets HAVE_BLOCK_DEVICE
    based on a list of enabled options. Moving HAVE_BLOCK_DEVICE to
    Kconfig allows us to drastically shrink the logic in
    config_fallbacks.h

    Signed-off-by: Adam Ford
    [trini: Rename HAVE_BLOCK_DEVICE to CONFIG_BLOCK_DEVICE]
    Signed-off-by: Tom Rini

    Adam Ford
     

30 Nov, 2017

1 commit


06 Nov, 2017

1 commit

  • Before this patch one could receive following errors when executing
    "gpt write" command on machine with cache enabled:

    display5 factory > gpt write mmc ${mmcdev} ${partitions}
    Writing GPT:
    CACHE: Misaligned operation at range [4ef8f7f0, 4ef8f9f0]
    CACHE: Misaligned operation at range [4ef8f9f8, 4ef939f8]
    CACHE: Misaligned operation at range [4ef8f9f8, 4ef939f8]
    CACHE: Misaligned operation at range [4ef8f7f0, 4ef8f9f0]
    success!

    To alleviate this problem - the calloc()s have been replaced with
    malloc_cache_aligned() and memset().

    After those changes the buffers are properly aligned (with both start
    address and size) to SoC cache line.

    Signed-off-by: Lukasz Majewski

    Lukasz Majewski
     

24 Oct, 2017

1 commit

  • the partition starting at 0x4400 is refused with overlap error:
    $> gpt write mmc 0 "name=test,start=0x4400,size=0"
    Writing GPT: Partition overlap
    error!

    even if the 0x4400 is the first available offset for LBA35 with default
    value:
    - MBR=LBA1
    - GPT header=LBA2
    - PTE= 32 LBAs (128 entry), 3 to 34

    And the command to have one partition for all the disk failed also :
    $> gpt write mmc 0 "name=test,size=0"

    After the patch :

    $> gpt write mmc 0 "name=test,size=0"
    Writing GPT: success!
    $> part list mmc 0

    Partition Map for MMC device 0 -- Partition Type: EFI

    Part Start LBA End LBA Name
    Attributes
    Type GUID
    Partition GUID
    1 0x00000022 0x01ce9fde "test"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    type: data
    guid: b4b84b8a-04e3-4000-0036-aff5c9c495b1

    And 0x22 = 34 LBA => offset = 0x4400 is accepted as expected

    Reviewed-by: Łukasz Majewski
    Tested-by: Stephen Warren
    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     

16 Oct, 2017

1 commit


04 Oct, 2017

1 commit

  • U-Boot widely uses error() as a bit noisier variant of printf().

    This macro causes name conflict with the following line in
    include/linux/compiler-gcc.h:

    # define __compiletime_error(message) __attribute__((error(message)))

    This prevents us from using __compiletime_error(), and makes it
    difficult to fully sync BUILD_BUG macros with Linux. (Notice
    Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().)

    Let's convert error() into now treewide-available pr_err().

    Done with the help of Coccinelle, excluing tools/ directory.

    The semantic patch I used is as follows:

    //
    @@@@
    -error
    +pr_err
    (...)
    //

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Simon Glass
    [trini: Re-run Coccinelle]
    Signed-off-by: Tom Rini

    Masahiro Yamada
     

20 Sep, 2017

1 commit

  • EFI client programs need the signature information from the partition
    table to determine the disk a partition is on, so we need to fill that
    in here.

    Signed-off-by: Peter Jones
    [separated from efi_loader part, and fixed build-errors for non-
    CONFIG_EFI_PARTITION case]
    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Peter Jones
     

03 Sep, 2017

4 commits

  • The current code checks that no partitions overlap with the GPT partition
    table using the offset of the first LBA usable for that partition.

    This works fine, unless you have a partition entry that is further away
    than it usually is and you want to create partitions in the gap between the
    GPT header and the GPT partition entries, for example to reflash a
    bootloader that needs to be set there.

    Rework the test to something a bit smarter that checks whether a partition
    would overlap with either the GPT header or the partition entries, no
    matter where it is on the disk.

    Partitions that do not have a start LBA specified will still start at the
    first LBA usable set in the GPT header, to avoid weird behaviours.

    Signed-off-by: Maxime Ripard
    Reviewed-by: Tom Rini

    Maxime Ripard
     
  • The gpt_fill_pte will need to access the device block size. Let's pass the
    device descriptor as an argument.

    Signed-off-by: Maxime Ripard
    Reviewed-by: Tom Rini

    Maxime Ripard
     
  • The start variable is only used inside a loop, and is never affected inside
    it, so it's a purely local variable.

    In the same way the partition size is accessed several times, so we can
    store it in a variable.

    Signed-off-by: Maxime Ripard
    Reviewed-by: Tom Rini

    Maxime Ripard
     
  • Both the config option and the DT options specify the offset to set the GPT
    at in bytes, yet the code treats those values as block numbers.

    Fix that.

    Signed-off-by: Maxime Ripard
    Reviewed-by: Tom Rini
    Reviewed-by: Philipp Tomsich

    Maxime Ripard
     

04 Aug, 2017

2 commits


21 Mar, 2017

1 commit

  • Some architectures require their SPL loader at a fixed address within
    the first 16KB of the disk. To avoid an overlap with the partition
    entries of the EFI partition table, the first safe offset (in bytes,
    from the start of the device) for the entries can be set through
    CONFIG_EFI_PARTITION_ENTRIES_OFF (via Kconfig)

    When formatting a device with an EFI partition table, we may need to
    leave a gap between the GPT header (always in LBA 1) and the partition
    entries. The GPT header already contains a field to specify the
    on-disk location, which has so far always been set to LBA 2. With this
    change, a configurable offset will be translated into a LBA address
    indicating where to put the entries.

    Now also allows an override via device-tree using a config-node (see
    doc/device-tree-bindings/config.txt for documentation).

    Tested (exporting an internal MMC formatted with this) against Linux,
    MacOS X and Windows.

    Signed-off-by: Philipp Tomsich
    Reviewed-by: Simon Glass
    [trini: __maybe_unused on config_offset to avoid warning]
    Signed-off-by: Tom Rini

    Philipp Tomsich
     

18 Mar, 2017

1 commit


09 Feb, 2017

1 commit

  • On some cases the first 440 bytes of MBR are used to keep an additional
    information for ROM boot loader. 'gpt write' command doesn't preserve
    that area and makes boot code gone.

    Preserve boot code area when run 'gpt write' command.

    Signed-off-by: Vincent Tinelli
    Signed-off-by: Brennan Ashton
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Simon Glass

    Vincent Tinelli
     

28 Jan, 2017

2 commits


02 Oct, 2016

1 commit

  • So far partition search by name has been supported only on the EFI partition
    table. This patch extends the search to all partition tables.

    Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from
    part_efi.c into part.c and make it a generic function which traverses all part
    drivers and searches all partitions (in the order given by the linked list).

    For this a new variable struct part_driver.max_entries is added, which limits
    the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS.
    Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.

    Signed-off-by: Petr Kulhavy
    Reviewed-by: Tom Rini
    Acked-by: Steve Rae

    Petr Kulhavy
     

06 Aug, 2016

1 commit

  • The calculation of "dev_desc->lba - 34 - 1 - offset" is not correct for
    size '-', because both fist_usable_lba and last_usable_lba will remain
    34 sectors.

    We can simply use 0 for size '-' because the part_efi module will decode
    the size and auto extend the size to maximum available size.

    Signed-off-by: Kever Yang

    Kever Yang
     

26 Jul, 2016

1 commit


27 May, 2016

1 commit

  • the last value acceptable value for offset is last_usable_lba + 1
    and not last_usable_lba - 1

    issue found with SDCARD partition commands on u-boot 2015.10
    but this part of code don't change

    1- create GPT partion on all the card
    > gpt write mmc 0 name=test,start=0,size=0
    > part list mmc 0

    Partition Map for MMC device 0 -- Partition Type: EFI

    Part Start LBA End LBA Name
    Attributes
    Type GUID
    Partition GUID
    1 0x00000022 0x003a9fde "test"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    type: data
    guid: b710eb04-45b9-e94a-8d0b-21458d596f54

    => Start = 0x22*512 = 0x4400
    => Size = (0x003a9fde-0x22+1) * 512 = 0x753F7A00

    2- try to recreate the same partition with the next command
    (block size:512 bytes = 0x200)

    > gpt write mmc 0 name=test,start=0x4400,size=0x753F7A00
    Writing GPT: Partitions layout exceds disk size

    > gpt write mmc 0 name=test,start=0x4400,size=0x753F7800
    Writing GPT: Partitions layout exceds disk size

    > gpt write mmc 0 name=test,start=0x4400,size=0x753F7600
    Writing GPT: success!

    Partition Map for MMC device 0 -- Partition Type: EFI

    Part Start LBA End LBA Name
    Attributes
    Type GUID
    Partition GUID
    1 0x00000022 0x003a9fdc "test"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    type: data
    guid: 36ec30ef-7ca4-cd48-97cd-ea9fb95185d0

    the max LBA when the size is indicated (0x003a9fdc) is lower than
    when u-boot compute the max allowed value with size=0 (0x003a9fde)

    in the code :

    /* partition ending lba */
    if ((i == parts - 1) && (partitions[i].size == 0))
    /* extend the last partition to maximuim */
    gpt_e[i].ending_lba = gpt_h->last_usable_lba;
    else
    gpt_e[i].ending_lba = cpu_to_le64(offset - 1);

    so offset = gpt_h->last_usable_lba + 1 is acceptable !
    but the test (offset >= last_usable_lba) cause the error

    END

    Signed-off-by: Patrick Delaunay disk: part_efi: fix check of the max partition size
    the last value acceptable value for offset is (last_usable_lba + 1)
    and not (last_usable_lba - 1)

    issue found with SDCARD partition commands on u-boot 2015.10
    but this part of code don't change

    1- I create GPT partion on all the card (start and size undefined)

    > gpt write mmc 0 name=test,start=0,size=0
    > part list mmc 0

    Partition Map for MMC device 0 -- Partition Type: EFI

    Part Start LBA End LBA Name
    Attributes
    Type GUID
    Partition GUID
    1 0x00000022 0x003a9fde "test"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    type: data
    guid: b710eb04-45b9-e94a-8d0b-21458d596f54

    => Start = 0x22*512 = 0x4400
    => Size = (0x003a9fde-0x22+1) * 512 = 0x753F7A00

    2- I try to recreate the same partition with the command gpt write
    and with start and size values (block size:512 bytes = 0x200)

    > gpt write mmc 0 name=test,start=0x4400,size=0x753F7A00
    Writing GPT: Partitions layout exceds disk size

    > gpt write mmc 0 name=test,start=0x4400,size=0x753F7800
    Writing GPT: Partitions layout exceds disk size

    > gpt write mmc 0 name=test,start=0x4400,size=0x753F7600
    Writing GPT: success!

    I check the partition created :

    > part list mmc 0

    Partition Map for MMC device 0 -- Partition Type: EFI

    Part Start LBA End LBA Name
    Attributes
    Type GUID
    Partition GUID
    1 0x00000022 0x003a9fdc "test"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    type: data
    guid: 36ec30ef-7ca4-cd48-97cd-ea9fb95185d0

    => but the max LBA when the size is indicated (0x003a9fdc) is lower than
    when u-boot compute the max allowed value with size=0 (0x003a9fde)

    3- in the code, just after my patch, line 446

    /* partition ending lba */
    if ((i == parts - 1) && (partitions[i].size == 0))
    /* extend the last partition to maximuim */
    gpt_e[i].ending_lba = gpt_h->last_usable_lba;
    else
    gpt_e[i].ending_lba = cpu_to_le64(offset - 1);

    so offset = gpt_h->last_usable_lba + 1 is acceptable !
    (it the value used when size is 0)

    but today the test (offset >= last_usable_lba) cause the error
    my patch only solve this issue

    END

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     

23 Mar, 2016

2 commits


15 Mar, 2016

7 commits

  • Rename these functions so that part_ is at the start. This more clearly
    identifies these functions as partition functions.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • To ease conversion to driver model, add helper functions which deal with
    calling each block device method. With driver model we can reimplement these
    functions with the same arguments.

    Use inline functions to avoid increasing code size on some boards.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Stephen Warren

    Simon Glass
     
  • This is a device number, and we want to use 'dev' to mean a driver model
    device. Rename the member.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Stephen Warren

    Simon Glass
     
  • Rename three partition functions so that they start with part_. This makes
    it clear what they relate to.

    Signed-off-by: Simon Glass
    Tested-by: Stephen Warren

    Simon Glass
     
  • We can use linker lists instead of explicitly declaring each function.
    This makes the code shorter by avoiding switch() statements and lots of
    header file declarations.

    While this does clean up the code it introduces a few code issues with SPL.
    SPL never needs to print partition information since this all happens from
    commands. SPL mostly doesn't need to obtain information about a partition
    either, except in a few cases. Add these cases so that the code will be
    dropped from each partition driver when not needed. This avoids code bloat.

    I think this is still a win, since it is not a bad thing to be explicit
    about which features are used in SPL. But others may like to weigh in.

    Signed-off-by: Simon Glass
    Reviewed-by: Tom Rini
    Tested-by: Stephen Warren

    Simon Glass
     
  • Adjust the cast to avoid a warning when stdint.h is used.

    Signed-off-by: Simon Glass
    Tested-by: Stephen Warren

    Simon Glass
     
  • Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
    and causes 80-column violations, rename it to struct blk_desc.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Stephen Warren

    Simon Glass
     

15 Jan, 2016

1 commit


14 Jan, 2016

1 commit

  • This will allow the implementation to make use of data in the block_dev
    structure beyond the base device number. This will be useful so that eMMC
    block devices can encompass the HW partition ID rather than treating this
    out-of-band. Equally, the existence of the priv field is crying out for
    this patch to exist.

    Signed-off-by: Stephen Warren
    Reviewed-by: Tom Rini

    Stephen Warren
     

24 Nov, 2015

2 commits

  • The optional parameter bootable is added in gpt command to set the
    partition attribute flag "Legacy BIOS bootable"

    This flag is used in extlinux and so in with distro to select
    the boot partition where is located the configuration file
    (please check out doc/README.distro for details).

    With this parameter, U-Boot can be used to create the boot partition
    needed for device using distro.

    example of use:

    setenv partitions "name=u-boot,size=60MiB;name=boot,size=60Mib,bootable;\
    name=rootfs,size=0"

    > gpt write mmc 0 $partitions

    > part list mmc 0

    Partition Map for MMC device 0 -- Partition Type: EFI

    Part Start LBA End LBA Name
    Attributes
    Type GUID
    Partition GUID
    1 0x00000022 0x0001e021 "u-boot"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    guid: cceb0b18-39cb-d547-9db7-03b405fa77d4
    2 0x0001e022 0x0003c021 "boot"
    attrs: 0x0000000000000004
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    guid: d4981a2b-0478-544e-9607-7fd3c651068d
    3 0x0003c022 0x003a9fde "rootfs"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    guid: 6d6c9a36-e919-264d-a9ee-bd00379686c7

    > part list mmc 0 -bootable devplist

    > printenv devplist

    devplist=2

    Then the distro scripts will search extlinux in partition 2
    and not in the first partition.

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     
  • This commit provides definition and declaration of GPT verification
    functions - namely gpt_verify_headers() and gpt_verify_partitions().
    The former is used to only check CRC32 of GPT's header and PTEs.
    The latter examines each partition entry and compare attributes such as:
    name, start offset and size with ones provided at '$partitions' env
    variable.

    Signed-off-by: Lukasz Majewski
    Reviewed-by: Tom Rini
    Reviewed-by: Przemyslaw Marczak

    Lukasz Majewski
     

13 Nov, 2015

2 commits

  • short strings can be used in type parameter of gpt command
    to replace the guid string for the types known by u-boot

    partitions = name=boot,size=0x6bc00,type=data; \
    name=root,size=0x7538ba00,type=linux;
    gpt write mmc 0 $partitions

    and they are also used to display the type of partition
    in "part list" command

    Partition Map for MMC device 0 -- Partition Type: EFI

    Part Start LBA End LBA Name
    Attributes
    Type GUID
    Partition GUID
    1 0x00000022 0x0000037f "boot"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    type: data
    guid: d117f98e-6f2c-d04b-a5b2-331a19f91cb2
    2 0x00000380 0x003a9fdc "root"
    attrs: 0x0000000000000000
    type: 0fc63daf-8483-4772-8e79-3d69d8477de4
    type: linux
    guid: 25718777-d0ad-7443-9e60-02cb591c9737

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     
  • code under flag CONFIG_PARTITION_TYPE_GUID
    add parameter "type" to select partition type guid

    example of use with gpt command :

    partitions = uuid_disk=${uuid_gpt_disk}; \
    name=boot,size=0x6bc00,uuid=${uuid_gpt_boot}; \
    name=root,size=0x7538ba00,uuid=${uuid_gpt_root}, \
    type=0fc63daf-8483-4772-8e79-3d69d8477de4;

    gpt write mmc 0 $partitions

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     

12 Sep, 2015

1 commit