arm: socfpga: fix bootcounter by reserving SRAM
PATCH 1/1 arm: socfpga: fix bootcounter by reserving 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 to allow boards to reserve some of the internal SRAM for other features (like the bootcounter).
---
include/configs/socfpga_common.h | 6 +++++- include/configs/socfpga_is1.h | 9 +++++---- include/configs/socfpga_sr1500.h | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-)
include/configs/socfpga_common.h +5 -1
@@ -31,8 +31,12 @@#define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000#define CONFIG_SYS_INIT_RAM_SIZE 0x40000/* 256KB */ #endif +#ifndef SOCFPGA_INIT_RAM_END_RESERVE +#define SOCFPGA_INIT_RAM_END_RESERVE 0 +#endif #define CONFIG_SYS_INIT_SP_ADDR \ - (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) + (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE - \ + SOCFPGA_INIT_RAM_END_RESERVE)#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
include/configs/socfpga_is1.h +5 -4
@@ -23,12 +23,13 @@/* PHY */ #endif -/* The rest of the configuration is shared */ -#include <configs/socfpga_common.h> -/* -* Bootcounter +* Bootcounter (8 bytes at the end of internal SRAM) */ #define CONFIG_SYS_BOOTCOUNT_BE +#define SOCFPGA_INIT_RAM_END_RESERVE 8 + +/* The rest of the configuration is shared */ +#include <configs/socfpga_common.h> #endif /* __CONFIG_SOCFPGA_IS1_H__ */
include/configs/socfpga_sr1500.h +2 -1
@@ -25,9 +25,10 @@#define CONFIG_SPI_N25Q256A_RESET /* -* Bootcounter +* Bootcounter (8 bytes at the end of internal SRAM) */ #define CONFIG_SYS_BOOTCOUNT_BE +#define SOCFPGA_INIT_RAM_END_RESERVE 8/* Environment setting for SPI flash */ #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
Signature · 1 line
2.17.1
PATCH 1/1 arm: socfpga: fix bootcounter by reserving SRAM
Simon Goldschmidt <[email protected]> schrieb am Mo., 29. Okt. 2018, 21:47:
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 6 lines
This patch allows to move the initial stack pointer down a bit to allow boards to reserve some of the internal SRAM for other features (like the bootcounter).
Signed-off-by Simon Goldschmidt <[email protected]>
Ok, it seems I have forgotten that I had sent this already:
https://patchwork.ozlabs.org/patch/913230/
However, I can't find that mail so I'll respond to Marek here.
Moving this to common memory reservation code does not work as the very first call to board_init_f_alloc_reserve() already overwrites the boot counter. This in that function it is too late. By changing the initial stack pointer define, it is ensured that no code writes to that memory.
Simon
---
Quoted 68 lines
include/configs/socfpga_common.h | 6 +++++- include/configs/socfpga_is1.h | 9 +++++---- include/configs/socfpga_sr1500.h | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-)include/configs/socfpga_common.h +5
-1@@ -31,8 +31,12 @@#define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000#define CONFIG_SYS_INIT_RAM_SIZE 0x40000/* 256KB */ #endif +#ifndef SOCFPGA_INIT_RAM_END_RESERVE +#define SOCFPGA_INIT_RAM_END_RESERVE 0 +#endif #define CONFIG_SYS_INIT_SP_ADDR \ - (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) + (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE - \ + SOCFPGA_INIT_RAM_END_RESERVE)#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1include/configs/socfpga_is1.h +5
-4@@ -23,12 +23,13 @@/* PHY */ #endif -/* The rest of the configuration is shared */ -#include <configs/socfpga_common.h> -/* -* Bootcounter +* Bootcounter (8 bytes at the end of internal SRAM) */ #define CONFIG_SYS_BOOTCOUNT_BE +#define SOCFPGA_INIT_RAM_END_RESERVE 8 + +/* The rest of the configuration is shared */ +#include <configs/socfpga_common.h> #endif /* __CONFIG_SOCFPGA_IS1_H__ */ include/configs/socfpga_sr1500.h +2
-2@@ -25,9 +25,10 @@#define CONFIG_SPI_N25Q256A_RESET /* -* Bootcounter +* Bootcounter (8 bytes at the end of internal SRAM) */ #define CONFIG_SYS_BOOTCOUNT_BE +#define SOCFPGA_INIT_RAM_END_RESERVE 8/* Environment setting for SPI flash */ #define CONFIG_SYS_REDUNDAND_ENVIRONMENT --2.17.1
PATCH 1/1 arm: socfpga: fix bootcounter by reserving SRAM
In reply to Simon GoldschmidtHi Simon,
Quoted 11 lines · Simon Goldschmidt
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 to allow boards to reserve some of the internal SRAM for other features (like the bootcounter).
Signed-off-by Simon Goldschmidt <[email protected]>
Thanks for working on this. I've just found some time to dig into this as well. I'll send a different approach for this shortly.
Thanks,
Stefan
Quoted 54 lines
---
include/configs/socfpga_common.h | 6 +++++- include/configs/socfpga_is1.h | 9 +++++---- include/configs/socfpga_sr1500.h | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-)include/configs/socfpga_common.h +5
-1@@ -31,8 +31,12 @@#define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000#define CONFIG_SYS_INIT_RAM_SIZE 0x40000/* 256KB */ #endif +#ifndef SOCFPGA_INIT_RAM_END_RESERVE +#define SOCFPGA_INIT_RAM_END_RESERVE 0 +#endif #define CONFIG_SYS_INIT_SP_ADDR \ - (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) + (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE - \ + SOCFPGA_INIT_RAM_END_RESERVE)#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1include/configs/socfpga_is1.h +5
-4@@ -23,12 +23,13 @@/* PHY */ #endif -/* The rest of the configuration is shared */ -#include <configs/socfpga_common.h> -/* -* Bootcounter +* Bootcounter (8 bytes at the end of internal SRAM) */ #define CONFIG_SYS_BOOTCOUNT_BE +#define SOCFPGA_INIT_RAM_END_RESERVE 8 + +/* The rest of the configuration is shared */ +#include <configs/socfpga_common.h> #endif /* __CONFIG_SOCFPGA_IS1_H__ */ include/configs/socfpga_sr1500.h +0
-0@@ -25,9 +25,10 @@#define CONFIG_SPI_N25Q256A_RESET
include/configs/socfpga_sr1500.h line 34
Quoted 10 lines
include/configs/socfpga_sr1500.h +2
-1/* -* Bootcounter +* Bootcounter (8 bytes at the end of internal SRAM) */ #define CONFIG_SYS_BOOTCOUNT_BE +#define SOCFPGA_INIT_RAM_END_RESERVE 8/* Environment setting for SPI flash */ #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
Viele 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 by reserving SRAM
Stefan Roese <[email protected]> schrieb am Di., 30. Okt. 2018, 09:52:
Quoted 13 lines
Hi Simon,
Quoted 10 lines · Simon Goldschmidt
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 to allow boards to reserve some of the internal SRAM for other features (like the bootcounter).
Quoted 6 lines
Quoted 1 line
Signed-off-by Simon Goldschmidt <[email protected]>Thanks for working on this. I've just found some time to dig into this as well. I'll send a different approach for this shortly.
That would be very welcome! I'm not saying my approach is nice, I only wanted the boot counter to work on my board somehow ;-)
Simon
Quoted 79 lines
Thanks,
StefanReview
Quoted 8 lines
---
include/configs/socfpga_common.h | 6 +++++- include/configs/socfpga_is1.h | 9 +++++---- include/configs/socfpga_sr1500.h | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/include/configs/socfpga_common.hReview
Quoted 18 lines
index
2330143cf1..1e26630330100644include/configs/socfpga_common.h +5
-1@@ -31,8 +31,12 @@#define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000#define CONFIG_SYS_INIT_RAM_SIZE 0x40000/* 256KB */ #endif +#ifndef SOCFPGA_INIT_RAM_END_RESERVE +#define SOCFPGA_INIT_RAM_END_RESERVE 0 +#endif #define CONFIG_SYS_INIT_SP_ADDR \ - (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) + (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE - \ + SOCFPGA_INIT_RAM_END_RESERVE)#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1(quoted diff) +0
-0
b/include/configs/socfpga_is1.hReview
Quoted 22 lines
index
c233c208a5..3c80c0f45c100644include/configs/socfpga_is1.h +5
-4@@ -23,12 +23,13 @@/* PHY */ #endif -/* The rest of the configuration is shared */ -#include <configs/socfpga_common.h> -/* -* Bootcounter +* Bootcounter (8 bytes at the end of internal SRAM) */ #define CONFIG_SYS_BOOTCOUNT_BE +#define SOCFPGA_INIT_RAM_END_RESERVE 8 + +/* The rest of the configuration is shared */ +#include <configs/socfpga_common.h> #endif /* __CONFIG_SOCFPGA_IS1_H__ */ (quoted diff) +0
-0
b/include/configs/socfpga_sr1500.hQuoted 6 lines
index
984f1183fd..b7b43fc6af100644include/configs/socfpga_sr1500.h +0
-0@@ -25,9 +25,10 @@#define CONFIG_SPI_N25Q256A_RESET include/configs/socfpga_sr1500.h line 34
Quoted 10 lines
include/configs/socfpga_sr1500.h +2
-1/* -* Bootcounter +* Bootcounter (8 bytes at the end of internal SRAM) */ #define CONFIG_SYS_BOOTCOUNT_BE +#define SOCFPGA_INIT_RAM_END_RESERVE 8/* Environment setting for SPI flash */ #define CONFIG_SYS_REDUNDAND_ENVIRONMENT Viele 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