<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/cmd/bcb.c, branch v2020.10</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<entry>
<title>common: Drop log.h from common header</title>
<updated>2020-05-19T01:19:18+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2020-05-10T17:40:05+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=f7ae49fc4f363a803dab3be078e93ead8e75a8e9'/>
<id>f7ae49fc4f363a803dab3be078e93ead8e75a8e9</id>
<content type='text'>
Move this header out of the common header.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move this header out of the common header.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>command: Remove the cmd_tbl_t typedef</title>
<updated>2020-05-18T22:36:55+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2020-05-10T17:40:03+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=09140113108541b95d340f3c7b6ee597d31ccc73'/>
<id>09140113108541b95d340f3c7b6ee597d31ccc73</id>
<content type='text'>
We should not use typedefs in U-Boot. They cannot be used as forward
declarations which means that header files must include the full header to
access them.

Drop the typedef and rename the struct to remove the _s suffix which is
now not useful.

This requires quite a few header-file additions.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We should not use typedefs in U-Boot. They cannot be used as forward
declarations which means that header files must include the full header to
access them.

Drop the typedef and rename the struct to remove the _s suffix which is
now not useful.

This requires quite a few header-file additions.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>common: Drop part.h from common header</title>
<updated>2020-05-18T21:33:33+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2020-05-10T17:39:58+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=e6f6f9e64882ddf242437c73fdd9ff06a8eb7c21'/>
<id>e6f6f9e64882ddf242437c73fdd9ff06a8eb7c21</id>
<content type='text'>
Move this uncommon header out of the common header.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move this uncommon header out of the common header.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>part: Drop disk_partition_t typedef</title>
<updated>2020-05-18T21:33:33+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2020-05-10T17:39:57+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=0528979fa7ab7853faaf2ecf34b7721dd4c0b383'/>
<id>0528979fa7ab7853faaf2ecf34b7721dd4c0b383</id>
<content type='text'>
We should not be using typedefs and these make it harder to use
forward declarations (to reduce header file inclusions). Drop the typedef.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We should not be using typedefs and these make it harder to use
forward declarations (to reduce header file inclusions). Drop the typedef.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cmd: bcb: Apply non-functional refinements</title>
<updated>2019-07-24T17:16:29+00:00</updated>
<author>
<name>Eugeniu Rosca</name>
<email>roscaeugeniu@gmail.com</email>
</author>
<published>2019-07-19T21:26:14+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=37f1811a0b31005284e8514955e7bf7e174cc506'/>
<id>37f1811a0b31005284e8514955e7bf7e174cc506</id>
<content type='text'>
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 &lt;sjg@chromium.org&gt;
Signed-off-by: Eugeniu Rosca &lt;erosca@de.adit-jv.com&gt;
Reviewed-by: Sam Protsenko &lt;semen.protsenko@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;sjg@chromium.org&gt;
Signed-off-by: Eugeniu Rosca &lt;erosca@de.adit-jv.com&gt;
Reviewed-by: Sam Protsenko &lt;semen.protsenko@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cmd: bcb: Use strcmp() instead of strncmp() for string literals</title>
<updated>2019-07-24T17:16:29+00:00</updated>
<author>
<name>Eugeniu Rosca</name>
<email>roscaeugeniu@gmail.com</email>
</author>
<published>2019-07-19T21:26:13+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=739168cfdc18690273e24a34f0360a61e6658424'/>
<id>739168cfdc18690273e24a34f0360a61e6658424</id>
<content type='text'>
Quote from https://patchwork.ozlabs.org/patch/1104244/#2210814:

 ----------8&lt;-----------
strncmp() is chosen for the sake of paranoid/defensive programming.
Indeed, strncmp() is not really needed when comparing a variable
with a string literal. We expect strcmp() to behave safely even if the
string variable is not NUL-terminated.

In the same scenario, Linux v5.2-rc7 uses both strcmp() and strncmp(),
but the frequency of strcmp() is higher:

$ git --version
git version 2.22.0
$ (Linux 5.2-rc7) git grep -En 'strncmp\([^"]*"[[:alnum:]]+"' | wc -l
1066
$ (Linux 5.2-rc7) git grep -En 'strcmp\([^"]*"[[:alnum:]]+"' | wc -l
1968

A quick "strcmp vs strncmp" object size test shows that strcmp()
generates smaller memory footprint (gcc-8, x86_64):

$ (U-Boot) size cmd/bcb-strncmp.o cmd/bcb-strcmp.o
   text	   data	    bss	    dec	    hex	filename
   3373	    400	   2048	   5821	   16bd	cmd/bcb-strncmp.o
   3314	    400	   2048	   5762	   1682	cmd/bcb-strcmp.o

So, overall, I agree to use strcmp() whenever variables are compared
with string literals.
 ----------8&lt;-----------

Fixes: db7b7a05b267 ("cmd: Add 'bcb' command to read/modify/write BCB fields")
Reported-by: Simon Glass &lt;sjg@chromium.org&gt;
Signed-off-by: Eugeniu Rosca &lt;erosca@de.adit-jv.com&gt;
Reviewed-by: Sam Protsenko &lt;semen.protsenko@linaro.org&gt;
Reviewed-by: Igor Opaniuk &lt;igor.opaniuk@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Quote from https://patchwork.ozlabs.org/patch/1104244/#2210814:

 ----------8&lt;-----------
strncmp() is chosen for the sake of paranoid/defensive programming.
Indeed, strncmp() is not really needed when comparing a variable
with a string literal. We expect strcmp() to behave safely even if the
string variable is not NUL-terminated.

In the same scenario, Linux v5.2-rc7 uses both strcmp() and strncmp(),
but the frequency of strcmp() is higher:

$ git --version
git version 2.22.0
$ (Linux 5.2-rc7) git grep -En 'strncmp\([^"]*"[[:alnum:]]+"' | wc -l
1066
$ (Linux 5.2-rc7) git grep -En 'strcmp\([^"]*"[[:alnum:]]+"' | wc -l
1968

A quick "strcmp vs strncmp" object size test shows that strcmp()
generates smaller memory footprint (gcc-8, x86_64):

$ (U-Boot) size cmd/bcb-strncmp.o cmd/bcb-strcmp.o
   text	   data	    bss	    dec	    hex	filename
   3373	    400	   2048	   5821	   16bd	cmd/bcb-strncmp.o
   3314	    400	   2048	   5762	   1682	cmd/bcb-strcmp.o

So, overall, I agree to use strcmp() whenever variables are compared
with string literals.
 ----------8&lt;-----------

Fixes: db7b7a05b267 ("cmd: Add 'bcb' command to read/modify/write BCB fields")
Reported-by: Simon Glass &lt;sjg@chromium.org&gt;
Signed-off-by: Eugeniu Rosca &lt;erosca@de.adit-jv.com&gt;
Reviewed-by: Sam Protsenko &lt;semen.protsenko@linaro.org&gt;
Reviewed-by: Igor Opaniuk &lt;igor.opaniuk@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cmd: bcb: Fix duplicated handling in two case-branches</title>
<updated>2019-07-24T17:16:29+00:00</updated>
<author>
<name>Eugeniu Rosca</name>
<email>roscaeugeniu@gmail.com</email>
</author>
<published>2019-07-19T21:26:12+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=e47b73b821f7f6078c0d11b453545507e25727cc'/>
<id>e47b73b821f7f6078c0d11b453545507e25727cc</id>
<content type='text'>
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 &lt;erosca@de.adit-jv.com&gt;
Reviewed-by: Igor Opaniuk &lt;igor.opaniuk@gmail.com&gt;
Reviewed-by: Sam Protsenko &lt;semen.protsenko@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;erosca@de.adit-jv.com&gt;
Reviewed-by: Igor Opaniuk &lt;igor.opaniuk@gmail.com&gt;
Reviewed-by: Sam Protsenko &lt;semen.protsenko@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cmd: Add 'bcb' command to read/modify/write BCB fields</title>
<updated>2019-07-11T18:11:19+00:00</updated>
<author>
<name>Eugeniu Rosca</name>
<email>erosca@de.adit-jv.com</email>
</author>
<published>2019-05-23T15:32:22+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=db7b7a05b2671c63cd49955dee58157045c68f05'/>
<id>db7b7a05b2671c63cd49955dee58157045c68f05</id>
<content type='text'>
'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
('&gt;&gt;&gt;' is an overlay on top of the original console output):

