You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/10/07 14:51:57 UTC

[incubator-nuttx] branch master updated (8eec165 -> caa945c)

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

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


    from 8eec165  tiva/lm3s: Fix nxstyle warnings
     new c20c8c6  arch/xtensa/esp32: Implement system reset. Both CPUs are soft-reset with a call to board_reset.  This is actually a Core Reset, so both cores and all registers are reset.  The only exception is RTC.
     new caa945c  arch/xtensa/src/esp32: Add a way to retrieve reset cause.

The 2 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/xtensa/Kconfig                                |  1 +
 arch/xtensa/src/esp32/Make.defs                    |  1 +
 .../src/esp32/esp32_resetcause.c}                  | 43 ++++++++++---------
 .../src/esp32/esp32_resetcause.h}                  | 48 +++++++++-------------
 .../src/esp32/esp32_systemreset.c}                 | 22 ++++++----
 boards/xtensa/esp32/esp32-core/src/Makefile        |  3 ++
 .../esp32/esp32-core/src/esp32_reset.c}            |  5 ++-
 7 files changed, 66 insertions(+), 57 deletions(-)
 copy arch/{arm/src/armv7-m/arm_systemreset.c => xtensa/src/esp32/esp32_resetcause.c} (71%)
 copy arch/{arm/src/lc823450/lc823450_lowputc.h => xtensa/src/esp32/esp32_resetcause.h} (68%)
 copy arch/{z16/src/common/z16_interruptcontext.c => xtensa/src/esp32/esp32_systemreset.c} (82%)
 copy boards/{arm/sama5/giant-board/src/sam_reset.c => xtensa/esp32/esp32-core/src/esp32_reset.c} (94%)


[incubator-nuttx] 02/02: arch/xtensa/src/esp32: Add a way to retrieve reset cause.

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit caa945cb249efa17dfd4ca9fba6cf11c83e6265b
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Tue Sep 29 15:50:12 2020 +0100

    arch/xtensa/src/esp32: Add a way to retrieve reset cause.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/src/esp32/Make.defs                    |  2 +-
 .../xtensa/src/esp32/esp32_resetcause.c            | 52 +++++++++++++---------
 .../xtensa/src/esp32/esp32_resetcause.h            | 51 +++++++++------------
 boards/xtensa/esp32/esp32-core/src/esp32_reset.c   |  2 +-
 4 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs
index 2c9c32c..e01a061 100644
--- a/arch/xtensa/src/esp32/Make.defs
+++ b/arch/xtensa/src/esp32/Make.defs
@@ -53,7 +53,7 @@ CMN_CSRCS += xtensa_puts.c xtensa_releasepending.c xtensa_releasestack.c
 CMN_CSRCS += xtensa_reprioritizertr.c xtensa_schedsigaction.c
 CMN_CSRCS += xtensa_sigdeliver.c xtensa_stackframe.c xtensa_udelay.c
 CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c
-CMN_CSRCS += esp32_systemreset.c
+CMN_CSRCS += esp32_systemreset.c esp32_resetcause.c
 
 # Configuration-dependent common XTENSA files
 
diff --git a/boards/xtensa/esp32/esp32-core/src/esp32_reset.c b/arch/xtensa/src/esp32/esp32_resetcause.c
similarity index 65%
copy from boards/xtensa/esp32/esp32-core/src/esp32_reset.c
copy to arch/xtensa/src/esp32/esp32_resetcause.c
index cd11e22..5f0c52e 100644
--- a/boards/xtensa/esp32/esp32-core/src/esp32_reset.c
+++ b/arch/xtensa/src/esp32/esp32_resetcause.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/xtensa/esp32/esp32-core/src/esp32_reset.c
+ * arch/xtensa/src/esp32/esp32_resetcause.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -24,40 +24,48 @@
 
 #include <nuttx/config.h>
 
+#include <stdint.h>
+
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
 
-#ifdef CONFIG_BOARDCTL_RESET
+#include "xtensa.h"
+#include "hardware/esp32_rtccntl.h"
+
+#include "esp32_resetcause.h"
 
 /****************************************************************************
- * Public functions
+ * Public Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: board_reset
+ * Name: esp32_resetcause
  *
  * Description:
- *   Reset board.  Support for this function is required by board-level
- *   logic if CONFIG_BOARDCTL_RESET is selected.
- *
- * Input Parameters:
- *   status - Status information provided with the reset event.  This
- *            meaning of this status information is board-specific.  If not
- *            used by a board, the value zero may be provided in calls to
- *            board_reset().
- *
- * Returned Value:
- *   If this function returns, then it was not possible to power-off the
- *   board due to some constraints.  The return value in this case is a
- *   board-specific reason for the failure to shutdown.
+ *   Get the cause of the last reset of the given CPU
  *
  ****************************************************************************/
 
-int board_reset(int status)
+enum esp32_resetcause_e esp32_resetcause(int cpu)
 {
-  up_systemreset();
+  uint32_t regmask;
+  uint32_t regshift;
+  uint32_t regval;
 
-  return 0;
-}
+  regval = getreg32(RTC_CNTL_RESET_STATE_REG);
+
+#ifdef CONFIG_SMP
+  if (cpu != 0)
+    {
+      regmask = RTC_CNTL_RESET_CAUSE_APPCPU_M;
+      regshift = RTC_CNTL_RESET_CAUSE_APPCPU_S;
+    }
+  else
+#endif
+    {
+      regmask = RTC_CNTL_RESET_CAUSE_PROCPU_M;
+      regshift = RTC_CNTL_RESET_CAUSE_PROCPU_S;
+    }
 
-#endif /* CONFIG_BOARDCTL_RESET */
+  return (regval & regmask) >> regshift;
+}
diff --git a/boards/xtensa/esp32/esp32-core/src/esp32_reset.c b/arch/xtensa/src/esp32/esp32_resetcause.h
similarity index 61%
copy from boards/xtensa/esp32/esp32-core/src/esp32_reset.c
copy to arch/xtensa/src/esp32/esp32_resetcause.h
index cd11e22..a0dd094 100644
--- a/boards/xtensa/esp32/esp32-core/src/esp32_reset.c
+++ b/arch/xtensa/src/esp32/esp32_resetcause.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/xtensa/esp32/esp32-core/src/esp32_reset.c
+ * arch/xtensa/src/esp32/esp32_resetcause.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -19,45 +19,36 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Included Files
+ * Public Types
  ****************************************************************************/
 
-#include <nuttx/config.h>
-
-#include <nuttx/arch.h>
-#include <nuttx/board.h>
-
-#ifdef CONFIG_BOARDCTL_RESET
+enum esp32_resetcause_e
+{
+  ESP32_RESETCAUSE_SYS_CHIPPOR = 0x01,
+  ESP32_RESETCAUSE_SYS_RWDTSR  = 0x10,
+  ESP32_RESETCAUSE_SYS_BOR     = 0x0f,
+  ESP32_RESETCAUSE_CORE_SOFT   = 0x03,
+  ESP32_RESETCAUSE_CORE_DPSP   = 0x05,
+  ESP32_RESETCAUSE_CORE_MWDT0  = 0x07,
+  ESP32_RESETCAUSE_CORE_MWDT1  = 0x08,
+  ESP32_RESETCAUSE_CORE_RWDT   = 0x09,
+  ESP32_RESETCAUSE_CPU_MWDT0   = 0x0b,
+  ESP32_RESETCAUSE_CPU_SOFT    = 0x0c,
+  ESP32_RESETCAUSE_CPU_RWDT    = 0x0d,
+  ESP32_RESETCAUSE_CPU_PROCPU  = 0x0e
+};
 
 /****************************************************************************
- * Public functions
+ * Public Function Prototypes
  ****************************************************************************/
 
 /****************************************************************************
- * Name: board_reset
+ * Name: esp32_resetcause
  *
  * Description:
- *   Reset board.  Support for this function is required by board-level
- *   logic if CONFIG_BOARDCTL_RESET is selected.
- *
- * Input Parameters:
- *   status - Status information provided with the reset event.  This
- *            meaning of this status information is board-specific.  If not
- *            used by a board, the value zero may be provided in calls to
- *            board_reset().
- *
- * Returned Value:
- *   If this function returns, then it was not possible to power-off the
- *   board due to some constraints.  The return value in this case is a
- *   board-specific reason for the failure to shutdown.
+ *   Get the cause of the last reset of the given CPU
  *
  ****************************************************************************/
 
-int board_reset(int status)
-{
-  up_systemreset();
-
-  return 0;
-}
+enum esp32_resetcause_e esp32_resetcause(int cpu);
 
