Merge branch '2022-10-11-assorted-fixes-and-updates'

- Assorted code cleanups and fixes, along with two new commands.
This commit is contained in:
Tom Rini 2022-10-11 17:35:42 -04:00
commit 8db1fa5a0d
37 changed files with 749 additions and 57 deletions

View file

@ -786,6 +786,11 @@ M: Simon Glass <sjg@chromium.org>
S: Maintained
F: tools/buildman/
CAT
M: Roger Knecht <rknecht@pm.me>
S: Maintained
F: cmd/cat.c
CFI FLASH
M: Stefan Roese <sr@denx.de>
S: Maintained
@ -1514,6 +1519,13 @@ M: Max Filippov <jcmvbkbc@gmail.com>
S: Maintained
F: arch/xtensa/
XXD
M: Roger Knecht <rknecht@pm.me>
S: Maintained
F: cmd/xxd.c
F: doc/usage/cmd/xxd.rst
F: test/py/tests/test_xxd/
THE REST
M: Tom Rini <trini@konsulko.com>
L: u-boot@lists.denx.de

View file

@ -443,6 +443,10 @@
sandbox_tee {
compatible = "sandbox,tee";
};
thermal {
compatible = "sandbox,thermal";
};
};
&cros_ec {

View file

@ -1694,6 +1694,10 @@
compatible = "sandbox,regmap_test";
};
};
thermal {
compatible = "sandbox,thermal";
};
};
#include "sandbox_pmic.dtsi"

View file