=&gt; bcb
bcb - Load/set/clear/test/dump/store Android BCB fields

Usage:
bcb load  &lt;dev&gt; &lt;part&gt;       - load  BCB from mmc &lt;dev&gt;:&lt;part&gt;
bcb set   &lt;field&gt; &lt;val&gt;      - set   BCB &lt;field&gt; to &lt;val&gt;
bcb clear [&lt;field&gt;]          - clear BCB &lt;field&gt; or all fields
bcb test  &lt;field&gt; &lt;op&gt; &lt;val&gt; - test  BCB &lt;field&gt; against &lt;val&gt;
bcb dump  &lt;field&gt;            - dump  BCB &lt;field&gt;
bcb store                    - store BCB back to mmc

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

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

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

=&gt; 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.............
 &gt;&gt;&gt; The output is in binary/string format for convenience
 &gt;&gt;&gt; The output size matches the size of inspected BCB field
 &gt;&gt;&gt; (32 bytes in case of 'command')

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

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

=&gt; bcb set command recovery
=&gt; 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.............
 &gt;&gt;&gt; The new value is NULL-terminated and stored in the BCB field

=&gt; bcb set recovery "msg1:msg2:msg3"
=&gt; 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    ................
 &gt;&gt;&gt; --- snip ---
 &gt;&gt;&gt; Every ':' is replaced by line-feed '\n' (0xA). The latter is used
 &gt;&gt;&gt; as separator between individual commands by Android userspace

=&gt; bcb store
 &gt;&gt;&gt; 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 &lt;erosca@de.adit-jv.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
'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
('&gt;&gt;&gt;' is an overlay on top of the original console output):

=&gt; bcb
bcb - Load/set/clear/test/dump/store Android BCB fields

Usage:
bcb load  &lt;dev&gt; &lt;part&gt;       - load  BCB from mmc &lt;dev&gt;:&lt;part&gt;
bcb set   &lt;field&gt; &lt;val&gt;      - set   BCB &lt;field&gt; to &lt;val&gt;
bcb clear [&lt;field&gt;]          - clear BCB &lt;field&gt; or all fields
bcb test  &lt;field&gt; &lt;op&gt; &lt;val&gt; - test  BCB &lt;field&gt; against &lt;val&gt;
bcb dump  &lt;field&gt;            - dump  BCB &lt;field&gt;
bcb store                    - store BCB back to mmc

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

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

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

=&gt; 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.............
 &gt;&gt;&gt; The output is in binary/string format for convenience
 &gt;&gt;&gt; The output size matches the size of inspected BCB field
 &gt;&gt;&gt; (32 bytes in case of 'command')

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

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

=&gt; bcb set command recovery
=&gt; 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.............
 &gt;&gt;&gt; The new value is NULL-terminated and stored in the BCB field

=&gt; bcb set recovery "msg1:msg2:msg3"
=&gt; 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    ................
 &gt;&gt;&gt; --- snip ---
 &gt;&gt;&gt; Every ':' is replaced by line-feed '\n' (0xA). The latter is used
 &gt;&gt;&gt; as separator between individual commands by Android userspace

=&gt; bcb store
 &gt;&gt;&gt; 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 &lt;erosca@de.adit-jv.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
