diff mbox series

[U-Boot] mach-stm32: Fix MPU region size dedicated to SDRAM for STM32F4

Message ID 20190625080745.21813-1-patrice.chotard@st.com
State Superseded
Delegated to: Patrice Chotard
Headers show
Series [U-Boot] mach-stm32: Fix MPU region size dedicated to SDRAM for STM32F4 | expand

Commit Message

Patrice CHOTARD June 25, 2019, 8:07 a.m. UTC
The MPU region dedicated for SDRAM for STM32F4 SoCs family
was set to 16MB, but STM32F429 Evaluation board have 32MB of SDRAM.

When kernel starts, only first 16MB of SDRAM are configured with XN
(eXecute Never) bit disabled, whereas kernel is using 32MB.

It fixes the following user land exception on STM32F429 Evaluation
board :

[    1.713002] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    1.722605] devtmpfs: mounted
[    1.733057] Freeing unused kernel memory: 72K
[    1.737622] This architecture does not have kernel memory protection.
[    1.744070] Run /sbin/init as init process
[    1.906850]
[    1.906850] Unhandled exception: IPSR = 00000004 LR = fffffffd
[    1.914282] CPU: 0 PID: 1 Comm: init Not tainted 5.1.0-00002-gcf9ca5719954 #6
[    1.921433] Hardware name: STM32 (Device Tree Support)
[    1.926601] PC is at 0x1a00b64
[    1.929642] LR is at   (null)
[    1.932669] pc : [<01a00b64>]    lr : [<00000000>]    psr: 01000000
[    1.938993] sp : 01a5cfb0  ip : 00000000  fp : 00000000
[    1.944269] r10: 01a43b00  r9 : 00000000  r8 : 00000000
[    1.949564] r7 : 00000000  r6 : 00000000  r5 : 00000000  r4 : 00000000
[    1.956168] r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 00000000
[    1.962701] xPSR: 01000000
[    1.965506] CPU: 0 PID: 1 Comm: init Not tainted 5.1.0-00002-gcf9ca5719954 #6
[    1.972658] Hardware name: STM32 (Device Tree Support)
[    1.978132] [<0000c009>] (unwind_backtrace) from [<0000b24f>] (show_stack+0xb/0xc)
[    1.986024] [<0000b24f>] (show_stack) from [<0000b947>] (__invalid_entry+0x4b/0x4c)

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 arch/arm/mach-stm32/soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Patrick DELAUNAY June 25, 2019, 9:18 a.m. UTC | #1
Hi Patrice,

