diff mbox series

[U-Boot] ARM: zynq: Fix SPL SD boot mode

Message ID b27899d64c223fc92966482443866131d7a94644.1512134005.git.michal.simek@xilinx.com
State Accepted
Delegated to: Michal Simek
Headers show
Series [U-Boot] ARM: zynq: Fix SPL SD boot mode | expand

Commit Message

Michal Simek Dec. 1, 2017, 1:13 p.m. UTC
This patch is fixing two issues:
1. Insufficient stack size for fat fs buffers
2. Insufficient space in malloc area

Tested on zc702 and zc706.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 configs/syzygy_hub_defconfig       | 2 ++
 configs/topic_miami_defconfig      | 2 ++
 configs/topic_miamilite_defconfig  | 2 ++
 configs/topic_miamiplus_defconfig  | 2 ++
 configs/zynq_cc108_defconfig       | 2 ++
 configs/zynq_microzed_defconfig    | 2 ++
 configs/zynq_picozed_defconfig     | 2 ++
 configs/zynq_z_turn_defconfig      | 2 ++
 configs/zynq_zc702_defconfig       | 2 ++
 configs/zynq_zc706_defconfig       | 2 ++
 configs/zynq_zc770_xm010_defconfig | 2 ++
 configs/zynq_zc770_xm011_defconfig | 2 ++
 configs/zynq_zc770_xm012_defconfig | 2 ++
 configs/zynq_zc770_xm013_defconfig | 2 ++
 configs/zynq_zed_defconfig         | 2 ++
 configs/zynq_zybo_defconfig        | 2 ++
 include/configs/zynq-common.h      | 7 ++-----
 17 files changed, 34 insertions(+), 5 deletions(-)

Comments

Jerry Van Baren Dec. 1, 2017, 5:30 p.m. UTC | #1
Hi Michal,

On Fri, Dec 1, 2017 at 8:13 AM, Michal Simek <michal.simek@xilinx.com>
wrote:

> This patch is fixing two issues:
> 1. Insufficient stack size for fat fs buffers
> 2. Insufficient space in malloc area
>
> Tested on zc702 and zc706.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>

What are the symptoms of this bug?

I am running on a custom board and have been bedeviled by the behavior
where I can boot off a SD Card with the SPL loading U-Boot also off the SD
Card for many new build / copy to SD Card / boot iterations and then it
stops with an error message that the SD Card did not respond to the voltage
select command. Adding debugging printouts indicate the SD Card does not
respond to commands right at the start of the capabilities read operations
for no apparent reason.

Once it fails for a given image, it always fails for that SD Card until I
load a new image... then it might work or might not. Sometimes if I
reformat the SD Card it works again (presumably due to shifting where the
images are on the SD Card), sometimes not.

This has been driving me CRAZY.

I've applied your changes and will see if my problem goes away, but it is a
"halting problem" in that I don't know how many time it has to succeed
before I'm sure it will never fail. :-/

Thanks,
gvb
Michal Simek Dec. 4, 2017, 2:12 p.m. UTC | #2
Hi,

On 1.12.2017 18:30, Gerald Van Baren wrote:
> Hi Michal,
> 
> On Fri, Dec 1, 2017 at 8:13 AM, Michal Simek <michal.simek@xilinx.com>
> wrote:
> 
>> This patch is fixing two issues:
>> 1. Insufficient stack size for fat fs buffers
>> 2. Insufficient space in malloc area
>>
>> Tested on zc702 and zc706.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>
> 
> What are the symptoms of this bug?
> 
> I am running on a custom board and have been bedeviled by the behavior
> where I can boot off a SD Card with the SPL loading U-Boot also off the SD
> Card for many new build / copy to SD Card / boot iterations and then it
> stops with an error message that the SD Card did not respond to the voltage
> select command. Adding debugging printouts indicate the SD Card does not
> respond to commands right at the start of the capabilities read operations
> for no apparent reason.
> 
> Once it fails for a given image, it always fails for that SD Card until I
> load a new image... then it might work or might not. Sometimes if I
> reformat the SD Card it works again (presumably due to shifting where the
> images are on the SD Card), sometimes not.
> 
> This has been driving me CRAZY.
> 
> I've applied your changes and will see if my problem goes away, but it is a
> "halting problem" in that I don't know how many time it has to succeed
> before I'm sure it will never fail. :-/

There were a lot of changes in fat implementation.
Ad 2) of that issue was that one patch moved buffers to malloc area from
stack

Here is sha1: 2460098cffacd18729262e3ed36656e6943783ed

Also look at:
"arm64: zynqmp: Do not use SPL_SYS_MALLOC_SIMPLE allocator"

This is the log I am getting.

U-Boot SPL 2017.11-00056-gb06c46de632c-dirty (Dec 04 2017 - 15:04:05)
mmc boot
Trying to boot from MMC1
spl_load_image_fat_os: error reading image system.dtb, err - -12
spl_load_image_fat: error reading image u-boot.img, err - -12
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

And the ad 1) issue I found was that if you debug
ALLOC_CACHE_ALIGN_BUFFER() size then you will find out that this buffer
allocated on the stack is quite huge.

It should be maybe enough just to extend Malloc space and don't care
about stack but moving stack to DDR after init makes also sense.
If you want I am happy to separate it.

Thanks,
Michal
diff mbox series

Patch

diff --git a/configs/syzygy_hub_defconfig b/configs/syzygy_hub_defconfig
index 1cc86b862c4a..8bdc4be67d70 100644
--- a/configs/syzygy_hub_defconfig
+++ b/configs/syzygy_hub_defconfig
@@ -3,6 +3,7 @@  CONFIG_SYS_VENDOR="opalkelly"
 CONFIG_SYS_CONFIG_NAME="syzygy_hub"
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-syzygy-hub"
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
@@ -10,6 +11,7 @@  CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/topic_miami_defconfig b/configs/topic_miami_defconfig
index 38f2e4e5ccfd..aabd705da0fb 100644
--- a/configs/topic_miami_defconfig
+++ b/configs/topic_miami_defconfig
@@ -3,12 +3,14 @@  CONFIG_SYS_VENDOR="topic"
 CONFIG_SYS_CONFIG_NAME="topic_miami"
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_BOOT_INIT_FILE="board/topic/zynq/zynq-topic-miami/ps7_regs.txt"
 CONFIG_DEFAULT_DEVICE_TREE="zynq-topic-miami"
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=0
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="zynq-uboot> "
 CONFIG_CMD_THOR_DOWNLOAD=y
diff --git a/configs/topic_miamilite_defconfig b/configs/topic_miamilite_defconfig
index a1e98b7bc3f6..7228283b3c6b 100644
--- a/configs/topic_miamilite_defconfig
+++ b/configs/topic_miamilite_defconfig
@@ -3,12 +3,14 @@  CONFIG_SYS_VENDOR="topic"
 CONFIG_SYS_CONFIG_NAME="topic_miami"
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_BOOT_INIT_FILE="board/topic/zynq/zynq-topic-miamilite/ps7_regs.txt"
 CONFIG_DEFAULT_DEVICE_TREE="zynq-topic-miamilite"
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=0
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="zynq-uboot> "
 CONFIG_CMD_THOR_DOWNLOAD=y
diff --git a/configs/topic_miamiplus_defconfig b/configs/topic_miamiplus_defconfig
index b51107725a0c..d511a942838b 100644
--- a/configs/topic_miamiplus_defconfig
+++ b/configs/topic_miamiplus_defconfig
@@ -3,12 +3,14 @@  CONFIG_SYS_VENDOR="topic"
 CONFIG_SYS_CONFIG_NAME="topic_miami"
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_BOOT_INIT_FILE="board/topic/zynq/zynq-topic-miamiplus/ps7_regs.txt"
 CONFIG_DEFAULT_DEVICE_TREE="zynq-topic-miamiplus"
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=0
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="zynq-uboot> "
 CONFIG_CMD_THOR_DOWNLOAD=y
diff --git a/configs/zynq_cc108_defconfig b/configs/zynq_cc108_defconfig
index fcf4635e3d17..bdba0d1cc9ba 100644
--- a/configs/zynq_cc108_defconfig
+++ b/configs/zynq_cc108_defconfig
@@ -1,6 +1,7 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-cc108"
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
@@ -8,6 +9,7 @@  CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
 CONFIG_CMD_BOOTZ=y
diff --git a/configs/zynq_microzed_defconfig b/configs/zynq_microzed_defconfig
index a713314343d8..fc21eb8f67a3 100644
--- a/configs/zynq_microzed_defconfig
+++ b/configs/zynq_microzed_defconfig
@@ -1,12 +1,14 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-microzed"
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_picozed_defconfig b/configs/zynq_picozed_defconfig
index bbccfa5dcecf..f36e7bd849f4 100644
--- a/configs/zynq_picozed_defconfig
+++ b/configs/zynq_picozed_defconfig
@@ -1,9 +1,11 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-picozed"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_z_turn_defconfig b/configs/zynq_z_turn_defconfig
index 396c63f35c8b..c727b2acbf28 100644
--- a/configs/zynq_z_turn_defconfig
+++ b/configs/zynq_z_turn_defconfig
@@ -1,6 +1,7 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zturn-myir"
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
@@ -8,6 +9,7 @@  CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_zc702_defconfig b/configs/zynq_zc702_defconfig
index ee6462f21aac..0d0efc223dd4 100644
--- a/configs/zynq_zc702_defconfig
+++ b/configs/zynq_zc702_defconfig
@@ -2,6 +2,7 @@  CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="zynq_zc70x"
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc702"
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
@@ -9,6 +10,7 @@  CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_zc706_defconfig b/configs/zynq_zc706_defconfig
index 52999debc115..4b186c9fffc6 100644
--- a/configs/zynq_zc706_defconfig
+++ b/configs/zynq_zc706_defconfig
@@ -2,6 +2,7 @@  CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="zynq_zc70x"
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc706"
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
@@ -9,6 +10,7 @@  CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_zc770_xm010_defconfig b/configs/zynq_zc770_xm010_defconfig
index bf334677c57f..897ca91e5606 100644
--- a/configs/zynq_zc770_xm010_defconfig
+++ b/configs/zynq_zc770_xm010_defconfig
@@ -1,6 +1,7 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm010"
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
@@ -9,6 +10,7 @@  CONFIG_FIT_VERBOSE=y
 CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM010"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_zc770_xm011_defconfig b/configs/zynq_zc770_xm011_defconfig
index 357b92b5fd0e..2b8a12ee6906 100644
--- a/configs/zynq_zc770_xm011_defconfig
+++ b/configs/zynq_zc770_xm011_defconfig
@@ -1,6 +1,7 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 # CONFIG_SPL_FAT_SUPPORT is not set
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm011"
 CONFIG_FIT=y
@@ -9,6 +10,7 @@  CONFIG_FIT_VERBOSE=y
 CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM011"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_zc770_xm012_defconfig b/configs/zynq_zc770_xm012_defconfig
index cce24b97a8dd..d53fe94db36b 100644
--- a/configs/zynq_zc770_xm012_defconfig
+++ b/configs/zynq_zc770_xm012_defconfig
@@ -1,6 +1,7 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 # CONFIG_SPL_FAT_SUPPORT is not set
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm012"
 CONFIG_FIT=y
@@ -9,6 +10,7 @@  CONFIG_FIT_VERBOSE=y
 CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM012"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_zc770_xm013_defconfig b/configs/zynq_zc770_xm013_defconfig
index 869975c0df62..e6445f735c57 100644
--- a/configs/zynq_zc770_xm013_defconfig
+++ b/configs/zynq_zc770_xm013_defconfig
@@ -1,6 +1,7 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 # CONFIG_SPL_FAT_SUPPORT is not set
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm013"
 CONFIG_FIT=y
@@ -9,6 +10,7 @@  CONFIG_FIT_VERBOSE=y
 CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM013"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_zed_defconfig b/configs/zynq_zed_defconfig
index d1d59e8e2f46..c18f056debc4 100644
--- a/configs/zynq_zed_defconfig
+++ b/configs/zynq_zed_defconfig
@@ -1,12 +1,14 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zed"
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_zybo_defconfig b/configs/zynq_zybo_defconfig
index 412646086fc6..21f8c08fd824 100644
--- a/configs/zynq_zybo_defconfig
+++ b/configs/zynq_zybo_defconfig
@@ -2,6 +2,7 @@  CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="zynq_zybo"
 CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x4000000
+CONFIG_SPL_STACK_R_ADDR=0x200000
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zybo"
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
@@ -9,6 +10,7 @@  CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
+CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index 7247c9030755..b10cb3f57220 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -344,12 +344,9 @@ 
 /* 3 * 64kB blocks of OCM - one is on the top because of bootrom */
 #define CONFIG_SPL_MAX_SIZE	0x30000
 
-/* The highest 64k OCM address */
-#define OCM_HIGH_ADDR	0xffff0000
-
 /* On the top of OCM space */
-#define CONFIG_SYS_SPL_MALLOC_START	OCM_HIGH_ADDR
-#define CONFIG_SYS_SPL_MALLOC_SIZE	0x2000
+#define CONFIG_SYS_SPL_MALLOC_START	CONFIG_SPL_STACK_R_ADDR
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x2000000
 
 /*
  * SPL stack position - and stack goes down