From 3a8ad050aa8b1663316952d1d4bebdb5f4911160 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Mon, 12 Aug 2024 23:57:59 +0300 Subject: [PATCH 1/4] efi_loader: fix memory freeing in efi_get_dp_from_boot() efi_get_var() allocates memory which must be freed after the variable is used. Since the device path is duplicated after we deserialize the load options free the memory used for the variable payload Fixes: db61e70e0d2a efi_loader: efi_dp_from_lo() should skip VenMedia node Signed-off-by: Ilias Apalodimas Reviewed-by: Heinric Schuchardt --- lib/efi_loader/efi_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 65d2116381a..916f43da26c 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -74,6 +74,7 @@ out: */ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t *guid) { + struct efi_device_path *file_path = NULL; struct efi_load_option lo; void *var_value; efi_uintn_t size; @@ -92,11 +93,11 @@ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t *guid) if (ret != EFI_SUCCESS) goto err; - return efi_dp_from_lo(&lo, guid); + file_path = efi_dp_from_lo(&lo, guid); err: free(var_value); - return NULL; + return file_path; } /** From 2a12caf75d282e20363c69707e93eeecbfa39749 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 14 Aug 2024 14:33:44 +0200 Subject: [PATCH 2/4] tools/mkeficapsule: correct printf codes uint64_t is defined as unsigned long long on 32-bit ARM. Use PRIX64 for printing uint64_t. This avoid a build failure on 32-bit systems: tools/mkeficapsule.c: In function 'dump_capsule_auth_header': tools/mkeficapsule.c:694:66: warning: format '%lX' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=] 694 | printf("EFI_FIRMWARE_IMAGE_AUTH.MONOTONIC_COUNT\t\t: %08lX\n", | ~~~~^ | | | long unsigned int | %08llX Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas Reviewed-by: Mark Kettenis --- tools/mkeficapsule.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index f28008a0829..1b53151d41a 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -691,7 +692,7 @@ static uint32_t dump_fmp_payload_header( static void dump_capsule_auth_header( struct efi_firmware_image_authentication *capsule_auth_hdr) { - printf("EFI_FIRMWARE_IMAGE_AUTH.MONOTONIC_COUNT\t\t: %08lX\n", + printf("EFI_FIRMWARE_IMAGE_AUTH.MONOTONIC_COUNT\t\t: %08" PRIX64 "\n", capsule_auth_hdr->monotonic_count); printf("EFI_FIRMWARE_IMAGE_AUTH.AUTH_INFO.HDR.dwLENGTH\t: %08X\n", capsule_auth_hdr->auth_info.hdr.dwLength); @@ -724,9 +725,9 @@ static void dump_fmp_capsule_image_header( image_hdr->update_image_size); printf("FMP_CAPSULE_IMAGE_HDR.UPDATE_VENDOR_CODE_SIZE\t: %08X\n", image_hdr->update_vendor_code_size); - printf("FMP_CAPSULE_IMAGE_HDR.UPDATE_HARDWARE_INSTANCE\t: %08lX\n", + printf("FMP_CAPSULE_IMAGE_HDR.UPDATE_HARDWARE_INSTANCE\t: %08" PRIX64 "\n", image_hdr->update_hardware_instance); - printf("FMP_CAPSULE_IMAGE_HDR.IMAGE_CAPSULE_SUPPORT\t: %08lX\n", + printf("FMP_CAPSULE_IMAGE_HDR.IMAGE_CAPSULE_SUPPORT\t: %08" PRIX64 "\n", image_hdr->image_capsule_support); printf("--------\n"); From 25a4b8114a7d4ee37eb11717b97400bd421faefc Mon Sep 17 00:00:00 2001 From: Emil Kronborg Date: Thu, 15 Aug 2024 08:21:22 +0000 Subject: [PATCH 3/4] doc: document the pwm command Signed-off-by: Emil Kronborg Reviewed-by: Simon Glass --- doc/usage/cmd/pwm.rst | 91 +++++++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + 2 files changed, 92 insertions(+) create mode 100644 doc/usage/cmd/pwm.rst diff --git a/doc/usage/cmd/pwm.rst b/doc/usage/cmd/pwm.rst new file mode 100644 index 00000000000..522acb5afa3 --- /dev/null +++ b/doc/usage/cmd/pwm.rst @@ -0,0 +1,91 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +.. index:: + single: pwm (command) + +pwm command +=========== + +Synopsis +-------- + +:: + + pwm invert + pwm config + pwm enable + pwm disable + + +Description +----------- + +The ``pwm`` command is used to access and configure PWM (Pulse Width Modulation) +signals. + +pwm invert +---------- + +* If the value of ``polarity`` is 0, the default polarity is used. +* If the value of ``polarity`` is 1, the polarity is inverted. + +pwm config +---------- + +Configure the period and duty period in nanoseconds. + +pwm enable +---------- + +Enable output on the configured device and channel. + +pwm disable +----------- + +Disable output on the configured device and channel. + +pwm_dev_num + Device number of the pulse width modulation device + +channel + Output channel of the PWM device + +polarity + * 0 - Use normal polarity + * 1 - Use inverted polarity + +duty_ns + Duty period in ns + +period_ns + Period time in ns + +Examples +-------- + +Configure device 0, channel 0 to 20 µs period and 14 µs (that is, 70%) duty period:: + + => pwm config 0 0 20000 14000 + +Enable output on the configured device and channel:: + + => pwm enable 0 0 + +Disable output on the configured device and channel:: + + => pwm disable 0 0 + +Invert the signal on the configured device and channel:: + + => pwm invert 0 0 1 + +Configuration +------------- + +The ``pwm`` command is only available if CONFIG_CMD_PWM=y. + +Return value +------------ + +If the command succeeds, the return value ``$?`` is set to 0. If an error occurs, the +return value ``$?`` is set to 1. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 1f6518b77c4..6a218c46b4e 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -93,6 +93,7 @@ Shell commands cmd/pinmux cmd/printenv cmd/pstore + cmd/pwm cmd/qfw cmd/read cmd/reset From dcd1b63b7072749f98ea0a87565d0ae5c8ddfb65 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 21 Aug 2024 23:33:49 +0200 Subject: [PATCH 4/4] efi_loader: allow EFI_LOADER_BOUNCE_BUFFER on all architectures There not only ARM64 boards but also RISC-V boards that require a bounce buffer to read block devices. Drop the architecture restriction. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 1179c31bb13..6ffefa9103f 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -364,7 +364,6 @@ endif config EFI_LOADER_BOUNCE_BUFFER bool "EFI Applications use bounce buffers for DMA operations" - depends on ARM64 help Some hardware does not support DMA to full 64bit addresses. For this hardware we can create a bounce buffer so that payloads don't have to