Skip to contentSkip to conversation

Add support for loading main_r5fss0_core0

PATCH Superseded Keerthy 3 participants 27 messages Jan 22, 2020 – Jan 28, 2020

Subsystems (3)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Keerthy

author
#0 lore raw

v4 cover Add support for loading main_r5fss0_core0

This patch series enables mcu_r5fss0_core0 & main_r5fss0_core0. Tested for firmware loading and execution on J721e.

Changes in v4:

* Changed env variable names, config names and enhanced commit logs.

Changes in v3:

* Removed saving env in MMC and fixed env saving in SPL when nowhere option is set.

Changes in v2:

* Factored out all the generic elf handling functions under lib/elf.c

Keerthy (10):
env: nowhere: set default enviroment
lib: elf: Move the generic elf loading/validating functions to lib
arm: k3: Add support for loading non linux remote cores
armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM
armv7R: K3: Add support for jumping to firmware
arm: dts: k3-j721e-r5: Add fs_loader node
arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL
include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 &

    main_r5fss0_core0

configs: j721e_evm_r5: Enable R5F remoteproc support
configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC

 .../arm/dts/k3-j721e-r5-common-proc-board.dts |  20 ++
 arch/arm/mach-k3/common.c                     | 106 +++++++-
 arch/arm/mach-k3/common.h                     |   2 +
 arch/arm/mach-k3/j721e_init.c                 |  34 +++
 arch/arm/mach-k3/r5_mpu.c                     |   4 +-
 cmd/Kconfig                                   |   1 +
 cmd/elf.c                                     | 229 ----------------
 configs/j721e_evm_r5_defconfig                |   6 +-
 env/nowhere.c                                 |   1 +
 include/configs/j721e_evm.h                   |   4 +
 include/elf.h                                 |   4 +
 lib/Kconfig                                   |   3 +
 lib/Makefile                                  |   1 +
 lib/elf.c                                     | 256 ++++++++++++++++++
 14 files changed, 426 insertions(+), 245 deletions(-)
 create mode 100644 lib/elf.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v4 1/10 env: nowhere: set default enviroment

Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set.

---

Changes in v4:

* Reworded commit log

 env/nowhere.c | 1 +
 1 file changed, 1 insertion(+)
env/nowhere.c +1 -0
index f5b0a17652..70c3b3e011 100644
@@ -23,6 +23,7 @@ static int env_nowhere_init(void)
 {
 	gd->env_addr	= (ulong)&default_environment[0];
 	gd->env_valid	= ENV_INVALID;
+	env_set_default(NULL, 0);
 
 	return 0;
 }
Signature · 1 line
2.17.1
#2 lore raw

PATCH v4 1/10 env: nowhere: set default enviroment

Quoted 18 lines · Keerthy

Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set.

---

Changes in v4:

* Reworded commit log

 env/nowhere.c | 1 +
 1 file changed, 1 insertion(+)
env/nowhere.c +0 -0
index f5b0a17652..70c3b3e011 100644

env/nowhere.c static int env_nowhere_init(void) · line 29

Quoted 7 lines
env/nowhere.c +1 -0
@@ -23,6 +23,7 @@ static int env_nowhere_init(void)
 {
 	gd->env_addr	= (ulong)&default_environment[0];
 	gd->env_valid	= ENV_INVALID;
+	env_set_default(NULL, 0);
 
 	return 0;
 }

What exactly do you mean by this? Can you give an example or two (code and/or shell) where things didn't work before but do now? And please CC Joe/Wolfgang in the future on env patches, thanks.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200124/1d27b40e/attachment.sig>
author
#3 lore raw

PATCH v4 1/10 env: nowhere: set default enviroment

Quoted 25 lines · Tom Rini
Quoted 23 lines · Keerthy

Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set.

---

Changes in v4:

* Reworded commit log

  env/nowhere.c | 1 +
  1 file changed, 1 insertion(+)
env/nowhere.c +1 -0
index f5b0a17652..70c3b3e011 100644
@@ -23,6 +23,7 @@ static int env_nowhere_init(void)
  {
  	gd->env_addr	= (ulong)&default_environment[0];
  	gd->env_valid	= ENV_INVALID;
+	(NULL, 0);
 
Quoted 6 lines

env/nowhere.c static int env_nowhere_init(void) · line 29

Quoted 2 lines
env/nowhere.c +0 -0
  	return 0;
  }

What exactly do you mean by this? Can you give an example or two (code and/or shell) where things didn't work before but do now? And please CC Joe/Wolfgang in the future on env patches, thanks.

Tom,

I have a case where only ENV_IS_NOWHERE is set in SPL without any of the memory based env configs like ENV_IS_IN_FAT or ENV_IS_IN_MMC. With that if i try to use env_set it does not work.

env_set checks for (gd->flags & GD_FLG_ENV_READY) which never is true for the nowhere case and hence env_set returns 1.

If any of the memory based ENV config is set i see that env_set_default is called hence env_set works nicely. So we need to have env_set_default in the case of nowhere configuration as well.

