Re: [PATCH] starfive: visionfive2: switch to standard boot

2024-03-18 Thread Milan P . Stanić
On Thu, 2024-03-14 at 13:04, Nam Cao wrote:
> On 13/Mar/2024 Milan P. Stanić wrote:
> > On Wed, 2024-02-21 at 13:00, Nam Cao wrote:
> > > Distro boot scripts are deprecated. Use standard boot instead.  
> > I had to enable 'CONFIG_CMD_SYSBOOT=y' in
> > configs/starfive_visionfive2_defconfig because it doesn't boot without
> > it. With this option it boots fine with this patch.
> 
> You should not have to do that for it to work, otherwise this patch
> introduced a bug.
> 
> CONFIG_CMD_SYSBOOT adds the "sysboot" command, which is only used by
> distroboot. So I suspect that you were actually still using distro boot,
> because you didn't "update" your environment variable (that can be checked
> with "printenv bootcmd"). For this patch to work, the environment variables
> also need to be updated with:
> env default
> env save -a
> 
> This makes me realize that the patch breaks boards if the users forget to
> update the environment variables. I am not sure if this is considered a
> bug. What do maintainers think?

Rebuild it again and it worked out of the box.

Tested-by: Milan P. Stanić 



Re: [PATCH] starfive: visionfive2: switch to standard boot

2024-03-13 Thread Milan P . Stanić
On Wed, 2024-02-21 at 13:00, Nam Cao wrote:
> Distro boot scripts are deprecated. Use standard boot instead.
I had to enable 'CONFIG_CMD_SYSBOOT=y' in
configs/starfive_visionfive2_defconfig because it doesn't boot without
it. With this option it boots fine with this patch.
Tested on u-boot version 2024.04-rc4-dirty

> Signed-off-by: Nam Cao 
> Reviewed-by: Leo Yu-Chi Liang 
Tested-by: Milan P. Stanić 

> ---
>  configs/starfive_visionfive2_defconfig |  2 +-
>  include/configs/starfive-visionfive2.h | 14 +-
>  2 files changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/configs/starfive_visionfive2_defconfig 
> b/configs/starfive_visionfive2_defconfig
> index b11be7ac86..aec751f871 100644
> --- a/configs/starfive_visionfive2_defconfig
> +++ b/configs/starfive_visionfive2_defconfig
> @@ -31,8 +31,8 @@ CONFIG_RISCV_SMODE=y
>  # CONFIG_OF_BOARD_FIXUP is not set
>  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>  CONFIG_FIT=y
> +CONFIG_BOOTSTD_DEFAULTS=y
>  CONFIG_SYS_BOOTM_LEN=0x400
> -CONFIG_DISTRO_DEFAULTS=y
>  CONFIG_BOOTSTAGE=y
>  CONFIG_QSPI_BOOT=y
>  CONFIG_SD_BOOT=y
> diff --git a/include/configs/starfive-visionfive2.h 
> b/include/configs/starfive-visionfive2.h
> index 29c74470c7..049b0a0630 100644
> --- a/include/configs/starfive-visionfive2.h
> +++ b/include/configs/starfive-visionfive2.h
> @@ -15,17 +15,6 @@
>  
>  #define __io
>  
> -/* Environment options */
> -
> -#define BOOT_TARGET_DEVICES(func) \
> - func(NVME, nvme, 0) \
> - func(USB, usb, 0) \
> - func(MMC, mmc, 0) \
> - func(MMC, mmc, 1) \
> - func(DHCP, dhcp, na)
> -
> -#include 
> -
>  #define TYPE_GUID_SPL"2E54B353-1271-4842-806F-E436D6AF6985"
>  #define TYPE_GUID_UBOOT  "BC13C2FF-59E6-4262-A352-B275FD6F7172"
>  #define TYPE_GUID_SYSTEM "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"
> @@ -48,7 +37,6 @@
>   "type_guid_gpt_loader2=" TYPE_GUID_UBOOT "\0" \
>   "type_guid_gpt_system=" TYPE_GUID_SYSTEM "\0" \
>   "partitions=" PARTS_DEFAULT "\0" \
> - "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
> - BOOTENV
> + "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"
>  
>  #endif /* _STARFIVE_VISIONFIVE2_H */


[PATCH] doc: build: fix wrongly written targests instead of targets

2023-11-04 Thread Milan P . Stanić
Signed-off-by: Milan P. Stanić 
---
 doc/build/gcc.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/build/gcc.rst b/doc/build/gcc.rst
index 23501dea37..3c64657727 100644
--- a/doc/build/gcc.rst
+++ b/doc/build/gcc.rst
@@ -66,7 +66,7 @@ For building U-Boot on Alpine Linux at least the following 
packages are needed:
 Depending on the build target further packages may be needed:
 
 * sandbox with lcd: sdl2-dev
-* riscv64 S-mode targests: opensbi
+* riscv64 S-mode targets: opensbi
 * some arm64 targets: arm-trusted-firmware
 
 Prerequisites
-- 
2.42.1



[PATCH v2] cros_ec: spi: disable annoying key echo on console

2023-10-18 Thread Milan P . Stanić
on Peach-pi console every key press is echoed with message
'cros_ec_command: Returned status 1'

this is not proper fix, just hack to disable this message

Signed-off-by: Milan P. Stanić 
Reviewed-by: Simon Glass 
---
changed patch to use log_debug and added forgoten Signed-off-by and
and Reviewed-by Simon response mail

 drivers/misc/cros_ec_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/cros_ec_spi.c b/drivers/misc/cros_ec_spi.c
index 001f0a85ca..591ff30df8 100644
--- a/drivers/misc/cros_ec_spi.c
+++ b/drivers/misc/cros_ec_spi.c
@@ -151,7 +151,7 @@ int cros_ec_spi_command(struct udevice *udev, uint8_t cmd, 
int cmd_version,
 
/* Response code is first byte of message */
if (p[0] != EC_RES_SUCCESS) {
-   printf("%s: Returned status %d\n", __func__, p[0]);
+   log_debug("Returned status %d\n", p[0]);
return -(int)(p[0]);
}
 
-- 
2.42.0



[PATCH] doc: build: update description of build dependencies for Alpine Linux

2023-10-17 Thread Milan P . Stanić
---
 doc/build/gcc.rst | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/doc/build/gcc.rst b/doc/build/gcc.rst
index a0650a51db..e73f24a304 100644
--- a/doc/build/gcc.rst
+++ b/doc/build/gcc.rst
@@ -60,8 +60,28 @@ For building U-Boot on Alpine Linux at least the following 
packages are needed:
 
 .. code-block:: bash
 
-apk add alpine-sdk bc bison dtc flex linux-headers ncurses-dev \
-  openssl-dev perl python3 py3-setuptools python3-dev sdl2-dev
+apk add alpine-sdk bc bison dtc flex gnutls-dev linux-headers \
+  openssl-dev py3-elftools py3-setuptools python3-dev swig util-linux-dev
+
+Dependeing on the build target further packages may be needed
+
+For build sandbox with lcd
+
+.. code-block:: bash
+
+apk add sdl2-dev
+
+For build riscv64 targets
+
+.. code-block:: bash
+
+apk add opensbi
+
+For build some arm64 targets
+
+.. code-block:: bash
+
+apk add arm-trusted-firmware
 
 Prerequisites
 -
-- 
2.42.0



[PATCH] cros_ec: spi: disable annoying key echo on console

2023-10-17 Thread Milan P . Stanić
on Peach-pi console every key press is echoed with message
'cros_ec_command: Returned status 1'

this is not proper fix, just hack to disable this message
---
 drivers/misc/cros_ec_spi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/misc/cros_ec_spi.c b/drivers/misc/cros_ec_spi.c
index 001f0a85ca..7317f4b0f1 100644
--- a/drivers/misc/cros_ec_spi.c
+++ b/drivers/misc/cros_ec_spi.c
@@ -151,7 +151,6 @@ int cros_ec_spi_command(struct udevice *udev, uint8_t cmd, 
int cmd_version,
 
/* Response code is first byte of message */
if (p[0] != EC_RES_SUCCESS) {
-   printf("%s: Returned status %d\n", __func__, p[0]);
return -(int)(p[0]);
}
 
-- 
2.42.0



Re: [PATCH 1/1] riscv: set fdtfile on VisionFive 2

2023-09-21 Thread Milan P . Stanić
On Thu, 2023-09-07 at 13:21, Heinrich Schuchardt wrote:
> Multiple revisions of the StarFive VisionFive 2 board exist. They can be
> identified by reading their EEPROM.
> 
> Linux uses two differently named device-tree files. To load the correct
> device-tree we need to set $fdtfile to the device-tree file name that
> matches the board revision.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Leo Yu-Chi Liang 

Tested-by: Milan P. Stanić 
> ---
>  arch/riscv/Kconfig|  1 +
>  .../visionfive2/starfive_visionfive2.c| 43 ++-
>  2 files changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 6771d8d919..1c62c2345b 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -26,6 +26,7 @@ config TARGET_SIFIVE_UNMATCHED
>  
>  config TARGET_STARFIVE_VISIONFIVE2
>   bool "Support StarFive VisionFive2 Board"
> + select BOARD_LATE_INIT
>  
>  config TARGET_TH1520_LPI4A
>   bool "Support Sipeed's TH1520 Lichee PI 4A Board"
> diff --git a/board/starfive/visionfive2/starfive_visionfive2.c 
> b/board/starfive/visionfive2/starfive_visionfive2.c
> index d609262b67..05d8d2d657 100644
> --- a/board/starfive/visionfive2/starfive_visionfive2.c
> +++ b/board/starfive/visionfive2/starfive_visionfive2.c
> @@ -5,14 +5,20 @@
>   */
>  
>  #include 
> -#include 
> -#include 
>  #include 
>  #include 
> +#include 
> +#include 
> +#include 
> +#include 
>  #include 
>  
>  #define JH7110_L2_PREFETCHER_BASE_ADDR   0x203
>  #define JH7110_L2_PREFETCHER_HART_OFFSET 0x2000
> +#define FDTFILE_VISIONFIVE2_1_2A \
> + "starfive/jh7110-starfive-visionfive-2-v1.2a.dtb"
> +#define FDTFILE_VISIONFIVE2_1_3B \
> + "starfive/jh7110-starfive-visionfive-2-v1.3b.dtb"
>  
>  /* enable U74-mc hart1~hart4 prefetcher */
>  static void enable_prefetcher(void)
> @@ -33,6 +39,31 @@ static void enable_prefetcher(void)
>   }
>  }
>  
> +/**
> + * set_fdtfile() - set the $fdtfile variable based on the board revision
> + */
> +static void set_fdtfile(void)
> +{
> + u8 version;
> + const char *fdtfile;
> +
> + version = get_pcb_revision_from_eeprom();
> + switch (version) {
> + case 'a':
> + case 'A':
> + fdtfile = FDTFILE_VISIONFIVE2_1_2A;
> + break;
> +
> + case 'b':
> + case 'B':
> + default:
> + fdtfile = FDTFILE_VISIONFIVE2_1_3B;
> + break;
> + };
> +
> + env_set("fdtfile", fdtfile);
> +}
> +
>  int board_init(void)
>  {
>   enable_caches();
> @@ -41,6 +72,14 @@ int board_init(void)
>   return 0;
>  }
>  
> +int board_late_init(void)
> +{
> + if (CONFIG_IS_ENABLED(ID_EEPROM))
> + set_fdtfile();
> +
> + return 0;
> +}
> +
>  void *board_fdt_blob_setup(int *err)
>  {
>   *err = 0;


[PATCH 1/1] starfive: visionfive2: add mmc0 and nvme boot targets

2023-09-18 Thread Milan P . Stanić
boot from SDIO3.0 (mmc sdcard) first if it is plugged.
If mmc is not plugged try to boot from emmc if it is plugged.
If emmc is not plugged then try to boot from nvme.

Signed-off-by: Milan P. Stanić 
---
 include/configs/starfive-visionfive2.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/starfive-visionfive2.h 
b/include/configs/starfive-visionfive2.h
index 4ee02b8420..13cf2aeef9 100644
--- a/include/configs/starfive-visionfive2.h
+++ b/include/configs/starfive-visionfive2.h
@@ -19,6 +19,8 @@
 
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 1) \
+   func(MMC, mmc, 0) \
+   func(NVME, nvme, 0) \
func(DHCP, dhcp, na)
 
 #include 
-- 
2.42.0



Re: [PATCH v3 2/2] riscv: dts: starfive: generate u-boot-spl.bin.normal.out

2023-09-17 Thread Milan P . Stanić
On Sun, 2023-09-17 at 13:47, Heinrich Schuchardt wrote:
> The StarFive VisionFive 2 board cannot load spl/u-boot-spl.bin but needs a
> prefixed header. We have referring to a vendor tool (spl_tool) for this
> task. 'mkimage -T sfspl' can generate the prefixed file.
> 
> Use binman to invoke mkimage for the generation of file
> spl/u-boot-spl.bin.normal.out.
> 
> Update the documentation.
> 
> Signed-off-by: Heinrich Schuchardt 

Tested-by: Milan P. Stanić 

> ---
> v3:
>   Rename binman node for SPL image.
>   Use u-boot-spl instead of blob as mkimage subnode.
> v2:
>   Fix a typo in a comment in tools/sfspl.c
>   Add Tested-by credits
> ---
>  .../dts/jh7110-starfive-visionfive-2-u-boot.dtsi   | 11 +++
>  doc/board/starfive/visionfive2.rst | 14 ++
>  2 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi 
> b/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
> index 13f69da31e..55185314dd 100644
> --- a/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
> +++ b/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
> @@ -103,4 +103,15 @@
>   };
>   };
>   };
> +
> + spl-img {
> + filename = "spl/u-boot-spl.bin.normal.out";
> +
> + mkimage {
> + args = "-T sfspl";
> +
> + u-boot-spl {
> + };
> + };
> +};
>  };
> diff --git a/doc/board/starfive/visionfive2.rst 
> b/doc/board/starfive/visionfive2.rst
> index 941899a0a4..f5575ab68b 100644
> --- a/doc/board/starfive/visionfive2.rst
> +++ b/doc/board/starfive/visionfive2.rst
> @@ -65,18 +65,8 @@ Now build the U-Boot SPL and U-Boot proper
>   make starfive_visionfive2_defconfig
>   make 
> OPENSBI=$(opensbi_dir)/opensbi/build/platform/generic/firmware/fw_dynamic.bin
>  
> -This will generate spl/u-boot-spl.bin and FIT image (u-boot.itb)
> -
> -u-boot-spl.bin cannot be used directly on StarFive VisionFive2,we need
> -to convert the u-boot-spl.bin to u-boot-spl.bin.normal.out with
> -the below command:
> -
> - ./spl_tool -c -f $(Uboot_PATH)/spl/u-boot-spl.bin
> -
> -More detailed description of spl_tool,please refer spl_tool documenation.
> -(Note: spl_tool git repo is at 
> https://github.com/starfive-tech/Tools/tree/master/spl_tool)
> -
> -This will generate u-boot-spl.bin.normal.out file.
> +This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as 
> well
> +as the FIT image (u-boot.itb) with OpenSBI and U-Boot.
>  
>  Flashing
>  
> -- 
> 2.40.1
> 


Re: [PATCH v2 1/2] tools: mkimage: Add StarFive SPL image support

2023-09-16 Thread Milan P . Stanić
On Wed, 2023-09-06 at 14:00, Heinrich Schuchardt wrote:
> The StarFive JH7110 base boards require a header to be prefixed to the SPL
> binary image. This has previously done with a vendor tool 'spl_tool'
> published under a GPL-2-or-later license. Integrate this capability into
> mkimage.
> 
> Signed-off-by: Heinrich Schuchardt 
> Tested-by: Chanho Park 

Tested-by: Milan P. Stanić 

> ---
> v2:
>   no change except for Tested-by credit
> ---
>  boot/image.c|   1 +
>  include/image.h |   1 +
>  tools/Makefile  |   1 +
>  tools/sfspl.c   | 174 
>  4 files changed, 177 insertions(+)
>  create mode 100644 tools/sfspl.c
> 
> diff --git a/boot/image.c b/boot/image.c
> index 5c4f9b807d..3a99d2e897 100644
> --- a/boot/image.c
> +++ b/boot/image.c
> @@ -182,6 +182,7 @@ static const table_entry_t uimage_type[] = {
>   {   IH_TYPE_SUNXI_TOC0, "sunxi_toc0",  "Allwinner TOC0 Boot Image" 
> },
>   {   IH_TYPE_FDT_LEGACY, "fdt_legacy", "legacy Image with Flat 
> Device Tree ", },
>   {   IH_TYPE_RENESAS_SPKG, "spkgimage", "Renesas SPKG Image" },
> + {   IH_TYPE_STARFIVE_SPL, "sfspl", "StarFive SPL Image" },
>   {   -1, "",   "",   },
>  };
>  
> diff --git a/include/image.h b/include/image.h
> index 01a6787d21..5f85bf84a2 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -231,6 +231,7 @@ enum image_type_t {
>   IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */
>   IH_TYPE_FDT_LEGACY, /* Binary Flat Device Tree Blob in a 
> Legacy Image */
>   IH_TYPE_RENESAS_SPKG,   /* Renesas SPKG image */
> + IH_TYPE_STARFIVE_SPL,   /* StarFive SPL image */
>  
>   IH_TYPE_COUNT,  /* Number of image types */
>  };
> diff --git a/tools/Makefile b/tools/Makefile
> index 3d0c4b0dd6..1aa1e36137 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -123,6 +123,7 @@ dumpimage-mkimage-objs := aisimage.o \
>   pblimage.o \
>   pbl_crc32.o \
>   renesas_spkgimage.o \
> + sfspl.o \
>   vybridimage.o \
>   stm32image.o \
>   $(ROCKCHIP_OBS) \
> diff --git a/tools/sfspl.c b/tools/sfspl.c
> new file mode 100644
> index 00..ec18a0a77e
> --- /dev/null
> +++ b/tools/sfspl.c
> @@ -0,0 +1,174 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright Heinrich Schuchardt 
> + *
> + * The StarFive JH7110 requires to prepend a header to u-boot-spl.bin 
> describing
> + * the payload length and CRC32.
> + *
> + * This module implements support in mkimage and dumpimage for this file 
> format.
> + *
> + * StarFive's spl_tool available under GPL-2.0-and-later at
> + * https://github.com/starfive-tech/Tools implements writing the same file
> + * format and served as a reference.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "imagetool.h"
> +
> +#define DEFAULT_VERSION 0x01010101
> +#define DEFAULT_BACKUP 0x20U
> +#define DEFAULT_OFFSET 0x240
> +
> +/**
> + * struct spl_hdr - header for SPL on JH7110
> + *
> + * All fields are low-endian.
> + */
> +struct spl_hdr {
> + /** @offset:offset to SPL header (0x240) */
> + unsigned int offset;
> + /** @bkp_offs:  address of backup SPL, defaults to DEFAULT_BACKUP */
> + unsigned int bkp_offs;
> + /** @zero1: set to zero */
> + unsigned int zero1[159];
> + /** @version:   header version, defaults to DEFAULT_VERSION */
> + unsigned int version;
> + /** @file_size: file size */
> + unsigned int file_size;
> + /** @hdr_size:  size of the file header (0x400) */
> + unsigned int hdr_size;
> + /** @crc32: CRC32 */
> + unsigned int crc32;
> + /** @zero2: set to zero */
> + unsigned int zero2[91];
> +};
> +
> +static int sfspl_check_params(struct image_tool_params *params)
> +{
> + /* Only the RISC-V architecture is supported */
> + if (params->Aflag && params->arch != IH_ARCH_RISCV)
> + return EXIT_FAILURE;
> +
> + return EXIT_SUCCESS;
> +}
> +
> +static int sfspl_verify_header(unsigned char *buf, int size,
> +struct image_tool_params *params)
> +{
> + struct spl_hdr *hdr = (void *)buf;
> + unsigned int hdr_size = le32_to_cpu(hdr->hdr_size);
> + unsigned int file_

Re: [PATCH v2 2/2] riscv: dts: starfive: generate u-boot-spl.bin.normal.out

2023-09-16 Thread Milan P . Stanić
On Wed, 2023-09-06 at 14:00, Heinrich Schuchardt wrote:
> The StarFive VisionFive 2 board cannot load spl/u-boot-spl.bin but needs a
> prefixed header. We have referring to a vendor tool (spl_tool) for this
> task. 'mkimage -T sfspl' can generate the prefixed file.
> 
> Use binman to invoke mkimage for the generation of file
> spl/u-boot-spl.bin.normal.out.
> 
> Update the documentation.
> 
> Signed-off-by: Heinrich Schuchardt 
> Tested-by: Chanho Park 

Tested-by: Milan P. Stanić 

> ---
> v2:
>   Fix a typo in a comment in tools/sfspl.c
>   Add Tested-by credit
> ---
>  .../dts/jh7110-starfive-visionfive-2-u-boot.dtsi   | 10 ++
>  doc/board/starfive/visionfive2.rst | 14 ++
>  2 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi 
> b/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
> index 13f69da31e..defe2b605f 100644
> --- a/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
> +++ b/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
> @@ -103,4 +103,14 @@
>   };
>   };
>   };
> + u-boot-spl {
> + filename = "spl/u-boot-spl.bin.normal.out";
> +
> + mkimage {
> + args = "-T sfspl";
> + blob {
> + filename = "spl/u-boot-spl.bin";
> + };
> + };
> + };
>  };
> diff --git a/doc/board/starfive/visionfive2.rst 
> b/doc/board/starfive/visionfive2.rst
> index 941899a0a4..f5575ab68b 100644
> --- a/doc/board/starfive/visionfive2.rst
> +++ b/doc/board/starfive/visionfive2.rst
> @@ -65,18 +65,8 @@ Now build the U-Boot SPL and U-Boot proper
>   make starfive_visionfive2_defconfig
>   make 
> OPENSBI=$(opensbi_dir)/opensbi/build/platform/generic/firmware/fw_dynamic.bin
>  
> -This will generate spl/u-boot-spl.bin and FIT image (u-boot.itb)
> -
> -u-boot-spl.bin cannot be used directly on StarFive VisionFive2,we need
> -to convert the u-boot-spl.bin to u-boot-spl.bin.normal.out with
> -the below command:
> -
> - ./spl_tool -c -f $(Uboot_PATH)/spl/u-boot-spl.bin
> -
> -More detailed description of spl_tool,please refer spl_tool documenation.
> -(Note: spl_tool git repo is at 
> https://github.com/starfive-tech/Tools/tree/master/spl_tool)
> -
> -This will generate u-boot-spl.bin.normal.out file.
> +This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as 
> well
> +as the FIT image (u-boot.itb) with OpenSBI and U-Boot.
>  
>  Flashing
>  


Re: [PATCH RFC 2/2] configs: visionfive2: Enable MISC_INIT_R

2023-09-12 Thread Milan P . Stanić
On Mon, 2023-09-11 at 18:32, Jami Kettunen wrote:
> From: Jami Kettunen 
> 
> Used to select mainline kernel fdtfile based on board revision.
> 
> Signed-off-by: Jami Kettunen 

Tested-by: Milan P. Stanić 

> ---
>  configs/starfive_visionfive2_defconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/configs/starfive_visionfive2_defconfig 
> b/configs/starfive_visionfive2_defconfig
> index e9b63e5b84..33f9ec8ad6 100644
> --- a/configs/starfive_visionfive2_defconfig
> +++ b/configs/starfive_visionfive2_defconfig
> @@ -125,3 +125,4 @@ CONFIG_USB=y
>  CONFIG_USB_XHCI_HCD=y
>  CONFIG_USB_XHCI_PCI=y
>  CONFIG_USB_KEYBOARD=y
> +CONFIG_MISC_INIT_R=y


Re: [PATCH RFC 1/2] board: visionfive2: Select fdtfile based on revision

2023-09-12 Thread Milan P . Stanić
On Mon, 2023-09-11 at 18:32, Jami Kettunen wrote:
> From: Jami Kettunen 
> 
> Linux mainline kernel device tree files[1] are named:
> - jh7110-starfive-visionfive-2-v1.2a
> - jh7110-starfive-visionfive-2-v1.3b
> 
> which should be selected accordingly by U-Boot to have a proper extlinux
> experience with fdtdir set by the distribution.
> 
> [1] https://github.com/torvalds/linux/tree/master/arch/riscv/boot/dts/starfive
> 
> Signed-off-by: Jami Kettunen 

Tested-by: Milan P. Stanić 

> ---
>  .../visionfive2/starfive_visionfive2.c| 25 +++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/board/starfive/visionfive2/starfive_visionfive2.c 
> b/board/starfive/visionfive2/starfive_visionfive2.c
> index d609262b67..9244d4654b 100644
> --- a/board/starfive/visionfive2/starfive_visionfive2.c
> +++ b/board/starfive/visionfive2/starfive_visionfive2.c
> @@ -10,6 +10,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #define JH7110_L2_PREFETCHER_BASE_ADDR   0x203
>  #define JH7110_L2_PREFETCHER_HART_OFFSET 0x2000
> @@ -41,6 +43,29 @@ int board_init(void)
>   return 0;
>  }
>  
> +int misc_init_r(void)
> +{
> + u8 rev;
> + const char *linux_dtb_file;
> +
> + rev = get_pcb_revision_from_eeprom();
> + switch (rev) {
> + case 'a':
> + case 'A':
> + linux_dtb_file = 
> "starfive/jh7110-starfive-visionfive-2-v1.2a.dtb";
> + break;
> +
> + case 'b':
> + case 'B':
> + default:
> + linux_dtb_file = 
> "starfive/jh7110-starfive-visionfive-2-v1.3b.dtb";
> + break;
> + };
> +
> + env_set("fdtfile", linux_dtb_file);
> + return 0;
> +}
> +
>  void *board_fdt_blob_setup(int *err)
>  {
>   *err = 0;


Re: [PATCH 2/2] riscv: Correct event usage for riscv_cpu_probe/setup

2023-09-05 Thread Milan P . Stanić
On Mon, 2023-09-04 at 15:06, Tom Rini wrote:
> With having both an EVENT_SPY_SIMPLE setup for both riscv_cpu_probe and
> riscv_cpu_setup we do not need the latter function to call the former
> function as it will already have been done in time.
> 
> Fixes: 1c55d62fb9cc ("riscv: cpu: make riscv_cpu_probe to EVT_DM_POST_INIT_R 
> callback")
> Signed-off-by: Tom Rini 
Tested-by: Milan P. Stanić 

> ---
> Cc: Rick Chen 
> Cc: Leo Yu-Chi Liang  
> Cc: Simon Glass 
> Cc: Nikita Shubin 
> Cc: Chanho Park 
> Cc: Yu Chien Peter Lin 
> ---
>  arch/riscv/cpu/cpu.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> index cfe9fdc9df55..c1a9638c1ab7 100644
> --- a/arch/riscv/cpu/cpu.c
> +++ b/arch/riscv/cpu/cpu.c
> @@ -94,11 +94,7 @@ static void dummy_pending_ipi_clear(ulong hart, ulong 
> arg0, ulong arg1)
>  
>  int riscv_cpu_setup(void)
>  {
> - int ret;
> -
> - ret = riscv_cpu_probe(ctx, event);
> - if (ret)
> - return ret;
> + int __maybe_unused ret;
>  
>   /* Enable FPU */
>   if (supports_extension('d') || supports_extension('f')) {
> -- 
> 2.34.1
> 


Re: [PATCH 1/2] riscv: Rework riscv_cpu_probe for current event macros

2023-09-05 Thread Milan P . Stanić
On Mon, 2023-09-04 at 15:06, Tom Rini wrote:
> This function should now be a EVENT_SPY_SIMPLE call, update it.
> 
> Signed-off-by: Tom Rini 
Tested-by: Milan P. Stanić 

> ---
>  arch/riscv/cpu/cpu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> index d64aa330f206..cfe9fdc9df55 100644
> --- a/arch/riscv/cpu/cpu.c
> +++ b/arch/riscv/cpu/cpu.c
> @@ -66,7 +66,7 @@ static inline bool supports_extension(char ext)
>  #endif /* CONFIG_CPU */
>  }
>  
> -static int riscv_cpu_probe(void *ctx, struct event *event)
> +static int riscv_cpu_probe(void)
>  {
>  #ifdef CONFIG_CPU
>   int ret;
> @@ -79,7 +79,7 @@ static int riscv_cpu_probe(void *ctx, struct event *event)
>  
>   return 0;
>  }
> -EVENT_SPY(EVT_DM_POST_INIT_R, riscv_cpu_probe);
> +EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_R, riscv_cpu_probe);
>  
>  /*
>   * This is called on secondary harts just after the IPI is init'd. Currently
> -- 
> 2.34.1
> 


Re: [PATCH v1 2/2] doc: board: starfive: Add more info about supported driver

2023-08-23 Thread Milan P . Stanić
On Tue, 2023-08-22 at 22:33, Shengyu Qu wrote:
> Since PLDA PCIE driver is added and VL805 support is enabled in
> defconfig for Starfive Visionfive 2, modify the document to keep
> consistent.
> 
> Signed-off-by: Shengyu Qu 
Tested-by: Milan P. Stanić 

> ---
>  doc/board/starfive/visionfive2.rst | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/doc/board/starfive/visionfive2.rst 
> b/doc/board/starfive/visionfive2.rst
> index 941899a0a4..460f23aec3 100644
> --- a/doc/board/starfive/visionfive2.rst
> +++ b/doc/board/starfive/visionfive2.rst
> @@ -20,6 +20,8 @@ The support for following drivers are already enabled:
>  3. StarFive JH7110 reset Driver.
>  4. Cadence QSPI controller Driver.
>  5. MMC SPI Driver for MMC/SD support.
> +6. PLDA PCIE controller driver.
> +7. On-board VL805 PCIE-USB controller driver.
>  
>  Booting from MMC using U-Boot SPL
>  -
> -- 
> 2.42.0
> 


Re: [PATCH v1 1/2] configs: starfive: Enable PCIE auto enum and NVME/USB stuff for Starfive Visionfive 2

2023-08-23 Thread Milan P . Stanić
On Tue, 2023-08-22 at 22:33, Shengyu Qu wrote:
> Although PCIE driver already exists, board defconfig isn't configured to
> enable PCIE enum on boot, thus USB storage device and NVME drive are not
> supported by default. So modify defconfig to enable PCIE auto enum, then
> start USB subsystem and scan nvme drive on boot.
> 
> Signed-off-by: Shengyu Qu 
Tested-by: Milan P. Stanić 

> ---
>  configs/starfive_visionfive2_defconfig | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/configs/starfive_visionfive2_defconfig 
> b/configs/starfive_visionfive2_defconfig
> index e9b63e5b84..3002c96f0e 100644
> --- a/configs/starfive_visionfive2_defconfig
> +++ b/configs/starfive_visionfive2_defconfig
> @@ -30,6 +30,7 @@ CONFIG_SPL_SPI=y
>  CONFIG_SYS_LOAD_ADDR=0x8200
>  CONFIG_SYS_PCI_64BIT=y
>  CONFIG_PCI=y
> +CONFIG_PCI_INIT_R=y
>  CONFIG_TARGET_STARFIVE_VISIONFIVE2=y
>  CONFIG_SPL_OPENSBI_LOAD_ADDR=0x4000
>  CONFIG_ARCH_RV64I=y
> @@ -43,7 +44,7 @@ CONFIG_SD_BOOT=y
>  CONFIG_USE_BOOTARGS=y
>  CONFIG_BOOTARGS="console=ttyS0,115200 debug rootwait earlycon=sbi"
>  CONFIG_USE_PREBOOT=y
> -CONFIG_PREBOOT="setenv fdt_addr ${fdtcontroladdr};fdt addr 
> ${fdtcontroladdr};"
> +CONFIG_PREBOOT="nvme scan; usb start; setenv fdt_addr ${fdtcontroladdr}; fdt 
> addr ${fdtcontroladdr};"
>  CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"
>  CONFIG_DISPLAY_CPUINFO=y
>  CONFIG_DISPLAY_BOARDINFO=y
> @@ -124,4 +125,9 @@ CONFIG_TIMER_EARLY=y
>  CONFIG_USB=y
>  CONFIG_USB_XHCI_HCD=y
>  CONFIG_USB_XHCI_PCI=y
> +CONFIG_USB_EHCI_HCD=y
> +CONFIG_USB_EHCI_PCI=y
> +CONFIG_USB_OHCI_HCD=y
> +CONFIG_USB_OHCI_PCI=y
> +CONFIG_USB_STORAGE=y
>  CONFIG_USB_KEYBOARD=y
> -- 
> 2.42.0
> 


Re: [PATCH v2 2/2] riscv: cpu: make riscv_cpu_probe to EVT_DM_POST_INIT_R callback

2023-08-19 Thread Milan P . Stanić
It works.

On Fri, 2023-08-18 at 14:11, Chanho Park wrote:
> Since the Patch 55171aedda88, VisionFive2 booting has been broken [1].
> VisionFive2 board requires to enable CONFIG_TIMER_EARLY but booting went
> to panic from initr_dm_devices due to lack of a timer device.
> 
> - Error logs
> initcall sequence fffd8d38 failed at call 402185e4
> (err=-19)
> 
> Thus, we need to move riscv_cpu_probe function in order to register
> the timer earlier than initr_dm_devices.
> 
> Fixes: 7fe32b3442f0 ("event: Convert arch_cpu_init_dm() to use events")
> Cc: Simon Glass 
> Cc: Bin Meng 
> Signed-off-by: Chanho Park 
Tested-by: Milan P. Stanić 

> ---
>  arch/riscv/cpu/cpu.c | 11 +++
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> index ecfb1fb08c4b..0b4208e72199 100644
> --- a/arch/riscv/cpu/cpu.c
> +++ b/arch/riscv/cpu/cpu.c
> @@ -66,7 +66,7 @@ static inline bool supports_extension(char ext)
>  #endif /* CONFIG_CPU */
>  }
>  
> -static int riscv_cpu_probe(void)
> +static int riscv_cpu_probe(void *ctx, struct event *event)
>  {
>  #ifdef CONFIG_CPU
>   int ret;
> @@ -79,6 +79,7 @@ static int riscv_cpu_probe(void)
>  
>   return 0;
>  }
> +EVENT_SPY(EVT_DM_POST_INIT_R, riscv_cpu_probe);
>  
>  /*
>   * This is called on secondary harts just after the IPI is init'd. Currently
> @@ -95,7 +96,7 @@ int riscv_cpu_setup(void *ctx, struct event *event)
>  {
>   int ret;
>  
> - ret = riscv_cpu_probe();
> + ret = riscv_cpu_probe(ctx, event);
>   if (ret)
>   return ret;
>  
> @@ -149,12 +150,6 @@ EVENT_SPY(EVT_DM_POST_INIT_F, riscv_cpu_setup);
>  
>  int arch_early_init_r(void)
>  {
> - int ret;
> -
> - ret = riscv_cpu_probe();
> - if (ret)
> - return ret;
> -
>   if (IS_ENABLED(CONFIG_SYSRESET_SBI))
>   device_bind_driver(gd->dm_root, "sbi-sysreset",
>  "sbi-sysreset", NULL);
> -- 
> 2.39.2
> 


Re: [PATCH v2 1/2] dm: event: add EVT_DM_POST_INIT_R event type

2023-08-19 Thread Milan P . Stanić
It works.

On Fri, 2023-08-18 at 14:11, Chanho Park wrote:
> This patch introduces EVT_DM_POST_INIT_R event type for handling hooks
> after relocation.
> 
> Fixes: 55171aedda88 ("dm: Emit the arch_cpu_init_dm() even only before 
> relocation")
> Suggested-by: Simon Glass 
> Cc: Bin Meng 
> Signed-off-by: Chanho Park 
Tested-by: Milan P. Stanić 

> ---
>  drivers/core/root.c | 6 --
>  include/event.h | 1 +
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index 6775fb0b6575..79d871ab291a 100644
> --- a/drivers/core/root.c
> +++ b/drivers/core/root.c
> @@ -436,8 +436,10 @@ int dm_init_and_scan(bool pre_reloc_only)
>   return ret;
>   }
>   }
> - if (CONFIG_IS_ENABLED(DM_EVENT) && !(gd->flags & GD_FLG_RELOC)) {
> - ret = event_notify_null(EVT_DM_POST_INIT_F);
> + if (CONFIG_IS_ENABLED(DM_EVENT)) {
> + ret = event_notify_null(gd->flags & GD_FLG_RELOC ?
> + EVT_DM_POST_INIT_R :
> + EVT_DM_POST_INIT_F);
>   if (ret)
>   return log_msg_ret("ev", ret);
>   }
> diff --git a/include/event.h b/include/event.h
> index daf44bf8a83b..bb38ba98e73b 100644
> --- a/include/event.h
> +++ b/include/event.h
> @@ -24,6 +24,7 @@ enum event_t {
>  
>   /* Events related to driver model */
>   EVT_DM_POST_INIT_F,
> + EVT_DM_POST_INIT_R,
>   EVT_DM_PRE_PROBE,
>   EVT_DM_POST_PROBE,
>   EVT_DM_PRE_REMOVE,
> -- 
> 2.39.2
> 


Re: [PATCH] Makefile: Use sort shortopts

2023-07-20 Thread Milan P . Stanić
On Thu, 2023-07-20 at 14:50, Marek Vasut wrote:
> POSIX does not defined longopts for sort, use shortops
> for even more compatibility.
> 
> Fixes: cc5a490cf465 ("Makefile: Sort u-boot-initial-env output")
> Reported-by: Milan P. Stanić 
> Signed-off-by: Marek Vasut 

Tested-by: Milan P. Stanić 

small note: single quotes are not needed aroud = (equal sign)

> ---
> Cc: Christoph Niedermaier 
> Cc: Marek Behún 
> Cc: Simon Glass 
> Cc: Stefano Babic 
> Cc: u-b...@dh-electronics.com
> Cc: u-boot@lists.denx.de
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 87f9fc786e8..5fc16b3b1f1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2444,7 +2444,7 @@ quiet_cmd_genenv = GENENV  $@
>  cmd_genenv = \
>   $(objtree)/tools/printinitialenv | \
>   sed -e '/^\s*$$/d' | \
> - sort --field-separator='=' -k1,1 --stable -o $@
> + sort -t '=' -k 1,1 -s -o $@
>  
>  u-boot-initial-env: $(env_h) FORCE
>   $(Q)$(MAKE) $(build)=tools $(objtree)/tools/printinitialenv
> -- 
> 2.40.1
> 


[PATCH] scripts/config: pick config script from kernel scripts

2022-07-27 Thread Milan P . Stanić
pulled from kernel tag v5.18
---
 scripts/config | 230 +
 1 file changed, 230 insertions(+)
 create mode 100755 scripts/config

diff --git a/scripts/config b/scripts/config
new file mode 100755
index 00..ff88e2faef
--- /dev/null
+++ b/scripts/config
@@ -0,0 +1,230 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: GPL-2.0
+# Manipulate options in a .config file from the command line
+
+myname=${0##*/}
+
+# If no prefix forced, use the default CONFIG_
+CONFIG_="${CONFIG_-CONFIG_}"
+
+# We use an uncommon delimiter for sed substitutions
+SED_DELIM=$(echo -en "\001")
+
+usage() {
+   cat >&2 <"$tmpfile"
+   # replace original file with the edited one
+   mv "$tmpfile" "$infile"
+}
+
+txt_subst() {
+   local before="$1"
+   local after="$2"
+   local infile="$3"
+   local tmpfile="$infile.swp"
+
+   sed -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" 
>"$tmpfile"
+   # replace original file with the edited one
+   mv "$tmpfile" "$infile"
+}
+
+txt_delete() {
+   local text="$1"
+   local infile="$2"
+   local tmpfile="$infile.swp"
+
+   sed -e "/$text/d" "$infile" >"$tmpfile"
+   # replace original file with the edited one
+   mv "$tmpfile" "$infile"
+}
+
+set_var() {
+   local name=$1 new=$2 before=$3
+
+   name_re="^($name=|# $name is not set)"
+   before_re="^($before=|# $before is not set)"
+   if test -n "$before" && grep -Eq "$before_re" "$FN"; then
+   txt_append "^$before=" "$new" "$FN"
+   txt_append "^# $before is not set" "$new" "$FN"
+   elif grep -Eq "$name_re" "$FN"; then
+   txt_subst "^$name=.*" "$new" "$FN"
+   txt_subst "^# $name is not set" "$new" "$FN"
+   else
+   echo "$new" >>"$FN"
+   fi
+}
+
+undef_var() {
+   local name=$1
+
+   txt_delete "^$name=" "$FN"
+   txt_delete "^# $name is not set" "$FN"
+}
+
+if [ "$1" = "--file" ]; then
+   FN="$2"
+   if [ "$FN" = "" ] ; then
+   usage
+   fi
+   shift 2
+else
+   FN=.config
+fi
+
+if [ "$1" = "" ] ; then
+   usage
+fi
+
+MUNGE_CASE=yes
+while [ "$1" != "" ] ; do
+   CMD="$1"
+   shift
+   case "$CMD" in
+   --keep-case|-k)
+   MUNGE_CASE=no
+   continue
+   ;;
+   --refresh)
+   ;;
+   --*-after|-E|-D|-M)
+   checkarg "$1"
+   A=$ARG
+   checkarg "$2"
+   B=$ARG
+   shift 2
+   ;;
+   -*)
+   checkarg "$1"
+   shift
+   ;;
+   esac
+   case "$CMD" in
+   --enable|-e)
+   set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
+   ;;
+
+   --disable|-d)
+   set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
+   ;;
+
+   --module|-m)
+   set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
+   ;;
+
+   --set-str)
+   # sed swallows one level of escaping, so we need double-escaping
+   set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\"}\""
+   shift
+   ;;
+
+   --set-val)
+   set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
+   shift
+   ;;
+   --undefine|-u)
+   undef_var "${CONFIG_}$ARG"
+   ;;
+
+   --state|-s)
+   if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
+   echo n
+   else
+   V="$(grep "^${CONFIG_}$ARG=" $FN)"
+   if [ $? != 0 ] ; then
+   echo undef
+   else
+   V="${V/#${CONFIG_}$ARG=/}"
+   V="${V/#\"/}"
+   V="${V/%\"/}"
+   V="${V//\\\"/\"}"
+   echo "${V}"
+   fi
+   fi
+   ;;
+
+   --enable-after|-E)
+   set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
+   ;;
+
+   --disable-after|-D)
+   set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" 
"${CONFIG_}$A"
+   ;;
+
+   --module-after|-M)
+   set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
+   ;;
+
+   # undocumented because it ignores --file (fixme)
+   --refresh)
+   yes "" | make oldconfig
+   ;;
+
+   *)
+   echo "bad command: $CMD" >&2
+   usage
+   ;;
+   esac
+done
-- 
2.37.1



Re: [PATCH] sunxi: usb: convert PHY GPIO functions to DM

2022-06-08 Thread Milan P . Stanić
Hi,

it works fine. Thank you.

On Wed, 2022-06-08 at 01:06, Andre Przywara wrote:
> The Allwinner USB PHY driver is still using the legacy GPIO interface,
> which is now implemented by the DM_GPIO compat functions.
> Those seem to have some design flaws, as setting the direction, then
> later setting the value will not work, if the DM_GPIO driver is
> implementing set_flags.
> 
> Fix this by using the dm_ version of the direct GPIO interface, which
> uses struct gpio_desc structs to handle requested GPIOs, and actually
> keeps the flags we set earlier.
> 
> This fixes USB operation on boards which need to toggle the VBUS supply
> via a GPIO, like the Teres-I laptop or the BananaPi M2 Berry board.
> 
> Signed-off-by: Andre Przywara 
> Reported-by: Milan P. Stanić 
Tested-by: Milan P. Stanić 
> ---
>  drivers/phy/allwinner/phy-sun4i-usb.c | 59 +++
>  1 file changed, 33 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c 
> b/drivers/phy/allwinner/phy-sun4i-usb.c
> index 86c589a65fd..aef2cb8f6f8 100644
> --- a/drivers/phy/allwinner/phy-sun4i-usb.c
> +++ b/drivers/phy/allwinner/phy-sun4i-usb.c
> @@ -125,9 +125,9 @@ struct sun4i_usb_phy_info {
>  
>  struct sun4i_usb_phy_plat {
>   void __iomem *pmu;
> - int gpio_vbus;
> - int gpio_vbus_det;
> - int gpio_id_det;
> + struct gpio_desc gpio_vbus;
> + struct gpio_desc gpio_vbus_det;
> + struct gpio_desc gpio_id_det;
>   struct clk clocks;
>   struct reset_ctl resets;
>   int id;
> @@ -224,8 +224,8 @@ static int sun4i_usb_phy_power_on(struct phy *phy)
>   initial_usb_scan_delay = 0;
>   }
>  
> - if (usb_phy->gpio_vbus >= 0)
> - gpio_set_value(usb_phy->gpio_vbus, SUNXI_GPIO_PULL_UP);
> + if (dm_gpio_is_valid(_phy->gpio_vbus))
> + dm_gpio_set_value(_phy->gpio_vbus, 1);
>  
>   return 0;
>  }
> @@ -235,8 +235,8 @@ static int sun4i_usb_phy_power_off(struct phy *phy)
>   struct sun4i_usb_phy_data *data = dev_get_priv(phy->dev);
>   struct sun4i_usb_phy_plat *usb_phy = >usb_phy[phy->id];
>  
> - if (usb_phy->gpio_vbus >= 0)
> - gpio_set_value(usb_phy->gpio_vbus, SUNXI_GPIO_PULL_DISABLE);
> + if (dm_gpio_is_valid(_phy->gpio_vbus))
> + dm_gpio_set_value(_phy->gpio_vbus, 0);
>  
>   return 0;
>  }
> @@ -386,8 +386,8 @@ int sun4i_usb_phy_vbus_detect(struct phy *phy)
>   struct sun4i_usb_phy_plat *usb_phy = >usb_phy[phy->id];
>   int err = 1, retries = 3;
>  
> - if (usb_phy->gpio_vbus_det >= 0) {
> - err = gpio_get_value(usb_phy->gpio_vbus_det);
> + if (dm_gpio_is_valid(_phy->gpio_vbus_det)) {
> + err = dm_gpio_get_value(_phy->gpio_vbus_det);
>   /*
>* Vbus may have been provided by the board and just turned off
>* some milliseconds ago on reset. What we're measuring then is
> @@ -395,7 +395,7 @@ int sun4i_usb_phy_vbus_detect(struct phy *phy)
>*/
>   while (err > 0 && retries--) {
>   mdelay(100);
> - err = gpio_get_value(usb_phy->gpio_vbus_det);
> + err = dm_gpio_get_value(_phy->gpio_vbus_det);
>   }
>   } else if (data->vbus_power_supply) {
>   err = regulator_get_enable(data->vbus_power_supply);
> @@ -409,10 +409,10 @@ int sun4i_usb_phy_id_detect(struct phy *phy)
>   struct sun4i_usb_phy_data *data = dev_get_priv(phy->dev);
>   struct sun4i_usb_phy_plat *usb_phy = >usb_phy[phy->id];
>  
> - if (usb_phy->gpio_id_det < 0)
> - return usb_phy->gpio_id_det;
> + if (!dm_gpio_is_valid(_phy->gpio_id_det))
> + return -1;
>  
> - return gpio_get_value(usb_phy->gpio_id_det);
> + return dm_gpio_get_value(_phy->gpio_id_det);
>  }
>  
>  void sun4i_usb_phy_set_squelch_detect(struct phy *phy, bool enabled)
> @@ -454,35 +454,42 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
>   if (data->cfg->missing_phys & BIT(i))
>   continue;
>  
> - phy->gpio_vbus = sunxi_name_to_gpio(info->gpio_vbus);
> - if (phy->gpio_vbus >= 0) {
> - ret = gpio_request(phy->gpio_vbus, "usb_vbus");
> + ret = dm_gpio_lookup_name(info->gpio_vbus, >gpio_vbus);
> + if (ret == 0) {
> + ret = dm_gpio_request(>gpio_vbus, "usb_vbus");
>   

[BUG] keyboard doesn't work on Olimex teres-I notebook

2022-04-19 Thread Milan P . Stanić
[ Please CC to me, I'm not subscribed to mailing list ]

Hi,

On u-boot release 2022.04 keyboard doesn't work in u-boot on Olimex
TERES-I notebook.

With git bisect I found that commit 35ae126c16a6a9149edc6638faaa247f67b8a400
is introduced this. Reverting this commit solved problem and in my test
keyboard now works.

-- 
Kind regards


Re: [PATCH] sandbox: fix build failure with musl and SDL

2022-02-03 Thread Milan P . Stanić
Hi,

On Thu, 2022-01-27 at 14:35, Simon Glass wrote:
> Hi,
> 
> On Fri, 21 Jan 2022 at 13:11, Milan P. Stanić  wrote:
> >
> > Hi,
> >
> > it works and build pass without error or warning.
> > Tested on alpine edge aarch64 bare metal.
> >
> > Thank you
> >
> > On Fri, 2022-01-21 at 18:00, Heinrich Schuchardt wrote:
> > > sdl.c is compiled against the SDL library.
> > >
> > > Trying to redefine wchar_t with -fshort-wchar is not necessary
> > > and leads to build failures when compiling against musl.
> > >
> > > Cc: Milan P. Stanić 
> > > Signed-off-by: Heinrich Schuchardt 
> >
> > Tested-by: Milan P. Stanić 
> >
> > > ---
> > >  arch/sandbox/Makefile |  7 +++
> > >  arch/sandbox/cpu/Makefile | 11 ---
> > >  2 files changed, 15 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
> > > index f6cf859f24..0bdd322f12 100644
> > > --- a/arch/sandbox/Makefile
> > > +++ b/arch/sandbox/Makefile
> > > @@ -4,3 +4,10 @@ head-y := arch/sandbox/cpu/start.o arch/sandbox/cpu/os.o
> > >  head-$(CONFIG_SANDBOX_SDL) += arch/sandbox/cpu/sdl.o
> > >  libs-y += arch/sandbox/cpu/
> > >  libs-y += arch/sandbox/lib/
> > > +
> > > +# sdl.c fails to compile with -fshort-wchar using musl.
> > > +cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \
> > > + $(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $<
> > > +
> > > +$(obj)/sdl.o: $(src)/sdl.c FORCE
> > > + $(call if_changed_dep,cc_sdl.o)
> > > diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
> > > index de7fe7f391..b74c866e56 100644
> > > --- a/arch/sandbox/cpu/Makefile
> > > +++ b/arch/sandbox/cpu/Makefile
> > > @@ -7,7 +7,7 @@
> > >
> > >  obj-y:= cache.o cpu.o state.o
> > >  extra-y  := start.o os.o
> > > -extra-$(CONFIG_SANDBOX_SDL)  += sdl.o
> > > +extra-$(CONFIG_SANDBOX_SDL)+= sdl.o
> > >  obj-$(CONFIG_SPL_BUILD)  += spl.o
> > >  obj-$(CONFIG_ETH_SANDBOX_RAW)+= eth-raw-os.o
> > >
> > > @@ -19,8 +19,6 @@ cmd_cc_os.o = $(CC) $(filter-out -nostdinc, \
> > >
> > >  $(obj)/os.o: $(src)/os.c FORCE
> > >   $(call if_changed_dep,cc_os.o)
> > > -$(obj)/sdl.o: $(src)/sdl.c FORCE
> > > - $(call if_changed_dep,cc_os.o)
> > >
> > >  # eth-raw-os.c is built in the system env, so needs standard includes
> > >  # CFLAGS_REMOVE_eth-raw-os.o cannot be used to drop header include path
> > > @@ -30,3 +28,10 @@ cmd_cc_eth-raw-os.o = $(CC) $(filter-out -nostdinc, \
> > >
> > >  $(obj)/eth-raw-os.o: $(src)/eth-raw-os.c FORCE
> > >   $(call if_changed_dep,cc_eth-raw-os.o)
> > > +
> > > +# sdl.c fails to build with -fshort-wchar using musl
> > > +cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \
> > > + $(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $<
> > > +
> > > +$(obj)/sdl.o: $(src)/sdl.c FORCE
> > > + $(call if_changed_dep,cc_sdl.o)
> > > --
> > > 2.33.1
> > >
> 
> This fails on gitlab.
> 
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/jobs/382812
> 
> $ tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e
> --board ${TEST_PY_BD} ${OVERRIDE}
> Building current source for 1 boards (1 thread, 40 jobs per thread)
>sandbox:  +   sandbox
> +/usr/bin/ld: error: LLVM gold plugin: linking module flags
> 'wchar_size': IDs have conflicting values in 'arch/sandbox/cpu/sdl.o'
> and 'ld-temp.o'
> +clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> +make[1]: *** [Makefile:1799: u-boot] Error 1
> +make: *** [Makefile:177: sub-make] Error 2
> 001 /1  sandbox
> Completed: 1 total built, duration 0:00:22, rate 0.05
> Running after_script
> 
> 
> Please can you take a look?

I tested with clang and lld, and clang ld.gold in lxc and bare metal
build. didn't had this errors.

Could be that this problem appears on docker only.

-- 
Kind regards


Re: [PATCH 1/1] sandbox: eth-raw: fix building with musl library

2022-01-21 Thread Milan P . Stanić
Hi,

it works and build pass without error or warning.
Tested on alpine edge aarch64 bare metal.

Thank you

On Fri, 2022-01-21 at 18:01, Heinrich Schuchardt wrote:
> The definition of struct udphdr in include netinet/udp.h in the
> musl library differs from the definition in the glibc library.
> 
> To use the same definition with musl the symbol _GNU_SOURCE has
> to be defined.
> 
> Reported-by: Milan P. Stanić 
> Signed-off-by: Heinrich Schuchardt 

Tested-by: Milan P. Stanić 

> ---
>  arch/sandbox/cpu/eth-raw-os.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
> index 6a8d809756..e59b96be5f 100644
> --- a/arch/sandbox/cpu/eth-raw-os.c
> +++ b/arch/sandbox/cpu/eth-raw-os.c
> @@ -4,6 +4,8 @@
>   * Copyright (c) 2015-2018 Joe Hershberger 
>   */
>  
> +#define _GNU_SOURCE
> +
>  #include 
>  #include 
>  #include 
> -- 
> 2.33.1
> 


Re: [PATCH] sandbox: fix build failure with musl and SDL

2022-01-21 Thread Milan P . Stanić
Hi,

it works and build pass without error or warning.
Tested on alpine edge aarch64 bare metal.

Thank you

On Fri, 2022-01-21 at 18:00, Heinrich Schuchardt wrote:
> sdl.c is compiled against the SDL library.
> 
> Trying to redefine wchar_t with -fshort-wchar is not necessary
> and leads to build failures when compiling against musl.
> 
> Cc: Milan P. Stanić 
> Signed-off-by: Heinrich Schuchardt 

Tested-by: Milan P. Stanić 

> ---
>  arch/sandbox/Makefile |  7 +++
>  arch/sandbox/cpu/Makefile | 11 ---
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
> index f6cf859f24..0bdd322f12 100644
> --- a/arch/sandbox/Makefile
> +++ b/arch/sandbox/Makefile
> @@ -4,3 +4,10 @@ head-y := arch/sandbox/cpu/start.o arch/sandbox/cpu/os.o
>  head-$(CONFIG_SANDBOX_SDL) += arch/sandbox/cpu/sdl.o
>  libs-y += arch/sandbox/cpu/
>  libs-y += arch/sandbox/lib/
> +
> +# sdl.c fails to compile with -fshort-wchar using musl.
> +cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \
> + $(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $<
> +
> +$(obj)/sdl.o: $(src)/sdl.c FORCE
> + $(call if_changed_dep,cc_sdl.o)
> diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
> index de7fe7f391..b74c866e56 100644
> --- a/arch/sandbox/cpu/Makefile
> +++ b/arch/sandbox/cpu/Makefile
> @@ -7,7 +7,7 @@
>  
>  obj-y:= cache.o cpu.o state.o
>  extra-y  := start.o os.o
> -extra-$(CONFIG_SANDBOX_SDL)  += sdl.o
> +extra-$(CONFIG_SANDBOX_SDL)+= sdl.o
>  obj-$(CONFIG_SPL_BUILD)  += spl.o
>  obj-$(CONFIG_ETH_SANDBOX_RAW)+= eth-raw-os.o
>  
> @@ -19,8 +19,6 @@ cmd_cc_os.o = $(CC) $(filter-out -nostdinc, \
>  
>  $(obj)/os.o: $(src)/os.c FORCE
>   $(call if_changed_dep,cc_os.o)
> -$(obj)/sdl.o: $(src)/sdl.c FORCE
> - $(call if_changed_dep,cc_os.o)
>  
>  # eth-raw-os.c is built in the system env, so needs standard includes
>  # CFLAGS_REMOVE_eth-raw-os.o cannot be used to drop header include path
> @@ -30,3 +28,10 @@ cmd_cc_eth-raw-os.o = $(CC) $(filter-out -nostdinc, \
>  
>  $(obj)/eth-raw-os.o: $(src)/eth-raw-os.c FORCE
>   $(call if_changed_dep,cc_eth-raw-os.o)
> +
> +# sdl.c fails to build with -fshort-wchar using musl
> +cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \
> + $(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $<
> +
> +$(obj)/sdl.o: $(src)/sdl.c FORCE
> + $(call if_changed_dep,cc_sdl.o)
> -- 
> 2.33.1
> 


Re: [PATCH 1/1] mkimage: struct stat.st_size may not be long

2022-01-17 Thread Milan P . Stanić
It fixes these warnings below.

On Sat, 2022-01-15 at 20:12, Heinrich Schuchardt wrote:
> The component st_size of struct stat is of type off_t. Depending on the
> system printing it it with %ld leads to a warning:
> 
> tools/mkimage.c:438:54: warning: format '%ld' expects argument of type
> 'long int', but argument 5 has type
> 'off_t' {aka 'long long int'} [-Wformat=]
>   438 | "%s: Bad size: \"%s\" is not valid image: size %ld < %u\n",
>   |~~^
>   |  |
>   |  long int
>   |%lld
> 
> When comparing an off_t value to a 32bit integer we should not convert to
> uint32_t but to off_t which may be wider.
> 
> Reported-by: Milan P. Stanić 
> Fixes: 331f0800f1a3 ("mkimage: allow -l to work on block devices on Linux")
> Signed-off-by: Heinrich Schuchardt 

Tested by: Milan P. Stanić 

> ---
>  tools/mkimage.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/mkimage.c b/tools/mkimage.c
> index fbe883ce36..79042be828 100644
> --- a/tools/mkimage.c
> +++ b/tools/mkimage.c
> @@ -433,11 +433,12 @@ int main(int argc, char **argv)
>   params.cmdname, params.imagefile);
>   exit (EXIT_FAILURE);
>  #endif
> - } else if ((unsigned)sbuf.st_size < tparams->header_size) {
> + } else if (sbuf.st_size < (off_t)tparams->header_size) {
>   fprintf (stderr,
> - "%s: Bad size: \"%s\" is not valid image: size 
> %ld < %u\n",
> + "%s: Bad size: \"%s\" is not valid image: size 
> %llu < %u\n",
>   params.cmdname, params.imagefile,
> - sbuf.st_size, tparams->header_size);
> + (unsigned long long) sbuf.st_size,
> + tparams->header_size);
>   exit (EXIT_FAILURE);
>   } else {
>   size = sbuf.st_size;
> -- 
> 2.33.1
> 


Re: [BUG] sandbox: NO_SDL=1 gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory

2022-01-16 Thread Milan P . Stanić
On Sun, 2022-01-16 at 23:41, Heinrich Schuchardt wrote:
> On 1/16/22 22:14, Milan P. Stanić wrote:
> > wrote:
> > > On 1/13/22 14:41, Simon Glass wrote:
> > > > Hi Heinrich,
> > > > 
> > > > On Mon, 10 Jan 2022 at 16:22, Heinrich Schuchardt  
> > > > wrote:
> > > > > Hello Simon,
> > > > > 
> > > > > compiling with SDL fails on Alpine Linux:
> > > > > https://gitlab.alpinelinux.org/alpine/aports/-/issues/13411
> > > > > 
> > > > > So I tried NO_SDL:
> > > > > 
> > > > > make sandbox_defconfig NO_SDL=1
> > > > > make menuconfig # CONFIG_ETH_SANDBOX_RAW=n
> > > > > make -j4 NO_SDL=1
> > > > > 
> > > > > But I got an error
> > > > > gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory
> > > > Do you need mrproper first? I don't hit that problem.
> > > Please, build the appended Dockerfile ("sudo docker build -t .").
> > I run it on aarch64 (I don't have x86_64 machine for this) and I didn't got 
> > error.
> > 
> > here is the output of 'docker build .':
> > ---
> > Step 12/16 : RUN git clonehttps://source.denx.de/u-boot/u-boot.git
> >   ---> Running in 4f89022fad97
> > Cloning into 'u-boot'...
> > Removing intermediate container 4f89022fad97
> >   ---> 8f4a64791065
> > Step 13/16 : WORKDIR /home/uboot/u-boot
> >   ---> Running in c88471d92078
> > Removing intermediate container c88471d92078
> >   ---> 361d0979bd27
> > Step 14/16 : RUN make sandbox_defconfig NO_SDL=1
> >   ---> Running in aad201f298b6
> >HOSTCC  scripts/basic/fixdep
> >HOSTCC  scripts/kconfig/conf.o
> >YACCscripts/kconfig/zconf.tab.c
> >LEX scripts/kconfig/zconf.lex.c
> >HOSTCC  scripts/kconfig/zconf.tab.o
> >HOSTLD  scripts/kconfig/conf
> > #
> > # configuration written to .config
> > #
> > Removing intermediate container aad201f298b6
> >   ---> bf5a898ae7f6
> > Step 15/16 : RUN sed -i 's/CONFIG_ETH_SANDBOX_RAW=y/# 
> > CONFIG_ETH_SANDBOX_RAW is not set/g' .config
> >   ---> Running in 50eb86bfd2aa
> > Removing intermediate container 50eb86bfd2aa
> >   ---> 0eb72e2956d1
> > Step 16/16 : RUN sed -i 's/CONFIG_VIDEO_SANDBOX_SDL=y/# 
> > CONFIG_VIDEO_SANDBOX_SDL is not set/g' .config
> >   ---> Running in 18bd37a4251f
> > Removing intermediate container 18bd37a4251f
> >   ---> 8b391226e895
> > Successfully built 8b391226e895
> > ---
> > 
> > -- Best regards
> > > It gives me:
> > > 
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp8':
> > > /home/uboot/u-boot/test/dm/video.c:357: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp16':
> > > /home/uboot/u-boot/test/dm/video.c:378: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp24':
> > > /home/uboot/u-boot/test/dm/video.c:401: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function 
> > > `dm_test_video_bmp24_32':
> > > /home/uboot/u-boot/test/dm/video.c:424: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp32':
> > > /home/uboot/u-boot/test/dm/video.c:445: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o:/home/uboot/u-boot/test/dm/video.c:479:
> > > more undefined references to `sandbox_sdl_set_bpp' follow
> > > collect2: error: ld returned 1 exit status
> > > make: *** [Makefile:1799: u-boot] Error 1
> > > 
> > > Best regards
> > > 
> >

Re: [BUG] sandbox: NO_SDL=1 gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory

2022-01-16 Thread Milan P . Stanić
On Sat, 2022-01-15 at 19:47, Heinrich Schuchardt wrote:
> On 1/13/22 14:41, Simon Glass wrote:
> > Hi Heinrich,
> > 
> > On Mon, 10 Jan 2022 at 16:22, Heinrich Schuchardt  
> > wrote:
> > > 
> > > Hello Simon,
> > > 
> > > compiling with SDL fails on Alpine Linux:
> > > https://gitlab.alpinelinux.org/alpine/aports/-/issues/13411
> > > 
> > > So I tried NO_SDL:
> > > 
> > > make sandbox_defconfig NO_SDL=1
> > > make menuconfig # CONFIG_ETH_SANDBOX_RAW=n
> > > make -j4 NO_SDL=1
> > > 
> > > But I got an error
> > > gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory
> > 
> > Do you need mrproper first? I don't hit that problem.
> 
> Please, build the appended Dockerfile ("sudo docker build -t .").

I run it on aarch64 (I don't have x86_64 machine for this) and I didn't got 
error.

here is the output of 'docker build .':
---
Step 12/16 : RUN git clone https://source.denx.de/u-boot/u-boot.git
 ---> Running in 4f89022fad97
Cloning into 'u-boot'...
Removing intermediate container 4f89022fad97
 ---> 8f4a64791065
Step 13/16 : WORKDIR /home/uboot/u-boot
 ---> Running in c88471d92078
Removing intermediate container c88471d92078
 ---> 361d0979bd27
Step 14/16 : RUN make sandbox_defconfig NO_SDL=1
 ---> Running in aad201f298b6
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACCscripts/kconfig/zconf.tab.c
  LEX scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
Removing intermediate container aad201f298b6
 ---> bf5a898ae7f6
Step 15/16 : RUN sed -i 's/CONFIG_ETH_SANDBOX_RAW=y/# CONFIG_ETH_SANDBOX_RAW is 
not set/g' .config
 ---> Running in 50eb86bfd2aa
Removing intermediate container 50eb86bfd2aa
 ---> 0eb72e2956d1
Step 16/16 : RUN sed -i 's/CONFIG_VIDEO_SANDBOX_SDL=y/# 
CONFIG_VIDEO_SANDBOX_SDL is not set/g' .config
 ---> Running in 18bd37a4251f
Removing intermediate container 18bd37a4251f
 ---> 8b391226e895
Successfully built 8b391226e895
---

-- 
Best regards

> 
> It gives me:
> 
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp8':
> /home/uboot/u-boot/test/dm/video.c:357: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp16':
> /home/uboot/u-boot/test/dm/video.c:378: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp24':
> /home/uboot/u-boot/test/dm/video.c:401: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp24_32':
> /home/uboot/u-boot/test/dm/video.c:424: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp32':
> /home/uboot/u-boot/test/dm/video.c:445: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o:/home/uboot/u-boot/test/dm/video.c:479:
> more undefined references to `sandbox_sdl_set_bpp' follow
> collect2: error: ld returned 1 exit status
> make: *** [Makefile:1799: u-boot] Error 1
> 
> Best regards
> 
> Heinrich
> 
> > 
> > I see that I broke it...it needs a static inline for
> > sandbox_sdl_remove_display().
> > 
> > > 
> > > Can't we make CONFIG_SANDBOX_SDL a Kconfig symbol to get rid of the
> > > command line symbol?
> > > 
> > > We already have CONFIG_SANDBOX_VIDEO_SDL. Do we need two symbols?
> > 
> > You mean, manually change the defconfig file? I suppose we could do
> > that, but it is harder for people to do.
> > 
> > In any case, we should add this case to CI.
> > 
> > Regards,
> > Simon

> # SPDX-License-Identifier: GPL-2.0+
> # This Dockerfile is used to build an image containing basic stuff to be used
> # to build U-Boot and run our test suites.
> 
> FROM alpine:3.15.0
> MAINTAINER Heinrich Schuchardt 
> LABEL Description=" This image is for building U-Boot inside a container"
> 
> # Install packages
> RUN apk update
> RUN apk add \
>   alpine-sdk \
>   bash \
>   bc \
>   bison \
>   dtc \
>   flex \
>   git \
>   linux-headers \
>   ncurses-dev \
>   openssl-dev \
>   perl \
>   python3 \
>   py3-setuptools \
>   python3-dev \
>   sdl2-dev \
>   sudo 
> 
> # Create our user/group
> RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
> RUN adduser -D uboot
> RUN addgroup 

Re: [PATCH 1/1] sandbox: compatibility of os_get_filesize()

2022-01-11 Thread Milan P . Stanić
On Tue, 2022-01-11 at 01:50, Heinrich Schuchardt wrote:
> U-Boot define loff_t as long long. But the header
> /usr/include/linux/types.h may not define it.
> This has lead to a build error on Alpine Linux.
> 
> So let's use long long instead of loff_t for
> the size parameter of function os_get_filesize().
> 
> Reported-by: Milan P. Stanić 
> Signed-off-by: Heinrich Schuchardt 
Tested-by: Milan P. Stanić 

> ---
>  arch/sandbox/cpu/os.c | 10 --
>  include/os.h  |  2 +-
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
> index 6837bfceaf..40ebe322ae 100644
> --- a/arch/sandbox/cpu/os.c
> +++ b/arch/sandbox/cpu/os.c
> @@ -624,7 +624,13 @@ const char *os_dirent_get_typename(enum os_dirent_t type)
>   return os_dirent_typename[OS_FILET_UNKNOWN];
>  }
>  
> -int os_get_filesize(const char *fname, loff_t *size)
> +/*
> + * For compatibility reasons avoid loff_t here.
> + * U-Boot defines loff_t as long long.
> + * But /usr/include/linux/types.h may not define it at all.
> + * Alpine Linux being one example.
> + */
> +int os_get_filesize(const char *fname, long long *size)
>  {
>   struct stat buf;
>   int ret;
> @@ -667,7 +673,7 @@ int os_read_ram_buf(const char *fname)
>  {
>   struct sandbox_state *state = state_get_current();
>   int fd, ret;
> - loff_t size;
> + long long size;
>  
>   ret = os_get_filesize(fname, );
>   if (ret < 0)
> diff --git a/include/os.h b/include/os.h
> index 4cbcbd93a7..10e198cf50 100644
> --- a/include/os.h
> +++ b/include/os.h
> @@ -266,7 +266,7 @@ const char *os_dirent_get_typename(enum os_dirent_t type);
>   * @size:size of file is returned if no error
>   * Return:   0 on success or -1 if an error ocurred
>   */
> -int os_get_filesize(const char *fname, loff_t *size);
> +int os_get_filesize(const char *fname, long long *size);
>  
>  /**
>   * os_putc() - write a character to the controlling OS terminal
> -- 
> 2.33.1
>