arm: socfpga: Fix bootcounter located at the end of internal SRAM
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Commit 768f23dc8ae3 ("ARM: socfpga: Put stack at the end of SRAM") broke those socfpga boards that keep the bootcounter at the end of the internal SRAM as the bootcounter needs 8 bytes by default and thus the very first SPL call to board_init_f_alloc_reserve overwrites the bootcounter.
This patch allows to move the initial stack pointer down a bit by checking if CONFIG_SYS_BOOTCOUNT_ADDR is located in the internal SRAM area and then using this address as location for the start of the stack pointer.
No new macros / defines are added by this approach.
--- include/configs/socfpga_common.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/configs/socfpga_common.h +13 -0
@@ -31,8 +31,21 @@#define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000#define CONFIG_SYS_INIT_RAM_SIZE 0x40000/* 256KB */ #endif + +/* +* Some boards (e.g. socfpga_sr1500) use 8 bytes at the end of the internal +* SRAM as bootcounter storage. Make sure to not put the stack directly +* at this address to not overwrite the bootcounter by checking, if the +* bootcounter address is located in the internal SRAM. +*/ +#if ((CONFIG_SYS_BOOTCOUNT_ADDR >CONFIG_SYS_INIT_RAM_ADDR ) && \ + (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR + \ +CONFIG_SYS_INIT_RAM_SIZE ))) +#define CONFIG_SYS_INIT_SP_ADDR CONFIG_SYS_BOOTCOUNT_ADDR +#else #define CONFIG_SYS_INIT_SP_ADDR \ (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) +#endif #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
Signature · 1 line
2.19.1
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Stefan Roese <[email protected]> schrieb am Di., 30. Okt. 2018, 10:00:
Quoted 6 lines
Commit
768f23dc8ae3("ARM: socfpga: Put stack at the end of SRAM") broke those socfpga boards that keep the bootcounter at the end of the internal SRAM as the bootcounter needs 8 bytes by default and thus the very first SPL call toboard_init_f_alloc_reserveoverwrites the bootcounter.
Quoted 7 lines
This patch allows to move the initial stack pointer down a bit by checking if
CONFIG_SYS_BOOTCOUNT_ADDRis located in the internal SRAM area and then using this address as location for the start of the stack pointer.No new macros / defines are added by this approach.
Ok, so no new macros are defined, but this is limited to the boot counter. However, I need to store additional data that survives a reboot somewhere, so I think an explicit range reservation would be nicer.
I could still do what I want with your patch by allocating my data above the bootcounter, but this works in a more or less implicit/hidden way, not explicitly configured...
Simon
Quoted 39 lines
Signed-off-by Stefan Roese <[email protected]>Cc Marek Vasut <[email protected]>Cc Simon Goldschmidt <[email protected]>--- include/configs/socfpga_common.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)include/configs/socfpga_common.h +3
-0@@ -31,8 +31,21 @@#define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000#define CONFIG_SYS_INIT_RAM_SIZE 0x40000/* 256KB */ #endif + +/* +* Some boards (e.g. socfpga_sr1500) use 8 bytes at the end of the internal
+ * SRAM as bootcounter storage. Make sure to not put the stack directly
+ * at this address to not overwrite the bootcounter by checking, if the
+ * bootcounter address is located in the internal SRAM.
+ */include/configs/socfpga_common.h +6
-1+#if ((CONFIG_SYS_BOOTCOUNT_ADDR >CONFIG_SYS_INIT_RAM_ADDR ) && \ + (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR + \ +CONFIG_SYS_INIT_RAM_SIZE ))) +#define CONFIG_SYS_INIT_SP_ADDR CONFIG_SYS_BOOTCOUNT_ADDR +#else #define CONFIG_SYS_INIT_SP_ADDR \ (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) +#endif #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 --2.19.1
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Hi Simon,
Quoted 15 lines · Simon Goldschmidt
Stefan Roese <sr at denx.de <mailto:[email protected]>> schrieb am Di., 30. Okt. 2018, 10:00:
Commit
768f23dc8ae3("ARM: socfpga: Put stack at the end of SRAM") broke those socfpga boards that keep the bootcounter at the end of the internal SRAM as the bootcounter needs 8 bytes by default and thus the very first SPL call toboard_init_f_alloc_reserveoverwrites the bootcounter.This patch allows to move the initial stack pointer down a bit by checking if
CONFIG_SYS_BOOTCOUNT_ADDRis located in the internal SRAM area and then using this address as location for the start of the stack pointer.
Quoted 7 lines
No new macros / defines are added by this approach.
Ok, so no new macros are defined, but this is limited to the boot counter. However, I need to store additional data that survives a reboot somewhere, so I think an explicit range reservation would be nicer.
Ah, I was not aware that you have a different reasoning to allocate some memory in the internal SRAM.
Quoted 3 lines
I could still do what I want with your patch by allocating my data above the bootcounter, but this works in a more or less implicit/ hidden way, not explicitly configured...
Some implicit (hidden) means is definitely not good. You can go ahead with your approach. But please don't introduce new defines for things that are already configured - meaning 0x8 bytes reserved and 0xfffffff8 as bootcounter location are redundant. This is a bit messy and might get out of hand, once those defines are not in sync any more.
And you probably need to add new defines to Kconfig as well (e.g. SOCFPGA_INIT_RAM_END_RESERVE).
Thanks,
Stefan
Quoted 30 lines
Simon
Signed-off-by: Stefan Roese <sr at denx.de <mailto:[email protected]>> Cc: Marek Vasut <marex at denx.de <mailto:[email protected]>> Cc: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com <mailto:[email protected]>> --- include/configs/socfpga_common.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h index 2330143cf1..bd8f5c8c41 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -31,8 +31,21 @@ #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000 #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /* 256KB */ #endif + +/* + * Some boards (e.g. socfpga_sr1500) use 8 bytes at the end of the internal + * SRAM as bootcounter storage. Make sure to not put the stack directly + * at this address to not overwrite the bootcounter by checking, if the + * bootcounter address is located in the internal SRAM. + */ +#if ((CONFIG_SYS_BOOTCOUNT_ADDR > CONFIG_SYS_INIT_RAM_ADDR) && \ + (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR + \ + CONFIG_SYS_INIT_RAM_SIZE))) +#define CONFIG_SYS_INIT_SP_ADDR CONFIG_SYS_BOOTCOUNT_ADDR +#else
Quoted 9 lines
#define CONFIG_SYS_INIT_SP_ADDR \
(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)
+#endif
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
--
2.19.1Viele Grüße,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Quoted 36 lines · Stefan Roese
Hi Simon,
Quoted 18 lines · Simon Goldschmidt
Stefan Roese <sr at denx.de <mailto:[email protected]>> schrieb am Di., 30. Okt. 2018, 10:00:
Commit
768f23dc8ae3("ARM: socfpga: Put stack at the end of SRAM") broke
those socfpga boards that keep the bootcounter at the end of the internal SRAM as the bootcounter needs 8 bytes by default and thus the
very first SPL call toboard_init_f_alloc_reserveoverwrites the bootcounter.This patch allows to move the initial stack pointer down a bit by checking if
CONFIG_SYS_BOOTCOUNT_ADDRis located in the internal SRAM area and then using this address as location for the start of the stack pointer.Quoted 7 lines
No new macros / defines are added by this approach.
Ok, so no new macros are defined, but this is limited to the boot counter. However, I need to store additional data that survives a reboot somewhere, so I think an explicit range reservation would be nicer.
Ah, I was not aware that you have a different reasoning to allocate some memory in the internal SRAM.
Quoted 3 lines
I could still do what I want with your patch by allocating my data above the bootcounter, but this works in a more or less implicit/ hidden way, not explicitly configured...
Quoted 8 lines
Some implicit (hidden) means is definitely not good. You can go ahead with your approach. But please don't introduce new defines for things that are already configured - meaning
0x8bytes reserved and0xfffffff8as bootcounter location are redundant. This is a bit messy and might get out of hand, once those defines are not in sync any more.And you probably need to add new defines to
Kconfigas well (e.g.SOCFPGA_INIT_RAM_END_RESERVE).
Thanks for discussing this and finding a better solution. I'm looking forward to the new patch.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
In reply to Stefan RoeseStefan Roese <[email protected]> schrieb am Di., 30. Okt. 2018, 10:36:
Quoted 36 lines
Hi Simon,
Quoted 3 lines · Simon Goldschmidt
Stefan Roese <sr at denx.de <mailto:[email protected]>> schrieb am Di., 30. Okt.
2018, 10:00:
Quoted 2 lines
Commit
768f23dc8ae3("ARM: socfpga: Put stack at the end of SRAM")broke
Quoted 2 lines
those socfpga boards that keep the bootcounter at the end of the internal SRAM as the bootcounter needs 8 bytes by default and thus
the
Quoted 8 lines
very first SPL call to
board_init_f_alloc_reserveoverwrites the bootcounter.This patch allows to move the initial stack pointer down a bit by checking if
CONFIG_SYS_BOOTCOUNT_ADDRis located in the internal SRAM area and then using this address as location for the start of the stack pointer.Quoted 7 lines
No new macros / defines are added by this approach.
Ok, so no new macros are defined, but this is limited to the boot counter. However, I need to store additional data that survives a reboot somewhere, so I think an explicit range reservation would be nicer.
Ah, I was not aware that you have a different reasoning to allocate some memory in the internal SRAM.
Quoted 3 lines
I could still do what I want with your patch by allocating my data above the bootcounter, but this works in a more or less implicit/ hidden way, not explicitly configured...
Quoted 6 lines
Some implicit (hidden) means is definitely not good. You can go ahead with your approach. But please don't introduce new defines for things that are already configured - meaning
0x8bytes reserved and0xfffffff8as bootcounter location are redundant. This is a bit messy and might get out of hand, once those defines are not in sync any more.
Well, you configure the bootcounter location in defconfig as an address, so you cannot really use this for a calculation other than your approach.
Quoted 3 lines
And you probably need to add new defines to
Kconfigas well (e.g.SOCFPGA_INIT_RAM_END_RESERVE).
An even cleaner solution would be to be able to override CONFIG_SYS_INIT_RAM_SIZE, but since this is a globally used define, I don't think I can provide a patch for this soon.
Maybe we'll start with your patch to fix the bootcounter in the mainline boards and I'll provide a patch for my additional requirements once I find the time.
Simon
Quoted 57 lines
Thanks,
StefanQuoted 6 lines
Simon
Signed-off-by Stefan Roese <sr at denx.de <mailto:[email protected]>>Cc Marek Vasut <marex at denx.de <mailto:[email protected]>>Cc Simon Goldschmidt <[email protected] <mailto:simon.k.r.goldschmidt at gmail.com>>
Quoted 5 lines
--- include/configs/socfpga_common.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/configs/socfpga_common.h
b/include/configs/socfpga_common.hQuoted 10 lines
index 2330143cf1..bd8f5c8c41 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -31,8 +31,21 @@ #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000 #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /* 256KB */ #endif + +/* + * Some boards (e.g. socfpga_sr1500) use 8 bytes at the end of theinternal
Quoted 1 line
+ * SRAM as bootcounter storage. Make sure to not put the stack
directly
Quoted 1 line
+ * at this address to not overwrite the bootcounter by checking, if
the
Quoted 6 lines
+ * bootcounter address is located in the internal SRAM.
+ */
+#if ((CONFIG_SYS_BOOTCOUNT_ADDR>CONFIG_SYS_INIT_RAM_ADDR) && \
+ (CONFIG_SYS_BOOTCOUNT_ADDR< (CONFIG_SYS_INIT_RAM_ADDR+ \
+CONFIG_SYS_INIT_RAM_SIZE)))
+#defineCONFIG_SYS_INIT_SP_ADDR
CONFIG_SYS_BOOTCOUNT_ADDRQuoted 10 lines
+#else #define CONFIG_SYS_INIT_SP_ADDR \ (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) +#endif #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 -- 2.19.1Viele Grüße,
Stefan--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Simon Goldschmidt <[email protected]> schrieb am Di., 30. Okt. 2018, 11:34:
Quoted 56 lines
Stefan Roese <[email protected]> schrieb am Di., 30. Okt. 2018, 10:36:
Quoted 37 lines
Hi Simon,
Quoted 3 lines · Simon Goldschmidt
Stefan Roese <sr at denx.de <mailto:[email protected]>> schrieb am Di., 30. Okt.
2018, 10:00:
Quoted 2 lines
Commit
768f23dc8ae3("ARM: socfpga: Put stack at the end of SRAM")broke
Quoted 2 lines
those socfpga boards that keep the bootcounter at the end of the internal SRAM as the bootcounter needs 8 bytes by default and thus
the
Quoted 5 lines
very first SPL call to
board_init_f_alloc_reserveoverwrites the bootcounter.This patch allows to move the initial stack pointer down a bit by checking if
CONFIG_SYS_BOOTCOUNT_ADDRis located in the internalSRAM
Quoted 10 lines
area and then using this address as location for the start of the stack pointer.
No new macros / defines are added by this approach.
Ok, so no new macros are defined, but this is limited to the boot counter. However, I need to store additional data that survives a reboot somewhere, so I think an explicit range reservation would be nicer.
Ah, I was not aware that you have a different reasoning to allocate some memory in the internal SRAM.
Quoted 3 lines
I could still do what I want with your patch by allocating my data above the bootcounter, but this works in a more or less implicit/ hidden way, not explicitly configured...
Quoted 6 lines
Some implicit (hidden) means is definitely not good. You can go ahead with your approach. But please don't introduce new defines for things that are already configured - meaning
0x8bytes reserved and0xfffffff8as bootcounter location are redundant. This is a bit messy and might get out of hand, once those defines are not in sync any more.Well, you configure the bootcounter location in defconfig as an address, so you cannot really use this for a calculation other than your approach.
Quoted 3 lines
And you probably need to add new defines to
Kconfigas well (e.g.SOCFPGA_INIT_RAM_END_RESERVE).
Quoted 8 lines
An even cleaner solution would be to be able to override
CONFIG_SYS_INIT_RAM_SIZE, but since this is a globally used define, I don't think I can provide a patch for this soon.Maybe we'll start with your patch to fix the bootcounter in the mainline boards and I'll provide a patch for my additional requirements once I find the time.
Drop the maybe. I'll test your patch and drop mine, but see the comment below.
Quoted 47 lines
Simon
Quoted 43 lines
Thanks,
StefanQuoted 6 lines
Simon
Signed-off-by Stefan Roese <sr at denx.de <mailto:[email protected]>>Cc Marek Vasut <marex at denx.de <mailto:[email protected]>>Cc Simon Goldschmidt <[email protected] <mailto:simon.k.r.goldschmidt at gmail.com>>
Quoted 5 lines
--- include/configs/socfpga_common.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/configs/socfpga_common.h
b/include/configs/socfpga_common.hQuoted 10 lines
index 2330143cf1..bd8f5c8c41 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -31,8 +31,21 @@ #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000 #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /* 256KB */ #endif + +/* + * Some boards (e.g. socfpga_sr1500) use 8 bytes at the end of theinternal
Quoted 1 line
+ * SRAM as bootcounter storage. Make sure to not put the stack
directly
Quoted 1 line
+ * at this address to not overwrite the bootcounter by checking,
if the
Quoted 6 lines
+ * bootcounter address is located in the internal SRAM.
+ */
+#if ((CONFIG_SYS_BOOTCOUNT_ADDR>CONFIG_SYS_INIT_RAM_ADDR) && \
+ (CONFIG_SYS_BOOTCOUNT_ADDR< (CONFIG_SYS_INIT_RAM_ADDR+ \
+CONFIG_SYS_INIT_RAM_SIZE)))
+#defineCONFIG_SYS_INIT_SP_ADDR
CONFIG_SYS_BOOTCOUNT_ADDRQuoted 4 lines
+#else #define CONFIG_SYS_INIT_SP_ADDR \ (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) +#endif
Can we have this check on CONFIG_INIT_RAM_SIZE instead of the initial stack pointer?
That would ensure the SPL size checks stay intact.
Simon
Quoted 16 lines
Quoted 15 lines
Quoted 6 lines
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 -- 2.19.1Viele Grüße,
Stefan--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
On 30.10.18 12:17, Simon Goldschmidt wrote:
<snip>
Quoted 25 lines
> diff --git
a/include/configs/socfpga_common.hb/include/configs/socfpga_common.h> index2330143cf1..bd8f5c8c41100644
> ---a/include/configs/socfpga_common.h
> +++b/include/configs/socfpga_common.h
> @@ -31,8 +31,21 @@
> #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000
> #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /* 256KB */
> #endif
> +
> +/*
> + * Some boards (e.g.socfpga_sr1500) use 8 bytes at the end of the internal > + * SRAM as bootcounter storage. Make sure to not put the stack directly > + * at this address to not overwrite the bootcounter by checking, if the > + * bootcounter address is located in the internal SRAM.
> + */
> +#if ((CONFIG_SYS_BOOTCOUNT_ADDR>CONFIG_SYS_INIT_RAM_ADDR) && \
> + (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR+ \
> +CONFIG_SYS_INIT_RAM_SIZE)))
> +#define CONFIG_SYS_INIT_SP_ADDRCONFIG_SYS_BOOTCOUNT_ADDR> +#else
> #define CONFIG_SYS_INIT_SP_ADDR \
> (CONFIG_SYS_INIT_RAM_ADDR+CONFIG_SYS_INIT_RAM_SIZE)
> +#endif
Quoted 4 lines
Can we have this check on
CONFIG_INIT_RAM_SIZEinstead of the initial stack pointer?That would ensure the SPL size checks stay intact.
I'm not really sure what you mean with this. Could you please explain in more detail?
Thanks,
Stefan
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Quoted 30 lines · Stefan Roese
On 30.10.18 12:17, Simon Goldschmidt wrote:
<snip>
Quoted 25 lines
> diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h > index 2330143cf1..bd8f5c8c41 100644 > --- a/include/configs/socfpga_common.h > +++ b/include/configs/socfpga_common.h > @@ -31,8 +31,21 @@ > #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000 > #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /* 256KB */ > #endif > + > +/* > + * Some boards (e.g. socfpga_sr1500) use 8 bytes at the end of the internal > + * SRAM as bootcounter storage. Make sure to not put the stack directly > + * at this address to not overwrite the bootcounter by checking, if the > + * bootcounter address is located in the internal SRAM. > + */ > +#if ((CONFIG_SYS_BOOTCOUNT_ADDR > CONFIG_SYS_INIT_RAM_ADDR) && \ > + (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR + \ > + CONFIG_SYS_INIT_RAM_SIZE))) > +#define CONFIG_SYS_INIT_SP_ADDR CONFIG_SYS_BOOTCOUNT_ADDR > +#else> #define
CONFIG_SYS_INIT_SP_ADDR\
> (CONFIG_SYS_INIT_RAM_ADDR+CONFIG_SYS_INIT_RAM_SIZE)
> +#endif
Quoted 7 lines
Quoted 4 lines
Can we have this check on
CONFIG_INIT_RAM_SIZEinstead of the initial stack pointer?That would ensure the SPL size checks stay intact.
I'm not really sure what you mean with this. Could you please explain in more detail?
Sorry for being unclear. What I meant was: currently CONFIG_SYS_INIT_RAM_SIZEis 0x10000 (the full 64 kByte). So if CONFIG_SYS_BOOTCOUNT_ADDR is 0xfffffff8, I think we should define CONFIG_SYS_INIT_RAM_SIZE to 0xfff8. That way, not only the CONFIG_SYS_INIT_SP_ADDR define is correct but CONFIG_SPL_MAX_SIZE is checked to not overlap this address, too.
Would that make sense to you?
Simon
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Quoted 39 lines · Simon Goldschmidt
Quoted 30 lines · Stefan Roese
On 30.10.18 12:17, Simon Goldschmidt wrote:
<snip>
Quoted 25 lines
> diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h > index 2330143cf1..bd8f5c8c41 100644 > --- a/include/configs/socfpga_common.h > +++ b/include/configs/socfpga_common.h > @@ -31,8 +31,21 @@ > #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000 > #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /* 256KB */ > #endif > + > +/* > + * Some boards (e.g. socfpga_sr1500) use 8 bytes at the end of the internal > + * SRAM as bootcounter storage. Make sure to not put the stack directly > + * at this address to not overwrite the bootcounter by checking, if the > + * bootcounter address is located in the internal SRAM. > + */ > +#if ((CONFIG_SYS_BOOTCOUNT_ADDR > CONFIG_SYS_INIT_RAM_ADDR) && \ > + (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR + \ > + CONFIG_SYS_INIT_RAM_SIZE))) > +#define CONFIG_SYS_INIT_SP_ADDR CONFIG_SYS_BOOTCOUNT_ADDR > +#else> #define
CONFIG_SYS_INIT_SP_ADDR\
> (CONFIG_SYS_INIT_RAM_ADDR+CONFIG_SYS_INIT_RAM_SIZE)
> +#endifQuoted 7 lines
Quoted 4 lines
Can we have this check on
CONFIG_INIT_RAM_SIZEinstead of the initial stack pointer?That would ensure the SPL size checks stay intact.
I'm not really sure what you mean with this. Could you please explain in more detail?
Quoted 8 lines
Sorry for being unclear. What I meant was: currently
CONFIG_SYS_INIT_RAM_SIZEis0x10000(the full 64 kByte). So ifCONFIG_SYS_BOOTCOUNT_ADDRis0xfffffff8, I think we should defineCONFIG_SYS_INIT_RAM_SIZEto0xfff8. That way, not only theCONFIG_SYS_INIT_SP_ADDRdefine is correct butCONFIG_SPL_MAX_SIZEis checked to not overlap this address, too.Would that make sense to you?
Yes, I thought that you meant it this way. I'm not sure if we should go this way. As we would change CONFIG_SYS_INIT_RAM_SIZE to something that does not represent the physical size of the on-chip SRAM. This could be very confusing and misleading, if this define is used elsewhere.
Thanks,
Stefan
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Stefan Roese <[email protected]> schrieb am Di., 30. Okt. 2018, 13:50:
Quoted 59 lines · Simon Goldschmidt
Quoted 7 lines · Stefan Roese
Quoted 6 lines · Simon Goldschmidt
<snip>
Quoted 1 line
> diff --git a/include/configs/socfpga_common.h
b/include/configs/socfpga_common.hQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
> index 2330143cf1..bd8f5c8c41 100644 > --- a/include/configs/socfpga_common.h > +++ b/include/configs/socfpga_common.h > @@ -31,8 +31,21 @@ > #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000 > #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /*256KB */
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
> #endif > + > +/* > + * Some boards (e.g. socfpga_sr1500) use 8 bytes atthe end of the internal
Quoted 1 line
Quoted 1 line
Quoted 1 line
> + * SRAM as bootcounter storage. Make sure to not put
the stack directly
Quoted 1 line
Quoted 1 line
Quoted 1 line
> + * at this address to not overwrite the bootcounter
by checking, if the
Quoted 1 line
Quoted 1 line
Quoted 1 line
> + * bootcounter address is located in the internal
SRAM.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
> + */
> +#if ((CONFIG_SYS_BOOTCOUNT_ADDR>
CONFIG_SYS_INIT_RAM_ADDR) && \Quoted 1 line
Quoted 1 line
Quoted 1 line
> + (
CONFIG_SYS_BOOTCOUNT_ADDR<(
CONFIG_SYS_INIT_RAM_ADDR+ \Quoted 1 line
Quoted 1 line
Quoted 1 line
> +
CONFIG_SYS_INIT_RAM_SIZE)))Quoted 1 line
Quoted 1 line
Quoted 1 line
> +#define
CONFIG_SYS_INIT_SP_ADDR
CONFIG_SYS_BOOTCOUNT_ADDRQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
> +#else
> #defineCONFIG_SYS_INIT_SP_ADDR\
Quoted 1 line
Quoted 1 line
Quoted 1 line
> (
CONFIG_SYS_INIT_RAM_ADDR+
CONFIG_SYS_INIT_RAM_SIZE)Quoted 18 lines
Quoted 10 lines
Quoted 7 lines
> +#endif
Can we have this check on
CONFIG_INIT_RAM_SIZEinstead of the initial stack pointer?That would ensure the SPL size checks stay intact.
I'm not really sure what you mean with this. Could you please explain in more detail?
Sorry for being unclear. What I meant was: currently
CONFIG_SYS_INIT_RAM_SIZEis0x10000(the full 64 kByte). So ifCONFIG_SYS_BOOTCOUNT_ADDRis0xfffffff8, I think we should defineCONFIG_SYS_INIT_RAM_SIZEto0xfff8. That way, not only theCONFIG_SYS_INIT_SP_ADDRdefine is correct butCONFIG_SPL_MAX_SIZEis checked to not overlap this address, too.
Quoted 8 lines
Quoted 1 line
Would that make sense to you?
Yes, I thought that you meant it this way. I'm not sure if we should go this way. As we would change
CONFIG_SYS_INIT_RAM_SIZEto something that does not represent the physical size of the on-chip SRAM. This could be very confusing and misleading, if this define is used elsewhere.
Hmm, okay. I dont want to push you there. I just thought it would be good to have the SPL binary size check correct...
Simon
Quoted 1 line
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Quoted 60 lines · Simon Goldschmidt
Stefan Roese <sr at denx.de <mailto:[email protected]>> schrieb am Di., 30. Okt. 2018, 13:50:
On 30.10.18 13:37, Simon Goldschmidt wrote:
> On Tue, Oct 30, 2018 at 12:28 PM Stefan Roese <sr at denx.de <mailto:[email protected]>> wrote:
>>
>> On 30.10.18 12:17, Simon Goldschmidt wrote:
>>
>> <snip>
>>
>>> > diff --gita/include/configs/socfpga_common.hb/include/configs/socfpga_common.h>>> > index2330143cf1..bd8f5c8c41100644
>>> > ---a/include/configs/socfpga_common.h
>>> > +++b/include/configs/socfpga_common.h
>>> > @@ -31,8 +31,21 @@
>>> > #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000
>>> > #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /* 256KB */ >>> > #endif
>>> > +
>>> > +/*
>>> > + * Some boards (e.g.socfpga_sr1500) use 8 bytes at the end of the internal >>> > + * SRAM as bootcounter storage. Make sure to not put the stack directly >>> > + * at this address to not overwrite the bootcounter by checking, if the >>> > + * bootcounter address is located in the internal SRAM.
>>> > + */
>>> > +#if ((CONFIG_SYS_BOOTCOUNT_ADDR>CONFIG_SYS_INIT_RAM_ADDR) && \
>>> > + (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR+ \
>>> > +CONFIG_SYS_INIT_RAM_SIZE))) >>> > +#define CONFIG_SYS_INIT_SP_ADDRCONFIG_SYS_BOOTCOUNT_ADDR>>> > +#else
>>> > #define CONFIG_SYS_INIT_SP_ADDR \
>>> > (CONFIG_SYS_INIT_RAM_ADDR+CONFIG_SYS_INIT_RAM_SIZE) >>> > +#endif
>>>
>>>
>>> Can we have this check onCONFIG_INIT_RAM_SIZEinstead of the
>>> initial stack pointer?
>>>
>>> That would ensure the SPL size checks stay intact.
>>
>> I'm not really sure what you mean with this. Could you please
>> explain in more detail?
>
> Sorry for being unclear. What I meant was: currently
>CONFIG_SYS_INIT_RAM_SIZEis0x10000(the full 64 kByte).
> So ifCONFIG_SYS_BOOTCOUNT_ADDRis0xfffffff8, I think we should
> defineCONFIG_SYS_INIT_RAM_SIZEto0xfff8. That way, not only the
>CONFIG_SYS_INIT_SP_ADDRdefine is correct butCONFIG_SPL_MAX_SIZEis
> checked to not overlap this address, too.
>
> Would that make sense to you?Yes, I thought that you meant it this way. I'm not sure if we should go this way. As we would change
CONFIG_SYS_INIT_RAM_SIZEto something that does not represent the physical size of the on-chip SRAM. This could be very confusing and misleading, if this define is used elsewhere.
Quoted 2 lines
Hmm, okay. I dont want to push you there. I just thought it would be good to have the SPL binary size check correct...
Of course would this be good. But perhaps we can make this SPL binary size check "better" by not changing the INIT_RAM_SIZE define. Its definitely possible - I just don't know how hard (I didn't look into this).
Thanks,
Stefan
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Quoted 77 lines · Stefan Roese
Quoted 76 lines · Simon Goldschmidt
Stefan Roese <sr at denx.de <mailto:[email protected]>> schrieb am Di., 30. Okt. 2018, 13:50:
On 30.10.18 13:37, Simon Goldschmidt wrote:
> On Tue, Oct 30, 2018 at 12:28 PM Stefan Roese <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 30.10.18 12:17, Simon Goldschmidt wrote:
>>
>> <snip>
>>
>>> > diff --gita/include/configs/socfpga_common.hb/include/configs/socfpga_common.h
>>> > index2330143cf1..bd8f5c8c41100644 >>> > ---a/include/configs/socfpga_common.h>>> > +++b/include/configs/socfpga_common.h>>> > @@ -31,8 +31,21 @@
>>> > #defineCONFIG_SYS_INIT_RAM_ADDR0xFFE00000
>>> > #defineCONFIG_SYS_INIT_RAM_SIZE0x40000/* 256KB */
>>> > #endif
>>> > +
>>> > +/*
>>> > + * Some boards (e.g.socfpga_sr1500) use 8 bytes at the end of the internal
>>> > + * SRAM as bootcounter storage. Make sure to not put the stack directly
>>> > + * at this address to not overwrite the bootcounter by checking, if the
>>> > + * bootcounter address is located in the internal SRAM.
>>> > + */
>>> > +#if ((CONFIG_SYS_BOOTCOUNT_ADDR>CONFIG_SYS_INIT_RAM_ADDR) && \
>>> > + (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR+ \
>>> > +CONFIG_SYS_INIT_RAM_SIZE)))
>>> > +#defineCONFIG_SYS_INIT_SP_ADDRCONFIG_SYS_BOOTCOUNT_ADDR
>>> > +#else
>>> > #defineCONFIG_SYS_INIT_SP_ADDR
\
>>> > (CONFIG_SYS_INIT_RAM_ADDR+CONFIG_SYS_INIT_RAM_SIZE)
>>> > +#endif
>>>
>>>
>>> Can we have this check onCONFIG_INIT_RAM_SIZEinstead of the >>> initial stack pointer?
>>>
>>> That would ensure the SPL size checks stay intact. >>
>> I'm not really sure what you mean with this. Could you please >> explain in more detail?
>
> Sorry for being unclear. What I meant was: currently >CONFIG_SYS_INIT_RAM_SIZEis0x10000(the full 64 kByte). > So ifCONFIG_SYS_BOOTCOUNT_ADDRis0xfffffff8, I think we should > defineCONFIG_SYS_INIT_RAM_SIZEto0xfff8. That way, not only the >CONFIG_SYS_INIT_SP_ADDRdefine is correct butCONFIG_SPL_MAX_SIZEis
> checked to not overlap this address, too.
>
> Would that make sense to you?Yes, I thought that you meant it this way. I'm not sure if we should go this way. As we would change
CONFIG_SYS_INIT_RAM_SIZEto something that does not represent the physical size of the on-chip SRAM. This could be very confusing and misleading, if this define is used elsewhere.
Quoted 7 lines
Quoted 2 lines
Hmm, okay. I dont want to push you there. I just thought it would be good to have the SPL binary size check correct...
Of course would this be good. But perhaps we can make this SPL binary size check "better" by not changing the
INIT_RAM_SIZEdefine. Its definitely possible - I just don't know how hard (I didn't look into this).
INIT_RAM_SIZE should reflect reality IMO
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Marek Vasut <[email protected]> schrieb am Di., 30. Okt. 2018, 14:24:
Quoted 81 lines · Stefan Roese
Quoted 80 lines · Simon Goldschmidt
Quoted 78 lines
Stefan Roese <sr at denx.de <mailto:[email protected]>> schrieb am Di., 30. Okt. 2018, 13:50:
On 30.10.18 13:37, Simon Goldschmidt wrote: > On Tue, Oct 30, 2018 at 12:28 PM Stefan Roese <[email protected] <mailto:[email protected]>> wrote: >> >> On 30.10.18 12:17, Simon Goldschmidt wrote: >> >> <snip> >> >>> > diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h >>> > index 2330143cf1..bd8f5c8c41 100644 >>> > --- a/include/configs/socfpga_common.h >>> > +++ b/include/configs/socfpga_common.h >>> > @@ -31,8 +31,21 @@ >>> > #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000 >>> > #define CONFIG_SYS_INIT_RAM_SIZE 0x40000 /* 256KB */ >>> > #endif >>> > + >>> > +/* >>> > + * Some boards (e.g. socfpga_sr1500) use 8bytes at the end of the internal
>>> > + * SRAM as bootcounter storage. Make sure to
not put the stack directly
>>> > + * at this address to not overwrite the
bootcounter by checking, if the
>>> > + * bootcounter address is located in the
internal SRAM.>>> > + */ >>> > +#if ((CONFIG_SYS_BOOTCOUNT_ADDR >
CONFIG_SYS_INIT_RAM_ADDR) && \
>>> > + (CONFIG_SYS_BOOTCOUNT_ADDR<
(CONFIG_SYS_INIT_RAM_ADDR+ \
>>> > +CONFIG_SYS_INIT_RAM_SIZE)))
>>> > +#defineCONFIG_SYS_INIT_SP_ADDR
CONFIG_SYS_BOOTCOUNT_ADDR
>>> > +#else
>>> > #defineCONFIG_SYS_INIT_SP_ADDR
\
>>> > (CONFIG_SYS_INIT_RAM_ADDR+CONFIG_SYS_INIT_RAM_SIZE)
>>> > +#endif
>>>
>>>
>>> Can we have this check onCONFIG_INIT_RAM_SIZEinstead of the >>> initial stack pointer?
>>>
>>> That would ensure the SPL size checks stay intact. >>
>> I'm not really sure what you mean with this. Could you please >> explain in more detail?
>
> Sorry for being unclear. What I meant was: currently >CONFIG_SYS_INIT_RAM_SIZEis0x10000(the full 64 kByte). > So ifCONFIG_SYS_BOOTCOUNT_ADDRis0xfffffff8, I think we should > defineCONFIG_SYS_INIT_RAM_SIZEto0xfff8. That way, not only the >CONFIG_SYS_INIT_SP_ADDRdefine is correct butCONFIG_SPL_MAX_SIZEis
> checked to not overlap this address, too.
>
> Would that make sense to you?Yes, I thought that you meant it this way. I'm not sure if we should go this way. As we would change
CONFIG_SYS_INIT_RAM_SIZEto something that does not represent the physical size of the on-chip SRAM. This could be very confusing and misleading, if this define is used elsewhere.Hmm, okay. I dont want to push you there. I just thought it would be good to have the SPL binary size check correct...
Quoted 7 lines
Quoted 4 lines
Of course would this be good. But perhaps we can make this SPL binary size check "better" by not changing the
INIT_RAM_SIZEdefine. Its definitely possible - I just don't know how hard (I didn't look into this).
INIT_RAM_SIZEshould reflect reality IMO
Right. I'll check how the SPL size check works with different offsets then.
So for this patch:
Since this is a bugfix, will it be merged for 2018.11?
Simon
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Quoted 102 lines · Simon Goldschmidt
Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Di., 30. Okt. 2018, 14:24:
On 10/30/2018 02:13 PM, Stefan Roese wrote:
> On 30.10.18 14:02, Simon Goldschmidt wrote:
>>
>>
>> Stefan Roese <sr at denx.de <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> schrieb am Di., 30. Okt.
>> 2018, 13:50:
>>
>> On 30.10.18 13:37, Simon Goldschmidt wrote:
>> > On Tue, Oct 30, 2018 at 12:28 PM Stefan Roese <[email protected] <mailto:[email protected]>
>> <mailto:sr at denx.de <mailto:[email protected]>>> wrote:
>> >>
>> >> On 30.10.18 12:17, Simon Goldschmidt wrote:
>> >>
>> >> <snip>
>> >>
>> >>> > diff --gita/include/configs/socfpga_common.h
>>b/include/configs/socfpga_common.h
>> >>> > index2330143cf1..bd8f5c8c41100644 >> >>> > ---a/include/configs/socfpga_common.h>> >>> > +++b/include/configs/socfpga_common.h>> >>> > @@ -31,8 +31,21 @@
>> >>> > #defineCONFIG_SYS_INIT_RAM_ADDR>> 0xFFE00000
>> >>> > #defineCONFIG_SYS_INIT_RAM_SIZE>> 0x40000 /* 256KB */
>> >>> > #endif
>> >>> > +
>> >>> > +/*
>> >>> > + * Some boards (e.g.socfpga_sr1500) use 8 >> bytes at the end of the internal
>> >>> > + * SRAM as bootcounter storage. Make sure to
>> not put the stack directly
>> >>> > + * at this address to not overwrite the >> bootcounter by checking, if the
>> >>> > + * bootcounter address is located in the >> internal SRAM.
>> >>> > + */
>> >>> > +#if ((CONFIG_SYS_BOOTCOUNT_ADDR> >>CONFIG_SYS_INIT_RAM_ADDR) && \
>> >>> > + (CONFIG_SYS_BOOTCOUNT_ADDR < >> (CONFIG_SYS_INIT_RAM_ADDR+ \
>> >>> > +
>>CONFIG_SYS_INIT_RAM_SIZE)))
>> >>> > +#defineCONFIG_SYS_INIT_SP_ADDR
>>CONFIG_SYS_BOOTCOUNT_ADDR
>> >>> > +#else
>> >>> > #defineCONFIG_SYS_INIT_SP_ADDR>> \
>> >>> > (CONFIG_SYS_INIT_RAM_ADDR+ >>CONFIG_SYS_INIT_RAM_SIZE)
>> >>> > +#endif
>> >>>
>> >>>
>> >>> Can we have this check onCONFIG_INIT_RAM_SIZEinstead of the
>> >>> initial stack pointer?
>> >>>
>> >>> That would ensure the SPL size checks stay intact. >> >>
>> >> I'm not really sure what you mean with this. Could you please >> >> explain in more detail?
>> >
>> > Sorry for being unclear. What I meant was: currently >> >CONFIG_SYS_INIT_RAM_SIZEis0x10000(the full 64 kByte). >> > So ifCONFIG_SYS_BOOTCOUNT_ADDRis0xfffffff8, I think we should
>> > defineCONFIG_SYS_INIT_RAM_SIZEto0xfff8. That way, not only the
>> >CONFIG_SYS_INIT_SP_ADDRdefine is correct but
>>CONFIG_SPL_MAX_SIZEis
>> > checked to not overlap this address, too.
>> >
>> > Would that make sense to you?
>>
>> Yes, I thought that you meant it this way. I'm not sure if we >> should go this way. As we would changeCONFIG_SYS_INIT_RAM_SIZE>> to something that does not represent the physical size of the >> on-chip SRAM. This could be very confusing and misleading, if >> this define is used elsewhere.
>>
>>
>> Hmm, okay. I dont want to push you there. I just thought it would >> be good to have the SPL binary size check correct...
>
> Of course would this be good. But perhaps we can make this SPL > binary size check "better" by not changing theINIT_RAM_SIZE> define. Its definitely possible - I just don't know how hard > (I didn't look into this).
INIT_RAM_SIZEshould reflect reality IMO
Quoted 7 lines
Right. I'll check how the SPL size check works with different offsets then.
So for this patch:
Acked-by Simon Goldschmidt <[email protected]<mailto:[email protected]>>
Since this is a bugfix, will it be merged for 2018.11?
I'll pick it if Stefan is fine with it (I guess he is) ?
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Quoted 10 lines · Marek Vasut
Quoted 10 lines
> Of course would this be good. But perhaps we can make this SPL > binary size check "better" by not changing the
INIT_RAM_SIZE> define. Its definitely possible - I just don't know how hard > (I didn't look into this).
INIT_RAM_SIZEshould reflect reality IMORight. I'll check how the SPL size check works with different offsets then.
Quoted 7 lines
Quoted 5 lines
So for this patch:
Acked-by Simon Goldschmidt <[email protected]<mailto:[email protected]>>
Since this is a bugfix, will it be merged for 2018.11?
I'll pick it if Stefan is fine with it (I guess he is) ?
Yes, I am. ;)
Thanks,
Stefan
Marek Vasut
AppliedPATCH 1/1 arm: socfpga: Fix bootcounter located at the end of internal SRAM
Quoted 16 lines · Stefan Roese
Quoted 15 lines · Marek Vasut
Quoted 15 lines
> Of course would this be good. But perhaps we can make this SPL > binary size check "better" by not changing the
INIT_RAM_SIZE> define. Its definitely possible - I just don't know how hard > (I didn't look into this).
INIT_RAM_SIZEshould reflect reality IMORight. I'll check how the SPL size check works with different offsets then.
So for this patch:
Acked-by Simon Goldschmidt <[email protected]<mailto:[email protected]>>
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Since this is a bugfix, will it be merged for 2018.11?
I'll pick it if Stefan is fine with it (I guess he is) ?
Yes, I am. ;)
Applied.
Signature · 2 lines
Best regards, Marek Vasut