[PATCH] board: amlogic: vim3: ethernet mac fixed from serial

2021-01-08 Thread Artem Lapkin
Fixed randomly generated ethernet mac address!

Used meson_generate_serial_ethaddr for generate mac address from
board serial number, if ethaddr variable not defined.

Signed-off-by: Artem Lapkin 
---
 board/amlogic/vim3/vim3.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index 09ef39ff30..0315eaf569 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -133,5 +133,14 @@ int misc_init_r(void)
 {
meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
 
+   u8 mac_addr[6];
+   if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+   meson_generate_serial_ethaddr();
+   eth_env_get_enetaddr("ethaddr", mac_addr);
+   printf("[i] serial eth mac %02X:%02X:%02X:%02X:%02X:%02X\n",
+   mac_addr[0],mac_addr[1],mac_addr[2],
+   mac_addr[3],mac_addr[4],mac_addr[5]);
+   }
+
return 0;
 }
-- 
2.25.1



[PATCH] board: amlogic: vim3: setup ethernet mac from efuse

2021-01-11 Thread Artem Lapkin
Add the board specific code for reading built-in ethernet MAC address from efuse

NOTE: MAC is stored in ASCII format, 1bytes = 2characters by 0 offset

if mac from efuse not valid we use meson_generate_serial_ethaddr

NOTE: remake odroid-n2.c variant from Neil Armstrong 

Signed-off-by: Artem Lapkin 
---
 board/amlogic/vim3/vim3.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index 09ef39ff30..c5d19cc17b 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -11,9 +11,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "khadas-mcu.h"
 
+#define EFUSE_MAC_OFFSET   0
+#define EFUSE_MAC_SIZE 12
+#define MAC_ADDR_LEN   6
+
 /*
  * The VIM3 on-board  MCU can mux the PCIe/USB3.0 shared differential
  * lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between
@@ -131,7 +136,37 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
 
 int misc_init_r(void)
 {
+   u8 mac_addr[MAC_ADDR_LEN];
+   char efuse_mac_addr[EFUSE_MAC_SIZE], tmp[3];
+   ssize_t len;
+
meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
 
+   if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+
+   len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, efuse_mac_addr, 
EFUSE_MAC_SIZE);
+   if (len != EFUSE_MAC_SIZE)
+   return 0;
+
+   /* MAC is stored in ASCII format, 1bytes = 2characters */
+   for (int i = 0; i < 6; i++) {
+   tmp[0] = efuse_mac_addr[i * 2];
+   tmp[1] = efuse_mac_addr[i * 2 + 1];
+   tmp[2] = '\0';
+   mac_addr[i] = simple_strtoul(tmp, NULL, 16);
+   }
+
+   if (is_valid_ethaddr(mac_addr))
+   eth_env_set_enetaddr("ethaddr", mac_addr);
+   else
+   meson_generate_serial_ethaddr();
+
+   eth_env_get_enetaddr("ethaddr", mac_addr);
+   printf("[i] setup onboard mac %02X:%02X:%02X:%02X:%02X:%02X\n",
+   mac_addr[0],mac_addr[1],mac_addr[2],
+   mac_addr[3],mac_addr[4],mac_addr[5]);
+
+   }
+
return 0;
 }
-- 
2.25.1



[PATCH] board: amlogic: vim3: fix setup ethernet mac from efuse

2021-01-12 Thread Artem Lapkin
Fix reading built-in ethernet MAC address from efuse

NOTE: MAC is stored in ASCII format, 1bytes = 2characters by 0 offset

if mac from efuse not valid we use meson_generate_serial_ethaddr

NOTE: remake odroid-n2.c variant from Neil Armstrong 

Signed-off-by: Artem Lapkin 
---
 board/amlogic/vim3/vim3.c | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index 824fff8262..87d9fe1f02 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -139,26 +139,42 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
 }
 
 #define EFUSE_MAC_OFFSET   0
-#define EFUSE_MAC_SIZE 6
+#define EFUSE_MAC_SIZE 12
+#define MAC_ADDR_LEN   6
 
 int misc_init_r(void)
 {
-   uint8_t mac_addr[EFUSE_MAC_SIZE];
+   uint8_t mac_addr[MAC_ADDR_LEN];
+   char efuse_mac_addr[EFUSE_MAC_SIZE], tmp[3];
ssize_t len;
 
meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
 
if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
- mac_addr, EFUSE_MAC_SIZE);
+ efuse_mac_addr, EFUSE_MAC_SIZE);
if (len != EFUSE_MAC_SIZE)
return 0;
 
+   /* MAC is stored in ASCII format, 1bytes = 2characters */
+   for (int i = 0; i < 6; i++) {
+   tmp[0] = efuse_mac_addr[i * 2];
+   tmp[1] = efuse_mac_addr[i * 2 + 1];
+   tmp[2] = '\0';
+   mac_addr[i] = simple_strtoul(tmp, NULL, 16);
+   }
+
if (is_valid_ethaddr(mac_addr))
eth_env_set_enetaddr("ethaddr", mac_addr);
else
meson_generate_serial_ethaddr();
+
+   eth_env_get_enetaddr("ethaddr", mac_addr);
+   printf("[i] setup onboard mac %02X:%02X:%02X:%02X:%02X:%02X\n",
+   mac_addr[0],mac_addr[1],mac_addr[2],
+   mac_addr[3],mac_addr[4],mac_addr[5]);
}
 
return 0;
 }
+
-- 
2.25.1



[PATCH] board: amlogic: vim3: fix setup ethernet mac from efuse

2021-01-12 Thread Artem Lapkin
Fix reading built-in ethernet MAC address from efuse

NOTE: MAC is stored in ASCII format, 1bytes = 2characters by 0 offset

if mac from efuse not valid we use meson_generate_serial_ethaddr

NOTE: remake odroid-n2.c from Neil Armstrong 

Signed-off-by: Artem Lapkin 
---
 board/amlogic/vim3/vim3.c | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index 824fff8262..87d9fe1f02 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -139,26 +139,42 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
 }
 
 #define EFUSE_MAC_OFFSET   0
-#define EFUSE_MAC_SIZE 6
+#define EFUSE_MAC_SIZE 12
+#define MAC_ADDR_LEN   6
 
 int misc_init_r(void)
 {
-   uint8_t mac_addr[EFUSE_MAC_SIZE];
+   u8 mac_addr[MAC_ADDR_LEN];
+   char efuse_mac_addr[EFUSE_MAC_SIZE], tmp[3];
ssize_t len;
 
meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
 
if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
- mac_addr, EFUSE_MAC_SIZE);
+ efuse_mac_addr, EFUSE_MAC_SIZE);
if (len != EFUSE_MAC_SIZE)
return 0;
 
+   /* MAC is stored in ASCII format, 1bytes = 2characters */
+   for (int i = 0; i < 6; i++) {
+   tmp[0] = efuse_mac_addr[i * 2];
+   tmp[1] = efuse_mac_addr[i * 2 + 1];
+   tmp[2] = '\0';
+   mac_addr[i] = simple_strtoul(tmp, NULL, 16);
+   }
+
if (is_valid_ethaddr(mac_addr))
eth_env_set_enetaddr("ethaddr", mac_addr);
else
meson_generate_serial_ethaddr();
+
+   eth_env_get_enetaddr("ethaddr", mac_addr);
+   printf("[i] setup onboard mac %02X:%02X:%02X:%02X:%02X:%02X\n",
+  mac_addr[0], mac_addr[1], mac_addr[2],
+  mac_addr[3], mac_addr[4], mac_addr[5]);
}
 
return 0;
 }
+
-- 
2.25.1



[PATCH 0/2] fix hdmi video setup for khadas vim3x boards

2021-01-15 Thread Artem Lapkin
next patches add missed parts

Artem Lapkin (2):
  gpio: gpio-uclass: add OPEN_DRAIN flag parsing
  arm64: dts: meson: fix meson-khadas-vim3-u-boot.dtsi

 arch/arm/dts/meson-khadas-vim3-u-boot.dtsi |  2 ++
 drivers/gpio/gpio-uclass.c | 10 ++
 2 files changed, 12 insertions(+)

-- 
2.25.1



[PATCH 1/2] gpio: gpio-uclass: add OPEN_DRAIN flag parsing

2021-01-15 Thread Artem Lapkin
add GPIOD_OPEN_DRAIN flag which cant parsed properly

Problem: for example cant power video system for sm1 g12a socs
because OPEN_DRAIN flag cant parsed

DTS examples:

```
$ grep GPIO_OPEN_DRAIN\>  arch/arm/dts/meson-*.dt*
arch/arm/dts/meson-g12a-sei510.dts: gpio = <&gpio GPIOH_8 
GPIO_OPEN_DRAIN>;
arch/arm/dts/meson-g12a-u200.dts:   gpio = <&gpio GPIOH_8 
GPIO_OPEN_DRAIN>;
arch/arm/dts/meson-gx-libretech-pc.dtsi:gpio = <&gpio GPIOH_3 
GPIO_OPEN_DRAIN>;
arch/arm/dts/meson-khadas-vim3.dtsi:gpio = <&gpio GPIOH_8 
GPIO_OPEN_DRAIN>;
arch/arm/dts/meson-sm1-sei610.dts:  gpio = <&gpio GPIOH_8 
GPIO_OPEN_DRAIN>;
```

Signed-off-by: Artem Lapkin 
---
 drivers/gpio/gpio-uclass.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index bad6b71e0c..6225f32457 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -574,6 +574,15 @@ int dm_gpio_set_value(const struct gpio_desc *desc, int 
value)
if (ret)
return ret;
 
+   if (desc->flags & GPIOD_OPEN_DRAIN) {
+   if (value)
+   gpio_get_ops(desc->dev)->direction_input(desc->dev, 
desc->offset);
+   else
+   gpio_get_ops(desc->dev)->direction_output(desc->dev, 
desc->offset, 0);
+
+   return 0;
+   }
+
if (desc->flags & GPIOD_ACTIVE_LOW)
value = !value;
 
-- 
2.25.1



[PATCH 2/2] arm64: dts: meson: fix meson-khadas-vim3-u-boot.dtsi

2021-01-15 Thread Artem Lapkin
Add missed include meson-g12-common-u-boot.dtsi

PROBLEM: missed hdmi video setup for VIM3 and VIM3L boards

