Skip to contentSkip to conversation

arm: socfpga: fix U-Boot running from fpga OnChip RAM

PATCH Superseded Simon Goldschmidt 2 participants 20 messages Aug 16, 2018 – Sep 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

gd->env_addr points to pre-relocation address even after relocation. This leads to an abort in env_callback_init when loading the environment.

Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC.

---

Changes in v5:
Improve comments

Changes in v4:
enable this fix for all socfpga, not for gen5 only

Changes in v3:
this patch is new in v3

Changes in v2:
None

 include/configs/socfpga_common.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/configs/socfpga_common.h +12 -0
index 8ebf6b85fe..8b9f0427c0 100644
@@ -284,6 +284,18 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_STACK		CONFIG_SYS_SPL_MALLOC_START
 #endif
 
+/*
+ * When U-Boot is started from FPGA, prevent gd->env_addr to point into
+ * FPGA OnChip RAM after relocation
+ */
+#define CONFIG_SYS_EXTRA_ENV_RELOC
+/*
+ * CONFIG_SYS_EXTRA_ENV_RELOC code needs this to calculate the relocation
+ * offset for gd->env_addr. Since this is based on gd->relocaddr, we need
+ * to use CONFIG_SYS_TEXT_BASE here.
+ */
+#define CONFIG_SYS_MONITOR_BASE	CONFIG_SYS_TEXT_BASE
+
 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 7 lines · Simon Goldschmidt

gd->env_addr points to pre-relocation address even after relocation. This leads to an abort in env_callback_init when loading the environment.

Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC.

I have one last question -- does this somehow influence SPL ?

Quoted 41 lines

---

Changes in v5:
Improve comments

Changes in v4:
enable this fix for all socfpga, not for gen5 only

Changes in v3:
this patch is new in v3

Changes in v2:
None

 include/configs/socfpga_common.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/configs/socfpga_common.h +12 -0
index 8ebf6b85fe..8b9f0427c0 100644
@@ -284,6 +284,18 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_STACK		CONFIG_SYS_SPL_MALLOC_START
 #endif
 
+/*
+ * When U-Boot is started from FPGA, prevent gd->env_addr to point into
+ * FPGA OnChip RAM after relocation
+ */
+#define CONFIG_SYS_EXTRA_ENV_RELOC
+/*
+ * CONFIG_SYS_EXTRA_ENV_RELOC code needs this to calculate the relocation
+ * offset for gd->env_addr. Since this is based on gd->relocaddr, we need
+ * to use CONFIG_SYS_TEXT_BASE here.
+ */
+#define CONFIG_SYS_MONITOR_BASE	CONFIG_SYS_TEXT_BASE
+
 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD
 
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 11 lines · Marek Vasut
Quoted 7 lines · Simon Goldschmidt

gd->env_addr points to pre-relocation address even after relocation. This leads to an abort in env_callback_init when loading the environment.

Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC.

I have one last question -- does this somehow influence SPL ?

No, it doesn't. The code that gets enabled by this define is in common/board_r.c, which is not linked for SPL.

Quoted 47 lines
Quoted 32 lines

---

Changes in v5:
Improve comments

Changes in v4:
enable this fix for all socfpga, not for gen5 only

Changes in v3:
this patch is new in v3

Changes in v2:
None

 include/configs/socfpga_common.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/configs/socfpga_common.h +5 -0
index 8ebf6b85fe..8b9f0427c0 100644
@@ -284,6 +284,18 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_STACK             CONFIG_SYS_SPL_MALLOC_START
 #endif
 
+/*
+ * When U-Boot is started from FPGA, prevent gd->env_addr to point into
+ * FPGA OnChip RAM after relocation
+ */
+#define CONFIG_SYS_EXTRA_ENV_RELOC

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 301

Quoted 10 lines
include/configs/socfpga_common.h +7 -0
+/*
+ * CONFIG_SYS_EXTRA_ENV_RELOC code needs this to calculate the relocation
+ * offset for gd->env_addr. Since this is based on gd->relocaddr, we need
+ * to use CONFIG_SYS_TEXT_BASE here.
+ */
+#define CONFIG_SYS_MONITOR_BASE      CONFIG_SYS_TEXT_BASE
+
 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD
 

