You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/04/25 08:19:32 UTC

[incubator-nuttx] 01/03: arch: rp2040: Fix the initial stack pointer

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit dc9223f4cf6558f4e3acd5baae139698972b65a6
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Sun Apr 25 10:54:50 2021 +0900

    arch: rp2040: Fix the initial stack pointer
    
    Summary:
    - The NuttX for raspberrypi-pico boots via the boot_stage2 provided
      by the pico-sdk which sets the MSP at the end of the SRAM.
    - However, the NuttX expects the MSP is set to the top of the idle stack.
    - This commit fixes this issue.
    
    Impact:
    - None
    
    Testing:
    - Tested with nsh, nshsram and smp configrations
---
 arch/arm/src/rp2040/rp2040_start.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/src/rp2040/rp2040_start.c b/arch/arm/src/rp2040/rp2040_start.c
index 8049158..498befd 100644
--- a/arch/arm/src/rp2040/rp2040_start.c
+++ b/arch/arm/src/rp2040/rp2040_start.c
@@ -89,6 +89,10 @@ void __start(void)
   uint32_t *dest;
   int i;
 
+  /* Set MSP to the top of the IDLE stack */
+
+  __asm__ __volatile__ ("\tmsr msp, %0\n" :: "r" (g_idle_topstack));
+
   if (up_cpu_index() != 0)
     {
       while (1)