Signed-off-by: Artem Lapkin 
---
 arch/arm/dts/meson-khadas-vim3-u-boot.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/dts/meson-khadas-vim3-u-boot.dtsi 
b/arch/arm/dts/meson-khadas-vim3-u-boot.dtsi
index 81fd5be378..5d6444cbac 100644
--- a/arch/arm/dts/meson-khadas-vim3-u-boot.dtsi
+++ b/arch/arm/dts/meson-khadas-vim3-u-boot.dtsi
@@ -10,6 +10,8 @@
};
 };
 
+#include "meson-g12-common-u-boot.dtsi"
+
 &sd_emmc_c {
status = "okay";
pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_4b_pins>, <&emmc_ds_pins>;
-- 
2.25.1



[PATCH] video: meson: add HDMI fail-save FullHD option

2021-01-15 Thread Artem Lapkin
add VIDEO_MESON_HDMI_FAIL_SAVE_FULL_HD configuration option

ABOUT:

Force setup FullHD display mode, if proper timing cant readed.
from display! Its happens for some 4K display, which send
unsupported high timings, but same time can works as FullHD!
Also its will be useful for suspended or disconnected displays.

NOTE: this option disabled by default

Signed-off-by: Artem Lapkin 
---
 drivers/video/meson/Kconfig | 10 ++
 drivers/video/meson/meson_vpu.c | 19 +--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/video/meson/Kconfig b/drivers/video/meson/Kconfig
index 0c9ddeb8..55d67700 100644
--- a/drivers/video/meson/Kconfig
+++ b/drivers/video/meson/Kconfig
@@ -10,3 +10,13 @@ config VIDEO_MESON
select DISPLAY
help
  Enable Amlogic Meson Video Processing Unit video support.
+
+config VIDEO_MESON_HDMI_FAIL_SAVE_FULL_HD
+   bool "Enable HDMI fail-save FullHD mode"
+   depends on VIDEO_MESON
+   default n
+   help
+ Force setup FullHD display mode, if proper timing cant readed.
+ from display! Its happens for some 4K display, which send
+ unsupported high timings, but same time can works as FullHD!
+ Also its will be useful for suspended or disconnected displays
diff --git a/drivers/video/meson/meson_vpu.c b/drivers/video/meson/meson_vpu.c
index 4868839f..af677a45 100644
--- a/drivers/video/meson/meson_vpu.c
+++ b/drivers/video/meson/meson_vpu.c
@@ -52,8 +52,23 @@ static int meson_vpu_setup_mode(struct udevice *dev, struct 
udevice *disp)
if (disp) {
ret = display_read_timing(disp, &timing);
if (ret) {
-   debug("%s: Failed to read timings\n", __func__);
-   goto cvbs;
+   if 
(IS_ENABLED(CONFIG_VIDEO_MESON_HDMI_FAIL_SAVE_FULL_HD)) {
+   printf("DISPLAY: setup failsave FullHD mode\n");
+   timing.pixelclock.typ = 14850;
+   timing.hactive.typ = 1920;
+   timing.hfront_porch.typ = 88;
+   timing.hback_porch.typ = 148;
+   timing.hsync_len.typ = 44;
+   timing.vactive.typ = 1080;
+   timing.vfront_porch.typ = 4;
+   timing.vback_porch.typ = 36;
+   timing.vsync_len.typ = 5;
+   timing.flags = 10;
+   timing.hdmi_monitor = true;
+   } else {
+   debug("%s: Failed to read timings\n", __func__);
+   goto cvbs;
+   }
}
 
uc_priv->xsize = timing.hactive.typ;
-- 
2.25.1



[PATCH] cmd: pxe_utils: fix ipappend ip config empty vars

2021-01-21 Thread Artem Lapkin
PROBLEM: If ipaddr, serverip, gatewayip or netmask variable undefined
we can have for example ip=192.168.2.33::192.168.2.1:255.255.255.0
yes its works same for linux kernel, but im think no need print 

SUGGESTED SOLUTION:
if some variable was undefined we need just print empty place like this
ip=192.168.2.33::192.168.2.1:255.255.255.0

Signed-off-by: Artem Lapkin 

---
 cmd/pxe_utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 8716e782..2049c0f3 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -395,9 +395,12 @@ static int label_boot(struct cmd_tbl *cmdtp, struct 
pxe_label *label)
}
 
if (label->ipappend & 0x1) {
+   char *a = env_get("ipaddr");
+   char *b = env_get("serverip");
+   char *c = env_get("gatewayip");
+   char *d = env_get("netmask");
sprintf(ip_str, " ip=%s:%s:%s:%s",
-   env_get("ipaddr"), env_get("serverip"),
-   env_get("gatewayip"), env_get("netmask"));
+   a ? a : "", b ? b : "", c ? c : "", d ? d : "");
}
 
 #ifdef CONFIG_CMD_NET
-- 
2.25.1



[PATCH] rk3399: boot_devices fix spinor node name

2021-05-26 Thread Artem Lapkin
Problem: board_spl_was_booted_from return wrong boot_devices[3] value 
/spi@ff1d and same-as-spl dont work properly for SPINOR flash
because arch/arm/mach-rockchip/spl-boot-order.c spl_node_to_boot_device 
need parse SPINOR flash node as UCLASS_SPI_FLASH

spl-boot-order: same-as-spl > *** BOOT_SOURCE_ID 3 (2:emmc 3:spi 5:sd ...
/spi@ff1d > board_boot_order: could not map node @618 to a boot-device
/sdhci@fe33 > /mmc@fe32

Solution: just change it to /spi@ff1d/flash@0

spl-boot-order: same-as-spl > *** BOOT_SOURCE_ID 3 (2:emmc 3:spi 5:sd ...
/spi@ff1d/flash@0 > /sdhci@fe33 > /mmc@fe320000

Signed-off-by: Artem Lapkin 
---
 arch/arm/mach-rockchip/rk3399/rk3399.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c 
b/arch/arm/mach-rockchip/rk3399/rk3399.c
index 869d2159..69e0c8c2 100644
--- a/arch/arm/mach-rockchip/rk3399/rk3399.c
+++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
@@ -28,7 +28,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
[BROM_BOOTSOURCE_EMMC] = "/sdhci@fe33",
-   [BROM_BOOTSOURCE_SPINOR] = "/spi@ff1d",
+   [BROM_BOOTSOURCE_SPINOR] = "/spi@ff1d/flash@0",
[BROM_BOOTSOURCE_SD] = "/mmc@fe32",
 };
 
-- 
2.25.1



[PATCH] evb_rk3399: add usb ohci definations

2021-05-26 Thread Artem Lapkin
Problem: not possible to use CONFIG_USB_OHCI_HCD=y and
CONFIG_USB_OHCI_GENERIC=y options without CONFIG_USB_OHCI_NEW and
CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS definations

Add missed definations.

Signed-off-by: Artem Lapkin 
---
 include/configs/evb_rk3399.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/configs/evb_rk3399.h b/include/configs/evb_rk3399.h
index b7e85037..492b7b4d 100644
--- a/include/configs/evb_rk3399.h
+++ b/include/configs/evb_rk3399.h
@@ -15,4 +15,7 @@
 
 #define SDRAM_BANK_SIZE(2UL << 30)
 
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 2
+
 #endif
-- 
2.25.1



[PATCH] rk3399_common: setup fdtoverlay_addr_r value

2021-05-26 Thread Artem Lapkin
fdtoverlay (pxe_utils) require define fdtoverlay_addr_r env variable
for example sunxi-common.h meson64.h already have it.

Signed-off-by: Artem Lapkin 
---
 include/configs/rk3399_common.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
index f0be3830..13d15b1f 100644
--- a/include/configs/rk3399_common.h
+++ b/include/configs/rk3399_common.h
@@ -51,6 +51,7 @@
"script_size_f=0x2000\0" \
"pxefile_addr_r=0x0060\0" \
"fdt_addr_r=0x01f0\0" \
+   "fdtoverlay_addr_r=0x0200\0" \
"kernel_addr_r=0x0208\0" \
"ramdisk_addr_r=0x0600\0" \
"kernel_comp_addr_r=0x0800\0" \
-- 
2.25.1



[PATCH] meson64: add kernel compression vars

2021-05-26 Thread Artem Lapkin
make possible to load simple compressed linux kernel for meson64

Signed-off-by: Artem Lapkin 
---
 include/configs/meson64.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index e3d25493..552a08c2 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -113,6 +113,8 @@
"stdin=" STDIN_CFG "\0" \
"stdout=" STDOUT_CFG "\0" \
"stderr=" STDOUT_CFG "\0" \
+   "kernel_comp_addr_r=0x0d08\0" \
+   "kernel_comp_size=0x200\0" \
"fdt_addr_r=0x08008000\0" \
"loadaddr=0x0100\0" \
"scriptaddr=0x0800\0" \
-- 
2.25.1



[PATCH] DTS: khadas-vim2 spi-flash change spi-max-frequency

2021-05-27 Thread Artem Lapkin
change max freq to 104Mhz for SPI-NOR flash

Signed-off-by: Artem Lapkin 
---
 arch/arm/dts/meson-gxm-khadas-vim2.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/meson-gxm-khadas-vim2.dts 
b/arch/arm/dts/meson-gxm-khadas-vim2.dts
index bff8ec2c1c..e2bd9c7c81 100644
--- a/arch/arm/dts/meson-gxm-khadas-vim2.dts
+++ b/arch/arm/dts/meson-gxm-khadas-vim2.dts
@@ -341,7 +341,7 @@
#size-cells = <1>;
compatible = "winbond,w25q16", "jedec,spi-nor";
reg = <0>;
-   spi-max-frequency = <300>;
+   spi-max-frequency = <10400>;
};
 };
 
-- 
2.25.1



[PATCH] VIM3: mmc_get_env_dev correct non emmc boot sources

2021-05-27 Thread Artem Lapkin
need return -1 if boot source is not EMMC or SD ( for example it will be
useful if we have multy env sources configuration and device was booted
from SPI flash and env need read from SPI not from mmc )