@ -11,49 +11,6 @@ DECLARE_GLOBAL_DATA_PTR;
#include <u-boot/sha256.h>
#define IMAGE_PRE_LOAD_SIG_MAGIC 0x55425348
#define IMAGE_PRE_LOAD_SIG_OFFSET_MAGIC 0
#define IMAGE_PRE_LOAD_SIG_OFFSET_IMG_LEN 4
#define IMAGE_PRE_LOAD_SIG_OFFSET_SIG 8
#define IMAGE_PRE_LOAD_PATH "/image/pre-load/sig"
#define IMAGE_PRE_LOAD_PROP_ALGO_NAME "algo-name"
#define IMAGE_PRE_LOAD_PROP_PADDING_NAME "padding-name"
#define IMAGE_PRE_LOAD_PROP_SIG_SIZE "signature-size"
#define IMAGE_PRE_LOAD_PROP_PUBLIC_KEY "public-key"
#define IMAGE_PRE_LOAD_PROP_MANDATORY "mandatory"
/*
* Information in the device-tree about the signature in the header
*/
struct image_sig_info {
char *algo_name; /* Name of the algo (eg: sha256,rsa2048) */
char *padding_name; /* Name of the padding */
u8 *key; /* Public signature key */
int key_len; /* Length of the public key */
u32 sig_size; /* size of the signature (in the header) */
int mandatory; /* Set if the signature is mandatory */
struct image_sign_info sig_info; /* Signature info */
};
/*
* Header of the signature header
*/
struct sig_header_s {
u32 magic;
u32 version;
u32 header_size;
u32 image_size;
u32 offset_img_sig;
u32 flags;
u32 reserved0;
u32 reserved1;
u8 sha256_img_sig[SHA256_SUM_LEN];
};
#define SIG_HEADER_LEN (sizeof(struct sig_header_s))
/*
* Offset of the image
*
@ -76,6 +33,7 @@ static int image_pre_load_sig_setup(struct image_sig_info *info)
const u32 *sig_size;
int key_len;
int node, ret = 0;
char *sig_info_path = NULL;
if (!info) {
log_err("ERROR: info is NULL for image pre-load sig check\n");
@ -85,7 +43,11 @@ static int image_pre_load_sig_setup(struct image_sig_info *info)
memset(info, 0, sizeof(*info));
node = fdt_path_offset(gd_fdt_blob(), IMAGE_PRE_LOAD_PATH);
sig_info_path = env_get("pre_load_sig_info_path");
if (!sig_info_path)
sig_info_path = IMAGE_PRE_LOAD_PATH;
node = fdt_path_offset(gd_fdt_blob(), sig_info_path);
if (node < 0) {
log_info("INFO: no info for image pre-load sig check\n");
ret = 1;

View file

@ -380,6 +380,7 @@ err:
/**
* label_boot_fdtoverlay() - Loads fdt overlays specified in 'fdtoverlays'
* or 'devicetree-overlay'
*
* @ctx: PXE context
* @label: Label to process
@ -809,6 +810,7 @@ static const struct token keywords[] = {
{"devicetreedir", T_FDTDIR},
{"fdtdir", T_FDTDIR},
{"fdtoverlays", T_FDTOVERLAYS},
{"devicetree-overlay", T_FDTOVERLAYS},
{"ontimeout", T_ONTIMEOUT,},
{"ipappend", T_IPAPPEND,},
{"background", T_BACKGROUND,},

View file

@ -469,6 +469,11 @@ config CMD_XIMG
help
Extract a part of a multi-image.
config CMD_XXD
bool "xxd"
help
Print file as hexdump to standard output
config CMD_SPL
bool "spl export - Export boot information for Falcon boot"
depends on SPL
@ -1449,6 +1454,12 @@ config DEFAULT_SPI_MODE
depends on CMD_SPI
default 0
config CMD_TEMPERATURE
bool "temperature - display the temperature from thermal sensors"
depends on DM_THERMAL
help
Provides a way to list thermal sensors and to get their readings.
config CMD_TSI148
bool "tsi148 - Command to access tsi148 device"
help
@ -1533,6 +1544,11 @@ endmenu
menu "Shell scripting commands"
config CMD_CAT
bool "cat"
help
Print file to standard output
config CMD_ECHO
bool "echo"
default y

View file

@ -38,6 +38,7 @@ obj-$(CONFIG_CMD_BOOTZ) += bootz.o
obj-$(CONFIG_CMD_BOOTI) += booti.o
obj-$(CONFIG_CMD_BTRFS) += btrfs.o
obj-$(CONFIG_CMD_BUTTON) += button.o
obj-$(CONFIG_CMD_CAT) += cat.o
obj-$(CONFIG_CMD_CACHE) += cache.o
obj-$(CONFIG_CMD_CBFS) += cbfs.o
obj-$(CONFIG_CMD_CLK) += clk.o
@ -155,6 +156,7 @@ obj-$(CONFIG_CMD_STRINGS) += strings.o
obj-$(CONFIG_CMD_SMC) += smccc.o
obj-$(CONFIG_CMD_SYSBOOT) += sysboot.o
obj-$(CONFIG_CMD_STACKPROTECTOR_TEST) += stackprot_test.o
obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o
obj-$(CONFIG_CMD_TERMINAL) += terminal.o
obj-$(CONFIG_CMD_TIME) += time.o
obj-$(CONFIG_CMD_TIMER) += timer.o
@ -184,6 +186,7 @@ obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o
obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o
obj-$(CONFIG_CMD_VBE) += vbe.o
obj-$(CONFIG_CMD_XIMG) += ximg.o
obj-$(CONFIG_CMD_XXD) += xxd.o
obj-$(CONFIG_CMD_YAFFS2) += yaffs2.o
obj-$(CONFIG_CMD_SPL) += spl.o
obj-$(CONFIG_CMD_W1) += w1.o

85
cmd/cat.c Normal file
View file

@ -0,0 +1,85 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2022
* Roger Knecht <rknecht@pm.de>
*/
#include <common.h>
#include <command.h>
#include <fs.h>
#include <malloc.h>
#include <mapmem.h>
static int do_cat(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
char *ifname;
char *dev;
char *file;
char *buffer;
phys_addr_t addr;
loff_t file_size;
if (argc < 4)
return CMD_RET_USAGE;
ifname = argv[1];
dev = argv[2];
file = argv[3];
// check file exists
if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
return CMD_RET_FAILURE;
if (!fs_exists(file)) {
log_err("File does not exist: ifname=%s dev=%s file=%s\n", ifname, dev, file);
return CMD_RET_FAILURE;
}
// get file size
if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
return CMD_RET_FAILURE;
if (fs_size(file, &file_size)) {
log_err("Cannot read file size: ifname=%s dev=%s file=%s\n", ifname, dev, file);
return CMD_RET_FAILURE;
}
// allocate memory for file content
buffer = calloc(sizeof(char), file_size + 1);
if (!buffer) {
log_err("Out of memory\n");
return CMD_RET_FAILURE;
}
// map pointer to system memory
addr = map_to_sysmem(buffer);
// read file to memory
if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
return CMD_RET_FAILURE;
if (fs_read(file, addr, 0, 0, &file_size)) {
log_err("Cannot read file: ifname=%s dev=%s file=%s\n", ifname, dev, file);
return CMD_RET_FAILURE;
}
// print file content
buffer[file_size] = '\0';
puts(buffer);
free(buffer);
return 0;
}
#ifdef CONFIG_SYS_LONGHELP
static char cat_help_text[] =
"<interface> <dev[:part]> <file>\n"
" - Print file from 'dev' on 'interface' to standard output\n";
#endif
U_BOOT_CMD(cat, 4, 1, do_cat,
"Print file to standard output",
cat_help_text
);

