
-----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@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@konsulko.com wrote:
On Mon, Jun 01, 2020 at 01:20:25PM +0300, razvan.becheriu@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