[PATCH]: cmd: part: add part block command

razvan becheriu razvan.becheriu at gmail.com
Tue Jun 2 20:36:48 CEST 2020


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

here is the implementation of the functions:

# function ota_conv_sizes
# Convert a bytes size to a block size
# input  bytesize : size in bytes to convert
# input  blksize  : size of a block in bytes
# output num_blk  : converted size in blocks
setenv ota_conv_sizes 'setexpr num_blk $bytesize / $blksize ; setexpr
mod_blk $bytesize % $blksize ; if itest $mod_blk > 0 ; then setexpr num_blk
$num_blk + 1; fi;'

# function ota_mmc_write
# Write a memory buffer to mmc drive
# input floadaddr    : address of buffer to write
# input u_part_start : block start in mmc
# input num_blk      : number of block to write
setenv ota_mmc_write 'if itest $ota_verbose == 1 ; then echo "mmc write
${floadaddr} ${u_part_start} ${num_blk};"; fi; mmc write $floadaddr
$u_part_start $num_blk; ret=$?; if itest $ret != 0 ; then setenv
ota_abort_reason "mmc write ${floadaddr} ${u_part_start} ${num_blk}
failed"; setenv ota_abort 1; fi;'

the old u-boot version supported 'part info mmc 0:${u_part_num}
u_part_start u_part_sz u_part_blksz;' to get the block size.

# function ota_get_partition_attributes
# Retrieve partition attribute
# input  u_part_num   : partition number
# output u_part_start : partition start block number
# output u_part_sz    : partition size in blocks
# output u_part_blksz : partition block size in bytes
setenv ota_get_partition_attributes 'if itest $ota_verbose == 1 ; then echo
"part info mmc 0:${u_part_num} u_part_start u_part_sz u_part_blksz;"; fi;
part info mmc 0:${u_part_num} u_part_start u_part_sz u_part_blksz;ret=$?;
if itest $ret != 0 ; then setenv ota_abort_reason "part info mmc
0:${u_part_num} u_part_start u_part_sz u_part_blksz failed: ${ret}"; setenv
ota_abort 1; fi;'

the new u-boot does not, so we need an explicit command 'part block mmc 0
${u_part_lbl} u_part_blksz;'

# function ota_get_partition_attributes_alternative
# Retrieve partition attribute
# input  u_part_lbl   : partition label
# output u_part_start : partition start block number
# output u_part_sz    : partition size in blocks
# output u_part_blksz : partition block size in bytes
setenv ota_get_partition_attributes_alternative 'if itest $ota_verbose == 1
; then echo "part start mmc 0 ${u_part_lbl} u_part_start; part size mmc 0
${u_part_lbl} u_part_sz; part block mmc 0 ${u_part_lbl} u_part_blksz;"; fi;
part start mmc 0 ${u_part_lbl} u_part_start;ret=$?; if itest $ret != 0 ;
then setenv ota_abort_reason "part start mmc 0 ${u_part_lbl} u_part_start
failed: ${ret}"; setenv ota_abort 1; fi; part size mmc 0 ${u_part_lbl}
u_part_sz;ret=$?; if itest $ret != 0 ; then setenv ota_abort_reason "part
size mmc 0 ${u_part_lbl} u_part_sz failed: ${ret}"; setenv ota_abort 1; fi;
part block mmc 0 ${u_part_lbl} u_part_blksz;ret=$?; if itest $ret != 0 ;
then setenv ota_abort_reason "part block mmc 0 ${u_part_lbl} u_part_blksz
failed: ${ret}"; setenv ota_abort 1; fi;'

On 2020-06-02 at 18:08, razvan.becheriu at gmail.com wrote:
> setexpr can compute the divide/multiply part, but we still need to get
the
> partition block size somehow.
>
> I know that this is 0x200 by default, but we can not hardcode that in the
> scripts. we should read that from the partition info.
>
> On 2020-06-02 at 17:55, trini at konsulko.com wrote:
> > On Mon, Jun 01, 2020 at 01:20:25PM +0300, razvan.becheriu at gmail.com
> wrote:
> > >
> > >     The Intel Edison OTA process requires a conversion of data size
> > >     from bytes to number of blocks. The following functions are used:
> > >
> > >     # function ota_conv_sizes
> > >     # Convert a bytes size to a block size
> > >     # input  bytesize : size in bytes to convert
> > >     # input  blksize  : size of a block in bytes
> > >     # output num_blk  : converted size in blocks
> > >
> > >     # function ota_mmc_write
> > >     # Write a memory buffer to mmc drive
> > >     # input floadaddr    : address of buffer to write
> > >     # input u_part_start : block start in mmc
> > >     # input num_blk      : number of block to write
> > >
> > >     This patch adds the cmd part sub-command 'block' which returns
> > >     the partition block size in bytes.
> >
> > This is usually done with the setexpr command today, thanks!
> >
> > --
> > Tom
-----BEGIN PGP SIGNATURE-----
Version: FlowCrypt 7.7.7 Gmail Encryption
Comment: Seamlessly send and receive encrypted email

wsFcBAEBCAAGBQJe1pxAAAoJECfW4OyT2xPzxxwQAI5G7KPEypB2gBNWNKIt
pH1MBgqMFC90mG8OtLjmCESVmiHZig/fzmEBbTIvyvE1KrEZfy4crjbrkkv3
gwv+Ro26HqtyuuuP0XjO/owWdDuAfdodwRb++YLnV8SgDvZhrf9ttcMX+OpT
kxXunxw1OsAP7Y2S9TxL0ujkKjTxgVW9oRPwWus8c7IRzKrq9SEcob0BFkRV
WrpiEa5K9RrXtsbRyw0OCY8vMr78f/6LJ91kNgGK0orYZF/gCEIw4gCHVopP
1x+O4JRhvxa7FGItB6Odrar01tqmIrSIFKfnyw7bzIXrxa/RLMU5nBLTPxUu
8rQkAGiuM2RwX+zK3odcczL1zXn1aXS+TJAvUYIJWpw1LxiGMc7SMBpegnov
lp6J6imZ2MYMsQ9s0yrpkRST45Qid6qWsYspXu5ZJoEsX+rnmb72drm3PXbs
6Blu5H612nmsnuVAqtyR8H6ElvETpQtC9jFyD66LWXmRZyaeuywXxubiSW54
/VL2JiPC9Rm2weHASTyT1O9+IHyKU9uCBryvpMsf0geHiyaHxDEwIUfUuHiS
DFCwbtxoG/nslEmw4CUZZ6dS22mPdAkUuc8oVPBTIf1mrF8AOM04XZHvYqNP
GEPjWdGYnRLSB4WFxwxT4/5eSm76K72otMVsFPuUT4XvuUbMTSIpSNAh24az
9Q90
=sNXc
-----END PGP SIGNATURE-----


More information about the U-Boot mailing list