85
cmd/temperature.c Normal file
View file

@ -0,0 +1,85 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2022 Sartura Ltd.
* Written by Robert Marko <robert.marko@sartura.hr>
*/
#include <common.h>
#include <command.h>
#include <dm.h>
#include <thermal.h>
#define LIMIT_DEVNAME 30
static int do_get(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
struct udevice *dev;
int ret, temp;
if (argc < 2) {
printf("thermal device not selected\n");
return CMD_RET_FAILURE;
}
ret = uclass_get_device_by_name(UCLASS_THERMAL, argv[1], &dev);
if (ret) {
printf("thermal device not found\n");
return CMD_RET_FAILURE;
}
ret = thermal_get_temp(dev, &temp);
if (ret)
return CMD_RET_FAILURE;
printf("%s: %d C\n", dev->name, temp);
return CMD_RET_SUCCESS;
}
static int do_list(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
struct udevice *dev;
printf("| %-*.*s| %-*.*s| %s\n",
LIMIT_DEVNAME, LIMIT_DEVNAME, "Device",
LIMIT_DEVNAME, LIMIT_DEVNAME, "Driver",
"Parent");
uclass_foreach_dev_probe(UCLASS_THERMAL, dev) {
printf("| %-*.*s| %-*.*s| %s\n",
LIMIT_DEVNAME, LIMIT_DEVNAME, dev->name,
LIMIT_DEVNAME, LIMIT_DEVNAME, dev->driver->name,
dev->parent->name);
}
return CMD_RET_SUCCESS;
}
static struct cmd_tbl temperature_subcmd[] = {
U_BOOT_CMD_MKENT(list, 1, 1, do_list, "", ""),
U_BOOT_CMD_MKENT(get, 2, 1, do_get, "", ""),
};
static int do_temperature(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
struct cmd_tbl *cmd;
argc--;
argv++;
cmd = find_cmd_tbl(argv[0], temperature_subcmd, ARRAY_SIZE(temperature_subcmd));
if (!cmd || argc > cmd->maxargs)
return CMD_RET_USAGE;
return cmd->cmd(cmdtp, flag, argc, argv);
}
U_BOOT_CMD(temperature, CONFIG_SYS_MAXARGS, 1, do_temperature,
"thermal sensor temperature",
"list\t\tshow list of temperature sensors\n"
"get [thermal device name]\tprint temperature in degrees C"
);

85
cmd/xxd.c Normal file
View file

@ -0,0 +1,85 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2022
* Roger Knecht <rknecht@pm.de>
*/
#include <common.h>
#include <command.h>
#include <display_options.h>
#include <fs.h>
#include <malloc.h>
#include <mapmem.h>
static int do_xxd(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
char *ifname;
char *dev;
char *file;
char *buffer;
phys_addr_t addr;
loff_t file_size;
if (argc < 4)
return CMD_RET_USAGE;
ifname = argv[1];
dev = argv[2];
file = argv[3];
// check file exists
if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
return CMD_RET_FAILURE;
if (!fs_exists(file)) {
log_err("File does not exist: ifname=%s dev=%s file=%s\n", ifname, dev, file);
return CMD_RET_FAILURE;
}
// get file size
if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
return CMD_RET_FAILURE;
if (fs_size(file, &file_size)) {
log_err("Cannot read file size: ifname=%s dev=%s file=%s\n", ifname, dev, file);
return CMD_RET_FAILURE;
}
// allocate memory for file content
buffer = calloc(sizeof(char), file_size);
if (!buffer) {
log_err("Out of memory\n");
return CMD_RET_FAILURE;
}
// map pointer to system memory
addr = map_to_sysmem(buffer);
// read file to memory
if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
return CMD_RET_FAILURE;
if (fs_read(file, addr, 0, 0, &file_size)) {
log_err("Cannot read file: ifname=%s dev=%s file=%s\n", ifname, dev, file);
return CMD_RET_FAILURE;
}
// print file content
print_buffer(0, buffer, sizeof(char), file_size, 0);
free(buffer);
return 0;
}
#ifdef CONFIG_SYS_LONGHELP
static char xxd_help_text[] =
"<interface> <dev[:part]> <file>\n"
" - Print file from 'dev' on 'interface' as hexdump to standard output\n";
#endif
U_BOOT_CMD(xxd, 4, 1, do_xxd,
"Print file as hexdump to standard output",
xxd_help_text
);

View file

@ -22,6 +22,7 @@ CONFIG_CONSOLE_RECORD=y
CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
CONFIG_PRE_CONSOLE_BUFFER=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_CMD_CAT=y
CONFIG_CMD_CPU=y
CONFIG_CMD_LICENSE=y
CONFIG_CMD_BOOTZ=y
@ -54,6 +55,7 @@ CONFIG_CMD_READ=y
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_CMD_USB=y
CONFIG_CMD_XXD=y
CONFIG_BOOTP_DNS2=y
CONFIG_CMD_TFTPPUT=y
CONFIG_CMD_TFTPSRV=y

View file

@ -36,6 +36,7 @@ CONFIG_LOG_DEFAULT_LEVEL=6
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_STACKPROTECTOR=y
CONFIG_ANDROID_AB=y
CONFIG_CMD_CAT=y
CONFIG_CMD_CPU=y
CONFIG_CMD_LICENSE=y
CONFIG_CMD_BOOTM_PRE_LOAD=y
@ -60,6 +61,7 @@ CONFIG_CMD_MEM_SEARCH=y
CONFIG_CMD_MX_CYCLIC=y
CONFIG_CMD_MEMTEST=y
CONFIG_CMD_UNZIP=y
CONFIG_CMD_XXD=y
CONFIG_CMD_BIND=y
CONFIG_CMD_DEMO=y
CONFIG_CMD_GPIO=y
@ -77,6 +79,7 @@ CONFIG_CMD_PCI=y
CONFIG_CMD_READ=y
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_CMD_TEMPERATURE=y
CONFIG_CMD_USB=y
CONFIG_CMD_AXI=y
CONFIG_CMD_SETEXPR_FMT=y
@ -279,6 +282,7 @@ CONFIG_SYSINFO=y
CONFIG_SYSINFO_SANDBOX=y
CONFIG_SYSINFO_GPIO=y
CONFIG_SYSRESET=y
CONFIG_DM_THERMAL=y
CONFIG_TIMER=y
CONFIG_TIMER_EARLY=y
CONFIG_SANDBOX_TIMER=y

View file

@ -45,6 +45,7 @@ CONFIG_CMD_OSD=y
CONFIG_CMD_PCI=y
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_CMD_TEMPERATURE=y
CONFIG_CMD_USB=y
CONFIG_BOOTP_DNS2=y
CONFIG_CMD_TFTPPUT=y
@ -186,6 +187,7 @@ CONFIG_SYSINFO=y
CONFIG_SYSINFO_SANDBOX=y
CONFIG_SYSINFO_GPIO=y
CONFIG_SYSRESET=y
CONFIG_DM_THERMAL=y
CONFIG_TIMER=y
CONFIG_TIMER_EARLY=y
CONFIG_SANDBOX_TIMER=y

View file

@ -62,6 +62,7 @@ CONFIG_CMD_OSD=y
CONFIG_CMD_PCI=y
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_CMD_TEMPERATURE=y
CONFIG_CMD_USB=y
CONFIG_BOOTP_DNS2=y
CONFIG_CMD_TFTPPUT=y
@ -213,6 +214,7 @@ CONFIG_SYSINFO_SANDBOX=y
CONFIG_SYSINFO_GPIO=y
CONFIG_SYSRESET=y
CONFIG_SPL_SYSRESET=y
CONFIG_DM_THERMAL=y
CONFIG_TIMER=y
CONFIG_TIMER_EARLY=y
CONFIG_SANDBOX_TIMER=y

View file

@ -62,6 +62,7 @@ CONFIG_CMD_OSD=y
CONFIG_CMD_PCI=y
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_CMD_TEMPERATURE=y
CONFIG_CMD_USB=y
CONFIG_BOOTP_DNS2=y
CONFIG_CMD_TFTPPUT=y
@ -216,6 +217,7 @@ CONFIG_SYSINFO_SANDBOX=y
CONFIG_SYSINFO_GPIO=y
CONFIG_SYSRESET=y
CONFIG_SPL_SYSRESET=y
CONFIG_DM_THERMAL=y
CONFIG_TIMER=y
CONFIG_TIMER_EARLY=y
CONFIG_SANDBOX_TIMER=y

View file