Best Regards,
Keerthy

Quoted 1 line
#4 lore raw

PATCH v4 1/10 env: nowhere: set default enviroment

Dear Keerthy,

Quoted 14 lines · In message <[email protected]> you wrote:
Quoted 14 lines
Quoted 14 lines

Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set.

---

Changes in v4:

* Reworded commit log

  env/nowhere.c | 1 +
  1 file changed, 1 insertion(+)
Quoted 9 lines
Quoted 9 lines

env/nowhere.c static int env_nowhere_init(void) · line 26

Quoted 9 lines
env/nowhere.c +1 -0
index f5b0a17652..70c3b3e011 100644
@@ -23,6 +23,7 @@ static int env_nowhere_init(void)
  {
  	gd->env_addr	= (ulong)&default_environment[0];
  	gd->env_valid	= ENV_INVALID;
+	(NULL, 0);

^^^^^^^^^^^^^^^^^^^^^^
You are inserting this line of "C code" only.

Quoted 13 lines
Quoted 6 lines

env/nowhere.c static int env_nowhere_init(void) · line 29

Quoted 2 lines
env/nowhere.c +0 -0
  	return 0;
  }

What exactly do you mean by this? Can you give an example or two (code and/or shell) where things didn't work before but do now? And please CC Joe/Wolfgang in the future on env patches, thanks.

Tom,

I have a case where only ENV_IS_NOWHERE is set in SPL without any of the memory based env configs like ENV_IS_IN_FAT or ENV_IS_IN_MMC. With that if i try to use env_set it does not work.

Quoted 6 lines

env_set checks for (gd->flags & GD_FLG_ENV_READY) which never is true for the nowhere case and hence env_set returns 1.

If any of the memory based ENV config is set i see that env_set_default is called hence env_set works nicely. So we need to have env_set_default in the case of nowhere configuration as well.

And in which way does inserting this single line of "code" change the behaviour?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
As far as we know, our computer has never had an undetected error.
		                                           -- Weisert
#5 lore raw

PATCH v4 1/10 env: nowhere: set default enviroment

Quoted 17 lines · Wolfgang Denk

Dear Keerthy,

Quoted 14 lines · In message <[email protected]> you wrote:
Quoted 14 lines
Quoted 14 lines

Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set.

---

Changes in v4:

* Reworded commit log

  env/nowhere.c | 1 +
  1 file changed, 1 insertion(+)
Quoted 12 lines
Quoted 9 lines
Quoted 9 lines

env/nowhere.c static int env_nowhere_init(void) · line 26

