u-boot/cmd
Tom Rini 2b28c3b871 Merge patch series "Modernize U-Boot shell"
Francis Laniel <francis.laniel@amarulasolutions.com> says:

During 2021 summer, Sean Anderson wrote a contribution to add a new shell, based
on LIL, to U-Boot [1, 2].
While one of the goals of this contribution was to address the fact actual
U-Boot shell, which is based on Busybox hush, is old there was a discussion
about adding a new shell versus updating the actual one [3, 4].

So, in this series, with Harald Seiler, we updated the actual U-Boot shell to
reflect what is currently in Busybox source code.
Basically, this contribution is about taking a snapshot of Busybox shell/hush.c
file (as it exists in commit 37460f5da) and adapt it to suit U-Boot needs.

This contribution was written to be as backward-compatible as possible to avoid
breaking the existing.
So, the modern hush flavor offers the same as the actual, that is to say:
1. Variable expansion.
2. Instruction lists (;, && and ||).
3. If, then and else.
4. Loops (for, while and until).
No new features offered by Busybox hush were implemented (e.g. functions).

It is possible to change the parser at runtime using the "cli" command:
=> cli print
old
=> cli set modern
=> cli print
modern
=> cli set old
The default parser is the old one.
Note that to use both parser, you would need to set both
CONFIG_HUSH_MODERN_PARSER and CONFIG_HUSH_OLD_PARSER.

In terms of testing, new unit tests were added to ut to ensure the new behavior
is the same as the old one and it does not add regression.
Nonetheless, if old behavior was buggy and fixed upstream, the fix is then added
to U-Boot [5].
In sandbox, all of these tests pass smoothly:
=> printenv board
board=sandbox
=> ut hush
Running 20 hush tests
...
Failures: 0
=> cli set modern
=> ut hush
Running 20 hush tests
...
Failures: 0

Thanks to the effort of Harald Seiler, I was successful booting a board:
=> printenv fdtfile
fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb
=> cli get
old
=> boot
...
root@lepotato:~#
root@lepotato:~# reboot
...
=> cli set modern
=> cli get
modern
=> printenv fdtfile
fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb
=> boot
...
root@lepotato:~#

This contribution indeed adds a lot of code and there were concern about its
size [6, 7].
With regard to the amount of code added, the cli_hush_upstream.c is 13030 lines
long but it seems a smaller subset is really used:
gcc -D__U_BOOT__ -E common/cli_hush_upstream.c | wc -l
2870
Despite this, it is better to still have the whole upstream code for the sake of
easing maintenance.
With regard to memory size, I conducted some experiments for version 8 of this
series and for a subset of arm64 boards and found the worst case to be 4K [8].
Tom Rini conducted more research on this and also found the increase to be
acceptable [9].

If you want to review it - your review will really be appreciated - here are
some information regarding the commits:
* commits marked as "test:" deal with unit tests.
* commit "cli: Add Busybox upstream hush.c file." copies Busybox shell/hush.c
into U-Boot tree, this explain why this commit contains around 12000 additions.
* commit "cli: Port Busybox 2021 hush to U-Boot." modifies previously added file
to permit us to use this as new shell.
The really good idea of #include'ing Busybox code into a wrapper file to define
some particular functions while minimizing modifications to upstream code comes
from Harald Seiler.
* commit "cmd: Add new parser command" adds a new command which permits
selecting parser at runtime.
I am not really satisfied with the fact it calls cli_init() and cli_loop() each
time the parser is set, so your reviews would be welcomed.
* Other commits focus on enabling features we need (e.g. if).
2023-12-28 14:38:25 -05:00
..
arm cmd: exception: arm64: fix undefined, add faults 2022-03-02 13:59:29 -05:00
broadcom
meson cmd/arm: meson: sm: introduce efusedump command 2023-01-17 09:26:42 +01:00
mvebu cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096 2023-10-26 14:49:36 +02:00
riscv cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
sandbox cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
ti tree-wide: Replace http:// link with https:// link for ti.com 2023-11-10 11:01:50 -05:00
x86 x86: Add a little more info to cbsysinfo 2023-08-01 10:08:49 +08:00
.gitignore
2048.c cmd: Add 2048 game 2023-04-06 19:10:08 -04:00
ab_select.c android_ab: Add option to skip decrementing tries 2023-07-17 15:39:55 -04:00
abootimg.c android: boot: support boot image header version 3 and 4 2023-04-04 14:50:47 -04:00
acpi.c cmd: check argc for acpi dump 2023-12-13 18:39:06 -05:00
adc.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
addrmap.c
adtimg.c
aes.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
armffa.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
armflash.c arm: afs: Set the filesize env. var. on load 2023-12-20 10:46:54 -05:00
avb.c
axi.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
bcb.c cmd: bcb: extend BCB C API to allow read/write the fields 2023-11-16 18:59:58 -05:00
bdinfo.c cmd: bdinfo: Implement support for printing ethernet settings via bdinfo -e 2023-12-09 08:42:29 -05:00
bind.c cmd: bind: Try to improve the (un)bind help 2023-11-21 15:48:38 +01:00
binop.c
blk_common.c cmd: blk_common: Stop using hard-coded block size for Sandbox operations 2023-10-10 16:25:48 -04:00
blkcache.c blkcache: Remove unused NEEDS_MANUAL_RELOC code bits 2023-09-14 10:42:24 -04:00
blkmap.c cmd: blkmap: Make map_handlers[] and its .fn static 2023-10-10 16:25:48 -04:00
blob.c global: Migrate CONFIG_SYS_FSL* symbols to the CFG_SYS namespace 2022-11-10 10:08:55 -05:00
bloblist.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
bmp.c cmd: bmp: Split bmp commands and functions 2023-04-24 21:37:45 +02:00
boot.c boot: Call flush() before booting 2022-09-24 11:34:38 -04:00
bootcount.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
bootdev.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
bootefi.c cmd: bootefi: move library interfaces under lib/efi_loader 2023-12-17 13:04:54 +01:00
bootflow.c bootflow: Allow setting a cmdline arg with no value 2023-12-20 10:46:54 -05:00
booti.c bootm: Rename do_bootm_states() to bootm_run_states() 2023-12-21 16:07:52 -05:00
bootm.c bootm: Create a function to run through the bootm states 2023-12-21 16:07:52 -05:00
bootmenu.c Fix incorrect return code of boot option update 2023-07-15 11:20:41 +02:00
bootmeth.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
bootstage.c
bootz.c bootm: Create a function to run through the bootz states 2023-12-21 16:07:52 -05:00
btrfs.c treewide: Tidy up semicolon after command macros 2023-12-13 11:51:24 -05:00
button.c
cache.c
cat.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
cbfs.c binman: Rename TYPE_STAGE to TYPE_LEGACY_STAGE 2023-11-02 22:38:01 -04:00
cedit.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
cli.c Merge patch series "Modernize U-Boot shell" 2023-12-28 14:38:25 -05:00
clk.c cmd: clk: Make soc_clk_dump static 2023-12-15 13:05:55 -05:00
clone.c
cls.c video: Add a function to clear the display 2023-12-13 18:39:05 -05:00
config.c
conitrace.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
console.c cmd: consider multiplexing in coninfo 2023-04-08 07:50:43 +02:00
cpu.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
cramfs.c Audit <flash.h> inclusion 2022-08-04 16:18:47 -04:00
cros_ec.c Audit <flash.h> inclusion 2022-08-04 16:18:47 -04:00
cyclic.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
date.c cmd: date: Remove unused NEEDS_MANUAL_RELOC code bits 2023-09-14 10:42:24 -04:00
demo.c cmd: List all uclass devices regardless of probe error 2022-10-17 21:17:12 -06:00
dfu.c
diag.c
disk.c command: Introduce functions to obtain command arguments 2023-12-13 11:51:24 -05:00
dm.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
echo.c
eeprom.c treewide: Tidy up semicolon after command macros 2023-12-13 11:51:24 -05:00
efi.c efi: Support showing tables 2023-03-25 11:07:22 +01:00
efi_common.c efi: Correct display of table GUIDs 2023-12-05 01:38:56 +01:00
eficonfig.c cmd: eficonfig: create shortened boot options 2023-11-20 19:06:22 +01:00
eficonfig_sbkey.c eficonfig: refactor eficonfig_process_common function 2023-01-27 18:32:00 +01:00
efidebug.c cmd: efidebug: ease efi configuration dependency 2023-12-17 13:04:54 +01:00
elf.c boot: Call flush() before booting 2022-09-24 11:34:38 -04:00
erofs.c fs/erofs: add filesystem commands 2022-03-15 16:19:29 -04:00
ethsw.c
event.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
exit.c cmd: exit: Fix return value propagation out of environment scripts 2023-01-11 15:02:24 -05:00
ext2.c treewide: Tidy up semicolon after command macros 2023-12-13 11:51:24 -05:00
ext4.c
extension_board.c bootstd: Add a hunter for the extension feature 2023-01-23 18:11:41 -05:00
fastboot.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
fat.c
fdt.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
flash.c Audit <flash.h> inclusion 2022-08-04 16:18:47 -04:00
font.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
fpga.c treewide: Drop image_header_t typedef 2022-09-29 16:07:57 -04:00
fpgad.c common: Drop display_options.h from common header 2022-08-10 13:46:55 -04:00
fs.c treewide: Tidy up semicolon after command macros 2023-12-13 11:51:24 -05:00
fs_uuid.c
fuse.c command: Introduce functions to obtain command arguments 2023-12-13 11:51:24 -05:00
fwu_mdata.c fwu: rename fwu_get_verified_mdata to fwu_get_mdata 2023-06-09 13:52:40 -04:00
gettime.c
gpio.c cmd: gpio: Skip output on -ENOENT 2023-10-16 15:46:18 +02:00
gpt.c cmd: gpt: fix gpt read 2023-09-11 16:34:19 -04:00
hash.c
help.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
history.c cli: Add a command to show cmdline history 2023-10-11 15:43:54 -04:00
host.c cmd: host: Print out the block size of the host device 2023-10-10 16:25:48 -04:00
i2c.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
ide.c ide: Move ide_init() into probing 2023-04-27 13:51:06 -04:00
ini.c cmd: ini: Fix build warning 2023-07-28 18:45:03 +08:00
io.c common: Drop display_options.h from common header 2022-08-10 13:46:55 -04:00
iotrace.c
irq.c
itest.c
jffs2.c Audit <flash.h> inclusion 2022-08-04 16:18:47 -04:00
kaslrseed.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
Kconfig cmd: Set modern hush as default shell 2023-12-28 12:02:56 -05:00
led.c
legacy-mtd-utils.c cmd: sf/nand: Print and return failure when 0 length is passed 2023-06-12 13:24:31 +02:00
legacy-mtd-utils.h
legacy_led.c
license.c
load.c cmd: fix loads, saves on sandbox 2023-07-20 14:10:57 -06:00
log.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
lsblk.c blk: Rename if_type to uclass_id 2022-09-25 08:30:05 -06:00
lzmadec.c
Makefile cli: Enables using modern hush parser as command line parser 2023-12-28 12:02:56 -05:00
mbr.c cmd: mbr: Force DOS driver to be used for verify 2023-07-17 16:20:08 -04:00
md5sum.c
mdio.c
mem.c cmd: fix mtest on 64 bit systems 2023-01-27 18:31:58 +01:00
mii.c
misc.c cmd/misc: Stop using a function pointer 2022-06-22 21:29:47 -04:00
mmc.c command: Introduce functions to obtain command arguments 2023-12-13 11:51:24 -05:00
mp.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
mtd.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
mtdparts.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
mux.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
nand.c cmd: nand: Map memory before accessing it 2023-11-16 12:43:48 -05:00
net.c Prepare v2023.07-rc6 2023-07-05 11:28:55 -04:00
nvedit.c env: Move env_set() out of cmd/nvedit.c and in to env/common.c 2023-11-07 14:48:19 -05:00
nvedit_efi.c cmd: improve string matching for hex 2023-08-08 17:41:52 -04:00
nvme.c blk: Switch over to using uclass IDs 2022-09-16 11:05:16 -04:00
onenand.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
optee_rpmb.c
osd.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
panic.c
part.c cmd: part: Cover both part type entries with GUID ifdef 2023-12-20 14:13:20 -05:00
pause.c cmd: Add pause command 2022-09-02 13:40:42 -04:00
pcap.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
pci.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
pci_mps.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
pinmux.c treewide: Tidy up semicolon after command macros 2023-12-13 11:51:24 -05:00
pmc.c
pmic.c cmd: List all uclass devices regardless of probe error 2022-10-17 21:17:12 -06:00
printf.c cmd: setexpr: fix printf_str() 2023-08-23 08:02:59 +02:00
printf.h
pstore.c pstore: Use root address-cells/size-cells as defaults for reserved-memory 2023-10-24 16:34:45 -04:00
pvblock.c blk: Switch over to using uclass IDs 2022-09-16 11:05:16 -04:00
pwm.c cmd: pwm: fix typo 'eisable' -> 'disable' 2022-03-04 15:20:06 -05:00
pxe.c net: Get pxe config file from dhcp option 209 2023-11-05 13:28:40 -05:00
qfw.c treewide: Tidy up semicolon after command macros 2023-12-13 11:51:24 -05:00
read.c cmd: introduce 'write' command 2023-03-17 15:44:01 -04:00
reginfo.c
regulator.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
reiser.c
remoteproc.c tree-wide: Replace http:// link with https:// link for ti.com 2023-11-10 11:01:50 -05:00
rkmtd.c rockchip: cmd: add rkmtd command 2023-10-24 15:55:17 +08:00
rng.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
rockusb.c cmd: rockusb: Use plain udevice for UDC controller interaction 2023-09-15 23:38:01 +02:00
rtc.c common: Drop display_options.h from common header 2022-08-10 13:46:55 -04:00
sata.c blk: Switch over to using uclass IDs 2022-09-16 11:05:16 -04:00
sb.c
scmi.c cmd: add scmi command for SCMI firmware 2023-11-28 22:31:03 -05:00
scp03.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
scsi.c scsi: Forceably finish migration to DM_SCSI 2023-11-07 18:36:06 -05:00
seama.c cmd: Add a SEAMA image load command 2023-02-06 17:10:15 -05:00
setexpr.c setexpr: Silence some diagnostic messages 2023-08-30 17:56:21 -04:00
sf.c mtd: spi-nor: Add spi flash lock config option 2023-11-07 13:47:08 +01:00
sha1sum.c
sleep.c
smccc.c cmd: smccc: Print results in hex instead of dec 2023-03-09 13:15:00 +01:00
sound.c cmd: avoid endless loop in sound play command 2023-01-04 13:17:42 +01:00
source.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
spi.c cmd: spi: Judge the number of added parameters 2023-01-12 11:25:17 -05:00
spl.c
sqfs.c
stackprot_test.c
strings.c
sysboot.c net: dhcp6: pxe: Add DHCP/PXE commands for IPv6 2023-05-05 17:48:44 -04:00
temperature.c cmd: add temperature command 2022-10-11 15:40:48 -04:00
terminal.c
test.c
thordown.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
time.c
timer.c
tlv_eeprom.c common: add prototype & rename populate_serial_number() 2023-10-23 17:07:06 +03:00
tpm-common.c tpm: Add 'tpm autostart' shell command 2023-06-13 08:51:07 +03:00
tpm-user-utils.h tpm: Add 'tpm autostart' shell command 2023-06-13 08:51:07 +03:00
tpm-v1.c tpm: Fix autostart for TPM1.2 devices 2023-09-09 06:12:47 +02:00
tpm-v2.c tpm: Add 'tpm autostart' shell command 2023-06-13 08:51:07 +03:00
tpm_test.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
trace.c
tsi148.c
ubi.c cmd: ubi: Fix 'ubi list' command arguments parsing 2023-08-15 07:32:13 +02:00
ubifs.c ubifs: allow loading to above 4GiB 2023-06-06 10:37:25 +02:00
ufs.c Merge patch series "ufs: Add a PCI UFS controller support" 2023-11-27 16:19:09 -05:00
universe.c
unlz4.c
unzip.c
usb.c cmd: usb: Prevent reset in usb tree/info command 2023-06-21 13:08:30 +02:00
usb_gadget_sdp.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
usb_mass_storage.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
vbe.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
version.c version: Separate our version string from the version command 2023-11-07 14:48:19 -05:00
video.c video: Move the console commands to cmd/ 2022-10-30 19:55:22 +01:00
virtio.c dm: treewide: Do not use the return value of simple uclass iterator 2022-10-29 07:36:33 -06:00
w1.c
wdt.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
wol.c
ximg.c imxtract: specify max gunzip size 2023-12-20 09:48:16 -05:00
xxd.c cmd: Convert existing long help messages to the new macro 2023-10-16 10:24:58 -04:00
yaffs2.c
zfs.c
zip.c