--
Best regards,
Marek Vasut

#3 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 7 lines · Simon Goldschmidt
Quoted 6 lines · Marek Vasut
Quoted 4 lines · Simon Goldschmidt

gd->env_addr points to pre-relocation address even after relocation. This leads to an abort in env_callback_init when loading the environment.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC.

I have one last question -- does this somehow influence SPL ?

No, it doesn't. The code that gets enabled by this define is in common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Quoted 47 lines
Quoted 47 lines
Quoted 32 lines

---

Changes in v5:
Improve comments

Changes in v4:
enable this fix for all socfpga, not for gen5 only

Changes in v3:
this patch is new in v3

Changes in v2:
None

 include/configs/socfpga_common.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/configs/socfpga_common.h +5 -0
index 8ebf6b85fe..8b9f0427c0 100644
@@ -284,6 +284,18 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_STACK             CONFIG_SYS_SPL_MALLOC_START
 #endif
 
+/*
+ * When U-Boot is started from FPGA, prevent gd->env_addr to point into
+ * FPGA OnChip RAM after relocation
+ */
+#define CONFIG_SYS_EXTRA_ENV_RELOC

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 301

Quoted 10 lines
include/configs/socfpga_common.h +7 -0
+/*
+ * CONFIG_SYS_EXTRA_ENV_RELOC code needs this to calculate the relocation
+ * offset for gd->env_addr. Since this is based on gd->relocaddr, we need
+ * to use CONFIG_SYS_TEXT_BASE here.
+ */
+#define CONFIG_SYS_MONITOR_BASE      CONFIG_SYS_TEXT_BASE
+
 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD
 

--
Best regards,
Marek Vasut

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Marek Vasut <[email protected]> schrieb am Do., 16. Aug. 2018, 15:06:

Quoted 14 lines · Simon Goldschmidt
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt
Quoted 7 lines

gd->env_addr points to pre-relocation address even after relocation. This leads to an abort in env_callback_init when loading the environment.

Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC.

I have one last question -- does this somehow influence SPL ?

Quoted 8 lines
Quoted 2 lines

No, it doesn't. The code that gets enabled by this define is in common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Simon

Quoted 57 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

---

Changes in v5:
Improve comments

Changes in v4:
enable this fix for all socfpga, not for gen5 only

Changes in v3:
this patch is new in v3

Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines

Changes in v2:
None

 include/configs/socfpga_common.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/include/configs/socfpga_common.h

Quoted 9 lines
Quoted 9 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 288

Quoted 9 lines

index 8ebf6b85fe..8b9f0427c0 100644

include/configs/socfpga_common.h +2 -0
@@ -284,6 +284,18 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_STACK             CONFIG_SYS_SPL_MALLOC_START
 #endif
 
+/*
+ * When U-Boot is started from FPGA, prevent gd->env_addr to point

into

Quoted 5 lines
Quoted 5 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void);

Quoted 5 lines
include/configs/socfpga_common.h +5 -0
+ * FPGA OnChip RAM after relocation
+ */
+#define CONFIG_SYS_EXTRA_ENV_RELOC
+/*
+ * CONFIG_SYS_EXTRA_ENV_RELOC code needs this to calculate the

relocation

Quoted 1 line
Quoted 1 line

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 294

Quoted 1 line
include/configs/socfpga_common.h +1 -0
+ * offset for gd->env_addr. Since this is based on gd->relocaddr, we

need

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/configs/socfpga_common.h +4 -0
+ * to use CONFIG_SYS_TEXT_BASE here.
+ */
+#define CONFIG_SYS_MONITOR_BASE      CONFIG_SYS_TEXT_BASE
+
 /* Extra Environment */
Quoted 8 lines
Quoted 8 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 301

Quoted 3 lines
include/configs/socfpga_common.h +0 -0
 #ifndef CONFIG_SPL_BUILD
 

--
Best regards,
Marek Vasut

--
Best regards,
Marek Vasut

#5 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 31 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Quoted 5 lines

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Signature · 2 lines
Best regards,
Marek Vasut
#6 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 33 lines · Marek Vasut
Quoted 31 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Quoted 8 lines
Quoted 5 lines

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Simon

