From: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 1/1] cmd: adding malloc, math, and strcmp commands to u-boot
Date: Wed, 20 Nov 2019 14:50:53 -0800 [thread overview]
Message-ID: <0a51307d771d8a198998141e3c405ed2@mail.gmail.com> (raw)
In-Reply-To: <20191119203733.GI19317@bill-the-cat>
Hi Tom,
> -----Original Message-----
> From: Tom Rini [mailto:trini at konsulko.com]
> Sent: Tuesday, November 19, 2019 12:38 PM
> To: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
> Cc: u-boot at lists.denx.de; Suji Velupiallai
<suji.velupillai@broadcom.com>;
> Heinrich Schuchardt <xypron.glpk@gmx.de>
> Subject: Re: [U-Boot] [PATCH v1 1/1] cmd: adding malloc, math, and
strcmp
> commands to u-boot
>
> On Mon, Nov 18, 2019 at 04:26:30PM -0800, Vladimir Olovyannikov wrote:
>
> > cmd: adding malloc, math, and strcmp u-boot commands.
> > - malloc supports allocation of heap memory and free allocated memory
> > via u-boot command line.
>
> Can you expand on how this is used in a script? I'm not sure I see that
> exactly.
I am upstreaming the new bcm platform. Here is an excerpt from the script
which uses
these:
#define SD_UPDATE \
"sd_update="\
"if malloc tmp 2000; then "\
"else "\
"echo [sd_update] malloc 2000 bytes ** FAILED **;"\
"exit;"\
"fi;"\
"if fatload mmc ${sd_device_number} ${tmp} "\
"${sd_update_prefix}.sd-update; then "\
"else "\
"echo [sd_update] fatload ${sd_update_prefix}.sd-update "\
"** FAILED **;"\
"exit;"\
"fi;"\
"if source ${tmp}; then "\
"else "\
"echo [sd_update] Executing script ** FAILED **;"\
"exit;"\
"fi;"\
"if free tmp; then "\
"else " \
"echo [sd_update] free 2000 bytes ** FAILED **;"\
"exit;"\
"fi \0"
;
"if math add filesize filesize 1FF; then "\
"else "\
"echo [mmc_flash_image_rsa] math add command ** FAILED
**;"\
"exit;"\
"fi;"\
"if math div fileblocks filesize 200; then "\
"else "\
"echo [mmc_flash_image_rsa] math div command ** FAILED
**;"\
"exit;"\
"fi;"\
> Also:
> > +config CMD_MALLOC
> > + bool "malloc"
> > + default y
> > + help
> > + Supports allocation of heap memory and free allocated memory
> commands.
> > + These commands are used by u-boot scripts.
> > +
> > +config CMD_MATH
> > + bool "math"
> > + default y
> > + help
> > + Provides math commands such as add, sub, mul, div, shift,
> > + convert decimal to hex functionalities to be available in the
script.
>
> First, why do we need this, rather than using setexpr ?
I agree, the platform needs to use setexpr as it contains all math
operations.
>
> > +
> > config CMD_SOURCE
> > bool "source"
> > default y
> > @@ -1301,6 +1315,13 @@ config CMD_SETEXPR
> > Also supports loading the value at a memory location into a
variable.
> > If CONFIG_REGEX is enabled, setexpr also supports a gsub
function.
> >
> > +config CMD_STRCMP
> > + bool "strcmp"
> > + default y
> > + help
> > + Provides string compare command feature to u-boot scripts.
>
> Second, new commands must not default to y, but they should be enabled
> on sandbox and new test.py tests added for them. Thanks!
OK, thank you.
Is there an example/doc on how to enable these on sandbox and to provide
tests?
Vladimir
>
> --
> Tom
next prev parent reply other threads:[~2019-11-20 22:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 0:26 [U-Boot] [PATCH v1 1/1] cmd: adding malloc, math, and strcmp commands to u-boot Vladimir Olovyannikov
2019-11-19 1:21 ` Simon Glass
2019-11-19 20:02 ` Vladimir Olovyannikov
2019-11-19 20:37 ` Tom Rini
2019-11-20 22:50 ` Vladimir Olovyannikov [this message]
2019-11-20 23:26 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0a51307d771d8a198998141e3c405ed2@mail.gmail.com \
--to=vladimir.olovyannikov@broadcom.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox