diff options
Diffstat (limited to 'doc/usage')
-rw-r--r-- | doc/usage/cmd/setexpr.rst | 5 | ||||
-rw-r--r-- | doc/usage/cmd/sntp.rst | 72 | ||||
-rw-r--r-- | doc/usage/cmd/test.rst | 102 | ||||
-rw-r--r-- | doc/usage/environment.rst | 4 | ||||
-rw-r--r-- | doc/usage/index.rst | 2 |
5 files changed, 181 insertions, 4 deletions
diff --git a/doc/usage/cmd/setexpr.rst b/doc/usage/cmd/setexpr.rst index 593a0ea91e1..5bc37ae50fc 100644 --- a/doc/usage/cmd/setexpr.rst +++ b/doc/usage/cmd/setexpr.rst @@ -144,8 +144,9 @@ Configuration * The *setexpr* command is only available if CMD_SETEXPR=y. * The *setexpr fmt* sub-command is only available if CMD_SETEXPR_FMT=y. -* The *setexpr gsub* and *setexpr sub* sub-commands are only available if - CONFIG_REGEX=y. +* The *setexpr gsub* and *setexpr sub* sub-commands are only available + if CONFIG_REGEX=y. For an overview of the supported regex syntax, + see :doc:`test`. Return value ------------ diff --git a/doc/usage/cmd/sntp.rst b/doc/usage/cmd/sntp.rst new file mode 100644 index 00000000000..d97f83053f7 --- /dev/null +++ b/doc/usage/cmd/sntp.rst @@ -0,0 +1,72 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +.. index:: + single: sntp (command) + +sntp command +============ + +Synopsis +-------- + +:: + + sntp [serverip] + sntp [servername] # NET_LWIP=y && CMD_DNS=y only + + +Description +----------- + +The sntp command gets the current time from an NTP time server and +syncronizes the Real Time Clock (RTC) of the board. This command needs +the server's IP address to be given on the command line or via the +`ntpserverip` environment variable. + +The address of the NTP server does not need to be given if the DHCP server +provides one. The legacy network stack (`CONFIG_NET=y`) can only use the +first NTP server provided in the `ntp-servers` DHCP option. + +When the network stack is lwIP (`CONFIG_NET_LWIP=y`) and the dns command +is enabled (`CONFIG_CMD_DNS=y`), then the sntp command accepts a server +name as an argument. + +The network time is sent as UTC. So, if you want to set the RTC to any local +time different from UTC, you need to set the `timeoffset` environment variable. + +Round-trip delay compensation is not implemented/not enabled. In practice +this should not matter much given that the RTC API does not have sub-second +resolution, and round-trip times are typically 10 to 100 ms at most. + +Examples +-------- + +:: + + => setenv ntpserverip 109.190.177.205 + => date + Date: 2025-06-16 (Monday) Time: 15:19:35 + => date reset + Reset RTC... + Date: 2000-01-01 (Saturday) Time: 0:00:00 + => date + Date: 2000-01-01 (Saturday) Time: 0:00:03 + => sntp + Date: 2025-06-16 Time: 15:19:43 + => date + Date: 2025-06-16 (Monday) Time: 15:19:47 + => setenv timeoffset 7200 + => sntp + Date: 2025-06-16 Time: 17:19:55 + => date + Date: 2025-06-16 (Monday) Time: 17:19:57 + +With `CONFIG_NET_LWIP=y` and `CONFIG_CMD_DNS=y`: + +:: + + => date reset + Reset RTC... + Date: 2000-01-01 (Saturday) Time: 0:00:00 + => sntp 0.us.pool.ntp.org + Date: 2025-06-16 Time: 15:10:59 diff --git a/doc/usage/cmd/test.rst b/doc/usage/cmd/test.rst new file mode 100644 index 00000000000..d1379117fca --- /dev/null +++ b/doc/usage/cmd/test.rst @@ -0,0 +1,102 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +.. index:: + single: test (command) + +test command +============ + +Synopsis +-------- + +:: + + test <str-op> <s> + test <s1> <str-cmp> <s2> + test <n1> <num-cmp> <n2> + test ! <expr> + test <expr1> -o <expr2> + test <expr1> -a <expr2> + test -e <interface> <dev[:part]> <path> + test <s> =~ <re> + +Description +----------- + +The ``test`` command is similar to the ordinary shell built-in by the +same name. Unlike in ordinary shells, it cannot be spelled ``[``. + +Strings +~~~~~~~ + +The string tests ``-n`` and ``-z``, and string comparison operators +``=``, ``!=``, ``<`` and ``>``, work exactly as in ordinary shells. + +Numbers +~~~~~~~ + +The number comparison operators ``-lt``, ``-le``, ``-gt``, ``-gt``, +``-eq`` and ``-ne`` work as in ordinary shells. + +.. note:: + Numbers are parsed with ``simple_strtol(, 0)``, meaning that they + are treated as decimal unless there is a `0x` prefix, any errors in + parsing are ignored, and parsing stops as soon as a non-digit (for + the selected base) is encountered. And most U-Boot commands that + generate "numeric" environment variables store them as hexadecimal + *without* a `0x` prefix. + +For example, this is not a correct way of testing whether a given file +has a size less than 4KiB:: + + # Assuming readme.txt exists, sets 'filesize' environment variable + $ size mmc 0:1 readme.txt + $ if test "$filesize" -lt 4096 ; then ... + +If the file size is actually 8000 (decimal), its hexadecimal +representation, and thus the value of ``$filesize``, is ``1f40``, so +the comparison that is done ends up being "1 < 4096". + +Logic +~~~~~ + +The ``!`` operator negates the sense of the test of the expression +``<expr>``. + +The ``-o`` and ``-a`` operators perform logical OR and logical AND, +respectively, of the two expressions. + +File existence +~~~~~~~~~~~~~~ + +Like ordinary shells, the ``-e`` operator can be used to test for +existence of a file. However, the U-Boot version takes three +arguments: + +- The interface (e.g. ``mmc``). +- The device number, possibly including a partition specification. +- The usual path argument, which is interpreted relative to the root + of the filesystem. + +Regular expressions +~~~~~~~~~~~~~~~~~~~ + +When ``CONFIG_REGEX`` is enabled, an additional operator ``=~`` is +available. This is similar to the same operator available with bash's +extended test command ``[[ ]]``. The left operand is a string which is +matched against the regular expression described by the right operand. + +The regular expression engine supports these features: + +- Anchoring ``^`` and ``$``, matching at the beginning/end of the + string. +- Matching any single character (including whitespace) using ``.``. +- Character classes ``[ ]``, including ranges ``[0-9]`` and negation + ``[^ /.]``. +- Grouping ``( )``. +- Alternation ``|``. +- Postfix qualifiers ``*``, ``+`` and ``?`` and their non-greedy + variants ``*?``, ``+?`` and ``??`` + +For extracting the parts matching a capture group and/or performing +substitutions, including back references, see :doc:`setexpr`. diff --git a/doc/usage/environment.rst b/doc/usage/environment.rst index 7e2f2863d06..bb6c351b441 100644 --- a/doc/usage/environment.rst +++ b/doc/usage/environment.rst @@ -562,8 +562,8 @@ only effect after the next boot (yes, that's just like Windows). External environment file ------------------------- -The `CONFIG_USE_DEFAULT_ENV_FILE` option provides a way to bypass the -environment generation in U-Boot. If enabled, then `CONFIG_DEFAULT_ENV_FILE` +The `CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE` option provides a way to bypass the +environment generation in U-Boot. If enabled, then `CONFIG_ENV_DEFAULT_ENV_TEXT_FILE` provides the name of a file which is converted into the environment, completely bypassing the standard environment variables in `env_default.h`. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 372ef56c967..e9e0bd04e05 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -119,10 +119,12 @@ Shell commands cmd/sleep cmd/sm cmd/smbios + cmd/sntp cmd/sound cmd/source cmd/tcpm cmd/temperature + cmd/test cmd/tftpput cmd/trace cmd/true |