Quoted 9 lines
env/nowhere.c +1 -0
index f5b0a17652..70c3b3e011 100644
@@ -23,6 +23,7 @@ static int env_nowhere_init(void)
  {
  	gd->env_addr	= (ulong)&default_environment[0];
  	gd->env_valid	= ENV_INVALID;
+	(NULL, 0);

^^^^^^^^^^^^^^^^^^^^^^
You are inserting this line of "C code" only.

I think something got ate along the way. The patch is at
http://patchwork.ozlabs.org/patch/1226946/
and the full line is:
+ env_set_default(NULL, 0);

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/29720997/attachment.sig>
author
#6 lore raw

PATCH v4 1/10 env: nowhere: set default enviroment

Quoted 34 lines · Tom Rini
Quoted 17 lines · Wolfgang Denk

Dear Keerthy,

Quoted 14 lines · In message <[email protected]> you wrote:
Quoted 14 lines
Quoted 14 lines

Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set.

---

Changes in v4:

* Reworded commit log

   env/nowhere.c | 1 +
   1 file changed, 1 insertion(+)
Quoted 12 lines
Quoted 9 lines
Quoted 9 lines

env/nowhere.c static int env_nowhere_init(void) · line 26

Quoted 9 lines
env/nowhere.c +1 -0
index f5b0a17652..70c3b3e011 100644
@@ -23,6 +23,7 @@ static int env_nowhere_init(void)
   {
   	gd->env_addr	= (ulong)&default_environment[0];
   	gd->env_valid	= ENV_INVALID;
+	(NULL, 0);

^^^^^^^^^^^^^^^^^^^^^^
You are inserting this line of "C code" only.

I think something got ate along the way. The patch is at
http://patchwork.ozlabs.org/patch/1226946/
and the full line is:

env/nowhere.c static int env_nowhere_init(void) · line 26

Quoted 1 line
env/nowhere.c +1 -0
+	env_set_default(NULL, 0);

Thanks Tom.

Wolfgang,

env_set_default(NULL, 0); sets the required flag for us in the nowhere path as well.

That enabled set_env.

Thanks,
Keerthy

Quoted 2 lines
#7 lore raw

PATCH v4 1/10 env: nowhere: set default enviroment

Dear Keerthy,

Quoted 12 lines · In message <[email protected]> you wrote:
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines

env/nowhere.c static int env_nowhere_init(void) · line 26

Quoted 8 lines
env/nowhere.c +1 -0
@@ -23,6 +23,7 @@ static int env_nowhere_init(void)
   {
   	gd->env_addr	= (ulong)&default_environment[0];
   	gd->env_valid	= ENV_INVALID;
+	(NULL, 0);

^^^^^^^^^^^^^^^^^^^^^^
You are inserting this line of "C code" only.

Quoted 7 lines

env/nowhere.c static int env_nowhere_init(void) · line 26

Quoted 4 lines

I think something got ate along the way. The patch is at
http://patchwork.ozlabs.org/patch/1226946/
and the full line is:

env/nowhere.c +1 -0
+	env_set_default(NULL, 0);

env_set_default(NULL, 0); sets the required flag for us in the nowhere path as well.

I see. Sorry, I didn't read the original patch. As you see in the quote above, the "env_set_default" somehow got lost, and this was what triggered my comment.

Feel free to ignore it.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Love all, trust a few.                          - William Shakespeare
author
#8 lore raw

PATCH v4 2/10 lib: elf: Move the generic elf loading/validating functions to lib

In reply to Keerthy

Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd.

---

Changes in v4:

* /s/ELF/LIB_ELF config option name

 cmd/Kconfig   |   1 +
 cmd/elf.c     | 229 --------------------------------------------
 include/elf.h |   4 +
 lib/Kconfig   |   3 +
 lib/Makefile  |   1 +
 lib/elf.c     | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 265 insertions(+), 229 deletions(-)
 create mode 100644 lib/elf.c
cmd/Kconfig +1 -0
index 298feae24d..ac0a985596 100644
@@ -375,6 +375,7 @@ config CMD_ADTIMG
 config CMD_ELF
 	bool "bootelf, bootvx"
 	default y
+	select LIB_ELF
 	help
 	  Boot an ELF/vxWorks image from the memory.
 
cmd/elf.c +0 -229

241 lines not on this page · raw message

include/elf.h +4 -0
index 81f40191d7..e7c51986df 100644
@@ -692,6 +692,10 @@ unsigned long elf_hash(const unsigned char *name);
 
 #ifndef __ASSEMBLER__
 int valid_elf_image(unsigned long addr);
+unsigned long load_elf64_image_phdr(unsigned long addr);
+unsigned long load_elf64_image_shdr(unsigned long addr);
+unsigned long load_elf_image_phdr(unsigned long addr);
+unsigned long load_elf_image_shdr(unsigned long addr);
 #endif
 
 #endif /* _ELF_H */
lib/Kconfig +3 -0
index d040a87d26..5ca86cd7fb 100644
@@ -601,4 +601,7 @@ config TEST_FDTDEC
 config LIB_DATE
 	bool
 
+config LIB_ELF
+	bool "enable basic elf loading/validating functions"
+
 endmenu
lib/Makefile +1 -0
index 51eba80b89..11bc77e7ad 100644
@@ -122,6 +122,7 @@ obj-y += vsprintf.o strto.o
 endif
 
 obj-y += date.o
+obj-$(CONFIG_LIB_ELF) += elf.o
 
 #
 # Build a fast OID lookup registry from include/linux/oid_registry.h
lib/elf.c new file +256 -0

256 lines not on this page · raw message

Signature · 1 line
2.17.1
#9 lore raw

PATCH v4 2/10 lib: elf: Move the generic elf loading/validating functions to lib

Quoted 7 lines · Keerthy

Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd.

[snip]

lib/Kconfig config TEST_FDTDEC · line 607

Quoted 12 lines
lib/Kconfig +3 -0
index d040a87d26..5ca86cd7fb 100644
@@ -601,4 +601,7 @@ config TEST_FDTDEC
 config LIB_DATE
 	bool
 
+config LIB_ELF
+	bool "enable basic elf loading/validating functions"
+
 endmenu

This shouldn't be a user-selectable symbol, it should be select'd as needed. So no bool text but a help text that mentions what it does provide is needed. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200124/4cdc415d/attachment.sig>
author
#10 lore raw

PATCH v4 2/10 lib: elf: Move the generic elf loading/validating functions to lib

Quoted 17 lines · Tom Rini
Quoted 7 lines · Keerthy

Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd.

[snip]

Quoted 8 lines
lib/Kconfig +0 -0
index d040a87d26..5ca86cd7fb 100644
@@ -601,4 +601,7 @@ config TEST_FDTDEC
  config LIB_DATE
  	bool
 
Quoted 8 lines

lib/Kconfig config TEST_FDTDEC · line 607

Quoted 4 lines
lib/Kconfig +3 -0
+config LIB_ELF
+	bool "enable basic elf loading/validating functions"
+
  endmenu

This shouldn't be a user-selectable symbol, it should be select'd as needed. So no bool text but a help text that mentions what it does provide is needed. Thanks!

Okay. I will change that.

Quoted 1 line
author
#11 lore raw

PATCH v4 2/10 lib: elf: Move the generic elf loading/validating functions to lib

Quoted 12 lines · Keerthy
Quoted 9 lines · Tom Rini
Quoted 7 lines · Keerthy

Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd.

[snip]

Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
lib/Kconfig +0 -0
index d040a87d26..5ca86cd7fb 100644
@@ -601,4 +601,7 @@ config TEST_FDTDEC

  config LIB_DATE
      bool

Quoted 8 lines
Quoted 4 lines
lib/Kconfig +3 -0
+config LIB_ELF
+    bool "enable basic elf loading/validating functions"
+

  endmenu

This shouldn't be a user-selectable symbol, it should be select'd as needed.  So no bool text but a help text that mentions what it does provide is needed.  Thanks!

Tom,

Just for my confirmation. Do you want the symbol type to be removed or just the bool text? I believe symbol type is must.

- Keerthy

Quoted 4 lines

Okay. I will change that.

Quoted 1 line
#12 lore raw

PATCH v4 2/10 lib: elf: Move the generic elf loading/validating functions to lib

Quoted 31 lines · Keerthy
Quoted 12 lines · Keerthy
Quoted 9 lines · Tom Rini
Quoted 7 lines · Keerthy

Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd.

[snip]

Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
lib/Kconfig +0 -0
index d040a87d26..5ca86cd7fb 100644
@@ -601,4 +601,7 @@ config TEST_FDTDEC

  config LIB_DATE
      bool

Quoted 8 lines
Quoted 4 lines
lib/Kconfig +3 -0
+config LIB_ELF
+    bool "enable basic elf loading/validating functions"
+

  endmenu

This shouldn't be a user-selectable symbol, it should be select'd as needed.  So no bool text but a help text that mentions what it does provide is needed.  Thanks!

Quoted 4 lines

Tom,

Just for my confirmation. Do you want the symbol type to be removed or just the bool text? I believe symbol type is must.

I want it converted from a user visible symbol, which in Kconfig means:
config VARIABLE
TYPE "Some text the user sees"
help
Description
and made a non-visible symbol which means:
config VARIABLE
TYPE
help
Description

Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/7a07f086/attachment.sig>
author
#13 lore raw

PATCH v4 2/10 lib: elf: Move the generic elf loading/validating functions to lib

Quoted 37 lines · Tom Rini
Quoted 31 lines · Keerthy
Quoted 12 lines · Keerthy
Quoted 9 lines · Tom Rini
Quoted 7 lines · Keerthy

Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd.

[snip]

Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
lib/Kconfig +0 -0
index d040a87d26..5ca86cd7fb 100644
@@ -601,4 +601,7 @@ config TEST_FDTDEC
   config LIB_DATE
       bool
Quoted 8 lines

lib/Kconfig config TEST_FDTDEC · line 607

Quoted 4 lines
lib/Kconfig +3 -0
+config LIB_ELF
+    bool "enable basic elf loading/validating functions"
+
   endmenu

This shouldn't be a user-selectable symbol, it should be select'd as needed.  So no bool text but a help text that mentions what it does provide is needed.  Thanks!

Quoted 4 lines

Tom,

Just for my confirmation. Do you want the symbol type to be removed or just the bool text? I believe symbol type is must.

Quoted 10 lines

I want it converted from a user visible symbol, which in Kconfig means:
config VARIABLE
TYPE "Some text the user sees"
help
Description
and made a non-visible symbol which means:
config VARIABLE
TYPE
help
Description

Thanks. Clear now :-)

Quoted 3 lines

Thanks!

author
#14 lore raw

PATCH v4 3/10 arm: k3: Add support for loading non linux remote cores

In reply to Keerthy

Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore.

In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode.

[Guard start_non_linux_remote_cores under CONFIG_FS_LOADER]

---

Changes in v4:

* Env variable names changed.

 arch/arm/mach-k3/common.c     | 84 ++++++++++++++++++++++++++++++++---
 arch/arm/mach-k3/common.h     |  2 +
 arch/arm/mach-k3/j721e_init.c | 34 ++++++++++++++
 3 files changed, 115 insertions(+), 5 deletions(-)
arch/arm/mach-k3/common.c +79 -5
index 8d1529062d..f0ac0c39f1 100644
@@ -16,6 +16,10 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/hardware.h>
 #include <asm/io.h>
+#include <fs_loader.h>
+#include <fs.h>
+#include <env.h>
+#include <elf.h>
 
 struct ti_sci_handle *get_ti_sci_handle(void)
 {
@@ -57,6 +61,74 @@ int early_console_init(void)
 #endif
 
 #ifdef CONFIG_SYS_K3_SPL_ATF
+
+void init_env(void)
+{
+#ifdef CONFIG_SPL_ENV_SUPPORT
+	char *part;
+
+	env_init();
+	env_load();
+	switch (spl_boot_device()) {
+	case BOOT_DEVICE_MMC2:
+		part = env_get("bootpart");
+		env_set("storage_interface", "mmc");
+		env_set("fw_dev_part", part);
+		break;
+	case BOOT_DEVICE_SPI:
+		env_set("storage_interface", "ubi");
+		env_set("fw_ubi_mtdpart", "UBI");
+		env_set("fw_ubi_volume", "UBI0");
+		break;
+	default:
+		printf("%s from device %u not supported!\n",
+		       __func__, spl_boot_device());
+		return;
+	}
+#endif
+}
+
+#ifdef CONFIG_FS_LOADER
+int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
+{
+	struct udevice *fsdev;
+	char *name = NULL;
+	int size = 0;
+
+	*loadaddr = 0;
+#ifdef CONFIG_SPL_ENV_SUPPORT
+	switch (spl_boot_device()) {
+	case BOOT_DEVICE_MMC2:
+		name = env_get(name_fw);
+		*loadaddr = env_get_hex(name_loadaddr, *loadaddr);
+		break;
+	default:
+		printf("Loading rproc fw image from device %u not supported!\n",
+		       spl_boot_device());
+		return 0;
+	}
+#endif
+	if (!*loadaddr)
+		return 0;
+
+	if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, &fsdev)) {
+		size = request_firmware_into_buf(fsdev, name, (void *)*loadaddr,
+						 0, 0);
+	}
+
+	return size;
+}
+#else
+int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
+{
+	return 0;
+}
+#endif
+
+__weak void start_non_linux_remote_cores(void)
+{
+}
+
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
 	struct ti_sci_handle *ti_sci = get_ti_sci_handle();
@@ -65,15 +137,17 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 	/* Release all the exclusive devices held by SPL before starting ATF */
 	ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci);
 
