aboutsummaryrefslogtreecommitdiff
path: root/cmd
AgeCommit message (Collapse)AuthorFilesLines
2021-01-31thor: add support for the dfu_alt_info reintialization from the flashed scriptMarek Szyprowski1-7/+12
Reinitialize dfu_env_entities after flashing the 'SCRIPT' entity to ensure that the potential changes to the 'dfu_alt_info' environment variable are applied. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
2021-01-31dfu: add support for the dfu_alt_info reintialization from the flashed scriptMarek Szyprowski1-2/+11
Reinitialize DFU USB gadget after flashing the 'SCRIPT' entity to ensure that the potential changes to the 'dfu_alt_info' environment variable are applied. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> [lukma - I've moved the bool retry to avoid build (CI) errors]
2021-01-31cmd: usb_mass_storage: show device interface nameMarek Szyprowski1-2/+2
Show the interface name (i.e. 'mmc') in the information string to ease user checking which device is exported via USB Mass Storage protocol. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Lukasz Majewski <lukma@denx.de>
2021-01-31cmd: bcb: Add support for processing const string literals in bcb_set()Eugeniu Rosca1-5/+12
On request/suggestion from Simon Glass back in May 22 2019 [1], the 'strsep' mechanism implemented in bcb_set() was set to work directly with user-provided argv strings, to avoid duplicating memory and for the sake of simpler implementation. However, since we recently exposed bcb_write_reboot_reason() API to be called by U-Boot fastboot, the idea is to be able to pass const string literals to this new BCB API, carrying the reboot reason. Since 'strsep' (just like its older/superseded sibling 'strtok') modifies the input string passed as parameter, BCB command in its current state would attempt to perform in-place modifications in a readonly string, which might lead to unexpected results. Fix the above with the cost of one dynamic memory allocation ('strdup'). This will also ensure no compiler warnings when passing string literals to bcb_write_reboot_reason(). [1] http://u-boot.10912.n7.nabble.com/PATCH-v2-0-2-Add-bcb-command-to-read-modify-write-Android-BCB-td369934i20.html#a370456 Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
2021-01-31cmd: bcb: Expose 'bcb_write_reboot_reason' to external callersEugeniu Rosca1-0/+20
Fastboot is evolving and beginning with commit [1], the upstream implementation expects bootloaders to offer support for: - reboot-recovery - reboot-fastboot The most natural way to achieve the above is through a set of pre-defined "reboot reason" strings, written into / read from the BCB "command" field, e.g.: - bootonce-bootloader [2] - boot-fastboot [3] - boot-recovery [4] Expose the first 'bcb' API meant to be called by e.g. fastboot stack, to allow updating the BCB reboot reason via the BCB 'command' field. [1] https://android.googlesource.com/platform/system/core/+/dea91b4b5354af2 ("Add fastbootd.") [2] https://android.googlesource.com/platform/bootable/recovery/+/cba7fa88d8b9 ("Add 'reboot bootloader' to bootloader_message.") [3] https://android.googlesource.com/platform/bootable/recovery/+/eee4e260f9f6 ("recovery: Add "boot-fastboot" command to BCB.") [4] https://android.googlesource.com/platform/system/core/+/5e98b633a748695f ("init: Write the reason in BCB on "reboot recovery"") Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com> [lukma - added missing #include <linux/errno.h> to avoid build breaks]
2021-01-31cmd: bcb: Extract '__bcb_store' from 'do_bcb_store' for internal needsEugeniu Rosca1-2/+7
Enriching the functionality of U-Boot 'bcb' may assume using the existing sub-commands as building blocks for the next ones. A clean way to achive the above is to expose a number of static routines, each mapped to an existing user command (e.g. load/set/store), with a user/caller-friendly prototype (i.e. do not force the caller to wrap an integer into a string). This third patch makes '__bcb_store' available for internal needs. No functional change intended. Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
2021-01-31cmd: bcb: Extract '__bcb_set' from 'do_bcb_set' for internal needsEugeniu Rosca1-6/+11
Enriching the functionality of U-Boot 'bcb' may assume using the existing sub-commands as building blocks for the next ones. A clean way to achive the above is to expose a number of static routines, each mapped to an existing user command (e.g. load/set/store), with a user/caller-friendly prototype (i.e. do not force the caller to wrap an integer into a string). This second patch makes '__bcb_set' available for internal needs. No functional change intended. Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
2021-01-31cmd: bcb: Extract '__bcb_load' from 'do_bcb_load' for internal needsEugeniu Rosca1-8/+23
Enriching the functionality of U-Boot 'bcb' may assume using the existing sub-commands as building blocks for the next ones. A clean way to achive the above is to expose a number of static routines, each mapped to an existing user command (e.g. load/set/store), with a user/caller-friendly prototype (i.e. do not force the caller to wrap an integer into a string). This first patch makes '__bcb_load' available for internal needs. No functional change, except for a tiny update in error handling. Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
2021-01-29cmd: add more implementation IDs to sbi commandWIP/2021-01-29-assorted-fixesHeinrich Schuchardt1-16/+21
Additional SBI implementation IDs have been added to the upcoming next version of the SBI specification. https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-27cmd: misc: Fix return value for the sleep commandMarek Szyprowski1-1/+1
If sleeping has been interrupted, return CMD_RET_FAILURE instead of -1 (CMD_RET_USAGE). Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-01-27cmd: pxe: add support for FDT overlaysNeil Armstrong2-0/+104
This adds support for specifying FDT overlays in an extlinux/pxelinux configuration file. Without this, there is no simple way to apply overlays when the kernel and fdt is loaded by the pxe command. This change adds the 'fdtoverlays' keyword for a label, supporting multiple overlay files to be applied on top of the fdt specified in the 'fdt' or 'devicetree' keyword. Example: label linux kernel /Image fdt /soc-board.dtb fdtoverlays /soc-board-function.dtbo append console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait This code makes usage of a new variable called fdtoverlay_addr_r used to load the overlay files without overwritting anything important. Cc: Tom Rini <trini@konsulko.com> Cc: Andre Heider <a.heider@gmail.com> Cc: Jernej Škrabec <jernej.skrabec@siol.net> Cc: Jonas Karlman <jonas@kwiboo.se> Tested-by: Jernej Škrabec <jernej.skrabec@siol.net> Reviewed-by: Jernej Škrabec <jernej.skrabec@siol.net> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-01-25cmd: correct long text loadb, loadx, loadyHeinrich Schuchardt1-6/+6
The first argument is the load address and not an offset. The second argument cannot be entered without the first one. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-25cmd: change suppress newline in echo commandHeinrich Schuchardt1-31/+18
By default the echo command emits its arguments followed by a line feed. If any of the arguments contains the sub-string "\c", the line feed is suppressed. This does not match shells used in Linux and BSD where the first argument has to be -n to suppress the line feed. The hush shell interferes with the parsing of backslashes. E.g. in the following command line quadruple backslashes are required for suppressing the line feed: for i in 1 2 3; do for j in 4 5; do echo \\\\c ${i}${j}; done; echo; done; To avoid unexpected behavior the patch changes echo to use -n as first argument to suppress the line feed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-23cmd: efidebug: always check return code from get_variable()AKASHI Takahiro1-5/+7
CID 316364 says: > Null pointer dereferences (FORWARD_NULL) > printf("Result total size: 0x%x\n", result->variable_total_size); at do_efi_capsule_res(). The code is basically safe because a buffer for "result" is allocated by malloc() and filled up by the second get_variable(), which fails any way if the allocation has failed. But the first (and second) get_variable() possibly returns an error other than EFI_SUCCESS. We always need to check the return code from get_variable() before accessing the data in "result". While this change won't suppress CID 316364, the resulting code is much safer. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-20efi_loader: make the UEFI boot manager configurableHeinrich Schuchardt2-6/+15
Some boards are very tight on the binary size. Booting via UEFI is possible without using the boot manager. Provide a configuration option to make the boot manager available. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-18cmd: Add a pwm commandPragnesh Patel3-0/+124
Add the command "pwm" for controlling the pwm channels. This command provides pwm invert/config/enable/disable functionalities via PWM uclass drivers Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-16cmd: disk: Remove fit_print_contents APIRavik Hasija1-1/+0
fit_print_contents prints similar fit information as printed in bootm stages. Removing this API reduces redundancy & provides improvement in boottime. Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-16bootmenu: Allow to quit it via ESC/CTRL+CPali Rohár1-7/+35
When ESC/CTRL+C is pressed interrupt bootmenu and jump into U-Boot console. As the last entry in bootmenu is always U-Boot console just choose the last entry when ESC or CTRL+C is pressed. ESC key is detected when either no other character appears after '\e' within 10ms or when non-'[' appears after '\e'. It is useful when bootmenu is part of boot process and you want to interrupt boot process by scripts which control U-Boot (serial) console. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-16cmd: gpt: add eMMC and GPT supportCorneliu Doban1-0/+161
Add eMMC and GPT support. - GPT partition list and command to create the GPT added to u-boot environment - eMMC boot commands added to u-boot environment - new gpt commands (enumarate and setenv) that are used by broadcom update scripts and boot commands - eMMC specific u-boot configurations with environment saved in eMMC and GPT support Signed-off-by: Corneliu Doban <cdoban@broadcom.com> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com> [trini: Make gpt_setenv initialize ret to -1, given relevant return error values] Signed-off-by: Tom Rini <trini@konsulko.com>
2021-01-16cmd: CMD_CPU depends on CPUHeinrich Schuchardt1-0/+1
Compiling with CONFIG_CMD_CPU=y and CONFIG_CPU=n fails with: aarch64-linux-gnu-ld.bfd: cmd/built-in.o: in function `print_cpu_list': /home/user/u-boot/cmd/cpu.c:34: undefined reference to `cpu_get_desc' aarch64-linux-gnu-ld.bfd: /home/user/u-boot/cmd/cpu.c:39: undefined reference to `cpu_get_info' Segmentation fault (core dumped) make: *** [Makefile:1757: u-boot] Error 139 make: *** Deleting file 'u-boot' See error report in https://stackoverflow.com/questions/64678347. Add the missing build dependency. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15cmd: Add MBR partition layout control utilityMarek Szyprowski3-0/+323
Add a 'mbr' command to let users create or verify MBR partition layout based on the provided text description. The partition layout is alternatively read from the 'mbr_parts' environment variable. This can be used in scripts to help system image flashing tools to ensure proper partition layout. The syntax of the text description of the partition list is similar to the one used by the 'gpt' command. Supported parameters are: name (currently ignored), start (partition start offset in bytes), size (in bytes or '-' to expand it to the whole free area), bootable (boolean flag) and id (MBR partition type). If one wants to create more than 4 partitions, an 'Extended' primary partition (with 0x05 ID) has to be explicitely provided as a one of the first 4 entries. Here is an example how to create a 6 partitions (3 on the 'extended volume'), some of the predefined sizes: > setenv mbr_parts 'name=boot,start=4M,size=128M,bootable,id=0x0e; name=rootfs,size=3072M,id=0x83; name=system-data,size=512M,id=0x83; name=[ext],size=-,id=0x05; name=user,size=-,id=0x83; name=modules,size=100M,id=0x83; name=ramdisk,size=8M,id=0x83' > mbr write mmc 0 Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
2021-01-13efi_loader: implement EFI_DT_FIXUP_PROTOCOLHeinrich Schuchardt2-80/+5
A boot manager like GRUB can use the protocol to * apply U-Boot's fix-ups to the a device-tree * let U-Boot make memory reservations according to the device-tree * install the device-tree as a configuration table Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-13cmd: conitrace: increase wait for next keyHeinrich Schuchardt1-2/+2
At 9600 baud or less a 1 ms wait is too short to detect the end of an escape sequence. Increase the wait duration to 10 ms which will work down to 1200 baud. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-13efi_loader: setting boot deviceHeinrich Schuchardt1-55/+87
Up to now the bootefi command used the last file loaded to determine the boot partition. This has led to errors when the fdt had been loaded from another partition after the EFI binary. Before setting the boot device from a loaded file check if it is a PE-COFF image or a FIT image. For a PE-COFF image remember address and size, boot device and path. For a FIT image remember boot device and path. If the PE-COFF image is overwritten by loading another file, forget it. Do not allow to start an image via bootefi which is not the last loaded PE-COFF image. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-13efi_loader: simplify running helloworld.efiHeinrich Schuchardt1-11/+1
Currently when executing 'bootefi hello' we copy helloworld.efi to the address identified by environment variable loadaddr. This is unexected behavior for a user. There is no need to copy helloworld.efi before executing it after relocation. Remove the copy action. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-06Merge tag 'xilinx-for-v2021.04' of ↵WIP/06Jan2021-nextTom Rini1-5/+4
https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze into next Xilinx changes for v2021.04 arm64: - DT updates microblaze: - Add support for NOR device support spi: - Fix unaligned data write issue nand: - Minor code change xilinx: - Fru fix in limit calculation - Fill git repo link for all Xilinx boards video: - Add support for seps525 spi display tools: - Minor Vitis file support cmd/common - Minor code indentation fixes serial: - Uartlite debug uart initialization fix
2021-01-05Merge tag 'dm-pull-5jan21' of git://git.denx.de/u-boot-dm into nextWIP/05Jan2021-nextTom Rini1-1/+1
Driver model: make some udevice fields private Driver model: Rename U_BOOT_DEVICE et al. dtoc: Tidy up and add more tests ns16550 code clean-up x86 and sandbox minor fixes for of-platdata dtoc prepration for adding build-time instantiation
2021-01-05Merge tag 'v2021.01-rc5' into nextTom Rini1-0/+5
Prepare v2021.01-rc5 Signed-off-by: Tom Rini <trini@konsulko.com>
2021-01-05dm: core: Access device flags through functionsSimon Glass1-1/+1
At present flags are stored as part of the device. In preparation for storing them separately, change the access to go through inline functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-04cmd: ubi: don't allow to rename a volume to a name that already existPhilippe Reynes1-0/+5
This commits add a check on the command ubi rename. This check avoids to rename a volume to with a name that is already used on another ubi volume. If two volumes has the same name, then the ubi device can't be mounted anymore. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
2021-01-04cmd: load: Fix code indentationMichal Simek1-5/+4
Reported by smatch like: cmd/load.c:228 read_record() warn: inconsistent indenting Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-31efidebug: capsule: Add a command to update capsule on diskSughosh Ganu1-0/+14
Add a efidebug subcommand to initiate a firmware update using the efi firmware management protocol(fmp) set_image routine. The firmware update can be initiated through 'efidebug capsule disk-update' This would locate the efi capsule file on the efi system partition, and call the platform's set_image fmp routine to initiate the firmware update. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-18cmd: Drop use of old sequence numbers in commandsSimon Glass3-5/+5
Several commands use sequence numbers. Update them to use the new ones. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-18dm: Avoid accessing seq directlySimon Glass9-16/+17
At present various drivers etc. access the device's 'seq' member directly. This makes it harder to change the meaning of that member. Change access to go through a function instead. The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename ..._platdata variables to just ..._platSimon Glass3-12/+12
Try to maintain some consistency between these variables by using _plat as a suffix for them. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename dev_get_platdata() to dev_get_plat()Simon Glass2-2/+2
Rename this to be consistent with the change from 'platdata'. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename 'platdata' variables to just 'plat'Simon Glass10-26/+26
We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13cmd: sandbox: implement exception commandHeinrich Schuchardt4-1/+46
Implement the commands * exception undefined - execute an illegal instruction * exception sigsegv - cause a segment violation Here is a possible output: => exception undefined Illegal instruction pc = 0x55eb8d0a7575, pc_reloc = 0x57575 Resetting ... Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-04cli: Support macro processing with a fixed-size bufferSimon Glass1-2/+4
At present cli_simple_process_macros() requires that the caller provide an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This makes sense since it is designed to be used from the command line. But we also want to use it for bootargs substitution. Update the function to allow the caller to specify the buffer size. Also return an error if the buffer is exhausted. The caller can ignore that if preferred. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-04env: Allow returning errors from hdelete_r()Simon Glass1-2/+4
At present this function returns 1 on success and 0 on failure. But in the latter case it provides no indication of what went wrong. If an attempt is made to delete a non-existent variable, the caller may want to ignore this error. This happens when setting a non-existent variable to "", for example. Update the function to return 0 on success and a useful error code on failure. Add a function comment too. Make sure that env_set() does not return an error if it is deleting a variable that doesn't exist. We could update env_set() to return useful error numbers also, but that is beyond the scope of this change. Signed-off-by: Simon Glass <sjg@chromium.org> wip
2020-12-03cmd: add "efidebug capsule" commandAKASHI Takahiro1-0/+235
"efidebug capsule" is more or less a debugging utility. efidebug capsule update: invoke UpdateCapsule against data on memory efidebug capsule show: show a capsule header efidebug capsule result: dump a capsule result variable Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-12-03cmd: efidebug: Add support for TCG2 final events tableIlias Apalodimas1-0/+4
A previous commit is adding EFI_TCG2_PROTOCOL, which in it's eventlog support registers an EFI configuration table. Let's add the necessary GUID so 'efidebug table' command can display table names properly. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2020-12-03tpm: use more than sha256 on pcr_extendIlias Apalodimas1-1/+2
The current tpm2_pcr_extend is hardcoded using SHA256. Let's make the actual command to the TPM2 configurable so we can support a wider range of algorithms and keep the current command line as-is i.e limited to SHA256 only Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-01cmd: Kconfig: migrate CONFIG_SYS_PROMPT_HUSH_PS2Patrick Delaunay1-0/+9
Move CONFIG_SYS_PROMPT_HUSH_PS2 in Kconfig, depending on CONFIG_HUSH_PARSER, and remove the default value defined in cli_hush.c under __U_BOOT__. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-01setexpr: Add support for stringsSimon Glass1-7/+75
Add support for dealing with string operands, including reading a string from memory into an environment variable and concatenating two strings. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Marek Behún <marek.behun@nic.cz>
2020-12-01setexpr: Convert to use a struct for valuesSimon Glass1-44/+67
At present a ulong is used to hold operand values. This means that strings cannot be used. While most operations are not useful for strings, concatenation is. As a starting point to supporting strings, convert the code to use a struct instead of a ulong for operands. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-01setexpr: Correct buffer overflow bug and enable testsSimon Glass1-5/+5
At present when more than one substitution is made this function overwrites its buffers. Fix this bug and update the tests now that they can pass. Also update the debug code to show all substrings, since at present it omits the final one. Fixes: 855f18ea0e6 ("setexpr: add regex substring matching and substitution") Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-01setexpr: Correct dropping of final unmatched stringSimon Glass1-5/+1
At present the 'nlen' variable increases with each loop. If the previous loop had back references, then subsequent loops without back references use the wrong value of nlen. The value is larger, meaning that the string terminator from nbuf is copied along to the main buffer, thus terminating the string prematurely. This leads to the final result being truncated, e.g. missing the last (unmatched) part of the string. So "match match tail" become "replaced replaced" instead of "replaced replaced tail". Fix this by resetting nlen to the correct value each time around the lop. Fixes: 855f18ea0e6 ("setexpr: add regex substring matching and substitution") Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-01setexpr: Add some tests for buffer overflow and backrefSimon Glass1-17/+4
Add tests to check for buffer overflow using simple replacement as well as back references. At present these don't fully pass. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-01setexpr: Split the core logic into its own functionSimon Glass1-58/+98
At present this function always allocates a large amount of stack, and selects its own size for buffers. This makes it hard to test the code for buffer overflow. Separate out the inner logic of the substitution so that tests can call this directly. This will allow checking that the algorithm does not overflow the buffer. Fix up one of the error lines at the same time, since it should be printing nbuf_size, not data_size. Signed-off-by: Simon Glass <sjg@chromium.org>