> -----Original Message-----
> From: Patrice CHOTARD <patrice.chotard@st.com>
> Sent: mardi 25 juin 2019 10:08
> To: u-boot@lists.denx.de
> Cc: Patrice CHOTARD <patrice.chotard@st.com>; Patrick DELAUNAY
> <patrick.delaunay@st.com>; U-Boot STM32 <uboot-stm32@st-md-
> mailman.stormreply.com>; Albert Aribaud <albert.u.boot@aribaud.net>; Vikas
> MANOCHA <vikas.manocha@st.com>
> Subject: [PATCH] mach-stm32: Fix MPU region size dedicated to SDRAM for
> STM32F4
> Importance: High
> 
> The MPU region dedicated for SDRAM for STM32F4 SoCs family was set to
> 16MB, but STM32F429 Evaluation board have 32MB of SDRAM.
> 
> When kernel starts, only first 16MB of SDRAM are configured with XN (eXecute
> Never) bit disabled, whereas kernel is using 32MB.
> 
> It fixes the following user land exception on STM32F429 Evaluation board :
> 
> [    1.713002] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
> [    1.722605] devtmpfs: mounted
> [    1.733057] Freeing unused kernel memory: 72K
> [    1.737622] This architecture does not have kernel memory protection.
> [    1.744070] Run /sbin/init as init process
> [    1.906850]
> [    1.906850] Unhandled exception: IPSR = 00000004 LR = fffffffd
> [    1.914282] CPU: 0 PID: 1 Comm: init Not tainted 5.1.0-00002-gcf9ca5719954 #6
> [    1.921433] Hardware name: STM32 (Device Tree Support)
> [    1.926601] PC is at 0x1a00b64
> [    1.929642] LR is at   (null)
> [    1.932669] pc : [<01a00b64>]    lr : [<00000000>]    psr: 01000000
> [    1.938993] sp : 01a5cfb0  ip : 00000000  fp : 00000000
> [    1.944269] r10: 01a43b00  r9 : 00000000  r8 : 00000000
> [    1.949564] r7 : 00000000  r6 : 00000000  r5 : 00000000  r4 : 00000000
> [    1.956168] r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 00000000
> [    1.962701] xPSR: 01000000
> [    1.965506] CPU: 0 PID: 1 Comm: init Not tainted 5.1.0-00002-gcf9ca5719954 #6
> [    1.972658] Hardware name: STM32 (Device Tree Support)
> [    1.978132] [<0000c009>] (unwind_backtrace) from [<0000b24f>]
> (show_stack+0xb/0xc)
> [    1.986024] [<0000b24f>] (show_stack) from [<0000b947>]
> (__invalid_entry+0x4b/0x4c)
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---
> 
>  arch/arm/mach-stm32/soc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-stm32/soc.c b/arch/arm/mach-stm32/soc.c index
> 6ae31d3a1f..77bb18638f 100644
> --- a/arch/arm/mach-stm32/soc.c
> +++ b/arch/arm/mach-stm32/soc.c
> @@ -18,7 +18,7 @@ int arch_cpu_init(void)
>  		 */
>  #if defined(CONFIG_STM32F4)
>  		{ 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
> -		O_I_WB_RD_WR_ALLOC, REGION_16MB },
> +		O_I_WB_RD_WR_ALLOC, REGION_32MB },

For these boards, SYSCFG_MEMRMP.MEM_MODE = 0x4

./arch/arm/dts/stm32429i-eval-u-boot.dtsi:41:			st,mem_remap = <4>;
./arch/arm/dts/stm32f469-disco-u-boot.dtsi:41:			st,mem_remap = <4>;

=> 100: FMC/SDRAM Bank 1 mapped at 0x0000 0000

So size when remap shoul be 512MB here to be ready with greter SDRAM size ?
And only if remap is requested ?

Else internal FLASH is used (000: Main Flash memory mapped at 0x0000 0000)
=> max Size is 2MB  ?