@ -74,6 +74,7 @@ CONFIG_CMD_OSD=y
CONFIG_CMD_PCI=y
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_CMD_TEMPERATURE=y
CONFIG_CMD_USB=y
CONFIG_BOOTP_DNS2=y
CONFIG_CMD_TFTPPUT=y
@ -223,6 +224,7 @@ CONFIG_SYSINFO_GPIO=y
CONFIG_SYSRESET=y
CONFIG_SPL_SYSRESET=y
CONFIG_TPL_SYSRESET=y
CONFIG_DM_THERMAL=y
CONFIG_TIMER=y
CONFIG_TIMER_EARLY=y
CONFIG_SANDBOX_TIMER=y

View file

@ -163,6 +163,13 @@ fdtoverlays <path> [...] - if this label is chosen, use tftp to retrieve the DT
and then applied in the load order to the fdt blob stored at the
address indicated in the fdt_addr_r environment variable.
devicetree-overlay <path> [...] - if this label is chosen, use tftp to retrieve the DT
overlay(s) at <path>. it will be temporarily stored at the
address indicated in the fdtoverlay_addr_r environment variable,
and then applied in the load order to the fdt blob stored at the
address indicated in the fdt_addr_r environment variable.
Alias for fdtoverlays.
kaslrseed - set this label to request random number from hwrng as kaslr seed.
append <string> - use <string> as the kernel command line when booting this
@ -178,6 +185,11 @@ fdt <path> - if this label is chosen, use tftp to retrieve the fdt blob
the fdt_addr_r environment variable, and that address will
be passed to bootm.
devicetree <path> - if this label is chosen, use tftp to retrieve the fdt blob
at <path>. it will be stored at the address indicated in
the fdt_addr_r environment variable, and that address will
be passed to bootm. Alias for fdt.
fdtdir <path> - if this label is chosen, use tftp to retrieve a fdt blob
relative to <path>. If the fdtfile environment variable
is set, <path>/<fdtfile> is retrieved. Otherwise, the

View file

@ -68,10 +68,10 @@ Boot Configuration Files
The standard format for boot configuration files is that of extlinux.conf, as
handled by U-Boot's "syslinux" (disk) or "pxe boot" (network). This is roughly
as specified at BootLoaderSpec_:
as specified at `Boot Loader Specification`_:
... with the exceptions that the BootLoaderSpec document:
... with the exceptions that the Boot Loader Specification document:
* Prescribes a separate configuration per boot menu option, whereas U-Boot
lumps all options into a single extlinux.conf file. Hence, U-Boot searches
@ -81,6 +81,8 @@ as specified at BootLoaderSpec_:
* Does not document the fdtdir option, which automatically selects the DTB to
pass to the kernel.
See also doc/README.pxe under 'pxe file format'.
One example extlinux.conf generated by the Fedora installer is::
# extlinux.conf generated by anaconda
@ -115,6 +117,25 @@ One example extlinux.conf generated by the Fedora installer is::
fdtdir /boot/dtb-3.16.0-0.rc6.git1.1.fc22.armv7hl+lpae
One example of hand-crafted extlinux.conf::
menu title Select kernel
timeout 100
label Arch with uart devicetree overlay
kernel /arch/Image.gz
initrd /arch/initramfs-linux.img
fdt /dtbs/arch/board.dtb
fdtoverlays /dtbs/arch/overlay/uart0-gpio0-1.dtbo
append console=ttyS0,115200 console=tty1 rw root=UUID=fc0d0284-ca84-4194-bf8a-4b9da8d66908
label Arch with uart devicetree overlay but with Boot Loader Specification keys
kernel /arch/Image.gz
initrd /arch/initramfs-linux.img
devicetree /dtbs/arch/board.dtb
devicetree-overlay /dtbs/arch/overlay/uart0-gpio0-1.dtbo
append console=ttyS0,115200 console=tty1 rw root=UUID=fc0d0284-ca84-4194-bf8a-4b9da8d66908
Another hand-crafted network boot configuration file is::
TIMEOUT 100
@ -214,6 +235,11 @@ fdt_addr_r:
A size of 1MB for the FDT/DTB seems reasonable.
fdtoverlay_addr_r:
Mandatory. The location in RAM where DTB overlays will be temporarily
stored and then applied in the load order to the fdt blob stored at the
address indicated in the fdt_addr_r environment variable.
fdtfile:
Mandatory. the name of the DTB file for the specific board for instance
the espressobin v5 board the value is "marvell/armada-3720-espressobin.dtb"
@ -408,7 +434,7 @@ way in future u-boot versions. In particular the <device type>_boot
variables (e.g. mmc_boot, usb_boot) are a strictly internal implementation
detail and must not be used as a public interface.
.. _BootLoaderSpec: http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
.. _`Boot Loader Specification`: https://systemd.io/BOOT_LOADER_SPECIFICATION/
.. sectionauthor:: (C) Copyright 2014 Red Hat Inc.
.. sectionauthor:: Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.

49
doc/usage/cmd/cat.rst Normal file
View file

@ -0,0 +1,49 @@
.. SPDX-License-Identifier: GPL-2.0+:
cat command
===============
Synopsis
--------
::
cat <interface> <dev[:part]> <file>
Description
-----------
The cat command prints the file content to standard out.
interface
interface for accessing the block device (mmc, sata, scsi, usb, ....)
dev
device number
part
partition number, defaults to 1
file
path to file
Example
-------
Here is the output for a example text file:
::
=> cat mmc 0:1 hello
hello world
=>
Configuration
-------------
The cat command is only available if CONFIG_CMD_CAT=y.
Return value
------------
The return value $? is set to 0 (true) if the file is readable, otherwise it returns a non-zero error code.

View file

@ -0,0 +1,50 @@
.. SPDX-License-Identifier: GPL-2.0-or-later
temperature command
===================
Synopsis
--------
::
temperature list
temperature get [thermal device name]
Description
-----------
The *temperature* command is used to list thermal sensors and get their
readings.
The 'temperature list' command diplays the available thermal devices.
The 'temperature get' command is used to get the reading in degrees C from
the desired device which is selected by passing its device name.
thermal device name
device name of thermal sensor to select
Example
-------
::
=> temperature list
| Device | Driver | Parent
| tmon@610508110 | sparx5-temp | axi@600000000
=>
=> temperature get tmon@610508110
tmon@610508110: 42 C
Configuration
-------------
The *temperature* command is only available if CONFIG_CMD_TEMPERATURE=y.
Return value
------------
The return value $? is set to 0 (true) if the command succeeded and to 1 (false)
otherwise.

50
doc/usage/cmd/xxd.rst Normal file
View file

@ -0,0 +1,50 @@
.. SPDX-License-Identifier: GPL-2.0+:
xxd command
===============
Synopsis
--------
::
xxd <interface> <dev[:part]> <file>
Description
-----------
The xxd command prints the file content as hexdump to standard out.
interface
interface for accessing the block device (mmc, sata, scsi, usb, ....)
dev
device number
part
partition number, defaults to 1
file
path to file
Example
-------
Here is the output for a example text file:
::
=> xxd mmc 0:1 hello
00000000: 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a 00 01 02 03 hello world.....
00000010: 04 05 ..
=>
Configuration
-------------
The xxd command is only available if CONFIG_CMD_XXD=y.
Return value
------------
The return value $? is set to 0 (true) if the file is readable, otherwise it returns a non-zero error code.

View file

@ -31,6 +31,7 @@ Shell commands
cmd/bootmeth
cmd/button
cmd/bootz
cmd/cat
cmd/cbsysinfo
cmd/cls
cmd/conitrace
@ -67,10 +68,12 @@ Shell commands
cmd/scp03
cmd/setexpr
cmd/size
cmd/temperature
cmd/tftpput
cmd/true
cmd/ums
cmd/wdt
cmd/xxd
Booting OS
----------

View file

@ -132,7 +132,7 @@ config DM_BOOTCOUNT_PMIC_PFUZE100
depends on DM_PMIC_PFUZE100
help
Enable support for the bootcounter using PMIC PFUZE100 registers.
This works only, if the PMIC is not connected.
This works only, if the PMIC is not connected to a battery.
config DM_BOOTCOUNT_SPI_FLASH
bool "Support SPI flash devices as a backing store for bootcount"

View file

@ -5,7 +5,7 @@
* Philip Oberfichtner <pro@denx.de>
*
* A bootcount driver using the registers MEMA - MEMD on the PFUZE100.
* This works only, if the PMIC is not connected.
* This works only, if the PMIC is not connected to a battery.
*/
#include <common.h>

View file

@ -1388,10 +1388,10 @@ static int npcm7xx_gpio_reset_persist(struct udevice *dev, unsigned int banknum,
dev_dbg(dev, "set gpio persist, bank %d, enable %d\n", banknum, enable);
if (enable) {
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD0RCR, BIT(num) | CA9C_RESET, 0);
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD1RCR, BIT(num) | CA9C_RESET, 0);
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD2RCR, BIT(num) | CA9C_RESET, 0);
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_CORSTC, BIT(num) | CA9C_RESET, 0);
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD0RCR, BIT(num), 0);
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD1RCR, BIT(num), 0);
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD2RCR, BIT(num), 0);
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_CORSTC, BIT(num), 0);
} else {
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD0RCR, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET);
regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD1RCR, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET);