Signed-off-by: Artem Lapkin 
---
 board/amlogic/vim3/vim3.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index 6cd5f2e1..71aaa0d8 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -19,9 +19,15 @@
 
 int mmc_get_env_dev(void)
 {
-   if (meson_get_boot_device() == BOOT_DEVICE_EMMC)
+   switch (meson_get_boot_device()) {
+   case BOOT_DEVICE_EMMC:
return 2;
-   return 1;
+   case BOOT_DEVICE_SD:
+   return 1;
+   default:
+   /* boot device is not EMMC|SD */
+   return -1;
+   }
 }
 
 /*
-- 
2.25.1



[PATCH] DTS: khadas-vim2 spi-flash change spi-max-frequency v2

2021-05-27 Thread Artem Lapkin
change max freq to 104Mhz for SPI-NOR flash

Signed-off-by: Artem Lapkin 
---
 arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi 
b/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
index c1763336cf..247817adea 100644
--- a/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
+++ b/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
@@ -18,5 +18,6 @@
 };
 
 &spifc {
+   spi-max-frequency = <10400>;
status = "okay";
 };
-- 
2.25.1



[PATCH 0/2] ARM64: rockchip: evb_rk3399: Khadas Edge add USB OHCI

2021-06-06 Thread Artem Lapkin
Problem: USB2.0 port can recognize any USB1.1 devices (like usb keyboard)
Add missed USB OHCI configuration

Artem Lapkin (2):
  ARM64: rockchip: evb_rk3399: add usb ohci definations
  configs: rockchip: rk3399: Khadas Edge add USB OHCI

 configs/khadas-edge-captain-rk3399_defconfig | 2 ++
 configs/khadas-edge-rk3399_defconfig | 2 ++
 configs/khadas-edge-v-rk3399_defconfig   | 2 ++
 include/configs/evb_rk3399.h | 3 +++
 4 files changed, 9 insertions(+)

-- 
2.25.1



[PATCH 1/2] ARM64: rockchip: evb_rk3399: add usb ohci definations

2021-06-06 Thread Artem Lapkin
Problem: USB2.0 port can recognize any USB1.1 devices (like usb keyboard)
Add missed USB OHCI configuration

USB device tree:
  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller

  1  Hub (12 Mb/s, 0mA)
  |   U-Boot Root Hub
  |
  +-2  Human Interface (1.5 Mb/s, 100mA)
Dell KB216 Wired Keyboard

Signed-off-by: Artem Lapkin 
---
 include/configs/evb_rk3399.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/configs/evb_rk3399.h b/include/configs/evb_rk3399.h
index b7e850370b..492b7b4df1 100644
--- a/include/configs/evb_rk3399.h
+++ b/include/configs/evb_rk3399.h
@@ -15,4 +15,7 @@
 
 #define SDRAM_BANK_SIZE(2UL << 30)
 
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 2
+
 #endif
-- 
2.25.1



[PATCH 2/2] configs: rockchip: rk3399: Khadas Edge add USB OHCI

2021-06-06 Thread Artem Lapkin
Problem: USB2.0 port can recognize any USB1.1 devices (like usb keyboard)
Add missed USB OHCI configuration

USB device tree:
  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller

  1  Hub (12 Mb/s, 0mA)
  |   U-Boot Root Hub
  |
  +-2  Human Interface (1.5 Mb/s, 100mA)
Dell KB216 Wired Keyboard

Signed-off-by: Artem Lapkin 
---
 configs/khadas-edge-captain-rk3399_defconfig | 2 ++
 configs/khadas-edge-rk3399_defconfig | 2 ++
 configs/khadas-edge-v-rk3399_defconfig   | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/configs/khadas-edge-captain-rk3399_defconfig 
b/configs/khadas-edge-captain-rk3399_defconfig
index 63074a4eed..ce6b492b3d 100644
--- a/configs/khadas-edge-captain-rk3399_defconfig
+++ b/configs/khadas-edge-captain-rk3399_defconfig
@@ -50,6 +50,8 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_GENERIC=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_ASIX88179=y
diff --git a/configs/khadas-edge-rk3399_defconfig 
b/configs/khadas-edge-rk3399_defconfig
index cf5a6da384..e52963e86f 100644
--- a/configs/khadas-edge-rk3399_defconfig
+++ b/configs/khadas-edge-rk3399_defconfig
@@ -49,6 +49,8 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_GENERIC=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_ASIX88179=y
diff --git a/configs/khadas-edge-v-rk3399_defconfig 
b/configs/khadas-edge-v-rk3399_defconfig
index 197a6f6677..5f61df85da 100644
--- a/configs/khadas-edge-v-rk3399_defconfig
+++ b/configs/khadas-edge-v-rk3399_defconfig
@@ -50,6 +50,8 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_GENERIC=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_ASIX88179=y
-- 
2.25.1



[PATCH] board: amlogic: vim3: fix phy-names property setup

2021-07-12 Thread Artem Lapkin
phy-names was improperly implemented resulting in an inoperable USB-OTG
port.

- phy-names = "usb2-phy0\0\0usb2-phy1\0";
+ phy-names = "usb2-phy0\0usb2-phy1";

Signed-off-by: Artem Lapkin 
---
 board/amlogic/vim3/vim3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index c8ebd676..6a67a39c 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -109,8 +109,8 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
}
 
/* Update PHY names (mandatory to disable USB3.0) */
-   len = strlcpy(data, "usb2-phy0", 32) + 1;
-   len += strlcpy(&data[len], "usb2-phy1", 32 - len) + 1;
+   len = strlcpy(data, "usb2-phy0", 32);
+   len += strlcpy(&data[len], "usb2-phy1", 32 - len);
ret = fdt_setprop(blob, node, "phy-names", data, len);
if (ret < 0) {
printf("vim3: failed to update usb phy names property 
(%d)\n", ret);
-- 
2.25.1



[PATCH] dts: khadas vim series: Use devicetree for SMBIOS settings

2021-07-14 Thread Artem Lapkin
Khadas vim series: Use devicetree for SMBIOS settings
Add settings and enable the default sysinfo driver so that these can come
from the device tree.

Signed-off-by: Artem Lapkin 
---
 .../meson-g12b-a311d-khadas-vim3-u-boot.dtsi  | 23 +++
 .../meson-gxl-s905x-khadas-vim-u-boot.dtsi| 23 +++
 .../arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi | 21 +
 .../dts/meson-sm1-khadas-vim3l-u-boot.dtsi| 23 +++
 4 files changed, 90 insertions(+)

diff --git a/arch/arm/dts/meson-g12b-a311d-khadas-vim3-u-boot.dtsi 
b/arch/arm/dts/meson-g12b-a311d-khadas-vim3-u-boot.dtsi
index 489efa15..fcd6f053 100644
--- a/arch/arm/dts/meson-g12b-a311d-khadas-vim3-u-boot.dtsi
+++ b/arch/arm/dts/meson-g12b-a311d-khadas-vim3-u-boot.dtsi
@@ -6,3 +6,26 @@
 
 #include "meson-g12-common-u-boot.dtsi"
 #include "meson-khadas-vim3-u-boot.dtsi"
+
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "VIM3";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "VIM3";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "VIM3";
+   };
+   };
+   };
+};
diff --git a/arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi 
b/arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi
index 39270ea7..20e36d1b 100644
--- a/arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi
+++ b/arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi
@@ -5,3 +5,26 @@
  */
 
 #include "meson-gxl-u-boot.dtsi"
+
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "VIM";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "VIM";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "VIM";
+   };
+   };
+   };
+};
diff --git a/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi 
b/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
index c1763336..41480c9a 100644
--- a/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
+++ b/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
@@ -10,6 +10,27 @@
aliases {
spi0 = &spifc;
};
+
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "VIM2";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "VIM2";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "VIM2";
+   };
+   };
+   };
 };
 
 &sd_emmc_c {
diff --git a/arch/arm/dts/meson-sm1-khadas-vim3l-u-boot.dtsi 
b/arch/arm/dts/meson-sm1-khadas-vim3l-u-boot.dtsi
index a591c0c9..06b81f23 100644
--- a/arch/arm/dts/meson-sm1-khadas-vim3l-u-boot.dtsi
+++ b/arch/arm/dts/meson-sm1-khadas-vim3l-u-boot.dtsi
@@ -6,3 +6,26 @@
 
 #include "meson-sm1-u-boot.dtsi"
 #include "meson-khadas-vim3-u-boot.dtsi"
+
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "VIM3L";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "VIM3L";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "VIM3L";
+   };
+   };
+   };
+};
-- 
2.25.1



[PATCH] configs: khadas-vim*: Enable SMBIOS

2021-07-14 Thread Artem Lapkin
Enable configs to support SMBIOS for all Khadas vim* boards

Signed-off-by: Artem Lapkin 
---
 configs/khadas-vim2_defconfig  | 2 ++
 configs/khadas-vim3_defconfig  | 2 ++
 configs/khadas-vim3l_defconfig | 2 ++
 configs/khadas-vim_defconfig   | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/configs/khadas-vim2_defconfig b/configs/khadas-vim2_defconfig
index 32513998..5d673463 100644
--- a/configs/khadas-vim2_defconfig
+++ b/configs/khadas-vim2_defconfig
@@ -50,6 +50,8 @@ CONFIG_DM_RESET=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_MESON_SPIFC=y
diff --git a/configs/khadas-vim3_defconfig b/configs/khadas-vim3_defconfig
index c4b24fc3..5a7a9006 100644
--- a/configs/khadas-vim3_defconfig
+++ b/configs/khadas-vim3_defconfig
@@ -61,6 +61,8 @@ CONFIG_DM_RESET=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_MESON_SPIFC=y
diff --git a/configs/khadas-vim3l_defconfig b/configs/khadas-vim3l_defconfig
index 0c731d4c..d719511f 100644
--- a/configs/khadas-vim3l_defconfig
+++ b/configs/khadas-vim3l_defconfig
@@ -61,6 +61,8 @@ CONFIG_DM_RESET=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_MESON_SPIFC=y
diff --git a/configs/khadas-vim_defconfig b/configs/khadas-vim_defconfig
index 2df00d54..dc6365fc 100644
--- a/configs/khadas-vim_defconfig
+++ b/configs/khadas-vim_defconfig
@@ -44,6 +44,8 @@ CONFIG_DM_RESET=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
-- 
2.25.1



[PATCH] dts: khadas Edge: Use devicetree for SMBIOS settings

2021-07-14 Thread Artem Lapkin
Khadas Edge series: Use devicetree for SMBIOS settings
Add settings and enable the default sysinfo driver so that these can come
from the device tree.

Signed-off-by: Artem Lapkin 
---
 arch/arm/dts/rk3399-khadas-edge-u-boot.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm/dts/rk3399-khadas-edge-u-boot.dtsi 
b/arch/arm/dts/rk3399-khadas-edge-u-boot.dtsi
index a7039d74a0..0e1c38c6e6 100644
--- a/arch/arm/dts/rk3399-khadas-edge-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-khadas-edge-u-boot.dtsi
@@ -10,6 +10,27 @@
chosen {
u-boot,spl-boot-order = "same-as-spl", &sdhci, &sdmmc;
};
+
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "Edge";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "Edge";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "Edge";
+   };
+   };
+   };
 };
 
 &vdd_log {
-- 
2.25.1



[PATCH] configs: khadas-edge series: Enable SMBIOS

2021-07-14 Thread Artem Lapkin
Enable configs to support SMBIOS for all Khadas Edge* boards

Signed-off-by: Artem Lapkin 
---
 configs/khadas-edge-captain-rk3399_defconfig | 2 ++
 configs/khadas-edge-rk3399_defconfig | 2 ++
 configs/khadas-edge-v-rk3399_defconfig   | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/configs/khadas-edge-captain-rk3399_defconfig 
b/configs/khadas-edge-captain-rk3399_defconfig
index 146a6a43..6dc78741 100644
--- a/configs/khadas-edge-captain-rk3399_defconfig
+++ b/configs/khadas-edge-captain-rk3399_defconfig
@@ -45,6 +45,8 @@ CONFIG_RAM_RK3399_LPDDR4=y
 CONFIG_BAUDRATE=150
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYSRESET=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
diff --git a/configs/khadas-edge-rk3399_defconfig 
b/configs/khadas-edge-rk3399_defconfig
index c7445fec..c9685f87 100644
--- a/configs/khadas-edge-rk3399_defconfig
+++ b/configs/khadas-edge-rk3399_defconfig
@@ -44,6 +44,8 @@ CONFIG_RAM_RK3399_LPDDR4=y
 CONFIG_BAUDRATE=150
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYSRESET=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
diff --git a/configs/khadas-edge-v-rk3399_defconfig 
b/configs/khadas-edge-v-rk3399_defconfig
index 5e9c29a3..8833b853 100644
--- a/configs/khadas-edge-v-rk3399_defconfig
+++ b/configs/khadas-edge-v-rk3399_defconfig
@@ -45,6 +45,8 @@ CONFIG_RAM_RK3399_LPDDR4=y
 CONFIG_BAUDRATE=150
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYSRESET=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
-- 
2.25.1



[PATCH] net: designware: improve ethernet DMA reset

2021-07-20 Thread Artem Lapkin
Problem: uboot ethernet always have "DMA reset timeout" after
linux usage, detected on VIM2 VIM3 VIM3L amlogic devices,
mainline uboot and mainline linux > 5.1? .

How-to reproduce:

1) Poweron device => ethernet uboot work fine.
2) Linux start and ethernet interface up and same works.
3) Reboot to uboot again and we cant use ethernet anymore.
uboot always have "DMA reset timeout" inside designware_eth_init()
only poweroff/poweron cycle can solve this problem.

Solution: add phy_reset() into waiting DMA reset cycle,
this insertion doesn't break normal behaviour (maybe).

Note: same need explore real problem why its happens! because this 
patch may be just hack.

Signed-off-by: Artem Lapkin 
---
 drivers/net/designware.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 5d92257e..6485c46d 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -371,6 +371,7 @@ int designware_eth_init(struct dw_eth_dev *priv, u8 
*enetaddr)
struct eth_dma_regs *dma_p = priv->dma_regs_p;
unsigned int start;
int ret;
+   int phy_reset_force = 0;
 
writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode);
 
@@ -389,6 +390,9 @@ int designware_eth_init(struct dw_eth_dev *priv, u8 
*enetaddr)
printf("DMA reset timeout\n");
return -ETIMEDOUT;
}
+   // forced phy reset after 0.2s can help with DMAMAC_SRST
+   if (phy_reset_force++ == 2)
+   phy_reset(priv->phydev);
 
mdelay(100);
};
-- 
2.25.1



[PATCH] ARM: dts: meson: Use devicetree for SMBIOS settings for Khadas VIM boards

2021-07-26 Thread Artem Lapkin
Khadas vim series: Use devicetree for SMBIOS settings
Add settings and enable the default sysinfo driver so that these can come
from the device tree.

Reviewed-by: Neil Armstrong 
Signed-off-by: Artem Lapkin 
---
 .../meson-g12b-a311d-khadas-vim3-u-boot.dtsi  | 23 +++
 .../meson-gxl-s905x-khadas-vim-u-boot.dtsi| 23 +++
 .../arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi | 21 +
 .../dts/meson-sm1-khadas-vim3l-u-boot.dtsi| 23 +++
 4 files changed, 90 insertions(+)

diff --git a/arch/arm/dts/meson-g12b-a311d-khadas-vim3-u-boot.dtsi 
b/arch/arm/dts/meson-g12b-a311d-khadas-vim3-u-boot.dtsi
index 489efa15..fcd6f053 100644
--- a/arch/arm/dts/meson-g12b-a311d-khadas-vim3-u-boot.dtsi
+++ b/arch/arm/dts/meson-g12b-a311d-khadas-vim3-u-boot.dtsi
@@ -6,3 +6,26 @@
 
 #include "meson-g12-common-u-boot.dtsi"
 #include "meson-khadas-vim3-u-boot.dtsi"
+
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "VIM3";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "VIM3";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "VIM3";
+   };
+   };
+   };
+};
diff --git a/arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi 
b/arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi
index 39270ea7..20e36d1b 100644
--- a/arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi
+++ b/arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi
@@ -5,3 +5,26 @@
  */
 
 #include "meson-gxl-u-boot.dtsi"
+
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "VIM";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "VIM";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "VIM";
+   };
+   };
+   };
+};
diff --git a/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi 
b/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
index c1763336..41480c9a 100644
--- a/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
+++ b/arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi
@@ -10,6 +10,27 @@
aliases {
spi0 = &spifc;
};
+
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "VIM2";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "VIM2";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "VIM2";
+   };
+   };
+   };
 };
 
 &sd_emmc_c {
diff --git a/arch/arm/dts/meson-sm1-khadas-vim3l-u-boot.dtsi 
b/arch/arm/dts/meson-sm1-khadas-vim3l-u-boot.dtsi
index a591c0c9..06b81f23 100644
--- a/arch/arm/dts/meson-sm1-khadas-vim3l-u-boot.dtsi
+++ b/arch/arm/dts/meson-sm1-khadas-vim3l-u-boot.dtsi
@@ -6,3 +6,26 @@
 
 #include "meson-sm1-u-boot.dtsi"
 #include "meson-khadas-vim3-u-boot.dtsi"
+
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "khadas";
+   product = "VIM3L";
+   };
+
+   baseboard {
+   manufacturer = "khadas";
+   product = "VIM3L";
+   };
+
+   chassis {
+   manufacturer = "khadas";
+   product = "VIM3L";
+   };
+   };
+   };
+};
-- 
2.25.1



[PATCH] configs: Enable SMBIOS for Khadas VIM boards

2021-07-26 Thread Artem Lapkin
Enable configs to support SMBIOS for all Khadas VIM boards

Reviewed-by: Neil Armstrong 
Signed-off-by: Artem Lapkin 
---
 configs/khadas-vim2_defconfig  | 2 ++
 configs/khadas-vim3_defconfig  | 2 ++
 configs/khadas-vim3l_defconfig | 2 ++
 configs/khadas-vim_defconfig   | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/configs/khadas-vim2_defconfig b/configs/khadas-vim2_defconfig
index 32513998..5d673463 100644
--- a/configs/khadas-vim2_defconfig
+++ b/configs/khadas-vim2_defconfig
@@ -50,6 +50,8 @@ CONFIG_DM_RESET=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_MESON_SPIFC=y
diff --git a/configs/khadas-vim3_defconfig b/configs/khadas-vim3_defconfig
index c4b24fc3..5a7a9006 100644
--- a/configs/khadas-vim3_defconfig
+++ b/configs/khadas-vim3_defconfig
@@ -61,6 +61,8 @@ CONFIG_DM_RESET=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_MESON_SPIFC=y
diff --git a/configs/khadas-vim3l_defconfig b/configs/khadas-vim3l_defconfig
index 0c731d4c..d719511f 100644
--- a/configs/khadas-vim3l_defconfig
+++ b/configs/khadas-vim3l_defconfig
@@ -61,6 +61,8 @@ CONFIG_DM_RESET=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_MESON_SPIFC=y
diff --git a/configs/khadas-vim_defconfig b/configs/khadas-vim_defconfig
index 2df00d54..dc6365fc 100644
--- a/configs/khadas-vim_defconfig
+++ b/configs/khadas-vim_defconfig
@@ -44,6 +44,8 @@ CONFIG_DM_RESET=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
-- 
2.25.1



[PATCH] pxe_utils: improve dftoverlay path

2021-02-26 Thread Artem Lapkin
I think be useful improve dftoverlay path logic, welcome for any suggestions.

Fdtoverlaydir definition usage example

LABEL linux
...
FDTOVERLAYDIR fdt
FDTOVERLAYS ethmac_disable.dtbo pcie_disable.dtbo vpu_disable.dtbo
# same as 
# FDTOVERLAYS fdt/ethmac_disable.dtbo fdt/pcie_disable.dtbo fdt/vpu_disable.dtbo

Usage without overlayfile extension (.dtbo)

LABEL linux
...
FDTOVERLAYS fdt/ethmac_disable fdt/pcie_disable fdt/vpu_disable
# same as 
# FDTOVERLAYS fdt/ethmac_disable.dtbo fdt/pcie_disable.dtbo fdt/vpu_disable.dtbo

Complex usage

LABEL linux
...
FDTOVERLAYDIR fdt
FDTOVERLAYS ethmac_disable pcie_disable vpu_disable
# same as 
# FDTOVERLAYS fdt/ethmac_disable.dtbo fdt/pcie_disable.dtbo fdt/vpu_disable.dtbo

Signed-off-by: Artem Lapkin 
---
 cmd/pxe_utils.c | 22 --
 cmd/pxe_utils.h |  1 +
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 333f2073..a657fde6 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -289,6 +289,9 @@ static void label_destroy(struct pxe_label *label)
if (label->fdtoverlays)
free(label->fdtoverlays);
 
+   if (label->fdtoverlaydir)
+   free(label->fdtoverlaydir);
+
free(label);
 }
 
@@ -352,6 +355,8 @@ static void label_boot_fdtoverlay(struct cmd_tbl *cmdtp, 
struct pxe_label *label
ulong fdtoverlay_addr;
ulong fdt_addr;
int err;
+   char overlayext[] = ".dtbo";
+   char path[MAX_TFTP_PATH_LEN + 1];
 
/* Get the main fdt and map it */
fdt_addr = simple_strtoul(env_get("fdt_addr_r"), NULL, 16);
@@ -393,9 +398,15 @@ static void label_boot_fdtoverlay(struct cmd_tbl *cmdtp, 
struct pxe_label *label
if (!strlen(overlayfile))
goto skip_overlay;
 
+   /* make overlay path */
+   sprintf(path, "%s%s%s%s",
+   label->fdtoverlaydir ? label->fdtoverlaydir : "",
+   label->fdtoverlaydir ? "/" : "",
+   overlayfile,
+   strstr(fdtoverlay, overlayext) ? "" : overlayext);
+
/* Load overlay file */
-   err = get_relfile_envaddr(cmdtp, overlayfile,
- "fdtoverlay_addr_r");
+   err = get_relfile_envaddr(cmdtp, path, "fdtoverlay_addr_r");
if (err < 0) {
printf("Failed loading overlay %s\n", overlayfile);
goto skip_overlay;
@@ -693,6 +704,7 @@ enum token_type {
T_FDT,
T_FDTDIR,
T_FDTOVERLAYS,
+   T_FDTOVERLAYDIR,
T_ONTIMEOUT,
T_IPAPPEND,
T_BACKGROUND,
@@ -730,6 +742,7 @@ static const struct token keywords[] = {
{"devicetreedir", T_FDTDIR},
{"fdtdir", T_FDTDIR},
{"fdtoverlays", T_FDTOVERLAYS},
+   {"fdtoverlaydir", T_FDTOVERLAYDIR},
{"ontimeout", T_ONTIMEOUT,},
{"ipappend", T_IPAPPEND,},
{"background", T_BACKGROUND,},
@@ -1168,6 +1181,11 @@ static int parse_label(char **c, struct pxe_menu *cfg)
err = parse_sliteral(c, &label->fdtoverlays);
break;
 
+   case T_FDTOVERLAYDIR:
+   if (!label->fdtoverlaydir)
+   err = parse_sliteral(c, &label->fdtoverlaydir);
+   break;
+
case T_LOCALBOOT:
label->localboot = 1;
err = parse_integer(c, &label->localboot_val);
diff --git a/cmd/pxe_utils.h b/cmd/pxe_utils.h
index d5475e84..cdac1327 100644
--- a/cmd/pxe_utils.h
+++ b/cmd/pxe_utils.h
@@ -44,6 +44,7 @@ struct pxe_label {
char *fdt;
char *fdtdir;
char *fdtoverlays;
+   char *fdtoverlaydir;
int ipappend;
int attempted;
int localboot;
-- 
2.25.1



[PATCH] pxe_utils: add localcmd defination

2021-02-26 Thread Artem Lapkin
pxe localboot usage too much limited, i think be useful improve it
welcome for any suggestions and feedbacks...

1) add localcmd defination which can used with localboot by default
localboot get from env, now we can define it in pxe script
2) localcmd can use without localboot
3) multiline usage for localcmd
4) add short alias ! for localcmd
5) localcmd eval as uboot script (run_command_list)
6) label + localcmd simple usage uboot pxe menu with uboot commands

Usage examples

# standalone usage
LABEL update_uboot
 LOCALCMD   ip=$tftpip && tftpboot $ip:boot.scr.uimg && script

LABEL reset
# multiline usage
 LOCALCMD   echo RESET
 LOCALCMD   reset

LABEL reset again
# multiline alias usage
 ! echo RESET
 ! reset

LABEL localboot
# redefile localcmd for localboot
 LOCALBOOT 1
 LOCALCMD   echo temporary redefine localcmd

Signed-off-by: Artem Lapkin 
---
 cmd/pxe_utils.c | 29 -
 cmd/pxe_utils.h |  1 +
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index f1ed671a..fdf532ec 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -271,6 +271,9 @@ static void label_destroy(struct pxe_label *label)
if (label->kernel)
free(label->kernel);
 
+   if (label->localcmd)
+   free(label->localcmd);
+
if (label->config)
free(label->config);
 
@@ -322,7 +325,10 @@ static int label_localboot(struct pxe_label *label)
 {
char *localcmd;
 
-   localcmd = from_env("localcmd");
+   if (label->localcmd)
+   localcmd = label->localcmd;
+   else
+   localcmd = from_env("localcmd");
 
if (!localcmd)
return -ENOENT;
@@ -470,6 +477,11 @@ static int label_boot(struct cmd_tbl *cmdtp, struct 
pxe_label *label)
return 0;
}
 
+   if (label->localcmd) {
+   if (!label->localboot_val)
+   return run_command_list(label->localcmd, 
strlen(label->localcmd), 0);
+   }
+
if (!label->kernel) {
printf("No kernel given, skipping %s\n",
   label->name);
@@ -687,6 +699,8 @@ enum token_type {
T_APPEND,
T_INITRD,
T_LOCALBOOT,
+   T_LOCALCMD,
+   T_LOCALCMD2,
T_DEFAULT,
T_PROMPT,
T_INCLUDE,
@@ -721,6 +735,8 @@ static const struct token keywords[] = {
{"kernel", T_KERNEL},
{"linux", T_LINUX},
{"localboot", T_LOCALBOOT},
+   {"localcmd", T_LOCALCMD},
+   {"!", T_LOCALCMD2},
{"append", T_APPEND},
{"initrd", T_INITRD},
{"include", T_INCLUDE},
@@ -1102,6 +1118,7 @@ static int parse_label(char **c, struct pxe_menu *cfg)
int len;
char *s = *c;
struct pxe_label *label;
+   char *add;
int err;
 
label = label_create();
@@ -1177,6 +1194,16 @@ static int parse_label(char **c, struct pxe_menu *cfg)
err = parse_integer(c, &label->localboot_val);
break;
 
+   case T_LOCALCMD:
+   case T_LOCALCMD2:
+   if (label->localcmd) {
+   if (parse_sliteral(c, &add))
+   sprintf(label->localcmd, "%s\n%s", 
label->localcmd, add);
+   } else {
+   err = parse_sliteral(c, &label->localcmd);
+   }
+   break;
+
case T_IPAPPEND:
err = parse_integer(c, &label->ipappend);
break;
diff --git a/cmd/pxe_utils.h b/cmd/pxe_utils.h
index bbdc606b..cdac1327 100644
--- a/cmd/pxe_utils.h
+++ b/cmd/pxe_utils.h
@@ -49,6 +49,7 @@ struct pxe_label {
int attempted;
int localboot;
int localboot_val;
+   char *localcmd;
struct list_head list;
 };
 
-- 
2.25.1



[PATCH] net: tftp: setup tftp_remote_ip and tftp_filename env variables

2021-03-01 Thread Artem Lapkin
setup tftp_remote_ip and tftp_filename environment variable for next usage

Problem: no way determinate real filename and remote ip after tftp transfer
1) serverip can be different from real tftp remote ip 
2) filename same determined automatically

Example

=> setenv bootfile 192.168.100.80:/ && pxe get
...
=> printenv tftp_filename tftp_remote_ip serverip
tftp_filename=/pxelinux.cfg/default-arm-meson
tftp_remote_ip=192.168.100.80
serverip=192.168.100.1

Signed-off-by: Artem Lapkin 
---
 net/tftp.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/net/tftp.c b/net/tftp.c
index 6fdb1a82..448103a1 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -798,6 +798,12 @@ void tftp_start(enum proto_t protocol)
 #endif
   &tftp_remote_ip, &net_ip);
 
+   char tftp_remote_ip_str[22];
+
+   ip_to_string(tftp_remote_ip, tftp_remote_ip_str);
+   env_set("tftp_remote_ip", tftp_remote_ip_str);
+   env_set("tftp_filename", tftp_filename);
+
/* Check if we need to send across this subnet */
if (net_gateway.s_addr && net_netmask.s_addr) {
struct in_addr our_net;
-- 
2.25.1



[RESEND v1] pxe_utils: add localcmd defination

2021-03-01 Thread Artem Lapkin
pxe localboot usage too much limited, i think be useful improve it
welcome for any suggestions and feedbacks...

1) add localcmd defination which can used with localboot by default
localboot get from env, now we can define it in pxe script
2) localcmd can use without localboot
3) multiline usage for localcmd
4) add short alias ! for localcmd
5) localcmd eval as uboot script (run_command_list)
6) label + localcmd simple usage uboot pxe menu with uboot commands

Usage examples

# standalone usage
LABEL update_uboot
 LOCALCMD   ip=$tftp_remote_ip && tftpboot $ip:boot.scr.uimg && script

LABEL reset
# multiline usage
 LOCALCMD   echo RESET
 LOCALCMD   reset

LABEL reset again
# multiline alias usage
 ! echo RESET
 ! reset

LABEL localboot
# redefile localcmd for localboot
 LOCALBOOT 1
 LOCALCMD   echo temporary redefine localcmd

Signed-off-by: Artem Lapkin 

---
v1:
- fix free(label->localcmd) add proper realloc for multiline localcmd
---
 cmd/pxe_utils.c | 39 ++-
 cmd/pxe_utils.h |  1 +
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index f1ed671a..1fab3d9a 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -271,6 +271,9 @@ static void label_destroy(struct pxe_label *label)
if (label->kernel)
free(label->kernel);
 
+   if (label->localcmd)
+   free(label->localcmd);
+
if (label->config)
free(label->config);
 
@@ -322,7 +325,10 @@ static int label_localboot(struct pxe_label *label)
 {
char *localcmd;
 
-   localcmd = from_env("localcmd");
+   if (label->localcmd)
+   localcmd = label->localcmd;
+   else
+   localcmd = from_env("localcmd");
 
if (!localcmd)
return -ENOENT;
@@ -470,6 +476,11 @@ static int label_boot(struct cmd_tbl *cmdtp, struct 
pxe_label *label)
return 0;
}
 