#7 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 40 lines · Simon Goldschmidt
Quoted 39 lines · Marek Vasut
Quoted 36 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Quoted 6 lines
Quoted 2 lines

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Signature · 2 lines
Best regards,
Marek Vasut
#8 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 42 lines · Marek Vasut
Quoted 40 lines · Simon Goldschmidt
Quoted 39 lines · Marek Vasut
Quoted 36 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Simon

#9 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 52 lines · Simon Goldschmidt
Quoted 42 lines · Marek Vasut
Quoted 40 lines · Simon Goldschmidt
Quoted 39 lines · Marek Vasut
Quoted 36 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Shouldn't most of those boards be easily fixable ?

Signature · 2 lines
Best regards,
Marek Vasut
#10 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 62 lines · Marek Vasut
Quoted 52 lines · Simon Goldschmidt
Quoted 42 lines · Marek Vasut
Quoted 40 lines · Simon Goldschmidt
Quoted 39 lines · Marek Vasut
Quoted 36 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Quoted 1 line

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

So to me that means we still have to make this overridable and could change the "default" state of such an option only. Meaning that the default is "relocate gd->env_addr" with an option to leave it. But is this really worth breaking existing boards?

Simon

#11 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 63 lines · Simon Goldschmidt
Quoted 62 lines · Marek Vasut
Quoted 59 lines · Simon Goldschmidt
Quoted 42 lines · Marek Vasut
Quoted 40 lines · Simon Goldschmidt
Quoted 39 lines · Marek Vasut
Quoted 36 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Quoted 7 lines
Quoted 1 line

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Quoted 4 lines

So to me that means we still have to make this overridable and could change the "default" state of such an option only. Meaning that the default is "relocate gd->env_addr" with an option to leave it. But is this really worth breaking existing boards?

I think you do want to relocate the env alongside U-Boot, always, no ?

Signature · 2 lines
Best regards,
Marek Vasut
#12 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 67 lines · Marek Vasut
Quoted 65 lines · Simon Goldschmidt
Quoted 63 lines · Marek Vasut
Quoted 52 lines · Simon Goldschmidt
Quoted 42 lines · Marek Vasut
Quoted 40 lines · Simon Goldschmidt
Quoted 39 lines · Marek Vasut
Quoted 36 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Shouldn't most of those boards be easily fixable ?

Quoted 7 lines
Quoted 5 lines

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Have a look at env_sf_init() in env/sf.c (called from env_init(), which in turn is called from board_init_f()). There gd->env_addr is initialized by a config setting. If this user-supplied address is outside of the binary, relocating it is wrong, isn't it?

Anyway, I'm off for 2 weeks now (holiday time here) with some email access at most, so I'll continue on this when I get back.

Simon

Quoted 11 lines
Quoted 5 lines

So to me that means we still have to make this overridable and could change the "default" state of such an option only. Meaning that the default is "relocate gd->env_addr" with an option to leave it. But is this really worth breaking existing boards?

I think you do want to relocate the env alongside U-Boot, always, no ?

--
Best regards,
Marek Vasut

#13 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 74 lines · Simon Goldschmidt
Quoted 73 lines · Marek Vasut
Quoted 70 lines · Simon Goldschmidt
Quoted 62 lines · Marek Vasut
Quoted 52 lines · Simon Goldschmidt
Quoted 42 lines · Marek Vasut
Quoted 40 lines · Simon Goldschmidt
Quoted 39 lines · Marek Vasut
Quoted 36 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Quoted 1 line

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

Quoted 6 lines
Quoted 1 line

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Have a look at env_sf_init() in env/sf.c (called from env_init(), which in turn is called from board_init_f()). There gd->env_addr is initialized by a config setting. If this user-supplied address is outside of the binary, relocating it is wrong, isn't it?

I think you want to relocate the env close to where U-Boot is relocated in all cases, no ?

Quoted 2 lines

Anyway, I'm off for 2 weeks now (holiday time here) with some email access at most, so I'll continue on this when I get back.

Have a nice vacation.

Quoted 13 lines

Simon

Quoted 11 lines
Quoted 5 lines

So to me that means we still have to make this overridable and could change the "default" state of such an option only. Meaning that the default is "relocate gd->env_addr" with an option to leave it. But is this really worth breaking existing boards?

I think you do want to relocate the env alongside U-Boot, always, no ?

--
Best regards,
Marek Vasut

Signature · 2 lines
Best regards,
Marek Vasut
#14 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

OK, so I got more than 2 weeks off of U-Boot, but here I'm back... ;-)

Quoted 63 lines · Marek Vasut
Quoted 62 lines · Simon Goldschmidt
Quoted 61 lines · Marek Vasut
Quoted 60 lines · Simon Goldschmidt
Quoted 46 lines · Marek Vasut
Quoted 45 lines · Simon Goldschmidt
Quoted 44 lines · Marek Vasut
Quoted 37 lines · Simon Goldschmidt
Quoted 36 lines · Marek Vasut
Quoted 35 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16. Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even after >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow influence SPL ? >
> No, it doesn't. The code that gets enabled by this define is in > common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by default on all systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this really works for all boards, but it would be worth a try to push after this release is out.

Quoted 5 lines
Quoted 2 lines

I think so too. I cannot think of a reason why this shouldn't be enabled in fact.

Exactly. Too me it seems like a leftover, especially given the use of CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 8 lines
Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Have a look at env_sf_init() in env/sf.c (called from env_init(), which in turn is called from board_init_f()). There gd->env_addr is initialized by a config setting. If this user-supplied address is outside of the binary, relocating it is wrong, isn't it?

I think you want to relocate the env close to where U-Boot is relocated in all cases, no ?

Hmm, yes, *I do*, but reading env/sf.c it seems like there *are* ways to have this initial environment located outside of the initial binary hence making relocation invalidate it. Now I'm in no position to see if this is an error or legal usage of the code as it was meant to be...

So I think we have two options:
a) apply CONFIG_SYS_EXTRA_ENV_RELOC for socfpga or
b) push a patch that always relocates the initial environment and see if someone cares...

Which of the two do you prefer?

Simon

#15 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 86 lines · Simon Goldschmidt

OK, so I got more than 2 weeks off of U-Boot, but here I'm back... ;-)

Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Goldschmidt
Quoted 72 lines · Marek Vasut
Quoted 71 lines · Simon Goldschmidt
Quoted 57 lines · Marek Vasut
Quoted 56 lines · Simon Goldschmidt
Quoted 55 lines · Marek Vasut
Quoted 46 lines · Simon Goldschmidt
Quoted 45 lines · Marek Vasut
Quoted 44 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16.
Aug. 2018, 15:06:

     On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
     > On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut <[email protected]
     <mailto:[email protected]>> wrote:
     >>
     >> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
     >>> gd->env_addr points to pre-relocation address even after
     >>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
     >>>
     >>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
     >>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
     >>
     >> I have one last question -- does this somehow influence SPL ?
     >
     > No, it doesn't. The code that gets enabled by this define is in
     > common/board_r.c, which is not linked for SPL.

     Ah, thanks for checking.

     btw do you think it'd make sense to just enable this by default on all
     systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the
embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this
really works for all boards, but it would be worth a try to push after
this release is out.

Quoted 7 lines
Quoted 3 lines

I think so too. I cannot think of a reason why this shouldn't be enabled
in fact.

Exactly. Too me it seems like a leftover, especially given the use of
CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 8 lines
Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC  does not seem to work.

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Have a look at env_sf_init() in env/sf.c (called from env_init(), which in turn is called from board_init_f()). There gd->env_addr is initialized by a config setting. If this user-supplied address is outside of the binary, relocating it is wrong, isn't it?

I think you want to relocate the env close to where U-Boot is relocated in all cases, no ?

Quoted 7 lines

Hmm, yes, *I do*, but reading env/sf.c it seems like there *are* ways to have this initial environment located outside of the initial binary hence making relocation invalidate it. Now I'm in no position to see if this is an error or legal usage of the code as it was meant to be...

So I think we have two options:
a) apply CONFIG_SYS_EXTRA_ENV_RELOC for socfpga or

But SoCFPGA can have env in SF too, so you cannot apply this too all SoCFPGA, unless I am wrong.

Quoted 2 lines

b) push a patch that always relocates the initial environment and see if someone cares...

Wouldn't it make sense to fix the sf and then enable env reloc for it too ?

Quoted 3 lines

Which of the two do you prefer?

Simon

Signature · 2 lines
Best regards,
Marek Vasut
#16 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 93 lines · Marek Vasut
Quoted 91 lines · Simon Goldschmidt

OK, so I got more than 2 weeks off of U-Boot, but here I'm back... ;-)

Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Goldschmidt
Quoted 72 lines · Marek Vasut
Quoted 71 lines · Simon Goldschmidt
Quoted 57 lines · Marek Vasut
Quoted 56 lines · Simon Goldschmidt
Quoted 55 lines · Marek Vasut
Quoted 46 lines · Simon Goldschmidt
Quoted 45 lines · Marek Vasut
Quoted 44 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Do., 16.
Aug. 2018, 15:06:

     On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
     > On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut
<[email protected]
     <mailto:[email protected]>> wrote:
     >>
     >> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
     >>> gd->env_addr points to pre-relocation address even

after
>>> relocation. This leads to an abort in env_callback_init >>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC. >>>
>>> Signed-off-by: Simon Goldschmidt <[email protected] <mailto:[email protected]>>
>>
>> I have one last question -- does this somehow
influence SPL ?
>
> No, it doesn't. The code that gets enabled by this
define is in
> common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by
default on all
systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the for the
embedded device tree relocation, we could then probably use gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just not sure this
really works for all boards, but it would be worth a try to push after
this release is out.

Quoted 7 lines
Quoted 3 lines

I think so too. I cannot think of a reason why this shouldn't be enabled
in fact.

Exactly. Too me it seems like a leftover, especially given the use of
CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 8 lines
Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Have a look at env_sf_init() in env/sf.c (called from env_init(), which in turn is called from board_init_f()). There gd->env_addr is initialized by a config setting. If this user-supplied address is outside of the binary, relocating it is wrong, isn't it?

I think you want to relocate the env close to where U-Boot is relocated in all cases, no ?

Hmm, yes, *I do*, but reading env/sf.c it seems like there *are* ways to have this initial environment located outside of the initial binary hence making relocation invalidate it. Now I'm in no position to see if this is an error or legal usage of the code as it was meant to be...

Quoted 5 lines
Quoted 2 lines

So I think we have two options:
a) apply CONFIG_SYS_EXTRA_ENV_RELOC for socfpga or

But SoCFPGA can have env in SF too, so you cannot apply this too all SoCFPGA, unless I am wrong.

It's again more confusing. This is only a problem if CONFIG_ENV_ADDR is defined, which isn't for socfpga.

Quoted 5 lines
Quoted 3 lines

b) push a patch that always relocates the initial environment and see if someone cares...

Wouldn't it make sense to fix the sf and then enable env reloc for it too ?

sf was only an example. AT least nand, flash and nvram env drivers also can put gd->env_addr at a different, configurable address. The only way to auto-relocate here would be to have a flag that tells us what to do. Or we could check if gd->env_addr is in the range of relocated code.

But the whole code in that area just pretty much confuses me...

Simon

#17 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 94 lines · Simon Goldschmidt
Quoted 93 lines · Marek Vasut
Quoted 91 lines · Simon Goldschmidt

OK, so I got more than 2 weeks off of U-Boot, but here I'm back... ;-)

Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Goldschmidt
Quoted 72 lines · Marek Vasut
Quoted 71 lines · Simon Goldschmidt
Quoted 57 lines · Marek Vasut
Quoted 56 lines · Simon Goldschmidt
Quoted 55 lines · Marek Vasut
Quoted 46 lines · Simon Goldschmidt
Quoted 45 lines · Marek Vasut
Quoted 44 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am
Do., 16.
Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut
<[email protected]
<mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even
after
>>> relocation. This leads to an abort in env_callback_init
>>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC.
>>>
>>> Signed-off-by: Simon Goldschmidt
<[email protected]
<mailto:[email protected]>>
>>
>> I have one last question -- does this somehow
influence SPL ?
>
> No, it doesn't. The code that gets enabled by this
define is in
> common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by
default on all
systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the
for the
embedded device tree relocation, we could then probably use
gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just
not sure this
really works for all boards, but it would be worth a try to
push after
this release is out.

Quoted 7 lines
Quoted 3 lines

I think so too. I cannot think of a reason why this shouldn't be enabled
in fact.

Exactly. Too me it seems like a leftover, especially given the use of
CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 8 lines
Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Have a look at env_sf_init() in env/sf.c (called from env_init(), which in turn is called from board_init_f()). There gd->env_addr is initialized by a config setting. If this user-supplied address is outside of the binary, relocating it is wrong, isn't it?

I think you want to relocate the env close to where U-Boot is relocated in all cases, no ?

Hmm, yes, *I do*, but reading env/sf.c it seems like there *are* ways to have this initial environment located outside of the initial binary hence making relocation invalidate it. Now I'm in no position to see if this is an error or legal usage of the code as it was meant to be...

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

So I think we have two options:
a) apply CONFIG_SYS_EXTRA_ENV_RELOC for socfpga or

But SoCFPGA can have env in SF too, so you cannot apply this too all SoCFPGA, unless I am wrong.

It's again more confusing. This is only a problem if CONFIG_ENV_ADDR is defined, which isn't for socfpga.

Could this be applicable to memory mapped CFI flashes only ? In that case, if CONFIG_ENV_ADDR is defined, undefine the ENV_RELOC and done ?

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

b) push a patch that always relocates the initial environment and see if someone cares...

Wouldn't it make sense to fix the sf and then enable env reloc for it too ?

Quoted 7 lines

sf was only an example. AT least nand, flash and nvram env drivers also can put gd->env_addr at a different, configurable address. The only way to auto-relocate here would be to have a flag that tells us what to do. Or we could check if gd->env_addr is in the range of relocated code.

But the whole code in that area just pretty much confuses me...

See above, isn't that about memory-mapped and non-memory-mapped env storage?

Signature · 2 lines
Best regards,
Marek Vasut
#18 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 104 lines · Marek Vasut
Quoted 90 lines · Simon Goldschmidt
Quoted 89 lines · Marek Vasut
Quoted 88 lines · Simon Goldschmidt

OK, so I got more than 2 weeks off of U-Boot, but here I'm back... ;-)

Quoted 73 lines · Marek Vasut
Quoted 72 lines · Simon Goldschmidt
Quoted 71 lines · Marek Vasut
Quoted 70 lines · Simon Goldschmidt
Quoted 56 lines · Marek Vasut
Quoted 55 lines · Simon Goldschmidt
Quoted 54 lines · Marek Vasut
Quoted 45 lines · Simon Goldschmidt
Quoted 44 lines · Marek Vasut

On 08/16/2018 03:12 PM, Simon Goldschmidt wrote:
Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am
Do., 16.
Aug. 2018, 15:06:

On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
> On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut
<[email protected]
<mailto:[email protected]>> wrote:
>>
>> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
>>> gd->env_addr points to pre-relocation address even
after
>>> relocation. This leads to an abort in env_callback_init
>>> when loading the environment.
>>>
>>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC.
>>>
>>> Signed-off-by: Simon Goldschmidt
<[email protected]
<mailto:[email protected]>>
>>
>> I have one last question -- does this somehow
influence SPL ?
>
> No, it doesn't. The code that gets enabled by this
define is in
> common/board_r.c, which is not linked for SPL.

Ah, thanks for checking.

btw do you think it'd make sense to just enable this by
default on all
systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the
for the
embedded device tree relocation, we could then probably use
gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just
not sure this
really works for all boards, but it would be worth a try to
push after
this release is out.

Quoted 7 lines
Quoted 3 lines

I think so too. I cannot think of a reason why this shouldn't
be enabled
in fact.

Exactly. Too me it seems like a leftover, especially given the use of
CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too. I've set up a reminder for a patch to remove it after the release.

Feel free to send it now.

Quoted 8 lines
Quoted 7 lines

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if this is outside of U-Boot's pre-relocation range, it clearly should not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not seem to work.

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Have a look at env_sf_init() in env/sf.c (called from env_init(), which in turn is called from board_init_f()). There gd->env_addr is initialized by a config setting. If this user-supplied address is outside of the binary, relocating it is wrong, isn't it?

I think you want to relocate the env close to where U-Boot is relocated in all cases, no ?

Hmm, yes, *I do*, but reading env/sf.c it seems like there *are* ways to have this initial environment located outside of the initial binary hence making relocation invalidate it. Now I'm in no position to see if this is an error or legal usage of the code as it was meant to be...

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

So I think we have two options:
a) apply CONFIG_SYS_EXTRA_ENV_RELOC for socfpga or

But SoCFPGA can have env in SF too, so you cannot apply this too all SoCFPGA, unless I am wrong.

It's again more confusing. This is only a problem if CONFIG_ENV_ADDR is defined, which isn't for socfpga.

Could this be applicable to memory mapped CFI flashes only ? In that case, if CONFIG_ENV_ADDR is defined, undefine the ENV_RELOC and done ?

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

b) push a patch that always relocates the initial environment and see if someone cares...

Wouldn't it make sense to fix the sf and then enable env reloc for it too ?

Quoted 9 lines
Quoted 7 lines

sf was only an example. AT least nand, flash and nvram env drivers also can put gd->env_addr at a different, configurable address. The only way to auto-relocate here would be to have a flag that tells us what to do. Or we could check if gd->env_addr is in the range of relocated code.

But the whole code in that area just pretty much confuses me...

See above, isn't that about memory-mapped and non-memory-mapped env storage?

Probably yes. So rather than making CONFIG_SYS_EXTRA_ENV_RELOC configurable, we could derive it (or a similar option) by depending on CONFIG_ENV_ADDR not being defined?

That might work. But I'm yet not sure if CONFIG_ENV_ADDR is the only option triggering memory-mapped env storage.

And in the end, maybe not all memory-mapped storages are affected. This only affects memory-mapped storage that is avaiable before relocation (so without drivers, probably).

If it's really worth trying to fix this in a generic way while risking to break other configs I cannot test, then I can prepare a patch.

Simon

#19 lore raw

PATCH v5 1/1 arm: socfpga: fix U-Boot running from fpga OnChip RAM

Quoted 138 lines · Simon Goldschmidt
Quoted 126 lines · Marek Vasut
Quoted 104 lines · Simon Goldschmidt
Quoted 103 lines · Marek Vasut
Quoted 102 lines · Simon Goldschmidt

OK, so I got more than 2 weeks off of U-Boot, but here I'm back... ;-)

Quoted 85 lines · Marek Vasut
Quoted 84 lines · Simon Goldschmidt
Quoted 83 lines · Marek Vasut
Quoted 73 lines · Simon Goldschmidt
Quoted 72 lines · Marek Vasut
Quoted 71 lines · Simon Goldschmidt
Quoted 53 lines · Marek Vasut
Quoted 52 lines · Simon Goldschmidt

On Thu, Aug 16, 2018 at 3:15 PM Marek Vasut <[email protected]>
wrote:
On 08/16/2018 03:12 PM, Simon Goldschmidt wrote:
Marek Vasut <marex at denx.de <mailto:[email protected]>>
schrieb am
Do., 16.
Aug. 2018, 15:06:

      On 08/16/2018 03:00 PM, Simon Goldschmidt wrote:
      > On Thu, Aug 16, 2018 at 1:18 PM Marek Vasut
<[email protected]
      <mailto:[email protected]>> wrote:
      >>
      >> On 08/16/2018 09:38 AM, Simon Goldschmidt wrote:
      >>> gd->env_addr points to pre-relocation address even
after
      >>> relocation. This leads to an abort in
env_callback_init
      >>> when loading the environment.
      >>>
      >>> Fix this by enabling CONFIG_SYS_EXTRA_ENV_RELOC.
      >>>
      >>> Signed-off-by: Simon Goldschmidt
      <[email protected]
      <mailto:[email protected]>>
      >>
      >> I have one last question -- does this somehow
