06 Oct, 2017

1 commit


05 Oct, 2017

1 commit

  • Since commit ff98cb90514d ("part: extract MBR signature from partitions")
    SPL boot on i.MX6 starts to fail:

    U-Boot SPL 2017.09-00221-g0d6ab32 (Oct 02 2017 - 15:13:19)
    Trying to boot from MMC1
    (keep in loop)

    Use the original allocation scheme for the SPL case, so that MX6 boards
    can boot again.

    This is a temporary solution to avoid the boot regression.

    Signed-off-by: Fabio Estevam
    Acked-by: Rob Clark
    Tested-by: Peter Robinson

    Fabio Estevam
     

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
     

19 Sep, 2017

1 commit

  • The UEFI spec allows an EFI system partition (ESP, with the bootloader or
    kernel EFI apps on it) to reside on a disk using a "legacy" MBR
    partitioning scheme.
    But in contrast to actual legacy disks the ESP is not marked as
    "bootable" using bit 7 in byte 0 of the legacy partition entry, but is
    instead using partition *type* 0xef (in contrast to 0x0b or 0x0c for a
    normal FAT partition). The EFI spec isn't 100% clear on this, but it even
    seems to discourage the use of the bootable flag for ESPs.
    Also it seems that some EFI implementations (EDK2?) even seem to ignore
    partitions marked as bootable (probably since they believe they contain
    legacy boot code).
    The Debian installer [1] (*not* mini.iso), for instance, contains such an
    MBR, where none of the two partitions are marked bootable, but the ESP
    has clearly type 0xef.
    Now U-Boot cannot find the ESP on such a disk (USB flash drive) and
    fails to load the EFI grub and thus the installer.

    Since it all boils down to the distro bootcmds eventually calling
    "part list -bootable" to find potential boot partitions, it seems logical
    to just add this "partition type is 0xef" condition to the is_bootable()
    implementation.

    This allows the bog standard arm64 Debian-testing installer to boot from
    an USB pen drive on Allwinner A64 boards (Pine64, BananaPi-M64).
    (Ubuntu and other distribution installers don't have a legacy MBR, so
    U-Boot falls back to El Torito there).

    [1] https://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/arm64/iso-cd/
    Signed-off-by: Andre Przywara
    Reviewed-by: Alexander Graf
    Signed-off-by: Alexander Graf

    Andre Przywara
     

15 Sep, 2017

1 commit

  • Needed to support efi file protocol. The fallback.efi loader wants
    to be able to read the contents of the /EFI directory to find an OS
    to boot.

    Modelled after POSIX opendir()/readdir()/closedir(). Unlike the other
    fs APIs, this is stateful (ie. state is held in the FS_DIR "directory
    stream"), to avoid re-traversing of the directory structure at each
    step. The directory stream must be released with closedir() when it
    is no longer needed.

    Signed-off-by: Rob Clark
    Reviewed-by: Łukasz Majewski
    Reviewed-by: Simon Glass

    Rob Clark
     

07 Sep, 2017

1 commit


04 Sep, 2017

1 commit


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
     

27 Aug, 2017

1 commit


16 Aug, 2017

1 commit

  • We are now using an env_ prefix for environment functions. Rename these
    two functions for consistency. Also add function comments in common.h.

    Quite a few places use getenv() in a condition context, provoking a
    warning from checkpatch. These are fixed up in this patch also.

    Suggested-by: Wolfgang Denk
    Signed-off-by: Simon Glass

    Simon Glass
     

14 Aug, 2017

1 commit


04 Aug, 2017

3 commits


12 May, 2017

1 commit


06 Apr, 2017

1 commit


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


18 Feb, 2017

1 commit

  • the socfpga bootrom supports mmc booting from either a raw image
    starting at 0x0, or from a partition of type 0xa2. This patch
    adds support for locating the boot image in the first type 0xa2
    partition found.

    Assigned a partition number of -1 will cause a search for a
    partition of type CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE
    and use it to find the u-boot image

    Signed-off-by: Dalon Westergreen

    Dalon Westergreen
     

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

8 commits


28 Dec, 2016

1 commit

  • With capacities getting bigger, we can see see messages with negative
    numbers like "Capacity: 1907729.0 MB = 1863.0 GB (-387938128 x 512)".
    Here the printed LBA is -387938128 when it should have been 3907029168.
    To fix this, use the right format when displaying the unsigned integers.

    Signed-off-by: Jean-Jacques Hiblot
    Reported-by: Yan Liu

    Jean-Jacques Hiblot
     

02 Oct, 2016

3 commits

  • In both DOS and ISO partition tables the same code to create partition name
    like "hda1" was repeated.

    Code moved to into a new function part_set_generic_name() in part.c and optimized.
    Added recognition of MMC and SD types, name is like "mmcsda1".

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

    Petr Kulhavy
     
  • Add special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME)
    to write MBR partition table.
    Partitions are now searched using the generic function which finds any
    partiiton by name. For MBR the partition names hda1, sda1, etc. are used.

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

    Petr Kulhavy
     
  • 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


23 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