+   if (label->localcmd) {
+   if (!label->localboot_val)
+   return run_command_list(label->localcmd, 
strlen(label->localcmd), 0);
+   }
+
if (!label->kernel) {
printf("No kernel given, skipping %s\n",
   label->name);
@@ -687,6 +698,8 @@ enum token_type {
T_APPEND,
T_INITRD,
T_LOCALBOOT,
+   T_LOCALCMD,
+   T_LOCALCMD2,
T_DEFAULT,
T_PROMPT,
T_INCLUDE,
@@ -721,6 +734,8 @@ static const struct token keywords[] = {
{"kernel", T_KERNEL},
{"linux", T_LINUX},
{"localboot", T_LOCALBOOT},
+   {"localcmd", T_LOCALCMD},
+   {"!", T_LOCALCMD2},
{"append", T_APPEND},
{"initrd", T_INITRD},
{"include", T_INCLUDE},
@@ -1102,6 +1117,7 @@ static int parse_label(char **c, struct pxe_menu *cfg)
int len;
char *s = *c;
struct pxe_label *label;
+   char *add, *p;
int err;
 
label = label_create();
@@ -1177,6 +1193,27 @@ static int parse_label(char **c, struct pxe_menu *cfg)
err = parse_integer(c, &label->localboot_val);
break;
 
+   case T_LOCALCMD:
+   case T_LOCALCMD2:
+   if (label->localcmd) {
+   err = parse_sliteral(c, &add);
+   if (err) {
+   p = realloc(label->localcmd,
+   strlen(label->localcmd) +
+   strlen(add) + 2);
+   if (p) {
+   label->localcmd = p;
+   sprintf(label->localcmd,
+   "%s\n%s",
+   label->localcmd, add);
+   }
+   free(add);
+   }
+   } else {
+   err = parse_sliteral(c, &label->localcmd);
+   }
+   break;
+
case T_IPAPPEND:
err = parse_integer(c, &label->ipappend);
break;
diff --git a/cmd/pxe_utils.h b/cmd/pxe_utils.h
index bbdc606b..cdac1327 100644
--- a/cmd/pxe_utils.h
+++ b/cmd/pxe_utils.h
@@ -49,6 +49,7 @@ struct pxe_label {
int attempted;
int localboot;
int localboot_val;
+   char *localcmd;
struct list_head list;
 };
 
-- 
2.25.1



[PATCH 0/4] EFI: console: improves

2021-08-04 Thread Artem Lapkin
Problems with Linux Grub and U-Boot EFI console
- multiplexed console output scrambled
- slow refresh rate for big console sizes
- vidconsole incompatible with unicode

This patchset provides the following solutions:

1) Fixed detection of vidconsole from within a multiplexed stdout string.
As you know, a user can use a comma-separated list of devices to set
stdin, stdout and stderr. For example, "setenv stdout serial,vidconsole"
is a multiplexed string.

2) Multiplexed adaptation of the query_console_size() function;
automatically determine the minimal console area that will fit all
outputs properly.

3) Setup the max rows and columns limit for the EFI console output.

4) If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
characters will be replaced with "." for all console outputs. Vidconsole
does not support unicode output, and your console will suffer display
issues if EFI_CONSOLE_UTF_SAFE is disabled.

Artem Lapkin (4):
  EFI: console: query_vidconsole: multiplex adaptation
  EFI: console: query_console_size: multiplex adaptation
  EFI: console: max rows and cols user limit
  EFI: console: improve vidconsole unicode output

 lib/efi_loader/Kconfig   | 21 +
 lib/efi_loader/efi_console.c | 27 +++
 2 files changed, 40 insertions(+), 8 deletions(-)

-- 
2.25.1



[PATCH 1/4] EFI: console: query_vidconsole: multiplex adaptation

2021-08-04 Thread Artem Lapkin
Fixed detection of vidconsole from within a multiplexed stdout string. As
you know, a user can use a comma-separated list of devices to set stdin,
stdout and stderr. For example, "setenv stdout serial,vidconsole" is a
multiplexed string.

Signed-off-by: Artem Lapkin 
---
 lib/efi_loader/efi_console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 3b012e1a66..2d03285f82 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -314,7 +314,7 @@ static int __maybe_unused query_vidconsole(int *rows, int 
*cols)
struct udevice *dev;
struct vidconsole_priv *priv;
 
-   if (!stdout_name || strncmp(stdout_name, "vidconsole", 10))
+   if (!stdout_name || !strstr(stdout_name, "vidconsole"))
return -ENODEV;
stdout_dev = stdio_get_by_name("vidconsole");
if (!stdout_dev)
-- 
2.25.1



[PATCH 2/4] EFI: console: query_console_size: multiplex adaptation

2021-08-04 Thread Artem Lapkin
Multiplexed adaptation of the query_console_size() function;
automatically determine the minimal console area that will fit all
outputs properly.

Signed-off-by: Artem Lapkin 
---
 lib/efi_loader/efi_console.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 3b012e1a66..ef5cf21bf7 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -340,14 +340,18 @@ static int __maybe_unused query_vidconsole(int *rows, int 
*cols)
 static void query_console_size(void)
 {
int rows = 25, cols = 80;
-   int ret = -ENODEV;
 
-   if (IS_ENABLED(CONFIG_DM_VIDEO))
-   ret = query_vidconsole(&rows, &cols);
-   if (ret)
-   ret = query_console_serial(&rows, &cols);
-   if (ret)
+   if (IS_ENABLED(CONFIG_DM_VIDEO) &&
+   !query_vidconsole(&rows, &cols)) {
+   int rows_serial, cols_serial;
+
+   if (!query_console_serial(&rows_serial, &cols_serial)) {
+   rows = min(rows, rows_serial);
+   cols = min(cols, cols_serial);
+   }
+   } else if (query_console_serial(&rows, &cols)) {
return;
+   }
 
/* Test if we can have Mode 1 */
if (cols >= 80 && rows >= 50) {
-- 
2.25.1



[PATCH 3/4] EFI: console: max rows and cols user limit

2021-08-04 Thread Artem Lapkin
Setup the max rows and columns limit for the EFI console output.

Signed-off-by: Artem Lapkin 
---
 lib/efi_loader/Kconfig   | 12 
 lib/efi_loader/efi_console.c |  5 +
 2 files changed, 17 insertions(+)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index dacc3b5881..7d00d6cde5 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -381,4 +381,16 @@ config EFI_ESRT
help
  Enabling this option creates the ESRT UEFI system table.
 
+config EFI_CONSOLE_MAX_ROWS
+   int "setup console max rows"
+   default 0
+   help
+ Set console max rows limit or set to zero to disable limit.
+
+config EFI_CONSOLE_MAX_COLS
+   int "setup console max cols"
+   default 0
+   help
+ Set console max rows limit or set to zero to disable limit.
+
 endif
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 847069212e..b5d79d788f 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -351,6 +351,11 @@ static void query_console_size(void)
} else if (query_console_serial(&rows, &cols))
return;
 
+   if (CONFIG_EFI_CONSOLE_MAX_ROWS > 0)
+   rows = min(rows, CONFIG_EFI_CONSOLE_MAX_ROWS);
+   if (CONFIG_EFI_CONSOLE_MAX_COLS > 0)
+   cols = min(cols, CONFIG_EFI_CONSOLE_MAX_COLS);
+
/* Test if we can have Mode 1 */
if (cols >= 80 && rows >= 50) {
efi_cout_modes[1].present = 1;
-- 
2.25.1



[PATCH 4/4] EFI: console: improve vidconsole unicode output

2021-08-04 Thread Artem Lapkin
If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
characters will be replaced with "." for all console outputs.

Vidconsole does not support unicode output, and your console will suffer
display issues if EFI_CONSOLE_UTF_SAFE is disabled.

Signed-off-by: Artem Lapkin 
---
 lib/efi_loader/Kconfig   | 9 +
 lib/efi_loader/efi_console.c | 6 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 7d00d6cde5..886e0ce111 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -393,4 +393,13 @@ config EFI_CONSOLE_MAX_COLS
help
  Set console max rows limit or set to zero to disable limit.
 
+config EFI_CONSOLE_UTF_SAFE
+   bool "If vidconsole is active, unicode characters will be replaced with 
'.'"
+   default n
+   help
+ If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
+ characters will be replaced with "." for all console outputs.
+ Vidconsole does not support unicode output, and your console will
+ suffer display issues if EFI_CONSOLE_UTF_SAFE is disabled.
+
 endif
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index b5d79d788f..bd1c14995d 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -19,6 +19,8 @@
 #define EFI_COUT_MODE_2 2
 #define EFI_MAX_COUT_MODE 3
 
+static int vidconsole_active;
+
 struct cout_mode {
unsigned long columns;
unsigned long rows;
@@ -163,7 +165,8 @@ static efi_status_t EFIAPI efi_cout_output_string(
}
pos = buf;
utf16_utf8_strcpy(&pos, string);
-   fputs(stdout, buf);
+   fputs(stdout, IS_ENABLED(CONFIG_EFI_CONSOLE_UTF_SAFE) &&
+ strlen(buf) > 1 && vidconsole_active ? "." : buf);
free(buf);
 
/*
@@ -327,6 +330,7 @@ static int __maybe_unused query_vidconsole(int *rows, int 
*cols)
return -ENODEV;
*rows = priv->rows;
*cols = priv->cols;
+   vidconsole_active = 1;
return 0;
 }
 
-- 
2.25.1



[PATCH] distro_boot: Fix bootfile env after calling boot_extlinux

2021-10-12 Thread Artem Lapkin
Problem

PXE cannot boot normally after Sysboot changed the bootfile env (called
from boot_extlinux) from the default "boot.scr.uimg" to
"/boot/extlinux/extlinux.conf".

In addition, an unbootable extlinux configuration will also make the PXE
boot unbootable, because it will use the incorrect path "/boot/extlinux/"
from the bootfile env.

Solution

Save and restore default bootfile env value when boot_extlinux is used.

Example

Hit SPACE in 2 seconds to stop autoboot
... is now current device
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
413 bytes read in 2 ms (201.2 KiB/s)
Skipping Krescue for failure retrieving kernel
SCRIPT FAILED: continuing...
...
Speed: 1000, full duplex
BOOTP broadcast 1
DHCP client bound to address 192.168.11.151 (8 ms)
Using ethernet@ff3f device
TFTP from server 192.168.11.1; our IP address is 192.168.11.151
Filename '/boot/extlinux/pxelinux.cfg/default'.
Not retrying...
========

Signed-off-by: Artem Lapkin 
---
 include/config_distro_bootcmd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 3f724aa10f..db3d1b2362 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -445,7 +445,9 @@
"${devnum}:${distro_bootpart} "   \
"${prefix}${boot_syslinux_conf}; then "   \
"echo Found ${prefix}${boot_syslinux_conf}; " \
+   "bootfile_bak=${bootfile}; "  \
"run boot_extlinux; " \
+   "setenv bootfile ${bootfile_bak}; "   \
"echo SCRIPT FAILED: continuing...; " \
"fi\0"\
\
-- 
2.25.1



[PATCH] cmd: sysboot: dont overwrite bootfile env

2021-10-12 Thread Artem Lapkin
Problem

PXE cannot boot normally after Sysboot changed the bootfile env (called
from boot_extlinux) from the default "boot.scr.uimg" to
"/boot/extlinux/extlinux.conf".

In addition, an unbootable extlinux configuration will also make the PXE
boot unbootable, because it will use the incorrect path "/boot/extlinux/"
from the bootfile env.

Solution

sysboot must care about bootfile and restore default value after usage.

Come from:
https://patchwork.ozlabs.org/project/uboot/patch/20211012085544.3206394-1-...@khadas.com/

Signed-off-by: Artem Lapkin 
---
 cmd/sysboot.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/cmd/sysboot.c b/cmd/sysboot.c
index af6a2f1b7f..99b11cc127 100644
--- a/cmd/sysboot.c
+++ b/cmd/sysboot.c
@@ -2,6 +2,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "pxe_utils.h"
@@ -61,8 +62,9 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int 
argc,
unsigned long pxefile_addr_r;
struct pxe_menu *cfg;
char *pxefile_addr_str;
-   char *filename;
+   char *filename, *filename_bak;
int prompt = 0;
+   int ret = 0;
 
is_pxe = false;
 
@@ -83,9 +85,10 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int 
argc,
pxefile_addr_str = argv[4];
}
 
-   if (argc < 6) {
-   filename = env_get("bootfile");
-   } else {
+   filename = env_get("bootfile");
+   if (argc > 5) {
+   filename_bak = malloc(strlen(filename) + 1);
+   strcpy(filename_bak, filename);
filename = argv[5];
env_set("bootfile", filename);
}
@@ -98,26 +101,26 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int 
argc,
do_getfile = do_get_any;
} else {
printf("Invalid filesystem: %s\n", argv[3]);
-   return 1;
+   goto err;
}
fs_argv[1] = argv[1];
fs_argv[2] = argv[2];
 
if (strict_strtoul(pxefile_addr_str, 16, &pxefile_addr_r) < 0) {
printf("Invalid pxefile address: %s\n", pxefile_addr_str);
-   return 1;
+   goto err;
}
 
if (get_pxe_file(cmdtp, filename, pxefile_addr_r) < 0) {
printf("Error reading config file\n");
-   return 1;
+   goto err;
}
 
cfg = parse_pxefile(cmdtp, pxefile_addr_r);
 
if (!cfg) {
printf("Error parsing config file\n");
-   return 1;
+   goto err;
}
 
if (prompt)
@@ -126,8 +129,15 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int 
argc,
handle_pxe_menu(cmdtp, cfg);
 
destroy_pxe_menu(cfg);
-
-   return 0;
+   goto ret;
+ err:
+   ret = 1;
+ ret:
+   if (filename_bak) {
+   env_set("bootfile", filename_bak);
+   free(filename_bak);
+   }
+   return ret;
 }
 
 U_BOOT_CMD(sysboot, 7, 1, do_sysboot,
-- 
2.25.1



[PATCH] image: fix select_ramdisk for raw initrd

2021-10-15 Thread Artem Lapkin
Problem

We have unbootable raw initrd images because, select_ramdisk for raw
initrd images ignore submited select addr and setup rd_datap value to 0

Solution: setup rd_datap value from select

Signed-off-by: Artem Lapkin 
---
 common/image-board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/image-board.c b/common/image-board.c
index e7660352e9..e3c6ea806a 100644
--- a/common/image-board.c
+++ b/common/image-board.c
@@ -439,7 +439,7 @@ static int select_ramdisk(bootm_headers_t *images, const 
char *select, u8 arch,
end = strchr(select, ':');
if (end) {
*rd_lenp = hextoul(++end, NULL);
-   *rd_datap = rd_addr;
+   *rd_datap = hextoul(select, NULL);
processed = true;
}
}
-- 
2.25.1



[PATCH] image-board: fix wrong implementation ram disk address setup from cmdline

2021-10-15 Thread Artem Lapkin
Problem

Wrong implementation logic: ramdisk cmdline image address always ignored!
Next block { rd_addr = hextoul(select, NULL) } unusable for raw initrd.

We have unbootable raw initrd images because, select_ramdisk for raw
initrd images ignore submited select addr and setup rd_datap value to 0

Come-from: 
https://patchwork.ozlabs.org/project/uboot/patch/20211015101501.4091141-1-...@khadas.com/

Signed-off-by: Artem Lapkin 
---
 common/image-board.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/image-board.c b/common/image-board.c
index e7660352e9..e7063016ef 100644
--- a/common/image-board.c
+++ b/common/image-board.c
@@ -333,7 +333,7 @@ static int select_ramdisk(bootm_headers_t *images, const 
char *select, u8 arch,
 
if (select) {
ulong default_addr;
-   bool done = true;
+   bool done = false;
 
if (CONFIG_IS_ENABLED(FIT)) {
/*
@@ -351,13 +351,13 @@ static int select_ramdisk(bootm_headers_t *images, const 
char *select, u8 arch,
   &fit_uname_config)) {
debug("*  ramdisk: config '%s' from image at 
0x%08lx\n",
  fit_uname_config, rd_addr);
+   done = true;
} else if (fit_parse_subimage(select, default_addr,
  &rd_addr,
  &fit_uname_ramdisk)) {
debug("*  ramdisk: subimage '%s' from image at 
0x%08lx\n",
  fit_uname_ramdisk, rd_addr);
-   } else {
-   done = false;
+   done = true;
}
}
if (!done) {
-- 
2.25.1



[PATCH v1] env: setenv add resolve value option

2021-11-02 Thread Artem Lapkin
Add possibility setup env variable with additional resolving vars inside
value.

Usage examples

=> setenv a hello
=> setenv b world
=> setenv c '${a} ${b}'
=> setenv -r d '${c}! ${a}...'
=> printenv d
d=hello world! hello...

/* internal usage example */
env_resolve("d", "${c}! ${a}...");
/* d="hello world! hello..." */

Notes

Resolving works only for ${var} "bracket" and didn't workd for
"unbracket" $var

=> setenv -r d '$c! $a...'
=> printenv d
d=$c! $a...

Signed-off-by: Artem Lapkin 
---
 cmd/nvedit.c   | 42 +-
 include/_exports.h |  1 +
 include/env.h  | 11 +++
 include/exports.h  |  1 +
 4 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 3bb6e764c0..6608932dc0 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -229,6 +229,7 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
int   i, len;
char  *name, *value, *s;
struct env_entry e, *ep;
+   bool  resolve = 0;
 
debug("Initial value for argc=%d\n", argc);
 
@@ -246,6 +247,9 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
case 'f':   /* force */
env_flag |= H_FORCE;
break;
+   case 'r':   /* resolve */
+   resolve = 1;
+   break;
default:
return CMD_RET_USAGE;
}
@@ -291,6 +295,26 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
if (s != value)
*--s = '\0';
 
+   /*
+* deep resolve value vars
+*/
+   if (resolve) {
+   int max_loop = 32;
+   char value2[CONFIG_SYS_CBSIZE];
+
+   do {
+   cli_simple_process_macros(value, value2, 
CONFIG_SYS_CBSIZE);
+   if (!strcmp(value, value2))
+   break;
+   value = realloc(value, strlen(value2));
+   if (!value) {
+   printf("## Can't realloc %d bytes\n", len);
+   return 1;
+   }
+   strcpy(value, value2);
+   } while (max_loop--);
+   }
+
e.key   = name;
e.data  = value;
hsearch_r(e, ENV_ENTER, &ep, &env_htab, env_flag);
@@ -304,6 +328,20 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
return 0;
 }
 
+int env_resolve(const char *varname, const char *varvalue)
+{
+   const char * const argv[5] = { "setenv", "-r", varname, varvalue, NULL 
};
+
+   /* before import into hashtable */
+   if (!(gd->flags & GD_FLG_ENV_READY))
+   return 1;
+
+   if (!varvalue || varvalue[0] == '\0')
+   return _do_env_set(0, 3, (char * const *)argv, H_PROGRAMMATIC);
+   else
+   return _do_env_set(0, 4, (char * const *)argv, H_PROGRAMMATIC);
+}
+
 int env_set(const char *varname, const char *varvalue)
 {
const char * const argv[4] = { "setenv", varname, varvalue, NULL };
@@ -1371,7 +1409,9 @@ U_BOOT_CMD_COMPLETE(
"setenv [-f] name value ...\n"
"- [forcibly] set environment variable 'name' to 'value ...'\n"
"setenv [-f] name\n"
-   "- [forcibly] delete environment variable 'name'",
+   "- [forcibly] delete environment variable 'name'\n"
+   "setenv [-r] name value ...\n"
+   "- [resolve] resolve 'value ...' to environment variable\n",
var_complete
 );
 
diff --git a/include/_exports.h b/include/_exports.h
index 8030d70c0b..86bc07f051 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -32,6 +32,7 @@
EXPORT_FUNC(do_reset, int, do_reset, struct cmd_tbl *,
int , int , char * const [])
EXPORT_FUNC(env_get, char  *, env_get, const char*)
+   EXPORT_FUNC(env_resolve, int, env_resolve, const char *, const char *)
EXPORT_FUNC(env_set, int, env_set, const char *, const char *)
EXPORT_FUNC(simple_strtoul, unsigned long, simple_strtoul,
const char *, char **, unsigned int)
diff --git a/include/env.h b/include/env.h
index ee5e30d036..c4efc5b7e5 100644
--- a/include/env.h
+++ b/include/env.h
@@ -133,6 +133,17 @@ int env_get_f(const char *name, char *buf, unsigned int 
len);
  */
 int env_get_yesno(const char *var);
 
+/**
+ * env_resolve() - resolve to en

[PATCH v2 0/2] env: setenv add resolve value option

2021-11-18 Thread Artem Lapkin
Add possibility setup env variable with additional resolving vars inside
value.

Usage examples:

=> setenv a hello; setenv b world; setenv c '${a} ${b}'
=> setenv -r d '${c}! ${a}...'
=> printenv d
d=hello world! hello...

/* internal usage example */
env_resolve("d", "${c}! ${a}...");
/* d="hello world! hello..." */

Artem Lapkin (2):
  env: setenv add resolve value option
  test: env: deep resolve value testing

---
V2 changes:
_ fix comments style
_ add comment include/exports.h
_ remake strcpy to strdup
_ env_resolve minimize
_ test added: test/py/tests/test_env.py: test_env_resovle
---

 cmd/nvedit.c  | 43 ++-
 include/_exports.h|  1 +
 include/env.h | 11 ++
 include/exports.h |  2 ++
 test/py/tests/test_env.py | 24 ++
 5 files changed, 80 insertions(+), 1 deletion(-)

-- 
2.25.1



[PATCH v2 1/2] env: setenv add resolve value option

2021-11-18 Thread Artem Lapkin
Add possibility setup env variable with additional resolving vars inside
value.

Usage examples:

=> setenv a hello; setenv b world; setenv c '${a} ${b}'
=> setenv -r d '${c}! ${a}...'
=> printenv d
d=hello world! hello...

/* internal usage example */
env_resolve("d", "${c}! ${a}...");
/* d="hello world! hello..." */

Signed-off-by: Artem Lapkin 
---
V2 changes:
_ fix comments style
_ add comment include/exports.h
_ remake strcpy to strdup
_ env_resolve minimize
---
 cmd/nvedit.c   | 43 ++-
 include/_exports.h |  1 +
 include/env.h  | 11 +++
 include/exports.h  |  2 ++
 4 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 3bb6e764c0..6e1237df81 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -229,6 +229,7 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
int   i, len;
char  *name, *value, *s;
struct env_entry e, *ep;
+   bool  resolve = 0;
 
debug("Initial value for argc=%d\n", argc);
 
@@ -246,6 +247,9 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
case 'f':   /* force */
env_flag |= H_FORCE;
break;
+   case 'r':   /* resolve */
+   resolve = 1;
+   break;
default:
return CMD_RET_USAGE;
}
@@ -291,6 +295,29 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
if (s != value)
*--s = '\0';
 
+   /* deep resolve value vars */
+   if (resolve) {
+   int max_loop = 32;
+   char value2[CONFIG_SYS_CBSIZE];
+   char *v = NULL;
+
+   do {
+   cli_simple_process_macros(value, value2, 
CONFIG_SYS_CBSIZE);
+
+   if (!strcmp(value, value2))
+   break;
+
+   v = strdup(value2);
+   if (!v) {
+   printf("## Can't allocate memory\n");
+   return 1;
+   }
+
+   free(value);
+   value = v;
+   } while (max_loop--);
+   }
+
e.key   = name;
e.data  = value;
hsearch_r(e, ENV_ENTER, &ep, &env_htab, env_flag);
@@ -304,6 +331,18 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
return 0;
 }
 