+	ret = rproc_init();
+	if (ret)
+		panic("rproc failed to be initialized (%d)\n", ret);
+
+	init_env();
+	start_non_linux_remote_cores();
+
 	/*
 	 * It is assumed that remoteproc device 1 is the corresponding
 	 * Cortex-A core which runs ATF. Make sure DT reflects the same.
 	 */
-	ret = rproc_dev_init(1);
-	if (ret)
-		panic("%s: ATF failed to initialize on rproc (%d)\n", __func__,
-		      ret);
-
 	ret = rproc_load(1, spl_image->entry_point, 0x200);
 	if (ret)
 		panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret);
arch/arm/mach-k3/common.h +2 -0
index d8b34fe060..42fb8ee6e7 100644
@@ -24,3 +24,5 @@ void setup_k3_mpu_regions(void);
 int early_console_init(void);
 void disable_linefill_optimization(void);
 void remove_fwl_configs(struct fwl_data *fwl_data, size_t fwl_data_size);
+void start_non_linux_remote_cores(void);
+int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr);
arch/arm/mach-k3/j721e_init.c +34 -0
index f7f7398081..13f3791823 100644
@@ -18,6 +18,7 @@
 #include <dm.h>
 #include <dm/uclass-internal.h>
 #include <dm/pinctrl.h>
+#include <remoteproc.h>
 
 #ifdef CONFIG_SPL_BUILD
 #ifdef CONFIG_K3_LOAD_SYSFW
@@ -295,3 +296,36 @@ void release_resources_for_core_shutdown(void)
 	}
 }
 #endif
+
+#ifdef CONFIG_SYS_K3_SPL_ATF
+void start_non_linux_remote_cores(void)
+{
+	int size = 0, ret;
+	u32 loadaddr = 0;
+
+	size = load_firmware("name_mainr5f0_0fw", "addr_mainr5f0_0load",
+			     &loadaddr);
+	if (size <= 0)
+		goto err_load;
+
+	/* assuming remoteproc 2 is aliased for the needed remotecore */
+	ret = rproc_load(2, loadaddr, size);
+	if (ret) {
+		printf("Firmware failed to start on rproc (%d)\n", ret);
+		goto err_load;
+	}
+
+	ret = rproc_start(2);
+	if (ret) {
+		printf("Firmware init failed on rproc (%d)\n", ret);
+		goto err_load;
+	}
+
+	printf("Remoteproc 2 started successfully\n");
+
+	return;
+
+err_load:
+	rproc_reset(2);
+}
+#endif
Signature · 1 line
2.17.1
author
#15 lore raw

PATCH v4 4/10 armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM

In reply to Keerthy

Enable execute permission for mcu_r5fss0_core0 BTCM so that we can jump to a firmware directly from SPL.

---
 arch/arm/mach-k3/r5_mpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-k3/r5_mpu.c +3 -1
index ee076ed877..3d2ff6775a 100644
@@ -26,7 +26,9 @@ struct mpu_region_config k3_mpu_regions[16] = {
 	/* U-Boot's code area marking it as WB and Write allocate */
 	{CONFIG_SYS_SDRAM_BASE, REGION_2, XN_DIS, PRIV_RW_USR_RW,
 	 O_I_WB_RD_WR_ALLOC, REGION_2GB},
-	{0x0, 3, 0x0, 0x0, 0x0, 0x0},
+	/* mcu_r5fss0_core0 BTCM area marking it as WB and Write allocate. */
+	{0x41010000, 3, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC,
+	 REGION_8MB},
 	{0x0, 4, 0x0, 0x0, 0x0, 0x0},
 	{0x0, 5, 0x0, 0x0, 0x0, 0x0},
 	{0x0, 6, 0x0, 0x0, 0x0, 0x0},
Signature · 1 line
2.17.1
author
#16 lore raw

PATCH v4 5/10 armv7R: K3: Add support for jumping to firmware

In reply to Keerthy

MCU Domain rf50 is currently shutting down after loading the ATF. Load elf firmware and jump to firmware post loading ATF.

ROM doesn't enable ATCM memory, so make sure that firmware that is being loaded doesn't use ATCM memory or override SPL.

---

Changes in v4:

* Env variable names changed.

 arch/arm/mach-k3/common.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
arch/arm/mach-k3/common.c +16 -6
index f0ac0c39f1..675a9dc4f7 100644
@@ -131,8 +131,10 @@ __weak void start_non_linux_remote_cores(void)
 
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
+	typedef void __noreturn (*image_entry_noargs_t)(void);
 	struct ti_sci_handle *ti_sci = get_ti_sci_handle();
-	int ret;
+	u32 loadaddr = 0;
+	int ret, size;
 
 	/* Release all the exclusive devices held by SPL before starting ATF */
 	ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci);
@@ -143,6 +145,9 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 
 	init_env();
 	start_non_linux_remote_cores();
+	size = load_firmware("name_mcur5f0_0fw", "addr_mcur5f0_0load",
+			     &loadaddr);
+
 
 	/*
 	 * It is assumed that remoteproc device 1 is the corresponding
@@ -158,13 +163,18 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 	ret = rproc_start(1);
 	if (ret)
 		panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret);
+	if (!(size > 0 && valid_elf_image(loadaddr))) {
+		debug("Shutting down...\n");
+		release_resources_for_core_shutdown();
+
+		while (1)
+			asm volatile("wfe");
+	}
 
-	debug("Releasing resources...\n");
-	release_resources_for_core_shutdown();
+	image_entry_noargs_t image_entry =
+		(image_entry_noargs_t)load_elf_image_phdr(loadaddr);
 
-	debug("Finalizing core shutdown...\n");
-	while (1)
-		asm volatile("wfe");
+	image_entry();
 }
 #endif
 
Signature · 1 line
2.17.1
author
#17 lore raw

PATCH v4 6/10 arm: dts: k3-j721e-r5: Add fs_loader node

In reply to Keerthy

Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem.

---
 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +6 -0
index 28a355d49c..caeee8defe 100644
@@ -18,6 +18,12 @@
 	chosen {
 		stdout-path = "serial2:115200n8";
 		tick-timer = &timer1;
+		firmware-loader = &fs_loader0;
+	};
+
+	fs_loader0: fs_loader at 0 {
+		u-boot,dm-pre-reloc;
+		compatible = "u-boot,fs-loader";
 	};
 
 	a72_0: a72 at 0 {
Signature · 1 line
2.17.1
#18 lore raw

PATCH v4 6/10 arm: dts: k3-j721e-r5: Add fs_loader node

Quoted 16 lines · Keerthy

Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem.

---
 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +0 -0
index 28a355d49c..caeee8defe 100644
@@ -18,6 +18,12 @@
 	chosen {
 		stdout-path = "serial2:115200n8";

arch/arm/dts/k3-j721e-r5-common-proc-board.dts line 29

Quoted 10 lines
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +6 -0
 		tick-timer = &timer1;
+		firmware-loader = &fs_loader0;
+	};
+
+	fs_loader0: fs_loader at 0 {
+		u-boot,dm-pre-reloc;
+		compatible = "u-boot,fs-loader";
 	};
 
 	a72_0: a72 at 0 {

All u-boot, properties need to be in a -u-boot.dtsi file so it's very clear what things we are adding and what files can be replaced directly from Linux. Please fixup anything else in this area that wasn't already doing this and then add what you need here, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200124/1e526471/attachment.sig>
author
#19 lore raw

PATCH v4 6/10 arm: dts: k3-j721e-r5: Add fs_loader node

Quoted 26 lines · Tom Rini
Quoted 25 lines · Keerthy

Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem.

---
  arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++++++
  1 file changed, 6 insertions(+)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +6 -0
index 28a355d49c..caeee8defe 100644
@@ -18,6 +18,12 @@
  	chosen {
  		stdout-path = "serial2:115200n8";
  		tick-timer = &timer1;
+		firmware-loader = &fs_loader0;
+	};
+
+	fs_loader0: fs_loader at 0 {
+		u-boot,dm-pre-reloc;
+		compatible = "u-boot,fs-loader";
  	};
 
Quoted 6 lines

arch/arm/dts/k3-j721e-r5-common-proc-board.dts line 29

Quoted 1 line
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +0 -0
  	a72_0: a72 at 0 {

All u-boot, properties need to be in a -u-boot.dtsi file so it's very clear what things we are adding and what files can be replaced directly from Linux. Please fixup anything else in this area that wasn't already doing this and then add what you need here, thanks!

Tom,

I believe we are safe here as the k3-j721e-r5-common-proc-board.dts entire file is u-boot specific. k3-j721e-r5-common-proc-board.dts is not present in Linux DT.

Thanks,
Keerthy

Quoted 1 line
#20 lore raw

PATCH v4 6/10 arm: dts: k3-j721e-r5: Add fs_loader node

Quoted 35 lines · Keerthy
Quoted 23 lines · Tom Rini
Quoted 22 lines · Keerthy

Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem.

---
  arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++++++
  1 file changed, 6 insertions(+)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +5 -0
index 28a355d49c..caeee8defe 100644
@@ -18,6 +18,12 @@
  	chosen {
  		stdout-path = "serial2:115200n8";
  		tick-timer = &timer1;
+		firmware-loader = &fs_loader0;
+	};
+
+	fs_loader0: fs_loader at 0 {
+		u-boot,dm-pre-reloc;
Quoted 8 lines

arch/arm/dts/k3-j721e-r5-common-proc-board.dts line 29

Quoted 3 lines
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +1 -0
+		compatible = "u-boot,fs-loader";
  	};
  	a72_0: a72 at 0 {

All u-boot, properties need to be in a -u-boot.dtsi file so it's very clear what things we are adding and what files can be replaced directly from Linux. Please fixup anything else in this area that wasn't already doing this and then add what you need here, thanks!

Quoted 5 lines

Tom,

I believe we are safe here as the k3-j721e-r5-common-proc-board.dts entire file is u-boot specific. k3-j721e-r5-common-proc-board.dts is not present in Linux DT.

Perhaps something is out of sync as we have both k3-j721e-common-proc-board.dts and k3-j721e-common-proc-board-u-boot.dtsi which leads me to believe that the former just hasn't made its way upstream yet. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/2b59814b/attachment.sig>
author
#21 lore raw

PATCH v4 6/10 arm: dts: k3-j721e-r5: Add fs_loader node

Quoted 38 lines · Tom Rini
Quoted 37 lines · Keerthy
Quoted 23 lines · Tom Rini
Quoted 22 lines · Keerthy

Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem.

---
   arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++++++
   1 file changed, 6 insertions(+)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +5 -0
index 28a355d49c..caeee8defe 100644
@@ -18,6 +18,12 @@
   	chosen {
   		stdout-path = "serial2:115200n8";
   		tick-timer = &timer1;
+		firmware-loader = &fs_loader0;
+	};
+
+	fs_loader0: fs_loader at 0 {
+		u-boot,dm-pre-reloc;
Quoted 8 lines

arch/arm/dts/k3-j721e-r5-common-proc-board.dts line 29

Quoted 3 lines
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +1 -0
+		compatible = "u-boot,fs-loader";
   	};
   	a72_0: a72 at 0 {

All u-boot, properties need to be in a -u-boot.dtsi file so it's very clear what things we are adding and what files can be replaced directly from Linux. Please fixup anything else in this area that wasn't already doing this and then add what you need here, thanks!

Tom,

Quoted 8 lines
Quoted 3 lines

I believe we are safe here as the k3-j721e-r5-common-proc-board.dts entire file is u-boot specific. k3-j721e-r5-common-proc-board.dts is not present in Linux DT.

Perhaps something is out of sync as we have both k3-j721e-common-proc-board.dts and k3-j721e-common-proc-board-u-boot.dtsi which leads me to believe that the former just hasn't made its way upstream yet. Thanks!

Tom,

k3-j721e-common-proc-board.dts is for A72 which is linux & that has corresponding k3-j721e-common-proc-board-u-boot.dtsi.

Where as k3-j721e-r5-common-proc-board.dts is only for R5 SPL that is only for u-boot repo. Am i clear now.

Regards,
Keerthy

Quoted 1 line
#22 lore raw

PATCH v4 6/10 arm: dts: k3-j721e-r5: Add fs_loader node

Quoted 50 lines · Keerthy
Quoted 38 lines · Tom Rini
Quoted 37 lines · Keerthy
Quoted 23 lines · Tom Rini
Quoted 22 lines · Keerthy

Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem.

---
   arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++++++
   1 file changed, 6 insertions(+)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +5 -0
index 28a355d49c..caeee8defe 100644
@@ -18,6 +18,12 @@
   	chosen {
   		stdout-path = "serial2:115200n8";
   		tick-timer = &timer1;
+		firmware-loader = &fs_loader0;
+	};
+
+	fs_loader0: fs_loader at 0 {
+		u-boot,dm-pre-reloc;
Quoted 8 lines

arch/arm/dts/k3-j721e-r5-common-proc-board.dts line 29

Quoted 3 lines
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +1 -0
+		compatible = "u-boot,fs-loader";
   	};
   	a72_0: a72 at 0 {

All u-boot, properties need to be in a -u-boot.dtsi file so it's very clear what things we are adding and what files can be replaced directly from Linux. Please fixup anything else in this area that wasn't already doing this and then add what you need here, thanks!

Tom,

Quoted 8 lines
Quoted 3 lines

I believe we are safe here as the k3-j721e-r5-common-proc-board.dts entire file is u-boot specific. k3-j721e-r5-common-proc-board.dts is not present in Linux DT.

Perhaps something is out of sync as we have both k3-j721e-common-proc-board.dts and k3-j721e-common-proc-board-u-boot.dtsi which leads me to believe that the former just hasn't made its way upstream yet. Thanks!

Quoted 7 lines

Tom,

k3-j721e-common-proc-board.dts is for A72 which is linux & that has corresponding k3-j721e-common-proc-board-u-boot.dtsi.

Where as k3-j721e-r5-common-proc-board.dts is only for R5 SPL that is only for u-boot repo. Am i clear now.

Ah yes. But still, that makes it look like yes, that other file may live elsewhere. So it too should be -u-boot.dtsi.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/87d43d55/attachment.sig>
author
#23 lore raw

PATCH v4 7/10 arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL

In reply to Keerthy

Enable MAIN domain r5fss0 cluster and its core0 in R5 spl.

---
 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +14 -0
index caeee8defe..d9f33bf4a4 100644
@@ -13,6 +13,8 @@
 	aliases {
 		remoteproc0 = &sysctrler;
 		remoteproc1 = &a72_0;
+		remoteproc2 = &main_r5fss0_core0;
+		remoteproc3 = &main_r5fss0_core1;
 	};
 
 	chosen {
@@ -213,4 +215,16 @@
 	u-boot,dm-spl;
 };
 
+&main_r5fss0 {
+	u-boot,dm-spl;
+};
+
+&main_r5fss0_core0 {
+	u-boot,dm-spl;
+};
+
+&main_r5fss0_core1 {
+	u-boot,dm-spl;
+};
+
 #include "k3-j721e-common-proc-board-u-boot.dtsi"
Signature · 1 line
2.17.1
author
#24 lore raw

PATCH v4 8/10 include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0

In reply to Keerthy

Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 firmware loadaddr and name.

---

Changes in v4:

* Env variable names changed.

 include/configs/j721e_evm.h | 4 ++++
 1 file changed, 4 insertions(+)
include/configs/j721e_evm.h +4 -0
index eaed520e6b..da0ca2b74f 100644
@@ -84,6 +84,10 @@
 	"mmcdev=1\0"							\
 	"bootpart=1:2\0"						\
 	"bootdir=/boot\0"						\
+	"addr_mainr5f0_0load=88000000\0"					\
+	"name_mainr5f0_0fw=/lib/firmware/j7-main-r5f0_0-fw\0"		\
+	"addr_mcur5f0_0load=89000000\0"					\
+	"name_mcur5f0_0fw=/lib/firmware/j7-mcu-r5f0_0-fw\0"		\
 	"rd_spec=-\0"							\
 	"init_mmc=run args_all args_mmc\0"				\
 	"get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}\0" \
Signature · 1 line
2.17.1
author
#25 lore raw

PATCH v4 9/10 configs: j721e_evm_r5: Enable R5F remoteproc support

In reply to Keerthy

Enable R5F remoteproc support in R5 defconfig so that R5s can be started in SPL. While at it enable the SPL_FS_EXT4 config option to load the firmwares from file system.

---
 configs/j721e_evm_r5_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/j721e_evm_r5_defconfig +2 -0
index cb6c74d7bf..0925690e10 100644
@@ -25,6 +25,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_EARLY_BSS=y
 CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL_FS_EXT4=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_RESET=y
@@ -92,6 +93,7 @@ CONFIG_SPL_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_TPS65941=y
 CONFIG_K3_SYSTEM_CONTROLLER=y
 CONFIG_REMOTEPROC_TI_K3_ARM64=y
+CONFIG_REMOTEPROC_TI_K3_R5F=y
 CONFIG_DM_RESET=y
 CONFIG_RESET_TI_SCI=y
 CONFIG_DM_SERIAL=y
Signature · 1 line
2.17.1
author
#26 lore raw

PATCH v4 10/10 configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC

In reply to Keerthy

Remove saving ENV in eMMC in R5 as the power domains are not setup. Environment in eMMC cannot be read if we do not boot from eMMC.

---
 configs/j721e_evm_r5_defconfig | 4 ----
 1 file changed, 4 deletions(-)
configs/j721e_evm_r5_defconfig +0 -4
index 0925690e10..0f391ff98e 100644
@@ -7,7 +7,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x55000
 CONFIG_SOC_K3_J721E=y
 CONFIG_TARGET_J721E_R5_EVM=y
 CONFIG_ENV_SIZE=0x20000
-CONFIG_ENV_OFFSET=0x680000
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
@@ -48,9 +47,6 @@ CONFIG_CMD_FAT=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-common-proc-board"
-CONFIG_ENV_IS_IN_MMC=y
-CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
-CONFIG_ENV_OFFSET_REDUND=0x700000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_SPL_DM=y
Signature · 1 line
2.17.1