Patchwork [U-Boot,1/6] eNET: Fix saveenv crash

login
register
mail settings
Submitter Graeme Russ
Date April 11, 2011, 11:06 a.m.
Message ID <1302520020-4767-2-git-send-email-graeme.russ@gmail.com>
Download mbox | patch
Permalink /patch/90586/
State Accepted
Commit ec8016c856af29de2f2ca6c3692929423673bf66
Delegated to: Graeme Russ
Headers show

Comments

Graeme Russ - April 11, 2011, 11:06 a.m.
CONFIG_ENV_SIZE = CONFIG_ENV_SECT_SIZE = 128kB but CONFIG_SYS_STACK_SIZE
is only 32kB resulting in saveenv causing a stack overflow and crashing
U-Boot. Resolve by reducing CONFIG_ENV_SIZE to 4kB

Also fix up CONFIG_SYS_MALLOC_LEN to correctly use environment sector
size and add some comments to the memory organisation configuration

Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
---
 include/configs/eNET.h |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)
Graeme Russ - April 13, 2011, 9:59 a.m.
On 11/04/11 21:06, Graeme Russ wrote:
> CONFIG_ENV_SIZE = CONFIG_ENV_SECT_SIZE = 128kB but CONFIG_SYS_STACK_SIZE
> is only 32kB resulting in saveenv causing a stack overflow and crashing
> U-Boot. Resolve by reducing CONFIG_ENV_SIZE to 4kB
> 
> Also fix up CONFIG_SYS_MALLOC_LEN to correctly use environment sector
> size and add some comments to the memory organisation configuration
> 
> Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
> ---
>  include/configs/eNET.h |   23 +++++++++++++++++------
>  1 files changed, 17 insertions(+), 6 deletions(-)

Applied to u-boot-x86, master branch, thanks.

Regards,

Graeme Russ

Patch

diff --git a/include/configs/eNET.h b/include/configs/eNET.h
index 34a9d68..f3ef7d2 100644
--- a/include/configs/eNET.h
+++ b/include/configs/eNET.h
@@ -158,16 +158,19 @@ 
 /*-----------------------------------------------------------------------
  * Memory organization:
  * 32kB Stack
+ * 16kB Cache-As-RAM @ 0x19200000
  * 256kB Monitor
+ * (128kB + Environment Sector Size) malloc pool
  */
-#define CONFIG_SYS_STACK_SIZE			0x8000
+#define CONFIG_SYS_STACK_SIZE			(32 * 1024)
 #define CONFIG_SYS_CAR_ADDR			0x19200000
-#define CONFIG_SYS_CAR_SIZE			0x00004000
+#define CONFIG_SYS_CAR_SIZE			(16 * 1024)
 #define CONFIG_SYS_INIT_SP_ADDR			(CONFIG_SYS_CAR_ADDR + \
 						 CONFIG_SYS_CAR_SIZE)
 #define CONFIG_SYS_MONITOR_BASE			CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_MONITOR_LEN			(256 * 1024)
-#define CONFIG_SYS_MALLOC_LEN			(CONFIG_ENV_SIZE + 128*1024)
+#define CONFIG_SYS_MALLOC_LEN			(CONFIG_ENV_SECT_SIZE + \
+						 128*1024)
 /* Address of temporary Global Data */
 #define CONFIG_SYS_INIT_GD_ADDR			CONFIG_SYS_CAR_ADDR
 
@@ -198,17 +201,25 @@ 
 #define CONFIG_SYS_FLASH_LEGACY_512Kx8
 #define CONFIG_SYS_FLASH_ERASE_TOUT		2000	/* ms */
 #define CONFIG_SYS_FLASH_WRITE_TOUT		2000	/* ms */
+
 /*-----------------------------------------------------------------------
  * Environment configuration
+ * - Boot flash is 512kB with 64kB sectors
+ * - StrataFlash is 32MB with 128kB sectors
+ * - Redundant embedded environment is 25% of the Boot flash
+ * - Redundant StrataFlash environment is <1% of the StrataFlash
+ * - Environment is therefore located in StrataFlash
+ * - Primary copy is located in first sector of first flash
+ * - Redundant copy is located in second sector of first flash
+ * - Stack is only 32kB, so environment size is limited to 4kB
  */
 #define CONFIG_ENV_IS_IN_FLASH
 #define CONFIG_ENV_SECT_SIZE			0x20000
-#define CONFIG_ENV_SIZE				CONFIG_ENV_SECT_SIZE
+#define CONFIG_ENV_SIZE				0x01000
 #define CONFIG_ENV_ADDR				CONFIG_SYS_FLASH_BASE_1
-/* Redundant Copy */
 #define CONFIG_ENV_ADDR_REDUND			(CONFIG_SYS_FLASH_BASE_1 + \
 						 CONFIG_ENV_SECT_SIZE)
-#define CONFIG_ENV_SIZE_REDUND			CONFIG_ENV_SECT_SIZE
+#define CONFIG_ENV_SIZE_REDUND			CONFIG_ENV_SIZE
 
 /*-----------------------------------------------------------------------
  * PCI configuration