Re: [PATCH v4 02/16] arm: mach-k3: Add basic support for J784S4 SoC definition
Hi Nishanth, On 07:24-20231004, Nishanth Menon wrote: > On 10:43-20231004, Manorit Chawdhry wrote: > > > These are required to remove the firewall configurations that are done > > by ROM, those are not the ones that are being handled by OIDs. The > > I am not sure I understand this clearly. OIDs are setup to open up > firewalls or close firewalls as the system requires and since it > is authenticated, not compromiseable.- U-boot by itself (even if > authenticated), is not a secure entity for it to dictate the firewall > configuration (u-boot must be assumed to be compromised after > authentication is complete). So, doing firewall configuration via APIs > after boot, to me looks broken approach. > I know U-boot ain't that secure given the most trusted entity is always gonna be the software that starts up the system, we can't expect those to be doing all the work and based on that we have the secure boot designed to configure firewalls (that are not owned by anymore) and U-boot R5 being one of the early bootloaders do come as a part of it. Regarding the OIDs thing, I don't think the OID in question is looked by ROM and ROM always configures some firewalls for it's usecase that are present in those arrays. The OID that we are using in the series that you had shared is looked by TIFS instead of ROM and TIFS is the entity that is authenticating the binary along with setting up the firewalls. > > current series that is being worked on is to add additional firewalling > > support with OIDs that TIFS will be handling. > > The above patch is > > essentially added to have the same development experience on GP devices > > similar to HS after the secure boot is done so that people don't end up > > huh? the code seems to blindly call the > remove_fwl_configs(cbass_hc_cfg0_fwls, ARRAY_SIZE(cbass_hc_cfg0_fwls)); > where is the distinction of HS vs GP here? This implementation looks > completely broken to me at least.. please correct what I missed here. Since this call is used across all SoCs there wasn't any point to make the differentiation between GP and HS here, remove_fwl_configs internally handles looking at the firewalls and disabling them if they are enabled ( Which would be only in the case of HS devices ), for GP it would automatically by a noop. Regards, Manorit > > -- > Regards, > Nishanth Menon > Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 > 849D 1736 249D
[PATCH] board: siemens: iot2050: Fix logical bug in PG1/PG2 detection
From: Jan Kiszka This caused the wrong fdtfile to be set and was failing to apply M.2 settings. Fixes: badaa1f6a7a9 ("boards: siemens: iot2050: Unify PG1 and PG2/M.2 configurations again") Signed-off-by: Jan Kiszka --- board/siemens/iot2050/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c index 15f5310c7bf..e35e55fb5de 100644 --- a/board/siemens/iot2050/board.c +++ b/board/siemens/iot2050/board.c @@ -160,7 +160,7 @@ static bool board_is_sr1(void) struct iot2050_info *info = IOT2050_INFO_DATA; return info->magic == IOT2050_INFO_MAGIC && - strstr((char *)info->name, "-PG2") != NULL; + strstr((char *)info->name, "-PG2") == NULL; } static bool board_is_m2(void) -- 2.35.3
[PATCH] arm: dts: k3-am65-iot2050: Fix boot
From: Jan Kiszka Since commit [1] A53 u-boot proper is broken. This is because nodes marked as 'bootph-pre-ram' are not available at u-boot proper before relocation. To fix this we mark all nodes in u-boot.dtsi as 'bootph-all'. [1] 9e644284ab812 ("dm: core: Report bootph-pre-ram/sram node as pre-reloc after relocation") Signed-off-by: Jan Kiszka --- .../dts/k3-am65-iot2050-common-u-boot.dtsi| 44 +-- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/arch/arm/dts/k3-am65-iot2050-common-u-boot.dtsi b/arch/arm/dts/k3-am65-iot2050-common-u-boot.dtsi index 9fd64809a63..30fc7a78d89 100644 --- a/arch/arm/dts/k3-am65-iot2050-common-u-boot.dtsi +++ b/arch/arm/dts/k3-am65-iot2050-common-u-boot.dtsi @@ -37,18 +37,18 @@ }; leds { - bootph-pre-ram; + bootph-all; status-led-red { - bootph-pre-ram; + bootph-all; }; status-led-green { - bootph-pre-ram; + bootph-all; }; }; }; &cbass_mcu { - bootph-pre-ram; + bootph-all; mcu_navss: bus@2838 { ringacc@2b80 { @@ -75,70 +75,70 @@ }; &cbass_wakeup { - bootph-pre-ram; + bootph-all; }; &cbass_main { - bootph-pre-ram; + bootph-all; main_navss: bus@3080 { - bootph-pre-ram; + bootph-all; }; }; &wkup_pmx0 { - bootph-pre-ram; + bootph-all; mcu-fss0-ospi0-pins-default { - bootph-pre-ram; + bootph-all; }; }; &main_pmx0 { - bootph-pre-ram; + bootph-all; main-uart1-pins-default { - bootph-pre-ram; + bootph-all; }; }; &main_uart1 { - bootph-pre-ram; + bootph-all; current-speed = <115200>; }; &wkup_gpio0 { - bootph-pre-ram; + bootph-all; }; &ospi0 { - bootph-pre-ram; + bootph-all; flash@0 { - bootph-pre-ram; + bootph-all; }; }; &secure_proxy_main { - bootph-pre-ram; + bootph-all; }; &dmsc { - bootph-pre-ram; + bootph-all; k3_sysreset: sysreset-controller { compatible = "ti,sci-sysreset"; - bootph-pre-ram; + bootph-all; }; }; &k3_pds { - bootph-pre-ram; + bootph-all; }; &k3_clks { - bootph-pre-ram; + bootph-all; }; &k3_reset { - bootph-pre-ram; + bootph-all; }; &fss { - bootph-pre-ram; + bootph-all; }; -- 2.35.3
Re: [PATCH] arm: dts: k3-am625-beagleplay: Fix boot
On 04.10.23 14:15, Nishanth Menon wrote: > On 22:26-20231003, Jan Kiszka wrote: >> From: Jan Kiszka >> >> Since commit [1] A53 u-boot proper is broken. This is because nodes >> marked as 'bootph-pre-ram' are not available at u-boot proper before >> relocation. >> >> To fix this we mark all nodes as 'bootph-all'. >> >> [1] 9e644284ab812 ("dm: core: Report bootph-pre-ram/sram node as pre-reloc >> after relocation") >> >> Signed-off-by: Jan Kiszka >> --- >> >> This may overshoot, but at least the board boots again. Could it be that >> [1] broke even more boards? > > Jan: > https://lore.kernel.org/all/b1c62a7d-a90e-4212-8972-9b622e147...@kernel.org/ > > I got boot without r5-beagleplay.dts modified. and it is in line with > the changes in linux-next commit 944adefc7f88 ("arm64: dts: ti: > k3-am625-beagleplay: Add boot phase tags marking") > Yeah, no problem, missed that. Meanwhile, I can fix our IOT2050 because I was unfortunatenly right: more havoc in sight. Did anyone tried to look at the fallouts systematically already? Is it only affecting the TI family? Jan -- Siemens AG, Technology Linux Expert Center
[PATCH 1/1] [u-boot][master][PATCH v3] pico-imx7d: add baseboard SD card boot detect
From: Benjamin Szőke Take over codes from Techenxion to support mmc autodetect boot for pico-imx7d. Signed-off-by: Benjamin Szőke --- board/technexion/pico-imx7d/pico-imx7d.c | 57 +++ board/technexion/pico-imx7d/spl.c| 91 ++-- include/configs/pico-imx7d.h | 4 +- 3 files changed, 144 insertions(+), 8 deletions(-) diff --git a/board/technexion/pico-imx7d/pico-imx7d.c b/board/technexion/pico-imx7d/pico-imx7d.c index 6e98b85b28..7e0fa002d3 100644 --- a/board/technexion/pico-imx7d/pico-imx7d.c +++ b/board/technexion/pico-imx7d/pico-imx7d.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,50 @@ int board_phy_config(struct phy_device *phydev) } #endif +#if CONFIG_IS_ENABLED(FSL_ESDHC_IMX) +int check_mmc_autodetect(void) +{ + char *autodetect_str = env_get("mmcautodetect"); + + if ((autodetect_str != NULL) && + (strcmp(autodetect_str, "yes") == 0)) { + return 1; + } + + return 0; +} + +void board_late_mmc_init(void) +{ + int dev_no = 0; + char cmd[32]; + char mmcblk[32]; + + if (!check_mmc_autodetect()) + return; + + switch (get_boot_device()) { + case SD3_BOOT: + case MMC3_BOOT: + env_set("bootdev", "MMC3"); + dev_no = 2; + break; + case SD1_BOOT: + env_set("bootdev", "SD1"); + dev_no = 0; + break; + default: + printf("Wrong boot device!"); + } + + /* Set mmcdev env */ + env_set_ulong("mmcdev", dev_no); + + sprintf(cmd, "mmc dev %d", dev_no); + run_command(cmd, 0); +} +#endif + static void setup_iomux_uart(void) { imx_iomux_v3_setup_multiple_pads(uart5_pads, ARRAY_SIZE(uart5_pads)); @@ -176,6 +221,12 @@ int board_late_init(void) set_wdog_reset(wdog); +#if CONFIG_IS_ENABLED(FSL_ESDHC_IMX) +#if defined(CONFIG_ENV_IS_IN_MMC) || defined(CONFIG_ENV_IS_NOWHERE) + board_late_mmc_init(); +#endif /* CONFIG_ENV_IS_IN_MMC or CONFIG_ENV_IS_NOWHERE */ +#endif + /* * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4), * since we use PMIC_PWRON to reset the board. @@ -210,3 +261,9 @@ int board_ehci_hcd_init(int port) } return 0; } + +/* This should be defined for each board */ +__weak int mmc_map_to_kernel_blk(int dev_no) +{ +return dev_no; +} diff --git a/board/technexion/pico-imx7d/spl.c b/board/technexion/pico-imx7d/spl.c index c6b21aaa42..f4711483df 100644 --- a/board/technexion/pico-imx7d/spl.c +++ b/board/technexion/pico-imx7d/spl.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -159,7 +160,20 @@ void reset_cpu(void) #define USDHC_PAD_CTRL (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \ PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU47KOHM) -static iomux_v3_cfg_t const usdhc3_pads[] = { +#define USDHC1_CD_GPIO IMX_GPIO_NR(5, 0) +/* EMMC/SD */ +static iomux_v3_cfg_t const usdhc1_pads[] = { + MX7D_PAD_SD1_CLK__SD1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX7D_PAD_SD1_CMD__SD1_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX7D_PAD_SD1_DATA0__SD1_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX7D_PAD_SD1_DATA1__SD1_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX7D_PAD_SD1_DATA2__SD1_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX7D_PAD_SD1_DATA3__SD1_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX7D_PAD_SD1_CD_B__GPIO5_IO0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), +}; + +#define USDHC3_CD_GPIO IMX_GPIO_NR(1, 14) +static iomux_v3_cfg_t const usdhc3_emmc_pads[] = { MX7D_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), MX7D_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), MX7D_PAD_SD3_DATA0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), @@ -173,20 +187,83 @@ static iomux_v3_cfg_t const usdhc3_pads[] = { MX7D_PAD_GPIO1_IO14__GPIO1_IO14 | MUX_PAD_CTRL(USDHC_PAD_CTRL), }; -static struct fsl_esdhc_cfg usdhc_cfg[1] = { +static struct fsl_esdhc_cfg usdhc_cfg[2] = { {USDHC3_BASE_ADDR}, + {USDHC1_BASE_ADDR}, }; int board_mmc_getcd(struct mmc *mmc) { - /* Assume uSDHC3 emmc is always present */ - return 1; + struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; + int ret = 0; + + switch (cfg->esdhc_base) { + case USDHC1_BASE_ADDR: + ret = !gpio_get_value(USDHC1_CD_GPIO); /* Assume uSDHC1 sd is always present */ + break; + case USDHC3_BASE_ADDR: + ret = !gpio_get_value(USDHC3_CD_GPIO); /* Assume uSDHC3 emmc is always present */ + break; + } + + return ret; } int board_mmc_init(struct bd_info *bis) { - imx_iomux_v3_setup_multiple_pads(us
Re: bootstd: Scanning for USB bootflow will remove existing SCSI bootflow
Hi Simon, On Mon, Oct 2, 2023 at 12:25 PM Tony Dinh wrote: > > Hi Simon, > > On Sun, Oct 1, 2023 at 6:22 PM Simon Glass wrote: > > > > Hi Tony, > > > > On Tue, 26 Sept 2023 at 13:40, Tony Dinh wrote: > > > > > > Hi Simon, > > > > > > On Tue, Sep 26, 2023 at 4:37 AM Simon Glass wrote: > > > > > > > > Hi Tony, > > > > > > > > On Mon, 25 Sept 2023 at 14:02, Tony Dinh wrote: > > > > > > > > > > Hi Simon, > > > > > > > > > > Here is an observation during testing the bootflow command. > > > > > > > > > > If there is a SCSI bootflow, scanning for USB bootflow will remove > > > > > that existing > > > > > SCSI bootflow. To bring it back, I scanned for SCSI bootflow again, > > > > > and it was > > > > > back to normal. Perhaps there is some kind of indexing problem? > > > > > > > > Yes that's right. The 'botflow scan' command is not additive. The > > > > first thing it does is removing existing bootflows. > > > > > > Thanks for clarifying that. I assumed it is additive, because the > > > existing USB bootflow was not removed when I did a "bootflow scan > > > scsi" immediately after (see the end of the log). > > > > Yes, but I'm not sure what is going on there. Perhaps it is a bug? > > When you scan SCSI it should not also scan USB. > > Yes, it looks like a bug. I think I can see the problem and am working > on a patch. Just to let you know, I'm out of time to work on this topic. I will revisit it some other time, if you have not already tracked it down. All the best, Tony > > All the best, > Tony > > > > > > Regards, > > SImon
[PATCH] net: phy: xilinx_phy: Get rid of using property xlnx, phy-type
As the xlnx,phy-type device tree property is deprecated and phy-mode is being used, so removing the code references of xlnx,phy-type. Signed-off-by: Venkatesh Yadav Abbarapu --- drivers/net/phy/xilinx_phy.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/net/phy/xilinx_phy.c b/drivers/net/phy/xilinx_phy.c index 1df639d6f4..50f1611ad5 100644 --- a/drivers/net/phy/xilinx_phy.c +++ b/drivers/net/phy/xilinx_phy.c @@ -107,10 +107,6 @@ static int xilinxphy_of_init(struct phy_device *phydev) if (!ofnode_valid(node)) return -EINVAL; - phytype = ofnode_read_u32_default(node, "xlnx,phy-type", -1); - if (phytype == XAE_PHY_TYPE_1000BASE_X) - phydev->flags |= XAE_PHY_TYPE_1000BASE_X; - return 0; } -- 2.17.1
Re: [PATCH 09/16] pinctrl: renesas: Add RZ/G2L PFC driver
On 10/4/23 21:43, Paul Barker wrote: [...] +/* + * We need to ensure that the module clock is enabled and all resets are + * de-asserted before using either the gpio or pinctrl functionality. Error + * handling can be quite simple here as if the PFC cannot be enabled then we + * will not be able to progress with the boot anyway. + */ +static int rzg2l_pfc_enable(struct udevice *dev) +{ + struct rzg2l_pfc_data *data = + (struct rzg2l_pfc_data *)dev_get_driver_data(dev); + struct reset_ctl_bulk rsts; + struct clk clk; + int ret; + + if (data->pfc_enabled) When does this get triggered ? This is initialised to false in rzg2l_pfc_bind(), then this function rzg2l_pfc_enable() sets it to true before a successful return. The effect is that the PFC is enabled just once, regardless of whether the pinctrl or gpio driver is probed first. Why would be call to rzg2l_pfc_enable() a problem in the first place ? It just grabs and enables clock and ungates reset, the second time this is called the impact on harware should be no-op , right ? The hw impact is a no-op, but it wastes time unnecessarily re-reading data from the fdt and repeating the setup, e.g. in rzg2l_cpg_clk_set() we have to search the array of clocks each time to find the requested entry. Does getting clock and enabling them have noticable overhead on this platform ? Look at CONFIG_OF_LIVE, that should mitigate the DT access overhead at least. I think it's worth keeping the conditional here but can drop it if you're really against it. It feels like fixing a problem at the wrong place really.
Re: [RFC] mmc: Remove alignment hole for cmdidx in struct mmc_cmd
Hi Jonas, On Mon, 2 Oct 2023 at 13:29, Jonas Karlman wrote: > > On 2023-10-02 20:56, Simon Glass wrote: > > On Fri, 29 Sept 2023 at 17:07, Jonas Karlman wrote: > >> > >> The alignment hole caused by cmdidx in struct mmc_cmd cause strange > >> issues together with the peephole2 optimization on Amlogic SoCs. > >> Following was observed while working on SPL support for Amlogic SoCs. > >> > >> sd_get_capabilities() normally issue a CMD55 followed by a CMD51. > >> However, on at least Amlogic S905 (Cortex-A53) and S905X3 (Cortex-A55), > >> CMD55 was instead followed by CMD8 (and a few reties) in SPL. > >> > >> Code from the call site: > >> > >> cmd.cmdidx = SD_CMD_APP_SEND_SCR; // 51 > >> ... > >> data.blocksize = 8; > >> ... > >> err = mmc_send_cmd_retry(mmc, &cmd, &data, 3); > >> > >> Running the code with MMC_TRACE enabled shows: > >> > >> CMD_SEND:55 > >> ARG 0x5048 > >> MMC_RSP_R1,5,6,7 0x0920 > >> CMD_SEND:8 > >> ARG 0x > >> RET -110 > >> > >> Removing the alignment hole by changing cmdidx from ushort to uint or > >> building with -fno-peephole2 flag seem to resolve this issue. > >> > >> CMD_SEND:55 > >> ARG 0x5048 > >> MMC_RSP_R1,5,6,7 0x0920 > >> CMD_SEND:51 > >> ARG 0x > >> MMC_RSP_R1,5,6,7 0x0920 > >> > >> Same issue was observed building U-Boot with gcc 8-13. Please advise on > >> how to best work around this possible gcc optimization bug. > >> > >> Signed-off-by: Jonas Karlman > >> --- > >> arch/arm/cpu/armv8/config.mk | 2 ++ > >> include/mmc.h| 2 +- > >> 2 files changed, 3 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/arm/cpu/armv8/config.mk b/arch/arm/cpu/armv8/config.mk > >> index 4d74b2a533e0..7177dcd7c73b 100644 > >> --- a/arch/arm/cpu/armv8/config.mk > >> +++ b/arch/arm/cpu/armv8/config.mk > >> @@ -7,6 +7,8 @@ PLATFORM_RELFLAGS += $(call > >> cc-option,-mbranch-protection=none) > >> PF_NO_UNALIGNED := $(call cc-option, -mstrict-align) > >> PLATFORM_CPPFLAGS += $(PF_NO_UNALIGNED) > >> > >> +PLATFORM_CPPFLAGS += $(call cc-option,-fno-peephole2) > > > > Eek really? > > As mentioned the issue could be resolved with changing cmdidx from > ushort to uint or disabling the peephole2 optimization. > > For the purpose of trying to get more feedback on the issue I included > both changes that would resolve my issue. > > Also if there is one struct affected, there could be other similar > structs affected by a similar issue. > > I do not really know if this could be a cpu errata, compiler bug or > something else, including some assembly from a non-working and working > case (peephole2 optimization enabled/disabled). > > Code generated with ushort and peephole2 enabled (not working): > > 60 06 80 52 movw0,#0x33 // 51 > f5 3f 06 91 addx21,sp,#0x18f > e0 23 01 79 strh w0,[sp, #cmd] > e0 03 00 b2 movx0,#0x10001 > b5 e6 7a 92 andx21,x21,#-0x40 > f5 03 06 a9 stpx21,x0,[sp, #data] > 00 01 80 52 movw0,#0x8 > e2 83 01 91 addx2,sp,#0x60 > e1 43 02 91 addx1,sp,#0x90 > 63 00 80 52 movw3,#0x3 > e0 73 00 b9 strw0,[sp, #blocksize] > e0 03 13 aa movx0,x19 > f6 ff 12 29 stpw22,wzr,[sp, #resp_type] > 50 fd ff 97 bl mmc_send_cmd_retry > > Code generated with ushort and peephole2 disabled (working): > > 60 06 80 52 movw0,#0x33 // 51 > e0 23 01 79 strh w0,[sp, #cmd] > e0 03 00 b2 movx0,#0x10001 > f5 3f 06 91 addx21,sp,#0x18f > e0 37 00 f9 strx0,[sp, #local_168] > 00 01 80 52 movw0,#0x8 > b5 e6 7a 92 andx21,x21,#-0x40 > e2 83 01 91 addx2,sp,#0x60 > e1 43 02 91 addx1,sp,#0x90 > 63 00 80 52 movw3,#0x3 > f5 33 00 f9 strx21,[sp, #data] > e0 73 00 b9 strw0,[sp, #blocksize] > e0 03 13 aa movx0,x19 > f6 97 00 b9 strw22,[sp, #resp_type] > ff 9b 00 b9 strwzr,[sp, #cmdarg] > 4a fd ff 97 bl mmc_send_cmd_retry > > Hoping someone can see something strange I cannot. I used to be able to see what compilers were doing, but sometime over the past 10 years they got a lot smarter and I didn't. I don't see anything wrong with the C code. The setting of cmd.resp_type to the same value could perhaps be fooling the compiler? Regards, Simon
Re: [PATCH 05/25] treewide: Correct use of long help
Hi Tom, On Sun, 24 Sept 2023 at 17:27, Tom Rini wrote: > > On Sun, Sep 24, 2023 at 02:39:23PM -0600, Simon Glass wrote: > > Some commands assume that CONFIG_SYS_LONGHELP is always defined. > > Declaration of long help should be bracketed by an #ifdef to avoid an > > 'unused variable' warning. > > > > Fix this treewide. > > > > Signed-off-by: Simon Glass > [snip] > > diff --git a/arch/arm/mach-imx/cmd_dek.c b/arch/arm/mach-imx/cmd_dek.c > > index 6fa5b41fcd38..25ea7d3b37da 100644 > > --- a/arch/arm/mach-imx/cmd_dek.c > > +++ b/arch/arm/mach-imx/cmd_dek.c > > @@ -393,11 +393,12 @@ static int do_dek_blob(struct cmd_tbl *cmdtp, int > > flag, int argc, > > return blob_encap_dek(src_addr, dst_addr, len); > > } > > > > -/***/ > > +#if IS_ENABLED(CONFIG_SYS_LONGHELP) > > static char dek_blob_help_text[] = > > "src dst len- Encapsulate and create blob of data\n" > > " $len bits long at address $src and\n" > > " store the result at address $dst.\n"; > > +#endif > > > > U_BOOT_CMD( > > dek_blob, 4, 1, do_dek_blob, > > This really doesn't read nicely. I would rather (globally and fix > existing users) __maybe_unused this instead. I think there's just one > example today that isn't "foo_help_text". Hmm, what do you think about adding a __longhelp symbol to cause the linker to discard it when not needed? Regards, Simon
Re: [PATCH v3 1/4] common: Add generic function for reading serial number
Hi Artur, On Wed, 4 Oct 2023 at 06:47, Artur Rojek wrote: > > >Hi Artur, > > > >On Mon, 2 Oct 2023 at 06:42, Artur Rojek wrote: > >> > >> Provide a generic way for boards to read their serial number from EEPROM > >> at init. > >> > >> If CONFIG_ID_EEPROM is set, the new serial_read_from_eeprom() function > >> will now be called during the post-relocation part of the board init. > >> > >> Provided is the tlv eeprom implementation of the above function, making > >> use of the existing, yet never utilized, populate_serial_number(). > >> Boards which use custom logic for interaction with their EEPROMs need to > >> supply their own implementation. > >> > >> Signed-off-by: Artur Rojek > >> --- > >> > >> v3: - restore original function name and make it static > >> - provide a generic function for reading EEPROM serial number and > >> wrap it around the existing tlv logic > >> - move the env var check out of populate_serial_number() and into > >> the new serial_read_from_eeprom() in order to stay consistent with > >> the documentation > >> > >> v2: - rename the function > >> - move function documentation from .c file to the prototype location > >> > >> cmd/tlv_eeprom.c | 25 + > >> common/board_r.c | 8 > >> include/init.h | 14 ++ > >> 3 files changed, 31 insertions(+), 16 deletions(-) > > > >Can you please use events for this? Something like EVT_SETTINGS_R ? > > > >See the one recently added for how to do this: > > > >INITCALL_EVENT(EVT_LAST_STAGE_INIT), > > I like this approach, but just to be clear with your intention - you > want me to move both serial_read_from_eeprom AND mac_read_from_eeprom > into a separate function, defined for each affected board? To do this > for mac_read_from_eeprom becomes slightly cumbersome, because there are > this many of them, depending on the current scheme: > > $ grep -r "ID_EEPROM" ./configs/ | wc -l > 55 > > If each of them needs to contain something like this: > > >static int settings_r(void) > >{ > >#if defined(CONFIG_ID_EEPROM) > > mac_read_from_eeprom(); > >#endif > > return 0; > >} > >EVENT_SPY_SIMPLE(EVT_SETTINGS_R, settings_r); > > then this strays very far from the original intention of this series, > which is to add support for a single board :) > Unless you only care about serial_read_from_eeprom, then I don't need to > modify any of the existing boards. As per irc, you don't need to adjust the mac_read_from_eeprom(). Just start your own thing (read_settings() or whatever) - i.e. don't make it any worse. People do appreciate cleanup, but sometimes it can be a big task Regards, Simon
Re: [PATCH] binman: bintool: Change make target arg type from string to list
On Wed, 4 Oct 2023 at 02:56, wrote: > > From: Lukas Funke > > The argument type of `build_from_git` was changed from string to list > in d71e7116997f14097735f04cc7847f0a68dbc485. > > This commit adapts the argument type of all bintools using this > function. > > Signed-off-by: Lukas Funke > > --- > > tools/binman/btool/bootgen.py | 2 +- > tools/binman/btool/fiptool.py | 2 +- > tools/binman/btool/futility.py | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) Reviewed-by: Simon Glass Tested-by: Simon Glass Thank you. Can you please resolve the test-coverage issue, too? It is the one line in the whole of binman with no coverage. If it is not needed, we can delete the line, perhaps? tools/binman/etype/xilinx_bootgen.py 72 199% The offending line is 216: data = tools.read_file(bootbin_fname) Regards, Simon
Re: [PATCH v12] Boot var automatic management for removable medias
Hi Tom, Heinrich, Ilias, # Added Tom since this patch is delegated to him On Wed, 27 Sept 2023 at 10:06, Masahisa Kojima wrote: > > From: Raymond Mao > > Changes for complying to EFI spec §3.5.1.1 > 'Removable Media Boot Behavior'. > Boot variables can be automatically generated during a removable > media is probed. At the same time, unused boot variables will be > detected and removed. > > Please note that currently the function 'efi_disk_remove' has no > ability to distinguish below two scenarios > a) Unplugging of a removable media under U-Boot > b) U-Boot exiting and booting an OS > Thus currently the boot variables management is not added into > 'efi_disk_remove' to avoid boot options being added/erased > repeatedly under scenario b) during power cycles > See TODO comments under function 'efi_disk_remove' for more details > > The original efi_secboot tests expect that BootOrder EFI variable > is not defined. With this commit, the BootOrder EFI variable is > automatically added when the disk is detected. The original efi_secboot > tests end up with unexpected failure. > The efi_secboot tests need to be modified to clear the BootOrder > EFI variable at the beginning of each test. > > Co-developed-by: Masahisa Kojima > Signed-off-by: Masahisa Kojima > Signed-off-by: Raymond Mao > Reviewed-by: Heinrich Schuchardt > Reviewed-by: Ilias Apalodimas > --- > lib/efi_loader/efi_disk.c | 18 ++ > lib/efi_loader/efi_setup.c | 7 +++ > test/py/tests/test_efi_secboot/test_signed.py | 9 + > .../test_efi_secboot/test_signed_intca.py | 3 +++ > .../py/tests/test_efi_secboot/test_unsigned.py | 3 +++ > 5 files changed, 40 insertions(+) > > diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c > index f0d76113b0..b808a7fe62 100644 > --- a/lib/efi_loader/efi_disk.c > +++ b/lib/efi_loader/efi_disk.c > @@ -690,6 +690,13 @@ int efi_disk_probe(void *ctx, struct event *event) > return -1; > } > > + /* only do the boot option management when UEFI sub-system is > initialized */ > + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR) && > efi_obj_list_initialized == EFI_SUCCESS) { > + ret = efi_bootmgr_update_media_device_boot_option(); > + if (ret != EFI_SUCCESS) > + return -1; > + } > + > return 0; > } > > @@ -742,6 +749,17 @@ int efi_disk_remove(void *ctx, struct event *event) > dev_tag_del(dev, DM_TAG_EFI); > > return 0; > + > + /* > +* TODO A flag to distinguish below 2 different scenarios of this > +* function call is needed: > +* a) Unplugging of a removable media under U-Boot > +* b) U-Boot exiting and booting an OS > +* In case of scenario a), > efi_bootmgr_update_media_device_boot_option() > +* needs to be invoked here to update the boot options and remove the > +* unnecessary ones. > +*/ > + > } > > /** > diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c > index 58d4e13402..69c8b27730 100644 > --- a/lib/efi_loader/efi_setup.c > +++ b/lib/efi_loader/efi_setup.c > @@ -245,6 +245,13 @@ efi_status_t efi_init_obj_list(void) > if (ret != EFI_SUCCESS) > goto out; > > + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) { > + /* update boot option after variable service initialized */ > + ret = efi_bootmgr_update_media_device_boot_option(); > + if (ret != EFI_SUCCESS) > + goto out; > + } > + > /* Define supported languages */ > ret = efi_init_platform_lang(); > if (ret != EFI_SUCCESS) > diff --git a/test/py/tests/test_efi_secboot/test_signed.py > b/test/py/tests/test_efi_secboot/test_signed.py > index ca52e853d8..b77b60e223 100644 > --- a/test/py/tests/test_efi_secboot/test_signed.py > +++ b/test/py/tests/test_efi_secboot/test_signed.py > @@ -28,6 +28,7 @@ class TestEfiSignedImage(object): > # Test Case 1a, run signed image if no PK > output = u_boot_console.run_command_list([ > 'host bind 0 %s' % disk_img, > +'setenv -e -nv -bs -rt BootOrder', This patch itself is trying to automatically add the EFI boot option(BOOT) and update the BootOrder variable. I now understand that clearing the BootOrder variable is not an appropriate fix in this efi_secboot test, 'setenv -e -nv -bs -rt BootOrder' fails when the BootOrder variable is not found. When booting the system with BootNext fails, efibootmgr falls back to BootOrder. Instead of loading an image with BootNext, efi_secboot tests need to explicitly set the BootOrder variable. I will revise this patch, and let me include this patch in EFI HTTP Boot series[1]. As discussed with Ilias, EFI HTTP Boot series[1] will rely heavily on this patch. [1] https://lore.kernel.org/u-boot/20230927093631.1595
Re: [PATCH 1/1] riscv: remove dram_init_banksize()
On 9/26/23 09:46, Wu, Fei wrote: On 9/26/2023 3:16 PM, Heinrich Schuchardt wrote: Remove dram_init_banksize() on the architecture level. Limiting used RAM to under 4 GiB is only necessary for CPUs which have a DMA issue. SoC specific code already exists for FU540, FU740, JH7110. Not all RISC-V boards will have memory below 4 GiB. A weak implementation of dram_init_banksize() exists in common/board_f.c. See the discussion in https://lore.kernel.org/u-boot/545fe813-cb1e-469c-a131-0025c77ae...@canonical.com/T/ Thanks you Heinrich, this patch itself is okay to me, but it still doesn't address the problem in that thread. In setup_dest_addr(): #ifdef CFG_SYS_SDRAM_BASE gd->ram_base = CFG_SYS_SDRAM_BASE; #endif gd->ram_top = gd->ram_base + get_effective_memsize(); gd->ram_top = board_get_usable_ram_top(gd->mon_len); ram_base is modified in #ifdef so that ram_base and get_effective_memsize() is not well paired. e.g. two ranges of memory [2GB, 3GB) and [4GB, 6GB), ram_base is set to 2GB of 1st range and get_effective_memsize() returns 2GB of 2nd range, ram_top will be set to 4GB which is not desired. Will you address this too? No, that is an independent issue. I only want to get rid of the generic restriction to memory below 4 GiB on RISC-V. I would recommend to set ram_top to the highest available memory address of the highest RAM bank with some special handling of the ARM LPAE case or 32bit in general. But this is not a RISC-V specific topic. Best regards Heinrich Best Regards, Fei. Signed-off-by: Heinrich Schuchardt --- arch/riscv/cpu/generic/dram.c | 16 1 file changed, 16 deletions(-) diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c index 94d8018407..1b51bae9b6 100644 --- a/arch/riscv/cpu/generic/dram.c +++ b/arch/riscv/cpu/generic/dram.c @@ -20,19 +20,3 @@ int dram_init_banksize(void) { return fdtdec_setup_memory_banksize(); } - -phys_addr_t board_get_usable_ram_top(phys_size_t total_size) -{ - /* -* Ensure that we run from first 4GB so that all -* addresses used by U-Boot are 32bit addresses. -* -* This in-turn ensures that 32bit DMA capable -* devices work fine because DMA mapping APIs will -* provide 32bit DMA addresses only. -*/ - if (gd->ram_top >= SZ_4G) - return SZ_4G - 1; - - return gd->ram_top; -}
Re: [PATCH 1/1] [u-boot][master][PATCH v3] pico-imx7d: add baseboard SD card boot detect
On Wed, Oct 4, 2023 at 8:35 PM wrote: > > From: Benjamin Szőke > > Take over codes from Techenxion to support mmc autodetect boot for pico-imx7d. > > Signed-off-by: Benjamin Szőke I wanted to test your patch, but there are several issues: checkpatch complains: total: 5 errors, 7 warnings, 5 checks, 214 lines checked git am complains: Applying: pico-imx7d: add baseboard SD card boot detect .git/rebase-apply/patch:41: trailing whitespace. .git/rebase-apply/patch:58: trailing whitespace. .git/rebase-apply/patch:61: trailing whitespace. warning: 3 lines add whitespace errors. Then when I try to build: board/technexion/pico-imx7d/pico-imx7d.c: In function ‘board_late_mmc_init’: board/technexion/pico-imx7d/pico-imx7d.c:173:9: warning: implicit declaration of function ‘run_command’ [-Wimplicit-function-declaration] 173 | run_command(cmd, 0); | ^~~ board/technexion/pico-imx7d/pico-imx7d.c:150:14: warning: unused variable ‘mmcblk’ [-Wunused-variable] 150 | char mmcblk[32]; | ^~ board/technexion/pico-imx7d/spl.c: In function ‘board_mmc_init’: board/technexion/pico-imx7d/spl.c:261:33: error: ‘CONFIG_SYS_FSL_USDHC_NUM’ undeclared (first use in this function); did you mean ‘CFG_SYS_FSL_USDHC_NUM’? 261 | for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) { | ^~~~ | CFG_SYS_FSL_USDHC_NUM board/technexion/pico-imx7d/spl.c:261:33: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [scripts/Makefile.build:256: spl/board/technexion/pico-imx7d/spl.o] Error 1 make[1]: *** [scripts/Makefile.spl:533: spl/board/technexion/pico-imx7d] Error 2 You clearly haven't tested your patch.
Re: [RFC PATCH v10 12/24] cli: Enables using hush 2021 parser as command line parser
On 10/4/23 18:42, Francis Laniel wrote: If one defines HUSH_2021_PARSER, it is then possible to use 2021 parser with: => cli get old => cli set 2021 => cli get 2021 Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- cmd/Kconfig | 8 + cmd/cli.c | 7 - common/Makefile | 1 + common/cli.c | 38 +++ common/cli_hush_2021.c| 3 ++ common/cli_hush_upstream.c| 46 +--- doc/usage/cmd/cli.rst | 17 ++- include/asm-generic/global_data.h | 4 +++ include/cli_hush.h| 51 +-- 9 files changed, 160 insertions(+), 15 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 5fb4cef54c..36595638a2 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -34,6 +34,14 @@ menu "Hush flavor to use" 2005. It is actually the default U-Boot shell when decided to use hush as shell. + + config HUSH_2021_PARSER + bool "Use hush 2021 parser" + help + This option enables the new flavor of hush based on hush Busybox from + 2021. + + For the moment, it is highly experimental and should be used at own risks. Every usage of GPL code is at own risk. That is in the license. "This parser is experimental and not well tested." Best regards Heinrich endmenu config CMDLINE_EDITING diff --git a/cmd/cli.c b/cmd/cli.c index 7671785b83..d2b64da613 100644 --- a/cmd/cli.c +++ b/cmd/cli.c @@ -12,6 +12,8 @@ static const char *gd_flags_to_parser(void) { if (gd->flags & GD_FLG_HUSH_OLD_PARSER) return "old"; + if (gd->flags & GD_FLG_HUSH_2021_PARSER) + return "2021"; return NULL; } @@ -34,12 +36,15 @@ static int parser_string_to_gd_flags(const char *parser) { if (!strcmp(parser, "old")) return GD_FLG_HUSH_OLD_PARSER; + if (!strcmp(parser, "2021")) + return GD_FLG_HUSH_2021_PARSER; return -1; } static void reset_parser_gd_flags(void) { gd->flags &= ~GD_FLG_HUSH_OLD_PARSER; + gd->flags &= ~GD_FLG_HUSH_2021_PARSER; } static int do_cli_set(struct cmd_tbl *cmdtp, int flag, int argc, @@ -108,7 +113,7 @@ static int do_cli(struct cmd_tbl *cmdtp, int flag, int argc, #if CONFIG_IS_ENABLED(SYS_LONGHELP) static char cli_help_text[] = "get - print current cli\n" - "set - set the current cli, possible value is: old" + "set - set the current cli, possible value are: old, 2021" ; #endif diff --git a/common/Makefile b/common/Makefile index 615eba8672..4b060bb565 100644 --- a/common/Makefile +++ b/common/Makefile @@ -9,6 +9,7 @@ obj-y += init/ obj-y += main.o obj-y += exports.o obj-$(CONFIG_HUSH_OLD_PARSER) += cli_hush.o +obj-$(CONFIG_HUSH_2021_PARSER) += cli_hush_2021.o obj-$(CONFIG_AUTOBOOT) += autoboot.o # # boards diff --git a/common/cli.c b/common/cli.c index d419671e8c..e3e2bc7fe1 100644 --- a/common/cli.c +++ b/common/cli.c @@ -43,12 +43,15 @@ int run_command(const char *cmd, int flag) return 1; return 0; -#else +#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER) int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP; if (flag & CMD_FLAG_ENV) hush_flags |= FLAG_CONT_ON_NEWLINE; return parse_string_outer(cmd, hush_flags); +#else /* HUSH_2021_PARSER */ + /* Not yet implemented. */ + return 1; #endif } @@ -108,7 +111,12 @@ int run_command_list(const char *cmd, int len, int flag) buff[len] = '\0'; } #ifdef CONFIG_HUSH_PARSER +#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON); +#else /* HUSH_2021_PARSER */ + /* Not yet implemented. */ + rcode = 1; +#endif #else /* * This function will overwrite any \n it sees with a \0, which @@ -254,8 +262,13 @@ err: void cli_loop(void) { bootstage_mark(BOOTSTAGE_ID_ENTER_CLI_LOOP); -#ifdef CONFIG_HUSH_PARSER - parse_file_outer(); +#if CONFIG_IS_ENABLED(HUSH_PARSER) + if (gd->flags & GD_FLG_HUSH_2021_PARSER) + parse_and_run_file(); + else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) + parse_file_outer(); + + printf("Problem\n"); /* This point is never reached */ for (;;); #elif defined(CONFIG_CMDLINE) @@ -268,10 +281,23 @@ void cli_loop(void) void cli_init(void) { #ifdef CONFIG_HUSH_PARSER + /* This if block is used to initialize hush parser gd flag. */ if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER) - && CONFIG_IS_ENABLED(HUSH_OLD_PARSER)) - gd->flags |= GD_FLG_HUSH_OLD_PARSER; - u_boot_hush_start(); + && !(gd->flags & GD_FLG_HUSH_2021_PARSER)) { + if (CONF
Re: [RFC PATCH v10 11/24] cmd: Add new cli command
On 10/4/23 18:42, Francis Laniel wrote: This command can be used to print the current parser with 'cli print'. Please, provide a commit message that matches the code. It can also be used to set the current parser with 'cli set'. For the moment, only one value is valid for set: old. If there is only one valid value, we should not provide the 'cli' command to save code size. The patch seems to be in the wrong spot in the series. Signed-off-by: Francis Laniel --- cmd/Makefile | 2 + cmd/cli.c | 120 ++ common/cli.c | 3 +- doc/usage/cmd/cli.rst | 59 + doc/usage/index.rst | 1 + 5 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 cmd/cli.c create mode 100644 doc/usage/cmd/cli.rst diff --git a/cmd/Makefile b/cmd/Makefile index 9bebf321c3..d468cc5065 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -226,6 +226,8 @@ obj-$(CONFIG_CMD_AVB) += avb.o # Foundries.IO SCP03 obj-$(CONFIG_CMD_SCP03) += scp03.o +obj-$(CONFIG_HUSH_PARSER) += cli.o Don't waste binary code size. We only need the command if at least two parsers are available. ifeq ($(CONFIG_HUSH_OLD_PARSER)$(HUSH_2021_PARSER),yy) obj-y += cli.o endif The symbol CONFIG_HUSH_PARSER should be eliminated. + obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_RISCV) += riscv/ obj-$(CONFIG_SANDBOX) += sandbox/ diff --git a/cmd/cli.c b/cmd/cli.c new file mode 100644 index 00..7671785b83 --- /dev/null +++ b/cmd/cli.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static const char *gd_flags_to_parser(void) +{ + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) + return "old"; + return NULL; +} + +static int do_cli_get(struct cmd_tbl *cmdtp, int flag, int argc, +char *const argv[]) +{ + const char *current = gd_flags_to_parser(); + + if (!current) { + printf("current cli value is not valid, this should not happen!\n"); + return CMD_RET_FAILURE; + } + + printf("%s\n", current); + + return CMD_RET_SUCCESS; +} + Please, describe this function (and all the others) in Sphinx style. /** * parser_string_to_gd_flags() - converts parser name to bit mask * * @parser: parser name * Return: valid bit mask or -1 */ +static int parser_string_to_gd_flags(const char *parser) +{ + if (!strcmp(parser, "old")) + return GD_FLG_HUSH_OLD_PARSER; Please, do not return an invalid bit mask. if (CONFIG_IS_ENABLED(HUSH_OLD_PARSER) && !strcmp(parser, "old")) return GD_FLG_HUSH_OLD_PARSER; if (CONFIG_IS_ENABLED(HUSH_2021_PARSER) && !strcmp(parser, "2021")) return GD_FLG_HUSH_201_PARSER; + return -1; +} + +static void reset_parser_gd_flags(void) +{ + gd->flags &= ~GD_FLG_HUSH_OLD_PARSER; gd->flags &= ~(GD_FLG_HUSH_OLD_PARSER | GD_FLG_HUSH_2021_PARSER); If there were only one parser, we wouldn't create this command. +} + +static int do_cli_set(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + char *parser_name; + int parser_flag; + + if (argc < 2) + return CMD_RET_USAGE; + + parser_name = argv[1]; + + parser_flag = parser_string_to_gd_flags(parser_name); This function should return -1 for for any value that is not supported be it 'foo', 'old', or '2021'. Then you can eliminate a bunch of error checking code below. + if (parser_flag == -1) { + printf("Bad value for parser name: %s\n", parser_name); + return CMD_RET_USAGE; + } + + if (parser_flag == GD_FLG_HUSH_OLD_PARSER && + !CONFIG_IS_ENABLED(HUSH_OLD_PARSER)) { + printf("Want to set current parser to old, but its code was not compiled!\n"); + return CMD_RET_FAILURE; + } Superfluous check, see above. + + if (parser_flag == GD_FLG_HUSH_2021_PARSER && + !CONFIG_IS_ENABLED(HUSH_2021_PARSER)) { + printf("Want to set current parser to 2021, but its code was not compiled!\n"); + return CMD_RET_FAILURE; + } Superfluous check, see above. + + reset_parser_gd_flags(); + gd->flags |= parser_flag; + + cli_init(); + cli_loop(); + + /* cli_loop() should never return. */ + return CMD_RET_FAILURE; Consuming stack space for every invocation of the 'cli set' command cannot be intended. Why don't we define cli_loop as __noreturn and ensure that it has no return statement? Then gcc can generate a simple jump without consuming stack. cli_loop should() invoke panic() instead of returning. +} + +static struct cmd_tbl parser_sub[] = { + U_BOOT_CMD_MKENT(get, 1, 1, do_cli_get, "", ""), + U_BOOT_CMD_MKENT(set, 2, 1, do_cli_set, "", ""), +}; + +static int do_cli(s
Re: [PATCH] toradex: verdin-imx8mm/imx8mp: Remove bootcmd_mfg
On Wed, 2023-10-04 at 16:13 -0300, Francesco Dolcini wrote: > From: Joao Paulo Goncalves > > The bootcmd_mfg env variable is legacy from IMX downstream u-boot branch > and is not needed on mainline. > > Signed-off-by: Joao Paulo Goncalves > Signed-off-by: Francesco Dolcini Acked-by: Marcel Ziswiler > --- > include/configs/verdin-imx8mm.h | 1 - > include/configs/verdin-imx8mp.h | 1 - > 2 files changed, 2 deletions(-) > > diff --git a/include/configs/verdin-imx8mm.h b/include/configs/verdin-imx8mm.h > index 8cb1f1aff353..8072d5d503f2 100644 > --- a/include/configs/verdin-imx8mm.h > +++ b/include/configs/verdin-imx8mm.h > @@ -37,7 +37,6 @@ > #define CFG_EXTRA_ENV_SETTINGS \ > BOOTENV \ > MEM_LAYOUT_ENV_SETTINGS \ > - "bootcmd_mfg=fastboot 0\0" \ > "boot_file=Image\0" \ > "boot_script_dhcp=boot.scr\0" \ > "console=ttymxc0\0" \ > diff --git a/include/configs/verdin-imx8mp.h b/include/configs/verdin-imx8mp.h > index 942081ab84d7..5a34f6a9b205 100644 > --- a/include/configs/verdin-imx8mp.h > +++ b/include/configs/verdin-imx8mp.h > @@ -46,7 +46,6 @@ > #define CFG_EXTRA_ENV_SETTINGS \ > BOOTENV \ > MEM_LAYOUT_ENV_SETTINGS \ > - "bootcmd_mfg=fastboot 0\0" \ > "boot_file=Image\0" \ > "boot_scripts=" BOOT_SCRIPT "\0" \ > "boot_script_dhcp=" BOOT_SCRIPT "\0" \
Re: [PATCHv10 14/15] net/lwip: replace original net commands with lwip
Am 4. Oktober 2023 10:29:54 MESZ schrieb Maxim Uvarov : >On Wed, 4 Oct 2023 at 08:12, Simon Glass wrote: > >> Hi Sean, >> >> On Tue, 3 Oct 2023 at 11:58, Sean Edmond >> wrote: >> > >> > >> > On 2023-09-26 2:41 a.m., Maxim Uvarov wrote: >> > > Replace original commands: ping, tftp, dhcp and wget. >> > > >> > > Signed-off-by: Maxim Uvarov >> > > --- >> > > boot/bootmeth_efi.c | 18 +++--- >> > > boot/bootmeth_pxe.c | 21 ++- >> > > cmd/net.c | 86 >> + >> > > cmd/pxe.c | 19 +- >> > > include/net.h | 8 +++-- >> > > include/net/ulwip.h | 64 + >> > > 6 files changed, 113 insertions(+), 103 deletions(-) >> > > create mode 100644 include/net/ulwip.h >> > > >> > > diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c >> > > index ae936c8daa..52399d627c 100644 >> > > --- a/boot/bootmeth_efi.c >> > > +++ b/boot/bootmeth_efi.c >> > > @@ -20,6 +20,8 @@ >> > > #include >> > > #include >> > > #include >> > > +#include >> > > +#include >> > > #include >> > > #include >> > > >> > > @@ -319,9 +321,7 @@ static int distro_efi_try_bootflow_files(struct >> udevice *dev, >> > > >> > > static int distro_efi_read_bootflow_net(struct bootflow *bflow) >> > > { >> > > - char file_addr[17], fname[256]; >> > > - char *tftp_argv[] = {"tftp", file_addr, fname, NULL}; >> > > - struct cmd_tbl cmdtp = {}; /* dummy */ >> > > + char fname[256]; >> > > const char *addr_str, *fdt_addr_str; >> > > int ret, arch, size; >> > > ulong addr, fdt_addr; >> > > @@ -368,7 +368,6 @@ static int distro_efi_read_bootflow_net(struct >> bootflow *bflow) >> > > if (!fdt_addr_str) >> > > return log_msg_ret("fdt", -EINVAL); >> > > fdt_addr = hextoul(fdt_addr_str, NULL); >> > > - sprintf(file_addr, "%lx", fdt_addr); >> > > >> > > /* We only allow the first prefix with PXE */ >> > > ret = distro_efi_get_fdt_name(fname, sizeof(fname), 0); >> > > @@ -379,7 +378,16 @@ static int distro_efi_read_bootflow_net(struct >> bootflow *bflow) >> > > if (!bflow->fdt_fname) >> > > return log_msg_ret("fil", -ENOMEM); >> > > >> > > - if (!do_tftpb(&cmdtp, 0, 3, tftp_argv)) { >> > > + ret = ulwip_init(); >> > > + if (ret) >> > > + return log_msg_ret("ulwip_init", ret); >> > > + >> > > + ret = ulwip_tftp(fdt_addr, fname); >> > > + if (ret) >> > > + return log_msg_ret("ulwip_tftp", ret); >> > > + >> > > + ret = ulwip_loop(); >> > > + if (!ret) { >> > > bflow->fdt_size = env_get_hex("filesize", 0); >> > > bflow->fdt_addr = fdt_addr; >> > > } else { >> > > diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c >> > > index 8d489a11aa..fc6aabaa18 100644 >> > > --- a/boot/bootmeth_pxe.c >> > > +++ b/boot/bootmeth_pxe.c >> > > @@ -21,6 +21,8 @@ >> > > #include >> > > #include >> > > #include >> > > +#include >> > > +#include >> > > #include >> > > >> > > static int extlinux_pxe_getfile(struct pxe_context *ctx, const char >> *file_path, >> > > @@ -116,18 +118,21 @@ static int extlinux_pxe_read_file(struct udevice >> *dev, struct bootflow *bflow, >> > > const char *file_path, ulong addr, >> > > ulong *sizep) >> > > { >> > > - char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; >> > > - struct pxe_context *ctx = dev_get_priv(dev); >> > > - char file_addr[17]; >> > > ulong size; >> > > int ret; >> > > >> > > - sprintf(file_addr, "%lx", addr); >> > > - tftp_argv[1] = file_addr; >> > > - tftp_argv[2] = (void *)file_path; >> > > + ret = ulwip_init(); >> > > + if (ret) >> > > + return log_msg_ret("ulwip_init", ret); >> > > + >> > > + ret = ulwip_tftp(addr, file_path); >> > > + if (ret) >> > > + return log_msg_ret("ulwip_tftp", ret); >> > > + >> > > + ret = ulwip_loop(); >> > > + if (ret) >> > > + return log_msg_ret("ulwip_loop", ret); >> > > >> > > - if (do_tftpb(ctx->cmdtp, 0, 3, tftp_argv)) >> > > - return -ENOENT; >> > > ret = pxe_get_file_size(&size); >> > > if (ret) >> > > return log_msg_ret("tftp", ret); >> > > diff --git a/cmd/net.c b/cmd/net.c >> > > index d407d8320a..dc5a114309 100644 >> > > --- a/cmd/net.c >> > > +++ b/cmd/net.c >> > > @@ -22,6 +22,7 @@ >> > > #include >> > > #include >> > > #include >> > > +#include >> > > >> > > static int netboot_common(enum proto_t, struct cmd_tbl *, int, char >> * const []); >> > > >> > > @@ -40,19 +41,9 @@ U_BOOT_CMD( >> > > #endif >> > > >> > > #ifdef CONFIG_CMD_TFTPBOOT >> > > -int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const >> argv[]) >> > > -{ >> > > - int ret; >> > > - >> > > - bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start"); >>
Re: [PATCH 09/16] pinctrl: renesas: Add RZ/G2L PFC driver
On Wed, Oct 04, 2023 at 02:24:38PM +0200, Marek Vasut wrote: > On 10/4/23 10:40, Paul Barker wrote: > > On 03/10/2023 14:20, Marek Vasut wrote: > > > On 9/20/23 14:42, Paul Barker wrote: > > > > This driver provides pinctrl and gpio control for the Renesas RZ/G2L > > > > (R9A07G044) SoC. > > > > > > > > This patch is based on the corresponding Linux v6.5 driver. > > > > > > > > Signed-off-by: Paul Barker > > > > Reviewed-by: Biju Das > > > > Reviewed-by: Lad Prabhakar > > > > --- > > > >arch/arm/mach-rmobile/Kconfig | 1 + > > > >drivers/pinctrl/renesas/Kconfig | 9 + > > > >drivers/pinctrl/renesas/Makefile| 1 + > > > >drivers/pinctrl/renesas/rzg2l-pfc.c | 906 > > > > > > > >4 files changed, 917 insertions(+) > > > >create mode 100644 drivers/pinctrl/renesas/rzg2l-pfc.c > > > > > > > > diff --git a/arch/arm/mach-rmobile/Kconfig > > > > b/arch/arm/mach-rmobile/Kconfig > > > > index 91f544c78337..973e84fcf7ba 100644 > > > > --- a/arch/arm/mach-rmobile/Kconfig > > > > +++ b/arch/arm/mach-rmobile/Kconfig > > > > @@ -76,6 +76,7 @@ config RZG2L > > > > imply SYS_MALLOC_F > > > > imply RENESAS_SDHI > > > > imply CLK_RZG2L > > > > + imply PINCTRL_RZG2L > > > > > > Keep the list sorted > > > > > > [...] > > > > > > Drop the parenthesis around values please, fix globally and in other > > > patches too. > > > > > > > +#define PWPR (0x3014) > > > > +#define SD_CH(n) (0x3000 + (n) * 4) > > > > +#define QSPI (0x3008) > > > > + > > > > +#define PVDD_1800 1 /* I/O domain voltage <= 1.8V */ > > > > +#define PVDD_3300 0 /* I/O domain voltage >= 3.3V */ > > > > + > > > > +#define PWPR_B0WI BIT(7) /* Bit Write Disable */ > > > > +#define PWPR_PFCWE BIT(6) /* PFC Register Write Enable */ > > > > + > > > > +#define PM_MASK0x03 > > > > +#define PVDD_MASK 0x01 > > > > +#define PFC_MASK 0x07 > > > > +#define IEN_MASK 0x01 > > > > +#define IOLH_MASK 0x03 > > > > + > > > > +#define PM_HIGH_Z 0x0 > > > > +#define PM_INPUT 0x1 > > > > +#define PM_OUTPUT 0x2 > > > > +#define PM_OUTPUT_IEN 0x3 > > > > + > > > > +struct rzg2l_pfc_driver_data { > > > > + uint num_dedicated_pins; > > > > + uint num_ports; > > > > + const u32 *gpio_configs; > > > > +}; > > > > + > > > > +struct rzg2l_pfc_data { > > > > + void __iomem *base; > > > > + uint num_dedicated_pins; > > > > + uint num_ports; > > > > + uint num_pins; > > > > + const u32 *gpio_configs; > > > > + bool pfc_enabled; > > > > +}; > > > > + > > > > +struct rzg2l_dedicated_configs { > > > > + const char *name; > > > > + u32 config; > > > > +}; > > > > + > > > > +/* > > > > + * We need to ensure that the module clock is enabled and all resets > > > > are > > > > + * de-asserted before using either the gpio or pinctrl functionality. > > > > Error > > > > + * handling can be quite simple here as if the PFC cannot be enabled > > > > then we > > > > + * will not be able to progress with the boot anyway. > > > > + */ > > > > +static int rzg2l_pfc_enable(struct udevice *dev) > > > > +{ > > > > + struct rzg2l_pfc_data *data = > > > > + (struct rzg2l_pfc_data *)dev_get_driver_data(dev); > > > > + struct reset_ctl_bulk rsts; > > > > + struct clk clk; > > > > + int ret; > > > > + > > > > + if (data->pfc_enabled) > > > > > > When does this get triggered ? > > > > This is initialised to false in rzg2l_pfc_bind(), then this function > > rzg2l_pfc_enable() sets it to true before a successful return. The > > effect is that the PFC is enabled just once, regardless of whether the > > pinctrl or gpio driver is probed first. > > Why would be call to rzg2l_pfc_enable() a problem in the first place ? > It just grabs and enables clock and ungates reset, the second time this is > called the impact on harware should be no-op , right ? The hw impact is a no-op, but it wastes time unnecessarily re-reading data from the fdt and repeating the setup, e.g. in rzg2l_cpg_clk_set() we have to search the array of clocks each time to find the requested entry. I think it's worth keeping the conditional here but can drop it if you're really against it. Thanks, Paul signature.asc Description: PGP signature
Re: [PATCH 12/16] arm: rmobile: Include in header
On 10/4/23 18:41, Paul Barker wrote: On Wed, Oct 04, 2023 at 05:19:43PM +0200, Marek Vasut wrote: On 10/4/23 15:48, Paul Barker wrote: On Wed, Oct 04, 2023 at 02:27:50PM +0200, Marek Vasut wrote: On 10/4/23 10:57, Paul Barker wrote: On 03/10/2023 14:27, Marek Vasut wrote: On 9/20/23 14:42, Paul Barker wrote: We don't want to rely on source files including before . What kind of error does this solve ? Without this, must be included before , for example in include/configs/rzg2l-smarc.h added in patch 16, to avoid the following error: CC arch/arm/lib/asm-offsets.s In file included from include/configs/rzg2l-smarc.h:9, from include/config.h:3, from include/common.h:16, from lib/asm-offsets.c:14: ./arch/arm/include/asm/arch/rmobile.h:49:7: error: unknown type name ‘u8’ 49 | const u8 *rzg_get_cpu_name(void); Hmmm, that's weird, why am I not hitting it with the rcar CPU name function too ? arch/arm/mach-rmobile/include/mach/rcar-gen3-base.h includes as it uses the `u32` type. However, arch/arm/mach-rmobile/include/mach/rzg2l.h doesn't use anything from so doesn't include it. Shouldn't arch/arm/mach-rmobile/include/mach/rmobile.h include the types.h then ? That's what this patch adds. Then this patch is Reviewed-by: Marek Vasut Sorry for the noise.
Re: [PATCH 10/16] serial: sh: Add RZ/G2L SCIF support
On 10/4/23 18:38, Paul Barker wrote: On Wed, Oct 04, 2023 at 05:17:55PM +0200, Marek Vasut wrote: On 10/4/23 15:43, Paul Barker wrote: On Wed, Oct 04, 2023 at 02:26:49PM +0200, Marek Vasut wrote: On 10/4/23 10:48, Paul Barker wrote: On 03/10/2023 14:23, Marek Vasut wrote: On 9/20/23 14:42, Paul Barker wrote: Extend the existing driver to support the SCIF serial ports on the Renesas RZ/G2L (R9A07G044) SoC. This also requires us to ensure that the relevant reset signal is de-asserted before we try to talk to the SCIF module. Signed-off-by: Paul Barker Reviewed-by: Biju Das Reviewed-by: Lad Prabhakar --- arch/arm/mach-rmobile/Kconfig | 1 + drivers/serial/serial_sh.c| 32 ++-- drivers/serial/serial_sh.h| 19 ++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig index 973e84fcf7ba..0ab22356aee5 100644 --- a/arch/arm/mach-rmobile/Kconfig +++ b/arch/arm/mach-rmobile/Kconfig @@ -77,6 +77,7 @@ config RZG2L imply RENESAS_SDHI imply CLK_RZG2L imply PINCTRL_RZG2L + imply SCIF_CONSOLE help Enable support for the Renesas RZ/G2L family of SoCs, including the the RZ/G2L itself (based on the R9A07G044 SoC). diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c index 5e543dbf3d58..a2e9a57137a6 100644 --- a/drivers/serial/serial_sh.c +++ b/drivers/serial/serial_sh.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include "serial_sh.h" DECLARE_GLOBAL_DATA_PTR; @@ -79,8 +81,16 @@ sh_serial_setbrg_generic(struct uart_port *port, int clk, int baudrate) static void handle_error(struct uart_port *port) { - sci_in(port, SCxSR); - sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); + /* The RZ/G2L datasheet says that error conditions are cleared by +* resetting the error bits in the FSR register to zero. Can you be more specific here ? It doesn't seem Linux sh-sci.c driver does anything special for G2L, so is this special case really needed ? On page 1268 of the datasheet (R01UH0914EJ0130 Rev.1.30): "DR is cleared to 0 when DR = 1 is read and then 0 is written to the DR flag." On page 1270: "[Clearing condition] ● When 0 is written to ER after it has been read as 1" So zeros must be written to clear these errors, not ones. We have an open task to investigate the issue in the Linux driver and fix it. Is the G2L UART broken in Linux ? Likely yes, but we need to reproduce the issue. Does it misbehave in U-Boot ? Yes, before I changed this, if a framing error occurred it could never be cleared and the serial port stopped sending/receiving data. The framing error was triggered by accident by unnecessarily re-doing pinmuxing for the serial port after TrustedFirmware had already set it up correctly. Since SCIF0 is wired to an FTDI USB/serial adaptor chip on the SMARC carrier board, it seems very difficult to trigger a framing error in any other way, the FTDI chip is too well behaved. Is it possible to trigger this on RZ/G2 with SCIF on those platforms as well ? It's not been seen or reported to my knowledge, but it's on our list to look into further. Can you give it a quick try ? I'd really like to avoid G2L specific behavior here if it can be avoided. Is there a testcase ?
[PATCH] toradex: verdin-imx8mm/imx8mp: Remove bootcmd_mfg
From: Joao Paulo Goncalves The bootcmd_mfg env variable is legacy from IMX downstream u-boot branch and is not needed on mainline. Signed-off-by: Joao Paulo Goncalves Signed-off-by: Francesco Dolcini --- include/configs/verdin-imx8mm.h | 1 - include/configs/verdin-imx8mp.h | 1 - 2 files changed, 2 deletions(-) diff --git a/include/configs/verdin-imx8mm.h b/include/configs/verdin-imx8mm.h index 8cb1f1aff353..8072d5d503f2 100644 --- a/include/configs/verdin-imx8mm.h +++ b/include/configs/verdin-imx8mm.h @@ -37,7 +37,6 @@ #define CFG_EXTRA_ENV_SETTINGS \ BOOTENV \ MEM_LAYOUT_ENV_SETTINGS \ - "bootcmd_mfg=fastboot 0\0" \ "boot_file=Image\0" \ "boot_script_dhcp=boot.scr\0" \ "console=ttymxc0\0" \ diff --git a/include/configs/verdin-imx8mp.h b/include/configs/verdin-imx8mp.h index 942081ab84d7..5a34f6a9b205 100644 --- a/include/configs/verdin-imx8mp.h +++ b/include/configs/verdin-imx8mp.h @@ -46,7 +46,6 @@ #define CFG_EXTRA_ENV_SETTINGS \ BOOTENV \ MEM_LAYOUT_ENV_SETTINGS \ - "bootcmd_mfg=fastboot 0\0" \ "boot_file=Image\0" \ "boot_scripts=" BOOT_SCRIPT "\0" \ "boot_script_dhcp=" BOOT_SCRIPT "\0" \ -- 2.25.1
[PATCH v6] board: rockchip: Add Bananapi R2Pro Board
From: Frank Wunderlich Add Bananapi R2 Pro board. tested: - sdcard - both front usb-ports - sata - wan-port lan-ports are connected to mt7531 switch where driver needs to be separated from mtk ethernet-driver. Signed-off-by: Frank Wunderlich Reviewed-by: Kever Yang Reviewed-by: Jonas Karlman --- because iodomain is different to evb and now iodomain driver is sent as patch we need to separate between EVB and R2Pro else board can be bricked. ethernet support depends on these series from jonas: rockchip: Port IO-domain driver for RK3568 from linux https://patchwork.ozlabs.org/project/uboot/cover/20230821223020.3918620-1-jo...@kwiboo.se/ and rockchip: Add GMAC support for RK3568 and RK3588 https://patchwork.ozlabs.org/project/uboot/cover/20230807000817.1701012-1-jo...@kwiboo.se/ --- v6: - fix missing dtb extension in CONFIG_DEFAULT_FDT_FILE - drop CONFIG_REGULATOR_PWM - add RBs - board name in maintainers file full uppercase v5: - add line break in description - reorder in makefile - drop special dts-handling (deletion of switchnode, disable of usb and gmac0) - add MAINTAINERS entry - changes to defconfig suggested by jonas - remove "pinctrl-0 pinctrl-names" from CONFIG_OF_SPL_REMOVE_PROPS - add CONFIG_SPL_DM_SEQ_ALIAS=y - add CONFIG_SPL_PINCTRL=y - remove CONFIG_USB_UHCI_HCD - enable EFI_LOADER (defaults to y) - drop CONFIG_SYSRESET_PSCI (reset works without) v4: - add r2pro board to readme - update r2pro dts to linux version - remove switch node from linux dts - disable gmac0 because switch driver does not work yet to solve timeout error: ethernet@fe2a Waiting for PHY auto negotiation to complete. TIMEOUT! phy_startup() failed: -110FAILED: -110ethernet@fe01 Waiting for PHY auto nee - cleanup r2pro u-boot.dtsi like jonas suggests - update and reorder defconfig based on jonas suggestions - dts: disable usb_host0_ohci because of error on usb-start scanning bus usb@fd84 for devices... ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token (IN) or did not provide a handshake (OUT) (5) unable to get device descriptor (error=-1) - pcie is not yet working, so not adding these options rockchip_pcie3phy phy@fe8c: lock failed 0x689 rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110. pcie_dw_rockchip pcie@fe27: failed to init phy (ret=-110) rockchip_pcie3phy phy@fe8c: lock failed 0x689 rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110. pcie_dw_rockchip pcie@fe28: failed to init phy (ret=-110) - emmc not tested as it is empty on my board because it breaks sdcard boot - rename dts and defconfig (add minus sign) - enable efi_loader in defconfig v3: - disable gmac0 as switch-driver is not yet ready to attach to the mac v2: - drop switch-node for now as u-boot driver works differently to linux --- arch/arm/dts/Makefile | 1 + arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi | 19 + arch/arm/dts/rk3568-bpi-r2-pro.dts | 852 + board/rockchip/evb_rk3568/MAINTAINERS | 7 + configs/bpi-r2-pro-rk3568_defconfig| 93 +++ doc/board/rockchip/rockchip.rst| 1 + 6 files changed, 973 insertions(+) create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro.dts create mode 100644 configs/bpi-r2-pro-rk3568_defconfig diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index bde2176ec7f6..fba7dfed26ba 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -177,6 +177,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \ rk3566-soquartz-blade.dtb \ rk3566-soquartz-cm4.dtb \ rk3566-soquartz-model-a.dtb \ + rk3568-bpi-r2-pro.dtb \ rk3568-evb.dtb \ rk3568-lubancat-2.dtb \ rk3568-nanopi-r5c.dtb \ diff --git a/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi b/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi new file mode 100644 index ..60a3b21f2d45 --- /dev/null +++ b/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2021 Rockchip Electronics Co., Ltd + */ + +#include "rk356x-u-boot.dtsi" + +/ { + chosen { + stdout-path = &uart2; + }; +}; + +&uart2 { + clock-frequency = <2400>; + bootph-pre-ram; + status = "okay"; +}; + diff --git a/arch/arm/dts/rk3568-bpi-r2-pro.dts b/arch/arm/dts/rk3568-bpi-r2-pro.dts new file mode 100644 index ..f9127ddfbb7d --- /dev/null +++ b/arch/arm/dts/rk3568-bpi-r2-pro.dts @@ -0,0 +1,852 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Author: Frank Wunderlich + * + */ + +/dts-v1/; +#include +#include +#include +#include +#include "rk3568.dtsi" + +/ { + model = "Bananapi-R2 Pro (RK3568) DDR4 Board"; + compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568"; + + aliases { + ethernet0 = &gmac0; +
Re: [PATCH v2 1/3] dt-bindings: mtd: fixed-partitions: Add binman compatible
Hi Michael, On Wed, 4 Oct 2023 at 11:17, Michael Walle wrote: > > Hi, > > >> >> Add a compatible string for binman, so we can extend fixed-partitions > >> >> in various ways. > >> > > >> > I've been thinking at the proper way to describe the binman partitions. > >> > I am wondering if we should really extend the fixed-partitions > >> > schema. This description is really basic and kind of supposed to remain > >> > like that. Instead, I wonder if we should not just keep the binman > >> > compatible alone, like many others already. This way it would be very > >> > clear > >> > what is expected and allowed in both cases. I am thinking about > >> > something like that: > >> > > >> > > >> > Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml > >> > > >> > this file is also referenced there (but this patch does the same, which > >> > is what I'd expect): > >> > > >> > Documentation/devicetree/bindings/mtd/partitions/partitions.yaml > >> > > >> > I'll let the binding maintainers judge whether they think it's > >> > relevant, it's not a strong opposition. > >> > >> What is the overall goal here? To replace the current binman node > >> which is > >> usually contained in the -u-boot.dtsi files? If one is using binman to > >> create an image, is it expected that one needs to adapt the DT in > >> linux? > >> Or will it still be a seperate -u-boot.dtsi? > Because in the latter > >> case > >> I see that there will be conflicts because you have to overwrite the > >> flash node. Or will it be a seperate node with all the information > >> duplicated? > > > > The goal is simply to have a full binding for firmware layout, such > > that firmware images can be created, examined and updated. The > > -u-boot.dtsi files are a stopgap while we sort out a real binding. > > They should eventually go away. > > You haven't answered whether this node should be a seperate binman > node - or if you'll reuse the existing flash (partitions) node(s) and > add any missing property there. If it's the latter, I don't think > compatible = "binman", "fixed-partitions"; is correct. My intent is to make it compatible, so wouldn't it make sense to have binman as the first compatible, then falling back to fixed-partitions as the second? > > >> Maybe (a more complete) example would be helpful. > > > > Can you please be a bit more specific? What is missing from the > > example? > > Like a complete (stripped) DTS. Right now I just see how the individual > node looks like. But with a complete example DTS, my question from above > would have been answered. > > What if a board uses eMMC to store the firmware binaries? Will that then > be a subnode to the eMMC device? I thought there was a way to link the partition nodes and the device using a property, without having the partition info as a subnode of the device. But I may have imagined it as I cannot find it now. So yes, it will be a subnode of the eMMC device. Regards, Simon
Re: [PATCH v4 02/16] arm: mach-k3: Add basic support for J784S4 SoC definition
On 23:22-20231004, Apurva Nandan wrote: [...] > > > + .virt = 0x5UL, > > > + .phys = 0x5UL, > > > + .size = 0x4UL, > > > + .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | > > > + PTE_BLOCK_NON_SHARE | > > > + PTE_BLOCK_PXN | PTE_BLOCK_UXN > > > + }, { > > > + /* List terminator */ > > > + 0, > > > + } > > > +}; > > Why not reuse CONFIG_SOC_K3_J721S2 or adopt it? > The mem_map regions are different for J784S4 from J721S2, > and on the hardware side also, i.e. J784S4 has 4x8G DDR slots, > so how can we bring it in same CONFIG as J721S2? Is'nt that what device tree is for? what harm do we run into if we define the common super set in the common file? -- Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Re: [PATCH v4 09/16] board: ti: j784s4: Add board support for J784S4 EVM
On 23:31-20231004, Apurva Nandan wrote: [...] > > > +rproc_fw_binaries= 2 /lib/firmware/j784s4-main-r5f0_0-fw 3 > > > /lib/firmware/j784s4-main-r5f0_1-fw 4 /lib/firmware/j784s4-main-r5f1_0-fw > > > 5 /lib/firmware/j784s4-main-r5f1_1-fw 6 > > > /lib/firmware/j784s4-main-r5f2_0-fw 7 /lib/firmware/j784s4-main-r5f2_1-fw > > > 8 /lib/firmware/j784s4-c71_0-fw 9 /lib/firmware/j784s4-c71_1-fw 10 > > > /lib/firmware/j784s4-c71_2-fw 11 /lib/firmware/j784s4-c71_3-fw > > No clue what the above mess is. > Are you talking about rproc_fw_binaries?, it is parsed by u-boot to find all > the firmwares > from filesystem for doing early boot of firmwares. Does stdboot support this? -- Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Aw: Re: [PATCH v5] board: rockchip: Add Bananapi R2Pro Board
Hi Jonas thanks for your review. > Gesendet: Dienstag, 03. Oktober 2023 um 22:27 Uhr > Von: "Jonas Karlman" > An: "Frank Wunderlich" , "Frank Wunderlich" > , "Kever Yang" > Cc: "Simon Glass" , "Philipp Tomsich" > , "Joseph Chen" , > u-boot@lists.denx.de > Betreff: Re: [PATCH v5] board: rockchip: Add Bananapi R2Pro Board > > Hi Frank, > > On 2023-09-20 20:40, Frank Wunderlich wrote: > > From: Frank Wunderlich > > > > Add Bananapi R2 Pro board. > > > > tested: > > - sdcard > > - both front usb-ports > > - sata > > - wan-port > > > > lan-ports are connected to mt7531 switch where driver needs to be > > separated from mtk ethernet-driver. > > > > Signed-off-by: Frank Wunderlich > > --- > > because iodomain is different to evb and now iodomain driver is sent as > > patch we need to separate between EVB and R2Pro else board can be bricked. > > > > ethernet support depends on these series from jonas: > > > > rockchip: Port IO-domain driver for RK3568 from linux > > https://patchwork.ozlabs.org/project/uboot/cover/20230821223020.3918620-1-jo...@kwiboo.se/ > > and > > rockchip: Add GMAC support for RK3568 and RK3588 > > https://patchwork.ozlabs.org/project/uboot/cover/20230807000817.1701012-1-jo...@kwiboo.se/ > > --- > > v5: > > - add line break in description > > - reorder in makefile > > - drop special dts-handling > > (deletion of switchnode, disable of usb and gmac0) > > - add MAINTAINERS entry > > - changes to defconfig suggested by jonas > > - remove "pinctrl-0 pinctrl-names" from CONFIG_OF_SPL_REMOVE_PROPS > > - add CONFIG_SPL_DM_SEQ_ALIAS=y > > - add CONFIG_SPL_PINCTRL=y > > - remove CONFIG_USB_UHCI_HCD > > - enable EFI_LOADER (defaults to y) > > - drop CONFIG_SYSRESET_PSCI (reset works without) > > > > v4: > > - add r2pro board to readme > > - update r2pro dts to linux version > > - remove switch node from linux dts > > - disable gmac0 because switch driver does not work yet > > to solve timeout error: > > ethernet@fe2a Waiting for PHY auto negotiation to complete. > > TIMEOUT! > > phy_startup() failed: -110FAILED: -110ethernet@fe01 Waiting for PHY > > auto nee > > - cleanup r2pro u-boot.dtsi like jonas suggests > > - update and reorder defconfig based on jonas suggestions > > - dts: disable usb_host0_ohci because of error on usb-start > > scanning bus usb@fd84 for devices... > > ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token > > (IN) or did > > not provide a handshake (OUT) (5) > > unable to get device descriptor (error=-1) > > - pcie is not yet working, so not adding these options > > rockchip_pcie3phy phy@fe8c: lock failed 0x689 > > rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110. > > pcie_dw_rockchip pcie@fe27: failed to init phy (ret=-110) > > rockchip_pcie3phy phy@fe8c: lock failed 0x689 > > rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110. > > pcie_dw_rockchip pcie@fe28: failed to init phy (ret=-110) > > - emmc not tested as it is empty on my board because it breaks sdcard boot > > - rename dts and defconfig (add minus sign) > > - enable efi_loader in defconfig > > > > v3: > > - disable gmac0 as switch-driver is not yet ready to attach to the mac > > > > v2: > > - drop switch-node for now as u-boot driver works differently to linux > > --- > > arch/arm/dts/Makefile | 1 + > > arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi | 19 + > > arch/arm/dts/rk3568-bpi-r2-pro.dts | 852 + > > board/rockchip/evb_rk3568/MAINTAINERS | 7 + > > configs/bpi-r2-pro-rk3568_defconfig| 94 +++ > > doc/board/rockchip/rockchip.rst| 1 + > > 6 files changed, 974 insertions(+) > > create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi > > create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro.dts > > create mode 100644 configs/bpi-r2-pro-rk3568_defconfig > > > > [...] > > > diff --git a/board/rockchip/evb_rk3568/MAINTAINERS > > b/board/rockchip/evb_rk3568/MAINTAINERS > > index cc9eb432a8b5..8c506162c01e 100644 > > --- a/board/rockchip/evb_rk3568/MAINTAINERS > > +++ b/board/rockchip/evb_rk3568/MAINTAINERS > > @@ -7,6 +7,13 @@ F: configs/evb-rk3568_defconfig > > F: arch/arm/dts/rk3568-evb-u-boot.dtsi > > F: arch/arm/dts/rk3568-evb.dts > > > > +Banana Pi BPI-R2 Pro > > Maintainer entries are typically in upper case. get_maintainer.pl does > not seem to mind, but use of uppercase seem to be the norm. ok, i wil change it to "BANANAPI-BPI-R2-PRO" as i noticed that no spaces are in the other Boards > > +M: Frank Wunderlich > > +S: Maintained > > +F: configs/bpi-r2-pro-rk3568_defconfig > > +F: arch/arm/dts/rk3568-bpi-r2-pro.dts > > +F: arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi > > + > > LUBANCAT-2 > > M: Andy Yan > > S: Maintained > > diff --git a/configs/bpi-r2-pro-rk3568_defconfig > > b/configs/bpi-r2-pro-rk3568_defconfig > > new file mode 100644 > > index ..59
Re: [PATCH v4 16/16] doc: board: ti: k3: Add J784S4 EVM and AM69 SK documentation
On 03/10/23 04:25, Heinrich Schuchardt wrote: On 10/2/23 18:58, Bryan Brattlof wrote: Hi Apurva! Sorry for the late review. Just some updates I noticed when reading over the docs. On October 1, 2023 thus sayeth Apurva Nandan: TI K3 J784S4 and AM69 are new additions to the K3 SoC family. Add documentation about the J784S4 EVM and AM69 SK. Signed-off-by: Dasnavis Sabiya Signed-off-by: Apurva Nandan --- board/ti/j784s4/MAINTAINERS | 1 + doc/board/ti/j784s4_evm.rst | 339 doc/board/ti/k3.rst | 1 + 3 files changed, 341 insertions(+) create mode 100644 doc/board/ti/j784s4_evm.rst diff --git a/board/ti/j784s4/MAINTAINERS b/board/ti/j784s4/MAINTAINERS index 5b5ef8b109..24db43f09b 100644 --- a/board/ti/j784s4/MAINTAINERS +++ b/board/ti/j784s4/MAINTAINERS @@ -15,6 +15,7 @@ F: arch/arm/dts/k3-j784s4-evm-u-boot.dtsi F: arch/arm/dts/k3-j784s4-r5-evm.dts F: arch/arm/dts/k3-j784s4-ddr.dtsi F: arch/arm/dts/k3-j784s4-ddr-evm-lp4-4266.dtsi +F: doc/board/ti/j784s4_evm.rst AM69 BOARD F: arch/arm/dts/k3-am69-sk.dts diff --git a/doc/board/ti/j784s4_evm.rst b/doc/board/ti/j784s4_evm.rst new file mode 100644 index 00..c04894b47a --- /dev/null +++ b/doc/board/ti/j784s4_evm.rst @@ -0,0 +1,339 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause +.. sectionauthor:: Apurva Nandan + +J784S4 and AM69 Platforms += + +Introduction + +The J784S4 SoC belongs to the K3 Multicore SoC architecture +platform, providing advanced system integration in automotive, +ADAS and industrial applications requiring AI at the network edge. +This SoC extends the K3 Jacinto 7 family of SoCs with focus on +raising performance and integration while providing interfaces, +memory architecture and compute performance for multi-sensor, high +concurrency applications. + +The device is partitioned into three functional domains, each containing +specific processing cores and peripherals: + +1. Wake-up (WKUP) domain + * ARM Cortex-M4F processor, runs TI Foundational Security (TIFS) + +2. Microcontroller (MCU) domain + * Dual core ARM Cortex-R5F processor, runs device management + and SoC early boot + +3. MAIN domain + * Dual core 64-bit ARM Cortex-A72, runs HLOS You have much more than this on these SoCs ;) + +More info can be found in TRM: http://www.ti.com/lit/zip/spruj52 + +Platform information: + +* https://www.ti.com/tool/J784S4XEVM +* https://www.ti.com/tool/SK-AM69 + +Boot Flow +- +Below is the pictorial representation of boot flow: + +.. image:: img/boot_diagram_k3_current.svg Please, provide alternative texts for all images, e.g. .. image:: img/boot_diagram_k3_current.svg :alt: K3 boot flow Thanks for pointing, will fix + +- On this platform, "TI Foundational Security (TIFS)" functions as the + security enclave master. While "Device Manager (DM)", also known as the + "TISCI server" in TI terminology, offers all the essential services. + +- As illustrated in the diagram above, R5 SPL manages power and clock + services independently before handing over control to DM. The A72 or + the C7x (Aux core) software components request TIFS/DM to handle + security or device management services. + +Sources +--- + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_boot_sources + :end-before: .. k3_rst_include_end_boot_sources + +Build procedure +--- +0. Setup the environment variables: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_desc + :end-before: .. k3_rst_include_end_common_env_vars_desc + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_board_env_vars_desc + :end-before: .. k3_rst_include_end_board_env_vars_desc + +Set the variables corresponding to this platform: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_defn + :end-before: .. k3_rst_include_end_common_env_vars_defn +.. code-block:: bash + + $ export UBOOT_CFG_CORTEXR=j784s4_evm_r5_defconfig + $ export UBOOT_CFG_CORTEXA=j784s4_evm_a72_defconfig + $ export TFA_BOARD=generic sadly the j784s4 breaks from the lite vs generic platform norm + $ export TFA_EXTRA_ARGS="K3_USART=0x8" + $ export OPTEE_PLATFORM=k3-j784s4 + $ export OPTEE_EXTRA_ARGS="CFG_CONSOLE_UART=0x8" + +.. j784s4_evm_rst_include_start_build_steps + +1. Trusted Firmware-A + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_tfa + +2. OP-TEE + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_optee + :end-before: .. k3_rst_include_end_build_steps_optee + +3. U-Boot + +.. _j784s4_evm_rst_u_boot_r5: + +* 3.1 R5 + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_spl_r5 + :end-before: .. k3_rst_include_end_build_steps_spl_r5 + +.. _j784s4_evm_rst_u_boot_a72: + +* 3.2 A72 + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_bu
Re: [PATCH v4 10/16] arm: dts: Introduce j784s4 u-boot dts files
On 02/10/23 19:34, Jerome Forissier wrote: Hello Apurva, On 10/1/23 18:55, Apurva Nandan wrote: Introduce the base dts files needed for u-boot or to augment the linux dtbs for use in the u-boot-spl and u-boot binaries. Signed-off-by: Hari Nagalla [ add binman and ddr dtsi files ] Signed-off-by: Neha Malcom Francis Signed-off-by: Apurva Nandan Signed-off-by: Dasnavis Sabiya --- arch/arm/dts/Makefile|2 + arch/arm/dts/k3-j784s4-binman.dtsi | 505 + arch/arm/dts/k3-j784s4-ddr-evm-lp4-4266.dtsi | 8757 + arch/arm/dts/k3-j784s4-ddr.dtsi | 8858 ++ arch/arm/dts/k3-j784s4-evm-u-boot.dtsi | 25 + arch/arm/dts/k3-j784s4-r5-evm.dts| 105 + 6 files changed, 18252 insertions(+) create mode 100644 arch/arm/dts/k3-j784s4-binman.dtsi create mode 100644 arch/arm/dts/k3-j784s4-ddr-evm-lp4-4266.dtsi create mode 100644 arch/arm/dts/k3-j784s4-ddr.dtsi create mode 100644 arch/arm/dts/k3-j784s4-evm-u-boot.dtsi create mode 100644 arch/arm/dts/k3-j784s4-r5-evm.dts diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 85fd5b1157..21cfebff58 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -1327,6 +1327,8 @@ dtb-$(CONFIG_SOC_K3_J721S2) += k3-am68-sk-base-board.dtb\ k3-am68-sk-r5-base-board.dtb\ k3-j721s2-common-proc-board.dtb\ k3-j721s2-r5-common-proc-board.dtb +dtb-$(CONFIG_SOC_K3_J784S4) += k3-j784s4-evm.dtb\ + k3-j784s4-r5-evm.dtb dtb-$(CONFIG_SOC_K3_AM642) += k3-am642-evm.dtb \ k3-am642-r5-evm.dtb \ k3-am642-sk.dtb \ diff --git a/arch/arm/dts/k3-j784s4-binman.dtsi b/arch/arm/dts/k3-j784s4-binman.dtsi new file mode 100644 index 00..f9b191424c --- /dev/null +++ b/arch/arm/dts/k3-j784s4-binman.dtsi @@ -0,0 +1,505 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/ + */ +&binman { + ti-spl_unsigned { + filename = "tispl.bin_unsigned"; + pad-byte = <0xff>; + + fit { + description = "Configuration to load ATF and SPL"; + #address-cells = <1>; + + images { + + atf { + description = "ARM Trusted Firmware"; + type = "firmware"; + arch = "arm64"; + compression = "none"; + os = "arm-trusted-firmware"; + load = ; + entry = ; + + atf-bl31 { + filename = "bl31.bin"; + }; + }; + + tee { + description = "OPTEE"; The official spelling is "OP-TEE". + type = "tee"; + arch = "arm64"; + compression = "none"; + os = "tee"; + load = <0x9e80>; + entry = <0x9e80>; + + tee-os { + filename = "tee-pager_v2.bin"; Since OP-TEE 3.21.0 this could/should be replaced with tee-raw.bin. Although tee-pager_v2.bin is still produced unconditionally (even when the "pager" feature is disabled in OP-TEE) it might not be the case in the future, and the name is somewhat misleading when pager is disabled anyways (which is clearly the case here since tee-pageable_v2.bin is not used). Thanks, Okay will fix it -- Regards, Apurva Nandan, Texas Instruments.
Re: [PATCH v4 09/16] board: ti: j784s4: Add board support for J784S4 EVM
On 02/10/23 21:21, Nishanth Menon wrote: On 22:25-20231001, Apurva Nandan wrote: Add board files for J784S4 EVM. Signed-off-by: Hari Nagalla [ add env and board specific yaml files for binman ] Signed-off-by: Neha Malcom Francis [ cleaned up the env files ] Signed-off-by: Manorit Chawdhry Signed-off-by: Apurva Nandan Signed-off-by: Dasnavis Sabiya --- arch/arm/mach-k3/Kconfig |1 + board/ti/j784s4/Kconfig | 63 + board/ti/j784s4/MAINTAINERS | 22 + board/ti/j784s4/Makefile |7 + board/ti/j784s4/board-cfg.yaml | 37 + board/ti/j784s4/evm.c| 82 + board/ti/j784s4/j784s4.env | 35 + board/ti/j784s4/pm-cfg.yaml | 13 + board/ti/j784s4/rm-cfg.yaml | 3058 ++ board/ti/j784s4/sec-cfg.yaml | 380 board/ti/j784s4/tifs-rm-cfg.yaml | 2656 ++ include/configs/j784s4_evm.h | 20 + There is all kind of changes mixed in that makes this patch hard to review. Will try to split into smaller patches. 12 files changed, 6374 insertions(+) create mode 100644 board/ti/j784s4/Kconfig create mode 100644 board/ti/j784s4/MAINTAINERS create mode 100644 board/ti/j784s4/Makefile create mode 100644 board/ti/j784s4/board-cfg.yaml create mode 100644 board/ti/j784s4/evm.c create mode 100644 board/ti/j784s4/j784s4.env create mode 100644 board/ti/j784s4/pm-cfg.yaml create mode 100644 board/ti/j784s4/rm-cfg.yaml create mode 100644 board/ti/j784s4/sec-cfg.yaml create mode 100644 board/ti/j784s4/tifs-rm-cfg.yaml create mode 100644 include/configs/j784s4_evm.h [...] new file mode 100644 index 00..025079c6a8 --- /dev/null +++ b/board/ti/j784s4/evm.c @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Board specific initialization for J784S4 EVM + * + * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/ + * Hari Nagalla + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../common/board_detect.h" + +#define board_is_j784s4_evm() board_ti_k3_is("J784S4-EVM") + +DECLARE_GLOBAL_DATA_PTR; + +int board_init(void) +{ + return 0; +} + +int dram_init(void) +{ +#ifdef CONFIG_PHYS_64BIT stop using #ifdef. if (IS_ENABLED()) Checkpatch will warn you on this. you seem to have ignore it. okay + gd->ram_size = 0x1; +#else + gd->ram_size = 0x8000; +#endif + + return 0; +} + +phys_size_t board_get_usable_ram_top(phys_size_t total_size) +{ +#ifdef CONFIG_PHYS_64BIT + /* Limit RAM used by U-Boot to the DDR low region */ + if (gd->ram_top > 0x1) + return 0x1; +#endif + + return gd->ram_top; +} + +int dram_init_banksize(void) +{ + /* Bank 0 declares the memory available in the DDR low region */ + gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE; + gd->bd->bi_dram[0].size = 0x7fff; + gd->ram_size = 0x8000; NAK. Use fdtdec_setup_mem_size_base fdtdec_setup_memory_banksize And fix up accordingly. Okay + +#ifdef CONFIG_PHYS_64BIT + /* Bank 1 declares the memory available in the DDR high region */ + gd->bd->bi_dram[1].start = CFG_SYS_SDRAM_BASE1; + gd->bd->bi_dram[1].size = 0x77fff; + gd->ram_size = 0x8; +#endif + + return 0; +} + +int board_late_init(void) +{ + return 0; +} + +void spl_board_init(void) +{ +} diff --git a/board/ti/j784s4/j784s4.env b/board/ti/j784s4/j784s4.env new file mode 100644 index 00..74f822440e --- /dev/null +++ b/board/ti/j784s4/j784s4.env @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +#if CONFIG_CMD_REMOTEPROC +#include +#endif + +default_device_tree=ti/k3-j784s4-evm.dtb +findfdt= + setenv name_fdt ${default_device_tree}; + if test CONFIG_DEFAULT_DEVICE_TREE = "k3-j784s4-evm"; then + setenv name_fdt ti/k3-j784s4-evm.dtb; fi; + setenv fdtfile ${name_fdt} Explained that this is a NAK. +name_kern=Image +console=ttyS2,115200n8 +args_all=setenv optargs ${optargs} earlycon=ns16550a,mmio32,0x0288 + ${mtdparts} +run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr} + +boot_targets=ti_mmc mmc0 mmc1 usb pxe dhcp ti_mmc is a boot_target in stdboot?? no, it wont work. Also change the boot meth to mmc1 (SD), mmc0(emmc), usb pxe dhcp. Okay +boot=mmc +mmcdev=1 +dorprocboot=1 +bootpart=1:2 +bootdir=/boot +rd_spec=- + +rproc_fw_binaries= 2 /lib/firmware/j784s4-main-r5f0_0-fw 3 /lib/firmware/j784s4-main-r5f0_1-fw 4 /lib/firmware/j784s4-main-r5f1_0-fw 5 /lib/firmware/j784s4-main-r5f1_1-fw 6 /lib/firmware/j784s4-main-r5f2_0-fw 7 /lib/firmware/j784s4-main-r5f2_1-fw 8 /lib/firmware/j784s4-c71_0-fw 9 /lib/firmware/j784s4-c71_1-fw 10 /lib/firmware/j784s4-c71_2-fw 11 /lib/firmware/j784s4-c71_3-fw No clue what the above mess is. Are you talking about rproc_fw_bin
Please pull u-boot-dm
Hi Tom, https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/18014 (usual azure branch but I cannot get the link) The following changes since commit 65b9b3462bec2966911658836983819ab4e4823e: Merge branch 'next_pinctrl_sync' of https://source.denx.de/u-boot/custodians/u-boot-sh (2023-10-02 15:19:02 -0400) are available in the Git repository at: git://git.denx.de/u-boot-dm.git tags/dm-pull-4oct23 for you to fetch changes up to 4840b71bb009711564e20f9695b92950c3f73e42: qconfig: Update the documentation (2023-10-04 09:25:22 -0600) moveconfig: enhance output; rename to qconfig Simon Glass (28): dm: core: Adjust dump-sorting to get stats only when needed moveconfig: Drop -H option moveconfig: Avoid deprecation warning for setDaemon moveconfig: Correct ordering of asteval import moveconfig: Drop unused cleanup options moveconfig: Drop CONFIG-moving code moveconfig: Drop check_defconfig() and update_dotconfig() moveconfig: Drop suspicious boards moveconfig: Correct some regular-expression strings moveconfig: Correct parameter-type warnings moveconfig: Use f strings where possible moveconfig: Correct unused variables moveconfig: Correct non-snake variables names moveconfig: Correct use of members not declared in __init__() moveconfig: Correct list-comprehension warnings moveconfig: Use an encoding with open() moveconfig: Fix misc pylint warnings moveconfig: Only show output when there is a reason moveconfig: Reduce the amount of output moveconfig: Avoid showing progress at the end moveconfig: Use u_boot_pylib for terminal colour moveconfig: Show failures in progress moveconfig: Show a summary at the end moveconfig: Drop the initial output moveconfig: Move summaries to the end moveconfig: Rename the tool to qconfig qconfig: Rename the database file qconfig: Update the documentation .gitignore | 4 +- doc/develop/index.rst | 2 +- doc/develop/{moveconfig.rst => qconfig.rst} | 160 - drivers/core/dump.c | 3 +- tools/{moveconfig.py => qconfig.py} | 894 ++-- 5 files changed, 273 insertions(+), 790 deletions(-) rename doc/develop/{moveconfig.rst => qconfig.rst} (59%) rename tools/{moveconfig.py => qconfig.py} (65%) Regards, Simon
Re: [PATCH 2/2] dm: core: Adjust dump-sorting to get stats only when needed
If we are not sorting the tree we don't need to get the stats. Adjust the code to avoid the wasted time. Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/dump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 01/27] moveconfig: Drop -H option
Drop this option, which is no longer needed now that we have converted all CONFIG options to Kconfig. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 02/27] moveconfig: Avoid deprecation warning for setDaemon
Use the recommended new way of setting a thread to be a daemon. This avoids a warning: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 03/27] moveconfig: Correct ordering of asteval import
This should be after the standard imports. Move it to avoid a lot of pylint warnings. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 07/27] moveconfig: Drop suspicious boards
This code isn't needed anymore. Drop it. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 25 - 1 file changed, 25 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 04/27] moveconfig: Drop unused cleanup options
Cleaning up the README and config.h files are not needed now, since we don't have any CONFIG options to convert. Drop this code. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 254 +--- 1 file changed, 2 insertions(+), 252 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 08/27] moveconfig: Correct some regular-expression strings
Use the 'r' prefix for these strings to avoid pylint warnings. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 06/27] moveconfig: Drop check_defconfig() and update_dotconfig()
These functions are not needed anymore. Drop them. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 62 ++--- 1 file changed, 2 insertions(+), 60 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 05/27] moveconfig: Drop CONFIG-moving code
As a step towards cleaning out old code, drop most of the code that moves CONFIG options to Kconfig. This includes parse_one_config(). Drop the ACTION_... values as well, since they are no-longer used. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 163 ++-- 1 file changed, 19 insertions(+), 144 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 10/27] moveconfig: Use f strings where possible
Avoid pylint warnings by using 'f' strings where possible. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 56 ++--- 1 file changed, 28 insertions(+), 28 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 09/27] moveconfig: Correct parameter-type warnings
Fix pylint warnings related to parameter types. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 43 ++- 1 file changed, 22 insertions(+), 21 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 11/27] moveconfig: Correct unused variables
Fix pylint warnings about unused variables. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 12/27] moveconfig: Correct non-snake variables names
Correct some variable names that do not conform to snake case, with the three-character minimum. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 70 ++--- 1 file changed, 35 insertions(+), 35 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 14/27] moveconfig: Correct list-comprehension warnings
Correct some pylint warnings about needing to use list comprehension. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 13/27] moveconfig: Correct use of members not declared in __init__()
Fix these pylint warnings. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 4 1 file changed, 4 insertions(+) Applied to u-boot-dm, thanks!
Re: [PATCH v3 15/27] moveconfig: Use an encoding with open()
Fix pylint warnings about needing an explicit character encoding. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 16/27] moveconfig: Fix misc pylint warnings
Fix various remaining pylint warnings. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 18/27] moveconfig: Reduce the amount of output
Output a single line in the case where the defconfig only has one line of output. Show the name without the _defconfig suffix, since that is the same for all boards. Use a list for the log so it is easier to process at the end. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 29 + 1 file changed, 17 insertions(+), 12 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 17/27] moveconfig: Only show output when there is a reason
There is no point in listing a board if everything went well. It makes it harder to see the failures, particularly on a fast machine. Suppress output unless something actually happened. Drop the 'Syncing by savedefconfig' since this is selected by the -s and is the same for all boards in this mode. Signed-off-by: Simon Glass --- Changes in v3: - Fix 'Supress' typo tools/moveconfig.py | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 19/27] moveconfig: Avoid showing progress at the end
When the process is finished, moveconfig leaves a line saying that all boards were processed (for better or worse). Drop this, since it is unncessary. Future work will provide a summary at the end instead. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 20/27] moveconfig: Use u_boot_pylib for terminal colour
Use the existing terminal code to handle ANSI colours. Enable colour by default if the output is going to a terminal. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 92 +++-- 1 file changed, 38 insertions(+), 54 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 22/27] moveconfig: Show a summary at the end
Rather than printing all the failed boards, which are now easily visible on the terminal, just show a summary. Sort it by defconfig and drop the '_defconfig' suffix. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 21/27] moveconfig: Show failures in progress
Show the number of accumulated failures when processing. Use a shorter format with colour. An unwanted space appears before the defconfig name on every item except the last. Fix that while we are here. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 26 +++--- 1 file changed, 19 insertions(+), 7 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 27/27] qconfig: Update the documentation
Update qconfig's documentation to better reflect its new purpose in life. Signed-off-by: Simon Glass --- Changes in v3: - Update based on Heinrich's comments Changes in v2: - Reinstate the -C option doc/develop/index.rst | 2 +- doc/develop/{moveconfig.rst => qconfig.rst} | 160 ++-- 2 files changed, 47 insertions(+), 115 deletions(-) rename doc/develop/{moveconfig.rst => qconfig.rst} (59%) Applied to u-boot-dm, thanks!
Re: [PATCH v3 23/27] moveconfig: Drop the initial output
Since moveconfig now just does what it is told (build database or sync defconfigs) we don't need to print what it is doing. Drop this info, which is of very little use. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 6 -- 1 file changed, 6 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 26/27] qconfig: Rename the database file
Use qconfig.db as the new name, to reflect the tool's purpose. Signed-off-by: Simon Glass --- (no changes since v1) .gitignore | 4 ++-- tools/qconfig.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v3 25/27] moveconfig: Rename the tool to qconfig
This does not move configs anymore, but queries them, based on a database it can build. Rename the tool to better reflect its purpose. Signed-off-by: Simon Glass --- (no changes since v1) tools/{moveconfig.py => qconfig.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename tools/{moveconfig.py => qconfig.py} (99%) Applied to u-boot-dm, thanks!
Re: [PATCH v3 24/27] moveconfig: Move summaries to the end
Write the summary for -s and -b at the end, using a unified format. Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 36 +++- 1 file changed, 23 insertions(+), 13 deletions(-) Applied to u-boot-dm, thanks!
Re: [PATCH v4 02/16] arm: mach-k3: Add basic support for J784S4 SoC definition
On 02/10/23 21:31, Nishanth Menon wrote: On 22:25-20231001, Apurva Nandan wrote: Add J784S4 initialization files for initial SPL boot. Signed-off-by: Hari Nagalla [ add firewall configurations and change the R5 MCU scratchpad ] Signed-off-by: Manorit Chawdhry Signed-off-by: Dasnavis Sabiya Signed-off-by: Apurva Nandan --- arch/arm/mach-k3/Kconfig | 16 +- arch/arm/mach-k3/Makefile | 3 + arch/arm/mach-k3/arm64-mmu.c | 52 +++ arch/arm/mach-k3/include/mach/hardware.h | 4 + .../mach-k3/include/mach/j784s4_hardware.h| 60 arch/arm/mach-k3/include/mach/j784s4_spl.h| 47 +++ arch/arm/mach-k3/include/mach/spl.h | 4 + arch/arm/mach-k3/j784s4_fdt.c | 15 + arch/arm/mach-k3/j784s4_init.c| 332 ++ 9 files changed, 526 insertions(+), 7 deletions(-) create mode 100644 arch/arm/mach-k3/include/mach/j784s4_hardware.h create mode 100644 arch/arm/mach-k3/include/mach/j784s4_spl.h create mode 100644 arch/arm/mach-k3/j784s4_fdt.c create mode 100644 arch/arm/mach-k3/j784s4_init.c diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig index 9168bf842d..0af2ec6ddb 100644 --- a/arch/arm/mach-k3/Kconfig +++ b/arch/arm/mach-k3/Kconfig @@ -22,6 +22,9 @@ config SOC_K3_AM625 config SOC_K3_AM62A7 bool "TI's K3 based AM62A7 SoC Family Support" +config SOC_K3_J784S4 + bool "TI's K3 based J784S4 SoC Family Support" + endchoice config SYS_SOC @@ -30,7 +33,7 @@ config SYS_SOC config SYS_K3_NON_SECURE_MSRAM_SIZE hex default 0x8 if SOC_K3_AM654 - default 0x10 if SOC_K3_J721E || SOC_K3_J721S2 + default 0x10 if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4 default 0x1c if SOC_K3_AM642 default 0x3c000 if SOC_K3_AM625 || SOC_K3_AM62A7 help @@ -42,7 +45,7 @@ config SYS_K3_NON_SECURE_MSRAM_SIZE config SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE hex default 0x58000 if SOC_K3_AM654 - default 0xc if SOC_K3_J721E || SOC_K3_J721S2 + default 0xc if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4 default 0x18 if SOC_K3_AM642 default 0x38000 if SOC_K3_AM625 || SOC_K3_AM62A7 help @@ -52,15 +55,14 @@ config SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE config SYS_K3_MCU_SCRATCHPAD_BASE hex default 0x4028 if SOC_K3_AM654 - default 0x41cff9fc if SOC_K3_J721S2 - default 0x41cff9fc if SOC_K3_J721E + default 0x41cff9fc if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4 help Describes the base address of MCU Scratchpad RAM. config SYS_K3_MCU_SCRATCHPAD_SIZE hex default 0x200 if SOC_K3_AM654 - default 0x200 if SOC_K3_J721E || SOC_K3_J721S2 + default 0x200 if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4 help Describes the size of MCU Scratchpad RAM. @@ -68,7 +70,7 @@ config SYS_K3_BOOT_PARAM_TABLE_INDEX hex default 0x41c7fbfc if SOC_K3_AM654 default 0x41cffbfc if SOC_K3_J721E - default 0x41cfdbfc if SOC_K3_J721S2 + default 0x41cfdbfc if SOC_K3_J721S2 || SOC_K3_J784S4 default 0x701bebfc if SOC_K3_AM642 default 0x43c3f290 if SOC_K3_AM625 default 0x43c3f290 if SOC_K3_AM62A7 && CPU_V7R @@ -172,7 +174,7 @@ config K3_ATF_LOAD_ADDR config K3_DM_FW bool "Separate DM firmware image" - depends on SPL && CPU_V7R && (SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_AM625 || SOC_K3_AM62A7) && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN + depends on SPL && CPU_V7R && (SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_J784S4) && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN default y help Enabling this will indicate that the system has separate DM diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile index fd77b8bbba..6fe36c265c 100644 --- a/arch/arm/mach-k3/Makefile +++ b/arch/arm/mach-k3/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_SOC_K3_J721E) += j721e/ j7200/ obj-$(CONFIG_SOC_K3_J721S2) += j721s2/ obj-$(CONFIG_SOC_K3_AM625) += am62x/ obj-$(CONFIG_SOC_K3_AM62A7) += am62ax/ +obj-$(CONFIG_SOC_K3_J784S4) += j784s4/ obj-$(CONFIG_ARM64) += arm64-mmu.o obj-$(CONFIG_CPU_V7R) += r5_mpu.o lowlevel_init.o obj-$(CONFIG_ARM64) += cache.o @@ -16,6 +17,7 @@ obj-$(CONFIG_SOC_K3_AM654) += am654_fdt.o obj-$(CONFIG_SOC_K3_J721E) += j721e_fdt.o obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o obj-$(CONFIG_SOC_K3_AM625) += am625_fdt.o +obj-$(CONFIG_SOC_K3_J784S4) += j784s4_fdt.o endif ifeq ($(CONFIG_SPL_BUILD),y) obj-$(CONFIG_SOC_K3_AM654) += am654_init.o @@ -24,6 +26,7 @@ obj-$(CONFIG_SOC_K3_J721S2) += j721s2_init.o obj-$(CONFIG_SOC_K3_AM642) += am642_init.o obj-$(CONFIG_SOC_K3_AM625) += am625_init.o obj-$(CONFIG_SOC_K3_AM62A7) += am62a7_init.o +obj-$(CONFIG_SOC_K3_J784S4) += j784s4_init.o obj-$(CONFIG_K3_LOAD_SYSFW)
Re: [PATCH v4 02/16] arm: mach-k3: Add basic support for J784S4 SoC definition
On 02/10/23 21:31, Nishanth Menon wrote: On 22:25-20231001, Apurva Nandan wrote: Add J784S4 initialization files for initial SPL boot. Signed-off-by: Hari Nagalla [ add firewall configurations and change the R5 MCU scratchpad ] Signed-off-by: Manorit Chawdhry Signed-off-by: Dasnavis Sabiya Signed-off-by: Apurva Nandan --- arch/arm/mach-k3/Kconfig | 16 +- arch/arm/mach-k3/Makefile | 3 + arch/arm/mach-k3/arm64-mmu.c | 52 +++ arch/arm/mach-k3/include/mach/hardware.h | 4 + .../mach-k3/include/mach/j784s4_hardware.h| 60 arch/arm/mach-k3/include/mach/j784s4_spl.h| 47 +++ arch/arm/mach-k3/include/mach/spl.h | 4 + arch/arm/mach-k3/j784s4_fdt.c | 15 + arch/arm/mach-k3/j784s4_init.c| 332 ++ 9 files changed, 526 insertions(+), 7 deletions(-) create mode 100644 arch/arm/mach-k3/include/mach/j784s4_hardware.h create mode 100644 arch/arm/mach-k3/include/mach/j784s4_spl.h create mode 100644 arch/arm/mach-k3/j784s4_fdt.c create mode 100644 arch/arm/mach-k3/j784s4_init.c diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig index 9168bf842d..0af2ec6ddb 100644 --- a/arch/arm/mach-k3/Kconfig +++ b/arch/arm/mach-k3/Kconfig @@ -22,6 +22,9 @@ config SOC_K3_AM625 config SOC_K3_AM62A7 bool "TI's K3 based AM62A7 SoC Family Support" +config SOC_K3_J784S4 + bool "TI's K3 based J784S4 SoC Family Support" + endchoice config SYS_SOC @@ -30,7 +33,7 @@ config SYS_SOC config SYS_K3_NON_SECURE_MSRAM_SIZE hex default 0x8 if SOC_K3_AM654 - default 0x10 if SOC_K3_J721E || SOC_K3_J721S2 + default 0x10 if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4 default 0x1c if SOC_K3_AM642 default 0x3c000 if SOC_K3_AM625 || SOC_K3_AM62A7 help @@ -42,7 +45,7 @@ config SYS_K3_NON_SECURE_MSRAM_SIZE config SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE hex default 0x58000 if SOC_K3_AM654 - default 0xc if SOC_K3_J721E || SOC_K3_J721S2 + default 0xc if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4 default 0x18 if SOC_K3_AM642 default 0x38000 if SOC_K3_AM625 || SOC_K3_AM62A7 help @@ -52,15 +55,14 @@ config SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE config SYS_K3_MCU_SCRATCHPAD_BASE hex default 0x4028 if SOC_K3_AM654 - default 0x41cff9fc if SOC_K3_J721S2 - default 0x41cff9fc if SOC_K3_J721E + default 0x41cff9fc if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4 help Describes the base address of MCU Scratchpad RAM. config SYS_K3_MCU_SCRATCHPAD_SIZE hex default 0x200 if SOC_K3_AM654 - default 0x200 if SOC_K3_J721E || SOC_K3_J721S2 + default 0x200 if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4 help Describes the size of MCU Scratchpad RAM. @@ -68,7 +70,7 @@ config SYS_K3_BOOT_PARAM_TABLE_INDEX hex default 0x41c7fbfc if SOC_K3_AM654 default 0x41cffbfc if SOC_K3_J721E - default 0x41cfdbfc if SOC_K3_J721S2 + default 0x41cfdbfc if SOC_K3_J721S2 || SOC_K3_J784S4 default 0x701bebfc if SOC_K3_AM642 default 0x43c3f290 if SOC_K3_AM625 default 0x43c3f290 if SOC_K3_AM62A7 && CPU_V7R @@ -172,7 +174,7 @@ config K3_ATF_LOAD_ADDR config K3_DM_FW bool "Separate DM firmware image" - depends on SPL && CPU_V7R && (SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_AM625 || SOC_K3_AM62A7) && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN + depends on SPL && CPU_V7R && (SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_J784S4) && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN default y help Enabling this will indicate that the system has separate DM diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile index fd77b8bbba..6fe36c265c 100644 --- a/arch/arm/mach-k3/Makefile +++ b/arch/arm/mach-k3/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_SOC_K3_J721E) += j721e/ j7200/ obj-$(CONFIG_SOC_K3_J721S2) += j721s2/ obj-$(CONFIG_SOC_K3_AM625) += am62x/ obj-$(CONFIG_SOC_K3_AM62A7) += am62ax/ +obj-$(CONFIG_SOC_K3_J784S4) += j784s4/ obj-$(CONFIG_ARM64) += arm64-mmu.o obj-$(CONFIG_CPU_V7R) += r5_mpu.o lowlevel_init.o obj-$(CONFIG_ARM64) += cache.o @@ -16,6 +17,7 @@ obj-$(CONFIG_SOC_K3_AM654) += am654_fdt.o obj-$(CONFIG_SOC_K3_J721E) += j721e_fdt.o obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o obj-$(CONFIG_SOC_K3_AM625) += am625_fdt.o +obj-$(CONFIG_SOC_K3_J784S4) += j784s4_fdt.o endif ifeq ($(CONFIG_SPL_BUILD),y) obj-$(CONFIG_SOC_K3_AM654) += am654_init.o @@ -24,6 +26,7 @@ obj-$(CONFIG_SOC_K3_J721S2) += j721s2_init.o obj-$(CONFIG_SOC_K3_AM642) += am642_init.o obj-$(CONFIG_SOC_K3_AM625) += am625_init.o obj-$(CONFIG_SOC_K3_AM62A7) += am62a7_init.o +obj-$(CONFIG_SOC_K3_J784S4) += j784s4_init.o obj-$(CONFIG_K3_LOAD_SYSFW)
Re: [PATCH v2 1/3] dt-bindings: mtd: fixed-partitions: Add binman compatible
Hi, >> Add a compatible string for binman, so we can extend fixed-partitions >> in various ways. > > I've been thinking at the proper way to describe the binman partitions. > I am wondering if we should really extend the fixed-partitions > schema. This description is really basic and kind of supposed to remain > like that. Instead, I wonder if we should not just keep the binman > compatible alone, like many others already. This way it would be very clear > what is expected and allowed in both cases. I am thinking about > something like that: > > Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml > > this file is also referenced there (but this patch does the same, which > is what I'd expect): > > Documentation/devicetree/bindings/mtd/partitions/partitions.yaml > > I'll let the binding maintainers judge whether they think it's > relevant, it's not a strong opposition. What is the overall goal here? To replace the current binman node which is usually contained in the -u-boot.dtsi files? If one is using binman to create an image, is it expected that one needs to adapt the DT in linux? Or will it still be a seperate -u-boot.dtsi? > Because in the latter case I see that there will be conflicts because you have to overwrite the flash node. Or will it be a seperate node with all the information duplicated? The goal is simply to have a full binding for firmware layout, such that firmware images can be created, examined and updated. The -u-boot.dtsi files are a stopgap while we sort out a real binding. They should eventually go away. You haven't answered whether this node should be a seperate binman node - or if you'll reuse the existing flash (partitions) node(s) and add any missing property there. If it's the latter, I don't think compatible = "binman", "fixed-partitions"; is correct. Maybe (a more complete) example would be helpful. Can you please be a bit more specific? What is missing from the example? Like a complete (stripped) DTS. Right now I just see how the individual node looks like. But with a complete example DTS, my question from above would have been answered. What if a board uses eMMC to store the firmware binaries? Will that then be a subnode to the eMMC device? -michael
[PATCH v4 0/2] J7200 device tree sync from v6.6-rc1 to u-boot
This series tries to sync device tree files from Linux v6.6-rc1 while making changes to the u-boot.dtsi and r5-common-proc-board.dts files in order to remove duplicate nodes and achieve successful boot. DMA fixes [0] are currently being upstreamed to Linux. They'll be fixed in U-boot post their merge in Linux. Previous version of patch no longer boots in next branch due to a recent change with how bootph-pre-ram now works [2]. Changes have been in this version to avoid future issues with that. Boot log is included in [1] [0]: https://lore.kernel.org/all/20230810174356.3322583-1-vigne...@ti.com/ [1]: https://gist.github.com/reidt1/3bc6c5a0230346a5136aa857485b2cdb [2]: https://lore.kernel.org/u-boot/capnjgz3mgwx8t0a0sofpher_xd77pe3hte9dnye1rubveb9...@mail.gmail.com/ --- Changes in v4: - Changed bootph-pre-ram to bootph-all in response to [2] - Removed serdes.h from series since it has been added already - Rebased off of "ec6f06bddc configs: Resync with savedefconfig" - Removed reviewed-by on patch 2 due to changes - Link to v3: https://lore.kernel.org/u-boot/20230918171813.11407-3-re...@ti.com/ Reid Tonking (2): arm: mach-k3: j7200: Add mcu_timer0 id to the dev list arm: dts: j7200: dts sync with Linux 6.6-rc1 .../k3-j7200-common-proc-board-u-boot.dtsi| 208 +++ arch/arm/dts/k3-j7200-common-proc-board.dts | 186 +++--- arch/arm/dts/k3-j7200-main.dtsi | 535 +- arch/arm/dts/k3-j7200-mcu-wakeup.dtsi | 286 +- .../arm/dts/k3-j7200-r5-common-proc-board.dts | 311 +- arch/arm/dts/k3-j7200-som-p0.dtsi | 154 +++-- arch/arm/dts/k3-j7200-thermal.dtsi| 47 ++ arch/arm/dts/k3-j7200.dtsi| 30 +- arch/arm/mach-k3/j7200/dev-data.c | 1 + 9 files changed, 1212 insertions(+), 546 deletions(-) create mode 100644 arch/arm/dts/k3-j7200-thermal.dtsi -- 2.34.1
[PATCH v4 2/2] arm: dts: j7200: dts sync with Linux 6.6-rc1
Sync j7200 dts with Linux 6.6-rc1 - k3-j7200-r5-common-proc-board.dts now inherits from k3-j7200-common-proc-board.dts instead of k3-j7200-som-p0.dtsi. This allows us to trim down the r5 file considerably by using existing properties - remove pimux nodes from r5 file - remove duplicate nodes & node properties from r5/u-boot files - mcu_timer0 now used instead of timer1 mcu_timer0 device id added to dev-data.c file in order to work - remove cpsw node This node is no longer required since the compatible is now fixed - remove dummy_clock_19_2_mhz This node wasn't being used anyhere, so it was removed - remove dummy_clock_200mhz main_sdhci0 & main_sdhci1 no longer need dummy clock for eMMC/SD - fix secure proxy node mcu_secproxy changed to used secure_prxy_mcu which is already defined in k3-j7200-mcu-wakeup.dtsi - removed &mcu_ringacc property override since they're present in v6.6-rc1 Signed-off-by: Reid Tonking --- .../k3-j7200-common-proc-board-u-boot.dtsi| 208 +++ arch/arm/dts/k3-j7200-common-proc-board.dts | 186 +++--- arch/arm/dts/k3-j7200-main.dtsi | 535 +- arch/arm/dts/k3-j7200-mcu-wakeup.dtsi | 286 +- .../arm/dts/k3-j7200-r5-common-proc-board.dts | 311 +- arch/arm/dts/k3-j7200-som-p0.dtsi | 154 +++-- arch/arm/dts/k3-j7200-thermal.dtsi| 47 ++ arch/arm/dts/k3-j7200.dtsi| 30 +- 8 files changed, 1211 insertions(+), 546 deletions(-) create mode 100644 arch/arm/dts/k3-j7200-thermal.dtsi diff --git a/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi index f25c7136c9..60ca6d21ab 100644 --- a/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi +++ b/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi @@ -1,200 +1,210 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2020 Texas Instruments Incorporated - https://www.ti.com/ + * Copyright (C) 2020-2023 Texas Instruments Incorporated - https://www.ti.com/ */ #include "k3-j7200-binman.dtsi" / { chosen { - stdout-path = "serial2:115200n8"; - tick-timer = &timer1; - }; - - aliases { - ethernet0 = &cpsw_port1; - i2c0 = &wkup_i2c0; - i2c1 = &mcu_i2c0; - i2c2 = &mcu_i2c1; - i2c3 = &main_i2c0; + tick-timer = &mcu_timer0; }; }; &cbass_main { - bootph-pre-ram; + bootph-all; }; &main_navss { - bootph-pre-ram; + bootph-all; +}; + +&main_esm { + bootph-all; }; &cbass_mcu_wakeup { - bootph-pre-ram; - - timer1: timer@4040 { - compatible = "ti,omap5430-timer"; - reg = <0x0 0x4040 0x0 0x80>; - ti,timer-alwon; - clock-frequency = <25000>; - bootph-pre-ram; - }; + bootph-all; chipid@4314 { - bootph-pre-ram; + bootph-all; }; +}; - mcu_navss: bus@2838 { - bootph-pre-ram; - #address-cells = <2>; - #size-cells = <2>; - - ringacc@2b80 { - reg = <0x0 0x2b80 0x0 0x40>, - <0x0 0x2b00 0x0 0x40>, - <0x0 0x2859 0x0 0x100>, - <0x0 0x2a50 0x0 0x4>, - <0x0 0x2844 0x0 0x4>; - reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target", "cfg"; - bootph-pre-ram; - }; - - dma-controller@285c { - reg = <0x0 0x285c 0x0 0x100>, - <0x0 0x284c 0x0 0x4000>, - <0x0 0x2a80 0x0 0x4>, - <0x0 0x284a 0x0 0x4000>, - <0x0 0x2aa0 0x0 0x4>, - <0x0 0x2840 0x0 0x2000>; - reg-names = "gcfg", "rchan", "rchanrt", "tchan", - "tchanrt", "rflow"; - bootph-pre-ram; - }; - }; +&mcu_navss { + bootph-all; +}; + +&mcu_ringacc { + bootph-all; +}; + +&mcu_udmap { + reg = <0x0 0x285c 0x0 0x100>, + <0x0 0x284c 0x0 0x4000>, + <0x0 0x2a80 0x0 0x4>, + <0x0 0x284a 0x0 0x4000>, + <0x0 0x2aa0 0x0 0x4>, + <0x0 0x2840 0x0 0x2000>; + reg-names = "gcfg", "rchan", "rchanrt", "tchan", + "tchanrt", "rflow"; + bootph-all; }; &secure_proxy_main { - bootph-pre-ram; + bootph-all; }; &dmsc { - bootph-pre-ram; + bootph-all; k3_sysreset: sysreset-controller {
[PATCH v4 1/2] arm: mach-k3: j7200: Add mcu_timer0 id to the dev list
mcu_timer0 is now used as the tick timer in u-boot, so this adds the timer to the soc device list so it can be enabled via the k3 power controller. Reviewed-by: Nishanth Menon Signed-off-by: Reid Tonking --- arch/arm/mach-k3/j7200/dev-data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-k3/j7200/dev-data.c b/arch/arm/mach-k3/j7200/dev-data.c index 4ddc34210e..8ce6796fd0 100644 --- a/arch/arm/mach-k3/j7200/dev-data.c +++ b/arch/arm/mach-k3/j7200/dev-data.c @@ -46,6 +46,7 @@ static struct ti_lpsc soc_lpsc_list[] = { static struct ti_dev soc_dev_list[] = { PSC_DEV(30, &soc_lpsc_list[0]), + PSC_DEV(35, &soc_lpsc_list[0]), PSC_DEV(61, &soc_lpsc_list[1]), PSC_DEV(90, &soc_lpsc_list[2]), PSC_DEV(8, &soc_lpsc_list[3]), -- 2.34.1
[RFC PATCH v10 24/24] DO NOT MERGE: ci: Build the world in any case.
The CI can fails previously for reasons which are not tied to hush 2021. Let's build the world in any case to check everything is OK there too. Signed-off-by: Francis Laniel --- .azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index da701e42da..3417722b21 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -447,6 +447,7 @@ stages: retryCountOnTaskFailure: 2 # QEMU may be too slow, etc. - stage: world_build + condition: always() jobs: - job: build_the_world timeoutInMinutes: 0 # Use the maximum allowed -- 2.34.1
[RFC PATCH v10 23/24] DO NOT MERGE: only to make CI happy
This commit set CONFIG_HUSH_PARSER_2021 as the default to trigger the CI with this parser. Nonetheless, the keymile (i.e. VENDOR_KM) board family is not compatible with new 2021 hush parser. Indeed, This boards used set_local_var() to store some variables as local shell. They then used get_local_var() to retrieve the variables values. Sadly, this two functions do not exist with CONFIG_HUSH_PARSER_2021. A patch was proposed to use environment variables rather than local variables but it does not tackle the problem, so complementary work is needed to make this boards use CONFIG_HUSH_PARSER_2021 [1]. We also remove a #undef of CONFIG_FEATURE_SH_STANDALONE as it does not exist in U-Boot and causes troubles in the CI. We also set CONFIG_LTO for kirkwoord sheevaplug and phytec bk4r1, otherwise it hits its board size limit. We also disable some check for pylint as it was not able to find future for commit object. Acked-by: Tony Dinh Signed-off-by: Francis Laniel [1] https://marc.info/?l=u-boot&m=165541917618725&w=2 --- cmd/Kconfig | 3 ++- common/cli_hush_upstream.c | 1 - configs/sheevaplug_defconfig | 1 + tools/patman/series.py | 4 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 36595638a2..e113ed49ac 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -28,7 +28,7 @@ menu "Hush flavor to use" config HUSH_OLD_PARSER bool "Use hush old parser" - default y + default y if VENDOR_KM help This option enables the old flavor of hush based on hush Busybox from 2005. @@ -37,6 +37,7 @@ menu "Hush flavor to use" config HUSH_2021_PARSER bool "Use hush 2021 parser" + default y if !VENDOR_KM help This option enables the new flavor of hush based on hush Busybox from 2021. diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index 709c055d2f..243710ab51 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -427,7 +427,6 @@ #include "NUM_APPLETS.h" #if NUM_APPLETS == 1 /* STANDALONE does not make sense, and won't compile */ -# undef CONFIG_FEATURE_SH_STANDALONE # undef ENABLE_FEATURE_SH_STANDALONE # undef IF_FEATURE_SH_STANDALONE # undef IF_NOT_FEATURE_SH_STANDALONE diff --git a/configs/sheevaplug_defconfig b/configs/sheevaplug_defconfig index 2e4901b840..365f779cc8 100644 --- a/configs/sheevaplug_defconfig +++ b/configs/sheevaplug_defconfig @@ -16,6 +16,7 @@ CONFIG_ENV_OFFSET=0x8 CONFIG_DEFAULT_DEVICE_TREE="kirkwood-sheevaplug" CONFIG_IDENT_STRING="\nMarvell-Sheevaplug" CONFIG_SYS_LOAD_ADDR=0x80 +CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=524288 CONFIG_BOOTDELAY=3 diff --git a/tools/patman/series.py b/tools/patman/series.py index 6866e1dbd0..f99818e33a 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -316,6 +316,8 @@ class Series(dict): # Show progress any commits that are taking forever lastlen = 0 while True: +# pylint does not find future which is set above. +# pylint: disable=E1101 left = [commit for commit in self.commits if not commit.future.done()] if not left: @@ -333,6 +335,8 @@ class Series(dict): print('Cc processing complete') for commit in self.commits: +# pylint does not find future which is set above. +# pylint: disable=E1101 cc = commit.future.result() all_ccs += cc print(commit.patch, '\0'.join(sorted(set(cc))), file=fd) -- 2.34.1
[RFC PATCH v10 22/24] cli: hush_2021: Add upstream commits up to 2nd October 2023.
This commit adds the following hush busybox upstream commits: 791b222dd55d ("sleep: fix "sleep -- ARGS"") 5353df91cba7 ("Update applet size estimates") e41e481fd571 ("hush: fix a compile failure") 07a95cfcabb0 ("ash: disable check for "good" function name, bash does not check this") e5692e2342c6 ("hush: quote values in "readonly" output") 96769486e20f ("shell: move varcmp() to shell_common.h and use it in hush") bab8828b0dad ("hush: fix expansion of space in "a=${a:+$a }c" construct") b5be8da350b5 ("hush: make "false" built-in") 6824298ab4d3 ("hush: fix ELIF cmd1;cmd2 THEN ... not executing cmd2, closes 15571") 3a7f00eadcf4 ("hush: add comment about abort on syntax error %{^}") acae889dd972 ("ash,hush: tab completion of functions and aliases") 90b607d79a13 ("hush: quote variable values printed by "set" (match ash behavior)") 6748e6494c22 ("hush (NOMMU): fix LINENO in execed children") fd5fb2d2b596 ("hush: speed up "big heredoc" code") 1409432d072e ("hush: add TODO comment") 93ae7464e6e4 ("hush: restore SIGHUP handling, this time explain why we do what we do") 1fdb33bd07e5 ("hush: restore tty pgrp on SIGHUP") 6101b6d3eaa0 ("hush: remove special handling of SIGHUP") 93e0898c663a ("shell: fix SIGWINCH and SIGCHLD (in hush) interrupting line input, closes 15256") 969e00816835 ("hush: code shrink") 27be0e8cfeb6 ("shell: fix compile failures in some configs") 7d1c7d833785 ("ash,hush: use HOME for tab completion and prompts") 21afddefd258 ("hush: fix "error: invalid preprocessing directive ##"") e53c7dbafc78 ("hush: fix set -n to act immediately, not just after run_list()") 574b9c446da1 ("hush: fix var_LINENO3.tests failure") 49bcf9f40cff ("hush: speed up ${x//\*/|} too") 53b2fdcdba4c ("*: add NOINLINEs where code noticeably shrinks") 7c3e96d4b3d4 ("shell: use more compact SHELL_ASH / HUSH config defines. no code changes") 62f1eed1e191 ("hush: in a comment, document what -i might be doing") aaf3d5ba74c5 ("shell: tweak --help") db5546ca1018 ("libbb: code shrink: introduce and use [_]exit_SUCCESS()") 931c55f9e2b4 ("libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> SETUP_ENV_CHDIR") 12566e7f9b5e ("ash,hush: fix handling of SIGINT while waiting for interactive input") 987be932ed3c ("*: slap on a few ALIGN_PTR where appropriate") Signed-off-by: Francis Laniel --- common/cli_hush_2021.c | 20 +- common/cli_hush_upstream.c | 407 ++--- 2 files changed, 304 insertions(+), 123 deletions(-) diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c index 0a207d147b..15a5d3134e 100644 --- a/common/cli_hush_2021.c +++ b/common/cli_hush_2021.c @@ -26,7 +26,7 @@ /* * BusyBox Version: UPDATE THIS WHEN PULLING NEW UPSTREAM REVISION! */ -#define BB_VER "1.34.0.git37460f5daff9" +#define BB_VER "1.35.0.git7d1c7d833785" /* * Define hush features by the names used upstream. @@ -236,6 +236,24 @@ static size_t list_size(char **list) return size; } +static int varcmp(const char *p, const char *q) +{ + int c, d; + + while ((c = *p) == (d = *q)) { + if (c == '\0' || c == '=') + goto out; + p++; + q++; + } + if (c == '=') + c = '\0'; + if (d == '=') + d = '\0'; +out: + return c - d; +} + struct in_str; static int u_boot_cli_readline(struct in_str *i); diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index 23392939e1..709c055d2f 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -91,7 +91,7 @@ * in word = GLOB, quoting should be significant on char-by-char basis: a*cd"*" */ //config:config HUSH -//config: bool "hush (68 kb)" +//config: bool "hush (70 kb)" //config: default y //config: select SHELL_HUSH //config: help @@ -339,7 +339,7 @@ * therefore we don't show them either. */ //usage:#define hush_trivial_usage -//usage: "[-enxl] [-c 'SCRIPT' [ARG0 ARGS] | FILE [ARGS] | -s [ARGS]]" +//usage: "[-enxl] [-c 'SCRIPT' [ARG0 ARGS] | FILE ARGS | -s ARGS]" //usage:#define hush_full_usage "\n\n" //usage: "Unix shell interpreter" @@ -374,7 +374,7 @@ # define F_DUPFD_CLOEXEC F_DUPFD #endif -#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !(ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH) +#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !ENABLE_SHELL_ASH # include "embedded_scripts.h" #else # define NUM_SCRIPTS 0 @@ -574,7 +574,7 @@ enum { #define NULL_O_STRING { NULL } #ifndef debug_printf_parse -static const char *const assignment_flag[] = { +static const char *const assignment_flag[] ALIGN_PTR = { "MAYBE_ASSIGNMENT", "DEFINITELY_ASSIGNMENT", "NOT_ASSIGNMENT", @@ -958,6 +958,7 @@ struct globals { #if ENABLE_HUSH_INTERACTIVE smallint promptmode; /* 0: PS1, 1: PS2 */ #endif + /* set by signal handler if SIGINT is received _and_ its trap is not set */ smallint fla
[RFC PATCH v10 21/24] test: hush: Fix loop tests for hush 2021
Modifies return code got from while loop as hush 2021 always returns 0 from while loop. Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- test/hush/loop.c | 34 ++ 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/test/hush/loop.c b/test/hush/loop.c index ca777e38fe..add5402a32 100644 --- a/test/hush/loop.c +++ b/test/hush/loop.c @@ -9,6 +9,9 @@ #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; static int hush_test_for(struct unit_test_state *uts) { @@ -21,7 +24,12 @@ static int hush_test_for(struct unit_test_state *uts) ut_assert_nextline("quux"); ut_assert_console_end(); - puts("Beware: this test set local variable loop_i and it cannot be unset!"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* Reset local variable. */ + ut_assertok(run_command("loop_i=", 0)); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + puts("Beware: this test set local variable loop_i and it cannot be unset!"); + } return 0; } @@ -31,12 +39,30 @@ static int hush_test_while(struct unit_test_state *uts) { console_record_reset_enable(); - /* Exit status is that of test, so 1 since test is false to quit the loop. */ - ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do echo bar; loop_foo=quux; done", 0)); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* Hush 2021 always returns 0 from while loop... +* You can see code snippet near this line to have a better +* understanding: +* debug_printf_exec(": while expr is false: breaking (exitcode:EXIT_SUCCESS)\n"); +*/ + ut_assertok(run_command("while test -z \"$loop_foo\"; do echo bar; loop_foo=quux; done", 0)); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + /* +* Exit status is that of test, so 1 since test is false to quit +* the loop. +*/ + ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do echo bar; loop_foo=quux; done", 0)); + } ut_assert_nextline("bar"); ut_assert_console_end(); - puts("Beware: this test set local variable loop_foo and it cannot be unset!"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* Reset local variable. */ + ut_assertok(run_command("loop_foo=", 0)); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + puts("Beware: this test set local variable loop_foo and it cannot be unset!"); + } return 0; } -- 2.34.1
[RFC PATCH v10 18/24] cli: hush_2021: Enable using < and > as string compare operators
In Busybox hush, '<' and '>' are used as redirection operators. For example, cat foo > bar will write content of file foo inside file bar. In U-Boot, we do not have file system, so we can hardly redirect command output inside a file. But, in actual U-Boot hush, these operators ('<' and '>') are used as string compare operators. For example, test aaa < bbb returns 0 as aaa is before bbb in the dictionary. Busybox hush also permits this, but operators need to be escaped ('\<' and '\>'). Indeed, if escaping is needed it permits the developer to think about its code, as in a lot of case, we want to compare integers (using '-lt' or '-gt') rather than strings. As testing in U-Boot is handled by the test command, we will stick with the original behaviour and not adapt to Busybox one. Nonetheless, if one day we decide to implement test with '[[ ]]', we will then stick to upstream Busybox behavior. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- common/cli_hush_upstream.c | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index dbf77ad503..68a9a4bb72 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -6160,7 +6160,28 @@ static struct pipe *parse_stream(char **pstring, if (parse_redirect(&ctx, redir_fd, redir_style, input)) goto parse_error_exitcode1; continue; /* get next char */ -#endif /* !__U_BOOT__ */ +#else /* __U_BOOT__ */ + /* +* In U-Boot, '<' and '>' can be used in test command to test if +* a string is, alphabetically, before or after another. +* In 2021 Busybox hush, we will keep the same behavior and so not treat +* them as redirection operator. +* +* Indeed, in U-Boot, tests are handled by the test command and not by the +* shell code. +* So, better to give this character as input to test command. +* +* NOTE In my opinion, when you use '<' or '>' I am almost sure +* you wanted to use "-gt" or "-lt" in place, so thinking to +* escape these will make you should check your code (sh syntax +* at this level is, for me, error prone). +*/ + case '>': + fallthrough; + case '<': + o_addQchr(&ctx.word, ch); + continue; +#endif /* __U_BOOT__ */ case '#': if (ctx.word.length == 0 && !ctx.word.has_quoted_part) { /* skip "#comment" */ -- 2.34.1
[RFC PATCH v10 17/24] test: hush: Fix variable expansion tests for hush 2021
Modifies the expected result for hush 2021. Indeed, there were bugs in actual U-Boot hush which were fixed in upstream Busybox. As hush 2021 is based on upstream Busybox, these bugs no longer exist. Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- test/hush/dollar.c | 79 -- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/test/hush/dollar.c b/test/hush/dollar.c index defb2c3fd0..f23392c72d 100644 --- a/test/hush/dollar.c +++ b/test/hush/dollar.c @@ -9,6 +9,9 @@ #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; static int hush_test_simple_dollar(struct unit_test_state *uts) { @@ -51,13 +54,29 @@ static int hush_test_simple_dollar(struct unit_test_state *uts) ut_asserteq(1, run_command("dollar_foo='bar quux", 0)); /* Next line contains error message */ ut_assert_skipline(); - ut_assert_console_end(); + + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* For some strange reasons, the console is not empty after +* running above command. +* So, we reset it to not have side effects for other tests. +*/ + console_record_reset_enable(); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_assert_console_end(); + } ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0)); /* Two next lines contain error message */ ut_assert_skipline(); ut_assert_skipline(); - ut_assert_console_end(); + + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* See above comments. */ + console_record_reset_enable(); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_assert_console_end(); + } ut_assertok(run_command("dollar_foo='bar \"quux'", 0)); @@ -71,17 +90,35 @@ static int hush_test_simple_dollar(struct unit_test_state *uts) */ console_record_reset_enable(); - ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0)); - /* Next line contains error message */ - ut_assert_skipline(); - ut_assert_console_end(); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* Old parser returns an error because it waits for closing +* '\'', but this behavior is wrong as the '\'' is surrounded by +* '"', so no need to wait for a closing one. +*/ + ut_assertok(run_command("dollar_foo=\"bar 'quux\"", 0)); + + ut_assertok(run_command("echo $dollar_foo", 0)); + ut_assert_nextline("bar 'quux"); + ut_assert_console_end(); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0)); + /* Next line contains error message */ + ut_assert_skipline(); + ut_assert_console_end(); + } ut_assertok(run_command("dollar_foo='bar quux'", 0)); ut_assertok(run_command("echo $dollar_foo", 0)); ut_assert_nextline("bar quux"); ut_assert_console_end(); - puts("Beware: this test set local variable dollar_foo and it cannot be unset!"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* Reset local variable. */ + ut_assertok(run_command("dollar_foo=", 0)); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + puts("Beware: this test set local variable dollar_foo and it cannot be unset!"); + } return 0; } @@ -109,7 +146,12 @@ static int hush_test_env_dollar(struct unit_test_state *uts) /* Clean up setting the variable */ env_set("env_foo", NULL); - puts("Beware: this test set local variable env_foo and it cannot be unset!"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* Reset local variable. */ + ut_assertok(run_command("env_foo=", 0)); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + puts("Beware: this test set local variable env_foo and it cannot be unset!"); + } return 0; } @@ -144,7 +186,18 @@ static int hush_test_command_dollar(struct unit_test_state *uts) ut_assertok(run_command("dollar_bar='echo bar\\n'", 0)); ut_assertok(run_command("$dollar_bar", 0)); - ut_assert_nextline("barn"); + + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* This difference seems to come from a bug solved in Busybox +* hush. +* Behavior of hush 2021 is coherent with bash and other shells. +*/ + ut_assert_nextline("bar\\n"); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_assert_nextline("barn"); + } + ut_assert_console_end(); ut_assertok(run_com
[RFC PATCH v10 19/24] cli: hush_2021: Enable if keyword
Adds support for "if then else" construct both for command line interface and through run_command(). Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- common/cli_hush_2021.c | 11 +++ common/cli_hush_upstream.c | 12 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c index 7dd30ea0ef..aba5dcbbcd 100644 --- a/common/cli_hush_2021.c +++ b/common/cli_hush_2021.c @@ -33,6 +33,7 @@ */ #define ENABLE_HUSH_INTERACTIVE1 #define ENABLE_FEATURE_EDITING 1 +#define ENABLE_HUSH_IF 1 /* No MMU in U-Boot */ #define BB_MMU 0 #define USE_FOR_NOMMU(...) __VA_ARGS__ @@ -124,6 +125,11 @@ static void bb_error_msg(const char *s, ...) va_end(p); } +static void bb_simple_error_msg(const char *s) +{ + bb_error_msg("%s", s); +} + static void *xmalloc(size_t size) { void *p = NULL; @@ -147,6 +153,11 @@ static void *xrealloc(void *ptr, size_t size) return p; } +static void *xmemdup(const void *s, int n) +{ + return memcpy(xmalloc(n), s, n); +} + #define xstrdupstrdup #define xstrndup strndup diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index 68a9a4bb72..9b65dcbde1 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -1488,7 +1488,6 @@ static void msg_and_die_if_script(unsigned lineno, const char *fmt, ...) die_if_script(); } -#ifndef __U_BOOT__ static void syntax_error(unsigned lineno UNUSED_PARAM, const char *msg) { if (msg) @@ -1497,7 +1496,6 @@ static void syntax_error(unsigned lineno UNUSED_PARAM, const char *msg) bb_simple_error_msg("syntax error"); die_if_script(); } -#endif /* !__U_BOOT__ */ static void syntax_error_at(unsigned lineno UNUSED_PARAM, const char *msg) { @@ -3962,7 +3960,6 @@ static void debug_print_tree(struct pipe *pi, int lvl) [PIPE_OR ] = "OR" , [PIPE_BG ] = "BG" , }; -#ifndef __U_BOOT__ static const char *RES[] = { [RES_NONE ] = "NONE" , # if ENABLE_HUSH_IF @@ -3992,7 +3989,6 @@ static void debug_print_tree(struct pipe *pi, int lvl) [RES_ ] = "" , [RES_SNTX ] = "SNTX" , }; -#endif /* !__U_BOOT__ */ static const char *const CMDTYPE[] = { "{}", "()", @@ -4010,10 +4006,8 @@ static void debug_print_tree(struct pipe *pi, int lvl) lvl*2, "", pin, pi->num_cmds, -#ifdef __U_BOOT__ (IF_HAS_KEYWORDS(pi->pi_inverted ? "! " :) ""), RES[pi->res_word], -#endif /* !__U_BOOT__ */ pi->followup, PIPE[pi->followup] ); prn = 0; @@ -9833,6 +9827,7 @@ static NOINLINE int run_pipe(struct pipe *pi) rcode = 1; /* exitcode if redir failed */ #ifndef __U_BOOT__ if (setup_redirects(command, &squirrel) == 0) { +#endif /* !__U_BOOT__ */ debug_printf_exec(": run_list\n"); //FIXME: we need to pass squirrel down into run_list() //for SH_STANDALONE case, or else this construct: @@ -9841,10 +9836,11 @@ static NOINLINE int run_pipe(struct pipe *pi) //and in SH_STANDALONE mode, "find" is not execed, //therefore CLOEXEC on saved fd does not help. rcode = run_list(command->group) & 0xff; +#ifndef __U_BOOT__ } restore_redirects(squirrel); - IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;) #endif /* !__U_BOOT__ */ + IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;) debug_leave(); debug_printf_exec("run_pipe: return %d\n", rcode); return rcode; @@ -10363,12 +10359,12 @@ static int run_list(struct pipe *pi) break; if (G_flag_return_in_progress == 1) break; +#endif /* !__U_BOOT__ */ IF_HAS_KEYWORDS(rword = pi->res_word;) debug_printf_exec(": rword=%d cond_code=%d last_rword=%d\n", rword, cond_code, last_rword); -#endif /* !__U_BOOT__ */ sv_errexit_depth = G.errexit_depth; if ( #if ENABLE_HUSH_IF -- 2.34.1
[RFC PATCH v10 20/24] cli: hush_2021: Enable loops
Enables the use of for, while and until loops for command line as well as with run_command(). Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- common/cli_hush_2021.c | 1 + common/cli_hush_upstream.c | 15 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c index aba5dcbbcd..0a207d147b 100644 --- a/common/cli_hush_2021.c +++ b/common/cli_hush_2021.c @@ -34,6 +34,7 @@ #define ENABLE_HUSH_INTERACTIVE1 #define ENABLE_FEATURE_EDITING 1 #define ENABLE_HUSH_IF 1 +#define ENABLE_HUSH_LOOPS 1 /* No MMU in U-Boot */ #define BB_MMU 0 #define USE_FOR_NOMMU(...) __VA_ARGS__ diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index 9b65dcbde1..23392939e1 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -10349,7 +10349,7 @@ static int run_list(struct pipe *pi) #ifndef __U_BOOT__ for (; pi; pi = IF_HUSH_LOOPS(rword == RES_DONE ? loop_top : ) pi->next) { #else /* __U_BOOT__ */ - for (; pi; pi = pi->next) { + for (; pi; pi = rword == RES_DONE ? loop_top : pi->next) { #endif /* __U_BOOT__ */ int r; int sv_errexit_depth; @@ -10451,7 +10451,20 @@ static int run_list(struct pipe *pi) } /* Insert next value from for_lcur */ /* note: *for_lcur already has quotes removed, $var expanded, etc */ +#ifndef __U_BOOT__ set_local_var(xasprintf("%s=%s", pi->cmds[0].argv[0], *for_lcur++), /*flag:*/ 0); +#else /* __U_BOOT__ */ + /* We cannot use xasprintf, so we emulate it. */ + char *full_var; + char *var = pi->cmds[0].argv[0]; + char *val = *for_lcur++; + + /* + 1 to take into account =. */ + full_var = xmalloc(strlen(var) + strlen(val) + 1); + sprintf(full_var, "%s=%s", var, val); + + set_local_var_2021(full_var, /*flag:*/ 0); +#endif /* __U_BOOT__ */ continue; } if (rword == RES_IN) { -- 2.34.1
[RFC PATCH v10 16/24] test: hush: Fix instructions list tests for hush 2021
Modifies the expected result for hush 2021. Indeed, there were bugs in actual U-Boot hush which were fixed in upstream Busybox. As hush 2021 is based on upstream Busybox, these bugs no longer exist. Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- test/hush/list.c | 69 +--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/test/hush/list.c b/test/hush/list.c index 052cf2783c..6f8f10f15e 100644 --- a/test/hush/list.c +++ b/test/hush/list.c @@ -9,6 +9,7 @@ #include #include #include +#include static int hush_test_semicolon(struct unit_test_state *uts) { @@ -46,12 +47,43 @@ static int hush_test_or(struct unit_test_state *uts) } HUSH_TEST(hush_test_or, 0); +DECLARE_GLOBAL_DATA_PTR; + static int hush_test_and_or(struct unit_test_state *uts) { /* A && B || C truth table. */ ut_asserteq(1, run_command("false && false || false", 0)); - ut_asserteq(1, run_command("false && false || true", 0)); - ut_asserteq(1, run_command("false && true || true", 0)); + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_asserteq(1, run_command("false && false || true", 0)); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* This difference seems to come from a bug solved in Busybox +* hush. +* +* Indeed, the following expression can be seen like this: +* (false && false) || true +* So, (false && false) returns 1, the second false is not +* executed, and true is executed because of ||. +*/ + ut_assertok(run_command("false && false || true", 0)); + } + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_asserteq(1, run_command("false && true || true", 0)); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* This difference seems to come from a bug solved in Busybox +* hush. +* +* Indeed, the following expression can be seen like this: +* (false && true) || true +* So, (false && true) returns 1, the true is not executed, and +* true is executed because of ||. +*/ + ut_assertok(run_command("false && true || true", 0)); + } + ut_asserteq(1, run_command("false && true || false", 0)); ut_assertok(run_command("true && true || false", 0)); ut_asserteq(1, run_command("true && false || false", 0)); @@ -69,8 +101,37 @@ static int hush_test_or_and(struct unit_test_state *uts) ut_asserteq(1, run_command("false || false && true", 0)); ut_assertok(run_command("false || true && true", 0)); ut_asserteq(1, run_command("false || true && false", 0)); - ut_assertok(run_command("true || true && false", 0)); - ut_assertok(run_command("true || false && false", 0)); + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_assertok(run_command("true || true && false", 0)); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* This difference seems to come from a bug solved in Busybox +* hush. +* +* Indeed, the following expression can be seen like this: +* (true || true) && false +* So, (true || true) returns 0, the second true is not +* executed, and then false is executed because of &&. +*/ + ut_asserteq(1, run_command("true || true && false", 0)); + } + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_assertok(run_command("true || false && false", 0)); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* This difference seems to come from a bug solved in Busybox +* hush. +* +* Indeed, the following expression can be seen like this: +* (true || false) && false +* So, (true || false) returns 0, the false is not executed, and +* then false is executed because of &&. +*/ + ut_asserteq(1, run_command("true || false && false", 0)); + } + ut_assertok(run_command("true || false && true", 0)); ut_assertok(run_command("true || true && true", 0)); -- 2.34.1
[RFC PATCH v10 15/24] cli: add hush 2021 as parser for run_command*()
Enables using, in code, hush 2021 as parser for run_command function family. It also enables the command run to be used by CLI user of hush 2021. Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- common/cli.c | 63 -- common/cli_hush_upstream.c | 2 +- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/common/cli.c b/common/cli.c index e3e2bc7fe1..899007da9d 100644 --- a/common/cli.c +++ b/common/cli.c @@ -43,14 +43,31 @@ int run_command(const char *cmd, int flag) return 1; return 0; -#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER) - int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP; - - if (flag & CMD_FLAG_ENV) - hush_flags |= FLAG_CONT_ON_NEWLINE; - return parse_string_outer(cmd, hush_flags); -#else /* HUSH_2021_PARSER */ - /* Not yet implemented. */ +#else + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP; + + if (flag & CMD_FLAG_ENV) + hush_flags |= FLAG_CONT_ON_NEWLINE; + return parse_string_outer(cmd, hush_flags); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* +* Possible values for flags are the following: +* FLAG_EXIT_FROM_LOOP: This flags ensures we exit from loop in +* parse_and_run_stream() after first iteration while normal +* behavior, * i.e. when called from cli_loop(), is to loop +* infinitely. +* FLAG_PARSE_SEMICOLON: Hush 2021 parses ';' and does not stop +* first time it sees one. So, I think we do not need this flag. +* FLAG_REPARSING: For the moment, I do not understand the goal +* of this flag. +* FLAG_CONT_ON_NEWLINE: This flag seems to be used to continue +* parsing even when reading '\n' when coming from +* run_command(). In this case, Hush 2021 reads until it finds +* '\0'. So, I think we do not need this flag. +*/ + return parse_string_outer_2021(cmd, FLAG_EXIT_FROM_LOOP); + } return 1; #endif } @@ -67,12 +84,25 @@ int run_command_repeatable(const char *cmd, int flag) #ifndef CONFIG_HUSH_PARSER return cli_simple_run_command(cmd, flag); #else + int ret; + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ret = parse_string_outer(cmd, +FLAG_PARSE_SEMICOLON +| FLAG_EXIT_FROM_LOOP); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + ret = parse_string_outer_2021(cmd, + FLAG_PARSE_SEMICOLON + | FLAG_EXIT_FROM_LOOP); + } else { + ret = 1; + } + /* * parse_string_outer() returns 1 for failure, so clean up * its result. */ - if (parse_string_outer(cmd, - FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP)) + if (ret) return -1; return 0; @@ -111,12 +141,13 @@ int run_command_list(const char *cmd, int len, int flag) buff[len] = '\0'; } #ifdef CONFIG_HUSH_PARSER -#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) - rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON); -#else /* HUSH_2021_PARSER */ - /* Not yet implemented. */ - rcode = 1; -#endif + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + rcode = parse_string_outer_2021(buff, FLAG_PARSE_SEMICOLON); + } else { + rcode = 1; + } #else /* * This function will overwrite any \n it sees with a \0, which diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index b11445c3ac..dbf77ad503 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -8023,7 +8023,7 @@ static int parse_and_run_string(const char *s) } #ifdef __U_BOOT__ -int parse_string_outer(const char *cmd, int flags) +int parse_string_outer_2021(const char *cmd, int flags) { int ret; int old_flags; -- 2.34.1
[RFC PATCH v10 14/24] cli: hush_2021: Add functions to be called from run_command()
run_command() is called internally by the command run and it can also be called directly from U-Boot code, e.g. to do unit tests. This commit adds this path to go to hush 2021. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- common/cli_hush_upstream.c | 66 -- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index b806c5c653..b11445c3ac 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -1012,6 +1012,7 @@ struct globals { #ifdef __U_BOOT__ int flag_repeat; int do_repeat; + int run_command_flags; #endif /* __U_BOOT__ */ char *ifs_whitespace; /* = G.ifs or malloced */ #ifndef __U_BOOT__ @@ -3005,7 +3006,24 @@ static int i_getch(struct in_str *i) if (i->p && *i->p != '\0') { ch = (unsigned char)*i->p++; goto out; +#ifndef __U_BOOT__ } +#else /* __U_BOOT__ */ + /* +* There are two ways for command to be called: +* 1. The first one is when they are typed by the user. +* 2. The second one is through run_command() (NOTE command run +* internally calls run_command()). +* +* In the second case, we do not get input from the user, so once we +* get a '\0', it means we need to stop. +* NOTE G.run_command_flags is only set on run_command call stack, so +* we use this to know if we come from user input or run_command(). +*/ + } else if (i->p && *i->p == '\0' && G.run_command_flags){ + return EOF; + } +#endif /* __U_BOOT__ */ #endif #ifndef __U_BOOT__ /* peek_buf[] is an int array, not char. Can contain EOF. */ @@ -3164,7 +3182,6 @@ static void setup_file_in_str(struct in_str *i) #endif /* !__U_BOOT__ */ } -#ifndef __U_BOOT__ static void setup_string_in_str(struct in_str *i, const char *s) { memset(i, 0, sizeof(*i)); @@ -3172,7 +3189,6 @@ static void setup_string_in_str(struct in_str *i, const char *s) i->p = s; } -#endif /* !__U_BOOT__ */ /* * o_string support @@ -7911,7 +7927,11 @@ static int run_and_free_list(struct pipe *pi); * NUL: parse all, execute, return * ';': parse till ';' or newline, execute, repeat till EOF */ +#ifndef __U_BOOT__ static void parse_and_run_stream(struct in_str *inp, int end_trigger) +#else /* __U_BOOT__ */ +static int parse_and_run_stream(struct in_str *inp, int end_trigger) +#endif /* __U_BOOT__ */ { /* Why we need empty flag? * An obscure corner case "false; ``; echo $?": @@ -7920,7 +7940,11 @@ static void parse_and_run_stream(struct in_str *inp, int end_trigger) * this breaks "false; echo `echo $?`" case. */ bool empty = 1; +#ifndef __U_BOOT__ while (1) { +#else /* __U_BOOT__ */ + do { +#endif /* __U_BOOT__ */ struct pipe *pipe_list; #if ENABLE_HUSH_INTERACTIVE @@ -7967,21 +7991,57 @@ static void parse_and_run_stream(struct in_str *inp, int end_trigger) empty = 0; if (G_flag_return_in_progress == 1) break; +#ifndef __U_BOOT__ } +#else /* __U_BOOT__ */ + /* +* This do/while is needed by run_command to avoid looping on a command +* with syntax error. +*/ + } while (!(G.run_command_flags & FLAG_EXIT_FROM_LOOP)); + + return G.last_exitcode; +#endif /* __U_BOOT__ */ } #ifndef __U_BOOT__ static void parse_and_run_string(const char *s) +#else /* __U_BOOT__ */ +static int parse_and_run_string(const char *s) +#endif /* __U_BOOT__ */ { struct in_str input; //IF_HUSH_LINENO_VAR(unsigned sv = G.parse_lineno;) setup_string_in_str(&input, s); +#ifndef __U_BOOT__ parse_and_run_stream(&input, '\0'); +#else /* __U_BOOT__ */ + return parse_and_run_stream(&input, '\0'); +#endif /* __U_BOOT__ */ //IF_HUSH_LINENO_VAR(G.parse_lineno = sv;) } -#endif /* !__U_BOOT__ */ +#ifdef __U_BOOT__ +int parse_string_outer(const char *cmd, int flags) +{ + int ret; + int old_flags; + + /* +* Keep old values of run_command to be able to restore them once +* command was executed. +*/ + old_flags = G.run_command_flags; + G.run_command_flags = flags; + + ret = parse_and_run_string(cmd); + + G.run_command_flags = old_flags; + + return ret; +} +#endif /* __U_BOOT__ */ #ifndef __U_BOOT__ static void parse_and_run_file(HFILE *fp) #else /* __U_BOOT__ */ -- 2.34.1
[RFC PATCH v10 13/24] cli: hush_2021: Enable variables expansion for hush 2021
Enables variables expansion for hush 2021, both for local and environment variables. So the following commands: foo=bar echo $foo setenv bar foo echo $bar leads to "bar" and "foo" being printed on console output. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- common/cli_hush_2021.c | 17 +++ common/cli_hush_upstream.c | 91 +++--- 2 files changed, 103 insertions(+), 5 deletions(-) diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c index 653ea52929..7dd30ea0ef 100644 --- a/common/cli_hush_2021.c +++ b/common/cli_hush_2021.c @@ -207,6 +207,23 @@ static const char* endofname(const char *name) return name; } +/** + * list_size() - returns the number of elements in char ** before NULL. + * + * Argument must contain NULL to signalize its end. + * + * @list The list to count the number of element. + * @return The number of element in list. + */ +static size_t list_size(char **list) +{ + size_t size; + + for (size = 0; list[size] != NULL; size++); + + return size; +} + struct in_str; static int u_boot_cli_readline(struct in_str *i); diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index 84227a248e..b806c5c653 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -3486,7 +3486,6 @@ static int o_get_last_ptr(o_string *o, int n) return ((int)(uintptr_t)list[n-1]) + string_start; } -#ifndef __U_BOOT__ /* * Globbing routines. * @@ -3741,8 +3740,10 @@ static int glob_needed(const char *s) */ static int perform_glob(o_string *o, int n) { +#ifndef __U_BOOT__ glob_t globdata; int gr; +#endif /* __U_BOOT__ */ char *pattern; debug_printf_glob("start perform_glob: n:%d o->data:%p\n", n, o->data); @@ -3751,13 +3752,16 @@ static int perform_glob(o_string *o, int n) pattern = o->data + o_get_last_ptr(o, n); debug_printf_glob("glob pattern '%s'\n", pattern); if (!glob_needed(pattern)) { +#ifndef __U_BOOT__ literal: +#endif /* __U_BOOT__ */ /* unbackslash last string in o in place, fix length */ o->length = unbackslash(pattern) - o->data; debug_printf_glob("glob pattern '%s' is literal\n", pattern); return o_save_ptr_helper(o, n); } +#ifndef __U_BOOT__ memset(&globdata, 0, sizeof(globdata)); /* Can't use GLOB_NOCHECK: it does not unescape the string. * If we glob "*.\*" and don't find anything, we need @@ -3793,16 +3797,22 @@ static int perform_glob(o_string *o, int n) if (DEBUG_GLOB) debug_print_list("perform_glob returning", o, n); return n; +#else /* __U_BOOT__ */ + /* +* NOTE We only use perform glob to call unbackslash to remove backslash +* from string once expanded. +* So, it seems OK to return this if no previous return was done. +*/ + return o_save_ptr_helper(o, n); +#endif /* __U_BOOT__ */ } -#endif /* !__U_BOOT__ */ #endif /* !HUSH_BRACE_EXPANSION */ /* If o->o_expflags & EXP_FLAG_GLOB, glob the string so far remembered. * Otherwise, just finish current list[] and start new */ static int o_save_ptr(o_string *o, int n) { -#ifndef __U_BOOT__ if (o->o_expflags & EXP_FLAG_GLOB) { /* If o->has_empty_slot, list[n] was already globbed * (if it was requested back then when it was filled) @@ -3810,7 +3820,6 @@ static int o_save_ptr(o_string *o, int n) if (!o->has_empty_slot) return perform_glob(o, n); /* o_save_ptr_helper is inside */ } -#endif /* !__U_BOOT__ */ return o_save_ptr_helper(o, n); } @@ -5456,7 +5465,20 @@ static int parse_dollar(o_string *as_string, nommu_addchr(as_string, ch); if (ch == '}') break; +#ifndef __U_BOOT__ if (!isalnum(ch) && ch != '_') { +#else /* __U_BOOT__ */ + /* +* In several places in U-Boot, we use variable like +* foo# (e.g. serial#), particularly in env. +* So, we need to authorize # to appear inside +* variable name and then expand this variable. +* NOTE Having # in variable name is not permitted in +* upstream hush but expansion will be done (even though +* the result will be empty). +*/ + if (!isalnum(ch) && ch != '_' && ch != '#') { +#endif /* __U_BOOT__ */ unsigned end_ch; #ifndef __U_BOOT__ unsigned char last_ch; @@ -7031,7 +7053,20 @@ static NOINLINE int expand_one_var(o_string *output, int n, } #endif /* !__U_BOOT__ */ default: +#ifndef __U_BOOT__
[RFC PATCH v10 08/24] cli: Port Busybox 2021 hush to U-Boot
Adds new file cli_hush_2021.c, it is a copy of Busybox hush file as it was of time to commit 37460f5da. This commit modifies Busybox hush to not compile some part specific to Busybox and adds some code needed by U-Boot. The modifications consists mainly on adding code #if(n)def guards. For the moment, this refurbished flavor of hush only permits running command without any keywords (i.e., if and for are not recognized) or variable expansion (i.e., echo $foo prints foo and not value stored in variable foo). A new file was also added to define some functions specific to U-Boot. Signed-off-by: Francis Laniel Signed-off-by: Harald Seiler --- common/cli_hush_2021.c | 274 common/cli_hush_upstream.c | 501 - 2 files changed, 774 insertions(+), 1 deletion(-) create mode 100644 common/cli_hush_2021.c diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c new file mode 100644 index 00..6d109933b8 --- /dev/null +++ b/common/cli_hush_2021.c @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * This file defines the compilation unit for the new hush shell version. The + * actual implementation from upstream BusyBox can be found in + * `cli_hush_2021_upstream.c` which is included at the end of this file. + * + * This "wrapper" technique is used to keep the changes to the upstream version + * as minmal as possible. Instead, all defines and redefines necessary are done + * here, outside the upstream sources. This will hopefully make upgrades to + * newer revisions much easier. + * + * Copyright (c) 2021, Harald Seiler, DENX Software Engineering, h...@denx.de + */ + +#include /* readline */ +#include +#include /* malloc, free, realloc*/ +#include /* isalpha, isdigit */ +#include +#include +#include +#include +#include /* find_cmd */ +#include + +/* + * BusyBox Version: UPDATE THIS WHEN PULLING NEW UPSTREAM REVISION! + */ +#define BB_VER "1.34.0.git37460f5daff9" + +/* + * Define hush features by the names used upstream. + */ +#define ENABLE_HUSH_INTERACTIVE1 +#define ENABLE_FEATURE_EDITING 1 +/* No MMU in U-Boot */ +#define BB_MMU 0 +#define USE_FOR_NOMMU(...) __VA_ARGS__ +#define USE_FOR_MMU(...) + +/* + * Size-saving "small" ints (arch-dependent) + */ +#if CONFIG_IS_ENABLED(X86) || CONFIG_IS_ENABLED(X86_64) || CONFIG_IS_ENABLED(MIPS) +/* add other arches which benefit from this... */ +typedef signed char smallint; +typedef unsigned char smalluint; +#else +/* for arches where byte accesses generate larger code: */ +typedef int smallint; +typedef unsigned smalluint; +#endif + +/* + * Alignment defines used by BusyBox. + */ +#define ALIGN1 __attribute__((aligned(1))) +#define ALIGN2 __attribute__((aligned(2))) +#define ALIGN4 __attribute__((aligned(4))) +#define ALIGN8 __attribute__((aligned(8))) +#define ALIGN_PTR __attribute__((aligned(sizeof(void* + +/* + * Miscellaneous compiler/platform defines. + */ +#define FAST_FUNC /* not used in U-Boot */ +#define UNUSED_PARAM __always_unused +#define ALWAYS_INLINE __always_inline +#define NOINLINE noinline + +/* + * Defines to provide equivalents to what libc/BusyBox defines. + */ +#define EOF(-1) +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 + +/* + * Stubs to provide libc/BusyBox functions based on U-Boot equivalents where it + * makes sense. + */ +#define utoa simple_itoa + +static void __noreturn xfunc_die(void) +{ + panic("HUSH died!"); +} + +#define bb_error_msg_and_die(format, ...) do { \ +panic("HUSH: " format, __VA_ARGS__); \ +} while (0); + +#define bb_simple_error_msg_and_die(msg) do { \ +panic_str("HUSH: " msg); \ +} while (0); + +/* fdprintf() is used for debug output. */ +static int __maybe_unused fdprintf(int fd, const char *format, ...) +{ + va_list args; + uint i; + + assert(fd == 2); + + va_start(args, format); + i = vprintf(format, args); + va_end(args); + + return i; +} + +static void bb_verror_msg(const char *s, va_list p, const char* strerr) +{ + /* TODO: what to do with strerr arg? */ + vprintf(s, p); +} + +static void bb_error_msg(const char *s, ...) +{ + va_list p; + + va_start(p, s); + bb_verror_msg(s, p, NULL); + va_end(p); +} + +static void *xmalloc(size_t size) +{ + void *p = NULL; + if (!(p = malloc(size))) + panic("out of memory"); + return p; +} + +static void *xzalloc(size_t size) +{ + void *p = xmalloc(size); + memset(p, 0, size); + return p; +} + +static void *xrealloc(void *ptr, size_t size) +{ + void *p = NULL; + if (!(p = realloc(ptr, size))) + panic("out of memory"); + return p; +} + +#define xstrdupstrdup +#define xs
[RFC PATCH v10 12/24] cli: Enables using hush 2021 parser as command line parser
If one defines HUSH_2021_PARSER, it is then possible to use 2021 parser with: => cli get old => cli set 2021 => cli get 2021 Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- cmd/Kconfig | 8 + cmd/cli.c | 7 - common/Makefile | 1 + common/cli.c | 38 +++ common/cli_hush_2021.c| 3 ++ common/cli_hush_upstream.c| 46 +--- doc/usage/cmd/cli.rst | 17 ++- include/asm-generic/global_data.h | 4 +++ include/cli_hush.h| 51 +-- 9 files changed, 160 insertions(+), 15 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 5fb4cef54c..36595638a2 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -34,6 +34,14 @@ menu "Hush flavor to use" 2005. It is actually the default U-Boot shell when decided to use hush as shell. + + config HUSH_2021_PARSER + bool "Use hush 2021 parser" + help + This option enables the new flavor of hush based on hush Busybox from + 2021. + + For the moment, it is highly experimental and should be used at own risks. endmenu config CMDLINE_EDITING diff --git a/cmd/cli.c b/cmd/cli.c index 7671785b83..d2b64da613 100644 --- a/cmd/cli.c +++ b/cmd/cli.c @@ -12,6 +12,8 @@ static const char *gd_flags_to_parser(void) { if (gd->flags & GD_FLG_HUSH_OLD_PARSER) return "old"; + if (gd->flags & GD_FLG_HUSH_2021_PARSER) + return "2021"; return NULL; } @@ -34,12 +36,15 @@ static int parser_string_to_gd_flags(const char *parser) { if (!strcmp(parser, "old")) return GD_FLG_HUSH_OLD_PARSER; + if (!strcmp(parser, "2021")) + return GD_FLG_HUSH_2021_PARSER; return -1; } static void reset_parser_gd_flags(void) { gd->flags &= ~GD_FLG_HUSH_OLD_PARSER; + gd->flags &= ~GD_FLG_HUSH_2021_PARSER; } static int do_cli_set(struct cmd_tbl *cmdtp, int flag, int argc, @@ -108,7 +113,7 @@ static int do_cli(struct cmd_tbl *cmdtp, int flag, int argc, #if CONFIG_IS_ENABLED(SYS_LONGHELP) static char cli_help_text[] = "get - print current cli\n" - "set - set the current cli, possible value is: old" + "set - set the current cli, possible value are: old, 2021" ; #endif diff --git a/common/Makefile b/common/Makefile index 615eba8672..4b060bb565 100644 --- a/common/Makefile +++ b/common/Makefile @@ -9,6 +9,7 @@ obj-y += init/ obj-y += main.o obj-y += exports.o obj-$(CONFIG_HUSH_OLD_PARSER) += cli_hush.o +obj-$(CONFIG_HUSH_2021_PARSER) += cli_hush_2021.o obj-$(CONFIG_AUTOBOOT) += autoboot.o # # boards diff --git a/common/cli.c b/common/cli.c index d419671e8c..e3e2bc7fe1 100644 --- a/common/cli.c +++ b/common/cli.c @@ -43,12 +43,15 @@ int run_command(const char *cmd, int flag) return 1; return 0; -#else +#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER) int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP; if (flag & CMD_FLAG_ENV) hush_flags |= FLAG_CONT_ON_NEWLINE; return parse_string_outer(cmd, hush_flags); +#else /* HUSH_2021_PARSER */ + /* Not yet implemented. */ + return 1; #endif } @@ -108,7 +111,12 @@ int run_command_list(const char *cmd, int len, int flag) buff[len] = '\0'; } #ifdef CONFIG_HUSH_PARSER +#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON); +#else /* HUSH_2021_PARSER */ + /* Not yet implemented. */ + rcode = 1; +#endif #else /* * This function will overwrite any \n it sees with a \0, which @@ -254,8 +262,13 @@ err: void cli_loop(void) { bootstage_mark(BOOTSTAGE_ID_ENTER_CLI_LOOP); -#ifdef CONFIG_HUSH_PARSER - parse_file_outer(); +#if CONFIG_IS_ENABLED(HUSH_PARSER) + if (gd->flags & GD_FLG_HUSH_2021_PARSER) + parse_and_run_file(); + else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) + parse_file_outer(); + + printf("Problem\n"); /* This point is never reached */ for (;;); #elif defined(CONFIG_CMDLINE) @@ -268,10 +281,23 @@ void cli_loop(void) void cli_init(void) { #ifdef CONFIG_HUSH_PARSER + /* This if block is used to initialize hush parser gd flag. */ if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER) - && CONFIG_IS_ENABLED(HUSH_OLD_PARSER)) - gd->flags |= GD_FLG_HUSH_OLD_PARSER; - u_boot_hush_start(); + && !(gd->flags & GD_FLG_HUSH_2021_PARSER)) { + if (CONFIG_IS_ENABLED(HUSH_OLD_PARSER)) + gd->flags |= GD_FLG_HUSH_OLD_PARSER; + else if (CONFIG_IS_ENABLED(HUSH_2021_PARSER)) + gd->flags |= GD_FLG_HUSH_2021_PARSE
[RFC PATCH v10 09/24] cli: Add menu for hush parser
For the moment, the menu contains only entry: HUSH_OLD_PARSER which is the default. The goal is to prepare the field to add a new hush parser which guarantees actual behavior is still correct. Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- cmd/Kconfig | 13 + common/Makefile | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 43ca10f69c..5fb4cef54c 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -23,6 +23,19 @@ config HUSH_PARSER If disabled, you get the old, much simpler behaviour with a somewhat smaller memory footprint. +menu "Hush flavor to use" + depends on HUSH_PARSER + + config HUSH_OLD_PARSER + bool "Use hush old parser" + default y + help + This option enables the old flavor of hush based on hush Busybox from + 2005. + + It is actually the default U-Boot shell when decided to use hush as shell. +endmenu + config CMDLINE_EDITING bool "Enable command line editing" depends on CMDLINE diff --git a/common/Makefile b/common/Makefile index f5c3d90f06..615eba8672 100644 --- a/common/Makefile +++ b/common/Makefile @@ -8,7 +8,7 @@ ifndef CONFIG_SPL_BUILD obj-y += init/ obj-y += main.o obj-y += exports.o -obj-$(CONFIG_HUSH_PARSER) += cli_hush.o +obj-$(CONFIG_HUSH_OLD_PARSER) += cli_hush.o obj-$(CONFIG_AUTOBOOT) += autoboot.o # # boards -- 2.34.1
[RFC PATCH v10 10/24] global_data.h: add GD_FLG_HUSH_OLD_PARSER flag
This flag is used to indicate we are using the hush parser. Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- common/cli.c | 2 ++ include/asm-generic/global_data.h | 4 2 files changed, 6 insertions(+) diff --git a/common/cli.c b/common/cli.c index 3916a7b10a..e5fe1060d0 100644 --- a/common/cli.c +++ b/common/cli.c @@ -268,6 +268,8 @@ void cli_loop(void) void cli_init(void) { #ifdef CONFIG_HUSH_PARSER + if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER)) + gd->flags |= GD_FLG_HUSH_OLD_PARSER; u_boot_hush_start(); #endif diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 8fc205ded1..f21926aa23 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -667,6 +667,10 @@ enum gd_flags { * @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags */ GD_FLG_OF_TAG_MIGRATE = 0x20, + /** +* @GD_FLG_HUSH_OLD_PARSER: Use hush old parser. +*/ + GD_FLG_HUSH_OLD_PARSER = 0x40, }; #endif /* __ASSEMBLY__ */ -- 2.34.1
[RFC PATCH v10 11/24] cmd: Add new cli command
This command can be used to print the current parser with 'cli print'. It can also be used to set the current parser with 'cli set'. For the moment, only one value is valid for set: old. Signed-off-by: Francis Laniel --- cmd/Makefile | 2 + cmd/cli.c | 120 ++ common/cli.c | 3 +- doc/usage/cmd/cli.rst | 59 + doc/usage/index.rst | 1 + 5 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 cmd/cli.c create mode 100644 doc/usage/cmd/cli.rst diff --git a/cmd/Makefile b/cmd/Makefile index 9bebf321c3..d468cc5065 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -226,6 +226,8 @@ obj-$(CONFIG_CMD_AVB) += avb.o # Foundries.IO SCP03 obj-$(CONFIG_CMD_SCP03) += scp03.o +obj-$(CONFIG_HUSH_PARSER) += cli.o + obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_RISCV) += riscv/ obj-$(CONFIG_SANDBOX) += sandbox/ diff --git a/cmd/cli.c b/cmd/cli.c new file mode 100644 index 00..7671785b83 --- /dev/null +++ b/cmd/cli.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static const char *gd_flags_to_parser(void) +{ + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) + return "old"; + return NULL; +} + +static int do_cli_get(struct cmd_tbl *cmdtp, int flag, int argc, +char *const argv[]) +{ + const char *current = gd_flags_to_parser(); + + if (!current) { + printf("current cli value is not valid, this should not happen!\n"); + return CMD_RET_FAILURE; + } + + printf("%s\n", current); + + return CMD_RET_SUCCESS; +} + +static int parser_string_to_gd_flags(const char *parser) +{ + if (!strcmp(parser, "old")) + return GD_FLG_HUSH_OLD_PARSER; + return -1; +} + +static void reset_parser_gd_flags(void) +{ + gd->flags &= ~GD_FLG_HUSH_OLD_PARSER; +} + +static int do_cli_set(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + char *parser_name; + int parser_flag; + + if (argc < 2) + return CMD_RET_USAGE; + + parser_name = argv[1]; + + parser_flag = parser_string_to_gd_flags(parser_name); + if (parser_flag == -1) { + printf("Bad value for parser name: %s\n", parser_name); + return CMD_RET_USAGE; + } + + if (parser_flag == GD_FLG_HUSH_OLD_PARSER && + !CONFIG_IS_ENABLED(HUSH_OLD_PARSER)) { + printf("Want to set current parser to old, but its code was not compiled!\n"); + return CMD_RET_FAILURE; + } + + if (parser_flag == GD_FLG_HUSH_2021_PARSER && + !CONFIG_IS_ENABLED(HUSH_2021_PARSER)) { + printf("Want to set current parser to 2021, but its code was not compiled!\n"); + return CMD_RET_FAILURE; + } + + reset_parser_gd_flags(); + gd->flags |= parser_flag; + + cli_init(); + cli_loop(); + + /* cli_loop() should never return. */ + return CMD_RET_FAILURE; +} + +static struct cmd_tbl parser_sub[] = { + U_BOOT_CMD_MKENT(get, 1, 1, do_cli_get, "", ""), + U_BOOT_CMD_MKENT(set, 2, 1, do_cli_set, "", ""), +}; + +static int do_cli(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct cmd_tbl *cp; + + if (argc < 2) + return CMD_RET_USAGE; + + /* drop initial "parser" arg */ + argc--; + argv++; + + cp = find_cmd_tbl(argv[0], parser_sub, ARRAY_SIZE(parser_sub)); + if (cp) + return cp->cmd(cmdtp, flag, argc, argv); + + return CMD_RET_USAGE; +} + +#if CONFIG_IS_ENABLED(SYS_LONGHELP) +static char cli_help_text[] = + "get - print current cli\n" + "set - set the current cli, possible value is: old" + ; +#endif + +U_BOOT_CMD(cli, 3, 1, do_cli, + "cli", +#if CONFIG_IS_ENABLED(SYS_LONGHELP) + cli_help_text +#endif +); diff --git a/common/cli.c b/common/cli.c index e5fe1060d0..d419671e8c 100644 --- a/common/cli.c +++ b/common/cli.c @@ -268,7 +268,8 @@ void cli_loop(void) void cli_init(void) { #ifdef CONFIG_HUSH_PARSER - if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER)) + if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER) + && CONFIG_IS_ENABLED(HUSH_OLD_PARSER)) gd->flags |= GD_FLG_HUSH_OLD_PARSER; u_boot_hush_start(); #endif diff --git a/doc/usage/cmd/cli.rst b/doc/usage/cmd/cli.rst new file mode 100644 index 00..89ece3203d --- /dev/null +++ b/doc/usage/cmd/cli.rst @@ -0,0 +1,59 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +cli command +=== + +Synopis +--- + +:: + +cli get +cli set cli_flavor + +Description +--- + +The cli command permits getting and changing the current parser at runtime. + +cli get +~~~ + +It shows the curre
[RFC PATCH v10 06/24] test: hush: Test hush loops
The added tests verifies correct behavior of for, while and until loops. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- test/hush/Makefile | 1 + test/hush/loop.c | 65 ++ 2 files changed, 66 insertions(+) create mode 100644 test/hush/loop.c diff --git a/test/hush/Makefile b/test/hush/Makefile index ff4fe7700b..a2d98815e5 100644 --- a/test/hush/Makefile +++ b/test/hush/Makefile @@ -7,3 +7,4 @@ obj-y += cmd_ut_hush.o obj-y += if.o obj-y += dollar.o obj-y += list.o +obj-y += loop.o diff --git a/test/hush/loop.c b/test/hush/loop.c new file mode 100644 index 00..ca777e38fe --- /dev/null +++ b/test/hush/loop.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) Copyright 2021 + * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com + */ + +#include +#include +#include +#include +#include + +static int hush_test_for(struct unit_test_state *uts) +{ + console_record_reset_enable(); + + ut_assertok(run_command("for loop_i in foo bar quux quux; do echo $loop_i; done", 0)); + ut_assert_nextline("foo"); + ut_assert_nextline("bar"); + ut_assert_nextline("quux"); + ut_assert_nextline("quux"); + ut_assert_console_end(); + + puts("Beware: this test set local variable loop_i and it cannot be unset!"); + + return 0; +} +HUSH_TEST(hush_test_for, 0); + +static int hush_test_while(struct unit_test_state *uts) +{ + console_record_reset_enable(); + + /* Exit status is that of test, so 1 since test is false to quit the loop. */ + ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do echo bar; loop_foo=quux; done", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + puts("Beware: this test set local variable loop_foo and it cannot be unset!"); + + return 0; +} +HUSH_TEST(hush_test_while, 0); + +static int hush_test_until(struct unit_test_state *uts) +{ + console_record_reset_enable(); + env_set("loop_bar", "bar"); + + /* +* WARNING We have to use environment variable because it is not possible +* resetting local variable. +*/ + ut_assertok(run_command("until test -z \"$loop_bar\"; do echo quux; setenv loop_bar; done", 0)); + ut_assert_nextline("quux"); + ut_assert_console_end(); + + /* +* Loop normally resets foo environment variable, but we reset it here in +* case the test failed. +*/ + env_set("loop_bar", NULL); + return 0; +} +HUSH_TEST(hush_test_until, 0); -- 2.34.1
[RFC PATCH v10 05/24] test: hush: Test hush commands list
Verifies behavior of commands separated by ';', '&&' and '||'. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- test/hush/Makefile | 1 + test/hush/list.c | 79 ++ 2 files changed, 80 insertions(+) create mode 100644 test/hush/list.c diff --git a/test/hush/Makefile b/test/hush/Makefile index feb4f71956..ff4fe7700b 100644 --- a/test/hush/Makefile +++ b/test/hush/Makefile @@ -6,3 +6,4 @@ obj-y += cmd_ut_hush.o obj-y += if.o obj-y += dollar.o +obj-y += list.o diff --git a/test/hush/list.c b/test/hush/list.c new file mode 100644 index 00..052cf2783c --- /dev/null +++ b/test/hush/list.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) Copyright 2021 + * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com + */ + +#include +#include +#include +#include +#include + +static int hush_test_semicolon(struct unit_test_state *uts) +{ + /* A; B = B truth table. */ + ut_asserteq(1, run_command("false; false", 0)); + ut_assertok(run_command("false; true", 0)); + ut_assertok(run_command("true; true", 0)); + ut_asserteq(1, run_command("true; false", 0)); + + return 0; +} +HUSH_TEST(hush_test_semicolon, 0); + +static int hush_test_and(struct unit_test_state *uts) +{ + /* A && B truth table. */ + ut_asserteq(1, run_command("false && false", 0)); + ut_asserteq(1, run_command("false && true", 0)); + ut_assertok(run_command("true && true", 0)); + ut_asserteq(1, run_command("true && false", 0)); + + return 0; +} +HUSH_TEST(hush_test_and, 0); + +static int hush_test_or(struct unit_test_state *uts) +{ + /* A || B truth table. */ + ut_asserteq(1, run_command("false || false", 0)); + ut_assertok(run_command("false || true", 0)); + ut_assertok(run_command("true || true", 0)); + ut_assertok(run_command("true || false", 0)); + + return 0; +} +HUSH_TEST(hush_test_or, 0); + +static int hush_test_and_or(struct unit_test_state *uts) +{ + /* A && B || C truth table. */ + ut_asserteq(1, run_command("false && false || false", 0)); + ut_asserteq(1, run_command("false && false || true", 0)); + ut_asserteq(1, run_command("false && true || true", 0)); + ut_asserteq(1, run_command("false && true || false", 0)); + ut_assertok(run_command("true && true || false", 0)); + ut_asserteq(1, run_command("true && false || false", 0)); + ut_assertok(run_command("true && false || true", 0)); + ut_assertok(run_command("true && true || true", 0)); + + return 0; +} +HUSH_TEST(hush_test_and_or, 0); + +static int hush_test_or_and(struct unit_test_state *uts) +{ + /* A || B && C truth table. */ + ut_asserteq(1, run_command("false || false && false", 0)); + ut_asserteq(1, run_command("false || false && true", 0)); + ut_assertok(run_command("false || true && true", 0)); + ut_asserteq(1, run_command("false || true && false", 0)); + ut_assertok(run_command("true || true && false", 0)); + ut_assertok(run_command("true || false && false", 0)); + ut_assertok(run_command("true || false && true", 0)); + ut_assertok(run_command("true || true && true", 0)); + + return 0; +} +HUSH_TEST(hush_test_or_and, 0); -- 2.34.1
[RFC PATCH v10 03/24] test/py: hush_if_test: Remove the test file
5804ebfeb1ce ("test: hush: Test hush if/else") translated this test to a C test, so this python file is no more needed. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- test/py/tests/test_hush_if_test.py | 197 - 1 file changed, 197 deletions(-) delete mode 100644 test/py/tests/test_hush_if_test.py diff --git a/test/py/tests/test_hush_if_test.py b/test/py/tests/test_hush_if_test.py deleted file mode 100644 index 3b4b6fcaf4..00 --- a/test/py/tests/test_hush_if_test.py +++ /dev/null @@ -1,197 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. - -# Test operation of the "if" shell command. - -import os -import os.path -import pytest - -# TODO: These tests should be converted to a C test. -# For more information please take a look at the thread -# https://lists.denx.de/pipermail/u-boot/2019-October/388732.html - -pytestmark = pytest.mark.buildconfigspec('hush_parser') - -# The list of "if test" conditions to test. -subtests = ( -# Base if functionality. - -('true', True), -('false', False), - -# Basic operators. - -('test aaa = aaa', True), -('test aaa = bbb', False), - -('test aaa != bbb', True), -('test aaa != aaa', False), - -('test aaa < bbb', True), -('test bbb < aaa', False), - -('test bbb > aaa', True), -('test aaa > bbb', False), - -('test 123 -eq 123', True), -('test 123 -eq 456', False), - -('test 123 -ne 456', True), -('test 123 -ne 123', False), - -('test 123 -lt 456', True), -('test 123 -lt 123', False), -('test 456 -lt 123', False), - -('test 123 -le 456', True), -('test 123 -le 123', True), -('test 456 -le 123', False), - -('test 456 -gt 123', True), -('test 123 -gt 123', False), -('test 123 -gt 456', False), - -('test 456 -ge 123', True), -('test 123 -ge 123', True), -('test 123 -ge 456', False), - -# Octal tests - -('test 010 -eq 010', True), -('test 010 -eq 011', False), - -('test 010 -ne 011', True), -('test 010 -ne 010', False), - -# Hexadecimal tests - -('test 0x200 -gt 0x201', False), -('test 0x200 -gt 0x200', False), -('test 0x200 -gt 0x1ff', True), - -# Mixed tests - -('test 010 -eq 10', False), -('test 010 -ne 10', True), -('test 0xa -eq 10', True), -('test 0xa -eq 012', True), - -('test 200 -gt 0x1ff', False), -('test 0x200 -gt 1ff', True), -('test 0x200 -lt 1ff', False), -('test 0x200 -eq 200', False), -('test 0x200 -ne 200', True), - -('test -z ""', True), -('test -z "aaa"', False), - -('test -n "aaa"', True), -('test -n ""', False), - -# Inversion of simple tests. - -('test ! aaa = aaa', False), -('test ! aaa = bbb', True), -('test ! ! aaa = aaa', True), -('test ! ! aaa = bbb', False), - -# Binary operators. - -('test aaa != aaa -o bbb != bbb', False), -('test aaa != aaa -o bbb = bbb', True), -('test aaa = aaa -o bbb != bbb', True), -('test aaa = aaa -o bbb = bbb', True), - -('test aaa != aaa -a bbb != bbb', False), -('test aaa != aaa -a bbb = bbb', False), -('test aaa = aaa -a bbb != bbb', False), -('test aaa = aaa -a bbb = bbb', True), - -# Inversion within binary operators. - -('test ! aaa != aaa -o ! bbb != bbb', True), -('test ! aaa != aaa -o ! bbb = bbb', True), -('test ! aaa = aaa -o ! bbb != bbb', True), -('test ! aaa = aaa -o ! bbb = bbb', False), - -('test ! ! aaa != aaa -o ! ! bbb != bbb', False), -('test ! ! aaa != aaa -o ! ! bbb = bbb', True), -('test ! ! aaa = aaa -o ! ! bbb != bbb', True), -('test ! ! aaa = aaa -o ! ! bbb = bbb', True), -) - -def exec_hush_if(u_boot_console, expr, result): -"""Execute a shell "if" command, and validate its result.""" - -config = u_boot_console.config.buildconfig -maxargs = int(config.get('config_sys_maxargs', '0')) -args = len(expr.split(' ')) - 1 -if args > maxargs: -u_boot_console.log.warning('CONFIG_SYS_MAXARGS too low; need ' + -str(args)) -pytest.skip() - -cmd = 'if ' + expr + '; then echo true; else echo false; fi' -response = u_boot_console.run_command(cmd) -assert response.strip() == str(result).lower() - -@pytest.mark.buildconfigspec('cmd_echo') -@pytest.mark.parametrize('expr,result', subtests) -def test_hush_if_test(u_boot_console, expr, result): -"""Test a single "if test" condition.""" - -exec_hush_if(u_boot_console, expr, result) - -def test_hush_z(u_boot_console): -"""Test the -z operator""" -u_boot_console.run_command('setenv ut_var_nonexistent') -u_boot_console.run_command('setenv ut_var_exists 1') -exec_hush_if(u_boot_console, 'test -z "$ut_var_nonexistent"', True) -exec_hush_if(u_boot_console, 'test -z "$ut_var_exists"', False) -u_boot_console.run_command('se
[RFC PATCH v10 04/24] test: hush: Test hush variable expansion
Verifies shell variables are replaced by their values. Reviewed-by: Simon Glass Signed-off-by: Francis Laniel --- test/hush/Makefile | 1 + test/hush/dollar.c | 167 +++ test/py/tests/test_ut.py | 8 +- 3 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 test/hush/dollar.c diff --git a/test/hush/Makefile b/test/hush/Makefile index a3c9ae5106..feb4f71956 100644 --- a/test/hush/Makefile +++ b/test/hush/Makefile @@ -5,3 +5,4 @@ obj-y += cmd_ut_hush.o obj-y += if.o +obj-y += dollar.o diff --git a/test/hush/dollar.c b/test/hush/dollar.c new file mode 100644 index 00..defb2c3fd0 --- /dev/null +++ b/test/hush/dollar.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) Copyright 2021 + * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com + */ + +#include +#include +#include +#include +#include + +static int hush_test_simple_dollar(struct unit_test_state *uts) +{ + console_record_reset_enable(); + ut_assertok(run_command("echo $dollar_foo", 0)); + ut_assert_nextline_empty(); + ut_assert_console_end(); + + ut_assertok(run_command("echo ${dollar_foo}", 0)); + ut_assert_nextline_empty(); + ut_assert_console_end(); + + ut_assertok(run_command("dollar_foo=bar", 0)); + + ut_assertok(run_command("echo $dollar_foo", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + ut_assertok(run_command("echo ${dollar_foo}", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + ut_assertok(run_command("dollar_foo=\\$bar", 0)); + + ut_assertok(run_command("echo $dollar_foo", 0)); + ut_assert_nextline("$bar"); + ut_assert_console_end(); + + ut_assertok(run_command("dollar_foo='$bar'", 0)); + + ut_assertok(run_command("echo $dollar_foo", 0)); + ut_assert_nextline("$bar"); + ut_assert_console_end(); + + ut_asserteq(1, run_command("dollar_foo=bar quux", 0)); + /* Next line contains error message */ + ut_assert_skipline(); + ut_assert_console_end(); + + ut_asserteq(1, run_command("dollar_foo='bar quux", 0)); + /* Next line contains error message */ + ut_assert_skipline(); + ut_assert_console_end(); + + ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0)); + /* Two next lines contain error message */ + ut_assert_skipline(); + ut_assert_skipline(); + ut_assert_console_end(); + + ut_assertok(run_command("dollar_foo='bar \"quux'", 0)); + + ut_assertok(run_command("echo $dollar_foo", 0)); + /* +* This one is buggy. +* ut_assert_nextline("bar \"quux"); +* ut_assert_console_end(); +* +* So, let's reset output: +*/ + console_record_reset_enable(); + + ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0)); + /* Next line contains error message */ + ut_assert_skipline(); + ut_assert_console_end(); + + ut_assertok(run_command("dollar_foo='bar quux'", 0)); + ut_assertok(run_command("echo $dollar_foo", 0)); + ut_assert_nextline("bar quux"); + ut_assert_console_end(); + + puts("Beware: this test set local variable dollar_foo and it cannot be unset!"); + + return 0; +} +HUSH_TEST(hush_test_simple_dollar, 0); + +static int hush_test_env_dollar(struct unit_test_state *uts) +{ + env_set("env_foo", "bar"); + console_record_reset_enable(); + + ut_assertok(run_command("echo $env_foo", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + ut_assertok(run_command("echo ${env_foo}", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + /* Environment variables have priority over local variable */ + ut_assertok(run_command("env_foo=quux", 0)); + ut_assertok(run_command("echo ${env_foo}", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + /* Clean up setting the variable */ + env_set("env_foo", NULL); + + puts("Beware: this test set local variable env_foo and it cannot be unset!"); + + return 0; +} +HUSH_TEST(hush_test_env_dollar, 0); + +static int hush_test_command_dollar(struct unit_test_state *uts) +{ + console_record_reset_enable(); + + ut_assertok(run_command("dollar_bar=\"echo bar\"", 0)); + + ut_assertok(run_command("$dollar_bar", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + ut_assertok(run_command("${dollar_bar}", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + ut_assertok(run_command("dollar_bar=\"echo\nbar\"", 0)); + + ut_assertok(run_command("$dollar_bar", 0)); + ut_assert_nextline("bar"); + ut_assert_console_end(); + + ut_assertok(run_command("dollar_bar='echo bar\n'", 0)); + + ut_assertok(run_command("$dol
[RFC PATCH v10 02/24] test: hush: Test hush if/else
As asked in commit 9c6bf1715f6a ("test/py: hush_if_test: Add tests to cover octal/hex values"), this commit translates test_hush_if_test.py to a C test. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- test/hush/Makefile | 1 + test/hush/if.c | 316 + 2 files changed, 317 insertions(+) create mode 100644 test/hush/if.c diff --git a/test/hush/Makefile b/test/hush/Makefile index dfa2a92615..a3c9ae5106 100644 --- a/test/hush/Makefile +++ b/test/hush/Makefile @@ -4,3 +4,4 @@ # Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com obj-y += cmd_ut_hush.o +obj-y += if.o diff --git a/test/hush/if.c b/test/hush/if.c new file mode 100644 index 00..b7200e32ec --- /dev/null +++ b/test/hush/if.c @@ -0,0 +1,316 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) Copyright 2021 + * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com + */ + +#include +#include +#include +#include +#include + +/* + * All tests will execute the following: + * if condition_to_test; then + * true + * else + * false + * fi + * If condition is true, command returns 1, 0 otherwise. + */ +const char *if_format = "if %s; then true; else false; fi"; + +static int hush_test_if_base(struct unit_test_state *uts) +{ + char if_formatted[128]; + + sprintf(if_formatted, if_format, "true"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "false"); + ut_asserteq(1, run_command(if_formatted, 0)); + + return 0; +} +HUSH_TEST(hush_test_if_base, 0); + +static int hush_test_if_basic_operators(struct unit_test_state *uts) +{ + char if_formatted[128]; + + sprintf(if_formatted, if_format, "test aaa = aaa"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test aaa = bbb"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test aaa != bbb"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test aaa != aaa"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test aaa < bbb"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test bbb < aaa"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test bbb > aaa"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test aaa > bbb"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -eq 123"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -eq 456"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -ne 456"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -ne 123"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -lt 456"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -lt 123"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 456 -lt 123"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -le 456"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -le 123"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 456 -le 123"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 456 -gt 123"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -gt 123"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -gt 456"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 456 -ge 123"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -ge 123"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 123 -ge 456"); + ut_asserteq(1, run_command(if_formatted, 0)); + + return 0; +} +HUSH_TEST(hush_test_if_basic_operators, 0); + +static int hush_test_if_octal(struct unit_test_state *uts) +{ + char if_formatted[128]; + + sprintf(if_formatted, if_format, "test 010 -eq 010"); + ut_assertok(run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 010 -eq 011"); + ut_asserteq(1, run_command(if_formatted, 0)); + + sprintf(if_formatted, if_format, "test 010 -ne 011"); + ut_assertok(run_command(if_fo
[RFC PATCH v10 01/24] test: Add framework to test hush behavior
Introduce a new subcommand to ut: ut hush. For the moment, this command does nothing, future commits will add tests which will be run on command call. Note that CONFIG_HUSH_PARSER must be defined to compile this new subcommand. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- include/test/hush.h | 15 +++ include/test/suites.h | 1 + test/Makefile | 3 +++ test/cmd_ut.c | 6 ++ test/hush/Makefile | 6 ++ test/hush/cmd_ut_hush.c | 20 6 files changed, 51 insertions(+) create mode 100644 include/test/hush.h create mode 100644 test/hush/Makefile create mode 100644 test/hush/cmd_ut_hush.c diff --git a/include/test/hush.h b/include/test/hush.h new file mode 100644 index 00..cca66544a0 --- /dev/null +++ b/include/test/hush.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * (C) Copyright 2021 + * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com + */ + +#ifndef __TEST_HUSH_H__ +#define __TEST_HUSH_H__ + +#include + +/* Declare a new environment test */ +#define HUSH_TEST(_name, _flags) UNIT_TEST(_name, _flags, hush_test) + +#endif /* __TEST_HUSH_H__ */ diff --git a/include/test/suites.h b/include/test/suites.h index 1c7dc65966..340a2b041f 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -42,6 +42,7 @@ int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); diff --git a/test/Makefile b/test/Makefile index 178773647a..d6ca3e221d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -20,6 +20,9 @@ obj-$(CONFIG_FUZZ) += fuzz/ ifndef CONFIG_SANDBOX_VPL obj-$(CONFIG_UNIT_TEST) += lib/ endif +ifneq ($(CONFIG_HUSH_PARSER),) +obj-$(CONFIG_$(SPL_)CMDLINE) += hush/ +endif obj-$(CONFIG_$(SPL_)CMDLINE) += print_ut.o obj-$(CONFIG_$(SPL_)CMDLINE) += str_ut.o obj-$(CONFIG_UT_TIME) += time_ut.o diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 0cb514490b..aae0c460ad 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -110,6 +110,9 @@ static struct cmd_tbl cmd_ut_sub[] = { #ifdef CONFIG_CMD_ADDRMAP U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""), #endif +#if CONFIG_IS_ENABLED(HUSH_PARSER) + U_BOOT_CMD_MKENT(hush, CONFIG_SYS_MAXARGS, 1, do_ut_hush, "", ""), +#endif #ifdef CONFIG_CMD_LOADM U_BOOT_CMD_MKENT(loadm, CONFIG_SYS_MAXARGS, 1, do_ut_loadm, "", ""), #endif @@ -203,6 +206,9 @@ static char ut_help_text[] = #ifdef CONFIG_CONSOLE_TRUETYPE "\nut font - font command" #endif +#if CONFIG_IS_ENABLED(HUSH_PARSER) + "\nhush - Test hush behavior" +#endif #ifdef CONFIG_CMD_LOADM "\nloadm - loadm command parameters and loading memory blob" #endif diff --git a/test/hush/Makefile b/test/hush/Makefile new file mode 100644 index 00..dfa2a92615 --- /dev/null +++ b/test/hush/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2021 +# Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com + +obj-y += cmd_ut_hush.o diff --git a/test/hush/cmd_ut_hush.c b/test/hush/cmd_ut_hush.c new file mode 100644 index 00..48a1adbf28 --- /dev/null +++ b/test/hush/cmd_ut_hush.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) Copyright 2021 + * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com + */ + +#include +#include +#include +#include +#include + +int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct unit_test *tests = UNIT_TEST_SUITE_START(hush_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(hush_test); + + return cmd_ut_category("hush", "hush_test_", + tests, n_ents, argc, argv); +} -- 2.34.1
[RFC PATCH v10 00/24] Modernize U-Boot shell
Hi. During 2021 summer, Sean Anderson wrote a contribution to add a new shell, based on LIL, to U-Boot [1, 2]. While one of the goals of this contribution was to address the fact actual U-Boot shell, which is based on Busybox hush, is old there was a discussion about adding a new shell versus updating the actual one [3, 4]. So, in this series, with Harald Seiler, we updated the actual U-Boot shell to reflect what is currently in Busybox source code. Basically, this contribution is about taking a snapshot of Busybox shell/hush.c file (as it exists in commit 37460f5da) and adapt it to suit U-Boot needs. This contribution was written to be as backward-compatible as possible to avoid breaking the existing. So, the 2021 hush flavor offers the same as the actual, that is to say: 1. Variable expansion. 2. Instruction lists (;, && and ||). 3. If, then and else. 4. Loops (for, while and until). No new features offered by Busybox hush were implemented (e.g. functions). It is possible to change the parser at runtime using the "cli" command: => cli print old => cli set 2021 => cli print 2021 => cli set old The default parser is the old one. Note that to use both parser, you would need to set both CONFIG_HUSH_2021_PARSER and CONFIG_HUSH_OLD_PARSER. In terms of testing, new unit tests were added to ut to ensure the new behavior is the same as the old one and it does not add regression. Nonetheless, if old behavior was buggy and fixed upstream, the fix is then added to U-Boot [5]. In sandbox, all of these tests pass smoothly: => printenv board board=sandbox => ut hush Running 20 hush tests ... Failures: 0 => parser set 2021 => ut hush Running 20 hush tests ... Failures: 0 Thanks to the effort of Harald Seiler, I was successful booting a board: => printenv fdtfile fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb => cli get old => boot ... root@lepotato:~# root@lepotato:~# reboot ... => cli set 2021 => cli get 2021 => printenv fdtfile fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb => boot ... root@lepotato:~# I had to not use CONFIG_HUSH_2021_PARSER for the keymile board. Indeed, the keymile board family is the only set of boards to call get_local_var(), set_local_var() and unset_local_var(). Sadly, these functions are static in this contribution. I could have change all of them to introduce code like this: *_local_var(/*...*/) { if (gd->flags & GD_FLG_HUSH_OLD_PARSER) return *_local_var_old(/*...*/); if (gd->flags & GD_FLG_HUSH_2021_PARSER) return *_local_var_2021(/*...*/); } But this would have mean renaming all old hush functions calls and I did not want to change the old hush particularly to avoid breaking things. Instead, I change the keymile board to use environment variable instead of local ones. I think this particularities can be addressed in future works. I also had to enable CONFIG_LTO for kirkwoord sheevaplug and phytec bk4r1, so they do not hit their limits. For all these reasons, I marked this contribution as RFC to indeed collect your opinions. My goal is not to change suddenly actual shell to this one, we clearly need a transition period to think about it. I think it is better to see this contribution as a proof of concept which shows it is possible to update the actual shell. If you want to review it - your review will really be appreciated - here are some information regarding the commits: * commits marked as "test:" deal with unit tests. * commit "cli: Add Busybox upstream hush.c file." copies Busybox shell/hush.c into U-Boot tree, this explain why this commit contains around 12000 additions. * commit "cli: Port Busybox 2021 hush to U-Boot." modifies previously added file to permit us to use this as new shell. The really good idea of #include'ing Busybox code into a wrapper file to define some particular functions while minimizing modifications to upstream code comes from Harald Seiler. * commit "cmd: Add new parser command" adds a new command which permits selecting parser at runtime. I am not really satisfied with the fact it calls cli_init() and cli_loop() each time the parser is set, so your reviews would be welcomed. * Other commits focus on enabling features we need (e.g. if). Changes since: v2: * Added a small fix to compile sandbox with NO_SDL=1. * Added a command to change parser at runtime. * Added 2021 parser function to all run_command*(). v3: * Various bug fixes pointed by the CI. * Added upstream busybox hush commits until 6th February 2022. v4: * Various cleaning. * Modified python test to accept failure output when the test are designed to fail. * Bumped upstream busybox hush commits until 24h March 2022. v5: * Bumped upstream busybox hush commits until 30th January 2023. * Fix how hush interprets '<' and '>', indeed we needed to escape them but I removed this behavior as tests are handled by test command and not hush itself. This permitted to have the ut fdt to pass. * Fix a problem with how exi
Re: [PATCH 12/16] arm: rmobile: Include in header
On Wed, Oct 04, 2023 at 05:19:43PM +0200, Marek Vasut wrote: > On 10/4/23 15:48, Paul Barker wrote: > > On Wed, Oct 04, 2023 at 02:27:50PM +0200, Marek Vasut wrote: > > > On 10/4/23 10:57, Paul Barker wrote: > > > > On 03/10/2023 14:27, Marek Vasut wrote: > > > > > On 9/20/23 14:42, Paul Barker wrote: > > > > > > We don't want to rely on source files including before > > > > > > . > > > > > > > > > > What kind of error does this solve ? > > > > > > > > Without this, must be included before > > > > , for example in include/configs/rzg2l-smarc.h added > > > > in patch 16, to avoid the following error: > > > > > > > > CC arch/arm/lib/asm-offsets.s > > > > In file included from include/configs/rzg2l-smarc.h:9, > > > >from include/config.h:3, > > > >from include/common.h:16, > > > >from lib/asm-offsets.c:14: > > > > ./arch/arm/include/asm/arch/rmobile.h:49:7: error: unknown type name > > > > ‘u8’ > > > > 49 | const u8 *rzg_get_cpu_name(void); > > > > > > Hmmm, that's weird, why am I not hitting it with the rcar CPU name > > > function > > > too ? > > > > arch/arm/mach-rmobile/include/mach/rcar-gen3-base.h includes > > as it uses the `u32` type. > > > > However, arch/arm/mach-rmobile/include/mach/rzg2l.h doesn't use anything > > from so doesn't include it. > > Shouldn't arch/arm/mach-rmobile/include/mach/rmobile.h include the types.h > then ? That's what this patch adds. Thanks, Paul signature.asc Description: PGP signature
Re: [PATCH 10/16] serial: sh: Add RZ/G2L SCIF support
On Wed, Oct 04, 2023 at 05:17:55PM +0200, Marek Vasut wrote: > On 10/4/23 15:43, Paul Barker wrote: > > On Wed, Oct 04, 2023 at 02:26:49PM +0200, Marek Vasut wrote: > > > On 10/4/23 10:48, Paul Barker wrote: > > > > On 03/10/2023 14:23, Marek Vasut wrote: > > > > > On 9/20/23 14:42, Paul Barker wrote: > > > > > > Extend the existing driver to support the SCIF serial ports on the > > > > > > Renesas RZ/G2L (R9A07G044) SoC. This also requires us to ensure > > > > > > that the > > > > > > relevant reset signal is de-asserted before we try to talk to the > > > > > > SCIF > > > > > > module. > > > > > > > > > > > > Signed-off-by: Paul Barker > > > > > > Reviewed-by: Biju Das > > > > > > Reviewed-by: Lad Prabhakar > > > > > > --- > > > > > > arch/arm/mach-rmobile/Kconfig | 1 + > > > > > > drivers/serial/serial_sh.c| 32 > > > > > > ++-- > > > > > > drivers/serial/serial_sh.h| 19 ++- > > > > > > 3 files changed, 49 insertions(+), 3 deletions(-) > > > > > > > > > > > > diff --git a/arch/arm/mach-rmobile/Kconfig > > > > > > b/arch/arm/mach-rmobile/Kconfig > > > > > > index 973e84fcf7ba..0ab22356aee5 100644 > > > > > > --- a/arch/arm/mach-rmobile/Kconfig > > > > > > +++ b/arch/arm/mach-rmobile/Kconfig > > > > > > @@ -77,6 +77,7 @@ config RZG2L > > > > > > imply RENESAS_SDHI > > > > > > imply CLK_RZG2L > > > > > > imply PINCTRL_RZG2L > > > > > > + imply SCIF_CONSOLE > > > > > > help > > > > > > Enable support for the Renesas RZ/G2L family of SoCs, > > > > > > including the > > > > > > the RZ/G2L itself (based on the R9A07G044 SoC). > > > > > > diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c > > > > > > index 5e543dbf3d58..a2e9a57137a6 100644 > > > > > > --- a/drivers/serial/serial_sh.c > > > > > > +++ b/drivers/serial/serial_sh.c > > > > > > @@ -17,6 +17,8 @@ > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > +#include > > > > > > +#include > > > > > > #include "serial_sh.h" > > > > > > DECLARE_GLOBAL_DATA_PTR; > > > > > > @@ -79,8 +81,16 @@ sh_serial_setbrg_generic(struct uart_port *port, > > > > > > int clk, int baudrate) > > > > > > static void handle_error(struct uart_port *port) > > > > > > { > > > > > > - sci_in(port, SCxSR); > > > > > > - sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); > > > > > > + /* The RZ/G2L datasheet says that error conditions are cleared > > > > > > by > > > > > > +* resetting the error bits in the FSR register to zero. > > > > > > > > > > Can you be more specific here ? > > > > > > > > > > It doesn't seem Linux sh-sci.c driver does anything special for G2L, > > > > > so > > > > > is this special case really needed ? > > > > > > > > On page 1268 of the datasheet (R01UH0914EJ0130 Rev.1.30): > > > > > > > > "DR is cleared to 0 when DR = 1 is read and then 0 is written to the DR > > > > flag." > > > > > > > > On page 1270: > > > > > > > > "[Clearing condition] > > > > ● When 0 is written to ER after it has been read as 1" > > > > > > > > So zeros must be written to clear these errors, not ones. > > > > > > > > We have an open task to investigate the issue in the Linux driver and > > > > fix it. > > > > > > Is the G2L UART broken in Linux ? > > > > Likely yes, but we need to reproduce the issue. > > > > > Does it misbehave in U-Boot ? > > > > Yes, before I changed this, if a framing error occurred it could never > > be cleared and the serial port stopped sending/receiving data. > > > > The framing error was triggered by accident by unnecessarily re-doing > > pinmuxing for the serial port after TrustedFirmware had already set it > > up correctly. Since SCIF0 is wired to an FTDI USB/serial adaptor chip on > > the SMARC carrier board, it seems very difficult to trigger a framing > > error in any other way, the FTDI chip is too well behaved. > > Is it possible to trigger this on RZ/G2 with SCIF on those platforms > as well ? It's not been seen or reported to my knowledge, but it's on our list to look into further. Thanks, Paul signature.asc Description: PGP signature
Re: [PATCHv10 01/15] submodule: add lwIP as git submodule
Hi Maxim, On Wed, 4 Oct 2023 at 01:53, Maxim Uvarov wrote: > > > > On Mon, 2 Oct 2023 at 20:46, Simon Glass wrote: >> >> Hi Maxim, >> >> On Mon, 2 Oct 2023 at 05:23, Maxim Uvarov wrote: >> > >> > I found what was missing. (reproduced with CI docker.) >> >> How about adding a script that copies in the lwip code needed for >> U-Boot, that you (or whoever the maintainer is) can run each quarter? >> >> Alternatively, I think just sending a patch with the code would be >> helpful, so we can see what you are wanting to include. >> >> Regards, >> Simon > > > Hello Simon, > > That might also work. lwIP is a little bit special library which we can not > just connect as an external library from the repo, because it has platform > implementation specifics (U-Boot here). Do you mean that it has an adaptation layer that we are using? I'm not sure what you are getting at. > At this time I'm trying to pass all CI tests. And even if they pass for me > locally CI has some interesting combinations where the test fails and I'm not > even sure that it's related to lwip code. > Once CI will pass all the things I want to take more attention on submodule > support or patch support. I really hope that submodule will work for us, but > that also will require Makefile and CI changes. I just hit a roadblock with submodules at the weekend. They are not properly integrated into git (git fetch, git rebase, etc.). Perhaps they will never be. > > However, review of lwIP code here might be helpful. But I think the mailing > list will not allow me to send such a big patch, and it's almost impossible > to do a review project in one email. It just gets held up, but is released by Tom. Yes, the email piece has its limits. Also I'm not sure how useful it is to review the lwip code, unless we actually plan to submit fixes upstream. > I guess it's better to do a git clone > https://git.savannah.nongnu.org/git/lwip.git and see what is there. OK. Regards, Simon > > BR, > Maxim. > > >> >> > >> > On Mon, 2 Oct 2023 at 12:34, Maxim Uvarov wrote: >> >> >> >> Can somebody help me to understand and reproduce CI errors? I can run >> >> locally 'make check' which runs a bunch of local builds with binman and >> >> all of them are fine. >> >> It looks like some dependency is missing or addition 'git config --global >> >> --add safe.directory /net/lwip/lwip-external' is required for the >> >> submodule directory. >> >> >> >> https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/17916 >> >> >> >> Building current source for 1 boards (0 threads, 24 jobs per thread) >> >>sandbox: + sandbox_spl >> >> +fatal: not a git repository (or any of the parent directories): .git >> >> +make[1]: *** [Makefile:1875: initsubmodules] Error 128 >> >> +make: *** [Makefile:177: sub-make] Error 2 >> >> 001 /1 sandbox_spl >> >> Completed: 1 total built, 1 newly), duration 0:00:06, rate 0.17 >> >> Traceback (most recent call last): >> >> File "/builds/u-boot/custodians/u-boot-tpm/./tools/binman/binman", line >> >> 45, in >> >> from binman import cmdline >> >> File "/builds/u-boot/custodians/u-boot-tpm/tools/binman/cmdline.py", >> >> line 11, in >> >> from binman import state >> >> File "/builds/u-boot/custodians/u-boot-tpm/tools/binman/state.py", line >> >> 14, in >> >> from dtoc import fdt >> >> File "/builds/u-boot/custodians/u-boot-tpm/tools/dtoc/fdt.py", line 14, >> >> in >> >> from libfdt import QUIET_NOTFOUND >> >> ImportError: cannot import name 'QUIET_NOTFOUND' from 'libfdt' (unknown >> >> location) >> >> >> >> On Tue, 26 Sept 2023 at 20:19, Tom Rini wrote: >> >>> >> >>> On Tue, Sep 26, 2023 at 08:16:35AM -0600, Simon Glass wrote: >> >>> > Hi Tom, >> >>> > >> >>> > On Tue, 26 Sept 2023 at 07:41, Tom Rini wrote: >> >>> > > >> >>> > > On Tue, Sep 26, 2023 at 05:37:25AM -0600, Simon Glass wrote: >> >>> > > > Hi Maxim, >> >>> > > > >> >>> > > > On Tue, 26 Sept 2023 at 03:43, Maxim Uvarov >> >>> > > > wrote: >> >>> > > > > >> >>> > > > > add external lwIP library as a git submodule. >> >>> > > > > Use STABLE-2_2_0_RELEASE tag. >> >>> > > > > >> >>> > > > > Signed-off-by: Maxim Uvarov >> >>> > > > > --- >> >>> > > > > .gitmodules| 3 +++ >> >>> > > > > net/lwip/lwip-external | 1 + >> >>> > > > > 2 files changed, 4 insertions(+) >> >>> > > > > create mode 100644 .gitmodules >> >>> > > > > create mode 16 net/lwip/lwip-external >> >>> > > >> >>> > > Do you have comments on the rest of the series? >> >>> > >> >>> > Not yet, but I should be able to review the rest in a few days. My >> >>> > main comments before were minor - return codes, tests, error checking. >> >>> >> >>> OK, thanks. I don't know how exactly I want to proceed with the core of >> >>> lwip itself, but that doesn't block reviewing and testing the rest of it >> >>> as we'll move forward with it one way or another. >> >>> >> >>> -- >> >>> Tom
Re: [PATCH v2 1/3] dt-bindings: mtd: fixed-partitions: Add binman compatible
Hi Michael, On Wed, 4 Oct 2023 at 05:35, Michael Walle wrote: > > Hi, > > >> Add a compatible string for binman, so we can extend fixed-partitions > >> in various ways. > > > > I've been thinking at the proper way to describe the binman partitions. > > I am wondering if we should really extend the fixed-partitions > > schema. This description is really basic and kind of supposed to remain > > like that. Instead, I wonder if we should not just keep the binman > > compatible alone, like many others already. This way it would be very clear > > what is expected and allowed in both cases. I am thinking about > > something like that: > > > > > > Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml > > > > this file is also referenced there (but this patch does the same, which > > is what I'd expect): > > > > Documentation/devicetree/bindings/mtd/partitions/partitions.yaml > > > > I'll let the binding maintainers judge whether they think it's > > relevant, it's not a strong opposition. > > What is the overall goal here? To replace the current binman node which is > usually contained in the -u-boot.dtsi files? If one is using binman to > create an image, is it expected that one needs to adapt the DT in linux? > Or will it still be a seperate -u-boot.dtsi? > Because in the latter case > I see that there will be conflicts because you have to overwrite the > flash node. Or will it be a seperate node with all the information > duplicated? The goal is simply to have a full binding for firmware layout, such that firmware images can be created, examined and updated. The -u-boot.dtsi files are a stopgap while we sort out a real binding. They should eventually go away. > > Maybe (a more complete) example would be helpful. Can you please be a bit more specific? What is missing from the example? Regards, Simon
Re: [PATCH v2 1/3] dt-bindings: mtd: fixed-partitions: Add binman compatible
Hi Miquel, On Wed, 4 Oct 2023 at 01:36, Miquel Raynal wrote: > > Hi Simon, > > s...@chromium.org wrote on Mon, 2 Oct 2023 11:49:40 -0600: > > > Add a compatible string for binman, so we can extend fixed-partitions > > in various ways. > > I've been thinking at the proper way to describe the binman partitions. > I am wondering if we should really extend the fixed-partitions > schema. This description is really basic and kind of supposed to remain > like that. Instead, I wonder if we should not just keep the binman > compatible alone, like many others already. This way it would be very clear > what is expected and allowed in both cases. I am thinking about > something like that: > > > Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml > > this file is also referenced there (but this patch does the same, which > is what I'd expect): > > Documentation/devicetree/bindings/mtd/partitions/partitions.yaml > > I'll let the binding maintainers judge whether they think it's > relevant, it's not a strong opposition. OK, yes I can do that. I suppose they would still remain backwards compatible, due to the use of '$ref: partition.yaml#' > > > Signed-off-by: Simon Glass > > --- > > [...] > > > +properties: > > + compatible: > > +const: binman > > Right now this does not fit (I believe) the example. But if we no > longer extend fixed-partitions but just create binman.yaml, this will > probably be enough. OK > > > + > > +additionalProperties: false > > + > > +examples: > > + - | > > +partitions { > > +compatible = "binman", "fixed-partitions"; > > +#address-cells = <1>; > > +#size-cells = <1>; > > + > > +partition@10 { > > +label = "u-boot"; > > +reg = <0x10 0xf0>; > > +}; > > +}; Regards, Simon
Re: [PATCH v2 0/8] Support USB for Meson A1
On 03/10/2023 13:28, Alexey Romanov wrote: Hello! This patchset adds USB stack support for Amlogic A1 SoC's series. Made reset / phy / dwc3 drivers more flexible and added support for A1 board. V2: - Made power domain for PHY optional. - Add missing CLKID_USB_PHY gate. - Drop patch with USB stack initialization in board-a1.c. Instead of, enable CONFIG_DM_USB_GADGET for AD401 board. - Support A1 in g12a_child_pre_probe/post_remove functions in dwc3 driver. Alexey Romanov (7): dt-bindings: reset: add Meson A1 reset bindings reset: add support for Amlogic A1 family phy: get rid of raw hex values phy: move clk enable/disable in init/exit phy: support Amlogic A1 family dwc3: add support for Amlogic A1 family ad401: enable USB stack Igor Prusov (1): a1: clk: Add missing USB_PHY_IN and USB_PHY gates configs/ad401_defconfig | 3 + drivers/clk/meson/a1.c| 6 + drivers/phy/Kconfig | 2 +- drivers/phy/meson-g12a-usb2.c | 235 -- drivers/reset/reset-meson.c | 42 +++- drivers/usb/dwc3/dwc3-meson-g12a.c| 73 +- .../reset/amlogic,meson-a1-reset.h| 76 ++ 7 files changed, 403 insertions(+), 34 deletions(-) create mode 100644 include/dt-bindings/reset/amlogic,meson-a1-reset.h The PHY and DWC3 patches don't apply cleanly, could you rebase on top of: https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commits/u-boot-amlogic Thanks, Neil
Re: [PATCHv10 01/15] submodule: add lwIP as git submodule
On Wed, Oct 04, 2023 at 01:52:53PM +0600, Maxim Uvarov wrote: > On Mon, 2 Oct 2023 at 20:46, Simon Glass wrote: > > > Hi Maxim, > > > > On Mon, 2 Oct 2023 at 05:23, Maxim Uvarov wrote: > > > > > > I found what was missing. (reproduced with CI docker.) > > > > How about adding a script that copies in the lwip code needed for > > U-Boot, that you (or whoever the maintainer is) can run each quarter? > > > > Alternatively, I think just sending a patch with the code would be > > helpful, so we can see what you are wanting to include. > > > > Regards, > > Simon > > > > Hello Simon, > > That might also work. lwIP is a little bit special library which we can not > just connect as an external library from the repo, because it has > platform implementation specifics (U-Boot here). > At this time I'm trying to pass all CI tests. And even if they pass for me > locally CI has some interesting combinations where the test fails and I'm > not even sure that it's related to lwip code. > Once CI will pass all the things I want to take more attention on submodule > support or patch support. I really hope that submodule will work for us, > but that also will require Makefile and CI changes. > > However, review of lwIP code here might be helpful. But I think the mailing > list will not allow me to send such a big patch, and it's almost impossible > to do a review project in one email. > I guess it's better to do a git clone > https://git.savannah.nongnu.org/git/lwip.git and see what is there. Yes, the mailing list will hold the message for moderation until I, or one of the other people with the password approve it. That's not a consideration for how we handle the initial lwip integration. It does need to be a "just the import" patch as there's no real way to review the code itself. -- Tom signature.asc Description: PGP signature
Re: [PATCH v3 6/8] drivers: introduce Meson Secure Monitor driver
Hi, On 21/09/2023 10:13, Alexey Romanov wrote: This patch adds an implementation of the Meson Secure Monitor driver based on UCLASS_SM. Signed-off-by: Alexey Romanov Reviewed-by: Simon Glass --- MAINTAINERS | 1 + drivers/sm/Kconfig| 7 ++ drivers/sm/Makefile | 1 + drivers/sm/meson-sm.c | 198 ++ include/meson/sm.h| 19 5 files changed, 226 insertions(+) create mode 100644 drivers/sm/meson-sm.c create mode 100644 include/meson/sm.h diff --git a/MAINTAINERS b/MAINTAINERS index 6c64427782..bdc364fd4c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -158,6 +158,7 @@ F: drivers/net/phy/meson-gxl.c F:drivers/adc/meson-saradc.c F:drivers/phy/meson* F:drivers/mmc/meson_gx_mmc.c +F: drivers/sm/meson-sm.c F:drivers/spi/meson_spifc.c F:drivers/pinctrl/meson/ F:drivers/power/domain/meson-gx-pwrc-vpu.c diff --git a/drivers/sm/Kconfig b/drivers/sm/Kconfig index 6cc6d55578..b4cc3f768e 100644 --- a/drivers/sm/Kconfig +++ b/drivers/sm/Kconfig @@ -1,2 +1,9 @@ config SM bool "Enable Secure Monitor driver support" + +config MESON_SM + bool "Amlogic Secure Monitor driver" + depends on SM + default n I get: WARNING: unmet direct dependencies detected for MESON_SM Depends on [n]: SM [=n] Selected by [y]: - MESON64_COMMON [=y] && ARM [=y] && ARCH_MESON [=y] so I think this should be: select SM instead of: depends on SM Could you post a fix so I can send the PR ? Neil + help + Say y here to enable the Amlogic secure monitor driver. diff --git a/drivers/sm/Makefile b/drivers/sm/Makefile index af5f475c2b..da81ee898a 100644 --- a/drivers/sm/Makefile +++ b/drivers/sm/Makefile @@ -2,3 +2,4 @@ obj-y += sm-uclass.o obj-$(CONFIG_SANDBOX) += sandbox-sm.o +obj-$(CONFIG_MESON_SM) += meson-sm.o diff --git a/drivers/sm/meson-sm.c b/drivers/sm/meson-sm.c new file mode 100644 index 00..25adaf4560 --- /dev/null +++ b/drivers/sm/meson-sm.c @@ -0,0 +1,198 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2023 SberDevices, Inc. + * + * Author: Alexey Romanov + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct meson_sm_cmd { + u32 smc_id; +}; + +#define SET_CMD(index, id) \ + [index] = { \ + .smc_id = (id), \ + } + +struct meson_sm_data { + u32 cmd_get_shmem_in; + u32 cmd_get_shmem_out; + unsigned int shmem_size; + struct meson_sm_cmd cmd[]; +}; + +struct meson_sm_priv { + void *sm_shmem_in; + void *sm_shmem_out; + const struct meson_sm_data *data; +}; + +static unsigned long __meson_sm_call(u32 cmd, const struct pt_regs *args) +{ + struct pt_regs r = *args; + + r.regs[0] = cmd; + smc_call(&r); + + return r.regs[0]; +}; + +static u32 meson_sm_get_cmd(const struct meson_sm_data *data, + u32 cmd_index) +{ + struct meson_sm_cmd cmd; + + if (cmd_index >= MESON_SMC_CMD_COUNT) + return 0; + + cmd = data->cmd[cmd_index]; + return cmd.smc_id; +} + +static int meson_sm_call(struct udevice *dev, u32 cmd_index, s32 *retval, +struct pt_regs *args) +{ + struct meson_sm_priv *priv = dev_get_priv(dev); + u32 cmd, ret; + + cmd = meson_sm_get_cmd(priv->data, cmd_index); + if (!cmd) + return -ENOENT; + + ret = __meson_sm_call(cmd, args); + if (retval) + *retval = ret; + + return 0; +} + +static int meson_sm_call_read(struct udevice *dev, void *buffer, size_t size, + u32 cmd_index, struct pt_regs *args) +{ + struct meson_sm_priv *priv = dev_get_priv(dev); + s32 nbytes; + int ret; + + if (!buffer || size > priv->data->shmem_size) + return -EINVAL; + + ret = meson_sm_call(dev, cmd_index, &nbytes, args); + if (ret) + return ret; + + if (nbytes < 0 || nbytes > size) + return -ENOBUFS; + + /* In some cases (for example GET_CHIP_ID command), +* SMC doesn't return the number of bytes read, even +* though the bytes were actually read into sm_shmem_out. +* So this check is needed. +*/ + ret = nbytes; + if (!nbytes) + nbytes = size; + + memcpy(buffer, priv->sm_shmem_out, nbytes); + + return ret; +} + +static int meson_sm_call_write(struct udevice *dev, void *buffer, size_t size, + u32 cmd_index, struct pt_regs *args) +{ + struct meson_sm_priv *priv = dev_get_priv(dev); + s32 nbytes; + int ret; + + if (!buffer || size > priv->data->shmem_size) + return -EINVAL; + + memcpy(priv->sm_shmem_in, buffer, size); + + ret = meson_sm_call
Re: [PATCH 16/16] board: rzg2l: Add RZ/G2L SMARC EVK board
On 10/4/23 15:56, Paul Barker wrote: On Wed, Oct 04, 2023 at 02:33:07PM +0200, Marek Vasut wrote: On 10/4/23 11:36, Paul Barker wrote: [...] +int dram_init(void) +{ + return fdtdec_setup_mem_size_base(); +} + +int dram_init_banksize(void) +{ + fdtdec_setup_memory_banksize(); This and the one function above can likely go into arch/mach-rmobile/ We're not able to test every supported mach-rmobile board so we've preferred to keep changes to RZ/G2L specific code where possible. I'm happy to merge this into mach-rmobile (along with the similar code in board/renesas/rcar-common/common.c), but it will only be tested on the boards we have in our team. Don't you already have a G2L specific file in arch/arm/mach-rmobile/ ? (I can test whatever changes on R-Car if needed) We could move these into arch/arm/mach-rmobile/memmap-rzg2l.c I guess. Yep, the memmap*c files are by now a total misnomer. + return 0; +} + +void __weak reset_cpu(void) +{ Is this platform missing a way to reset the system ? Please fix. Adding reset support is on my todo list. I'm prioritising Ethernet support above this right now, but we don't mind too much what order we do things. Let me know if you'd prefer us to prioritise reset support. Isn't the reset like really really simple ? Enable SYSRESET config option and do TFA/SMC reset I guess ? We don't have support for that in TF-A yet. Hmmm, can you whack the reset controller register maybe ? Or is the reset triggered by some PMIC I2C register write ? There are examples of both in board/renesas/
Re: [PATCH 14/16] arm: rmobile: Support RZ/G2L memory map
On 10/4/23 15:54, Paul Barker wrote: On Wed, Oct 04, 2023 at 02:30:53PM +0200, Marek Vasut wrote: On 10/4/23 11:18, Paul Barker wrote: [...] +static struct mm_region rzg2l_mem_map[RZG2L_NR_REGIONS] = { + { + .virt = 0x0UL, + .phys = 0x0UL, + .size = 0x4000UL, + .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | +PTE_BLOCK_NON_SHARE | +PTE_BLOCK_PXN | PTE_BLOCK_UXN + }, { + .virt = 0x4000UL, + .phys = 0x4000UL, + .size = 0x03F0UL, + .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | +PTE_BLOCK_INNER_SHARE + }, { + .virt = 0x47E0UL, What's this part about ? This is copied from the RCar Gen3 memory map. I suspected as much. Please recheck the memory map instead of copy-paste and make sure it is really matching the hardware. Sorry, I wasn't specific enough there. The addition of an entry at 0x4000 of size 0x03F0, followed by a gap until 0x47E0, is coped from R-Car as the way TrustedFirmware and OP-TEE use the first 128MiB of system memory is the same. The mappings here are due to the software configuration of TrustedFirmware & OP-TEE, not due to the hardware. The hardware itself has a pretty simple memory map which is shown in the commit message. The memory map in this file is complete. I have a note in the commit that says "Within the DDR area, the first 128 MiB are reserved by TrustedFirmware.", I probably just need to expand on why we need the mappings at 0x4000 and 0x47E0, instead of just using the mapping from 0x4800 that's in the dtb. Yes please :) The better the commit message is, the easier the long term maintenance is.