From 8fde50f702b92895f0a1ae5fa307199ab4ff0dbe Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 28 Apr 2020 18:20:11 +0200 Subject: ARM: dts: imxrt1050: indent lcdif node correctly Accidentally submitted a patch with indentation not correct, let's fix it by indenting wrong lines. Signed-off-by: Giulio Benetti Acked-by: Peng Fan --- arch/arm/dts/imxrt1050.dtsi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/dts/imxrt1050.dtsi b/arch/arm/dts/imxrt1050.dtsi index 7cfe5f5..a928100 100644 --- a/arch/arm/dts/imxrt1050.dtsi +++ b/arch/arm/dts/imxrt1050.dtsi @@ -147,12 +147,12 @@ }; lcdif: lcdif@402b8000 { - compatible = "fsl,imxrt-lcdif"; - reg = <0x402b8000 0x10000>; - interrupts = ; - clocks = <&clks IMXRT1050_CLK_LCDIF>; - clock-names = "per"; - status = "disabled"; + compatible = "fsl,imxrt-lcdif"; + reg = <0x402b8000 0x4000>; + interrupts = ; + clocks = <&clks IMXRT1050_CLK_LCDIF>; + clock-names = "per"; + status = "disabled"; }; }; }; -- cgit v1.1 From f3e1c536a9d9b9940f02d0b4f24eb818e31398dc Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 5 May 2020 20:18:02 +0800 Subject: imx: Kconfig: enable IMX_BOOTAUX for i.MX8M i.MX8M could use imx bootaux to boot m4/m7 core, so let's add it to the dependency list. Signed-off-by: Peng Fan --- arch/arm/mach-imx/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index bed8cc7..6c3fedf 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -23,7 +23,7 @@ config IMX_RDC config IMX_BOOTAUX bool "Support boot auxiliary core" - depends on ARCH_MX7 || ARCH_MX6 || ARCH_VF610 + depends on ARCH_MX7 || ARCH_MX6 || ARCH_VF610 || ARCH_IMX8M help bootaux [addr] to boot auxiliary core. -- cgit v1.1 From 0e9c045b2b6a0409d650dd39265b4f6924a69832 Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Fri, 8 May 2020 11:59:47 +0200 Subject: imx: move ATF to the back of the FIT to fix loading over yModem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With yModem the FIT Image is only supplied once, so we can only seek forward in the yModem supplied image and never backwards. With the recent changes to the SPL mechanism, including loading U-Boot first, FDT after, then the loadables, we must also reorder the FIT image script to make sure that the loadables are last in the FIT image. Signed-off-by: Patrick Wildt Tested-by: Sébastien Szymanski --- arch/arm/mach-imx/mkimage_fit_atf.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-imx/mkimage_fit_atf.sh b/arch/arm/mach-imx/mkimage_fit_atf.sh index dd1ca5a..fe12b7b 100755 --- a/arch/arm/mach-imx/mkimage_fit_atf.sh +++ b/arch/arm/mach-imx/mkimage_fit_atf.sh @@ -62,6 +62,23 @@ cat << __HEADER_EOF compression = "none"; load = <$BL33_LOAD_ADDR>; }; +__HEADER_EOF + +cnt=1 +for dtname in $* +do + cat << __FDT_IMAGE_EOF + fdt@$cnt { + description = "$(basename $dtname .dtb)"; + data = /incbin/("$dtname"); + type = "flat_dt"; + compression = "none"; + }; +__FDT_IMAGE_EOF +cnt=$((cnt+1)) +done + +cat << __HEADER_EOF atf@1 { description = "ARM Trusted Firmware"; os = "arm-trusted-firmware"; @@ -88,20 +105,6 @@ cat << __HEADER_EOF __HEADER_EOF fi -cnt=1 -for dtname in $* -do - cat << __FDT_IMAGE_EOF - fdt@$cnt { - description = "$(basename $dtname .dtb)"; - data = /incbin/("$dtname"); - type = "flat_dt"; - compression = "none"; - }; -__FDT_IMAGE_EOF -cnt=$((cnt+1)) -done - cat << __CONF_HEADER_EOF }; configurations { -- cgit v1.1 From 9ccd30df609db2186fc27c107bb905a51197e221 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 11 May 2020 09:45:51 -0300 Subject: imx8mp_evk: Add a README file Add a README file explaining the U-Boot build and SD card flash procedures. Signed-off-by: Fabio Estevam --- board/freescale/imx8mp_evk/README | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 board/freescale/imx8mp_evk/README diff --git a/board/freescale/imx8mp_evk/README b/board/freescale/imx8mp_evk/README new file mode 100644 index 0000000..7dd3a93 --- /dev/null +++ b/board/freescale/imx8mp_evk/README @@ -0,0 +1,41 @@ +U-Boot for the NXP i.MX8MP EVK board + +Quick Start +=========== +- Build the ARM Trusted firmware binary +- Get the firmware-imx package +- Build U-Boot +- Boot + +Get and Build the ARM Trusted firmware +====================================== +Note: $(srctree) is the U-Boot source directory +Get ATF from: https://source.codeaurora.org/external/imx/imx-atf +branch: imx_5.4.3_2.0.0 +$ make PLAT=imx8mp bl31 +$ sudo cp build/imx8mp/release/bl31.bin $(srctree) + +Get the ddr firmware +==================== +$ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.7.bin +$ chmod +x firmware-imx-8.7.bin +$ ./firmware-imx-8.7 +$ sudo cp firmware-imx-8.7/firmware/ddr/synopsys/lpddr4_pmu_train_1d_dmem_201904.bin $(srctree)/lpddr4_pmu_train_1d_dmem.bin +$ sudo cp firmware-imx-8.7/firmware/ddr/synopsys/lpddr4_pmu_train_1d_imem_201904.bin $(srctree)/lpddr4_pmu_train_1d_imem.bin +$ sudo cp firmware-imx-8.7/firmware/ddr/synopsys/lpddr4_pmu_train_2d_dmem_201904.bin $(srctree)/lpddr4_pmu_train_2d_dmem.bin +$ sudo cp firmware-imx-8.7/firmware/ddr/synopsys/lpddr4_pmu_train_2d_imem_201904.bin $(srctree)/lpddr4_pmu_train_2d_imem.bin + +Build U-Boot +============ +$ export CROSS_COMPILE=aarch64-poky-linux- +$ make imx8mp_evk_defconfig +$ export ATF_LOAD_ADDR=0x960000 +$ make flash.bin + +Burn the flash.bin to the MicroSD card at offset 32KB +$sudo dd if=flash.bin of=/dev/sd[x] bs=1K seek=32; sync + +Boot +==== +Set Boot switch to SD boot +Use /dev/ttyUSB2 for U-Boot console -- cgit v1.1 From c5a015c32e46632b9d593402951feface11ca66b Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 11 May 2020 11:00:27 -0300 Subject: imx8mm_evk: Select the watchdog driver Currently the watchdog driver is not selected, which causes the following warnings in both SPL and U-Boot proper: U-Boot SPL 2020.07-rc1-00387-g67887903af (May 07 2020 - 23:49:27 -0300) Normal Boot WDT: Started without servicing (60s timeout) Trying to boot from MMC1 U-Boot 2020.07-rc1-00387-g67887903af (May 07 2020 - 23:49:27 -0300) CPU: Freescale i.MX8MMQ rev1.0 at 1200 MHz Reset cause: POR Model: FSL i.MX8MM EVK board DRAM: 2 GiB WDT: Started without servicing (60s timeout) .... System reboots after staying 60s in the U-Boot prompt. Fix this problem by enabling CONFIG_WATCHDOG so that watchdog can be properly serviced. Suggested-by: Marek Vasut Signed-off-by: Fabio Estevam --- configs/imx8mm_evk_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/imx8mm_evk_defconfig b/configs/imx8mm_evk_defconfig index 9a72f46..e7abf6b 100644 --- a/configs/imx8mm_evk_defconfig +++ b/configs/imx8mm_evk_defconfig @@ -85,5 +85,4 @@ CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y -# CONFIG_WATCHDOG is not set CONFIG_IMX_WATCHDOG=y -- cgit v1.1 From 010bd4718b9ef1cfe39f7be8ef4ee4c56d6b1edb Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 11 May 2020 11:00:28 -0300 Subject: imx8mn_ddr4_evk: Select the watchdog driver Currently watchdog driver is not selected, which causes system to reboot after staying 60s in the U-Boot prompt. Fix this problem by enabling CONFIG_WATCHDOG so that watchdog can be properly serviced. Signed-off-by: Fabio Estevam --- configs/imx8mn_ddr4_evk_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/imx8mn_ddr4_evk_defconfig b/configs/imx8mn_ddr4_evk_defconfig index bc6014d..7fd443f 100644 --- a/configs/imx8mn_ddr4_evk_defconfig +++ b/configs/imx8mn_ddr4_evk_defconfig @@ -79,5 +79,4 @@ CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y -# CONFIG_WATCHDOG is not set CONFIG_IMX_WATCHDOG=y -- cgit v1.1 From 979d5e4bf674f7f676b9d116b526c7e422a2238e Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 11 May 2020 11:00:29 -0300 Subject: imx8mm_beacon: Select the watchdog driver Currently watchdog driver is not selected, which causes system to reboot after staying 60s in the U-Boot prompt. Fix this problem by enabling CONFIG_WATCHDOG so that watchdog can be properly serviced. Signed-off-by: Fabio Estevam Reviewed-by: Adam Ford --- configs/imx8mm_beacon_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/imx8mm_beacon_defconfig b/configs/imx8mm_beacon_defconfig index b935d72..a518963 100644 --- a/configs/imx8mm_beacon_defconfig +++ b/configs/imx8mm_beacon_defconfig @@ -100,5 +100,4 @@ CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y -# CONFIG_WATCHDOG is not set CONFIG_IMX_WATCHDOG=y -- cgit v1.1 From 51c0e493c2a97c51f5ee5b83c63d326bcf41cff4 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 11 May 2020 11:00:30 -0300 Subject: imx8mp_evk: Select the watchdog driver Currently watchdog driver is not selected, which causes system to reboot after staying 60s in the U-Boot prompt. Fix this problem by enabling CONFIG_WATCHDOG so that watchdog can be properly serviced. Signed-off-by: Fabio Estevam --- configs/imx8mp_evk_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/imx8mp_evk_defconfig b/configs/imx8mp_evk_defconfig index 44b2935..0693658 100644 --- a/configs/imx8mp_evk_defconfig +++ b/configs/imx8mp_evk_defconfig @@ -82,5 +82,4 @@ CONFIG_SYSRESET=y CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y -# CONFIG_WATCHDOG is not set CONFIG_IMX_WATCHDOG=y -- cgit v1.1 From 2c72bf21c66692cf0b9c305c27ac4a5218a4dd01 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 11 May 2020 11:00:31 -0300 Subject: verdin-imx8mm: Select the watchdog driver Currently watchdog driver is not selected, which causes system to reboot after staying 60s in the U-Boot prompt. Fix this problem by enabling CONFIG_WATCHDOG so that watchdog can be properly serviced. Signed-off-by: Fabio Estevam Acked-by: Igor Opaniuk --- configs/verdin-imx8mm_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/verdin-imx8mm_defconfig b/configs/verdin-imx8mm_defconfig index c68b299..f5b6e03 100644 --- a/configs/verdin-imx8mm_defconfig +++ b/configs/verdin-imx8mm_defconfig @@ -99,5 +99,4 @@ CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y -# CONFIG_WATCHDOG is not set CONFIG_IMX_WATCHDOG=y -- cgit v1.1 From 1f63ee656698724bcdc4e711b4ccd267f6bf64ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Szymanski?= Date: Wed, 13 May 2020 16:02:28 +0200 Subject: imx: rom api: fix image offset computation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When not booting from FlexSPI, the offset computation is: offset = image_offset + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000; When booting from SD card or eMMC user partition, image_offset is 0x8000. It is useless to add and remove 0x8000. When booting from other device, image_offset is 0 so this computation is wrong. Simplfy this computation to work on all booting devices. Signed-off-by: Sébastien Szymanski --- arch/arm/mach-imx/spl_imx_romapi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c index f588a5f..893b7d1 100644 --- a/arch/arm/mach-imx/spl_imx_romapi.c +++ b/arch/arm/mach-imx/spl_imx_romapi.c @@ -84,12 +84,7 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image, printf("image offset 0x%x, pagesize 0x%x, ivt offset 0x%x\n", image_offset, pagesize, offset); - if (((rom_bt_dev >> 16) & 0xff) == BT_DEV_TYPE_FLEXSPINOR) - offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512; - else - offset = image_offset + - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000; - + offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512; size = ALIGN(sizeof(struct image_header), pagesize); ret = g_rom_api->download_image((u8 *)header, offset, size, ((uintptr_t)header) ^ offset ^ size); -- cgit v1.1 From c04b41b3299d7d82c4b991a200bef137d4991a85 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Wed, 13 May 2020 17:45:15 +0200 Subject: imx: Update MTD partitions layout for display5 (i.MX6Q) board This change updates the MTD partition layout on SPI-NOR memory for display5 board. Signed-off-by: Lukasz Majewski --- configs/display5_defconfig | 2 +- configs/display5_factory_defconfig | 2 +- include/configs/display5.h | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/configs/display5_defconfig b/configs/display5_defconfig index 78e4627..700bdcb 100644 --- a/configs/display5_defconfig +++ b/configs/display5_defconfig @@ -71,7 +71,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_CMD_MTDPARTS=y CONFIG_MTDIDS_DEFAULT="nor0=02008000.spi.1" -CONFIG_MTDPARTS_DEFAULT="mtdparts=02008000.spi.1:128k(SPL),1m(u-boot),64k(env1),64k(env2),4m(swu-kernel),16m(swu-initramfs),1m(factory),-(reserved)" +CONFIG_MTDPARTS_DEFAULT="mtdparts=02008000.spi.1:128k(SPL),1m(u-boot),64k(env1),64k(env2),6m(swu-kernel),20m(swu-initramfs),3840k(reserved),1m(factory)" # CONFIG_SPL_EFI_PARTITION is not set CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="imx6q-display5" diff --git a/configs/display5_factory_defconfig b/configs/display5_factory_defconfig index d453073..39f3168 100644 --- a/configs/display5_factory_defconfig +++ b/configs/display5_factory_defconfig @@ -73,7 +73,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_CMD_MTDPARTS=y CONFIG_MTDIDS_DEFAULT="nor0=02008000.spi.1" -CONFIG_MTDPARTS_DEFAULT="mtdparts=02008000.spi.1:128k(SPL),1m(u-boot),64k(env1),64k(env2),4m(swu-kernel),16m(swu-initramfs),1m(factory),-(reserved)" +CONFIG_MTDPARTS_DEFAULT="mtdparts=02008000.spi.1:128k(SPL),1m(u-boot),64k(env1),64k(env2),6m(swu-kernel),20m(swu-initramfs),3840k(reserved),1m(factory)" # CONFIG_SPL_EFI_PARTITION is not set CONFIG_PARTITION_TYPE_GUID=y CONFIG_OF_CONTROL=y diff --git a/include/configs/display5.h b/include/configs/display5.h index 2e5dbfe..3348ecc 100644 --- a/include/configs/display5.h +++ b/include/configs/display5.h @@ -28,9 +28,10 @@ * 0x020000 - 0x120000 : SPI.u-boot (1MiB) * 0x120000 - 0x130000 : SPI.u-boot-env1 (64KiB) * 0x130000 - 0x140000 : SPI.u-boot-env2 (64KiB) - * 0x140000 - 0x540000 : SPI.swupdate-kernel-FIT (4MiB) - * 0x540000 - 0x1540000 : SPI.swupdate-initramfs (16MiB) - * 0x1540000 - 0x1640000 : SPI.factory (1MiB) + * 0x140000 - 0x740000 : SPI.swupdate-kernel-FIT (6MiB) + * 0x740000 - 0x1B40000 : SPI.swupdate-initramfs (20MiB) + * 0x1B40000 - 0x1F00000 : SPI.reserved (3840KiB) + * 0x1F00000 - 0x2000000 : SPI.factory (1MiB) */ /* SPI Flash Configs */ -- cgit v1.1 From 87f6e2f51e337623b1794e916d8b8eb654736c0d Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 26 May 2020 20:33:46 -0300 Subject: imx8mp_evk: spl: drop useless code Drop useless getting ccm device, there is no need to explicted do this in board code, and we not enable SPL CLK currently. Signed-off-by: Peng Fan Signed-off-by: Fabio Estevam --- board/freescale/imx8mp_evk/spl.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/board/freescale/imx8mp_evk/spl.c b/board/freescale/imx8mp_evk/spl.c index cd5b32c..f2cc177 100644 --- a/board/freescale/imx8mp_evk/spl.c +++ b/board/freescale/imx8mp_evk/spl.c @@ -29,11 +29,6 @@ #include #include -#include -#include -#include -#include - DECLARE_GLOBAL_DATA_PTR; int spl_board_boot_device(enum boot_device boot_dev_spl) @@ -48,16 +43,7 @@ void spl_dram_init(void) void spl_board_init(void) { - struct udevice *dev; - int ret; - puts("Normal Boot\n"); - - ret = uclass_get_device_by_name(UCLASS_CLK, - "clock-controller@30380000", - &dev); - if (ret < 0) - printf("Failed to find clock node. Check device tree\n"); } #define I2C_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PE) -- cgit v1.1 From ebdd07f5b2e4b00eee7f8630b3b026a65c3f51c4 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 26 May 2020 20:33:47 -0300 Subject: imx8mp_evk: spl: drop timer_init timer_init has been invoked in arch_cpu_init, no need to invoke it again in board code. Signed-off-by: Peng Fan Signed-off-by: Fabio Estevam --- board/freescale/imx8mp_evk/spl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/board/freescale/imx8mp_evk/spl.c b/board/freescale/imx8mp_evk/spl.c index f2cc177..f45f935 100644 --- a/board/freescale/imx8mp_evk/spl.c +++ b/board/freescale/imx8mp_evk/spl.c @@ -114,8 +114,6 @@ void board_init_f(ulong dummy) board_early_init_f(); - timer_init(); - preloader_console_init(); /* Clear the BSS. */ -- cgit v1.1 From bdada3b14d554b029ec0406ca04cd54482c20d81 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 26 May 2020 20:33:48 -0300 Subject: imx8mp_evk: spl: use spl_early_init Use spl_early_init to replace spl_init, spl_init will be invoked in board_init_r, we only need use spl_early_init to setup malloc and scan early dt. Signed-off-by: Peng Fan Signed-off-by: Fabio Estevam --- board/freescale/imx8mp_evk/spl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/board/freescale/imx8mp_evk/spl.c b/board/freescale/imx8mp_evk/spl.c index f45f935..d4feb84 100644 --- a/board/freescale/imx8mp_evk/spl.c +++ b/board/freescale/imx8mp_evk/spl.c @@ -114,17 +114,17 @@ void board_init_f(ulong dummy) board_early_init_f(); - preloader_console_init(); - - /* Clear the BSS. */ - memset(__bss_start, 0, __bss_end - __bss_start); - - ret = spl_init(); + ret = spl_early_init(); if (ret) { debug("spl_init() failed: %d\n", ret); hang(); } + preloader_console_init(); + + /* Clear the BSS. */ + memset(__bss_start, 0, __bss_end - __bss_start); + enable_tzc380(); setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1); -- cgit v1.1 From 0ec9d5bda93e0203405ffff134ce7b2d7fbda6aa Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 26 May 2020 20:33:49 -0300 Subject: imx8mp_evk: spl: no need the code since spl framework could do that We no need invoke the code, since spl framework could help us do that. Signed-off-by: Peng Fan Signed-off-by: Fabio Estevam --- board/freescale/imx8mp_evk/spl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/board/freescale/imx8mp_evk/spl.c b/board/freescale/imx8mp_evk/spl.c index d4feb84..3b3a854 100644 --- a/board/freescale/imx8mp_evk/spl.c +++ b/board/freescale/imx8mp_evk/spl.c @@ -104,6 +104,7 @@ int board_fit_config_name_match(const char *name) } #endif +/* Do not use BSS area in this phase */ void board_init_f(ulong dummy) { int ret; @@ -122,9 +123,6 @@ void board_init_f(ulong dummy) preloader_console_init(); - /* Clear the BSS. */ - memset(__bss_start, 0, __bss_end - __bss_start); - enable_tzc380(); setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1); @@ -133,6 +131,4 @@ void board_init_f(ulong dummy) /* DDR initialization */ spl_dram_init(); - - board_init_r(NULL, 0); } -- cgit v1.1 From 28fff3fa1c7abb09888585252147e35496074880 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 26 May 2020 20:33:50 -0300 Subject: imx: imx8mp_evk: fix boot issue The u-boot-spl.bin pad with ddr firmware conflicts with the CONFIG_MALLOC_F_ADDR area, the ddr firmware will be overwritten by malloc in SPL stage and cause ddr initialization not able to finish. So update the related addresses to fix the issue. Reported-by: Fabio Estevam Signed-off-by: Peng Fan Signed-off-by: Fabio Estevam --- configs/imx8mp_evk_defconfig | 3 ++- include/configs/imx8mp_evk.h | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/configs/imx8mp_evk_defconfig b/configs/imx8mp_evk_defconfig index 0693658..17452b6 100644 --- a/configs/imx8mp_evk_defconfig +++ b/configs/imx8mp_evk_defconfig @@ -4,7 +4,8 @@ CONFIG_SYS_TEXT_BASE=0x40200000 CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y -CONFIG_SYS_MALLOC_F_LEN=0x10000 +CONFIG_SYS_MALLOC_F_LEN=0x8000 +CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_ENV_SIZE=0x1000 CONFIG_ENV_OFFSET=0x400000 CONFIG_SYS_I2C_MXC_I2C1=y diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h index b346154..7f38f21 100644 --- a/include/configs/imx8mp_evk.h +++ b/include/configs/imx8mp_evk.h @@ -24,16 +24,14 @@ #ifdef CONFIG_SPL_BUILD /*#define CONFIG_ENABLE_DDR_TRAINING_DEBUG*/ #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" -#define CONFIG_SPL_STACK 0x990000 -#define CONFIG_SPL_BSS_START_ADDR 0x0095e000 -#define CONFIG_SPL_BSS_MAX_SIZE 0x2000 /* 8 KB */ -#define CONFIG_SYS_SPL_MALLOC_START 0x42200000 -#define CONFIG_SYS_SPL_MALLOC_SIZE SZ_512K /* 512 KB */ +#define CONFIG_SPL_STACK 0x960000 +#define CONFIG_SPL_BSS_START_ADDR 0x0098FC00 +#define CONFIG_SPL_BSS_MAX_SIZE 0x400 /* 1 KB */ +#define CONFIG_SYS_SPL_MALLOC_START 0x42200000 +#define CONFIG_SYS_SPL_MALLOC_SIZE SZ_512K /* 512 KB */ #define CONFIG_SYS_ICACHE_OFF #define CONFIG_SYS_DCACHE_OFF -#define CONFIG_MALLOC_F_ADDR 0x940000 - #define CONFIG_SPL_ABORT_ON_RAW_IMAGE #undef CONFIG_DM_MMC -- cgit v1.1 From 661d9afe1429e28adcaacd277ab9f28e3790e93f Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 29 May 2020 19:22:41 +0200 Subject: power: pmic: Add SPL Kconfig entry for PFUZE100 Add Kconfig entry for the PFUZE PMIC, SPL variant. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Jaehoon Chung Cc: Peng Fan Cc: Stefano Babic Reviewed-by: Jaehoon Chung --- drivers/power/pmic/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index ef8bf49..a62aa38 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -105,6 +105,13 @@ config DM_PMIC_PFUZE100 This config enables implementation of driver-model pmic uclass features for PMIC PFUZE100. The driver implements read/write operations. +config SPL_DM_PMIC_PFUZE100 + bool "Enable Driver Model for PMIC PFUZE100 in SPL" + depends on DM_PMIC + ---help--- + This config enables implementation of driver-model pmic uclass features + for PMIC PFUZE100 in SPL. The driver implements read/write operations. + config DM_PMIC_MAX77686 bool "Enable Driver Model for PMIC MAX77686" depends on DM_PMIC -- cgit v1.1 From 0e06d63d195670f5181958f43216d7106c05357f Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 30 May 2020 02:14:48 +0200 Subject: ARM: imx: ddr: Add missing PHY reset The iMX7D RM 9.2.4.9.3 Power removal flow Table 9-11. Re-enabling power explicitly says both the DDR controller and the PHY must be reset in the correct sequence. Currently the code only resets the controller. This leads to a misbehavior where the system brings the DRAM up after reboot, but the DRAM is unstable. Add the missing reset. The easiest way to trigger this is by triggering WDT without having the WDT assert WDOG_B signal, i.e. mw.w 0x30280000 0x25 . Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: NXP i.MX U-Boot Team Cc: Peng Fan Cc: Stefano Babic --- arch/arm/include/asm/arch-mx7/imx-regs.h | 1 + arch/arm/mach-imx/mx7/ddr.c | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/arch-mx7/imx-regs.h b/arch/arm/include/asm/arch-mx7/imx-regs.h index 95238dc..f37419c 100644 --- a/arch/arm/include/asm/arch-mx7/imx-regs.h +++ b/arch/arm/include/asm/arch-mx7/imx-regs.h @@ -274,6 +274,7 @@ struct src { #define SRC_DDRC_RCR_DDRC_CORE_RST_OFFSET 1 #define SRC_DDRC_RCR_DDRC_CORE_RST_MASK (1 << 1) +#define SRC_DDRC_RCR_DDRC_PRST_MASK (1 << 0) /* GPR0 Bit Fields */ #define IOMUXC_GPR_GPR0_DMAREQ_MUX_SEL0_MASK 0x1u diff --git a/arch/arm/mach-imx/mx7/ddr.c b/arch/arm/mach-imx/mx7/ddr.c index 9713835..d1e10a6 100644 --- a/arch/arm/mach-imx/mx7/ddr.c +++ b/arch/arm/mach-imx/mx7/ddr.c @@ -13,6 +13,7 @@ #include #include #include +#include /* * Routine: mx7_dram_cfg @@ -37,8 +38,23 @@ void mx7_dram_cfg(struct ddrc *ddrc_regs_val, struct ddrc_mp *ddrc_mp_val, (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; int i; - /* Assert DDR Controller preset and DDR PHY reset */ - writel(SRC_DDRC_RCR_DDRC_CORE_RST_MASK, &src_regs->ddrc_rcr); + /* + * iMX7D RM 9.2.4.9.3 Power removal flow Table 9-11. Re-enabling power + * row 2 says "Reset controller / PHY by driving core_ddrc_rst = 0 , + * aresetn_n = 0, presetn = 0. That means reset everything. + */ + writel(SRC_DDRC_RCR_DDRC_CORE_RST_MASK | SRC_DDRC_RCR_DDRC_PRST_MASK, + &src_regs->ddrc_rcr); + + /* + * iMX7D RM 6.2.7.26 SRC_DDRC_RCR says wait 30 cycles (of unknown). + * If we assume this is 30 cycles at 100 MHz (about the rate of a + * DRAM bus), that's 300 nS, so waiting 10 uS is more then plenty. + */ + udelay(10); + + /* De-assert DDR Controller 'preset' and DDR PHY reset */ + clrbits_le32(&src_regs->ddrc_rcr, SRC_DDRC_RCR_DDRC_PRST_MASK); /* DDR controller configuration */ writel(ddrc_regs_val->mstr, &ddrc_regs->mstr); @@ -71,7 +87,7 @@ void mx7_dram_cfg(struct ddrc *ddrc_regs_val, struct ddrc_mp *ddrc_mp_val, writel(ddrc_regs_val->odtcfg, &ddrc_regs->odtcfg); writel(ddrc_regs_val->odtmap, &ddrc_regs->odtmap); - /* De-assert DDR Controller preset and DDR PHY reset */ + /* De-assert DDR Controller 'core_ddrc_rstn' and 'aresetn' */ clrbits_le32(&src_regs->ddrc_rcr, SRC_DDRC_RCR_DDRC_CORE_RST_MASK); /* PHY configuration */ -- cgit v1.1 From dae6cb8fb757fa13d9f894a67443a7ea7e93c6bc Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 30 May 2020 22:44:45 +0200 Subject: ARM: imx: m53menlo: Do not fail boot on invalid splash screen None of these splash screen loading errors are so critical as to justify complete failure to boot, so just print error message as needed and return 0, the boot can very likely continue without the splash. Fix a couple of missing free(dst) instances as well. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: NXP i.MX U-Boot Team Cc: Peng Fan Cc: Stefano Babic --- board/menlo/m53menlo/m53menlo.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/board/menlo/m53menlo/m53menlo.c b/board/menlo/m53menlo/m53menlo.c index 58a564a..d4288a2 100644 --- a/board/menlo/m53menlo/m53menlo.c +++ b/board/menlo/m53menlo/m53menlo.c @@ -353,24 +353,28 @@ int board_late_init(void) ret = splash_screen_prepare(); if (ret < 0) - return ret; + goto splasherr; len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; ret = gunzip(dst + 2, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE - 2, (uchar *)addr, &len); if (ret) { printf("Error: no valid bmp or bmp.gz image at %lx\n", addr); - free(dst); - return ret; + goto splasherr; } ret = uclass_get_device(UCLASS_VIDEO, 0, &dev); if (ret) - return ret; + goto splasherr; ret = video_bmp_display(dev, (ulong)dst + 2, xpos, ypos, true); if (ret) - return ret; + goto splasherr; + + return 0; + +splasherr: + free(dst); #endif return 0; } -- cgit v1.1 From a13644c065173fad6bcaf163569bd01e6eb93834 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 30 May 2020 22:44:46 +0200 Subject: ARM: dts: imx: m53menlo: Convert to DM_ETH Convert the board to DM_ETH instead of legacy networking. This requires a minor addition to the DT to satisfy the requirement for specifying a PHY node. No functional change from board user perspective. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: NXP i.MX U-Boot Team Cc: Peng Fan Cc: Stefano Babic --- arch/arm/dts/imx53-m53menlo.dts | 11 +++++++++++ configs/m53menlo_defconfig | 3 +++ 2 files changed, 14 insertions(+) diff --git a/arch/arm/dts/imx53-m53menlo.dts b/arch/arm/dts/imx53-m53menlo.dts index a6805ec..3767dca 100644 --- a/arch/arm/dts/imx53-m53menlo.dts +++ b/arch/arm/dts/imx53-m53menlo.dts @@ -86,8 +86,19 @@ &fec { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_fec>; + phy-handle = <ðphy0>; phy-mode = "rmii"; status = "okay"; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + ethphy0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + }; }; &i2c1 { diff --git a/configs/m53menlo_defconfig b/configs/m53menlo_defconfig index a65c21a..5289899 100644 --- a/configs/m53menlo_defconfig +++ b/configs/m53menlo_defconfig @@ -75,6 +75,9 @@ CONFIG_NAND_MXC=y CONFIG_PHYLIB=y CONFIG_PHY_MICREL=y CONFIG_PHY_MICREL_KSZ8XXX=y +CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y +CONFIG_DM_ETH_PHY=y CONFIG_PINCTRL=y CONFIG_PINCTRL_IMX5=y CONFIG_DM_REGULATOR=y -- cgit v1.1 From 385429680106f8612386e26564f69dccdd110620 Mon Sep 17 00:00:00 2001 From: Stefano Babic Date: Tue, 9 Jun 2020 11:19:55 +0200 Subject: Revert "imx: rom api: fix image offset computation" This reverts commit 1f63ee656698724bcdc4e711b4ccd267f6bf64ab. As reported by Ye Li on ML: 1. Removing the image_offset will break secondary (redundant) boot support for sd and emmc. 2. When booting from emmc boot partition, the image_offset is 0. But the flash.bin generated by mkimage with imximage-8mp-lpddr4.cfg is for sd. It expects to be burn at 32KB offset. The fit offset 0x60000 has already included the 32KB offset. So when you burn this flash.bin to emmc boot partition at offset 0, the fit offset should subtract the 32KB (0x60000 - 0x8000). Signed-off-by: Stefano Babic --- arch/arm/mach-imx/spl_imx_romapi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c index 893b7d1..f588a5f 100644 --- a/arch/arm/mach-imx/spl_imx_romapi.c +++ b/arch/arm/mach-imx/spl_imx_romapi.c @@ -84,7 +84,12 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image, printf("image offset 0x%x, pagesize 0x%x, ivt offset 0x%x\n", image_offset, pagesize, offset); - offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512; + if (((rom_bt_dev >> 16) & 0xff) == BT_DEV_TYPE_FLEXSPINOR) + offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512; + else + offset = image_offset + + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000; + size = ALIGN(sizeof(struct image_header), pagesize); ret = g_rom_api->download_image((u8 *)header, offset, size, ((uintptr_t)header) ^ offset ^ size); -- cgit v1.1 From 870bd567994b4455c9f68c3bc30fea6499fe5f54 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 6 May 2020 16:29:04 -0600 Subject: patman: Fix 'warning' typo If no warnings are detected due to checkpatch having unexpected options, patman currently shows an error: TypeError: unsupported operand type(s) for +=: 'int' and 'property' Fix this by initing the variable correctly. Signed-off-by: Simon Glass --- tools/patman/checkpatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 795b519..a2611a8 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -59,7 +59,7 @@ def CheckPatch(fname, verbose=False): 'stdout'] result = collections.namedtuple('CheckPatchResult', fields) result.ok = False - result.errors, result.warning, result.checks = 0, 0, 0 + result.errors, result.warnings, result.checks = 0, 0, 0 result.lines = 0 result.problems = [] chk = FindCheckPatch() -- cgit v1.1 From 7d5b5e8965b3f0bdf91665cf654b9eaeb9b30e52 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 6 May 2020 16:29:05 -0600 Subject: patman: Support emacs mode with checkpatch If checkpatch is run in 'emacs' mode it shows the filename at the start of each line. Add support for this so that the warnings and errors are correctly detected. Signed-off-by: Simon Glass --- tools/patman/checkpatch.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index a2611a8..16d534b 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -72,13 +72,17 @@ def CheckPatch(fname, verbose=False): # total: 0 errors, 0 warnings, 159 lines checked # or: # total: 0 errors, 2 warnings, 7 checks, 473 lines checked - re_stats = re.compile('total: (\\d+) errors, (\d+) warnings, (\d+)') - re_stats_full = re.compile('total: (\\d+) errors, (\d+) warnings, (\d+)' + emacs_prefix = '(?:[0-9]{4}.*\.patch:[0-9]+: )?' + emacs_stats = '(?:[0-9]{4}.*\.patch )?' + re_stats = re.compile(emacs_stats + + 'total: (\\d+) errors, (\d+) warnings, (\d+)') + re_stats_full = re.compile(emacs_stats + + 'total: (\\d+) errors, (\d+) warnings, (\d+)' ' checks, (\d+)') re_ok = re.compile('.*has no obvious style problems') re_bad = re.compile('.*has style problems, please review') re_error = re.compile('ERROR: (.*)') - re_warning = re.compile('WARNING: (.*)') + re_warning = re.compile(emacs_prefix + 'WARNING:(?:[A-Z_]+:)? (.*)') re_check = re.compile('CHECK: (.*)') re_file = re.compile('#\d+: FILE: ([^:]*):(\d+):') -- cgit v1.1 From 7175b085e1213c99fbc237483b33cd52ff00f891 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 6 May 2020 16:29:06 -0600 Subject: patman: Don't try to process checkpatch lines twice Once we have determined what the line refers to there is no point in processing it further. Update the logic to continue to the next line in these cases. Signed-off-by: Simon Glass --- tools/patman/checkpatch.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 16d534b..2cfa977 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -91,9 +91,11 @@ def CheckPatch(fname, verbose=False): print(line) # A blank line indicates the end of a message - if not line and item: - result.problems.append(item) - item = {} + if not line: + if item: + result.problems.append(item) + item = {} + continue match = re_stats_full.match(line) if not match: match = re_stats.match(line) @@ -105,10 +107,13 @@ def CheckPatch(fname, verbose=False): result.lines = int(match.group(4)) else: result.lines = int(match.group(3)) + continue elif re_ok.match(line): result.ok = True + continue elif re_bad.match(line): result.ok = False + continue err_match = re_error.match(line) warn_match = re_warning.match(line) file_match = re_file.match(line) -- cgit v1.1 From 666eb15e923e93872dbca1b834ce123a327fc9b3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 6 May 2020 16:29:07 -0600 Subject: patman: Handle checkpatch output with notes and code If checkpatch is configured to output code we should ignore it. Similarly, notes should be ignored. Update the logic to handle these situations. Signed-off-by: Simon Glass --- tools/patman/checkpatch.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 2cfa977..5426bb9 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -85,7 +85,8 @@ def CheckPatch(fname, verbose=False): re_warning = re.compile(emacs_prefix + 'WARNING:(?:[A-Z_]+:)? (.*)') re_check = re.compile('CHECK: (.*)') re_file = re.compile('#\d+: FILE: ([^:]*):(\d+):') - + re_note = re.compile('NOTE: (.*)') + indent = ' ' * 6 for line in result.stdout.splitlines(): if verbose: print(line) @@ -96,6 +97,14 @@ def CheckPatch(fname, verbose=False): result.problems.append(item) item = {} continue + if re_note.match(line): + continue + # Skip lines which quote code + if line.startswith(indent): + continue + # Skip code quotes and # + if line.startswith('+') or line.startswith('#'): + continue match = re_stats_full.match(line) if not match: match = re_stats.match(line) -- cgit v1.1 From 37f3bb53b78d13f15634a976ebbfa36499d74290 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 6 May 2020 16:29:08 -0600 Subject: patman: Support warnings in the patch subject Sometimes checkpatch outputs problems in the patch subject. Add support for parsing this output and reporting it correctly. Signed-off-by: Simon Glass --- tools/patman/checkpatch.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 5426bb9..5ae450d 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -127,6 +127,7 @@ def CheckPatch(fname, verbose=False): warn_match = re_warning.match(line) file_match = re_file.match(line) check_match = re_check.match(line) + subject_match = line.startswith('Subject:') if err_match: item['msg'] = err_match.group(1) item['type'] = 'error' @@ -139,6 +140,9 @@ def CheckPatch(fname, verbose=False): elif file_match: item['file'] = file_match.group(1) item['line'] = int(file_match.group(2)) + elif subject_match: + item['file'] = '' + item['line'] = None return result @@ -157,7 +161,8 @@ def GetWarningMsg(col, msg_type, fname, line, msg): msg_type = col.Color(col.RED, msg_type) elif msg_type == 'check': msg_type = col.Color(col.MAGENTA, msg_type) - return '%s:%d: %s: %s\n' % (fname, line, msg_type, msg) + line_str = '' if line is None else '%d' % line + return '%s:%s: %s: %s\n' % (fname, line_str, msg_type, msg) def CheckPatches(verbose, args): '''Run the checkpatch.pl script on each patch''' -- cgit v1.1 From 96daa41aab97f87f1a7b2d8bf00ee546db2ca156 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 6 May 2020 16:29:09 -0600 Subject: patman: Complain if a checkpatch line is not understood Rather than suffering in silence, output a warning if something about the checkpatch output cannot be understood. Signed-off-by: Simon Glass --- tools/patman/checkpatch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 5ae450d..98c63af 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -143,6 +143,8 @@ def CheckPatch(fname, verbose=False): elif subject_match: item['file'] = '' item['line'] = None + else: + print('bad line "%s", %d' % (line, len(line))) return result -- cgit v1.1 From 7664b03ffc51fa7563969c61fa28bf656af441bd Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Fri, 15 May 2020 09:30:12 +0300 Subject: buildman: Remove _of_#_ from results directory paths Currently, the following scenario will rebuild the first commit even though it is not really necessary - the commit sha or the position in the patchset did not change: $ git am $ tools/buildman/buildman -P -E -W -b master mx6 $ git am $ tools/buildman/buildman -P -E -W -b master mx6 <- will rebuild the first commit as well, even though nothing has changed about it. This is due to the fact that previous results directories get removed when the number of commits change. By removing the _of_#_ part of the directory path, the commits will be rebuilt only if the commit sha or the position in the patchset changes. Also, update the testcase to reflect this change. Signed-off-by: Ovidiu Panait --- tools/buildman/builder.py | 10 +++++----- tools/buildman/test.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index f8e71de..f2756ea 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -70,12 +70,12 @@ As an example, say we are building branch 'us-net' for boards 'sandbox' and like this: us-net/ base directory - 01_of_02_g4ed4ebc_net--Add-tftp-speed-/ + 01_g4ed4ebc_net--Add-tftp-speed-/ sandbox/ u-boot.bin seaboard/ u-boot.bin - 02_of_02_g4ed4ebc_net--Check-tftp-comp/ + 02_g4ed4ebc_net--Check-tftp-comp/ sandbox/ u-boot.bin seaboard/ @@ -487,8 +487,8 @@ class Builder: commit = self.commits[commit_upto] subject = commit.subject.translate(trans_valid_chars) # See _GetOutputSpaceRemovals() which parses this name - commit_dir = ('%02d_of_%02d_g%s_%s' % (commit_upto + 1, - self.commit_count, commit.hash, subject[:20])) + commit_dir = ('%02d_g%s_%s' % (commit_upto + 1, + commit.hash, subject[:20])) elif not self.no_subdirs: commit_dir = 'current' if not commit_dir: @@ -1599,7 +1599,7 @@ class Builder: for dirname in glob.glob(os.path.join(self.base_dir, '*')): if dirname not in dir_list: leaf = dirname[len(self.base_dir) + 1:] - m = re.match('[0-9]+_of_[0-9]+_g[0-9a-f]+_.*', leaf) + m = re.match('[0-9]+_g[0-9a-f]+_.*', leaf) if m: to_remove.append(dirname) return to_remove diff --git a/tools/buildman/test.py b/tools/buildman/test.py index 40811ba..82d25cf 100644 --- a/tools/buildman/test.py +++ b/tools/buildman/test.py @@ -541,7 +541,7 @@ class TestBuild(unittest.TestCase): build.commits = self.commits build.commit_count = len(self.commits) subject = self.commits[1].subject.translate(builder.trans_valid_chars) - dirname ='/%02d_of_%02d_g%s_%s' % (2, build.commit_count, commits[1][0], + dirname ='/%02d_g%s_%s' % (2, build.commit_count, commits[1][0], subject[:20]) self.CheckDirs(build, dirname) @@ -609,9 +609,9 @@ class TestBuild(unittest.TestCase): base_dir = tempfile.mkdtemp() # Add various files that we want removed and left alone - to_remove = ['01_of_22_g0982734987_title', '102_of_222_g92bf_title', - '01_of_22_g2938abd8_title'] - to_leave = ['something_else', '01-something.patch', '01_of_22_another'] + to_remove = ['01_g0982734987_title', '102_g92bf_title', + '01_g2938abd8_title'] + to_leave = ['something_else', '01-something.patch', '01_another'] for name in to_remove + to_leave: _Touch(name) -- cgit v1.1 From a9ad113df005b4ecd7b719736c228b1da69aa8d6 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 19 May 2020 23:38:32 -0700 Subject: fdtdec: Fix the types of addr and size in fdtdec_add_reserved_memory() fdtdec_get_addr_size() expects size is of type 'fdt_size_t', and return value is of type 'fdt_addr_t'. Adjust their types accordingly. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- lib/fdtdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 1f2b763..42f7a25 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1294,7 +1294,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, /* find a matching node and return the phandle to that */ fdt_for_each_subnode(node, blob, parent) { const char *name = fdt_get_name(blob, node, NULL); - phys_addr_t addr, size; + fdt_addr_t addr; + fdt_size_t size; addr = fdtdec_get_addr_size(blob, node, "reg", &size); if (addr == FDT_ADDR_T_NONE) { -- cgit v1.1 From f6704c79946c15fe327ff44e50f9559cd559d7ef Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 19 May 2020 23:38:33 -0700 Subject: fdtdec: Honor #address-cells and #size-cells in fdtdec_add_reserved_memory() At present fdtdec_add_reserved_memory() calls fdtdec_get_addr_size() to get address and size for the subnodes of /reserved-memory node. We should honor #address-cells and #size-cells properties in the parent node. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- lib/fdtdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 42f7a25..0dd7ff1 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1297,7 +1297,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, fdt_addr_t addr; fdt_size_t size; - addr = fdtdec_get_addr_size(blob, node, "reg", &size); + addr = fdtdec_get_addr_size_fixed(blob, node, "reg", 0, na, ns, + &size, false); if (addr == FDT_ADDR_T_NONE) { debug("failed to read address/size for %s\n", name); continue; -- cgit v1.1 From 2f8f5e23539819dcf9c995d7a829dbac67d0ba27 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 20 May 2020 23:27:27 +0200 Subject: doc: driver-model: there is no UCLASS_SATA %s/UCLASS_SATA/UCLASS_AHCI/g Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- doc/driver-model/design.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/driver-model/design.rst b/doc/driver-model/design.rst index 635effc..9e92727 100644 --- a/doc/driver-model/design.rst +++ b/doc/driver-model/design.rst @@ -613,7 +613,7 @@ be connected on a SATA bus or standalone with no bus:: xhci_usb (UCLASS_USB) flash (UCLASS_FLASH_STORAGE) - parent data/methods defined by USB bus - sata (UCLASS_SATA) + sata (UCLASS_AHCI) flash (UCLASS_FLASH_STORAGE) - parent data/methods defined by SATA bus flash (UCLASS_FLASH_STORAGE) - no parent data/methods (not on a bus) -- cgit v1.1 From 42a768c6892ba3bdedea75a430dff234fddffc8d Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Fri, 22 May 2020 18:41:36 +0200 Subject: libfdt: Remove superfluous NUL character from overlay symbols The symbol path already ends with a NUL character (something which is actually checked by the code) and this NUL is included in rel_path_len, so there is no need to add a second one. This change fixes incorrect display in "fdt list /__symbols" after applying an overlay with symbols. Signed-off-by: Marcus Comstedt Reviewed-by: Simon Glass --- scripts/dtc/libfdt/fdt_overlay.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/dtc/libfdt/fdt_overlay.c b/scripts/dtc/libfdt/fdt_overlay.c index c090e69..bd75e3d 100644 --- a/scripts/dtc/libfdt/fdt_overlay.c +++ b/scripts/dtc/libfdt/fdt_overlay.c @@ -757,7 +757,7 @@ static int overlay_symbol_update(void *fdt, void *fdto) && (memcmp(s, "/__overlay__", len - 1) == 0)) { /* //__overlay__ */ rel_path = ""; - rel_path_len = 0; + rel_path_len = 1; /* Include NUL character */ } else { /* Symbol refers to something that won't end * up in the target tree */ @@ -794,7 +794,7 @@ static int overlay_symbol_update(void *fdt, void *fdto) } ret = fdt_setprop_placeholder(fdt, root_sym, name, - len + (len > 1) + rel_path_len + 1, &p); + len + (len > 1) + rel_path_len, &p); if (ret < 0) return ret; @@ -820,7 +820,6 @@ static int overlay_symbol_update(void *fdt, void *fdto) buf[len] = '/'; memcpy(buf + len + 1, rel_path, rel_path_len); - buf[len + 1 + rel_path_len] = '\0'; } return 0; -- cgit v1.1 From b59889bf344dd261b50d69a5eacfa2874573c7cd Mon Sep 17 00:00:00 2001 From: Pratyush Yadav Date: Tue, 26 May 2020 17:35:57 +0530 Subject: regmap: Check for out-of-range offsets before mapping them In regmap_raw_{read,write}_range(), offsets are checked to make sure they aren't out of range. But this check happens _after_ the address is mapped from physical memory. Input should be sanity-checked before using it. Mapping the address before validating it leaves the door open to passing an invalid address to map_physmem(). So check for out of range offsets _before_ mapping them. This fixes a segmentation fault in sandbox when -1 is used as an offset to regmap_{read,write}(). Signed-off-by: Pratyush Yadav --- drivers/core/regmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 4a214ef..a67a237 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -310,13 +310,13 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset, } range = &map->ranges[range_num]; - ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE); - if (offset + val_len > range->size) { debug("%s: offset/size combination invalid\n", __func__); return -ERANGE; } + ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE); + switch (val_len) { case REGMAP_SIZE_8: *((u8 *)valp) = __read_8(ptr, map->endianness); @@ -419,13 +419,13 @@ int regmap_raw_write_range(struct regmap *map, uint range_num, uint offset, } range = &map->ranges[range_num]; - ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE); - if (offset + val_len > range->size) { debug("%s: offset/size combination invalid\n", __func__); return -ERANGE; } + ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE); + switch (val_len) { case REGMAP_SIZE_8: __write_8(ptr, val, map->endianness); -- cgit v1.1 From b44c751efe09e0069ba4ca6fca246b935bf5efcc Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 27 May 2020 09:43:31 +0200 Subject: doc: log: correct option name CONFIG_LOG_MAX_LEVEL Replace CONFIG_(SPL_)MAX_LOG_LEVEL by the correct name as defined in common/Kconfig: line 668:config LOG_MAX_LEVEL line 688:config SPL_LOG_MAX_LEVEL line 708:config TPL_LOG_MAX_LEVEL Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- doc/README.log | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/README.log b/doc/README.log index 1057981..ba83882 100644 --- a/doc/README.log +++ b/doc/README.log @@ -60,13 +60,14 @@ Enabling logging The following options are used to enable logging at compile time: CONFIG_LOG - Enables the logging system - CONFIG_MAX_LOG_LEVEL - Max log level to build (anything higher is compiled + CONFIG_LOG_MAX_LEVEL - Max log level to build (anything higher is compiled out) CONFIG_LOG_CONSOLE - Enable writing log records to the console If CONFIG_LOG is not set, then no logging will be available. -The above have SPL versions also, e.g. CONFIG_SPL_MAX_LOG_LEVEL. +The above have SPL and TPL versions also, e.g. CONFIG_SPL_LOG_MAX_LEVEL and +CONFIG_TPL_LOG_MAX_LEVEL. Temporary logging within a single file -- cgit v1.1 From a7813918fe4fa27146ed5777ee63329ae7564af9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 31 May 2020 10:46:12 +0200 Subject: doc: move README.log to HTML documentation Convert README.log to reStructuredText and add it to the generated HTML documentation. Assign doc/develop/logging.rst to the maintainer of LOGGING. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- MAINTAINERS | 1 + doc/develop/index.rst | 1 + doc/develop/logging.rst | 290 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 292 insertions(+) create mode 100644 doc/develop/logging.rst diff --git a/MAINTAINERS b/MAINTAINERS index 1fd975c..02971c2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -698,6 +698,7 @@ S: Maintained T: git https://gitlab.denx.de/u-boot/u-boot.git F: common/log* F: cmd/log.c +F: doc/develop/logging.rst F: test/log/ F: test/py/tests/test_log.py diff --git a/doc/develop/index.rst b/doc/develop/index.rst index 072db63..eb5095a 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -8,3 +8,4 @@ Develop U-Boot :maxdepth: 2 crash_dumps + logging diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst new file mode 100644 index 0000000..7ce8482 --- /dev/null +++ b/doc/develop/logging.rst @@ -0,0 +1,290 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. Copyright (c) 2017 Simon Glass + +Logging in U-Boot +================= + +Introduction +------------ + +U-Boot's internal operation involves many different steps and actions. From +setting up the board to displaying a start-up screen to loading an Operating +System, there are many component parts each with many actions. + +Most of the time this internal detail is not useful. Displaying it on the +console would delay booting (U-Boot's primary purpose) and confuse users. + +But for digging into what is happening in a particular area, or for debugging +a problem it is often useful to see what U-Boot is doing in more detail than +is visible from the basic console output. + +U-Boot's logging feature aims to satisfy this goal for both users and +developers. + + +Logging levels +-------------- + +There are a number logging levels available, in increasing order of verbosity: + +* LOGL_EMERG - Printed before U-Boot halts +* LOGL_ALERT - Indicates action must be taken immediate or U-Boot will crash +* LOGL_CRIT - Indicates a critical error that will cause boot failure +* LOGL_ERR - Indicates an error that may cause boot failure +* LOGL_WARNING - Warning about an unexpected condition +* LOGL_NOTE - Important information about progress +* LOGL_INFO - Information about normal boot progress +* LOGL_DEBUG - Debug information (useful for debugging a driver or subsystem) +* LOGL_DEBUG_CONTENT - Debug message showing full message content +* LOGL_DEBUG_IO - Debug message showing hardware I/O access + + +Logging category +---------------- + +Logging can come from a wide variety of places within U-Boot. Each log message +has a category which is intended to allow messages to be filtered according to +their source. + +The following main categories are defined: + +* LOGC_NONE - Unknown category (e.g. a debug() statement) +* UCLASS\_... - Related to a particular uclass (e.g. UCLASS_USB) +* LOGC_ARCH - Related to architecture-specific code +* LOGC_BOARD - Related to board-specific code +* LOGC_CORE - Related to core driver-model support +* LOGC_DT - Related to device tree control +* LOGC_EFI - Related to EFI implementation + + +Enabling logging +---------------- + +The following options are used to enable logging at compile time: + +* CONFIG_LOG - Enables the logging system +* CONFIG_LOG_MAX_LEVEL - Max log level to build (anything higher is compiled + out) +* CONFIG_LOG_CONSOLE - Enable writing log records to the console + +If CONFIG_LOG is not set, then no logging will be available. + +The above have SPL and TPL versions also, e.g. CONFIG_SPL_LOG_MAX_LEVEL and +CONFIG_TPL_LOG_MAX_LEVEL. + + +Temporary logging within a single file +-------------------------------------- + +Sometimes it is useful to turn on logging just in one file. You can use this + +.. code-block:: c + + #define LOG_DEBUG + +to enable building in of all logging statements in a single file. Put it at +the top of the file, before any #includes. + +To actually get U-Boot to output this you need to also set the default logging +level - e.g. set CONFIG_LOG_DEFAULT_LEVEL to 7 (LOGL_DEBUG) or more. Otherwise +debug output is suppressed and will not be generated. + + +Convenience functions +--------------------- + +A number of convenience functions are available to shorten the code needed +for logging: + +* log_err(_fmt...) +* log_warning(_fmt...) +* log_notice(_fmt...) +* log_info(_fmt...) +* log_debug(_fmt...) +* log_content(_fmt...) +* log_io(_fmt...) + +With these the log level is implicit in the name. The category is set by +LOG_CATEGORY, which you can only define once per file, above all #includes, e.g. + +.. code-block:: c + + #define LOG_CATEGORY LOGC_ALLOC + +Remember that all uclasses IDs are log categories too. + + +Log command +----------- + +The 'log' command provides access to several features: + +* level - access the default log level +* format - access the console log format +* rec - output a log record +* test - run tests + +Type 'help log' for details. + + +Using DEBUG +----------- + +U-Boot has traditionally used a #define called DEBUG to enable debugging on a +file-by-file basis. The debug() macro compiles to a printf() statement if +DEBUG is enabled, and an empty statement if not. + +With logging enabled, debug() statements are interpreted as logging output +with a level of LOGL_DEBUG and a category of LOGC_NONE. + +The logging facilities are intended to replace DEBUG, but if DEBUG is defined +at the top of a file, then it takes precedence. This means that debug() +statements will result in output to the console and this output will not be +logged. + + +Logging destinations +-------------------- + +If logging information goes nowhere then it serves no purpose. U-Boot provides +several possible determinations for logging information, all of which can be +enabled or disabled independently: + +* console - goes to stdout +* syslog - broadcast RFC 3164 messages to syslog servers on UDP port 514 + +The syslog driver sends the value of environmental variable 'log_hostname' as +HOSTNAME if available. + + +Log format +---------- + +You can control the log format using the 'log format' command. The basic +format is:: + + LEVEL.category,file.c:123-func() message + +In the above, file.c:123 is the filename where the log record was generated and +func() is the function name. By default ('log format default') only the +function name and message are displayed on the console. You can control which +fields are present, but not the field order. + + +Filters +------- + +Filters are attached to log drivers to control what those drivers emit. Only +records that pass through the filter make it to the driver. + +Filters can be based on several criteria: + +* maximum log level +* in a set of categories +* in a set of files + +If no filters are attached to a driver then a default filter is used, which +limits output to records with a level less than CONFIG_MAX_LOG_LEVEL. + + +Logging statements +------------------ + +The main logging function is: + +.. code-block:: c + + log(category, level, format_string, ...) + +Also debug() and error() will generate log records - these use LOG_CATEGORY +as the category, so you should #define this right at the top of the source +file to ensure the category is correct. + +You can also define CONFIG_LOG_ERROR_RETURN to enable the log_ret() macro. This +can be used whenever your function returns an error value: + +.. code-block:: c + + return log_ret(uclass_first_device(UCLASS_MMC, &dev)); + +This will write a log record when an error code is detected (a value < 0). This +can make it easier to trace errors that are generated deep in the call stack. + + +Code size +--------- + +Code size impact depends largely on what is enabled. The following numbers are +generated by 'buildman -S' for snow, which is a Thumb-2 board (all units in +bytes):: + + This series: adds bss +20.0 data +4.0 rodata +4.0 text +44.0 + CONFIG_LOG: bss -52.0 data +92.0 rodata -635.0 text +1048.0 + CONFIG_LOG_MAX_LEVEL=7: bss +188.0 data +4.0 rodata +49183.0 text +98124.0 + +The last option turns every debug() statement into a logging call, which +bloats the code hugely. The advantage is that it is then possible to enable +all logging within U-Boot. + + +To Do +----- + +There are lots of useful additions that could be made. None of the below is +implemented! If you do one, please add a test in test/py/tests/test_log.py + +Convenience functions to support setting the category: + +* log_arch(level, format_string, ...) - category LOGC_ARCH +* log_board(level, format_string, ...) - category LOGC_BOARD +* log_core(level, format_string, ...) - category LOGC_CORE +* log_dt(level, format_string, ...) - category LOGC_DT + +More logging destinations: + +* device - goes to a device (e.g. serial) +* buffer - recorded in a memory buffer + +Convert debug() statements in the code to log() statements + +Support making printf() emit log statements at L_INFO level + +Convert error() statements in the code to log() statements + +Figure out what to do with BUG(), BUG_ON() and warn_non_spl() + +Figure out what to do with assert() + +Add a way to browse log records + +Add a way to record log records for browsing using an external tool + +Add commands to add and remove filters + +Add commands to add and remove log devices + +Allow sharing of printf format strings in log records to reduce storage size +for large numbers of log records + +Add a command-line option to sandbox to set the default logging level + +Convert core driver model code to use logging + +Convert uclasses to use logging with the correct category + +Consider making log() calls emit an automatic newline, perhaps with a logn() +function to avoid that + +Passing log records through to linux (e.g. via device tree /chosen) + +Provide a command to access the number of log records generated, and the +number dropped due to them being generated before the log system was ready. + +Add a printf() format string pragma so that log statements are checked properly + +Enhance the log console driver to show level / category / file / line +information + +Add a command to add new log records and delete existing records. + +Provide additional log() functions - e.g. logc() to specify the category -- cgit v1.1 From 7b6c34cb15270c3dbd463faaceb2bfbdd0b8f1a8 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 31 May 2020 15:34:22 +0200 Subject: log: clean up Kconfig LOG_DEFAULT_LEVEL has been chosen as 6. Adjust the default of LOG_MAX_LEVEL to this value. Use ranges to clamp log levels to reasonable values. Group output options by main U-Boot, SPL, TPL, followed by other logging options. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- common/Kconfig | 159 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 85 insertions(+), 74 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index 2d86dd7..7872bc4 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -647,28 +647,12 @@ config LOG discarded if not needed. Logging supports various categories and levels of severity. -config SPL_LOG - bool "Enable logging support in SPL" - depends on LOG - help - This enables support for logging of status and debug messages. These - can be displayed on the console, recorded in a memory buffer, or - discarded if not needed. Logging supports various categories and - levels of severity. - -config TPL_LOG - bool "Enable logging support in TPL" - depends on LOG - help - This enables support for logging of status and debug messages. These - can be displayed on the console, recorded in a memory buffer, or - discarded if not needed. Logging supports various categories and - levels of severity. +if LOG config LOG_MAX_LEVEL int "Maximum log level to record" - depends on LOG - default 5 + default 6 + range 0 9 help This selects the maximum log level that will be recorded. Any value higher than this will be ignored. If possible log statements below @@ -685,14 +669,15 @@ config LOG_MAX_LEVEL 8 - debug content 9 - debug hardware I/O -config SPL_LOG_MAX_LEVEL - int "Maximum log level to record in SPL" - depends on SPL_LOG - default 3 +config LOG_DEFAULT_LEVEL + int "Default logging level to display" + default LOG_MAX_LEVEL + range 0 LOG_MAX_LEVEL help - This selects the maximum log level that will be recorded. Any value - higher than this will be ignored. If possible log statements below - this level will be discarded at build time. Levels: + This is the default logging level set when U-Boot starts. It can + be adjusted later using the 'log level' command. Note that setting + this to a value above LOG_MAX_LEVEL will be ineffective, since the + higher levels are not compiled in to U-Boot. 0 - emergency 1 - alert @@ -705,10 +690,38 @@ config SPL_LOG_MAX_LEVEL 8 - debug content 9 - debug hardware I/O -config TPL_LOG_MAX_LEVEL - int "Maximum log level to record in TPL" - depends on TPL_LOG +config LOG_CONSOLE + bool "Allow log output to the console" + default y + help + Enables a log driver which writes log records to the console. + Generally the console is the serial port or LCD display. Only the + log message is shown - other details like level, category, file and + line number are omitted. + +config LOG_SYSLOG + bool "Log output to syslog server" + depends on NET + help + Enables a log driver which broadcasts log records via UDP port 514 + to syslog servers. + +config SPL_LOG + bool "Enable logging support in SPL" + depends on LOG + help + This enables support for logging of status and debug messages. These + can be displayed on the console, recorded in a memory buffer, or + discarded if not needed. Logging supports various categories and + levels of severity. + +if SPL_LOG + +config SPL_LOG_MAX_LEVEL + int "Maximum log level to record in SPL" + depends on SPL_LOG default 3 + range 0 9 help This selects the maximum log level that will be recorded. Any value higher than this will be ignored. If possible log statements below @@ -725,14 +738,37 @@ config TPL_LOG_MAX_LEVEL 8 - debug content 9 - debug hardware I/O -config LOG_DEFAULT_LEVEL - int "Default logging level to display" - default 6 +config SPL_LOG_CONSOLE + bool "Allow log output to the console in SPL" + default y help - This is the default logging level set when U-Boot starts. It can - be adjusted later using the 'log level' command. Note that setting - this to a value above LOG_MAX_LEVEL will be ineffective, since the - higher levels are not compiled in to U-Boot. + Enables a log driver which writes log records to the console. + Generally the console is the serial port or LCD display. Only the + log message is shown - other details like level, category, file and + line number are omitted. + +endif + +config TPL_LOG + bool "Enable logging support in TPL" + depends on LOG + help + This enables support for logging of status and debug messages. These + can be displayed on the console, recorded in a memory buffer, or + discarded if not needed. Logging supports various categories and + levels of severity. + +if TPL_LOG + +config TPL_LOG_MAX_LEVEL + int "Maximum log level to record in TPL" + depends on TPL_LOG + default 3 + range 0 9 + help + This selects the maximum log level that will be recorded. Any value + higher than this will be ignored. If possible log statements below + this level will be discarded at build time. Levels: 0 - emergency 1 - alert @@ -745,29 +781,8 @@ config LOG_DEFAULT_LEVEL 8 - debug content 9 - debug hardware I/O -config LOG_CONSOLE - bool "Allow log output to the console" - depends on LOG - default y - help - Enables a log driver which writes log records to the console. - Generally the console is the serial port or LCD display. Only the - log message is shown - other details like level, category, file and - line number are omitted. - -config SPL_LOG_CONSOLE - bool "Allow log output to the console in SPL" - depends on SPL_LOG - default y - help - Enables a log driver which writes log records to the console. - Generally the console is the serial port or LCD display. Only the - log message is shown - other details like level, category, file and - line number are omitted. - config TPL_LOG_CONSOLE bool "Allow log output to the console in TPL" - depends on TPL_LOG default y help Enables a log driver which writes log records to the console. @@ -775,26 +790,10 @@ config TPL_LOG_CONSOLE log message is shown - other details like level, category, file and line number are omitted. -config LOG_SYSLOG - bool "Log output to syslog server" - depends on LOG && NET - help - Enables a log driver which broadcasts log records via UDP port 514 - to syslog servers. - -config LOG_TEST - bool "Provide a test for logging" - depends on LOG && UNIT_TEST - default y if SANDBOX - help - This enables a 'log test' command to test logging. It is normally - executed from a pytest and simply outputs logging information - in various different ways to test that the logging system works - correctly with various settings. +endif config LOG_ERROR_RETURN bool "Log all functions which return an error" - depends on LOG help When an error is returned in U-Boot it is sometimes difficult to figure out the root cause. For example, reading from SPI flash may @@ -805,6 +804,18 @@ config LOG_ERROR_RETURN You can add log_ret() to all functions which return an error code. +config LOG_TEST + bool "Provide a test for logging" + depends on UNIT_TEST + default y if SANDBOX + help + This enables a 'log test' command to test logging. It is normally + executed from a pytest and simply outputs logging information + in various different ways to test that the logging system works + correctly with various settings. + +endif + endmenu config SUPPORT_RAW_INITRD -- cgit v1.1 From 77007f9543a0fac8c4f60800de6ddccfacd9af5d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 31 May 2020 13:44:51 +0000 Subject: log: check argument of 'log level' command Check that the argument provided to the 'log level' command is in the range between zero and CONFIG_LOG_MAX_LEVEL. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- cmd/log.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/log.c b/cmd/log.c index 664f7bd..78352b2 100644 --- a/cmd/log.c +++ b/cmd/log.c @@ -14,10 +14,18 @@ static char log_fmt_chars[LOGF_COUNT] = "clFLfm"; static int do_log_level(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - if (argc > 1) - gd->default_log_level = simple_strtol(argv[1], NULL, 10); - else + if (argc > 1) { + long log_level = simple_strtol(argv[1], NULL, 10); + + if (log_level < 0 || log_level > _LOG_MAX_LEVEL) { + printf("Only log levels <= %d are supported\n", + _LOG_MAX_LEVEL); + return CMD_RET_FAILURE; + } + gd->default_log_level = log_level; + } else { printf("Default log level: %d\n", gd->default_log_level); + } return 0; } -- cgit v1.1 From c03b7612ea346ad7454086d1623fb57098faf315 Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Tue, 2 Jun 2020 01:47:07 +0200 Subject: usb: provide a device tree node to USB devices It is possible to specify a device tree node for an USB device. This is useful if you have a static USB setup and want to use aliases which point to these nodes, like on the Raspberry Pi. The nodes are matched against their hub port number, the compatible strings are not matched for now. Signed-off-by: Michael Walle Reviewed-by: Marek Vasut Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 9 +++++++++ drivers/usb/host/usb-uclass.c | 41 ++++++++++++++++++++++++++++++++++++----- test/dm/usb.c | 22 ++++++++++++++++++++++ 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 5ce5e28..b9255e4 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -810,6 +810,8 @@ hub { compatible = "usb-hub"; usb,device-class = <9>; + #address-cells = <1>; + #size-cells = <0>; hub-emul { compatible = "sandbox,usb-hub"; #address-cells = <1>; @@ -838,6 +840,13 @@ }; }; + + usbstor@1 { + reg = <1>; + }; + usbstor@3 { + reg = <3>; + }; }; }; diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index cb79dfb..f42c062 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -494,6 +494,35 @@ static int usb_match_one_id(struct usb_device_descriptor *desc, return usb_match_one_id_intf(desc, int_desc, id); } +static ofnode usb_get_ofnode(struct udevice *hub, int port) +{ + ofnode node; + u32 reg; + + if (!dev_has_of_node(hub)) + return ofnode_null(); + + /* + * The USB controller and its USB hub are two different udevices, + * but the device tree has only one node for both. Thus we are + * assigning this node to both udevices. + * If port is zero, the controller scans its root hub, thus we + * are using the same ofnode as the controller here. + */ + if (!port) + return dev_ofnode(hub); + + ofnode_for_each_subnode(node, dev_ofnode(hub)) { + if (ofnode_read_u32(node, "reg", ®)) + continue; + + if (reg == port) + return node; + } + + return ofnode_null(); +} + /** * usb_find_and_bind_driver() - Find and bind the right USB driver * @@ -502,13 +531,14 @@ static int usb_match_one_id(struct usb_device_descriptor *desc, static int usb_find_and_bind_driver(struct udevice *parent, struct usb_device_descriptor *desc, struct usb_interface_descriptor *iface, - int bus_seq, int devnum, + int bus_seq, int devnum, int port, struct udevice **devp) { struct usb_driver_entry *start, *entry; int n_ents; int ret; char name[30], *str; + ofnode node = usb_get_ofnode(parent, port); *devp = NULL; debug("%s: Searching for driver\n", __func__); @@ -533,8 +563,8 @@ static int usb_find_and_bind_driver(struct udevice *parent, * find another driver. For now this doesn't seem * necesssary, so just bind the first match. */ - ret = device_bind(parent, drv, drv->name, NULL, -1, - &dev); + ret = device_bind_ofnode(parent, drv, drv->name, NULL, + node, &dev); if (ret) goto error; debug("%s: Match found: %s\n", __func__, drv->name); @@ -651,9 +681,10 @@ int usb_scan_device(struct udevice *parent, int port, if (ret) { if (ret != -ENOENT) return ret; - ret = usb_find_and_bind_driver(parent, &udev->descriptor, iface, + ret = usb_find_and_bind_driver(parent, &udev->descriptor, + iface, udev->controller_dev->seq, - udev->devnum, &dev); + udev->devnum, port, &dev); if (ret) return ret; created = true; diff --git a/test/dm/usb.c b/test/dm/usb.c index a25c2c1..b273a51 100644 --- a/test/dm/usb.c +++ b/test/dm/usb.c @@ -78,6 +78,28 @@ static int dm_test_usb_multi(struct unit_test_state *uts) } DM_TEST(dm_test_usb_multi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); +/* test that we have an associated ofnode with the usb device */ +static int dm_test_usb_fdt_node(struct unit_test_state *uts) +{ + struct udevice *dev; + ofnode node; + + state_set_skip_delays(true); + ut_assertok(usb_init()); + ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &dev)); + node = ofnode_path("/usb@1/hub/usbstor@1"); + ut_asserteq(1, ofnode_equal(node, dev_ofnode(dev))); + ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 1, &dev)); + ut_asserteq(1, ofnode_equal(ofnode_null(), dev_ofnode(dev))); + ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 2, &dev)); + node = ofnode_path("/usb@1/hub/usbstor@3"); + ut_asserteq(1, ofnode_equal(node, dev_ofnode(dev))); + ut_assertok(usb_stop()); + + return 0; +} +DM_TEST(dm_test_usb_fdt_node, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + static int count_usb_devices(void) { struct udevice *hub; -- cgit v1.1 From 0a6b75f7d8cbf7edc62c7d132b521703f1e2a53d Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Tue, 2 Jun 2020 01:47:08 +0200 Subject: dm: core: fix dev_read_alias_highest_id() without libfdt If CONFIG_DM_DEV_READ_INLINE is set, dev_read_alias_highest_id() calls libfdt_get_highest_id(). But this function is only available if we have libfdt compiled in. If its not available return -1, which matches the return code for no alias found. This fixes the following error on omapl138_lcdk: arm-linux-gnueabi-ld.bfd: drivers/built-in.o: in function `dev_read_alias_highest_id': /home/mw/repo/u-boot/include/dm/read.h:986: undefined reference to `fdtdec_get_alias_highest_id' Signed-off-by: Michael Walle Reviewed-by: Simon Glass --- include/dm/read.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/dm/read.h b/include/dm/read.h index b952551..1c1bc37 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -983,6 +983,8 @@ static inline u64 dev_translate_dma_address(const struct udevice *dev, static inline int dev_read_alias_highest_id(const char *stem) { + if (!CONFIG_IS_ENABLED(OF_LIBFDT)) + return -1; return fdtdec_get_alias_highest_id(gd->fdt_blob, stem); } -- cgit v1.1 From be1a6e94254af205bd67d69e3bdb26b161ccd72f Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Tue, 2 Jun 2020 01:47:09 +0200 Subject: dm: uclass: don't assign aliased seq numbers If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias. Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2. In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one. Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers. Signed-off-by: Michael Walle Reviewed-by: Alex Marginean Tested-by: Alex Marginean Acked-by: Vladimir Oltean Reviewed-by: Simon Glass Tested-by: Michal Simek [on zcu102-revA] --- arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index b9255e4..a6e2bfd 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -23,8 +23,8 @@ pci0 = &pci0; pci1 = &pci1; pci2 = &pci2; - remoteproc1 = &rproc_1; - remoteproc2 = &rproc_2; + remoteproc0 = &rproc_1; + remoteproc1 = &rproc_2; rtc0 = &rtc_0; rtc1 = &rtc_1; spi0 = "/spi@0"; diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 2ab419c..c3f1b73 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -689,13 +689,14 @@ int uclass_unbind_device(struct udevice *dev) int uclass_resolve_seq(struct udevice *dev) { + struct uclass *uc = dev->uclass; + struct uclass_driver *uc_drv = uc->uc_drv; struct udevice *dup; - int seq; + int seq = 0; int ret; assert(dev->seq == -1); - ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, dev->req_seq, - false, &dup); + ret = uclass_find_device_by_seq(uc_drv->id, dev->req_seq, false, &dup); if (!ret) { dm_warn("Device '%s': seq %d is in use by '%s'\n", dev->name, dev->req_seq, dup->name); @@ -707,9 +708,17 @@ int uclass_resolve_seq(struct udevice *dev) return ret; } - for (seq = 0; seq < DM_MAX_SEQ; seq++) { - ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, seq, - false, &dup); + if (CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_SEQ_ALIAS) && + (uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) { + /* + * dev_read_alias_highest_id() will return -1 if there no + * alias. Thus we can always add one. + */ + seq = dev_read_alias_highest_id(uc_drv->name) + 1; + } + + for (; seq < DM_MAX_SEQ; seq++) { + ret = uclass_find_device_by_seq(uc_drv->id, seq, false, &dup); if (ret == -ENODEV) break; if (ret) diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 2a81f3a..528187e 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -94,9 +94,9 @@ #endif #define SANDBOX_ETH_SETTINGS "ethaddr=00:00:11:22:33:44\0" \ - "eth1addr=00:00:11:22:33:45\0" \ - "eth3addr=00:00:11:22:33:46\0" \ - "eth5addr=00:00:11:22:33:47\0" \ + "eth3addr=00:00:11:22:33:45\0" \ + "eth5addr=00:00:11:22:33:46\0" \ + "eth6addr=00:00:11:22:33:47\0" \ "ipaddr=1.2.3.4\0" #define MEM_LAYOUT_ENV_SETTINGS \ diff --git a/test/dm/eth.c b/test/dm/eth.c index 1fddcaa..b58c964 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -48,7 +48,7 @@ static int dm_test_eth_alias(struct unit_test_state *uts) ut_assertok(net_loop(PING)); ut_asserteq_str("eth@10002000", env_get("ethact")); - env_set("ethact", "eth1"); + env_set("ethact", "eth6"); ut_assertok(net_loop(PING)); ut_asserteq_str("eth@10004000", env_get("ethact")); @@ -105,7 +105,7 @@ static int dm_test_eth_act(struct unit_test_state *uts) const char *ethname[DM_TEST_ETH_NUM] = {"eth@10002000", "eth@10003000", "sbe5", "eth@10004000"}; const char *addrname[DM_TEST_ETH_NUM] = {"ethaddr", "eth5addr", - "eth3addr", "eth1addr"}; + "eth3addr", "eth6addr"}; char ethaddr[DM_TEST_ETH_NUM][18]; int i; @@ -188,15 +188,15 @@ static int dm_test_eth_rotate(struct unit_test_state *uts) /* Invalidate eth1's MAC address */ memset(ethaddr, '\0', sizeof(ethaddr)); - strncpy(ethaddr, env_get("eth1addr"), 17); - /* Must disable access protection for eth1addr before clearing */ - env_set(".flags", "eth1addr"); - env_set("eth1addr", NULL); + strncpy(ethaddr, env_get("eth6addr"), 17); + /* Must disable access protection for eth6addr before clearing */ + env_set(".flags", "eth6addr"); + env_set("eth6addr", NULL); retval = _dm_test_eth_rotate1(uts); /* Restore the env */ - env_set("eth1addr", ethaddr); + env_set("eth6addr", ethaddr); env_set("ethrotate", NULL); if (!retval) { diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 4fcae03..51f2547 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -361,20 +361,32 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts) ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 2, &dev)); ut_asserteq_str("d-test", dev->name); - /* d-test actually gets 0 */ - ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 0, &dev)); + /* + * d-test actually gets 9, because thats the next free one after the + * aliases. + */ + ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 9, &dev)); ut_asserteq_str("d-test", dev->name); - /* initially no one wants seq 1 */ - ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, + /* initially no one wants seq 10 */ + ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev)); ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev)); /* But now that it is probed, we can find it */ - ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, &dev)); + ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev)); ut_asserteq_str("f-test", dev->name); + /* + * And we should still have holes in our sequence numbers, that is 2 + * and 4 should not be used. + */ + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 2, + true, &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4, + true, &dev)); + return 0; } DM_TEST(dm_test_fdt_uclass_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -- cgit v1.1 From cea8f2c995b9d87af6ef42f967402e1c8a3506db Mon Sep 17 00:00:00 2001 From: Dario Binacchi Date: Thu, 4 Jun 2020 14:58:13 +0200 Subject: doc: driver-model: fix typo in design.rst Fix the 'memeber' typo in doc/driver-model/design.rst. Signed-off-by: Dario Binacchi Reviewed-by: Simon Glass --- doc/driver-model/design.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/driver-model/design.rst b/doc/driver-model/design.rst index 9e92727..96525b6 100644 --- a/doc/driver-model/design.rst +++ b/doc/driver-model/design.rst @@ -628,7 +628,7 @@ parent device which is a bus, causes the device to start behaving like a bus device, regardless of its own views on the matter. The uclass for the device can also contain data private to that uclass. -But note that each device on the bus may be a memeber of a different +But note that each device on the bus may be a member of a different uclass, and this data has nothing to do with the child data for each child on the bus. It is the bus' uclass that controls the child with respect to the bus. -- cgit v1.1