influence SPL ?
      >
      > No, it doesn't. The code that gets enabled by this
define is in
      > common/board_r.c, which is not linked for SPL.

      Ah, thanks for checking.

      btw do you think it'd make sense to just enable
this by
default on all
      systems and zap the EXTRA_ENV_RELOC macro altogether ?

Yes, that's what I have thought about already. Just like the
for the
embedded device tree relocation, we could then probably use
gd->reloc_off instead of CONFIG_SYS_MONITOR_BASE. I'm just
not sure this
really works for all boards, but it would be worth a try to
push after
this release is out.
I think so too. I cannot think of a reason why this shouldn't
be enabled
in fact.

Quoted 6 lines
Quoted 5 lines

Exactly. Too me it seems like a leftover, especially given the
use of
CONFIG_SYS_MONITOR_BASE, which seems a little outdated, too.
I've set up a reminder for a patch to remove it after the
release.

Feel free to send it now.

OK, I have tried, but it seems it's not that easy: some boards override the initial gd->env_addr by setting CONFIG_ENV_ADDR. So if
this is outside of U-Boot's pre-relocation range, it clearly should
not be relocated. One might find an improved way to relocate gd->env_addr if it is internal (e.g. checking the range to be in pre-relocation?). But simply removing the EXTRA_ENV_RELOC does not
seem to work.

Quoted 7 lines
Quoted 1 line

Shouldn't most of those boards be easily fixable ?

Well, if we unconditionally alter gd->env_addr by gd->reloc_off, boards that have their initial gd->env_addr outside of the initial binary can be fixed only by changing their behaviour. I don't know how
widely used this feature is, but since it's a config option (CONFIG_ENV_ADDR), how would we know?

git grep ? But aren't you mixing CONFIG_ENV_ADDR and CONFIG_ENV_RELOC ?

Quoted 7 lines
Quoted 4 lines

Have a look at env_sf_init() in env/sf.c (called from env_init(), which in turn is called from board_init_f()). There gd->env_addr is initialized by a config setting. If this user-supplied address is outside of the binary, relocating it is wrong, isn't it?

I think you want to relocate the env close to where U-Boot is relocated
in all cases, no ?

Hmm, yes, *I do*, but reading env/sf.c it seems like there *are* ways to
have this initial environment located outside of the initial binary hence making relocation invalidate it. Now I'm in no position to see if
this is an error or legal usage of the code as it was meant to be...

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

So I think we have two options:
a) apply CONFIG_SYS_EXTRA_ENV_RELOC for socfpga or

But SoCFPGA can have env in SF too, so you cannot apply this too all SoCFPGA, unless I am wrong.

It's again more confusing. This is only a problem if CONFIG_ENV_ADDR is defined, which isn't for socfpga.

Could this be applicable to memory mapped CFI flashes only ? In that case, if CONFIG_ENV_ADDR is defined, undefine the ENV_RELOC and done ?

Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

b) push a patch that always relocates the initial environment and see if
someone cares...

Wouldn't it make sense to fix the sf and then enable env reloc for it too ?

sf was only an example. AT least nand, flash and nvram env drivers also can put gd->env_addr at a different, configurable address. The only way to auto-relocate here would be to have a flag that tells us what to do. Or we could check if gd->env_addr is in the range of relocated code.

Quoted 4 lines
Quoted 1 line

But the whole code in that area just pretty much confuses me...

See above, isn't that about memory-mapped and non-memory-mapped env storage?

Probably yes. So rather than making CONFIG_SYS_EXTRA_ENV_RELOC configurable, we could derive it (or a similar option) by depending on CONFIG_ENV_ADDR not being defined?

That might work. But I'm yet not sure if CONFIG_ENV_ADDR is the only option triggering memory-mapped env storage.

Quoted 6 lines

And in the end, maybe not all memory-mapped storages are affected. This only affects memory-mapped storage that is avaiable before relocation (so without drivers, probably).

If it's really worth trying to fix this in a generic way while risking to break other configs I cannot test, then I can prepare a patch.

Let's try it, I think it makes sense :)

Signature · 2 lines
Best regards,
Marek Vasut