[PATCH 3/3] bsps/shared/: Use device tree blob

Alan Cudmore alan.cudmore at gmail.com
Wed Sep 14 03:57:34 UTC 2022


Hi Padmarao,
I am working on a RISC-V bsp variant for the Kendryte K210 and I am also
using an included DTB. For my k210 bsp, I changed
riscv/shared/start/start.S to set the address of the DTB array before
calling bsp_fdt_copy. If we change start.S to handle the following three
cases, we would not have to change the bsp_fdt_copy function. The three
cases are:
- no FDT, I assume griscv bsp
- uboot - a0 in contains the address of the u-boot loaded DTB
- polarfire, k210 and others - set a0 to the address of the included DTB
array
I think it's better to keep this function generic and not have to
conditionally ignore the input parameter.

Thanks,
Alan


On Thu, Sep 8, 2022 at 11:44 AM Padmarao Begari <
padmarao.begari at microchip.com> wrote:

> If the bsp is integrated and supported a device tree
> blob(dtb) then use dtb instead of using it from the U-Boot.
> ---
>  bsps/shared/start/bsp-fdt.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/bsps/shared/start/bsp-fdt.c b/bsps/shared/start/bsp-fdt.c
> index 75a1ea41c9..7e1a698896 100644
> --- a/bsps/shared/start/bsp-fdt.c
> +++ b/bsps/shared/start/bsp-fdt.c
> @@ -32,6 +32,10 @@
>  #include <bsp/fdt.h>
>  #include <bsp/linker-symbols.h>
>
> +#ifdef BSP_DTB_IS_SUPPORTED
> +#include BSP_DTB_HEADER_PATH
> +#endif
> +
>  #ifndef BSP_FDT_IS_SUPPORTED
>  #warning "BSP FDT support indication not defined"
>  #endif
> @@ -51,7 +55,12 @@ bsp_fdt_blob[BSP_FDT_BLOB_SIZE_MAX / sizeof(uint32_t)];
>
>  void bsp_fdt_copy(const void *src)
>  {
> +#ifdef BSP_DTB_IS_SUPPORTED
> +const volatile uint32_t *s = (const uint32_t *) system_dtb;
> +#else
>    const volatile uint32_t *s = (const uint32_t *) src;
> +#endif
> +
>  #ifdef BSP_FDT_BLOB_COPY_TO_READ_ONLY_LOAD_AREA
>    uint32_t *d = (uint32_t *) ((uintptr_t) &bsp_fdt_blob[0]
>      - (uintptr_t) bsp_section_rodata_begin
> @@ -61,7 +70,7 @@ void bsp_fdt_copy(const void *src)
>  #endif
>
>    if (s != d) {
> -    size_t m = MIN(sizeof(bsp_fdt_blob), fdt_totalsize(src));
> +    size_t m = MIN(sizeof(bsp_fdt_blob), fdt_totalsize(s));
>      size_t aligned_size = roundup2(m, CPU_CACHE_LINE_BYTES);
>      size_t n = (m + sizeof(*d) - 1) / sizeof(*d);
>      size_t i;
> --
> 2.25.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20220913/15f65249/attachment.htm>


More information about the devel mailing list