>  #endif
> 
>  		{ 0x90000000, REGION_1, XN_DIS, PRIV_RW_USR_RW,
> --
> 2.17.1

Regards

Patrick
Patrice CHOTARD June 25, 2019, 9:53 a.m. UTC | #2
Hi Patrick

On 6/25/19 11:18 AM, Patrick DELAUNAY wrote:
> Hi Patrice,
>
>> -----Original Message-----
>> From: Patrice CHOTARD <patrice.chotard@st.com>
>> Sent: mardi 25 juin 2019 10:08
>> To: u-boot@lists.denx.de
>> Cc: Patrice CHOTARD <patrice.chotard@st.com>; Patrick DELAUNAY
>> <patrick.delaunay@st.com>; U-Boot STM32 <uboot-stm32@st-md-
>> mailman.stormreply.com>; Albert Aribaud <albert.u.boot@aribaud.net>; Vikas
>> MANOCHA <vikas.manocha@st.com>
>> Subject: [PATCH] mach-stm32: Fix MPU region size dedicated to SDRAM for
>> STM32F4
>> Importance: High
>>
>> The MPU region dedicated for SDRAM for STM32F4 SoCs family was set to
>> 16MB, but STM32F429 Evaluation board have 32MB of SDRAM.
>>
>> When kernel starts, only first 16MB of SDRAM are configured with XN (eXecute
>> Never) bit disabled, whereas kernel is using 32MB.
>>
>> It fixes the following user land exception on STM32F429 Evaluation board :
>>
>> [    1.713002] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
>> [    1.722605] devtmpfs: mounted
>> [    1.733057] Freeing unused kernel memory: 72K
>> [    1.737622] This architecture does not have kernel memory protection.
>> [    1.744070] Run /sbin/init as init process
>> [    1.906850]
>> [    1.906850] Unhandled exception: IPSR = 00000004 LR = fffffffd
>> [    1.914282] CPU: 0 PID: 1 Comm: init Not tainted 5.1.0-00002-gcf9ca5719954 #6
>> [    1.921433] Hardware name: STM32 (Device Tree Support)
>> [    1.926601] PC is at 0x1a00b64
>> [    1.929642] LR is at   (null)
>> [    1.932669] pc : [<01a00b64>]    lr : [<00000000>]    psr: 01000000
>> [    1.938993] sp : 01a5cfb0  ip : 00000000  fp : 00000000
>> [    1.944269] r10: 01a43b00  r9 : 00000000  r8 : 00000000
>> [    1.949564] r7 : 00000000  r6 : 00000000  r5 : 00000000  r4 : 00000000
>> [    1.956168] r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 00000000
>> [    1.962701] xPSR: 01000000
>> [    1.965506] CPU: 0 PID: 1 Comm: init Not tainted 5.1.0-00002-gcf9ca5719954 #6
>> [    1.972658] Hardware name: STM32 (Device Tree Support)
>> [    1.978132] [<0000c009>] (unwind_backtrace) from [<0000b24f>]
>> (show_stack+0xb/0xc)
>> [    1.986024] [<0000b24f>] (show_stack) from [<0000b947>]
>> (__invalid_entry+0x4b/0x4c)
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>> ---
>>
>>  arch/arm/mach-stm32/soc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-stm32/soc.c b/arch/arm/mach-stm32/soc.c index
>> 6ae31d3a1f..77bb18638f 100644
>> --- a/arch/arm/mach-stm32/soc.c
>> +++ b/arch/arm/mach-stm32/soc.c
>> @@ -18,7 +18,7 @@ int arch_cpu_init(void)
>>  		 */
>>  #if defined(CONFIG_STM32F4)
>>  		{ 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
>> -		O_I_WB_RD_WR_ALLOC, REGION_16MB },
>> +		O_I_WB_RD_WR_ALLOC, REGION_32MB },
> For these boards, SYSCFG_MEMRMP.MEM_MODE = 0x4
>
> ./arch/arm/dts/stm32429i-eval-u-boot.dtsi:41:			st,mem_remap = <4>;
> ./arch/arm/dts/stm32f469-disco-u-boot.dtsi:41:			st,mem_remap = <4>;
>
> => 100: FMC/SDRAM Bank 1 mapped at 0x0000 0000
>
> So size when remap shoul be 512MB here to be ready with greter SDRAM size ?
> And only if remap is requested ?

You are right, should be better to extend this MPU regionĀ  to 512MB.


>
> Else internal FLASH is used (000: Main Flash memory mapped at 0x0000 0000)
> => max Size is 2MB  ?

Only STM32F429-Discovery board is using this setup.

For this board, i only test that U-Boot is starting. I didn't test kernel boot in XIP configuration.

Patrice


>
>>  #endif
>>
>>  		{ 0x90000000, REGION_1, XN_DIS, PRIV_RW_USR_RW,
>> --
>> 2.17.1
> Regards
>
> Patrick
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32/soc.c b/arch/arm/mach-stm32/soc.c
index 6ae31d3a1f..77bb18638f 100644
--- a/arch/arm/mach-stm32/soc.c
+++ b/arch/arm/mach-stm32/soc.c
@@ -18,7 +18,7 @@  int arch_cpu_init(void)
 		 */
 #if defined(CONFIG_STM32F4)
 		{ 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
-		O_I_WB_RD_WR_ALLOC, REGION_16MB },
+		O_I_WB_RD_WR_ALLOC, REGION_32MB },
 #endif
 
 		{ 0x90000000, REGION_1, XN_DIS, PRIV_RW_USR_RW,