25 Jul, 2019

3 commits

  • These have been reported by Simon in [1] and fixed in [2].
    However, since [1] has already been pushed to u-boot/master, the
    improvements incorporated in [2] are now extracted and resubmitted.

    The changes are in the area of coding style and best practices:
    * s/field/fieldp/, s/size/sizep/, to convey that the variables return
    an output to the caller
    * s/err_1/err_read_fail/, s/err_2/err_too_small/, to be more descriptive
    * Made sure 'static int do_bcb_load' appears on the same line
    * Placed a `/*` on top of multi-line comment

    [1] https://patchwork.ozlabs.org/patch/1104244/#2200259
    [2] https://patchwork.ozlabs.org/cover/1128661/
    ("[v4,0/4] Add 'bcb' command to read/modify/write Android BCB")

    Fixes: db7b7a05b267 ("cmd: Add 'bcb' command to read/modify/write BCB fields")
    Reported-by: Simon Glass
    Signed-off-by: Eugeniu Rosca
    Reviewed-by: Sam Protsenko

    Eugeniu Rosca
     
  • Quote from https://patchwork.ozlabs.org/patch/1104244/#2210814:

    ----------8
    Signed-off-by: Eugeniu Rosca
    Reviewed-by: Sam Protsenko
    Reviewed-by: Igor Opaniuk

    Eugeniu Rosca
     
  • Fix warning V1037 reported by PVS-Studio Static Analyzer:
    Two or more case-branches perform the same actions. Check lines: 49, 53

    Fixes: db7b7a05b267 ("cmd: Add 'bcb' command to read/modify/write BCB fields")
    Signed-off-by: Eugeniu Rosca
    Reviewed-by: Igor Opaniuk
    Reviewed-by: Sam Protsenko

    Eugeniu Rosca
     

12 Jul, 2019

1 commit

  • 'Bootloader Control Block' (BCB) is a well established term/acronym in
    the Android namespace which refers to a location in a dedicated raw
    (i.e. FS-unaware) flash (e.g. eMMC) partition, usually called "misc",
    which is used as media for exchanging messages between Android userspace
    (particularly recovery [1]) and an Android-capable bootloader.

    On higher level, this allows implementing a subset of Android Bootloader
    Requirements [2], amongst which is the Android-specific bootloader
    flow [3]. Regardless how the latter is implemented in U-Boot ([3] being
    the most memorable example), reading/writing/dumping the BCB fields in
    the development process from inside the U-Boot is a convenient feature.
    Hence, make it available to the users.

    Some usage examples of the new command recorded on R-Car H3ULCB-KF
    ('>>>' is an overlay on top of the original console output):

    => bcb
    bcb - Load/set/clear/test/dump/store Android BCB fields

    Usage:
    bcb load - load BCB from mmc :
    bcb set - set BCB to
    bcb clear [] - clear BCB or all fields
    bcb test - test BCB against
    bcb dump - dump BCB
    bcb store - store BCB back to mmc

    Legend:
    - MMC device index containing the BCB partition
    - MMC partition index or name containing the BCB
    - one of {command,status,recovery,stage,reserved}
    - the binary operator used in 'bcb test':
    '=' returns true if matches the string stored in
    '~' returns true if matches a subset of 's string
    - string/text provided as input to bcb {set,test}
    NOTE: any ':' character in will be replaced by line feed
    during 'bcb set' and used as separator by upper layers

    => bcb dump command
    Error: Please, load BCB first!
    >>> Users must specify mmc device and partition before any other call

    => bcb load 1 misc
    => bcb load 1 1
    >>> The two calls are equivalent (assuming "misc" has index 1)

    => bcb dump command
    00000000: 62 6f 6f 74 6f 6e 63 65 2d 73 68 65 6c 6c 00 72 bootonce-shell.r
    00000010: 79 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 y.r.............
    >>> The output is in binary/string format for convenience
    >>> The output size matches the size of inspected BCB field
    >>> (32 bytes in case of 'command')

    => bcb test command = bootonce-shell && echo true
    true
    => bcb test command = bootonce-shell- && echo true
    => bcb test command = bootonce-shel && echo true
    >>> The '=' operator returns 'true' on perfect match

    => bcb test command ~ bootonce-shel && echo true
    true
    => bcb test command ~ bootonce-shell && echo true
    true
    >>> The '~' operator returns 'true' on substring match

    => bcb set command recovery
    => bcb dump command
    00000000: 72 65 63 6f 76 65 72 79 00 73 68 65 6c 6c 00 72 recovery.shell.r
    00000010: 79 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 y.r.............
    >>> The new value is NULL-terminated and stored in the BCB field

    => bcb set recovery "msg1:msg2:msg3"
    => bcb dump recovery
    00000040: 6d 73 67 31 0a 6d 73 67 32 0a 6d 73 67 33 00 00 msg1.msg2.msg3..
    00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    >>> --- snip ---
    >>> Every ':' is replaced by line-feed '\n' (0xA). The latter is used
    >>> as separator between individual commands by Android userspace

    => bcb store
    >>> Flush/store the BCB structure to MMC

    [1] https://android.googlesource.com/platform/bootable/recovery
    [2] https://source.android.com/devices/bootloader
    [3] https://patchwork.ozlabs.org/patch/746835/
    ("[U-Boot,5/6] Initial support for the Android Bootloader flow")

    Signed-off-by: Eugeniu Rosca

    Eugeniu Rosca