Re: [PATCH 2/2] x86: Switch QEMU over to use the bochs driver
Am 30. April 2023 04:31:57 MESZ schrieb Simon Glass : >This is more convenient since it does not require a video BIOS. Enable >it for QEMU. Does this require a change in how QEMU is invoked? If so, please add a documentation change. Best regards Heinrich > >Signed-off-by: Simon Glass >--- > > arch/x86/cpu/qemu/Kconfig | 2 +- > configs/qemu-x86_64_defconfig | 5 + > configs/qemu-x86_defconfig| 3 --- > 3 files changed, 2 insertions(+), 8 deletions(-) > >diff --git a/arch/x86/cpu/qemu/Kconfig b/arch/x86/cpu/qemu/Kconfig >index f8f2f6473088..aa329b0dab29 100644 >--- a/arch/x86/cpu/qemu/Kconfig >+++ b/arch/x86/cpu/qemu/Kconfig >@@ -12,7 +12,7 @@ config QEMU > imply SYS_NS16550 > imply USB > imply USB_EHCI_HCD >- imply VIDEO_VESA >+ imply VIDEO_BOCHS > > if QEMU > >diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig >index 79ea35918575..3ebc16d370fe 100644 >--- a/configs/qemu-x86_64_defconfig >+++ b/configs/qemu-x86_64_defconfig >@@ -84,11 +84,8 @@ CONFIG_SPL_DM_RTC=y > CONFIG_SYS_NS16550_PORT_MAPPED=y > CONFIG_SPI=y > CONFIG_USB_KEYBOARD=y >-CONFIG_SPL_VIDEO=y >-CONFIG_FRAMEBUFFER_SET_VESA_MODE=y >-CONFIG_FRAMEBUFFER_VESA_MODE_USER=y >-CONFIG_FRAMEBUFFER_VESA_MODE=0x144 > CONFIG_CONSOLE_SCROLL_LINES=5 >+CONFIG_SPL_VIDEO=y > CONFIG_FAT_BLK_XLATE=y > # CONFIG_SPL_USE_TINY_PRINTF is not set > CONFIG_GENERATE_ACPI_TABLE=y >diff --git a/configs/qemu-x86_defconfig b/configs/qemu-x86_defconfig >index 9bf29647fe59..fcf429f77115 100644 >--- a/configs/qemu-x86_defconfig >+++ b/configs/qemu-x86_defconfig >@@ -54,9 +54,6 @@ CONFIG_NVME_PCI=y > CONFIG_SYS_NS16550_PORT_MAPPED=y > CONFIG_SPI=y > CONFIG_USB_KEYBOARD=y >-CONFIG_FRAMEBUFFER_SET_VESA_MODE=y >-CONFIG_FRAMEBUFFER_VESA_MODE_USER=y >-CONFIG_FRAMEBUFFER_VESA_MODE=0x144 > CONFIG_CONSOLE_SCROLL_LINES=5 > CONFIG_GENERATE_ACPI_TABLE=y > # CONFIG_GZIP is not set
[PATCH 2/2] x86: Switch QEMU over to use the bochs driver
This is more convenient since it does not require a video BIOS. Enable it for QEMU. Signed-off-by: Simon Glass --- arch/x86/cpu/qemu/Kconfig | 2 +- configs/qemu-x86_64_defconfig | 5 + configs/qemu-x86_defconfig| 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/x86/cpu/qemu/Kconfig b/arch/x86/cpu/qemu/Kconfig index f8f2f6473088..aa329b0dab29 100644 --- a/arch/x86/cpu/qemu/Kconfig +++ b/arch/x86/cpu/qemu/Kconfig @@ -12,7 +12,7 @@ config QEMU imply SYS_NS16550 imply USB imply USB_EHCI_HCD - imply VIDEO_VESA + imply VIDEO_BOCHS if QEMU diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig index 79ea35918575..3ebc16d370fe 100644 --- a/configs/qemu-x86_64_defconfig +++ b/configs/qemu-x86_64_defconfig @@ -84,11 +84,8 @@ CONFIG_SPL_DM_RTC=y CONFIG_SYS_NS16550_PORT_MAPPED=y CONFIG_SPI=y CONFIG_USB_KEYBOARD=y -CONFIG_SPL_VIDEO=y -CONFIG_FRAMEBUFFER_SET_VESA_MODE=y -CONFIG_FRAMEBUFFER_VESA_MODE_USER=y -CONFIG_FRAMEBUFFER_VESA_MODE=0x144 CONFIG_CONSOLE_SCROLL_LINES=5 +CONFIG_SPL_VIDEO=y CONFIG_FAT_BLK_XLATE=y # CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_GENERATE_ACPI_TABLE=y diff --git a/configs/qemu-x86_defconfig b/configs/qemu-x86_defconfig index 9bf29647fe59..fcf429f77115 100644 --- a/configs/qemu-x86_defconfig +++ b/configs/qemu-x86_defconfig @@ -54,9 +54,6 @@ CONFIG_NVME_PCI=y CONFIG_SYS_NS16550_PORT_MAPPED=y CONFIG_SPI=y CONFIG_USB_KEYBOARD=y -CONFIG_FRAMEBUFFER_SET_VESA_MODE=y -CONFIG_FRAMEBUFFER_VESA_MODE_USER=y -CONFIG_FRAMEBUFFER_VESA_MODE=0x144 CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_GENERATE_ACPI_TABLE=y # CONFIG_GZIP is not set -- 2.40.1.495.gc816e09b53d-goog
[PATCH 1/2] x86: video: Add a driver for QEMU bochs emulation
Bochs is convenient with QEMU on x86 since it does not require a video BIOS. Add a driver for it. Signed-off-by: Simon Glass --- drivers/video/Kconfig | 30 ++ drivers/video/Makefile | 2 + drivers/video/bochs.c | 130 + drivers/video/bochs.h | 36 4 files changed, 198 insertions(+) create mode 100644 drivers/video/bochs.c create mode 100644 drivers/video/bochs.h diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 9a95b7a4c792..5fd42807179f 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -278,6 +278,36 @@ config VIDCONSOLE_AS_NAME possible to update the environment, the breakage may be confusing for users. This option will be removed around the end of 2020. +config VIDEO_BOCHS + bool "Enable Bochs video emulation for QEMU" + depends on X86 + help + Enable this to use the Boschs video support provided in the QEMU + emulator. This appears as a PCI device which U-Boot can set up to + provide a frame buffer. + +if VIDEO_BOCHS + +config VIDEO_BOCHS_SIZE_X + int "Width of display (X resolution)" + default 1280 + help + Sets the width of the display. + + These two options control the size of the display set up by QEMU. + Typical sizes are 1024 x 768 or 1280 x 1024. + +config VIDEO_BOCHS_SIZE_Y + int "High of display (Y resolution)" + default 1024 + help + Sets the height of the display. + + These two options control the size of the display set up by QEMU. + Typical sizes are 1024 x 768 or 1280 x 1024. + +endif + config VIDEO_COREBOOT bool "Enable coreboot framebuffer driver support" depends on X86 diff --git a/drivers/video/Makefile b/drivers/video/Makefile index a609e35d22e8..11d872ddf41d 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -28,6 +28,8 @@ obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o endif +obj-$(CONFIG_VIDEO_BOCHS) += bochs.o + obj-${CONFIG_EXYNOS_FB} += exynos/ obj-${CONFIG_VIDEO_ROCKCHIP} += rockchip/ obj-${CONFIG_VIDEO_STM32} += stm32/ diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c new file mode 100644 index ..7ea29a0ed177 --- /dev/null +++ b/drivers/video/bochs.c @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Modified from coreboot bochs.c + */ + +#define LOG_CATEGORY UCLASS_VIDEO + +#include +#include +#include +#include +#include +#include +#include +#include +#include "bochs.h" + +static int xsize = CONFIG_VIDEO_BOCHS_SIZE_X; +static int ysize = CONFIG_VIDEO_BOCHS_SIZE_Y; + +static void bochs_write(void *mmio, int index, int val) +{ + writew(val, mmio + MMIO_BASE + index * 2); +} + +static int bochs_read(void *mmio, int index) +{ + return readw(mmio + MMIO_BASE + index * 2); +} + +static void bochs_vga_write(int index, uint8_t val) +{ + outb(val, VGA_INDEX); +} + +static int bochs_init_linear_fb(struct udevice *dev) +{ + struct video_uc_plat *plat = dev_get_uclass_plat(dev); + struct video_priv *uc_priv = dev_get_uclass_priv(dev); + ulong fb; + void *mmio; + int id, mem; + + log_debug("probing %s at PCI %x\n", dev->name, dm_pci_get_bdf(dev)); + fb = dm_pci_read_bar32(dev, 0); + if (!fb) + return log_msg_ret("fb", -EIO); + + /* MMIO bar supported since qemu 3.0+ */ + mmio = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_2, 0, 0, PCI_REGION_TYPE, + PCI_REGION_MEM); + + if (!mmio) + return log_msg_ret("map", -EIO); + + log_debug("QEMU VGA: bochs @ %p: %d MiB FB at %lx\n", mmio, mem / SZ_1M, + fb); + + /* bochs dispi detection */ + id = bochs_read(mmio, INDEX_ID); + if ((id & 0xfff0) != ID0) { + log_debug("ID mismatch\n"); + return -EPROTONOSUPPORT; + } + mem = bochs_read(mmio, INDEX_VIDEO_MEMORY_64K) * SZ_64K; + + uc_priv->xsize = xsize; + uc_priv->ysize = ysize; + uc_priv->bpix = VIDEO_BPP32; + + /* setup video mode */ + bochs_write(mmio, INDEX_ENABLE, 0); + bochs_write(mmio, INDEX_BANK, 0); + bochs_write(mmio, INDEX_BPP, VNBITS(uc_priv->bpix)); + bochs_write(mmio, INDEX_XRES, xsize); + bochs_write(mmio, INDEX_YRES, ysize); + bochs_write(mmio, INDEX_VIRT_WIDTH, xsize); + bochs_write(mmio, INDEX_VIRT_HEIGHT, ysize); + bochs_write(mmio, INDEX_X_OFFSET, 0); + bochs_write(mmio, INDEX_Y_OFFSET, 0); + bochs_write(mmio, INDEX_ENABLE, ENABLED | LFB_ENABLED); + + bochs_vga_write(0, 0x20); /* disable blanking */ + + plat->base = fb; + + return 0; +} + +static int bochs_video_probe(struct udevice *dev) +{ + int ret; + + ret = bochs_init_linear_fb(dev); + if (ret) + return log_ret(ret); + + return 0; +} + +static
[PATCH v2 30/30] CI: Enable sandbox build for Windows
Add a new rule to build sandbox for Windows. For now, no tests are run in this configuration. Signed-off-by: Simon Glass --- Changes in v2: - Update the cover letter to better explain the motivation .azure-pipelines.yml | 27 +++ 1 file changed, 27 insertions(+) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 76ffdeebd667..d15a86ff3650 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -39,6 +39,33 @@ stages: # Tell MSYS2 not to ‘cd’ our startup directory to HOME CHERE_INVOKING: yes + - job: sandbox_windows +displayName: 'Ensure sandbox build for Windows' +pool: + vmImage: $(windows_vm) +steps: + - powershell: | + (New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2021-06-04/msys2-base-x86_64-20210604.sfx.exe;, "sfx.exe") +displayName: 'Install MSYS2' + - script: | + sfx.exe -y -o%CD:~0,2%\ + %CD:~0,2%\msys64\usr\bin\bash -lc " " + %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" + %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" +displayName: 'Update MSYS2' + - script: | + %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm --needed -Sy bc bison diffutils flex gcc libgnutls-devel libutil-linux-devel make openssl-devel python python-setuptools swig" +displayName: 'Install Toolchain' + - script: | + echo make sandbox_defconfig all > build-tools.sh + %CD:~0,2%\msys64\usr\bin\bash -lc "bash build-tools.sh" +displayName: 'Build sandbox' +env: + # Tell MSYS2 we need a POSIX emulation layer + MSYSTEM: MSYS + # Tell MSYS2 not to ‘cd’ our startup directory to HOME + CHERE_INVOKING: yes + - job: tools_only_macOS displayName: 'Ensure host tools build for macOS X' pool: -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 27/30] doc: Update the MSYS2 packages and versions
These are now quite out-of-date. Update to 2023 versions and bring in those are are needed for the newer tool features. Signed-off-by: Simon Glass --- (no changes since v1) doc/build/tools.rst | 20 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/build/tools.rst b/doc/build/tools.rst index ec0172292585..6b7342a27606 100644 --- a/doc/build/tools.rst +++ b/doc/build/tools.rst @@ -24,15 +24,18 @@ you can use MSYS2, a software distro and building platform for Windows. Download the MSYS2 installer from https://www.msys2.org. Make sure you have installed all required packages below in order to build these host tools:: - * gcc (9.1.0) - * make (4.2.1) - * bison (3.4.2) - * diffutils (3.7) - * openssl-devel (1.1.1.d) + * gcc (11.3.0-3) + * make (4.4.1-1) + * bison (3.8.2-4) + * diffutils (3.9-1) + * flex (2.6.4-3) + * libgnutls-devel (3.8.0-1) + * libutil-linux-devel (2.35.2) + * openssl-devel (3.1.0-1) Note the version numbers in these parentheses above are the package versions at the time being when writing this document. The MSYS2 installer tested is -http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20190524.exe. +https://github.com/msys2/msys2-installer/releases/download/2023-03-18/msys2-x86_64-20230318.exe There are 3 MSYS subsystems installed: MSYS2, MinGW32 and MinGW64. Each subsystem provides an environment to build Windows applications. The MSYS2 @@ -43,5 +46,6 @@ applications using a linux toolchain (gcc, bash, etc), targeting respectively Launch the MSYS2 shell of the MSYS2 environment, and do the following:: - $ make tools-only_defconfig - $ make tools-only + $ pacman -S bison diffutils flex gcc libgnutls-devel libutil-linux-devel \ + make openssl-devel + $ make tools-only_defconfig tools-only -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 29/30] Makefile: Drop unwind tables for MSYS
These give lots of warnings for the form: lib/efi_loader/helloworld.o:helloworld.c:(.pdata+0x0): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against `.text' The tables are not needed except when debugging, so disable them for now. Signed-off-by: Simon Glass --- (no changes since v1) lib/efi_loader/Makefile | 8 scripts/Makefile.lib| 4 2 files changed, 12 insertions(+) diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 13a35eae6c06..c17d39eba91e 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -15,11 +15,19 @@ CFLAGS_efi_boottime.o += \ CFLAGS_boothart.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_REMOVE_boothart.o := $(CFLAGS_NON_EFI) CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding + +ifneq ($(MSYS_VERSION),0) +CFLAGS_helloworld.o += -fno-asynchronous-unwind-tables -fno-unwind-tables +endif + CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI) CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI) CFLAGS_initrddump.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI) +ifneq ($(MSYS_VERSION),0) +CFLAGS_initrddump.o += -fno-asynchronous-unwind-tables -fno-unwind-tables +endif ifdef CONFIG_RISCV always += boothart.efi diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index aaae37d50a43..e751e452214e 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -450,6 +450,10 @@ targets += $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(obj)/efi_freestanding.o CFLAGS_REMOVE_efi_reloc.o := $(LTO_CFLAGS) CFLAGS_REMOVE_efi_freestanding.o := $(LTO_CFLAGS) +ifneq ($(MSYS_VERSION),0) +CFLAGS_efi_reloc.o += -fno-asynchronous-unwind-tables -fno-unwind-tables +CFLAGS_efi_freestanding.o += -fno-asynchronous-unwind-tables -fno-unwind-tables +endif # ACPI # --- -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 28/30] doc: Show how to build sandbox for MSYS2
Add instructions for building u-boot.exe to run on Windows. Signed-off-by: Simon Glass --- Changes in v2: - Clearify the documentation to explain the environment better doc/build/gcc.rst | 40 1 file changed, 40 insertions(+) diff --git a/doc/build/gcc.rst b/doc/build/gcc.rst index a0650a51db4b..96861c2b3d90 100644 --- a/doc/build/gcc.rst +++ b/doc/build/gcc.rst @@ -184,8 +184,48 @@ Important ones are * clean - remove most generated files but keep the configuration * mrproper - remove all generated files + config + various backup files +Building on/for Windows +--- + +Limited support is available for Windows, including building sandbox in the +MSYS2 environment. This produces native applications, but they must have access +to the `msys-2.0.dll` file. + +Note that this is not the same as running Windows Subsystem for Linux (WSL), +which is designed to build Linux applications. + +It is best to use an out-of-tree build, so you can build multiple boards, +with the output in a temporary directory like `/tmp/b`. + +First enable Windows developer mode with `Developer Mode`_ so that symbolic +links can be used. Then run the MSYS2 shell and enable symbolic links:: + + cd + echo "export MSYS=winsymlinks:nativestrict" >>.bashrc + +Close all MSYS2 shells so that the setting takes effect. + +To build sandbox, first install some required packages:: + +pacman install bc bison diffutils flex gcc libgnutls-devel \ + libutil-linux-devel make openssl-devel python python-setuptools swig + +then:: + +make O=/tmp/b/sandbox -j$(nproc) sandbox_defconfig all + +Note that it currently only gets as far as running binman, since this doesn't +fully work on Windows. + +You can also build sandbox_spl:: + +make O=/tmp/b/sandbox_spl -j$(nproc) sandbox_spl_defconfig all + + Installation The process for installing U-Boot on the target device is device specific. Please, refer to the board specific documentation :doc:`../board/index`. + +.. _`Developer Mode`: https://msdn.microsoft.com/en-us/windows/uwp/get-started/enable-your-device-for-development -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 26/30] build: Disable weak symbols for MSYS2
Weak symbols are not well supported by the PE format, so disable them. We need to manually ensure that only one function is present in the source code. Add a Kconfig option to control this and enable it when building for Windows. Signed-off-by: Simon Glass --- (no changes since v1) Kconfig | 12 include/linux/compiler_attributes.h | 4 2 files changed, 16 insertions(+) diff --git a/Kconfig b/Kconfig index 9ac816abef1c..985b09680934 100644 --- a/Kconfig +++ b/Kconfig @@ -75,6 +75,18 @@ config CLANG_VERSION config CC_IS_MSYS def_bool $(success,uname -o | grep -q Msys) +config WEAK_SYMBOLS + bool "Enable use of weak symbols" + default y if !CC_IS_MSYS + help + The Portable Executable (PE) format used by Windows does not support + weak symbols very well. Even where it can be made to work, the __weak + function attribute cannot be made to work with PE. Supporting weak + symbols would involve changing the source code in undesirable ways. + + This option controls whether weak symbols are used, or not. When + disabled, the __weak function attribute does nothing. + choice prompt "Optimization level" default CC_OPTIMIZE_FOR_SIZE diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index 44c9a08d7346..c954109a065b 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -268,6 +268,10 @@ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute */ +#ifdef CONFIG_WEAK_SYMBOLS #define __weak __attribute__((__weak__)) +#else +#define __weak +#endif #endif /* __LINUX_COMPILER_ATTRIBUTES_H */ -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 25/30] sandbox: Allow weak symbols to be dropped
The sandbox build makes use of a small number of weak symbols. Allow these to be dropped when building for the PE format, since its support for weak symbols is poor. Signed-off-by: Simon Glass --- (no changes since v1) cmd/bootefi.c | 3 ++- cmd/bootz.c | 3 +++ common/usb.c | 3 +++ drivers/core/root.c | 3 +++ drivers/spi/sandbox_spi.c | 3 +++ env/env.c | 6 ++ lib/efi_loader/efi_image_loader.c | 3 +++ lib/efi_loader/efi_runtime.c | 4 lib/lmb.c | 4 +++- lib/time.c| 3 +++ 10 files changed, 33 insertions(+), 2 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 8aa15a64c836..21e4a87da53a 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -358,7 +358,8 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) u16 *exit_data = NULL; /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ - switch_to_non_secure_mode(); + if (IS_ENABLED(CONFIG_WEAK_SYMBOLS)) + switch_to_non_secure_mode(); /* * The UEFI standard requires that the watchdog timer is set to five diff --git a/cmd/bootz.c b/cmd/bootz.c index f1423573d23d..1ffafbd6f2b9 100644 --- a/cmd/bootz.c +++ b/cmd/bootz.c @@ -13,6 +13,8 @@ #include #include +#ifdef CONFIG_WEAK_SYMBOLS + int __weak bootz_setup(ulong image, ulong *start, ulong *end) { /* Please define bootz_setup() for your platform */ @@ -20,6 +22,7 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end) puts("Your platform's zImage format isn't supported yet!\n"); return -1; } +#endif /* * zImage booting support diff --git a/common/usb.c b/common/usb.c index ae9253dfc0ed..cff53254a379 100644 --- a/common/usb.c +++ b/common/usb.c @@ -1220,6 +1220,8 @@ int usb_new_device(struct usb_device *dev) } #endif +#ifdef CONFIG_WEAK_SYMBOLS + __weak int board_usb_init(int index, enum usb_init_type init) { @@ -1231,6 +1233,7 @@ int board_usb_cleanup(int index, enum usb_init_type init) { return 0; } +#endif /* CONFIG_WEAK_SYMBOLS */ bool usb_device_has_child_on_port(struct usb_device *parent, int port) { diff --git a/drivers/core/root.c b/drivers/core/root.c index c4fb48548bb3..e311f93a08c9 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -347,10 +347,13 @@ int dm_extended_scan(bool pre_reloc_only) } #endif +#ifdef CONFIG_WEAK_SYMBOLS + __weak int dm_scan_other(bool pre_reloc_only) { return 0; } +#endif #if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY) void *dm_priv_to_rw(void *priv) diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c index f844597d04cf..f68c9f33bdb4 100644 --- a/drivers/spi/sandbox_spi.c +++ b/drivers/spi/sandbox_spi.c @@ -41,12 +41,15 @@ struct sandbox_spi_priv { uint mode; }; +#ifdef CONFIG_WEAK_SYMBOLS + __weak int sandbox_spi_get_emul(struct sandbox_state *state, struct udevice *bus, struct udevice *slave, struct udevice **emulp) { return -ENOENT; } +#endif uint sandbox_spi_get_speed(struct udevice *dev) { diff --git a/env/env.c b/env/env.c index ad774f41175b..bcc66b4a6a12 100644 --- a/env/env.c +++ b/env/env.c @@ -53,6 +53,8 @@ static struct env_driver *_env_driver_lookup(enum env_location loc) return NULL; } +#ifdef CONFIG_WEAK_SYMBOLS + static enum env_location env_locations[] = { #ifdef CONFIG_ENV_IS_IN_EEPROM ENVL_EEPROM, @@ -88,6 +90,7 @@ static enum env_location env_locations[] = { ENVL_NOWHERE, #endif }; +#endif /* CONFIG_WEAK_SYMBOLS */ static bool env_has_inited(enum env_location location) { @@ -106,6 +109,8 @@ static void env_set_inited(enum env_location location) gd->env_has_init |= BIT(location); } +#ifdef CONFIG_WEAK_SYMBOLS + /** * arch_env_get_location() - Returns the best env location for an arch * @op: operations performed on the environment @@ -155,6 +160,7 @@ __weak enum env_location env_get_location(enum env_operation op, int prio) { return arch_env_get_location(op, prio); } +#endif /* CONFIG_WEAK_SYMBOLS */ /** * env_driver_lookup() - Finds the most suited environment location diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index 26df0da16c93..c473cd58cfb8 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -174,10 +174,13 @@ static efi_status_t efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel, return EFI_SUCCESS; } +#ifdef CONFIG_WEAK_SYMBOLS + void __weak invalidate_icache_all(void) { /* If the system doesn't support icache_all flush, cross our fingers */ } +#endif /** * efi_set_code_and_data_type() - determine the memory types to be used for code diff --git
[PATCH v2 24/30] sandbox: Provide an EFI link script for PE
Add another case for sandbox, when it is built on Windows. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/config.mk | 4 +- arch/x86/lib/crt0_x86_64_efi.S | 2 + arch/x86/lib/pe_x86_64_efi.lds | 83 ++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 arch/x86/lib/pe_x86_64_efi.lds diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index c97c39d4301b..d397ae3fe29b 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -44,7 +44,9 @@ cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \ -Wl,--no-whole-archive \ $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections) -ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64)) +ifneq ($(MSYS_VERSION),0) +EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/pe_x86_64_efi.lds +else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64)) EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds EFI_TARGET := --target=efi-app-x86_64 else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86)) diff --git a/arch/x86/lib/crt0_x86_64_efi.S b/arch/x86/lib/crt0_x86_64_efi.S index 47ed5af97228..cd61b4bdd82f 100644 --- a/arch/x86/lib/crt0_x86_64_efi.S +++ b/arch/x86/lib/crt0_x86_64_efi.S @@ -15,6 +15,7 @@ _start: subq $8, %rsp +#ifndef __CYGWIN__ pushq %rcx pushq %rdx @@ -28,6 +29,7 @@ _start: testq %rax, %rax jnz .exit +#endif call efi_main .exit: diff --git a/arch/x86/lib/pe_x86_64_efi.lds b/arch/x86/lib/pe_x86_64_efi.lds new file mode 100644 index ..1ee08f6e662e --- /dev/null +++ b/arch/x86/lib/pe_x86_64_efi.lds @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * U-Boot EFI linker script + * + * Modified from usr/lib32/elf_x86_64_efi.lds in gnu-efi + */ + +OUTPUT_FORMAT("pe-x86-64", "pe-x86-64", "pe-x86-64") +OUTPUT_ARCH(i386:x86-64) +ENTRY(_start) +SECTIONS +{ + image_base = .; + .hash : { *(.hash) }/* this MUST come first, EFI expects it */ + . = ALIGN(4096); + .eh_frame : { + *(.eh_frame) + } + + . = ALIGN(4096); + + .text : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + } + + . = ALIGN(4096); + + .reloc : { + *(.reloc) + } + + . = ALIGN(4096); + + .data : { + *(.rodata*) + *(.got.plt) + *(.got) + *(.data*) + *(.sdata) + /* the EFI loader doesn't seem to like a .bss section, so we stick +* it all into .data: */ + *(.sbss) + *(.scommon) + *(.dynbss) + *(.bss*) + *(COMMON) + *(.rel.local) + + /* U-Boot lists and device tree */ + . = ALIGN(8); + *(SORT(__u_boot_list*)); + . = ALIGN(8); + *(.dtb*); + } + + . = ALIGN(4096); + .dynamic : { *(.dynamic) } + . = ALIGN(4096); + + .rela : { + *(.rela.data*) + *(.rela.got) + *(.rela.stab) +*(.rela__u_boot_list*) + } + + . = ALIGN(4096); + .dynsym : { *(.dynsym) } + . = ALIGN(4096); + .dynstr : { *(.dynstr) } + . = ALIGN(4096); + +/DISCARD/ : { *(.eh_frame) } + + .ignored.reloc : { + *(.rela.reloc) + *(.note.GNU-stack) + } + + .comment 0 : { *(.comment) } +} -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 23/30] sandbox: Augment the linker script for MSYS2
We need to place the linker lists, etc. in the .rdata section but this is not possible with the default linker script. We can only add new sections, which causes Windows to give an "Exec format error" error. Add a rule to create a new linker script, by obtaining the one from the linker and adding some things to the end of the .rdata section. Signed-off-by: Simon Glass --- Changes in v2: - Add an awk script to augment the built-in link script Makefile | 17 - arch/sandbox/config.mk| 19 ++- arch/sandbox/cpu/u-boot-pe.lds.in | 25 + scripts/add_to_rdata.awk | 25 + 4 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 arch/sandbox/cpu/u-boot-pe.lds.in create mode 100644 scripts/add_to_rdata.awk diff --git a/Makefile b/Makefile index a328652f0f23..760c143049aa 100644 --- a/Makefile +++ b/Makefile @@ -1734,6 +1734,12 @@ else u-boot-keep-syms-lto := endif +ifeq ($(MSYS_VERSION),0) +add_ld_script := -T u-boot.lds +else +add_ld_script := u-boot.lds +endif + # Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk ifeq ($(LTO_ENABLE),y) @@ -1742,7 +1748,7 @@ quiet_cmd_u-boot__ ?= LTO $@ $(CC) -nostdlib -nostartfiles \ $(LTO_FINAL_LDFLAGS) $(c_flags) \ $(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_u-boot:%=-Wl,%) -o $@ \ - -T u-boot.lds $(u-boot-init) \ + $(add_ld_script) $(u-boot-init) \ -Wl,--whole-archive \ $(u-boot-main) \ $(u-boot-keep-syms-lto) \ @@ -1753,7 +1759,7 @@ quiet_cmd_u-boot__ ?= LTO $@ else quiet_cmd_u-boot__ ?= LD $@ cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ - -T u-boot.lds $(u-boot-init) \ + $(add_ld_script) $(u-boot-init) \ --whole-archive \ $(u-boot-main) \ --no-whole-archive \ @@ -1905,10 +1911,11 @@ endif # prepare2 creates a makefile if using a separate output directory prepare2: prepare3 outputmakefile cfg +# Allow the linker script to be generated from LDSCRIPT_IN prepare1: prepare2 $(version_h) $(timestamp_h) $(dt_h) $(env_h) \ - include/config/auto.conf -ifeq ($(wildcard $(LDSCRIPT)),) - @echo >&2 " Could not find linker script." + include/config/auto.conf $(if $(LDSCRIPT_IN),$(LDSCRIPT)) +ifeq ($(wildcard $(LDSCRIPT))$(LDSCRIPT_IN),) + @echo >&2 " Could not find linker script $(LDSCRIPT)" @/bin/false endif diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 2d184c5f652a..c97c39d4301b 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0+ + # SPDX-License-Identifier: GPL-2.0+ # Copyright (c) 2011 The Chromium OS Authors. PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE @@ -71,3 +71,20 @@ EFI_CRT0 := crt0_sandbox_efi.o EFI_RELOC := reloc_sandbox_efi.o AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)" CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)" + +ifneq ($(MSYS_VERSION),0) +LDSCRIPT := $(objtree)/u-boot-pe.lds + +AWK_RDATA := ${srctree}/scripts/add_to_rdata.awk +LDSCRIPT_IN := ${srctree}/arch/sandbox/cpu/u-boot-pe.lds.in + +quiet_cmd_gen_lds = GEN LDS $@ +cmd_gen_lds = echo "int main() { return 0; }" | $(CC) -x c - -Wl,-verbose | \ + awk -f $(AWK_RDATA) -v INFILE=$< >$@ + +# Write out the contents of INFILE immediately before the close of the .rdata +# block +$(LDSCRIPT): $(LDSCRIPT_IN) $(AWK_RDATA) FORCE + $(call if_changed,gen_lds) + +endif diff --git a/arch/sandbox/cpu/u-boot-pe.lds.in b/arch/sandbox/cpu/u-boot-pe.lds.in new file mode 100644 index ..0ec7ef3bb350 --- /dev/null +++ b/arch/sandbox/cpu/u-boot-pe.lds.in @@ -0,0 +1,25 @@ + /* U-Boot additions from here on */ + . = ALIGN(4); + KEEP(*(SORT(__u_boot_list*))); + + *(_u_boot_sandbox_getopt_start) + *(_u_boot_sandbox_getopt) + *(_u_boot_sandbox_getopt_end) + + *(___efi_runtime_start) + *(efi_runtime_text) + *(efi_runtime_data) + *(___efi_runtime_stop) + + *(___efi_runtime_rel_start) + *(.relefi_runtime_text) + *(.relefi_runtime_data) + *(___efi_runtime_rel_stop) + + . = ALIGN(4); + *(.rodata.ttf.init) + *(.rodata.splash.init) +
[PATCH v2 22/30] Makefile: Correct the ans1_compiler rule for MSYS2
Add the required extension to the Makefile rule. Signed-off-by: Simon Glass --- Changes in v2: - Use EXEEXT instead of ELFEXT Makefile | 1 + scripts/Makefile.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 240562dff00b..a328652f0f23 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ ifeq ($(MSYS_VERSION),0) export LIBEXT := so else export LIBEXT := dll +export EXEEXT := .exe endif # Avoid funny character set dependencies diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 97dd4a64f6ef..a494e2f105b8 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -309,7 +309,7 @@ quiet_cmd_asn1_compiler = ASN.1 $@ cmd_asn1_compiler = $(objtree)/tools/asn1_compiler $< \ $(subst .h,.c,$@) $(subst .c,.h,$@) -$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/tools/asn1_compiler +$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/tools/asn1_compiler$(EXEEXT) $(call cmd,asn1_compiler) # Build the compiled-in targets -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 21/30] Makefile: Disable unsupported compiler options with PE
The MSYS2 compiler does not support some of these options. Drop them to avoid build errors. Signed-off-by: Simon Glass --- Changes in v2: - Use cc-option and ld-option instead Makefile | 2 +- scripts/Makefile.lib | 5 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2453a80eca62..240562dff00b 100644 --- a/Makefile +++ b/Makefile @@ -819,7 +819,7 @@ KBUILD_CPPFLAGS += $(KCPPFLAGS) KBUILD_AFLAGS += $(KAFLAGS) KBUILD_CFLAGS += $(KCFLAGS) -KBUILD_LDFLAGS += -z noexecstack +KBUILD_LDFLAGS += $(call ld-option,-znoexecstack) KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments) KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7b27224b5d44..aaae37d50a43 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -425,7 +425,10 @@ cmd_efi_objcopy = $(OBJCOPY) -j .header -j .text -j .sdata -j .data -j \ $(obj)/%.efi: $(obj)/%_efi.so $(call cmd,efi_objcopy) -KBUILD_EFILDFLAGS = -nostdlib -zexecstack -znocombreloc -znorelro +KBUILD_EFILDFLAGS := -nostdlib +KBUILD_EFILDFLAGS += $(call ld-option,-zexecstack) +KBUILD_EFILDFLAGS += $(call ld-option,-znocombreloc) +KBUILD_EFILDFLAGS += $(call ld-option,-znorelro) KBUILD_EFILDFLAGS += $(call ld-option,--no-warn-rwx-segments) quiet_cmd_efi_ld = LD $@ cmd_efi_ld = $(LD) $(KBUILD_EFILDFLAGS) -T $(EFI_LDS_PATH) \ -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 20/30] sandbox: Fix up setting of monitor_len on MSYS2
The required linker symbols are not present. For now just return 0 in this case. Signed-off-by: Simon Glass --- (no changes since v1) common/board_f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/board_f.c b/common/board_f.c index 1688e27071fc..4f380d7c82c8 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -290,7 +290,7 @@ static int setup_mon_len(void) { #if defined(__ARM__) || defined(__MICROBLAZE__) gd->mon_len = (ulong)&__bss_end - (ulong)_start; -#elif defined(CONFIG_SANDBOX) && !defined(__riscv) +#elif defined(CONFIG_SANDBOX) && !defined(__riscv) && !defined(__MSYS__) gd->mon_len = (ulong)&_end - (ulong)_init; #elif defined(CONFIG_SANDBOX) /* gcc does not provide _init in crti.o on RISC-V */ -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 19/30] sandbox: Drop signal handling for MSYS2
The Linux register format used on Linux (and perhaps other OSes) is not used on Windows, so disable this feature. Signed-off-by: Simon Glass --- Changes in v2: - Update commit message to mention other OSes - Check for __MSYS__ instead of __linux arch/sandbox/cpu/os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index e76568ebdd32..522fe8a6f2b1 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -288,7 +288,7 @@ static void os_signal_handler(int sig, siginfo_t *info, void *con) ucontext_t __maybe_unused *context = con; unsigned long pc; -#if defined(__x86_64__) +#if defined(__x86_64__) && !defined(__MSYS__) pc = context->uc_mcontext.gregs[REG_RIP]; #elif defined(__aarch64__) pc = context->uc_mcontext.pc; -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 18/30] sandbox: Disable raw Ethernet on MSYS2
This relies on Linux features so cannot be built for Windows. Drop it. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/Makefile | 2 ++ drivers/net/Makefile | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile index 7c5c52652f5c..be6b57692dd5 100644 --- a/arch/sandbox/cpu/Makefile +++ b/arch/sandbox/cpu/Makefile @@ -9,7 +9,9 @@ obj-y := cache.o cpu.o state.o extra-y:= start.o os.o extra-$(CONFIG_SANDBOX_SDL)+= sdl.o obj-$(CONFIG_SPL_BUILD)+= spl.o +ifeq ($(MSYS_VERSION),0) obj-$(CONFIG_ETH_SANDBOX_RAW) += eth-raw-os.o +endif # os.c is build in the system environment, so needs standard includes # CFLAGS_REMOVE_os.o cannot be used to drop header include path diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 46a40e2ed9f8..6580f8d85510 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -30,8 +30,10 @@ obj-$(CONFIG_ETH_DESIGNWARE_MESON8B) += dwmac_meson8b.o obj-$(CONFIG_ETH_DESIGNWARE_S700) += dwmac_s700.o obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o obj-$(CONFIG_ETH_SANDBOX) += sandbox.o +ifeq ($(MSYS_VERSION),0) obj-$(CONFIG_ETH_SANDBOX_RAW) += sandbox-raw-bus.o obj-$(CONFIG_ETH_SANDBOX_RAW) += sandbox-raw.o +endif obj-$(CONFIG_FEC_MXC) += fec_mxc.o obj-$(CONFIG_FMAN_ENET) += fm/ obj-$(CONFIG_FMAN_ENET) += fsl_mdio.o -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 17/30] Kbuild: Detect including an MSYS2 path
The source-tree directory is prepended to relative include paths, but this does not work on Windows, where a path may have a drive letter like C: at the start of it. This breaks SDL which includes an absolute path to the header directory to the C flags, e.g. -IC:/msys64/mingw64/include/SDL2 Add this as a special case to leave these absolute paths alone on Windows. Signed-off-by: Simon Glass --- (no changes since v1) scripts/Kbuild.include | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 62e0207f91b4..411a768a7767 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -205,9 +205,10 @@ clean := -f $(srctree)/scripts/Makefile.clean obj hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj # Prefix -I with $(srctree) if it is not an absolute path. +# Detect C: (C drive) with MSYS2 # skip if -I has no parameter addtree = $(if $(patsubst -I%,%,$(1)), \ -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) +$(if $(filter-out -I/% -I./% -I../% -IC:%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) # Find all -I options and call addtree flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 16/30] Makefile: Disable LTO when not building with gcc
For MSYS2 this creates a lot of errors of the form: `__stack_chk_fail' referenced in section `.text' of ...ltrans.o: defined in discarded section `.text' of common/stackprot.o (symbol from plugin) For clang it doesn't work, except with sandbox. Update the dependency to (hopefully) deal with all of that. Signed-off-by: Simon Glass --- Changes in v2: - Make LTO depend on !MSYS2 rather than adding another check - Also disable LTO for clang, except with sandbox Kconfig | 5 + 1 file changed, 5 insertions(+) diff --git a/Kconfig b/Kconfig index 888b9984ac3b..9ac816abef1c 100644 --- a/Kconfig +++ b/Kconfig @@ -72,6 +72,9 @@ config CLANG_VERSION int default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) +config CC_IS_MSYS + def_bool $(success,uname -o | grep -q Msys) + choice prompt "Optimization level" default CC_OPTIMIZE_FOR_SIZE @@ -121,6 +124,8 @@ config ARCH_SUPPORTS_LTO config LTO bool "Enable Link Time Optimizations" depends on ARCH_SUPPORTS_LTO + depends on CC_IS_GCC || (CC_IS_CLANG && SANDBOX) + depends on !CC_IS_MSYS help This option enables Link Time Optimization (LTO), a mechanism which allows the compiler to optimize between different compilation units. -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 15/30] ctype: Avoid using a symlink
Windows doesn't really support symlinks so fails to build this file. Use a single-line #include instead. Signed-off-by: Simon Glass --- (no changes since v1) include/ctype.h | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) mode change 12 => 100644 include/ctype.h diff --git a/include/ctype.h b/include/ctype.h deleted file mode 12 index 9e43f9c6c6c4.. --- a/include/ctype.h +++ /dev/null @@ -1 +0,0 @@ -linux/ctype.h \ No newline at end of file diff --git a/include/ctype.h b/include/ctype.h new file mode 100644 index ..155e3c63e59d --- /dev/null +++ b/include/ctype.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2023 Google LLC + */ + +#include -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 14/30] test: Avoid strange symbols in the assembler file
This works correctly on Linux with ELF but not on Windows with PE, since it creates assembly symbols with invalid names. Use the lowest/highest valid characters instead. This should still work correctly, since we have no tests starting with $ and none starting with 'zz' at present. Signed-off-by: Simon Glass --- Changes in v2: - Update comment and use zz to make it less likely we have a problem include/test/test.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/test/test.h b/include/test/test.h index 838e3ce8a8f3..fd07238a7b0b 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -126,9 +126,9 @@ struct unit_test { #define UNIT_TEST_SUITE_COUNT(_suite) \ ll_entry_count(struct unit_test, ut_ ## _suite) -/* Use ! and ~ so that all tests will be sorted between these two values */ -#define UNIT_TEST_ALL_START() ll_entry_start(struct unit_test, ut_!) -#define UNIT_TEST_ALL_END()ll_entry_start(struct unit_test, ut_~) +/* Use $ and zz so that all tests will be sorted between these two values */ +#define UNIT_TEST_ALL_START() ll_entry_start(struct unit_test, ut_$) +#define UNIT_TEST_ALL_END()ll_entry_start(struct unit_test, ut_zz) #define UNIT_TEST_ALL_COUNT() (UNIT_TEST_ALL_END() - UNIT_TEST_ALL_START()) /* Sizes for devres tests */ -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 13/30] sandbox: Drop inclusion of os.h in sscanf.c
There is no need for this file and it should not be included unless sandbox is being used. Drop it. Signed-off-by: Simon Glass --- (no changes since v1) lib/sscanf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/sscanf.c b/lib/sscanf.c index 4c35c035fe10..b79f6d79255c 100644 --- a/lib/sscanf.c +++ b/lib/sscanf.c @@ -17,7 +17,6 @@ #if !defined HAVE_LIBC -#include #include #include #include -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 12/30] sandbox: Drop incorrect inclusion of linux/types.h
This header file should only be included in U-Boot standalone files, not those built in the Linux environment. When not building for Linux, the header file does not exist, except in the U-Boot tree. In any case, it should not be used. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/os.c | 1 - include/os.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 9e93a0fa571f..e76568ebdd32 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/include/os.h b/include/os.h index 968412b0a822..561ef1264b13 100644 --- a/include/os.h +++ b/include/os.h @@ -11,8 +11,6 @@ #ifndef __OS_H__ #define __OS_H__ -#include - struct rtc_time; struct sandbox_state; -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 11/30] sections: Drop use of linux/types.h
Use 'unsigned long' instead of 'ulong' so this file does not need to include the linux/types.h header file. This allows it to be built with MSYS2. Signed-off-by: Simon Glass --- (no changes since v1) include/asm-generic/sections.h | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index 267f1db73f23..4ed9a8478cc5 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -8,8 +8,6 @@ #ifndef _ASM_GENERIC_SECTIONS_H_ #define _ASM_GENERIC_SECTIONS_H_ -#include - /* References to section boundaries */ extern char _text[], _stext[], _etext[]; @@ -71,7 +69,7 @@ extern char __image_copy_end[]; extern void _start(void); /* - * ARM defines its symbols as char[]. Other arches define them as ulongs. + * ARM defines its symbols as char[]. Other archs define them as unsigned long */ #ifdef CONFIG_ARM @@ -86,13 +84,13 @@ extern char __rel_dyn_end[]; #else /* don't use offsets: */ /* Exports from the Linker Script */ -extern ulong __data_end; -extern ulong __rel_dyn_start; -extern ulong __rel_dyn_end; -extern ulong __bss_end; -extern ulong _image_binary_end; +extern unsigned long __data_end; +extern unsigned long __rel_dyn_start; +extern unsigned long __rel_dyn_end; +extern unsigned long __bss_end; +extern unsigned long _image_binary_end; -extern ulong _TEXT_BASE; /* code start */ +extern unsigned long _TEXT_BASE; /* code start */ #endif -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 10/30] sandbox: Include errno.h in the test header
Add this so that the header file can used without first including the errno.h header. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/include/asm/test.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index e482271fe975..86968ea6d345 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -8,6 +8,7 @@ #ifndef __ASM_TEST_H #define __ASM_TEST_H +#include #include #include -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 09/30] sandbox: Correct SDL.h header inclusion
We rely on sdl-config to provide the include directory for this header file, so should not add the include directory in the C file. Drop it so that this works as expected on Windows. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/sdl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index 2c570ed8d164..31d3e9c32dec 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include /** -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 08/30] sandbox: Drop dead code from Makefile
This is not used, since the same code appears in cpu/Makefile Drop it. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/Makefile | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile index a335f8acfde6..f6cf859f249c 100644 --- a/arch/sandbox/Makefile +++ b/arch/sandbox/Makefile @@ -4,10 +4,3 @@ head-y := arch/sandbox/cpu/start.o arch/sandbox/cpu/os.o head-$(CONFIG_SANDBOX_SDL) += arch/sandbox/cpu/sdl.o libs-y += arch/sandbox/cpu/ libs-y += arch/sandbox/lib/ - -# sdl.c fails to compile with -fshort-wchar using musl. -cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \ - $(patsubst -I%,-idirafter%,$(c_flags))) -fno-lto -c -o $@ $< - -$(obj)/sdl.o: $(src)/sdl.c FORCE - $(call if_changed_dep,cc_sdl.o) -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 07/30] mkimage: Correct checking of configuration node
This returns a negative value on error. Update the logic to detect this and avoid a segfault when the node is not found. Signed-off-by: Simon Glass --- (no changes since v1) tools/image-host.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/image-host.c b/tools/image-host.c index 4a24dee8153c..e4e44e33badd 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -1336,8 +1336,10 @@ int fit_check_sign(const void *fit, const void *key, int ret; cfg_noffset = fit_conf_get_node(fit, fit_uname_config); - if (!cfg_noffset) + if (cfg_noffset < 0) { + fprintf(stderr, "Configuration node not found\n"); return -1; + } printf("Verifying Hash Integrity for node '%s'... ", fdt_get_name(fit, cfg_noffset, NULL)); -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 06/30] Fix Makefile warning about parallel targets
These targets are not really parallel; they are handled one at a time when invoked by other rules. Some recent versions of make (e.g. on MSYS2) give a warning about this. Split out the rules to avoid the warning. Signed-off-by: Simon Glass --- (no changes since v1) tools/Makefile | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/Makefile b/tools/Makefile index 38699b069d63..22ae5c30351f 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -263,7 +263,16 @@ HOSTCFLAGS_sha512.o := -pedantic -DCONFIG_SHA512 -DCONFIG_SHA384 quiet_cmd_wrap = WRAP$@ cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@ -$(obj)/boot/%.c $(obj)/common/%.c $(obj)/env/%.c $(obj)/lib/%.c: +$(obj)/boot/%.c: + $(call cmd,wrap) + +$(obj)/common/%.c: + $(call cmd,wrap) + +$(obj)/env/%.c: + $(call cmd,wrap) + +$(obj)/lib/%.c: $(call cmd,wrap) clean-dirs := lib common -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 05/30] pylibfdt: Allow building on Windows
Handle the different shared-object extension with MSYS2 by creating a new SOEXT variable. Signed-off-by: Simon Glass --- Changes in v2: - Use LIBEXT instead of SOEXT Makefile | 11 +++ scripts/dtc/pylibfdt/Makefile | 16 +--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 166acba27032..2453a80eca62 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,17 @@ else ifeq ("riscv64", $(MK_ARCH)) endif undefine MK_ARCH +# Building on Windows with MSYS2 +export MSYS_VERSION = $(if $(findstring Msys, $(shell uname -o)),$(word 1, $(subst ., ,$(shell uname -r))),0) +# $(info The version of MSYS you are running is $(MSYS_VERSION) (0 meaning not MSYS at all)) + +# Sets the extension to use for shared-object files +ifeq ($(MSYS_VERSION),0) +export LIBEXT := so +else +export LIBEXT := dll +endif + # Avoid funny character set dependencies unexport LC_ALL LC_COLLATE=C diff --git a/scripts/dtc/pylibfdt/Makefile b/scripts/dtc/pylibfdt/Makefile index e442d5c24201..314ef91e527b 100644 --- a/scripts/dtc/pylibfdt/Makefile +++ b/scripts/dtc/pylibfdt/Makefile @@ -7,6 +7,8 @@ LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt) include $(LIBFDT_srcdir)/Makefile.libfdt +LIBFILE := _libfdt.$(LIBEXT) + # Unfortunately setup.py (or actually the Python distutil implementation) puts # files into the same directory as the .i file. We cannot touch the source # directory, so we "ship" .i file into the objtree. @@ -29,16 +31,16 @@ quiet_cmd_pymod = PYMOD $@ rebuild: $(src)/setup.py $(PYLIBFDT_srcs) @# Remove the library since otherwise Python doesn't seem to regenerate @# the libfdt.py file if it is missing. - @rm -f $(obj)/_libfdt*.so + @rm -f $(obj)/_libfdt*.$(LIBEXT) $(call if_changed,pymod) - @# Rename the file to _libfdt.so so this Makefile doesn't run every time - @if [ ! -e $(obj)/_libfdt.so ]; then \ - mv $(obj)/_libfdt*.so $(obj)/_libfdt.so; \ + @# Rename the file to $(LIBFILE) so this Makefile doesn't run every time + @if [ ! -e $(obj)/$(LIBFILE) ]; then \ + mv $(obj)/_libfdt*.$(LIBEXT) $(obj)/$(LIBFILE); \ fi -$(obj)/_libfdt.so $(obj)/libfdt.py &: rebuild +$(obj)/$(LIBFILE) $(obj)/libfdt.py &: rebuild @: -always += _libfdt.so libfdt.py +always += $(LIBFILE) libfdt.py -clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c +clean-files += libfdt.i $(LIBFILE) libfdt.py libfdt_wrap.c -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 04/30] binman: Avoid using a symlink
Use a small Python script instead of a symlink to avoid problems with Windows. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/binman | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) mode change 12 => 100755 tools/binman/binman diff --git a/tools/binman/binman b/tools/binman/binman deleted file mode 12 index 11a5d8e18ab7.. --- a/tools/binman/binman +++ /dev/null @@ -1 +0,0 @@ -main.py \ No newline at end of file diff --git a/tools/binman/binman b/tools/binman/binman new file mode 100755 index ..2b0633073abc --- /dev/null +++ b/tools/binman/binman @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0+ + +import os + +our_path = os.path.dirname(os.path.realpath(__file__)) + +import main + +main.start_binman() -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 01/30] u_boot_pylib: Correct name of readme
This has an rst prefix rather than md. Fix it. Signed-off-by: Simon Glass --- (no changes since v1) tools/u_boot_pylib/README.rst | 2 +- tools/u_boot_pylib/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/u_boot_pylib/README.rst b/tools/u_boot_pylib/README.rst index 93858f5571da..b1bab4364896 100644 --- a/tools/u_boot_pylib/README.rst +++ b/tools/u_boot_pylib/README.rst @@ -1,6 +1,6 @@ .. SPDX-License-Identifier: GPL-2.0+ -# U-Boot Python Library +U-Boot Python Library = This is a Python library used by various U-Boot tools, including patman, diff --git a/tools/u_boot_pylib/pyproject.toml b/tools/u_boot_pylib/pyproject.toml index 3f33caf6f8d2..31a4c0adae87 100644 --- a/tools/u_boot_pylib/pyproject.toml +++ b/tools/u_boot_pylib/pyproject.toml @@ -9,7 +9,7 @@ authors = [ { name="Simon Glass", email="s...@chromium.org" }, ] description = "U-Boot python library" -readme = "README.md" +readme = "README.rst" requires-python = ">=3.7" classifiers = [ "Programming Language :: Python :: 3", -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 03/30] u_boot_pylib: Make pty optional
This library is not available on Windows. Detect this and work around it by using a normal pipe. Signed-off-by: Simon Glass --- Changes in v2: - move u_boot_pylib changes to a separate patch tools/u_boot_pylib/cros_subprocess.py | 28 ++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tools/u_boot_pylib/cros_subprocess.py b/tools/u_boot_pylib/cros_subprocess.py index cd614f38a648..35cef7333f3a 100644 --- a/tools/u_boot_pylib/cros_subprocess.py +++ b/tools/u_boot_pylib/cros_subprocess.py @@ -16,12 +16,18 @@ progress information and filter output in real time. import errno import os -import pty import select import subprocess import sys import unittest +try: +import pty +HAVE_PTY = True +except: +# For Windows +HAVE_PTY = False + # Import these here so the caller does not need to import subprocess also. PIPE = subprocess.PIPE @@ -74,11 +80,17 @@ class Popen(subprocess.Popen): stderr_pty = None if stdout == PIPE_PTY: -stdout_pty = pty.openpty() -stdout = os.fdopen(stdout_pty[1]) +if HAVE_PTY: +stdout_pty = pty.openpty() +stdout = os.fdopen(stdout_pty[1]) +else: +stdout = PIPE if stderr == PIPE_PTY: -stderr_pty = pty.openpty() -stderr = os.fdopen(stderr_pty[1]) +if HAVE_PTY: +stderr_pty = pty.openpty() +stderr = os.fdopen(stderr_pty[1]) +else: +stderr = PIPE super(Popen, self).__init__(args, stdin=stdin, stdout=stdout, stderr=stderr, shell=shell, cwd=cwd, env=env, @@ -156,6 +168,12 @@ class Popen(subprocess.Popen): Note also that if you set stderr to STDOUT, then stderr will be empty and the combined output will just be the same as stdout. """ +if not HAVE_PTY: +stdout, stderr = self.communicate(input_buf) +stdout = self.convert_data(stdout) +stderr = self.convert_data(stderr) +combined = self.convert_data(stdout + stderr) +return (stdout, stderr, combined) read_set = [] write_set = [] -- 2.40.1.495.gc816e09b53d-goog
[PATCH v2 00/30] Allow building sandbox with MSYS2
This expands the existing work to allow sandbox to build and run natively on Windows using MSYS2. This produces a native application that can run on Windows. This is quite different from using WSL to cross-compile a Linux application, which is then run in a virtual environment. It also fixes a few issues so that binman can be used. There are various limitations and some features do not work fully yet. In particular, weak functions are not well supported on Windows so these are disabled. Various minor compiler-flag and filename adjustments are also needed. This does not support SDL, so U-Boot has no display. This is potentially possible, but requires using minggw instead of the base toolchain [1] so needs to be dealt with separately. Note: This series is split into two parts: generic fixes and MSYS2 stuff. Patches up until this one should be ready to be applied: Makefile: Disable LTO when not building with gcc After that, some of the MSYS2 stuff may need more work, depending on review comments. [1] https://gist.github.com/thales17/fb2e4cff60890a51d94c6e832ad2 Changes in v2: - Split out u_boot_pylib from the subprocess patch - move u_boot_pylib changes to a separate patch - Use LIBEXT instead of SOEXT - Update comment and use zz to make it less likely we have a problem - Make LTO depend on !MSYS2 rather than adding another check - Also disable LTO for clang, except with sandbox - Update commit message to mention other OSes - Check for __MSYS__ instead of __linux - Use cc-option and ld-option instead - Use EXEEXT instead of ELFEXT - Add an awk script to augment the built-in link script - Clearify the documentation to explain the environment better - Update the cover letter to better explain the motivation Simon Glass (30): u_boot_pylib: Correct name of readme u_boot_pylib: Avoid deleting the test_util.py file u_boot_pylib: Make pty optional binman: Avoid using a symlink pylibfdt: Allow building on Windows Fix Makefile warning about parallel targets mkimage: Correct checking of configuration node sandbox: Drop dead code from Makefile sandbox: Correct SDL.h header inclusion sandbox: Include errno.h in the test header sections: Drop use of linux/types.h sandbox: Drop incorrect inclusion of linux/types.h sandbox: Drop inclusion of os.h in sscanf.c test: Avoid strange symbols in the assembler file ctype: Avoid using a symlink Makefile: Disable LTO when not building with gcc Kbuild: Detect including an MSYS2 path sandbox: Disable raw Ethernet on MSYS2 sandbox: Drop signal handling for MSYS2 sandbox: Fix up setting of monitor_len on MSYS2 Makefile: Disable unsupported compiler options with PE Makefile: Correct the ans1_compiler rule for MSYS2 sandbox: Augment the linker script for MSYS2 sandbox: Provide an EFI link script for PE sandbox: Allow weak symbols to be dropped build: Disable weak symbols for MSYS2 doc: Update the MSYS2 packages and versions doc: Show how to build sandbox for MSYS2 Makefile: Drop unwind tables for MSYS CI: Enable sandbox build for Windows .azure-pipelines.yml | 27 + Kconfig | 17 ++ Makefile | 31 -- arch/sandbox/Makefile | 7 --- arch/sandbox/config.mk| 23 +++- arch/sandbox/cpu/Makefile | 2 + arch/sandbox/cpu/os.c | 3 +- arch/sandbox/cpu/sdl.c| 2 +- arch/sandbox/cpu/u-boot-pe.lds.in | 25 arch/sandbox/include/asm/test.h | 1 + arch/x86/lib/crt0_x86_64_efi.S| 2 + arch/x86/lib/pe_x86_64_efi.lds| 83 +++ cmd/bootefi.c | 3 +- cmd/bootz.c | 3 + common/board_f.c | 2 +- common/usb.c | 3 + doc/build/gcc.rst | 40 + doc/build/tools.rst | 20 --- drivers/core/root.c | 3 + drivers/net/Makefile | 2 + drivers/spi/sandbox_spi.c | 3 + env/env.c | 6 ++ include/asm-generic/sections.h| 16 +++--- include/ctype.h | 7 ++- include/linux/compiler_attributes.h | 4 ++ include/os.h | 2 - include/test/test.h | 6 +- lib/efi_loader/Makefile | 8 +++ lib/efi_loader/efi_image_loader.c | 3 + lib/efi_loader/efi_runtime.c | 4 ++ lib/lmb.c | 4 +- lib/sscanf.c | 1 - lib/time.c| 3 + scripts/Kbuild.include| 3 +- scripts/Makefile.build| 2 +- scripts/Makefile.lib | 9 ++- scripts/add_to_rdata.awk | 25 scripts/dtc/pylibfdt/Makefile | 16 +++--- scripts/make_pip.sh | 7
[PATCH v2 02/30] u_boot_pylib: Avoid deleting the test_util.py file
This is needed, so update the removal code to keep it. Signed-off-by: Simon Glass --- Changes in v2: - Split out u_boot_pylib from the subprocess patch scripts/make_pip.sh | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/make_pip.sh b/scripts/make_pip.sh index 4602dcf61c88..ef43e028e385 100755 --- a/scripts/make_pip.sh +++ b/scripts/make_pip.sh @@ -91,7 +91,12 @@ find ${dest} -name __pycache__ -type f -exec rm {} \; find ${dest} -depth -name __pycache__ -exec rmdir 112 \; # Remove test files -rm -rf ${dest}/*test* +for path in ${dest}/*test*; do + echo ${path} + if ! [[ "${path}" =~ .*test_util.* ]]; then + rm -rf ${path} + fi +done mkdir ${dir}/tests cd ${dir} -- 2.40.1.495.gc816e09b53d-goog
[PATCH 3/3] efi: Correct .efi rules
These files should have both 'always' and 'targets' so that dependencies are detected correctly. When only 'always' is used, the target is built every time, although I am not quite sure why. Make sure each has both 'always' and 'targets' to avoid this problem. Signed-off-by: Simon Glass --- lib/efi_loader/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 13a35eae6c06..1a8c8d7cab5c 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -23,6 +23,7 @@ CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI) ifdef CONFIG_RISCV always += boothart.efi +targets += boothart.o endif ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) @@ -32,10 +33,12 @@ endif ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) always += dtbdump.efi +targets += dtbdump.o endif ifdef CONFIG_EFI_LOAD_FILE2_INITRD always += initrddump.efi +targets += initrddump.o endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o -- 2.40.1.495.gc816e09b53d-goog
[PATCH 2/3] acpi: Put the version numbers in a central place
At present two acpi files are built every time since they use a version number from version.h This is not necessary. Make use of the same technique as for the version string, so that they are build only when they change. Signed-off-by: Simon Glass --- cmd/version.c| 2 ++ include/version_string.h | 2 ++ lib/acpi/acpi_table.c| 15 +++ test/dm/acpi.c | 16 +++- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/cmd/version.c b/cmd/version.c index 190ef6a9061a..87e1fa4159c1 100644 --- a/cmd/version.c +++ b/cmd/version.c @@ -19,6 +19,8 @@ U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING const char version_string[] = U_BOOT_VERSION_STRING; +const unsigned short version_num = U_BOOT_VERSION_NUM; +const unsigned char version_num_patch = U_BOOT_VERSION_NUM_PATCH; static int do_version(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) diff --git a/include/version_string.h b/include/version_string.h index a89a6e43705e..a7d07e4cc7ca 100644 --- a/include/version_string.h +++ b/include/version_string.h @@ -4,5 +4,7 @@ #define__VERSION_STRING_H__ extern const char version_string[]; +extern const unsigned short version_num; +extern const unsigned char version_num_patch; #endif /* __VERSION_STRING_H__ */ diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 7c4189e2434b..a8d4b470001d 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -11,8 +11,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -25,12 +24,12 @@ * to have valid date. So for U-Boot version 2021.04 OEM_REVISION is set to * value 0x20210401. */ -#define OEM_REVISION U_BOOT_VERSION_NUM / 1000) % 10) << 28) | \ - (((U_BOOT_VERSION_NUM / 100) % 10) << 24) | \ - (((U_BOOT_VERSION_NUM / 10) % 10) << 20) | \ - ((U_BOOT_VERSION_NUM % 10) << 16) | \ - (((U_BOOT_VERSION_NUM_PATCH / 10) % 10) << 12) | \ - ((U_BOOT_VERSION_NUM_PATCH % 10) << 8) | \ +#define OEM_REVISION version_num / 1000) % 10) << 28) | \ + (((version_num / 100) % 10) << 24) | \ + (((version_num / 10) % 10) << 20) | \ + ((version_num % 10) << 16) | \ + (((version_num_patch / 10) % 10) << 12) | \ + ((version_num_patch % 10) << 8) | \ 0x01) int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags) diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 9634fc2e9002..818f71572c7c 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -11,10 +11,8 @@ #include #include #include -#include -#include #include -#include +#include #include #include #include @@ -26,12 +24,12 @@ #define BUF_SIZE 4096 -#define OEM_REVISION U_BOOT_VERSION_NUM / 1000) % 10) << 28) | \ - (((U_BOOT_VERSION_NUM / 100) % 10) << 24) | \ - (((U_BOOT_VERSION_NUM / 10) % 10) << 20) | \ - ((U_BOOT_VERSION_NUM % 10) << 16) | \ - (((U_BOOT_VERSION_NUM_PATCH / 10) % 10) << 12) | \ - ((U_BOOT_VERSION_NUM_PATCH % 10) << 8) | \ +#define OEM_REVISION version_num / 1000) % 10) << 28) | \ + (((version_num / 100) % 10) << 24) | \ + (((version_num / 10) % 10) << 20) | \ + ((version_num % 10) << 16) | \ + (((version_num_patch / 10) % 10) << 12) | \ + ((version_num_patch % 10) << 8) | \ 0x01) /** -- 2.40.1.495.gc816e09b53d-goog
[PATCH 1/3] Makefile: Fix incorrect FORCE deps on env rules
These rules run on every build even if nothing has changed. The FORCE dependency is only needed for if_changed, not for cmd. Drop it. Signed-off-by: Simon Glass --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 166acba27032..19503d013ab6 100644 --- a/Makefile +++ b/Makefile @@ -1808,7 +1808,7 @@ quiet_cmd_gen_envp = ENVP$@ rm -f $@; \ touch $@ ; \ fi -include/generated/env.in: include/generated/env.txt FORCE +include/generated/env.in: include/generated/env.txt $(call cmd,gen_envp) # Regenerate the environment if it changes @@ -1826,7 +1826,7 @@ quiet_cmd_envc = ENVC$@ touch $@ ; \ fi -include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE +include/generated/env.txt: $(wildcard $(ENV_FILE)) $(call cmd,envc) # Write out the resulting environment, converted to a C string -- 2.40.1.495.gc816e09b53d-goog
Re: [GIT PULL] Please pull u-boot-mpc8xx
On Sat, Apr 29, 2023 at 11:56:15AM +, Christophe Leroy wrote: > Hi Tom, > > This pull request adds support for the last CPU board from > CS GROUP France (previously CSSI). > > That CPU board called CMPCPRO has a mpc8321E CPU (Family PQII PRO hence > its name) and can be plugged in place of the CMPC885 board. > > In order to support that new board, the following changes are included > in this series: > - Make the mpc8xx watchdog driver more generic for reusing it > with mpc83xx > - Fix various small problems on mpc83xx platform > - Add a GPIO Driver for QE GPIOs > - Add support for mpc832x into mpc83xx SPI driver > - Refactor existing board code that will be shared with new board > - Add the new board > > CI: https://source.denx.de/u-boot/custodians/u-boot-mpc8xx/-/pipelines/16153 > > Thanks > Christophe > > > The following changes since commit a25dcda452bf6a6de72764a8d990d72e5def643d: > >Revert "disk: Use a helper function to reduce duplication" > (2023-04-03 10:43:37 -0400) > > are available in the Git repository at: > >g...@source.denx.de:u-boot/custodians/u-boot-mpc8xx.git for-2023.07 > > for you to fetch changes up to 4d0c8db74d83e43dec4e7481b2d1e194f51d907b: > >board: cssi: Add CPU board CMPCPRO (2023-04-28 17:52:23 +0200) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH 24/31] build: Disable weak symbols for MSYS2
Hi Pali, On Tue, 25 Apr 2023 at 10:21, Pali Rohár wrote: > > On Monday 24 April 2023 17:08:29 Simon Glass wrote: > > Weak symbols are not well supported by the PE format, so disable them. > > They are supported by PE format. This is likely issue of (older) > toolchain. What about rather requiring better toolchain version and > fix special cases of weak functions do not work correctly? What compiler are you using? How do weak symbols work in that compiler? I am using: $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/11.3.0/lto-wrapper.exe Target: x86_64-pc-msys Configured with: /c/S/gcc/src/gcc-11.3.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.3.0 (GCC) sglass@DESKTOP-OHNGJ4K MINGW64 ~/u-boot $ ld -v GNU ld (GNU Binutils) 2.40 Regards, Simon > > > We need to manually ensure that only one function is present in the source > > code. > > > > Add a Kconfig option to control this and enable it when building for > > Windows. > > > > Signed-off-by: Simon Glass > > --- > > > > Kconfig | 15 +++ > > include/linux/compiler_attributes.h | 4 > > 2 files changed, 19 insertions(+) > > > > diff --git a/Kconfig b/Kconfig > > index f24e4f0a331e..ca1402d09d10 100644 > > --- a/Kconfig > > +++ b/Kconfig > > @@ -72,6 +72,21 @@ config CLANG_VERSION > > int > > default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) > > > > +config CC_IS_MSYS > > + def_bool $(success,uname -o | grep -q Msys) > > + > > +config WEAK_SYMBOLS > > + bool "Enable use of weak symbols" > > + default y if !CC_IS_MSYS > > + help > > + The Portable Executable (PE) format used by Windows does not support > > + weak symbols very well. Even where it can be made to work, the > > __weak > > + function attribute cannot be made to work with PE. Supporting weak > > + symbols would involve changing the source code in undesirable ways. > > + > > + This option controls whether weak symbols are used, or not. When > > + disabled, the __weak function attribute does nothing. > > + > > choice > > prompt "Optimization level" > > default CC_OPTIMIZE_FOR_SIZE > > diff --git a/include/linux/compiler_attributes.h > > b/include/linux/compiler_attributes.h > > index 44c9a08d7346..c954109a065b 100644 > > --- a/include/linux/compiler_attributes.h > > +++ b/include/linux/compiler_attributes.h > > @@ -268,6 +268,10 @@ > > * gcc: > > https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute > > * gcc: > > https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute > > */ > > +#ifdef CONFIG_WEAK_SYMBOLS > > #define __weak __attribute__((__weak__)) > > +#else > > +#define __weak > > +#endif > > > > #endif /* __LINUX_COMPILER_ATTRIBUTES_H */ > > -- > > 2.40.0.634.g4ca3ef3211-goog > >
Re: [PATCH 17/31] sandbox: Allow weak symbols to be dropped
Hi Pali, On Tue, 25 Apr 2023 at 10:31, Pali Rohár wrote: > > On Tuesday 25 April 2023 10:44:17 Bin Meng wrote: > > Hi Simon, > > > > On Tue, Apr 25, 2023 at 7:09 AM Simon Glass wrote: > > > > > > The sandbox build makes use of a small number of weak symbols. Allow these > > > to be dropped when building for the PE format, since its support for weak > > > symbols is poor. > > > > > > Signed-off-by: Simon Glass > > > --- > > > > > > cmd/bootefi.c | 3 ++- > > > cmd/bootz.c | 3 +++ > > > common/usb.c | 3 +++ > > > drivers/core/root.c | 3 +++ > > > drivers/spi/sandbox_spi.c | 3 +++ > > > env/env.c | 6 ++ > > > lib/efi_loader/efi_image_loader.c | 3 +++ > > > lib/efi_loader/efi_runtime.c | 4 > > > lib/lmb.c | 4 +++- > > > lib/time.c| 3 +++ > > > 10 files changed, 33 insertions(+), 2 deletions(-) > > > > > > > You probably need to use: > > > > __declspec(selectany) > > > > to replace __weak in the ELF for the *nix world. > > > > Note this Microsoft bizarre does not provide the "strong override > > weak" effect but I suspect what you only need is to get the build pass > > on Windows so it should be okay. > > > > Regards, > > Bin > > You have selectany and external weaks support in PE format. For the > majority of weak function cases, this is enough. Cannot we use them? Not that I can tell. Can you provide a patch to linux/compiler_attributes.h which handles this? Regards, Simon
Re: [PATCH 17/31] sandbox: Allow weak symbols to be dropped
Hi Heinrich, On Mon, 24 Apr 2023 at 20:47, Heinrich Schuchardt wrote: > > > > Am 25. April 2023 01:08:22 MESZ schrieb Simon Glass : > >The sandbox build makes use of a small number of weak symbols. Allow these > >to be dropped when building for the PE format, since its support for weak > >symbols is poor. > > This comment does not explain the necessity of the change. Why is it really > needed? Has the compiler version in MSYS a problem? Yes, from what I understand, PE has never really supported weak symbols properly. I'm not sure if that has changed, but it doesn't look like it. I'm hoping there is another workaround. That said, I really don't like weak symbols and I think we should use them less. [..] Regards, Simon
Re: [PATCH 17/31] sandbox: Allow weak symbols to be dropped
Hi Bin, On Mon, 24 Apr 2023 at 20:44, Bin Meng wrote: > > Hi Simon, > > On Tue, Apr 25, 2023 at 7:09 AM Simon Glass wrote: > > > > The sandbox build makes use of a small number of weak symbols. Allow these > > to be dropped when building for the PE format, since its support for weak > > symbols is poor. > > > > Signed-off-by: Simon Glass > > --- > > > > cmd/bootefi.c | 3 ++- > > cmd/bootz.c | 3 +++ > > common/usb.c | 3 +++ > > drivers/core/root.c | 3 +++ > > drivers/spi/sandbox_spi.c | 3 +++ > > env/env.c | 6 ++ > > lib/efi_loader/efi_image_loader.c | 3 +++ > > lib/efi_loader/efi_runtime.c | 4 > > lib/lmb.c | 4 +++- > > lib/time.c| 3 +++ > > 10 files changed, 33 insertions(+), 2 deletions(-) > > > > You probably need to use: > > __declspec(selectany) > > to replace __weak in the ELF for the *nix world. > > Note this Microsoft bizarre does not provide the "strong override > weak" effect but I suspect what you only need is to get the build pass > on Windows so it should be okay. With that I get: lib/sha1.c:226:1: error: ‘selectany’ attribute applies only to initialized variables with external linkage and it dies. The line is: __weak void sha1_process(sha1_context *ctx, const unsigned char *data, unsigned int blocks) I tried adding a prototype to the header but got the same error. Regards, Simon
Re: Please pull u-boot-dm
On Fri, Apr 28, 2023 at 01:25:16PM -0600, Simon Glass wrote: > Hi Tom, > > https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/16143 > > > The following changes since commit c9c2c95d4cd27fe0cd41fe13a863899d268f973c: > > Merge branch '2023-04-27-introduce-nvm-xip-block-storage-emulation' > (2023-04-27 19:22:38 -0400) > > are available in the Git repository at: > > git://git.denx.de/u-boot-dm.git tags/dm-pull-28apr23 > > for you to fetch changes up to f43fc16812487289e98389f0f643d20c444f9c9c: > > fdt: Indicate that people should use the ofnode API (2023-04-28 > 11:52:38 -0600) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
[GIT PULL] Please pull u-boot-mpc8xx
Hi Tom, This pull request adds support for the last CPU board from CS GROUP France (previously CSSI). That CPU board called CMPCPRO has a mpc8321E CPU (Family PQII PRO hence its name) and can be plugged in place of the CMPC885 board. In order to support that new board, the following changes are included in this series: - Make the mpc8xx watchdog driver more generic for reusing it with mpc83xx - Fix various small problems on mpc83xx platform - Add a GPIO Driver for QE GPIOs - Add support for mpc832x into mpc83xx SPI driver - Refactor existing board code that will be shared with new board - Add the new board CI: https://source.denx.de/u-boot/custodians/u-boot-mpc8xx/-/pipelines/16153 Thanks Christophe The following changes since commit a25dcda452bf6a6de72764a8d990d72e5def643d: Revert "disk: Use a helper function to reduce duplication" (2023-04-03 10:43:37 -0400) are available in the Git repository at: g...@source.denx.de:u-boot/custodians/u-boot-mpc8xx.git for-2023.07 for you to fetch changes up to 4d0c8db74d83e43dec4e7481b2d1e194f51d907b: board: cssi: Add CPU board CMPCPRO (2023-04-28 17:52:23 +0200) Christophe Leroy (15): powerpc: mpc8xx: Migrate to CONFIG_SYS_CLK_FREQ watchdog: mpc8xx: Rename it mpc8xxx watchdog: mpc8xxx: Make it generic watchdog: mpc8xxx: Add support for mpc83xx powerpc: mpc832x: Fix reset word powerpc: mpc83xx: Fix soc.h powerpc: mpc83xx: Don't activate MMU when not necessary clk: mpc83xx: Fix clocks for mpc832x gpio: Add QUICC Engine GPIOs driver spi: mpc8xxx: Add support for SPI on mpc832x board: cssi: Migrate to hashed password board: cssi: Create dedicated file for common sources board: cssi: Refactor EEPROM read board: cssi: Move all mother board code into common.c board: cssi: Add CPU board CMPCPRO arch/powerpc/Kconfig | 2 +- arch/powerpc/cpu/mpc83xx/Kconfig | 5 + arch/powerpc/cpu/mpc83xx/cpu.c | 2 +- arch/powerpc/cpu/mpc83xx/hrcw/Kconfig| 3 +- arch/powerpc/cpu/mpc83xx/start.S | 4 +- arch/powerpc/cpu/mpc8xx/Kconfig | 6 +- arch/powerpc/cpu/mpc8xx/cpu_init.c | 5 +- arch/powerpc/cpu/mpc8xx/speed.c | 4 +- arch/powerpc/dts/Makefile| 1 + arch/powerpc/dts/cmpc885.dts | 12 +- arch/powerpc/dts/cmpcpro.dts | 189 + arch/powerpc/dts/mcr3000.dts | 20 +- arch/powerpc/include/asm/arch-mpc83xx/gpio.h | 5 + arch/powerpc/include/asm/arch-mpc83xx/soc.h | 16 +- arch/powerpc/include/asm/mpc8xxx_spi.h | 1 + board/cssi/MAINTAINERS | 2 + board/cssi/cmpc885/Makefile | 2 +- board/cssi/cmpc885/cmpc885.c | 241 ++-- board/cssi/cmpcpro/Kconfig | 26 ++ board/cssi/cmpcpro/Makefile | 8 + board/cssi/cmpcpro/cmpcpro.c | 404 +++ board/cssi/cmpcpro/cmpcpro.env | 8 + board/cssi/cmpcpro/nand.c| 43 +++ board/cssi/common/common.c | 219 +++ board/cssi/common/common.h | 15 + board/cssi/mcr3000/mcr3000.c | 14 - configs/CMPC885_defconfig| 9 +- configs/CMPCPRO_defconfig| 209 ++ configs/MCR3000_defconfig| 10 +- drivers/clk/mpc83xx_clk.c| 7 + drivers/gpio/Kconfig | 18 ++ drivers/gpio/Makefile| 1 + drivers/gpio/qe_gpio.c | 170 +++ drivers/spi/mpc8xxx_spi.c| 13 + drivers/watchdog/Kconfig | 26 +- drivers/watchdog/Makefile| 2 +- drivers/watchdog/mpc8xx_wdt.c| 75 - drivers/watchdog/mpc8xxx_wdt.c | 112 include/configs/cmpc885.h| 6 + include/configs/cmpcpro.h| 99 +++ 40 files changed, 1668 insertions(+), 346 deletions(-) create mode 100644 arch/powerpc/dts/cmpcpro.dts create mode 100644 board/cssi/cmpcpro/Kconfig create mode 100644 board/cssi/cmpcpro/Makefile create mode 100644 board/cssi/cmpcpro/cmpcpro.c create mode 100644 board/cssi/cmpcpro/cmpcpro.env create mode 100644 board/cssi/cmpcpro/nand.c create mode 100644 board/cssi/common/common.c create mode 100644 board/cssi/common/common.h create mode 100644 configs/CMPCPRO_defconfig create mode 100644 drivers/gpio/qe_gpio.c delete mode 100644 drivers/watchdog/mpc8xx_wdt.c create mode 100644 drivers/watchdog/mpc8xxx_wdt.c create mode 100644 include/configs/cmpcpro.h
Re: [PATCH u-boot 0/3] pci: mpc85xx: Fixes for PCI config space
On Thursday 13 April 2023 22:41:43 Pali Rohár wrote: > This patch series contains small fixes for mpc85xx old PCI Local Bus driver. > > Heiko: Are you able to test these changes? Has your Socrates board > available old PCI Local Bus support? > > Pali Rohár (3): > pci: mpc85xx: Add missing sync() after writing to PCI config space > pci: mpc85xx: Allow 8/16-bit access to PCI config space > pci: mpc85xx: Do not try to access extended PCIe registers > > drivers/pci/pci_mpc85xx.c | 39 +++ > 1 file changed, 35 insertions(+), 4 deletions(-) > > -- > 2.20.1 > Anything more here? Remaining issues are handled by the other patch series on the list.
Re: [PATCH v2 u-boot-mvebu 4/4] arm: mvebu: clearfog: Update eMMC/SD/SATA instructions
On Thursday 27 April 2023 10:56:17 Stefan Roese wrote: > Hi Pali, > > On 4/27/23 01:44, Pali Rohár wrote: > > On Thursday 13 April 2023 22:43:25 Martin Rowe wrote: > > > On Thu, 13 Apr 2023 at 20:58, Pali Rohár wrote: > > > > > > > > BootROM and neither SPL does not use eMMC boot acknowledgement or boot > > > > enable bits in EXT_CSD_PART_CONF eMMC register. And also fixed SATA disk > > > > sector 0x141 is not used at all. > > > > > > > > Signed-off-by: Pali Rohár > > > > > > SPL successfully loads u-boot from the same partition as SPL. SD card > > > and UART continue to boot. > > > > > > Thanks Pali! > > > > > > Tested-by: Martin Rowe > > > > Ok, is something more needed for this patch series? > > Unfortunately yes. As at least this board breaks with this patchset > added: > > $ make sama5d2_icp_mmc_defconfig > $ make -sj > /opt/kernel.org/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd: > u-boot-spl section `__u_boot_list' will not fit in region `.sram' > /opt/kernel.org/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd: > region `.sram' overflowed by 32 bytes > make[1]: *** [scripts/Makefile.spl:527: spl/u-boot-spl] Error 1 > make: *** [Makefile:2049: spl/u-boot-spl] Error 2 > > So CI build fails and I can't send a pull request. I'm sending a patch > though, to fix this image overflow by enabling LTO. Stay tuned... I see... LTO helped. So can be this patch series now applied? > Thanks, > Stefan > > > > > --- > > > > board/solidrun/clearfog/README | 20 ++-- > > > > 1 file changed, 10 insertions(+), 10 deletions(-) > > > > > > > > diff --git a/board/solidrun/clearfog/README > > > > b/board/solidrun/clearfog/README > > > > index ed4a712c5aa2..c86b37061a30 100644 > > > > --- a/board/solidrun/clearfog/README > > > > +++ b/board/solidrun/clearfog/README > > > > @@ -1,7 +1,7 @@ > > > > Update from original Marvell U-Boot to mainline U-Boot: > > > > --- > > > > > > > > -Generate the U-Boot image with these commands: > > > > +Generate the U-Boot image for eMMC/SD with these commands: > > > > > > > > $ make clearfog_defconfig > > > > $ make > > > > @@ -9,7 +9,7 @@ $ make > > > > The resulting image including the SPL binary with the > > > > full DDR setup is "u-boot-with-spl.kwb". > > > > > > > > -Now all you need to do is copy this image on a SD card. > > > > +Now all you need to do is copy this image on a SD card's sector 1. > > > > For example with this command: > > > > > > > > $ sudo dd if=u-boot-with-spl.kwb of=/dev/sdX bs=512 seek=1 > > > > @@ -20,12 +20,6 @@ of "/dev/sdX" here! > > > > Install U-Boot on eMMC: > > > > --- > > > > > > > > -To make SPL load the main U-Boot image from the eMMC boot partition > > > > enable > > > > -eMMC boot acknowledgement and boot partition with the following U-Boot > > > > -command: > > > > - > > > > - mmc partconf 0 1 1 0 > > > > - > > > > Install U-Boot on eMMC boot partition from Linux running on Clearfog: > > > > > > > > echo 0 > /sys/block/mmcblk0boot0/force_ro > > > > @@ -37,8 +31,14 @@ Consider initial boot from UART (see below). > > > > Install U-Boot on SATA: > > > > --- > > > > > > > > -When loading the main U-Boot image from raw SATA sector, set > > > > -CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR to 0x141. > > > > +Generate the U-Boot image for SATA with these commands: > > > > + > > > > +$ make clearfog_sata_defconfig > > > > +$ make > > > > + > > > > +Copy image on a SATA disk's sector 1: > > > > + > > > > +$ sudo dd if=u-boot-with-spl.kwb of=/dev/sdX bs=512 seek=1 > > > > > > > > Boot selection: > > > > --- > > > > -- > > > > 2.20.1 > > > > > > Viele Grüße, > Stefan Roese > > -- > DENX Software Engineering GmbH, Managing Director: Erika Unter > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de
Re: [PATCH u-boot 0/3] pci: Do not access Freescale PCI controllers BARs registers
On Friday 21 April 2023 05:54:29 Heiko Schocher wrote: > Hello Pali, > > On 20.04.23 21:44, Pali Rohár wrote: > > Freescale PCI and PCIe controllers export in config space in BARs offset > > for BDF address 00:00.0 internal controller registers, instead of BAR > > registers. Avoid access to these registers to prevent overwriting them. > > > > Fixes autoconfiguration of PCI and PCIe devices on Freescale PowerPC > > platforms. > > > > Pali Rohár (3): > > pci: mpc85xx: Do not access PCI BARs registers of BDF address 00:00.0 > > pci: fsl: Do not access PCI BAR0 register of PCIe Root Port > > pci: auto: Remove PCI_CLASS_PROCESSOR_POWERPC autoconfig case > > > > drivers/pci/pci_auto.c| 4 > > drivers/pci/pci_mpc85xx.c | 12 > > drivers/pci/pcie_fsl.c| 14 ++ > > 3 files changed, 26 insertions(+), 4 deletions(-) > > Many thanks for this series! Ok, is something more needed? > bye, > Heiko > -- > DENX Software Engineering GmbH, Managing Director: Erika Unter > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH v2 00/17] rockchip: eMMC fixes for RK3568 and support for RK3588
On 2023-04-28 12:58, Eugen Hristev wrote: > On 4/27/23 21:27, Jonas Karlman wrote: >> On 2023-04-27 17:33, Eugen Hristev wrote: >>> On 4/27/23 18:25, Jonas Karlman wrote: Hi Eugen, On 2023-04-27 16:45, Eugen Hristev wrote: > On 4/18/23 19:46, Jonas Karlman wrote: >> This series fixes eMMC HS400 modes on RK3568 and add support for RK3588. >> >> It has been tested with rock-3a-rk3568/rock5b-rk3588 defconfig and >> >> CONFIG_MMC_HS200_SUPPORT=y >> CONFIG_MMC_HS400_SUPPORT=y >> CONFIG_MMC_HS400_ES_SUPPORT=y >> CONFIG_MMC_SPEED_MODE_SET=y >> >> using the following command to switch mode and then read 512 MiB of data >> from eMMC into memory, >> >> => mmc dev 0 0 && mmc info && mmc read 1000 2000 1 >> >> for each of the modes below. >> >> 0 = MMC legacy >> 1 = MMC High Speed (26MHz) >> 3 = MMC High Speed (52MHz) >> 4 = MMC DDR52 (52MHz) >> 10 = HS200 (200MHz) >> 11 = HS400 (200MHz) >> 12 = HS400ES (200MHz) >> >> All reads have reported OK, prior to this some of these modes worked and >> others failed. >> >> Patch 1-2 fixes an issue with high-speed bit and uhs speed mode field. >> Patch 3-6 refactors the rk3568 driver to use set_clock and config_dll >> ops, so that clocks and regs are changed when output clock is disabled. >> Patch 7-10 continues refactoring and simplification of the driver. >> Patch 11-12 updates tap and delay values to fix HS400 modes on RK3568. >> Patch 13-15 adds support for RK3588 to driver and device tree. >> Patch 16-17 adds workarounds needed to use PIO mode in SPL to >> successfully load TF-A into SRAM when booting from eMMC on RK3588. >> >> Note that this series does not include any change to defconfigs to >> enable HS200/HS400/HS400ES modes. >> >> Changes in v2: >> - Add Signed-off-by tag and update commit message with a note from where >> reg-values originates from >> - Rename quirks to flags >> - Use driver data for hs200/hs400 txclk tapnum values >> - Change u-boot,dm-spl to bootph-pre-ram >> >> This series require working pinctrl, see [1]. A copy of this series and >> its dependencies can be found at [2]. >> >> [1] >> https://patchwork.ozlabs.org/project/uboot/patch/20230315153215.389809-1-eugen.hris...@collabora.com/ >> [2] https://github.com/Kwiboo/u-boot-rockchip/commits/rk35xx-emmc-v2 >> >> Jonas Karlman (16): >> mmc: sdhci: Fix HISPD bit handling for MMC HS 52MHz mode >> mmc: sdhci: Set UHS Mode Select field for UHS SDR25 mode >> mmc: rockchip_sdhci: Fix use of device private data >> mmc: rockchip_sdhci: Remove unneeded emmc_phy_init ops >> mmc: rockchip_sdhci: Add set_clock and config_dll sdhci_ops >> mmc: rockchip_sdhci: Use set_clock and config_dll sdhci_ops >> mmc: rockchip_sdhci: Refactor execute tuning error handling >> mmc: rockchip_sdhci: Update speed mode controls in set_ios_post >> mmc: rockchip_sdhci: Remove empty get_phy and set_enhanced_strobe >> ops >> mmc: rockchip_sdhci: Rearrange and simplify used regs and flags >> mmc: rockchip_sdhci: Fix HS400 and HS400ES mode on RK3568 >> rockchip: rk3568-rock-3a: Enable support for more eMMC modes >> mmc: rockchip_sdhci: Add support for RK3588 >> rockchip: rk3588-rock-5b: Include eMMC node in SPL dtb >> clk: rockchip: rk3588: Add limited TMCLK_EMMC clock support >> mmc: rockchip_sdhci: Limit number of blocks read in a single command >> >> Peter Geis (1): >> mmc: sdhci: Allow disabling of SDMA in SPL >> >> arch/arm/dts/rk3568-rock-3a-u-boot.dtsi | 8 + >> arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 12 +- >> arch/arm/dts/rk3588s-u-boot.dtsi| 4 + >> configs/rock5b-rk3588_defconfig | 1 + >> drivers/clk/rockchip/clk_rk3588.c | 2 + >> drivers/mmc/Kconfig | 8 + >> drivers/mmc/rockchip_sdhci.c| 309 >> +--- >> drivers/mmc/sdhci.c | 13 +- >> 8 files changed, 215 insertions(+), 142 deletions(-) >> > > > Hi Jonas, > > I saw in the logs you provided in the series that the SPL should also > work in eMMC in rk3588, however, I am getting this error on my rock5b : > > Trying to boot from MMC2 > spl: mmc boot mode: raw > hdr read sector 4000, count=1 > mmc_load_image_raw_sector: mmc block read error > > Do you have any idea of what's going wrong ? I know that there was some issue reading more then 4 sectors using CMD18. But here it looks like the initial 1 sector read using CMD17 fails. Try with CONFIG_MMC_VERBOSE=y,
Re: [PATCH 1/1] pci: pcie_dw_rockchip: support fixed vcc3v3 regulator type
Hi John, On 2023-04-28 20:28, John Clark wrote: > If the regulator is fixed, the call to regulator_set_value will fail with > -ENOSYS as fixed regulators do not support dm_regulator_ops->set_value. > see: regulator-uclass.c, regulator_set_value(), ops->set_value > > This patch ignores -ENOSYS and enables the regulator via > regulator_set_enable which should be suitable for all regulator types. Please see patch [1] in my series "rockchip: Fix PCIe and NVMe support on RK3568", that series fixes this and other issues to fully support PCIe and NVMe on RK3568. [1] https://patchwork.ozlabs.org/project/uboot/patch/20230422181943.889436-3-jo...@kwiboo.se/ Regards, Jonas > > Signed-off-by: John Clark > > --- > > drivers/pci/pcie_dw_rockchip.c | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c > index 9322e735b9..a30fb45222 100644 > --- a/drivers/pci/pcie_dw_rockchip.c > +++ b/drivers/pci/pcie_dw_rockchip.c > @@ -289,6 +289,13 @@ static int rockchip_pcie_init_port(struct udevice *dev) > /* Set power and maybe external ref clk input */ > if (priv->vpcie3v3) { > ret = regulator_set_value(priv->vpcie3v3, 330); > + if (ret && ret != -ENOSYS) { > + dev_err(priv->dw.dev, > + "failed to set vpcie3v3 value (ret=%d)\n", ret); > + return ret; > + } > + > + ret = regulator_set_enable(priv->vpcie3v3, true); > if (ret) { > dev_err(priv->dw.dev, "failed to enable vpcie3v3 > (ret=%d)\n", > ret);
Re: [PATCH] dm: core: introduce uclass_get_device_by_of_path()
On 28/04/2023 21.21, Simon Glass wrote: >> Looks fine but please add a test to ofnode.c > > Did you send a patch with a test? If so I missed it. No, sorry, haven't found the time yet. > Also please check my tweak to this (OF_REAL) Looks correct. Rasmus
[PATCH 2/3] cmd: tlv_eeprom: handle -ENODEV error from read_eeprom function
When tlv eeprom does not exist, return error code instead of quietly making up tlv structure in memory. Signed-off-by: Josua Mayer Cc: Stefan Roese Cc: Baruch Siach Cc: Heinrich Schuchardt --- cmd/tlv_eeprom.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c index d36401e9138..636c1fe32ef 100644 --- a/cmd/tlv_eeprom.c +++ b/cmd/tlv_eeprom.c @@ -134,6 +134,8 @@ static int read_eeprom(int devnum, u8 *eeprom) if (ret == 0 && is_valid_tlvinfo_header(eeprom_hdr)) ret = read_tlv_eeprom((void *)eeprom_tlv, HDR_SIZE, be16_to_cpu(eeprom_hdr->totallen), devnum); + else if (ret == -ENODEV) + return ret; // If the contents are invalid, start over with default contents if (!is_valid_tlvinfo_header(eeprom_hdr) || @@ -432,8 +434,13 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) // If no arguments, read the EERPOM and display its contents if (argc == 1) { if (!has_been_read) { - if (read_eeprom(current_dev, eeprom) == 0) - has_been_read = 1; + ret = read_eeprom(current_dev, eeprom); + if (ret) { + printf("Failed to read EEPROM data from device.\n"); + return 0; + } + + has_been_read = 1; } show_eeprom(current_dev, eeprom); return 0; @@ -446,11 +453,14 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) // Read the EEPROM contents if (cmd == 'r') { has_been_read = 0; - if (read_eeprom(current_dev, eeprom) == 0) { - printf("EEPROM data loaded from device to memory.\n"); - has_been_read = 1; + ret = read_eeprom(current_dev, eeprom); + if (ret) { + printf("Failed to read EEPROM data from device.\n"); + return 0; } - return 0; + + printf("EEPROM data loaded from device to memory.\n"); + has_been_read = 1; } // Subsequent commands require that the EEPROM has already been read. -- 2.35.3
[PATCH 3/3] cmd: tlv_eeprom: enable 'dev' subcommand before 'read'
Move the handler for "tlv_eeprom dev X" command to the beginning of do_tlv_eeprom, to allow using it before issuing a "read" command for currently selected eeprom. Also remove the check if eeprom exists, since that can only work after the first execution of read_eeprom triggered device lookup. Instead accept values up to the defined array size (MAX_TLV_DEVICES). Signed-off-by: Josua Mayer Cc: Stefan Roese Cc: Baruch Siach Cc: Heinrich Schuchardt --- cmd/tlv_eeprom.c | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c index 636c1fe32ef..79796394c5c 100644 --- a/cmd/tlv_eeprom.c +++ b/cmd/tlv_eeprom.c @@ -450,6 +450,22 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) // "reset" will both be treated as "read". cmd = argv[1][0]; + // select device + if (cmd == 'd') { +/* 'dev' command */ + unsigned int devnum; + + devnum = simple_strtoul(argv[2], NULL, 0); + if (devnum >= MAX_TLV_DEVICES) { + printf("Invalid device number\n"); + return 0; + } + current_dev = devnum; + has_been_read = 0; + + return 0; + } + // Read the EEPROM contents if (cmd == 'r') { has_been_read = 0; @@ -508,16 +524,6 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) tlvinfo_delete_tlv(eeprom, tcode); if (argc == 4) tlvinfo_add_tlv(eeprom, tcode, argv[3]); - } else if (cmd == 'd') { /* 'dev' command */ - unsigned int devnum; - - devnum = simple_strtoul(argv[2], NULL, 0); - if (devnum > MAX_TLV_DEVICES || !tlv_devices[devnum]) { - printf("Invalid device number\n"); - return 0; - } - current_dev = devnum; - has_been_read = 0; } else { return CMD_RET_USAGE; } -- 2.35.3
[PATCH 1/3] cmd: tlv_eeprom: remove use of global variable has_been_read
has_been_read is only used as an optimization for do_tlv_eeprom. Explicitly use and set inside this function, thus making read_eeprom stateless. Signed-off-by: Josua Mayer Cc: Stefan Roese Cc: Baruch Siach Cc: Heinrich Schuchardt --- cmd/tlv_eeprom.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c index 8049bf9843c..d36401e9138 100644 --- a/cmd/tlv_eeprom.c +++ b/cmd/tlv_eeprom.c @@ -42,8 +42,6 @@ static int set_date(char *buf, const char *string); static int set_bytes(char *buf, const char *string, int *converted_accum); static void show_tlv_devices(int current_dev); -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read; /* The EERPOM contents after being read into memory */ static u8 eeprom[TLV_INFO_MAX_LEN]; @@ -130,9 +128,6 @@ static int read_eeprom(int devnum, u8 *eeprom) struct tlvinfo_header *eeprom_hdr = to_header(eeprom); struct tlvinfo_tlv *eeprom_tlv = to_entry([HDR_SIZE]); - if (has_been_read) - return 0; - /* Read the header */ ret = read_tlv_eeprom((void *)eeprom_hdr, 0, HDR_SIZE, devnum); /* If the header was successfully read, read the TLVs */ @@ -149,10 +144,8 @@ static int read_eeprom(int devnum, u8 *eeprom) update_crc(eeprom); } - has_been_read = 1; - #ifdef DEBUG - show_eeprom(eeprom); + show_eeprom(devnum, eeprom); #endif return ret; @@ -432,10 +425,16 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) char cmd; struct tlvinfo_header *eeprom_hdr = to_header(eeprom); static unsigned int current_dev; + /* Set to 1 if we've read EEPROM into memory */ + static int has_been_read; + int ret; // If no arguments, read the EERPOM and display its contents if (argc == 1) { - read_eeprom(current_dev, eeprom); + if (!has_been_read) { + if (read_eeprom(current_dev, eeprom) == 0) + has_been_read = 1; + } show_eeprom(current_dev, eeprom); return 0; } @@ -447,8 +446,10 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) // Read the EEPROM contents if (cmd == 'r') { has_been_read = 0; - if (!read_eeprom(current_dev, eeprom)) + if (read_eeprom(current_dev, eeprom) == 0) { printf("EEPROM data loaded from device to memory.\n"); + has_been_read = 1; + } return 0; } -- 2.35.3
[PATCH 0/3] cmd: tlv_eeprom: global variables and error cleanup
This patch-set removes some uses of global variables, and improves error reporting for the "read" command. It is intended to help switching to a split tlv library eventually, but general enough to apply independently. Josua Mayer (3): cmd: tlv_eeprom: remove use of global variable has_been_read cmd: tlv_eeprom: handle -ENODEV error from read_eeprom function cmd: tlv_eeprom: enable 'dev' subcommand before 'read' cmd/tlv_eeprom.c | 61 +++- 1 file changed, 39 insertions(+), 22 deletions(-) -- 2.35.3
Enable SDP for Compulab IOT-GATE-iMX8 BOARD
Dear All, Good day! Tried enabling SDP for "Compulab IOT-GATE-iMX8 BOARD" for booting over SDP and uuu, but fails to compile. Please find the below compilation error. SRAM overflow considers the whole data section of flash.bin or is it just SPL? .config is already minimal and only enabled required components. Also the USB dependency is tricky for me to fix as the gadget part depends on the host driver. Many thanks to narrow down. ``` aarch64-none-linux-gnu-ld.bfd: u-boot-spl section `.data' will not fit in region `.sram' aarch64-none-linux-gnu-ld.bfd: region `.sram' overflowed by 9816 bytes aarch64-none-linux-gnu-ld.bfd: drivers/usb/gadget/ci_udc.o: in function `usb_gadget_register_driver': u-boot/out/../drivers/usb/gadget/ci_udc.c:1026: undefined reference to `usb_setup_ehci_gadget' make[2]: *** [../scripts/Makefile.spl:527: spl/u-boot-spl] Error 1 make[1]: *** [u-boot/Makefile:2043: spl/u-boot-spl] Error 2 make[1]: Leaving directory 'u-boot/out' make: *** [Makefile:177: sub-make] Error 2 ``` -- Thanks, Parthiban N https://www.linumiz.com Berlin, Germany