mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-07-11 09:02:52 +00:00
Merge branch '2022-02-11-assorted-updates-and-fixes'
A partial list: - fw_env updates, a new testcase for mkimage -o ..., nop-phy reset-gpios support, DFU updates, kaslr-seed support in extlinux.conf, modern "partitions" support in mtd device tree
This commit is contained in:
commit
dd1c255cbc
30 changed files with 527 additions and 211 deletions
4
Makefile
4
Makefile
|
@ -1843,7 +1843,7 @@ quiet_cmd_gen_envp = ENVP $@
|
||||||
-I$(srctree)/arch/$(ARCH)/include \
|
-I$(srctree)/arch/$(ARCH)/include \
|
||||||
$< -o $@; \
|
$< -o $@; \
|
||||||
else \
|
else \
|
||||||
echo -n >$@ ; \
|
touch $@ ; \
|
||||||
fi
|
fi
|
||||||
include/generated/env.in: include/generated/env.txt FORCE
|
include/generated/env.in: include/generated/env.txt FORCE
|
||||||
$(call cmd,gen_envp)
|
$(call cmd,gen_envp)
|
||||||
|
@ -1860,7 +1860,7 @@ quiet_cmd_envc = ENVC $@
|
||||||
elif [ -n "$(ENV_SOURCE_FILE)" ]; then \
|
elif [ -n "$(ENV_SOURCE_FILE)" ]; then \
|
||||||
echo "Missing file $(ENV_FILE_CFG)"; \
|
echo "Missing file $(ENV_FILE_CFG)"; \
|
||||||
else \
|
else \
|
||||||
echo -n >$@ ; \
|
touch $@ ; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE
|
include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
#ifndef __ASM_ACPI_TABLE_H__
|
#ifndef __ASM_ACPI_TABLE_H__
|
||||||
#define __ASM_ACPI_TABLE_H__
|
#define __ASM_ACPI_TABLE_H__
|
||||||
|
|
||||||
ulong write_acpi_tables(ulong start);
|
/* Empty for now, this file is required by acpi/acpi_table.h */
|
||||||
|
|
||||||
#endif /* __ASM_ACPI_TABLE_H__ */
|
#endif /* __ASM_ACPI_TABLE_H__ */
|
||||||
|
|
|
@ -64,8 +64,6 @@ int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
|
||||||
*/
|
*/
|
||||||
int acpi_create_gnvs(struct acpi_global_nvs *gnvs);
|
int acpi_create_gnvs(struct acpi_global_nvs *gnvs);
|
||||||
|
|
||||||
ulong write_acpi_tables(ulong start);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpi_get_rsdp_addr() - get ACPI RSDP table address
|
* acpi_get_rsdp_addr() - get ACPI RSDP table address
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_DM_RNG
|
||||||
|
#include <dm.h>
|
||||||
|
#include <rng.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <splash.h>
|
#include <splash.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
|
||||||
|
@ -311,6 +316,67 @@ static int label_localboot(struct pxe_label *label)
|
||||||
return run_command_list(localcmd, strlen(localcmd), 0);
|
return run_command_list(localcmd, strlen(localcmd), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* label_boot_kaslrseed generate kaslrseed from hw rng
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void label_boot_kaslrseed(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_DM_RNG
|
||||||
|
ulong fdt_addr;
|
||||||
|
struct fdt_header *working_fdt;
|
||||||
|
size_t n = 0x8;
|
||||||
|
struct udevice *dev;
|
||||||
|
u64 *buf;
|
||||||
|
int nodeoffset;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
/* Get the main fdt and map it */
|
||||||
|
fdt_addr = hextoul(env_get("fdt_addr_r"), NULL);
|
||||||
|
working_fdt = map_sysmem(fdt_addr, 0);
|
||||||
|
err = fdt_check_header(working_fdt);
|
||||||
|
if (err)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* add extra size for holding kaslr-seed */
|
||||||
|
/* err is new fdt size, 0 or negtive */
|
||||||
|
err = fdt_shrink_to_minimum(working_fdt, 512);
|
||||||
|
if (err <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
|
||||||
|
printf("No RNG device\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeoffset = fdt_find_or_add_subnode(working_fdt, 0, "chosen");
|
||||||
|
if (nodeoffset < 0) {
|
||||||
|
printf("Reading chosen node failed\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = malloc(n);
|
||||||
|
if (!buf) {
|
||||||
|
printf("Out of memory\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dm_rng_read(dev, buf, n)) {
|
||||||
|
printf("Reading RNG failed\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = fdt_setprop(working_fdt, nodeoffset, "kaslr-seed", buf, sizeof(buf));
|
||||||
|
if (err < 0) {
|
||||||
|
printf("Unable to set kaslr-seed on chosen node: %s\n", fdt_strerror(err));
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
err:
|
||||||
|
free(buf);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* label_boot_fdtoverlay() - Loads fdt overlays specified in 'fdtoverlays'
|
* label_boot_fdtoverlay() - Loads fdt overlays specified in 'fdtoverlays'
|
||||||
*
|
*
|
||||||
|
@ -631,6 +697,9 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (label->kaslrseed)
|
||||||
|
label_boot_kaslrseed();
|
||||||
|
|
||||||
#ifdef CONFIG_OF_LIBFDT_OVERLAY
|
#ifdef CONFIG_OF_LIBFDT_OVERLAY
|
||||||
if (label->fdtoverlays)
|
if (label->fdtoverlays)
|
||||||
label_boot_fdtoverlay(ctx, label);
|
label_boot_fdtoverlay(ctx, label);
|
||||||
|
@ -710,6 +779,7 @@ enum token_type {
|
||||||
T_ONTIMEOUT,
|
T_ONTIMEOUT,
|
||||||
T_IPAPPEND,
|
T_IPAPPEND,
|
||||||
T_BACKGROUND,
|
T_BACKGROUND,
|
||||||
|
T_KASLRSEED,
|
||||||
T_INVALID
|
T_INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -741,6 +811,7 @@ static const struct token keywords[] = {
|
||||||
{"ontimeout", T_ONTIMEOUT,},
|
{"ontimeout", T_ONTIMEOUT,},
|
||||||
{"ipappend", T_IPAPPEND,},
|
{"ipappend", T_IPAPPEND,},
|
||||||
{"background", T_BACKGROUND,},
|
{"background", T_BACKGROUND,},
|
||||||
|
{"kaslrseed", T_KASLRSEED,},
|
||||||
{NULL, T_INVALID}
|
{NULL, T_INVALID}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1194,6 +1265,10 @@ static int parse_label(char **c, struct pxe_menu *cfg)
|
||||||
err = parse_integer(c, &label->ipappend);
|
err = parse_integer(c, &label->ipappend);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_KASLRSEED:
|
||||||
|
label->kaslrseed = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case T_EOL:
|
case T_EOL:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
#ifdef CONFIG_DFU_OVER_USB
|
#ifdef CONFIG_DFU_OVER_USB
|
||||||
char *usb_controller = argv[1];
|
char *usb_controller = argv[1];
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP)
|
|
||||||
char *interface = NULL;
|
char *interface = NULL;
|
||||||
char *devstring = NULL;
|
char *devstring = NULL;
|
||||||
#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
|
#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
|
||||||
|
@ -42,7 +41,6 @@ static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
|
#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
|
||||||
if (argc == 5 || argc == 3)
|
if (argc == 5 || argc == 3)
|
||||||
value = simple_strtoul(argv[argc - 1], NULL, 0);
|
value = simple_strtoul(argv[argc - 1], NULL, 0);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -50,7 +48,6 @@ static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
if (!strcmp(argv[1], "tftp"))
|
if (!strcmp(argv[1], "tftp"))
|
||||||
return update_tftp(value, interface, devstring);
|
return update_tftp(value, interface, devstring);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_DFU_OVER_USB
|
|
||||||
ret = dfu_init_env_entities(interface, devstring);
|
ret = dfu_init_env_entities(interface, devstring);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -65,6 +62,7 @@ static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DFU_OVER_USB
|
||||||
int controller_index = simple_strtoul(usb_controller, NULL, 0);
|
int controller_index = simple_strtoul(usb_controller, NULL, 0);
|
||||||
bool retry = false;
|
bool retry = false;
|
||||||
do {
|
do {
|
||||||
|
@ -79,9 +77,9 @@ static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
}
|
}
|
||||||
} while (retry);
|
} while (retry);
|
||||||
|
|
||||||
|
#endif
|
||||||
done:
|
done:
|
||||||
dfu_free_entities();
|
dfu_free_entities();
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +98,8 @@ U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
|
||||||
#ifdef CONFIG_DFU_TIMEOUT
|
#ifdef CONFIG_DFU_TIMEOUT
|
||||||
" [<timeout>] - specify inactivity timeout in seconds\n"
|
" [<timeout>] - specify inactivity timeout in seconds\n"
|
||||||
#endif
|
#endif
|
||||||
" [list] - list available alt settings\n"
|
|
||||||
#endif
|
#endif
|
||||||
|
" [list] - list available alt settings\n"
|
||||||
#ifdef CONFIG_DFU_OVER_TFTP
|
#ifdef CONFIG_DFU_OVER_TFTP
|
||||||
#ifdef CONFIG_DFU_OVER_USB
|
#ifdef CONFIG_DFU_OVER_USB
|
||||||
"dfu "
|
"dfu "
|
||||||
|
|
|
@ -17,7 +17,8 @@ static int do_test_stackprot_fail(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
|
||||||
memset(a, 0xa5, 512);
|
memset(a, 0xa5, 512);
|
||||||
|
|
||||||
printf("We have smashed our stack as this should not exceed 128: sizeof(a) = %ld\n", strlen(a));
|
printf("We have smashed our stack as this should not exceed 128: sizeof(a) = %zd\n",
|
||||||
|
strlen(a));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -988,7 +988,7 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
|
||||||
{
|
{
|
||||||
struct mtd_device *dev;
|
struct mtd_device *dev;
|
||||||
int i, idx;
|
int i, idx;
|
||||||
int noff;
|
int noff, parts;
|
||||||
bool inited = false;
|
bool inited = false;
|
||||||
|
|
||||||
for (i = 0; i < node_info_size; i++) {
|
for (i = 0; i < node_info_size; i++) {
|
||||||
|
@ -1014,7 +1014,12 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
|
||||||
|
|
||||||
dev = device_find(node_info[i].type, idx++);
|
dev = device_find(node_info[i].type, idx++);
|
||||||
if (dev) {
|
if (dev) {
|
||||||
if (fdt_node_set_part_info(blob, noff, dev))
|
parts = fdt_subnode_offset(blob, noff,
|
||||||
|
"partitions");
|
||||||
|
if (parts < 0)
|
||||||
|
parts = noff;
|
||||||
|
|
||||||
|
if (fdt_node_set_part_info(blob, parts, dev))
|
||||||
return; /* return on error */
|
return; /* return on error */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ static void *alloc_simple(size_t bytes, int align)
|
||||||
|
|
||||||
addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
|
addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
|
||||||
new_ptr = addr + bytes - gd->malloc_base;
|
new_ptr = addr + bytes - gd->malloc_base;
|
||||||
log_debug("size=%zx, ptr=%lx, limit=%lx: ", bytes, new_ptr,
|
log_debug("size=%lx, ptr=%lx, limit=%lx: ", (ulong)bytes, new_ptr,
|
||||||
gd->malloc_limit);
|
gd->malloc_limit);
|
||||||
if (new_ptr > gd->malloc_limit) {
|
if (new_ptr > gd->malloc_limit) {
|
||||||
log_err("alloc space exhausted\n");
|
log_err("alloc space exhausted\n");
|
||||||
|
|
|
@ -163,6 +163,8 @@ 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
|
and then applied in the load order to the fdt blob stored at the
|
||||||
address indicated in the fdt_addr_r environment variable.
|
address indicated in the fdt_addr_r environment variable.
|
||||||
|
|
||||||
|
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
|
append <string> - use <string> as the kernel command line when booting this
|
||||||
label.
|
label.
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ CONFIG_OF_CONTROL in U-Boot.
|
||||||
.TP
|
.TP
|
||||||
.BI "\-o [" "signing algorithm" "]"
|
.BI "\-o [" "signing algorithm" "]"
|
||||||
Specifies the algorithm to be used for signing a FIT image. The default is
|
Specifies the algorithm to be used for signing a FIT image. The default is
|
||||||
taken from the target signature nodes 'algo' properties.
|
taken from the signature node's 'algo' property.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-p [" "external position" "]"
|
.BI "\-p [" "external position" "]"
|
||||||
|
|
|
@ -113,9 +113,9 @@ mmc
|
||||||
each element in *dfu_alt_info* being
|
each element in *dfu_alt_info* being
|
||||||
|
|
||||||
* <name> raw <offset> <size> [mmcpart <num>] raw access to mmc device
|
* <name> raw <offset> <size> [mmcpart <num>] raw access to mmc device
|
||||||
* <name> part <dev> <part_id> [mmcpart <num>] raw access to partition
|
* <name> part <dev> <part_id> [offset <byte>] raw access to partition
|
||||||
* <name> fat <dev> <part_id> [mmcpart <num>] file in FAT partition
|
* <name> fat <dev> <part_id> file in FAT partition
|
||||||
* <name> ext4 <dev> <part_id> [mmcpart <num>] file in EXT4 partition
|
* <name> ext4 <dev> <part_id> file in EXT4 partition
|
||||||
* <name> skip 0 0 ignore flashed data
|
* <name> skip 0 0 ignore flashed data
|
||||||
* <name> script 0 0 execute commands in shell
|
* <name> script 0 0 execute commands in shell
|
||||||
|
|
||||||
|
@ -169,14 +169,20 @@ nand
|
||||||
|
|
||||||
each element in *dfu_alt_info* being either of
|
each element in *dfu_alt_info* being either of
|
||||||
|
|
||||||
* <name> raw <offset> <size> raw access to mmc device
|
* <name> raw <offset> <size> raw access to nand device
|
||||||
* <name> part <dev> <part_id> raw acces to partition
|
* <name> part <dev_id> <part_id> raw access to partition
|
||||||
* <name> partubi <dev> <part_id> raw acces to ubi partition
|
* <name> partubi <dev_id> <part_id> raw access to ubi partition
|
||||||
|
|
||||||
with
|
with
|
||||||
|
|
||||||
partid
|
offset
|
||||||
is the MTD partition index
|
is the offset in the nand device (hexadecimal without "0x")
|
||||||
|
size
|
||||||
|
is the size of the access area (hexadecimal without "0x")
|
||||||
|
dev_id
|
||||||
|
is the NAND device index (decimal only)
|
||||||
|
part_id
|
||||||
|
is the NAND partition index (decimal only)
|
||||||
|
|
||||||
ram
|
ram
|
||||||
raw access to ram::
|
raw access to ram::
|
||||||
|
@ -190,6 +196,13 @@ ram
|
||||||
|
|
||||||
<name> ram <offset> <size> raw access to ram
|
<name> ram <offset> <size> raw access to ram
|
||||||
|
|
||||||
|
with
|
||||||
|
|
||||||
|
offset
|
||||||
|
is the offset in the ram device (hexadecimal without "0x")
|
||||||
|
size
|
||||||
|
is the size of the access area (hexadecimal without "0x")
|
||||||
|
|
||||||
sf
|
sf
|
||||||
serial flash : NOR::
|
serial flash : NOR::
|
||||||
|
|
||||||
|
@ -198,13 +211,19 @@ sf
|
||||||
each element in *dfu_alt_info* being either of:
|
each element in *dfu_alt_info* being either of:
|
||||||
|
|
||||||
* <name> raw <offset> <size> raw access to sf device
|
* <name> raw <offset> <size> raw access to sf device
|
||||||
* <name> part <dev> <part_id> raw acces to partition
|
* <name> part <dev_id> <part_id> raw acces to partition
|
||||||
* <name> partubi <dev> <part_id> raw acces to ubi partition
|
* <name> partubi <dev_id> <part_id> raw acces to ubi partition
|
||||||
|
|
||||||
with
|
with
|
||||||
|
|
||||||
partid
|
offset
|
||||||
is the MTD partition index
|
is the offset in the sf device (hexadecimal without "0x")
|
||||||
|
size
|
||||||
|
is the size of the access area (hexadecimal without "0x")
|
||||||
|
dev_id
|
||||||
|
is the sf device index (the device is "nor<dev_id>") (deximal only)
|
||||||
|
part_id
|
||||||
|
is the MTD partition index (decimal only)
|
||||||
|
|
||||||
mtd
|
mtd
|
||||||
all MTD device: NAND, SPI-NOR, SPI-NAND,...::
|
all MTD device: NAND, SPI-NOR, SPI-NAND,...::
|
||||||
|
@ -219,14 +238,18 @@ mtd
|
||||||
|
|
||||||
each element in *dfu_alt_info* being either of:
|
each element in *dfu_alt_info* being either of:
|
||||||
|
|
||||||
* <name> raw <offset> <size> forraw access to mtd device
|
* <name> raw <offset> <size> for raw access to mtd device
|
||||||
* <name> part <dev> <part_id> for raw acces to partition
|
* <name> part <part_id> for raw access to partition
|
||||||
* <name> partubi <dev> <part_id> for raw acces to ubi partition
|
* <name> partubi <part_id> for raw access to ubi partition
|
||||||
|
|
||||||
with
|
with
|
||||||
|
|
||||||
partid
|
offset
|
||||||
is the MTD partition index
|
is the offset in the mtd device (hexadecimal without "0x")
|
||||||
|
size
|
||||||
|
is the size of the access area (hexadecimal without "0x")
|
||||||
|
part_id
|
||||||
|
is the MTD partition index (decimal only)
|
||||||
|
|
||||||
virt
|
virt
|
||||||
virtual flash back end for DFU
|
virtual flash back end for DFU
|
||||||
|
|
|
@ -55,7 +55,7 @@ static int button_adc_of_to_plat(struct udevice *dev)
|
||||||
struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev);
|
struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev);
|
||||||
struct button_adc_priv *priv = dev_get_priv(dev);
|
struct button_adc_priv *priv = dev_get_priv(dev);
|
||||||
struct ofnode_phandle_args args;
|
struct ofnode_phandle_args args;
|
||||||
u32 threshold, up_threshold, t;
|
u32 down_threshold = 0, up_threshold, voltage, t;
|
||||||
ofnode node;
|
ofnode node;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ static int button_adc_of_to_plat(struct udevice *dev)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = ofnode_read_u32(dev_ofnode(dev), "press-threshold-microvolt",
|
ret = ofnode_read_u32(dev_ofnode(dev), "press-threshold-microvolt",
|
||||||
&threshold);
|
&voltage);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -87,13 +87,24 @@ static int button_adc_of_to_plat(struct udevice *dev)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (t > threshold)
|
if (t > voltage && t < up_threshold)
|
||||||
up_threshold = t;
|
up_threshold = t;
|
||||||
|
else if (t < voltage && t > down_threshold)
|
||||||
|
down_threshold = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->channel = args.args[0];
|
priv->channel = args.args[0];
|
||||||
priv->min = threshold;
|
|
||||||
priv->max = up_threshold;
|
/*
|
||||||
|
* Define the voltage range such that the button is only pressed
|
||||||
|
* when the voltage is closest to its own press-threshold-microvolt
|
||||||
|
*/
|
||||||
|
if (down_threshold == 0)
|
||||||
|
priv->min = 0;
|
||||||
|
else
|
||||||
|
priv->min = down_threshold + (voltage - down_threshold) / 2;
|
||||||
|
|
||||||
|
priv->max = voltage + (up_threshold - voltage) / 2;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,9 +123,10 @@ int dfu_config_interfaces(char *env)
|
||||||
s = env;
|
s = env;
|
||||||
while (s) {
|
while (s) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
i = strsep(&s, " ");
|
i = strsep(&s, " \t");
|
||||||
if (!i)
|
if (!i)
|
||||||
break;
|
break;
|
||||||
|
s = skip_spaces(s);
|
||||||
d = strsep(&s, "=");
|
d = strsep(&s, "=");
|
||||||
if (!d)
|
if (!d)
|
||||||
break;
|
break;
|
||||||
|
@ -499,11 +500,29 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
|
||||||
static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
|
static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
|
||||||
char *interface, char *devstr)
|
char *interface, char *devstr)
|
||||||
{
|
{
|
||||||
|
char *argv[DFU_MAX_ENTITY_ARGS];
|
||||||
|
int argc;
|
||||||
char *st;
|
char *st;
|
||||||
|
|
||||||
debug("%s: %s interface: %s dev: %s\n", __func__, s, interface, devstr);
|
debug("%s: %s interface: %s dev: %s\n", __func__, s, interface, devstr);
|
||||||
st = strsep(&s, " ");
|
st = strsep(&s, " \t");
|
||||||
strcpy(dfu->name, st);
|
strlcpy(dfu->name, st, DFU_NAME_SIZE);
|
||||||
|
|
||||||
|
/* Parse arguments */
|
||||||
|
for (argc = 0; s && argc < DFU_MAX_ENTITY_ARGS; argc++) {
|
||||||
|
s = skip_spaces(s);
|
||||||
|
if (!*s)
|
||||||
|
break;
|
||||||
|
argv[argc] = strsep(&s, " \t");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc == DFU_MAX_ENTITY_ARGS && s) {
|
||||||
|
s = skip_spaces(s);
|
||||||
|
if (*s) {
|
||||||
|
log_err("Too many arguments for %s\n", dfu->name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dfu->alt = alt;
|
dfu->alt = alt;
|
||||||
dfu->max_buf_size = 0;
|
dfu->max_buf_size = 0;
|
||||||
|
@ -511,22 +530,22 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
|
||||||
|
|
||||||
/* Specific for mmc device */
|
/* Specific for mmc device */
|
||||||
if (strcmp(interface, "mmc") == 0) {
|
if (strcmp(interface, "mmc") == 0) {
|
||||||
if (dfu_fill_entity_mmc(dfu, devstr, s))
|
if (dfu_fill_entity_mmc(dfu, devstr, argv, argc))
|
||||||
return -1;
|
return -1;
|
||||||
} else if (strcmp(interface, "mtd") == 0) {
|
} else if (strcmp(interface, "mtd") == 0) {
|
||||||
if (dfu_fill_entity_mtd(dfu, devstr, s))
|
if (dfu_fill_entity_mtd(dfu, devstr, argv, argc))
|
||||||
return -1;
|
return -1;
|
||||||
} else if (strcmp(interface, "nand") == 0) {
|
} else if (strcmp(interface, "nand") == 0) {
|
||||||
if (dfu_fill_entity_nand(dfu, devstr, s))
|
if (dfu_fill_entity_nand(dfu, devstr, argv, argc))
|
||||||
return -1;
|
return -1;
|
||||||
} else if (strcmp(interface, "ram") == 0) {
|
} else if (strcmp(interface, "ram") == 0) {
|
||||||
if (dfu_fill_entity_ram(dfu, devstr, s))
|
if (dfu_fill_entity_ram(dfu, devstr, argv, argc))
|
||||||
return -1;
|
return -1;
|
||||||
} else if (strcmp(interface, "sf") == 0) {
|
} else if (strcmp(interface, "sf") == 0) {
|
||||||
if (dfu_fill_entity_sf(dfu, devstr, s))
|
if (dfu_fill_entity_sf(dfu, devstr, argv, argc))
|
||||||
return -1;
|
return -1;
|
||||||
} else if (strcmp(interface, "virt") == 0) {
|
} else if (strcmp(interface, "virt") == 0) {
|
||||||
if (dfu_fill_entity_virt(dfu, devstr, s))
|
if (dfu_fill_entity_virt(dfu, devstr, argv, argc))
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
printf("%s: Device %s not (yet) supported!\n",
|
printf("%s: Device %s not (yet) supported!\n",
|
||||||
|
|
|
@ -337,34 +337,34 @@ void dfu_free_entity_mmc(struct dfu_entity *dfu)
|
||||||
* 4th (optional):
|
* 4th (optional):
|
||||||
* mmcpart <num> (access to HW eMMC partitions)
|
* mmcpart <num> (access to HW eMMC partitions)
|
||||||
*/
|
*/
|
||||||
int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
|
int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
|
||||||
{
|
{
|
||||||
const char *entity_type;
|
const char *entity_type;
|
||||||
ssize_t second_arg;
|
ssize_t second_arg;
|
||||||
size_t third_arg;
|
size_t third_arg;
|
||||||
|
|
||||||
struct mmc *mmc;
|
struct mmc *mmc;
|
||||||
|
char *s;
|
||||||
|
|
||||||
const char *argv[3];
|
if (argc < 3) {
|
||||||
const char **parg = argv;
|
pr_err("The number of parameters are not enough.\n");
|
||||||
|
return -EINVAL;
|
||||||
dfu->data.mmc.dev_num = dectoul(devstr, NULL);
|
|
||||||
|
|
||||||
for (; parg < argv + sizeof(argv) / sizeof(*argv); ++parg) {
|
|
||||||
*parg = strsep(&s, " ");
|
|
||||||
if (*parg == NULL) {
|
|
||||||
pr_err("Invalid number of arguments.\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dfu->data.mmc.dev_num = dectoul(devstr, &s);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
entity_type = argv[0];
|
entity_type = argv[0];
|
||||||
/*
|
/*
|
||||||
* Base 0 means we'll accept (prefixed with 0x or 0) base 16, 8,
|
* Base 0 means we'll accept (prefixed with 0x or 0) base 16, 8,
|
||||||
* with default 10.
|
* with default 10.
|
||||||
*/
|
*/
|
||||||
second_arg = simple_strtol(argv[1], NULL, 0);
|
second_arg = simple_strtol(argv[1], &s, 0);
|
||||||
third_arg = simple_strtoul(argv[2], NULL, 0);
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
third_arg = simple_strtoul(argv[2], &s, 0);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
mmc = find_mmc_device(dfu->data.mmc.dev_num);
|
mmc = find_mmc_device(dfu->data.mmc.dev_num);
|
||||||
if (mmc == NULL) {
|
if (mmc == NULL) {
|
||||||
|
@ -389,10 +389,14 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
* Check for an extra entry at dfu_alt_info env variable
|
* Check for an extra entry at dfu_alt_info env variable
|
||||||
* specifying the mmc HW defined partition number
|
* specifying the mmc HW defined partition number
|
||||||
*/
|
*/
|
||||||
if (s)
|
if (argc > 3) {
|
||||||
if (!strcmp(strsep(&s, " "), "mmcpart"))
|
if (argc != 5 || strcmp(argv[3], "mmcpart")) {
|
||||||
dfu->data.mmc.hw_partition =
|
pr_err("DFU mmc raw accept 'mmcpart <partnum>' option.\n");
|
||||||
simple_strtoul(s, NULL, 0);
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
dfu->data.mmc.hw_partition =
|
||||||
|
simple_strtoul(argv[4], NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (!strcmp(entity_type, "part")) {
|
} else if (!strcmp(entity_type, "part")) {
|
||||||
struct disk_partition partinfo;
|
struct disk_partition partinfo;
|
||||||
|
@ -411,13 +415,18 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
* Check for an extra entry at dfu_alt_info env variable
|
* Check for an extra entry at dfu_alt_info env variable
|
||||||
* specifying the mmc HW defined partition number
|
* specifying the mmc HW defined partition number
|
||||||
*/
|
*/
|
||||||
if (s)
|
if (argc > 3) {
|
||||||
if (!strcmp(strsep(&s, " "), "offset"))
|
if (argc != 5 || strcmp(argv[3], "offset")) {
|
||||||
offset = simple_strtoul(s, NULL, 0);
|
pr_err("DFU mmc raw accept 'mmcpart <partnum>' option.\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
dfu->data.mmc.hw_partition =
|
||||||
|
simple_strtoul(argv[4], NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
dfu->layout = DFU_RAW_ADDR;
|
dfu->layout = DFU_RAW_ADDR;
|
||||||
dfu->data.mmc.lba_start = partinfo.start + offset;
|
dfu->data.mmc.lba_start = partinfo.start + offset;
|
||||||
dfu->data.mmc.lba_size = partinfo.size-offset;
|
dfu->data.mmc.lba_size = partinfo.size - offset;
|
||||||
dfu->data.mmc.lba_blk_size = partinfo.blksz;
|
dfu->data.mmc.lba_blk_size = partinfo.blksz;
|
||||||
} else if (!strcmp(entity_type, "fat")) {
|
} else if (!strcmp(entity_type, "fat")) {
|
||||||
dfu->layout = DFU_FS_FAT;
|
dfu->layout = DFU_FS_FAT;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <mtd.h>
|
#include <mtd.h>
|
||||||
#include <jffs2/load_kernel.h>
|
#include <jffs2/load_kernel.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
|
#include <linux/ctype.h>
|
||||||
|
|
||||||
static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
|
static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
|
||||||
{
|
{
|
||||||
|
@ -270,9 +271,9 @@ static unsigned int dfu_polltimeout_mtd(struct dfu_entity *dfu)
|
||||||
return DFU_DEFAULT_POLL_TIMEOUT;
|
return DFU_DEFAULT_POLL_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
|
int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
|
||||||
{
|
{
|
||||||
char *st;
|
char *s;
|
||||||
struct mtd_info *mtd;
|
struct mtd_info *mtd;
|
||||||
int ret, part;
|
int ret, part;
|
||||||
|
|
||||||
|
@ -284,22 +285,33 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
dfu->dev_type = DFU_DEV_MTD;
|
dfu->dev_type = DFU_DEV_MTD;
|
||||||
dfu->data.mtd.info = mtd;
|
dfu->data.mtd.info = mtd;
|
||||||
dfu->max_buf_size = mtd->erasesize;
|
dfu->max_buf_size = mtd->erasesize;
|
||||||
|
if (argc < 1)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
st = strsep(&s, " ");
|
if (!strcmp(argv[0], "raw")) {
|
||||||
if (!strcmp(st, "raw")) {
|
if (argc != 3)
|
||||||
|
return -EINVAL;
|
||||||
dfu->layout = DFU_RAW_ADDR;
|
dfu->layout = DFU_RAW_ADDR;
|
||||||
dfu->data.mtd.start = hextoul(s, &s);
|
dfu->data.mtd.start = hextoul(argv[1], &s);
|
||||||
s++;
|
if (*s)
|
||||||
dfu->data.mtd.size = hextoul(s, &s);
|
return -EINVAL;
|
||||||
} else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
|
dfu->data.mtd.size = hextoul(argv[2], &s);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
} else if ((!strcmp(argv[0], "part")) || (!strcmp(argv[0], "partubi"))) {
|
||||||
char mtd_id[32];
|
char mtd_id[32];
|
||||||
struct mtd_device *mtd_dev;
|
struct mtd_device *mtd_dev;
|
||||||
u8 part_num;
|
u8 part_num;
|
||||||
struct part_info *pi;
|
struct part_info *pi;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
dfu->layout = DFU_RAW_ADDR;
|
dfu->layout = DFU_RAW_ADDR;
|
||||||
|
|
||||||
part = dectoul(s, &s);
|
part = dectoul(argv[1], &s);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
sprintf(mtd_id, "%s,%d", devstr, part - 1);
|
sprintf(mtd_id, "%s,%d", devstr, part - 1);
|
||||||
printf("using id '%s'\n", mtd_id);
|
printf("using id '%s'\n", mtd_id);
|
||||||
|
@ -314,10 +326,10 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
|
|
||||||
dfu->data.mtd.start = pi->offset;
|
dfu->data.mtd.start = pi->offset;
|
||||||
dfu->data.mtd.size = pi->size;
|
dfu->data.mtd.size = pi->size;
|
||||||
if (!strcmp(st, "partubi"))
|
if (!strcmp(argv[0], "partubi"))
|
||||||
dfu->data.mtd.ubi = 1;
|
dfu->data.mtd.ubi = 1;
|
||||||
} else {
|
} else {
|
||||||
printf("%s: Memory layout (%s) not supported!\n", __func__, st);
|
printf("%s: Memory layout (%s) not supported!\n", __func__, argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,20 +194,25 @@ unsigned int dfu_polltimeout_nand(struct dfu_entity *dfu)
|
||||||
return DFU_DEFAULT_POLL_TIMEOUT;
|
return DFU_DEFAULT_POLL_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s)
|
int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
|
||||||
{
|
{
|
||||||
char *st;
|
char *s;
|
||||||
int ret, dev, part;
|
int ret, dev, part;
|
||||||
|
|
||||||
dfu->data.nand.ubi = 0;
|
dfu->data.nand.ubi = 0;
|
||||||
dfu->dev_type = DFU_DEV_NAND;
|
dfu->dev_type = DFU_DEV_NAND;
|
||||||
st = strsep(&s, " ");
|
if (argc != 3)
|
||||||
if (!strcmp(st, "raw")) {
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!strcmp(argv[0], "raw")) {
|
||||||
dfu->layout = DFU_RAW_ADDR;
|
dfu->layout = DFU_RAW_ADDR;
|
||||||
dfu->data.nand.start = hextoul(s, &s);
|
dfu->data.nand.start = hextoul(argv[1], &s);
|
||||||
s++;
|
if (*s)
|
||||||
dfu->data.nand.size = hextoul(s, &s);
|
return -EINVAL;
|
||||||
} else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
|
dfu->data.nand.size = hextoul(argv[2], &s);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
} else if ((!strcmp(argv[0], "part")) || (!strcmp(argv[0], "partubi"))) {
|
||||||
char mtd_id[32];
|
char mtd_id[32];
|
||||||
struct mtd_device *mtd_dev;
|
struct mtd_device *mtd_dev;
|
||||||
u8 part_num;
|
u8 part_num;
|
||||||
|
@ -215,9 +220,12 @@ int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
|
|
||||||
dfu->layout = DFU_RAW_ADDR;
|
dfu->layout = DFU_RAW_ADDR;
|
||||||
|
|
||||||
dev = dectoul(s, &s);
|
dev = dectoul(argv[1], &s);
|
||||||
s++;
|
if (*s)
|
||||||
part = dectoul(s, &s);
|
return -EINVAL;
|
||||||
|
part = dectoul(argv[2], &s);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
sprintf(mtd_id, "%s%d,%d", "nand", dev, part - 1);
|
sprintf(mtd_id, "%s%d,%d", "nand", dev, part - 1);
|
||||||
debug("using id '%s'\n", mtd_id);
|
debug("using id '%s'\n", mtd_id);
|
||||||
|
@ -232,10 +240,10 @@ int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
|
|
||||||
dfu->data.nand.start = pi->offset;
|
dfu->data.nand.start = pi->offset;
|
||||||
dfu->data.nand.size = pi->size;
|
dfu->data.nand.size = pi->size;
|
||||||
if (!strcmp(st, "partubi"))
|
if (!strcmp(argv[0], "partubi"))
|
||||||
dfu->data.nand.ubi = 1;
|
dfu->data.nand.ubi = 1;
|
||||||
} else {
|
} else {
|
||||||
printf("%s: Memory layout (%s) not supported!\n", __func__, st);
|
printf("%s: Memory layout (%s) not supported!\n", __func__, argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,17 +54,13 @@ static int dfu_read_medium_ram(struct dfu_entity *dfu, u64 offset,
|
||||||
return dfu_transfer_medium_ram(DFU_OP_READ, dfu, offset, buf, len);
|
return dfu_transfer_medium_ram(DFU_OP_READ, dfu, offset, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr, char *s)
|
int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
|
||||||
{
|
{
|
||||||
const char *argv[3];
|
char *s;
|
||||||
const char **parg = argv;
|
|
||||||
|
|
||||||
for (; parg < argv + sizeof(argv) / sizeof(*argv); ++parg) {
|
if (argc != 3) {
|
||||||
*parg = strsep(&s, " ");
|
pr_err("Invalid number of arguments.\n");
|
||||||
if (*parg == NULL) {
|
return -EINVAL;
|
||||||
pr_err("Invalid number of arguments.\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dfu->dev_type = DFU_DEV_RAM;
|
dfu->dev_type = DFU_DEV_RAM;
|
||||||
|
@ -74,8 +70,12 @@ int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
dfu->layout = DFU_RAM_ADDR;
|
dfu->layout = DFU_RAM_ADDR;
|
||||||
dfu->data.ram.start = hextoul(argv[1], NULL);
|
dfu->data.ram.start = hextoul(argv[1], &s);
|
||||||
dfu->data.ram.size = hextoul(argv[2], NULL);
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
dfu->data.ram.size = hextoul(argv[2], &s);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
dfu->write_medium = dfu_write_medium_ram;
|
dfu->write_medium = dfu_write_medium_ram;
|
||||||
dfu->get_medium_size = dfu_get_medium_size_ram;
|
dfu->get_medium_size = dfu_get_medium_size_ram;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <spi_flash.h>
|
#include <spi_flash.h>
|
||||||
#include <jffs2/load_kernel.h>
|
#include <jffs2/load_kernel.h>
|
||||||
#include <linux/mtd/mtd.h>
|
#include <linux/mtd/mtd.h>
|
||||||
|
#include <linux/ctype.h>
|
||||||
|
|
||||||
static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size)
|
static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size)
|
||||||
{
|
{
|
||||||
|
@ -165,9 +166,9 @@ static struct spi_flash *parse_dev(char *devstr)
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
|
int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
|
||||||
{
|
{
|
||||||
char *st;
|
char *s;
|
||||||
char *devstr_bkup = strdup(devstr);
|
char *devstr_bkup = strdup(devstr);
|
||||||
|
|
||||||
dfu->data.sf.dev = parse_dev(devstr_bkup);
|
dfu->data.sf.dev = parse_dev(devstr_bkup);
|
||||||
|
@ -178,14 +179,18 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
dfu->dev_type = DFU_DEV_SF;
|
dfu->dev_type = DFU_DEV_SF;
|
||||||
dfu->max_buf_size = dfu->data.sf.dev->sector_size;
|
dfu->max_buf_size = dfu->data.sf.dev->sector_size;
|
||||||
|
|
||||||
st = strsep(&s, " ");
|
if (argc != 3)
|
||||||
if (!strcmp(st, "raw")) {
|
return -EINVAL;
|
||||||
|
if (!strcmp(argv[0], "raw")) {
|
||||||
dfu->layout = DFU_RAW_ADDR;
|
dfu->layout = DFU_RAW_ADDR;
|
||||||
dfu->data.sf.start = hextoul(s, &s);
|
dfu->data.sf.start = hextoul(argv[1], &s);
|
||||||
s++;
|
if (*s)
|
||||||
dfu->data.sf.size = hextoul(s, &s);
|
return -EINVAL;
|
||||||
|
dfu->data.sf.size = hextoul(argv[2], &s);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
|
} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
|
||||||
(!strcmp(st, "part") || !strcmp(st, "partubi"))) {
|
(!strcmp(argv[0], "part") || !strcmp(argv[0], "partubi"))) {
|
||||||
char mtd_id[32];
|
char mtd_id[32];
|
||||||
struct mtd_device *mtd_dev;
|
struct mtd_device *mtd_dev;
|
||||||
u8 part_num;
|
u8 part_num;
|
||||||
|
@ -194,9 +199,12 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
|
|
||||||
dfu->layout = DFU_RAW_ADDR;
|
dfu->layout = DFU_RAW_ADDR;
|
||||||
|
|
||||||
dev = dectoul(s, &s);
|
dev = dectoul(argv[1], &s);
|
||||||
s++;
|
if (*s)
|
||||||
part = dectoul(s, &s);
|
return -EINVAL;
|
||||||
|
part = dectoul(argv[2], &s);
|
||||||
|
if (*s)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
sprintf(mtd_id, "%s%d,%d", "nor", dev, part - 1);
|
sprintf(mtd_id, "%s%d,%d", "nor", dev, part - 1);
|
||||||
printf("using id '%s'\n", mtd_id);
|
printf("using id '%s'\n", mtd_id);
|
||||||
|
@ -210,10 +218,10 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
|
||||||
}
|
}
|
||||||
dfu->data.sf.start = pi->offset;
|
dfu->data.sf.start = pi->offset;
|
||||||
dfu->data.sf.size = pi->size;
|
dfu->data.sf.size = pi->size;
|
||||||
if (!strcmp(st, "partubi"))
|
if (!strcmp(argv[0], "partubi"))
|
||||||
dfu->data.sf.ubi = 1;
|
dfu->data.sf.ubi = 1;
|
||||||
} else {
|
} else {
|
||||||
printf("%s: Memory layout (%s) not supported!\n", __func__, st);
|
printf("%s: Memory layout (%s) not supported!\n", __func__, argv[0]);
|
||||||
spi_flash_free(dfu->data.sf.dev);
|
spi_flash_free(dfu->data.sf.dev);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,13 @@ int __weak dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char *s)
|
int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
|
||||||
{
|
{
|
||||||
debug("%s: devstr = %s\n", __func__, devstr);
|
debug("%s: devstr = %s\n", __func__, devstr);
|
||||||
|
|
||||||
|
if (argc != 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
dfu->dev_type = DFU_DEV_VIRT;
|
dfu->dev_type = DFU_DEV_VIRT;
|
||||||
dfu->layout = DFU_RAW_ADDR;
|
dfu->layout = DFU_RAW_ADDR;
|
||||||
dfu->data.virt.dev_num = dectoul(devstr, NULL);
|
dfu->data.virt.dev_num = dectoul(devstr, NULL);
|
||||||
|
|
|
@ -10,25 +10,54 @@
|
||||||
#include <dm/device.h>
|
#include <dm/device.h>
|
||||||
#include <dm/device_compat.h>
|
#include <dm/device_compat.h>
|
||||||
#include <generic-phy.h>
|
#include <generic-phy.h>
|
||||||
|
#include <asm-generic/gpio.h>
|
||||||
|
|
||||||
struct nop_phy_priv {
|
struct nop_phy_priv {
|
||||||
struct clk_bulk bulk;
|
struct clk_bulk bulk;
|
||||||
|
#if CONFIG_IS_ENABLED(DM_GPIO)
|
||||||
|
struct gpio_desc reset_gpio;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(DM_GPIO)
|
||||||
|
static int nop_phy_reset(struct phy *phy)
|
||||||
|
{
|
||||||
|
struct nop_phy_priv *priv = dev_get_priv(phy->dev);
|
||||||
|
|
||||||
|
/* Return if there is no gpio since it's optional */
|
||||||
|
if (!dm_gpio_is_valid(&priv->reset_gpio))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return dm_gpio_set_value(&priv->reset_gpio, false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int nop_phy_init(struct phy *phy)
|
static int nop_phy_init(struct phy *phy)
|
||||||
{
|
{
|
||||||
struct nop_phy_priv *priv = dev_get_priv(phy->dev);
|
struct nop_phy_priv *priv = dev_get_priv(phy->dev);
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (CONFIG_IS_ENABLED(CLK))
|
if (CONFIG_IS_ENABLED(CLK)) {
|
||||||
return clk_enable_bulk(&priv->bulk);
|
ret = clk_enable_bulk(&priv->bulk);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(DM_GPIO)
|
||||||
|
ret = nop_phy_reset(phy);
|
||||||
|
if (ret) {
|
||||||
|
if (CONFIG_IS_ENABLED(CLK))
|
||||||
|
clk_disable_bulk(&priv->bulk);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nop_phy_probe(struct udevice *dev)
|
static int nop_phy_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct nop_phy_priv *priv = dev_get_priv(dev);
|
struct nop_phy_priv *priv = dev_get_priv(dev);
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
if (CONFIG_IS_ENABLED(CLK)) {
|
if (CONFIG_IS_ENABLED(CLK)) {
|
||||||
ret = clk_get_bulk(dev, &priv->bulk);
|
ret = clk_get_bulk(dev, &priv->bulk);
|
||||||
|
@ -37,6 +66,13 @@ static int nop_phy_probe(struct udevice *dev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if CONFIG_IS_ENABLED(DM_GPIO)
|
||||||
|
ret = gpio_request_by_name(dev, "reset-gpios", 0,
|
||||||
|
&priv->reset_gpio,
|
||||||
|
GPIOD_IS_OUT);
|
||||||
|
#endif
|
||||||
|
if (ret != -ENOENT)
|
||||||
|
return ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +85,9 @@ static const struct udevice_id nop_phy_ids[] = {
|
||||||
|
|
||||||
static struct phy_ops nop_phy_ops = {
|
static struct phy_ops nop_phy_ops = {
|
||||||
.init = nop_phy_init,
|
.init = nop_phy_init,
|
||||||
|
#if CONFIG_IS_ENABLED(DM_GPIO)
|
||||||
|
.reset = nop_phy_reset,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
U_BOOT_DRIVER(nop_phy) = {
|
U_BOOT_DRIVER(nop_phy) = {
|
||||||
|
|
|
@ -913,6 +913,16 @@ void acpi_fill_header(struct acpi_table_header *header, char *signature);
|
||||||
*/
|
*/
|
||||||
int acpi_fill_csrt(struct acpi_ctx *ctx);
|
int acpi_fill_csrt(struct acpi_ctx *ctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* write_acpi_tables() - Write out the ACPI tables
|
||||||
|
*
|
||||||
|
* This writes all ACPI tables to the given address
|
||||||
|
*
|
||||||
|
* @start: Start address for the tables
|
||||||
|
* @return address of end of tables, where the next tables can be written
|
||||||
|
*/
|
||||||
|
ulong write_acpi_tables(ulong start);
|
||||||
|
|
||||||
#endif /* !__ACPI__*/
|
#endif /* !__ACPI__*/
|
||||||
|
|
||||||
#include <asm/acpi_table.h>
|
#include <asm/acpi_table.h>
|
||||||
|
|
|
@ -432,11 +432,15 @@ static inline void dfu_set_defer_flush(struct dfu_entity *dfu)
|
||||||
int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size);
|
int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size);
|
||||||
|
|
||||||
/* Device specific */
|
/* Device specific */
|
||||||
|
/* Each entity has 5 arguments in maximum. */
|
||||||
|
#define DFU_MAX_ENTITY_ARGS 5
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(DFU_MMC)
|
#if CONFIG_IS_ENABLED(DFU_MMC)
|
||||||
extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s);
|
extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
|
||||||
|
char **argv, int argc);
|
||||||
#else
|
#else
|
||||||
static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
|
static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
|
||||||
char *s)
|
char **argv, int argc)
|
||||||
{
|
{
|
||||||
puts("MMC support not available!\n");
|
puts("MMC support not available!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -444,10 +448,11 @@ static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(DFU_NAND)
|
#if CONFIG_IS_ENABLED(DFU_NAND)
|
||||||
extern int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s);
|
extern int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr,
|
||||||
|
char **argv, int argc);
|
||||||
#else
|
#else
|
||||||
static inline int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr,
|
static inline int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr,
|
||||||
char *s)
|
char **argv, int argc)
|
||||||
{
|
{
|
||||||
puts("NAND support not available!\n");
|
puts("NAND support not available!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -455,10 +460,11 @@ static inline int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(DFU_RAM)
|
#if CONFIG_IS_ENABLED(DFU_RAM)
|
||||||
extern int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr, char *s);
|
extern int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr,
|
||||||
|
char **argv, int argc);
|
||||||
#else
|
#else
|
||||||
static inline int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr,
|
static inline int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr,
|
||||||
char *s)
|
char **argv, int argc)
|
||||||
{
|
{
|
||||||
puts("RAM support not available!\n");
|
puts("RAM support not available!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -466,10 +472,11 @@ static inline int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(DFU_SF)
|
#if CONFIG_IS_ENABLED(DFU_SF)
|
||||||
extern int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s);
|
extern int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr,
|
||||||
|
char **argv, int argc);
|
||||||
#else
|
#else
|
||||||
static inline int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr,
|
static inline int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr,
|
||||||
char *s)
|
char **argv, int argc)
|
||||||
{
|
{
|
||||||
puts("SF support not available!\n");
|
puts("SF support not available!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -477,10 +484,11 @@ static inline int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(DFU_MTD)
|
#if CONFIG_IS_ENABLED(DFU_MTD)
|
||||||
int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s);
|
extern int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr,
|
||||||
|
char **argv, int argc);
|
||||||
#else
|
#else
|
||||||
static inline int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr,
|
static inline int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr,
|
||||||
char *s)
|
char **argv, int argc)
|
||||||
{
|
{
|
||||||
puts("MTD support not available!\n");
|
puts("MTD support not available!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -488,7 +496,8 @@ static inline int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_DFU_VIRT
|
#ifdef CONFIG_DFU_VIRT
|
||||||
int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char *s);
|
int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr,
|
||||||
|
char **argv, int argc);
|
||||||
int dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
|
int dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
|
||||||
void *buf, long *len);
|
void *buf, long *len);
|
||||||
int dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
|
int dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
|
||||||
|
@ -496,7 +505,7 @@ int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
|
||||||
void *buf, long *len);
|
void *buf, long *len);
|
||||||
#else
|
#else
|
||||||
static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr,
|
static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr,
|
||||||
char *s)
|
char **argv, int argc)
|
||||||
{
|
{
|
||||||
puts("VIRT support not available!\n");
|
puts("VIRT support not available!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
* initrd - path to the initrd to use for this label.
|
* initrd - path to the initrd to use for this label.
|
||||||
* attempted - 0 if we haven't tried to boot this label, 1 if we have.
|
* attempted - 0 if we haven't tried to boot this label, 1 if we have.
|
||||||
* localboot - 1 if this label specified 'localboot', 0 otherwise.
|
* localboot - 1 if this label specified 'localboot', 0 otherwise.
|
||||||
|
* kaslrseed - 1 if generate kaslrseed from hw_rng
|
||||||
* list - lets these form a list, which a pxe_menu struct will hold.
|
* list - lets these form a list, which a pxe_menu struct will hold.
|
||||||
*/
|
*/
|
||||||
struct pxe_label {
|
struct pxe_label {
|
||||||
|
@ -50,6 +51,7 @@ struct pxe_label {
|
||||||
int attempted;
|
int attempted;
|
||||||
int localboot;
|
int localboot;
|
||||||
int localboot_val;
|
int localboot_val;
|
||||||
|
int kaslrseed;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ test_tests_test_tpm2.py 8.51
|
||||||
test_tests_test_ums.py 6.32
|
test_tests_test_ums.py 6.32
|
||||||
test_tests_test_unknown_cmd.py 5.00
|
test_tests_test_unknown_cmd.py 5.00
|
||||||
test_tests_test_ut.py 7.06
|
test_tests_test_ut.py 7.06
|
||||||
test_tests_test_vboot.py 6.08
|
test_tests_test_vboot.py 6.01
|
||||||
test_tests_vboot_evil.py 8.95
|
test_tests_vboot_evil.py 8.95
|
||||||
test_tests_vboot_forge.py 9.22
|
test_tests_vboot_forge.py 9.22
|
||||||
test_u_boot_console_base.py 7.08
|
test_u_boot_console_base.py 7.08
|
||||||
|
|
|
@ -370,6 +370,18 @@ static int snprint(struct unit_test_state *uts)
|
||||||
char buf[10] = "xxxxxxxxx";
|
char buf[10] = "xxxxxxxxx";
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
ret = snprintf(buf, 5, "%d", 12345678);
|
||||||
|
ut_asserteq_str("1234", buf);
|
||||||
|
ut_asserteq(8, ret);
|
||||||
|
ret = snprintf(buf, 5, "0x%x", 0x1234);
|
||||||
|
ut_asserteq_str("0x12", buf);
|
||||||
|
ut_asserteq(6, ret);
|
||||||
|
ret = snprintf(buf, 5, "0x%08x", 0x1234);
|
||||||
|
ut_asserteq_str("0x00", buf);
|
||||||
|
ut_asserteq(10, ret);
|
||||||
|
ret = snprintf(buf, 3, "%s", "abc");
|
||||||
|
ut_asserteq_str("ab", buf);
|
||||||
|
ut_asserteq(3, ret);
|
||||||
ret = snprintf(buf, 4, "%s:%s", "abc", "def");
|
ret = snprintf(buf, 4, "%s:%s", "abc", "def");
|
||||||
ut_asserteq(0, buf[3]);
|
ut_asserteq(0, buf[3]);
|
||||||
ut_asserteq(7, ret);
|
ut_asserteq(7, ret);
|
||||||
|
|
|
@ -35,18 +35,19 @@ import vboot_evil
|
||||||
# Only run the full suite on a few combinations, since it doesn't add any more
|
# Only run the full suite on a few combinations, since it doesn't add any more
|
||||||
# test coverage.
|
# test coverage.
|
||||||
TESTDATA = [
|
TESTDATA = [
|
||||||
['sha1-basic', 'sha1', '', None, False, True],
|
['sha1-basic', 'sha1', '', None, False, True, False],
|
||||||
['sha1-pad', 'sha1', '', '-E -p 0x10000', False, False],
|
['sha1-pad', 'sha1', '', '-E -p 0x10000', False, False, False],
|
||||||
['sha1-pss', 'sha1', '-pss', None, False, False],
|
['sha1-pss', 'sha1', '-pss', None, False, False, False],
|
||||||
['sha1-pss-pad', 'sha1', '-pss', '-E -p 0x10000', False, False],
|
['sha1-pss-pad', 'sha1', '-pss', '-E -p 0x10000', False, False, False],
|
||||||
['sha256-basic', 'sha256', '', None, False, False],
|
['sha256-basic', 'sha256', '', None, False, False, False],
|
||||||
['sha256-pad', 'sha256', '', '-E -p 0x10000', False, False],
|
['sha256-pad', 'sha256', '', '-E -p 0x10000', False, False, False],
|
||||||
['sha256-pss', 'sha256', '-pss', None, False, False],
|
['sha256-pss', 'sha256', '-pss', None, False, False, False],
|
||||||
['sha256-pss-pad', 'sha256', '-pss', '-E -p 0x10000', False, False],
|
['sha256-pss-pad', 'sha256', '-pss', '-E -p 0x10000', False, False, False],
|
||||||
['sha256-pss-required', 'sha256', '-pss', None, True, False],
|
['sha256-pss-required', 'sha256', '-pss', None, True, False, False],
|
||||||
['sha256-pss-pad-required', 'sha256', '-pss', '-E -p 0x10000', True, True],
|
['sha256-pss-pad-required', 'sha256', '-pss', '-E -p 0x10000', True, True, False],
|
||||||
['sha384-basic', 'sha384', '', None, False, False],
|
['sha384-basic', 'sha384', '', None, False, False, False],
|
||||||
['sha384-pad', 'sha384', '', '-E -p 0x10000', False, False],
|
['sha384-pad', 'sha384', '', '-E -p 0x10000', False, False, False],
|
||||||
|
['algo-arg', 'algo-arg', '', '-o sha256,rsa2048', False, False, True],
|
||||||
]
|
]
|
||||||
|
|
||||||
@pytest.mark.boardspec('sandbox')
|
@pytest.mark.boardspec('sandbox')
|
||||||
|
@ -55,10 +56,10 @@ TESTDATA = [
|
||||||
@pytest.mark.requiredtool('fdtget')
|
@pytest.mark.requiredtool('fdtget')
|
||||||
@pytest.mark.requiredtool('fdtput')
|
@pytest.mark.requiredtool('fdtput')
|
||||||
@pytest.mark.requiredtool('openssl')
|
@pytest.mark.requiredtool('openssl')
|
||||||
@pytest.mark.parametrize("name,sha_algo,padding,sign_options,required,full_test",
|
@pytest.mark.parametrize("name,sha_algo,padding,sign_options,required,full_test,algo_arg",
|
||||||
TESTDATA)
|
TESTDATA)
|
||||||
def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required,
|
def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required,
|
||||||
full_test):
|
full_test, algo_arg):
|
||||||
"""Test verified boot signing with mkimage and verification with 'bootm'.
|
"""Test verified boot signing with mkimage and verification with 'bootm'.
|
||||||
|
|
||||||
This works using sandbox only as it needs to update the device tree used
|
This works using sandbox only as it needs to update the device tree used
|
||||||
|
@ -219,7 +220,7 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required,
|
||||||
# Build the FIT, but don't sign anything yet
|
# Build the FIT, but don't sign anything yet
|
||||||
cons.log.action('%s: Test FIT with signed images' % sha_algo)
|
cons.log.action('%s: Test FIT with signed images' % sha_algo)
|
||||||
make_fit('sign-images-%s%s.its' % (sha_algo, padding))
|
make_fit('sign-images-%s%s.its' % (sha_algo, padding))
|
||||||
run_bootm(sha_algo, 'unsigned images', 'dev-', True)
|
run_bootm(sha_algo, 'unsigned images', ' - OK' if algo_arg else 'dev-', True)
|
||||||
|
|
||||||
# Sign images with our dev keys
|
# Sign images with our dev keys
|
||||||
sign_fit(sha_algo, sign_options)
|
sign_fit(sha_algo, sign_options)
|
||||||
|
@ -230,7 +231,7 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required,
|
||||||
|
|
||||||
cons.log.action('%s: Test FIT with signed configuration' % sha_algo)
|
cons.log.action('%s: Test FIT with signed configuration' % sha_algo)
|
||||||
make_fit('sign-configs-%s%s.its' % (sha_algo, padding))
|
make_fit('sign-configs-%s%s.its' % (sha_algo, padding))
|
||||||
run_bootm(sha_algo, 'unsigned config', '%s+ OK' % sha_algo, True)
|
run_bootm(sha_algo, 'unsigned config', '%s+ OK' % ('sha256' if algo_arg else sha_algo), True)
|
||||||
|
|
||||||
# Sign images with our dev keys
|
# Sign images with our dev keys
|
||||||
sign_fit(sha_algo, sign_options)
|
sign_fit(sha_algo, sign_options)
|
||||||
|
|
44
test/py/tests/vboot/sign-configs-algo-arg.its
Normal file
44
test/py/tests/vboot/sign-configs-algo-arg.its
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
|
/ {
|
||||||
|
description = "Chrome OS kernel image with one or more FDT blobs";
|
||||||
|
#address-cells = <1>;
|
||||||
|
|
||||||
|
images {
|
||||||
|
kernel {
|
||||||
|
data = /incbin/("test-kernel.bin");
|
||||||
|
type = "kernel_noload";
|
||||||
|
arch = "sandbox";
|
||||||
|
os = "linux";
|
||||||
|
compression = "none";
|
||||||
|
load = <0x4>;
|
||||||
|
entry = <0x8>;
|
||||||
|
kernel-version = <1>;
|
||||||
|
hash-1 {
|
||||||
|
algo = "sha256";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
fdt-1 {
|
||||||
|
description = "snow";
|
||||||
|
data = /incbin/("sandbox-kernel.dtb");
|
||||||
|
type = "flat_dt";
|
||||||
|
arch = "sandbox";
|
||||||
|
compression = "none";
|
||||||
|
fdt-version = <1>;
|
||||||
|
hash-1 {
|
||||||
|
algo = "sha256";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
configurations {
|
||||||
|
default = "conf-1";
|
||||||
|
conf-1 {
|
||||||
|
kernel = "kernel";
|
||||||
|
fdt = "fdt-1";
|
||||||
|
signature {
|
||||||
|
key-name-hint = "dev";
|
||||||
|
sign-images = "fdt", "kernel";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
40
test/py/tests/vboot/sign-images-algo-arg.its
Normal file
40
test/py/tests/vboot/sign-images-algo-arg.its
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
|
/ {
|
||||||
|
description = "Chrome OS kernel image with one or more FDT blobs";
|
||||||
|
#address-cells = <1>;
|
||||||
|
|
||||||
|
images {
|
||||||
|
kernel {
|
||||||
|
data = /incbin/("test-kernel.bin");
|
||||||
|
type = "kernel_noload";
|
||||||
|
arch = "sandbox";
|
||||||
|
os = "linux";
|
||||||
|
compression = "none";
|
||||||
|
load = <0x4>;
|
||||||
|
entry = <0x8>;
|
||||||
|
kernel-version = <1>;
|
||||||
|
signature {
|
||||||
|
key-name-hint = "dev";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
fdt-1 {
|
||||||
|
description = "snow";
|
||||||
|
data = /incbin/("sandbox-kernel.dtb");
|
||||||
|
type = "flat_dt";
|
||||||
|
arch = "sandbox";
|
||||||
|
compression = "none";
|
||||||
|
fdt-version = <1>;
|
||||||
|
signature {
|
||||||
|
key-name-hint = "dev";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
configurations {
|
||||||
|
default = "conf-1";
|
||||||
|
conf-1 {
|
||||||
|
kernel = "kernel";
|
||||||
|
fdt = "fdt-1";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
105
tools/env/fw_env.c
vendored
105
tools/env/fw_env.c
vendored
|
@ -346,7 +346,7 @@ static int ubi_write(int fd, const void *buf, size_t count)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flash_io(int mode);
|
static int flash_io(int mode, void *buf, size_t count);
|
||||||
static int parse_config(struct env_opts *opts);
|
static int parse_config(struct env_opts *opts);
|
||||||
|
|
||||||
#if defined(CONFIG_FILE)
|
#if defined(CONFIG_FILE)
|
||||||
|
@ -516,7 +516,7 @@ int fw_env_flush(struct env_opts *opts)
|
||||||
*environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
|
*environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
|
||||||
|
|
||||||
/* write environment back to flash */
|
/* write environment back to flash */
|
||||||
if (flash_io(O_RDWR)) {
|
if (flash_io(O_RDWR, environment.image, CUR_ENVSIZE)) {
|
||||||
fprintf(stderr, "Error: can't write fw_env to flash\n");
|
fprintf(stderr, "Error: can't write fw_env to flash\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,8 @@ static int flash_flag_obsolete(int dev, int fd, off_t offset)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flash_write(int fd_current, int fd_target, int dev_target)
|
static int flash_write(int fd_current, int fd_target, int dev_target, void *buf,
|
||||||
|
size_t count)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -1212,11 +1213,10 @@ static int flash_write(int fd_current, int fd_target, int dev_target)
|
||||||
if (IS_UBI(dev_target)) {
|
if (IS_UBI(dev_target)) {
|
||||||
if (ubi_update_start(fd_target, CUR_ENVSIZE) < 0)
|
if (ubi_update_start(fd_target, CUR_ENVSIZE) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return ubi_write(fd_target, environment.image, CUR_ENVSIZE);
|
return ubi_write(fd_target, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = flash_write_buf(dev_target, fd_target, environment.image,
|
rc = flash_write_buf(dev_target, fd_target, buf, count);
|
||||||
CUR_ENVSIZE);
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
@ -1235,17 +1235,17 @@ static int flash_write(int fd_current, int fd_target, int dev_target)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flash_read(int fd)
|
static int flash_read(int fd, void *buf, size_t count)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (IS_UBI(dev_current)) {
|
if (IS_UBI(dev_current)) {
|
||||||
DEVTYPE(dev_current) = MTD_ABSENT;
|
DEVTYPE(dev_current) = MTD_ABSENT;
|
||||||
|
|
||||||
return ubi_read(fd, environment.image, CUR_ENVSIZE);
|
return ubi_read(fd, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = flash_read_buf(dev_current, fd, environment.image, CUR_ENVSIZE,
|
rc = flash_read_buf(dev_current, fd, buf, count,
|
||||||
DEVOFFSET(dev_current));
|
DEVOFFSET(dev_current));
|
||||||
if (rc != CUR_ENVSIZE)
|
if (rc != CUR_ENVSIZE)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1291,7 +1291,7 @@ err:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flash_io_write(int fd_current)
|
static int flash_io_write(int fd_current, void *buf, size_t count)
|
||||||
{
|
{
|
||||||
int fd_target = -1, rc, dev_target;
|
int fd_target = -1, rc, dev_target;
|
||||||
const char *dname, *target_temp = NULL;
|
const char *dname, *target_temp = NULL;
|
||||||
|
@ -1322,7 +1322,7 @@ static int flash_io_write(int fd_current)
|
||||||
fd_target = fd_current;
|
fd_target = fd_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = flash_write(fd_current, fd_target, dev_target);
|
rc = flash_write(fd_current, fd_target, dev_target, buf, count);
|
||||||
|
|
||||||
if (fsync(fd_current) && !(errno == EINVAL || errno == EROFS)) {
|
if (fsync(fd_current) && !(errno == EINVAL || errno == EROFS)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -1377,7 +1377,7 @@ static int flash_io_write(int fd_current)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flash_io(int mode)
|
static int flash_io(int mode, void *buf, size_t count)
|
||||||
{
|
{
|
||||||
int fd_current, rc;
|
int fd_current, rc;
|
||||||
|
|
||||||
|
@ -1391,9 +1391,9 @@ static int flash_io(int mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == O_RDWR) {
|
if (mode == O_RDWR) {
|
||||||
rc = flash_io_write(fd_current);
|
rc = flash_io_write(fd_current, buf, count);
|
||||||
} else {
|
} else {
|
||||||
rc = flash_read(fd_current);
|
rc = flash_read(fd_current, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (close(fd_current)) {
|
if (close(fd_current)) {
|
||||||
|
@ -1421,9 +1421,6 @@ int fw_env_open(struct env_opts *opts)
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
struct env_image_single *single;
|
|
||||||
struct env_image_redundant *redundant;
|
|
||||||
|
|
||||||
if (!opts)
|
if (!opts)
|
||||||
opts = &default_opts;
|
opts = &default_opts;
|
||||||
|
|
||||||
|
@ -1439,40 +1436,37 @@ int fw_env_open(struct env_opts *opts)
|
||||||
goto open_cleanup;
|
goto open_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read environment from FLASH to local buffer */
|
|
||||||
environment.image = addr0;
|
|
||||||
|
|
||||||
if (have_redund_env) {
|
|
||||||
redundant = addr0;
|
|
||||||
environment.crc = &redundant->crc;
|
|
||||||
environment.flags = &redundant->flags;
|
|
||||||
environment.data = redundant->data;
|
|
||||||
} else {
|
|
||||||
single = addr0;
|
|
||||||
environment.crc = &single->crc;
|
|
||||||
environment.flags = NULL;
|
|
||||||
environment.data = single->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_current = 0;
|
dev_current = 0;
|
||||||
if (flash_io(O_RDONLY)) {
|
if (flash_io(O_RDONLY, addr0, CUR_ENVSIZE)) {
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto open_cleanup;
|
goto open_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE);
|
|
||||||
|
|
||||||
crc0_ok = (crc0 == *environment.crc);
|
|
||||||
if (!have_redund_env) {
|
if (!have_redund_env) {
|
||||||
|
struct env_image_single *single = addr0;
|
||||||
|
|
||||||
|
crc0 = crc32(0, (uint8_t *)single->data, ENV_SIZE);
|
||||||
|
crc0_ok = (crc0 == single->crc);
|
||||||
if (!crc0_ok) {
|
if (!crc0_ok) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Warning: Bad CRC, using default environment\n");
|
"Warning: Bad CRC, using default environment\n");
|
||||||
memcpy(environment.data, default_environment,
|
memcpy(single->data, default_environment,
|
||||||
sizeof(default_environment));
|
sizeof(default_environment));
|
||||||
environment.dirty = 1;
|
environment.dirty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment.image = addr0;
|
||||||
|
environment.crc = &single->crc;
|
||||||
|
environment.flags = NULL;
|
||||||
|
environment.data = single->data;
|
||||||
} else {
|
} else {
|
||||||
flag0 = *environment.flags;
|
struct env_image_redundant *redundant0 = addr0;
|
||||||
|
struct env_image_redundant *redundant1;
|
||||||
|
|
||||||
|
crc0 = crc32(0, (uint8_t *)redundant0->data, ENV_SIZE);
|
||||||
|
crc0_ok = (crc0 == redundant0->crc);
|
||||||
|
|
||||||
|
flag0 = redundant0->flags;
|
||||||
|
|
||||||
dev_current = 1;
|
dev_current = 1;
|
||||||
addr1 = calloc(1, CUR_ENVSIZE);
|
addr1 = calloc(1, CUR_ENVSIZE);
|
||||||
|
@ -1483,14 +1477,9 @@ int fw_env_open(struct env_opts *opts)
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto open_cleanup;
|
goto open_cleanup;
|
||||||
}
|
}
|
||||||
redundant = addr1;
|
redundant1 = addr1;
|
||||||
|
|
||||||
/*
|
if (flash_io(O_RDONLY, addr1, CUR_ENVSIZE)) {
|
||||||
* have to set environment.image for flash_read(), careful -
|
|
||||||
* other pointers in environment still point inside addr0
|
|
||||||
*/
|
|
||||||
environment.image = addr1;
|
|
||||||
if (flash_io(O_RDONLY)) {
|
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto open_cleanup;
|
goto open_cleanup;
|
||||||
}
|
}
|
||||||
|
@ -1518,18 +1507,12 @@ int fw_env_open(struct env_opts *opts)
|
||||||
goto open_cleanup;
|
goto open_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
crc1 = crc32(0, (uint8_t *)redundant->data, ENV_SIZE);
|
crc1 = crc32(0, (uint8_t *)redundant1->data, ENV_SIZE);
|
||||||
|
|
||||||
crc1_ok = (crc1 == redundant->crc);
|
crc1_ok = (crc1 == redundant1->crc);
|
||||||
flag1 = redundant->flags;
|
flag1 = redundant1->flags;
|
||||||
|
|
||||||
/*
|
if (memcmp(redundant0->data, redundant1->data, ENV_SIZE) ||
|
||||||
* environment.data still points to ((struct
|
|
||||||
* env_image_redundant *)addr0)->data. If the two
|
|
||||||
* environments differ, or one has bad crc, force a
|
|
||||||
* write-out by marking the environment dirty.
|
|
||||||
*/
|
|
||||||
if (memcmp(environment.data, redundant->data, ENV_SIZE) ||
|
|
||||||
!crc0_ok || !crc1_ok)
|
!crc0_ok || !crc1_ok)
|
||||||
environment.dirty = 1;
|
environment.dirty = 1;
|
||||||
|
|
||||||
|
@ -1540,7 +1523,7 @@ int fw_env_open(struct env_opts *opts)
|
||||||
} else if (!crc0_ok && !crc1_ok) {
|
} else if (!crc0_ok && !crc1_ok) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Warning: Bad CRC, using default environment\n");
|
"Warning: Bad CRC, using default environment\n");
|
||||||
memcpy(environment.data, default_environment,
|
memcpy(redundant0->data, default_environment,
|
||||||
sizeof(default_environment));
|
sizeof(default_environment));
|
||||||
environment.dirty = 1;
|
environment.dirty = 1;
|
||||||
dev_current = 0;
|
dev_current = 0;
|
||||||
|
@ -1586,13 +1569,15 @@ int fw_env_open(struct env_opts *opts)
|
||||||
*/
|
*/
|
||||||
if (dev_current) {
|
if (dev_current) {
|
||||||
environment.image = addr1;
|
environment.image = addr1;
|
||||||
environment.crc = &redundant->crc;
|
environment.crc = &redundant1->crc;
|
||||||
environment.flags = &redundant->flags;
|
environment.flags = &redundant1->flags;
|
||||||
environment.data = redundant->data;
|
environment.data = redundant1->data;
|
||||||
free(addr0);
|
free(addr0);
|
||||||
} else {
|
} else {
|
||||||
environment.image = addr0;
|
environment.image = addr0;
|
||||||
/* Other pointers are already set */
|
environment.crc = &redundant0->crc;
|
||||||
|
environment.flags = &redundant0->flags;
|
||||||
|
environment.data = redundant0->data;
|
||||||
free(addr1);
|
free(addr1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -71,7 +71,9 @@ struct image_tool_params {
|
||||||
const char *keydest; /* Destination .dtb for public key */
|
const char *keydest; /* Destination .dtb for public key */
|
||||||
const char *keyfile; /* Filename of private or public key */
|
const char *keyfile; /* Filename of private or public key */
|
||||||
const char *comment; /* Comment to add to signature node */
|
const char *comment; /* Comment to add to signature node */
|
||||||
const char *algo_name; /* Algorithm name to use hashing/signing */
|
/* Algorithm name to use for hashing/signing or NULL to use the one
|
||||||
|
* specified in the its */
|
||||||
|
const char *algo_name;
|
||||||
int require_keys; /* 1 to mark signing keys as 'required' */
|
int require_keys; /* 1 to mark signing keys as 'required' */
|
||||||
int file_size; /* Total size of output file */
|
int file_size; /* Total size of output file */
|
||||||
int orig_file_size; /* Original size for file before padding */
|
int orig_file_size; /* Original size for file before padding */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue