diff options
author | Dominik Sliwa <dominik.sliwa@toradex.com> | 2017-08-02 12:19:02 +0200 |
---|---|---|
committer | Max Krummenacher <max.krummenacher@toradex.com> | 2019-01-30 18:05:15 +0100 |
commit | ded6bc5a211b13bd9abba62326f7487163d83b95 (patch) | |
tree | 0485d5bd62c8d5882b44ff0ad9012318afba1c67 | |
parent | e28e4cf5b0599932d24002ea3f4534a95c636eba (diff) |
toradex: configblock: add an -y parameter to 'cfgblock create’
Add an optional -y parameter to 'cfgblock create’ to simplify
automation.
Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Acked-by: Stefan Agner <stefan.agner@toradex.com>
(cherry picked from commit d909b68d7f9da189a16e3ead0a6454b715201e23)
(cherry picked from commit ace5cf96413d3c736148dcecd1481e4249b7c5f1)
(cherry picked from commit 31091506e79e4924f47bc20b1830d6beef9bd1d7)
(cherry picked from commit 674ffe96fb6d9264f2e9019c8d26fce5fb3588e3)
-rw-r--r-- | board/toradex/common/tdx-cfg-block.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c index 76dfeae9485..d1064242125 100644 --- a/board/toradex/common/tdx-cfg-block.c +++ b/board/toradex/common/tdx-cfg-block.c @@ -424,6 +424,7 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc, int offset = 0; int ret = CMD_RET_SUCCESS; int err; + int force_overwrite = 0; /* Allocate RAM area for config block */ config_block = memalign(ARCH_DMA_MINALIGN, size); @@ -434,6 +435,11 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc, memset(config_block, 0xff, size); + if (argc >= 3) { + if (argv[2][0] == '-' && argv[2][1] == 'y') + force_overwrite = 1; + } + read_tdx_cfg_block(); if (valid_cfgblock) { #if defined(CONFIG_TDX_CFG_BLOCK_IS_IN_NAND) @@ -454,24 +460,29 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc, CONFIG_TDX_CFG_BLOCK_OFFSET); goto out; #else - char message[CONFIG_SYS_CBSIZE]; - sprintf(message, - "A valid Toradex config block is present, still recreate? [y/N] "); + if (!force_overwrite) { + char message[CONFIG_SYS_CBSIZE]; + sprintf(message, + "A valid Toradex config block is present, still recreate? [y/N] "); - if (!cli_readline(message)) - goto out; + if (!cli_readline(message)) + goto out; - if (console_buffer[0] != 'y' && console_buffer[0] != 'Y') - goto out; + if (console_buffer[0] != 'y' && console_buffer[0] != 'Y') + goto out; + } #endif } /* Parse new Toradex config block data... */ - if (argc < 3) + if (argc < 3 || (force_overwrite && argc < 4)) err = get_cfgblock_interactive(); - else - err = get_cfgblock_barcode(argv[2]); - + else { + if (force_overwrite) + err = get_cfgblock_barcode(argv[3]); + else + err = get_cfgblock_barcode(argv[2]); + } if (err) { ret = CMD_RET_FAILURE; goto out; @@ -555,8 +566,8 @@ static int do_cfgblock(cmd_tbl_t *cmdtp, int flag, int argc, } U_BOOT_CMD( - cfgblock, 3, 0, do_cfgblock, + cfgblock, 4, 0, do_cfgblock, "Toradex config block handling commands", - "create [barcode] - (Re-)create Toradex config block\n" + "create [-y] [barcode] - (Re-)create Toradex config block\n" "cfgblock reload - Reload Toradex config block from flash" ); |