+int env_resolve(const char *varname, const char *varvalue)
+{
+   const char * const argv[5] = { "setenv", "-r", varname, varvalue, NULL 
};
+
+   /* before import into hashtable */
+   if (!(gd->flags & GD_FLG_ENV_READY))
+   return 1;
+
+   return _do_env_set(0, !varvalue || varvalue[0]  == '\0' ? 3 : 4,
+   (char * const *)argv, H_PROGRAMMATIC);
+}
+
 int env_set(const char *varname, const char *varvalue)
 {
const char * const argv[4] = { "setenv", varname, varvalue, NULL };
@@ -1371,7 +1410,9 @@ U_BOOT_CMD_COMPLETE(
"setenv [-f] name value ...\n"
"- [forcibly] set environment variable 'name' to 'value ...'\n"
"setenv [-f] name\n"
-   "- [forcibly] delete environment variable 'name'",
+   "- [forcibly] delete environment variable 'name'\n"
+   "setenv [-r] name value ...\n"
+   "- [resolve] resolve 'value ...' to environment variable\n",
var_complete
 );
 
diff --git a/include/_exports.h b/include/_exports.h
index 8030d70c0b..86bc07f051 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -32,6 +32,7 @@
EXPORT_FUNC(do_reset, int, do_reset, struct cmd_tbl *,
int , int , char * const [])
EXPORT_FUNC(env_get, char  *, env_get, const char*)
+   EXPORT_FUNC(env_resolve, int, env_resolve, const char *, const char *)
EXPORT_FUNC(env_set, int, env_set, const char *, const char *)
EXPORT_FUNC(simple_strtoul, unsigned long, simple_strtoul,
const char *, char **, unsigned int)
diff --git a/include/env.h b/include/env.h
index ee5e30d036..73d1aca9ac 100644
--- a/include/env.h
+++ b/include/env.h
@@ -133,6 +133,17 @@ int env_get_f(const char *name, char *buf, unsigned int 
len);
  */
 int env_get_yesno(const char *var);
 
+/**
+ * env_resolve() - resolve to environment variable
+ *
+ * Same as env_set but make deep resolve for value
+ *
+ * @varname: Variable to adjust
+ * @value: Value to resolve for the v

[PATCH v2 2/2] test: env: deep resolve value testing

2021-11-18 Thread Artem Lapkin
Add new tests for `setenv -r` options (setup env variable with additional
resolving vars inside value).

test.py -k test_env

Signed-off-by: Artem Lapkin 
---
 test/py/tests/test_env.py | 24 
 1 file changed, 24 insertions(+)

diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 9bed2f48d7..a2f02f6f67 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -201,6 +201,30 @@ def test_env_unset_non_existent(state_test_env):
 unset_var(state_test_env, var)
 validate_empty(state_test_env, var)
 
+def test_env_resovle(state_test_env):
+"""Test deep resolve variable."""
+c = state_test_env.u_boot_console
+c.run_command("setenv a hello; setenv b world; setenv c '${a} ${b}'")
+assert c.run_command('printenv a') == 'a=hello'
+assert c.run_command('printenv b') == 'b=world'
+assert c.run_command('printenv c') == 'c=${a} ${b}'
+c.run_command("setenv d '${c}'")
+assert c.run_command('printenv d') == 'd=${c}'
+c.run_command("setenv -r e '${a} ${b} ${c}'")
+assert c.run_command('printenv e') == 'e=hello world hello world'
+c.run_command("setenv not_exist; setenv -r e '${not_exist}OK'")
+assert c.run_command('printenv e') == 'e=OK'
+c.run_command("setenv a 'A${b}'; setenv b 'B${a}'")
+assert c.run_command('printenv a') == 'a=A${b}'
+c.run_command("setenv e ''")
+assert c.run_command('printenv e') == 'e='
+c.run_command("setenv -r e '${b}'")
+#assert c.run_command('printenv e') == 
'e=BABABABABABABABABABABABABABABABAB${a}'
+assert c.run_command('printenv e') != 'e='
+c.run_command("setenv -r e")
+with c.disable_check('error_notification'):
+assert c.run_command('printenv e') == '## Error: "e" not defined'
+
 def test_env_set_non_existent(state_test_env):
 """Test set a non-existant variable."""
 
-- 
2.25.1



[PATCH] image: add lz4 zstd compression magic map

2021-08-31 Thread Artem Lapkin
Add lz4 and zstd compression magic map. Already can decompress images
with lz4 and zstd compression type.

Signed-off-by: Artem Lapkin 
---
 common/image.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/image.c b/common/image.c
index 59c52a1f9a..e199d61a4c 100644
--- a/common/image.c
+++ b/common/image.c
@@ -216,6 +216,8 @@ static const struct comp_magic_map image_comp[] = {
{   IH_COMP_GZIP,   "gzip", {0x1f, 0x8b},},
{   IH_COMP_LZMA,   "lzma", {0x5d, 0x00},},
{   IH_COMP_LZO,"lzo",  {0x89, 0x4c},},
+   {   IH_COMP_LZ4,"lz4",  {0x04, 0x22},},
+   {   IH_COMP_ZSTD,   "zstd", {0x28, 0xb5},},
{   IH_COMP_NONE,   "none", {}, },
 };
 
-- 
2.25.1



[PATCH v2] image-board: fix wrong implementation ram disk address setup from cmdline

2021-11-24 Thread Artem Lapkin
Problem

Wrong implementation logic: ramdisk cmdline image address always ignored!
Next block { rd_addr = hextoul(select, NULL) } unusable for raw initrd.

We have unbootable raw initrd images because, select_ramdisk for raw
initrd images ignore submited select addr and setup rd_datap value to 0

Signed-off-by: Artem Lapkin 
---
V2 changes
_ rebase to master
_ from 
https://patchwork.ozlabs.org/project/uboot/patch/20211016051915.4157293-1-...@khadas.com/
---
 boot/image-board.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/boot/image-board.c b/boot/image-board.c
index bf8817165c..87a8f07432 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -334,7 +334,7 @@ static int select_ramdisk(bootm_headers_t *images, const 
char *select, u8 arch,
 
if (select) {
ulong default_addr;
-   bool done = true;
+   bool done = false;
 
if (CONFIG_IS_ENABLED(FIT)) {
/*
@@ -352,13 +352,13 @@ static int select_ramdisk(bootm_headers_t *images, const 
char *select, u8 arch,
   &fit_uname_config)) {
debug("*  ramdisk: config '%s' from image at 
0x%08lx\n",
  fit_uname_config, rd_addr);
+   done = true;
} else if (fit_parse_subimage(select, default_addr,
  &rd_addr,
  &fit_uname_ramdisk)) {
debug("*  ramdisk: subimage '%s' from image at 
0x%08lx\n",
  fit_uname_ramdisk, rd_addr);
-   } else {
-   done = false;
+   done = true;
}
}
if (!done) {
-- 
2.25.1