[U-Boot] [PATCH 06/51] cmd: Add command for calculating binary operations

Mario Six mario.six at gdsys.cc
Tue Jul 25 07:28:47 UTC 2017


Hi Simon,

On Wed, Jul 19, 2017 at 11:07 AM, Simon Glass <sjg at chromium.org> wrote:
> Hi Mario,
>
> On 19 July 2017 at 01:53, Mario Six <mario.six at gdsys.cc> wrote:
>> Hi Simon,
>>
>> On Tue, Jul 18, 2017 at 4:01 PM, Simon Glass <sjg at chromium.org> wrote:
>>> Hi Mario,
>>>
>>> On 14 July 2017 at 05:54, Mario Six <mario.six at gdsys.cc> wrote:
>>>> This patch adds a command that enables the calculation of bit operations
>>>> (AND, OR, XOR) on binary data from the command line. Memory locations as
>>>> well as the contents of environment variables are eligible as sources
>>>> and destination of the binary data used in the operations.
>>>>
>>>> The possible applications are manifold: Setting specific bits in
>>>> registers using the regular read-OR-write pattern, masking out bits in
>>>> bit values, implementation of simple OTP encryption using the XOR
>>>> operation, etc.
>>>>
>>>> Signed-off-by: Mario Six <mario.six at gdsys.cc>
>>>
>>> Is this very different from setexpr? It looks like it supports and / or.
>>>
>>> Regards,
>>> Simon
>>
>> It is quite similar, but it lacks the support to write the result directly back
>> to memory, and, the more important point, it also only operates on bytes, words
>> and longs, whereas binop operates on arbitrarily long byte arrays.
>>
>> I thought about somehow fixing up setexpr to add support for these two
>> features, but couldn't think of a good way to do so. Do you have an idea how to
>> do that? I'd also rather not add an additional command if somehow possible.
>
> Not really. It makes sense to me now. Perhaps add in the help that you
> can use byte arrays.
>
> Also can you add a test for this? See for example ut_cmd.
>
> Regards,
> Simon

OK, I'll improve the help text and add a test in v2.

Best regards,

Mario


More information about the U-Boot mailing list