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:31 UTC

[incubator-nuttx] branch master updated (05f743a -> 1bded73)

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

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


    from 05f743a  Revert "boards: lc823450-xgevk: Workaround to avoid an ostest crash with rndis"
     new dc9223f  arch: rp2040: Fix the initial stack pointer
     new 8e161bc  arch: rp2040: Add stack coloration for the idle task
     new 1bded73  boards: raspberrypi-pico: Add CONFIG_STACK_COLORATION=y to smp/defconfig

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/src/rp2040/rp2040_start.c                 | 64 ++++++++++++++++++++++
 .../rp2040/raspberrypi-pico/configs/smp/defconfig  |  1 +
 2 files changed, 65 insertions(+)

[incubator-nuttx] 03/03: boards: raspberrypi-pico: Add CONFIG_STACK_COLORATION=y to smp/defconfig

Posted by xi...@apache.org.
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 1bded73f9fb55a8183065c395eb6f1b82ad7b3b2
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Sun Apr 25 11:24:56 2021 +0900

    boards: raspberrypi-pico: Add CONFIG_STACK_COLORATION=y to smp/defconfig
---
 boards/arm/rp2040/raspberrypi-pico/configs/smp/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/boards/arm/rp2040/raspberrypi-pico/configs/smp/defconfig b/boards/arm/rp2040/raspberrypi-pico/configs/smp/defconfig
index 14a62de..7f35050 100644
--- a/boards/arm/rp2040/raspberrypi-pico/configs/smp/defconfig
+++ b/boards/arm/rp2040/raspberrypi-pico/configs/smp/defconfig
@@ -42,6 +42,7 @@ CONFIG_RR_INTERVAL=200
 CONFIG_SDCLONE_DISABLE=y
 CONFIG_SMP=y
 CONFIG_SMP_NCPUS=2
+CONFIG_STACK_COLORATION=y
 CONFIG_START_DAY=9
 CONFIG_START_MONTH=2
 CONFIG_START_YEAR=2021

[incubator-nuttx] 02/03: arch: rp2040: Add stack coloration for the idle task

Posted by xi...@apache.org.
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 8e161bc992a4ad478f7704dc1adba9ca862b7cad
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Sun Apr 25 11:01:27 2021 +0900

    arch: rp2040: Add stack coloration for the idle task
    
    Summary:
    - This commit adds stack coloration for the idle task
    
    Impact:
    - rp2040 with CONFIG_STACK_COLORATION=y
    
    Testing:
    - Tested with nsh, nshsram and smp configurations
    - NOTE: CONFIG_STACK_COLORATION=y needs to be added
---
 arch/arm/src/rp2040/rp2040_start.c | 60 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/arch/arm/src/rp2040/rp2040_start.c b/arch/arm/src/rp2040/rp2040_start.c
index 498befd..8952e68 100644
--- a/arch/arm/src/rp2040/rp2040_start.c
+++ b/arch/arm/src/rp2040/rp2040_start.c
@@ -52,6 +52,14 @@
 const uintptr_t g_idle_topstack = IDLE_STACK;
 
 /****************************************************************************
+ * Private Function prototypes
+ ****************************************************************************/
+
+#ifdef CONFIG_STACK_COLORATION
+static inline void go_nx_start(void *pv, unsigned int nbytes);
+#endif
+
+/****************************************************************************
  * Private Functions
  ****************************************************************************/
 
@@ -70,6 +78,51 @@ const uintptr_t g_idle_topstack = IDLE_STACK;
 #endif
 
 /****************************************************************************
+ * Name: go_nx_start
+ ****************************************************************************/
+
+#ifdef CONFIG_STACK_COLORATION
+static inline void go_nx_start(void *pv, unsigned int nbytes)
+{
+  /* Set the IDLE stack to the stack coloration value then jump to
+   * nx_start().  We take extreme care here because were currently
+   * executing on this stack.
+   *
+   * We want to avoid sneak stack access generated by the compiler.
+   * NOTE: this function must be inlined so that SRAM boot can work.
+   */
+
+  __asm__ __volatile__
+  (
+    "\t.global nx_start\n"
+    "\tlsr  %1, %1, #2\n"       /* %1 = nwords = nbytes >> 2 */
+    "\tcmp  %1, #0\n"           /* Check (nwords == 0) */
+    "\tbeq  2f\n"               /* (should not happen) */
+
+    "\tmov  r2, #3\n"
+    "\tadd  %0, %0, #3\n"
+    "\tbic  %0, r2\n"           /* %0 = Aligned stackptr */
+    "\tldr  r2, =0xdeadbeef\n"  /* R2 = STACK_COLOR = 0xdeadbeef */
+
+    "1:\n"                      /* Top of the loop */
+    "\tstr  r2, [%0, #0]\n"     /* Save stack color word */
+    "\tadd  %0, %0, #4\n"       /* Increment stackptr */
+    "\tsub  %1, %1, #1\n"       /* %1 nwords-- */
+    "\tcmp  %1, #0\n"           /* Check (nwords == 0) */
+    "\tbne  1b\n"               /* Bottom of the loop */
+
+    "2:\n"
+    "\tmov  r2, #0\n"
+    "\tmov  r14, r2\n"          /* LR = return address (none) */
+    "\tbl   nx_start\n"         /* Branch to nx_start */
+    :
+    : "r" (pv), "r" (nbytes)
+    : "r2"
+  );
+}
+#endif
+
+/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -169,7 +222,14 @@ void __start(void)
 
   showprogress('\r');
   showprogress('\n');
+
+#ifdef CONFIG_STACK_COLORATION
+  /* Set the IDLE stack to the coloration value and jump into nx_start() */
+
+  go_nx_start((FAR void *)&_ebss, CONFIG_IDLETHREAD_STACKSIZE);
+#else
   nx_start();
+#endif
 
   /* Shouldn't get here */
 

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

Posted by xi...@apache.org.
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)