-#endif /* CONFIG_BOARDCTL_RESET */
diff --git a/boards/xtensa/esp32/esp32-core/src/esp32_reset.c b/boards/xtensa/esp32/esp32-core/src/esp32_reset.c
index cd11e22..926f312 100644
--- a/boards/xtensa/esp32/esp32-core/src/esp32_reset.c
+++ b/boards/xtensa/esp32/esp32-core/src/esp32_reset.c
@@ -30,7 +30,7 @@
 #ifdef CONFIG_BOARDCTL_RESET
 
 /****************************************************************************
- * Public functions
+ * Public Functions
  ****************************************************************************/
 
 /****************************************************************************


[incubator-nuttx] 01/02: arch/xtensa/esp32: Implement system reset. Both CPUs are soft-reset with a call to board_reset. This is actually a Core Reset, so both cores and all registers are reset. The only exception is RTC.

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c20c8c6dd5bf40058ef78ad761833a55014d9c06
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Tue Sep 29 14:38:32 2020 +0100

    arch/xtensa/esp32: Implement system reset.
    Both CPUs are soft-reset with a call to board_reset.  This is actually a
    Core Reset, so both cores and all registers are reset.  The only
    exception is RTC.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/Kconfig                              |  1 +
 arch/xtensa/src/esp32/Make.defs                  |  1 +
 arch/xtensa/src/esp32/esp32_systemreset.c        | 54 ++++++++++++++++++++
 boards/xtensa/esp32/esp32-core/src/Makefile      |  3 ++
 boards/xtensa/esp32/esp32-core/src/esp32_reset.c | 63 ++++++++++++++++++++++++
 5 files changed, 122 insertions(+)

diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 7ee94b5..3b9d2ef 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -15,6 +15,7 @@ config ARCH_CHIP_ESP32
 	select XTENSA_HAVE_INTERRUPTS
 	select ARCH_HAVE_MULTICPU
 	select ARCH_HAVE_MODULE_TEXT
+	select ARCH_HAVE_RESET
 	select ARCH_TOOLCHAIN_GNU
 	---help---
 		The ESP32 is a dual-core system from Espressif with two Harvard
diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs
index 9ef9f65..2c9c32c 100644
--- a/arch/xtensa/src/esp32/Make.defs
+++ b/arch/xtensa/src/esp32/Make.defs
@@ -53,6 +53,7 @@ CMN_CSRCS += xtensa_puts.c xtensa_releasepending.c xtensa_releasestack.c
 CMN_CSRCS += xtensa_reprioritizertr.c xtensa_schedsigaction.c
 CMN_CSRCS += xtensa_sigdeliver.c xtensa_stackframe.c xtensa_udelay.c
 CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c
+CMN_CSRCS += esp32_systemreset.c
 
 # Configuration-dependent common XTENSA files
 
diff --git a/arch/xtensa/src/esp32/esp32_systemreset.c b/arch/xtensa/src/esp32/esp32_systemreset.c
new file mode 100644
index 0000000..c19dfa9
--- /dev/null
+++ b/arch/xtensa/src/esp32/esp32_systemreset.c
@@ -0,0 +1,54 @@
+/****************************************************************************
+ * arch/xtensa/src/esp32/esp32_systemreset.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/board.h>
+
+#include "xtensa.h"
+#include "hardware/esp32_rtccntl.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_systemreset
+ *
+ * Description:
+ *   Internal reset logic.
+ *
+ ****************************************************************************/
+
+void up_systemreset(void)
+{
+  putreg32(RTC_CNTL_SW_SYS_RST, RTC_CNTL_OPTIONS0_REG);
+
+  /* Wait for the reset */
+
+  for (; ; );
+}
diff --git a/boards/xtensa/esp32/esp32-core/src/Makefile b/boards/xtensa/esp32/esp32-core/src/Makefile
index e5b6f45..6b08aec 100644
--- a/boards/xtensa/esp32/esp32-core/src/Makefile
+++ b/boards/xtensa/esp32/esp32-core/src/Makefile
@@ -43,6 +43,9 @@ CSRCS = esp32_boot.c esp32_bringup.c
 
 ifeq ($(CONFIG_LIB_BOARDCTL),y)
 CSRCS += esp32_appinit.c
+ifeq ($(CONFIG_BOARDCTL_RESET),y)
+CSRCS += esp32_reset.c
+endif
 endif
 
 ifeq ($(CONFIG_ESP32_SPI),y)
diff --git a/boards/xtensa/esp32/esp32-core/src/esp32_reset.c b/boards/xtensa/esp32/esp32-core/src/esp32_reset.c
new file mode 100644
index 0000000..cd11e22
--- /dev/null
+++ b/boards/xtensa/esp32/esp32-core/src/esp32_reset.c
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * boards/xtensa/esp32/esp32-core/src/esp32_reset.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/board.h>
+
+#ifdef CONFIG_BOARDCTL_RESET
+
+/****************************************************************************
+ * Public functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_reset
+ *
+ * Description:
+ *   Reset board.  Support for this function is required by board-level
+ *   logic if CONFIG_BOARDCTL_RESET is selected.
+ *
+ * Input Parameters:
+ *   status - Status information provided with the reset event.  This
+ *            meaning of this status information is board-specific.  If not
+ *            used by a board, the value zero may be provided in calls to
+ *            board_reset().
+ *
+ * Returned Value:
+ *   If this function returns, then it was not possible to power-off the
+ *   board due to some constraints.  The return value in this case is a
+ *   board-specific reason for the failure to shutdown.
+ *
+ ****************************************************************************/
+
+int board_reset(int status)
+{
+  up_systemreset();
+
+  return 0;
+}
+
+#endif /* CONFIG_BOARDCTL_RESET */