View file

@ -237,7 +237,7 @@ enum pinmux_subnode_type {
static const char *alloc_name_with_prefix(const char *name, const char *prefix)
{
if (prefix) {
char *name_with_prefix = malloc(strlen(prefix) + sizeof("pins"));
char *name_with_prefix = malloc(strlen(prefix) + strlen(name) + 1);
if (name_with_prefix)
sprintf(name_with_prefix, "%s%s", prefix, name);
return name_with_prefix;

View file

@ -4,6 +4,7 @@
# Author: Nitin Garg <nitin.garg@freescale.com>
obj-$(CONFIG_DM_THERMAL) += thermal-uclass.o
obj-$(CONFIG_SANDBOX) += thermal_sandbox.o
obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
obj-$(CONFIG_IMX_SCU_THERMAL) += imx_scu_thermal.o
obj-$(CONFIG_TI_DRA7_THERMAL) += ti-bandgap.o

View file

@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2022 Sartura Ltd.
* Written by Robert Marko <robert.marko@sartura.hr>
*
* Sandbox driver for the thermal uclass.
*/
#include <common.h>
#include <dm.h>
#include <thermal.h>
int sandbox_thermal_get_temp(struct udevice *dev, int *temp)
{
/* Simply return 100°C */
*temp = 100;
return 0;
}
static const struct dm_thermal_ops sandbox_thermal_ops = {
.get_temp = sandbox_thermal_get_temp,
};
static const struct udevice_id sandbox_thermal_ids[] = {
{ .compatible = "sandbox,thermal" },
{ }
};
U_BOOT_DRIVER(thermal_sandbox) = {
.name = "thermal-sandbox",
.id = UCLASS_THERMAL,
.of_match = sandbox_thermal_ids,
.ops = &sandbox_thermal_ops,
.flags = DM_FLAG_PRE_RELOC,
};

View file

@ -1421,6 +1421,49 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name);
*/
struct padding_algo *image_get_padding_algo(const char *name);
#define IMAGE_PRE_LOAD_SIG_MAGIC 0x55425348
#define IMAGE_PRE_LOAD_SIG_OFFSET_MAGIC 0
#define IMAGE_PRE_LOAD_SIG_OFFSET_IMG_LEN 4
#define IMAGE_PRE_LOAD_SIG_OFFSET_SIG 8
#define IMAGE_PRE_LOAD_PATH "/image/pre-load/sig"
#define IMAGE_PRE_LOAD_PROP_ALGO_NAME "algo-name"
#define IMAGE_PRE_LOAD_PROP_PADDING_NAME "padding-name"
#define IMAGE_PRE_LOAD_PROP_SIG_SIZE "signature-size"
#define IMAGE_PRE_LOAD_PROP_PUBLIC_KEY "public-key"
#define IMAGE_PRE_LOAD_PROP_MANDATORY "mandatory"
/*
* Information in the device-tree about the signature in the header
*/
struct image_sig_info {
char *algo_name; /* Name of the algo (eg: sha256,rsa2048) */
char *padding_name; /* Name of the padding */
uint8_t *key; /* Public signature key */
int key_len; /* Length of the public key */
uint32_t sig_size; /* size of the signature (in the header) */
int mandatory; /* Set if the signature is mandatory */
struct image_sign_info sig_info; /* Signature info */
};
/*
* Header of the signature header
*/
struct sig_header_s {
uint32_t magic;
uint32_t version;
uint32_t header_size;
uint32_t image_size;
uint32_t offset_img_sig;
uint32_t flags;
uint32_t reserved0;
uint32_t reserved1;
uint8_t sha256_img_sig[SHA256_SUM_LEN];
};
#define SIG_HEADER_LEN (sizeof(struct sig_header_s))
/**
* image_pre_load() - Manage pre load header
*

View file

@ -12,7 +12,6 @@ if CRYPT_PW
config CRYPT_PW_SHA256
bool "Provide sha256crypt"
select SHA256
select SHA256_ALGO
help
Enables support for the sha256crypt password-hashing algorithm.
The prefix is "$5$".

View file

@ -16,3 +16,4 @@ obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
obj-$(CONFIG_CMD_PINMUX) += pinmux.o
obj-$(CONFIG_CMD_PWM) += pwm.o
obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o

39
test/cmd/temperature.c Normal file
View file

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Executes tests for temperature command
*
* Copyright (C) 2022 Sartura Ltd.
*/
#include <common.h>
#include <command.h>
#include <dm.h>
#include <dm/test.h>
#include <test/test.h>
#include <test/ut.h>
static int dm_test_cmd_temperature(struct unit_test_state *uts)
{
struct udevice *dev;
ut_assertok(uclass_get_device(UCLASS_THERMAL, 0, &dev));
ut_assertnonnull(dev);
ut_assertok(console_record_reset_enable());
/* Test that "temperature list" shows the sandbox device */
ut_assertok(run_command("temperature list", 0));
ut_assert_nextline("| Device | Driver | Parent");
ut_assert_nextline("| thermal | thermal-sandbox | root_driver");
ut_assert_console_end();
/* Test that "temperature get thermal" returns expected value */
console_record_reset();
ut_assertok(run_command("temperature get thermal", 0));
ut_assert_nextline("thermal: 100 C");
ut_assert_console_end();
return 0;
}
DM_TEST(dm_test_cmd_temperature, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);

View file

@ -0,0 +1,35 @@
# SPDX-License-Identifier: GPL-2.0+
"""Fixture for cat command test
"""
import os
import shutil
from subprocess import check_call, CalledProcessError
import pytest
@pytest.fixture(scope='session')
def cat_data(u_boot_config):
"""Set up a file system to be used in cat tests
Args:
u_boot_config -- U-boot configuration.
"""
mnt_point = u_boot_config.persistent_data_dir + '/test_cat'
image_path = u_boot_config.persistent_data_dir + '/cat.img'
try:
os.mkdir(mnt_point, mode = 0o755)
with open(mnt_point + '/hello', 'w', encoding = 'ascii') as file:
file.write('hello world\n')
check_call(f'virt-make-fs --partition=gpt --size=+1M --type=vfat {mnt_point} {image_path}',
shell=True)
yield image_path
except CalledProcessError:
pytest.skip('Setup failed')
finally:
shutil.rmtree(mnt_point)
os.remove(image_path)

View file

@ -0,0 +1,20 @@
# SPDX-License-Identifier: GPL-2.0+
""" Unit test for cat command
"""
import pytest
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_cat')
def test_cat(u_boot_console, cat_data):
""" Unit test for cat
Args:
u_boot_console -- U-Boot console
cat_data -- Path to the disk image used for testing.
"""
response = u_boot_console.run_command_list([
f'host bind 0 {cat_data}',
'cat host 0 hello'])
assert 'hello world' in response

View file

@ -0,0 +1,35 @@
# SPDX-License-Identifier: GPL-2.0+
"""Fixture for xxd command test
"""
import os
import shutil
from subprocess import check_call, CalledProcessError
import pytest
@pytest.fixture(scope='session')
def xxd_data(u_boot_config):
"""Set up a file system to be used in xxd tests
Args:
u_boot_config -- U-boot configuration.
"""
mnt_point = u_boot_config.persistent_data_dir + '/test_xxd'
image_path = u_boot_config.persistent_data_dir + '/xxd.img'
try:
os.mkdir(mnt_point, mode = 0o755)
with open(mnt_point + '/hello', 'w', encoding = 'ascii') as file:
file.write('hello world\n\x00\x01\x02\x03\x04\x05')
check_call(f'virt-make-fs --partition=gpt --size=+1M --type=vfat {mnt_point} {image_path}',
shell=True)
yield image_path
except CalledProcessError:
pytest.skip('Setup failed')
finally:
shutil.rmtree(mnt_point)
os.remove(image_path)

View file

@ -0,0 +1,23 @@
# SPDX-License-Identifier: GPL-2.0+
""" Unit test for xxd command
"""
import pytest
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_xxd')
def test_xxd(u_boot_console, xxd_data):
""" Unit test for xxd
Args:
u_boot_console -- U-Boot console
xxd_data -- Path to the disk image used for testing.
"""
response = u_boot_console.run_command_list([
f'host bind 0 {xxd_data}',
'xxd host 0 hello'])
assert '00000000: 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a 00 01 02 03 hello world.....\r\r\n' + \
'00000010: 04 05 ..' \
in response

View file

@ -17,8 +17,6 @@
#include <openssl/pem.h>
#include <openssl/evp.h>
#define IMAGE_PRE_LOAD_PATH "/image/pre-load/sig"
/**
* fit_set_hash_value - set hash value in requested has node
* @fit: pointer to the FIT format image header