commit 510b93ccf3818200d52dfc72f9aa66acd27ab6db
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Mon Oct 28 15:48:46 2019 +0100

    Several fixed to the recent SSSP overhaul

diff --git a/core/src/aos_main.cpp b/core/src/aos_main.cpp
index d404768..fbb81e0 100644
--- a/core/src/aos_main.cpp
+++ b/core/src/aos_main.cpp
@@ -408,7 +408,7 @@ int main(void)
     }
   }
 #else /* (AMIROOS_CFG_SSSP_MASTER == true) */
-  while ((shutdown == AOS_SHUTDOWN_NONE) && (aosSsspProceed(&_eventListenerGPIO, MODULE_SSSP_EVENTFLAG_S, EVENTMASK_GPIO, &eventmask) != AOS_SUCCES)) {
+  while ((shutdown == AOS_SHUTDOWN_NONE) && (aosSsspProceed(&_eventListenerGPIO, MODULE_SSSP_EVENTFLAG_S, EVENTMASK_GPIO, &eventmask) != AOS_SUCCESS)) {
     /*
      * This code is executed if the received event was not about a deactivation of the snychronization signal.
      * The received event could be caused by any listener.
diff --git a/core/src/aos_sssp.c b/core/src/aos_sssp.c
index 683dd79..c058862 100644
--- a/core/src/aos_sssp.c
+++ b/core/src/aos_sssp.c
@@ -44,8 +44,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* LOCAL VARIABLES                                                            */
 /******************************************************************************/
 
-#if (AMIROOS_CFG_SSSP_MASTER == true) || defined (__DOXYGEN__)
-
 /**
  * @brief   A timer event based delays.
  */
@@ -61,14 +59,10 @@ static event_source_t _eventSourceDelay;
  */
 static event_listener_t _eventListenerDelay;
 
-#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
-
 /******************************************************************************/
 /* LOCAL FUNCTIONS                                                            */
 /******************************************************************************/
 
-#if (AMIROOS_CFG_SSSP_MASTER == true) || defined (__DOXYGEN__)
-
 /**
  * @brief   General callback function to be used for any local timers.
  *
@@ -85,8 +79,6 @@ static void _timerCallback(void* par)
   return;
 }
 
-#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
-
 /**
  * @brief   Waits for the S signal to switch to the desired state.
  *
@@ -120,8 +112,6 @@ static inline aos_status_t _waitForS(event_listener_t* listener, eventflags_t fl
   return AOS_FAILURE;
 }
 
-#if (AMIROOS_CFG_SSSP_MASTER == true) || defined(__DOXYGEN__)
-
 /**
  * @brief   Uses the local delay timer to setup a timed event and waits for it to fire.
  *
@@ -156,8 +146,6 @@ static inline aos_status_t _delay(uint32_t dt, eventmask_t mask, bool arm_timer,
   return AOS_FAILURE;
 }
 
-#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
-
 /******************************************************************************/
 /* EXPORTED FUNCTIONS                                                         */
 /******************************************************************************/
@@ -167,48 +155,39 @@ static inline aos_status_t _delay(uint32_t dt, eventmask_t mask, bool arm_timer,
  */
 void aosSsspInit(void)
 {
-#if (AMIROOS_CFG_SSSP_MSI == true)
-  // module ID is initialized as 'invalid'
-  aos.sssp.moduleId = AOS_SSSP_MODULEID_INVALID;
-#endif /* (AMIROOS_CFG_SSSP_MSI == true) */
+  // local variables
+  apalControlGpioState_t state;
 
 #if (AMIROOS_CFG_SSSP_STARTUP == true)
   // AMiRo-OS has to perform the basic initialization
   aos.sssp.stage = AOS_SSSP_STAGE_STARTUP_1_1;
-#if (AMIROOS_CFG_DBG == true)
-  // check whether the initial signal configuration is correct
-  {
-    apalControlGpioState_t state;
-    // S signal
-    apalControlGpioGet(&moduleSsspGpioS, &state);
-    aosDbgAssert(state == APAL_GPIO_ON);
-    // PD signal
-    apalControlGpioGet(&moduleSsspGpioPD, &state);
-    aosDbgAssert(state == APAL_GPIO_OFF);
-  }
-#endif /* (AMIROOS_CFG_DBG == true) */
 #else /* (AMIROOS_CFG_SSSP_STARTUP == true) */
   // basic initialization was already performed by a bootloader
   aos.sssp.stage = AOS_SSSP_STAGE_STARTUP_2_1;
-#if (AMIROOS_CFG_DBG == true)
-  // check whether the initial signal configuration is correct
-  {
-    apalControlGpioState_t state;
-    // S signal
-    apalControlGpioGet(&moduleSsspGpioS, &state);
-    aosDbgAssert(state == APAL_GPIO_ON);
-    // PD signal
-    apalControlGpioGet(&moduleSsspGpioPD, &state);
-    aosDbgAssert(state == APAL_GPIO_OFF);
-  }
-#endif /* (AMIROOS_CFG_DBG == true) */
 #endif /* (AMIROOS_CFG_SSSP_STARTUP == true) */
 
-#if (AMIROOS_CFG_SSSP_MASTER == true)
+  // check all SSSP signals for correct state
+  apalControlGpioGet(&moduleSsspGpioS, &state);
+  aosDbgAssert(state == APAL_GPIO_ON);
+  apalControlGpioGet(&moduleSsspGpioPD, &state);
+  aosDbgAssert(state == APAL_GPIO_OFF);
+#if (AMIROOS_CFG_SSSP_STACK_END != true)
+  apalControlGpioGet(&moduleSsspGpioUP, &state);
+  aosDbgAssert(state == APAL_GPIO_OFF);
+#endif /* (AMIROOS_CFG_SSSP_STACK_END != true) */
+#if (AMIROOS_CFG_SSSP_STACK_START != true)
+  apalControlGpioGet(&moduleSsspGpioDN, &state);
+  aosDbgAssert(state == APAL_GPIO_OFF);
+#endif /* (AMIROOS_CFG_SSSP_STACK_START != true) */
+
+#if (AMIROOS_CFG_SSSP_MSI == true)
+  // module ID is initialized as 'invalid'
+  aos.sssp.moduleId = AOS_SSSP_MODULEID_INVALID;
+#endif /* (AMIROOS_CFG_SSSP_MSI == true) */
+
   // initialize static variables
   chVTObjectInit(&_delayTimer);
   chEvtObjectInit(&_eventSourceDelay);
-#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
 
   return;
 }
diff --git a/core/src/aos_system.c b/core/src/aos_system.c
index 97270e6..7208963 100644
--- a/core/src/aos_system.c
+++ b/core/src/aos_system.c
@@ -574,14 +574,18 @@ static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* ar
 #if (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_NONE)
 
   (void)argv;
-  (void)argc;
-
-  // broadcast shutdown event
-  chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_MASK);
-  // set terminate flag so no further prompt will be printed
-  chThdTerminate(chThdGetSelfX());
 
-  return AOS_OK;
+  if (argc != 1) {
+    // error
+    chprintf(stream, "ERROR: no arguments allowed.\n");
+    return AOS_INVALIDARGUMENTS;
+  } else {
+    // broadcast shutdown event
+    chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_MASK);
+    // set terminate flag so no further prompt will be printed
+    chThdTerminate(chThdGetSelfX());
+    return AOS_OK;
+  }
 
 #elif (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT)
 
diff --git a/modules/DiWheelDrive_1-1/aosconf.h b/modules/DiWheelDrive_1-1/aosconf.h
index 0f93be9..fbac3a8 100644
--- a/modules/DiWheelDrive_1-1/aosconf.h
+++ b/modules/DiWheelDrive_1-1/aosconf.h
@@ -112,7 +112,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_AMiRoBLT
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_AMiRoBLT
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
 
 /** @} */
 
diff --git a/modules/DiWheelDrive_1-2/aosconf.h b/modules/DiWheelDrive_1-2/aosconf.h
index 549f682..4d8765d 100644
--- a/modules/DiWheelDrive_1-2/aosconf.h
+++ b/modules/DiWheelDrive_1-2/aosconf.h
@@ -112,7 +112,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_AMiRoBLT
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_AMiRoBLT
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
 
 /** @} */
 
diff --git a/modules/LightRing_1-0/aosconf.h b/modules/LightRing_1-0/aosconf.h
index 16dcc6e..4f1a7e7 100644
--- a/modules/LightRing_1-0/aosconf.h
+++ b/modules/LightRing_1-0/aosconf.h
@@ -112,7 +112,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_AMiRoBLT
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_AMiRoBLT
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
 
 /** @} */
 
diff --git a/modules/LightRing_1-2/aosconf.h b/modules/LightRing_1-2/aosconf.h
index b46f4b3..af0db51 100644
--- a/modules/LightRing_1-2/aosconf.h
+++ b/modules/LightRing_1-2/aosconf.h
@@ -112,7 +112,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_AMiRoBLT
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_AMiRoBLT
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
 
 /** @} */
 
diff --git a/modules/NUCLEO-F103RB/aosconf.h b/modules/NUCLEO-F103RB/aosconf.h
index 85ae785..54e87ec 100644
--- a/modules/NUCLEO-F103RB/aosconf.h
+++ b/modules/NUCLEO-F103RB/aosconf.h
@@ -112,7 +112,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_NONE
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_NONE
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
 
 /** @} */
 
diff --git a/modules/NUCLEO-F401RE/aosconf.h b/modules/NUCLEO-F401RE/aosconf.h
index 45e6687..3ebcf04 100644
--- a/modules/NUCLEO-F401RE/aosconf.h
+++ b/modules/NUCLEO-F401RE/aosconf.h
@@ -112,7 +112,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_NONE
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_NONE
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
+
+/** @} */
 
 /*===========================================================================*/
 /**
diff --git a/modules/NUCLEO-F767ZI/aosconf.h b/modules/NUCLEO-F767ZI/aosconf.h
index 0e4ebee..099f033 100644
--- a/modules/NUCLEO-F767ZI/aosconf.h
+++ b/modules/NUCLEO-F767ZI/aosconf.h
@@ -112,7 +112,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_NONE
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_NONE
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
+
+/** @} */
 
 /*===========================================================================*/
 /**
diff --git a/modules/NUCLEO-L476RG/aosconf.h b/modules/NUCLEO-L476RG/aosconf.h
index 5b0779e..862a882 100644
--- a/modules/NUCLEO-L476RG/aosconf.h
+++ b/modules/NUCLEO-L476RG/aosconf.h
@@ -112,7 +112,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_NONE
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_NONE
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
+
+/** @} */
 
 /*===========================================================================*/
 /**
diff --git a/modules/PowerManagement_1-1/aosconf.h b/modules/PowerManagement_1-1/aosconf.h
index 968bbf6..caa6515 100644
--- a/modules/PowerManagement_1-1/aosconf.h
+++ b/modules/PowerManagement_1-1/aosconf.h
@@ -112,7 +112,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_AMiRoBLT
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_AMiRoBLT
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
 
 /** @} */
 
diff --git a/modules/PowerManagement_1-2/aosconf.h b/modules/PowerManagement_1-2/aosconf.h
index 024aad2..71bf84e 100644
--- a/modules/PowerManagement_1-2/aosconf.h
+++ b/modules/PowerManagement_1-2/aosconf.h
@@ -112,7 +112,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_AMiRoBLT
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_AMiRoBLT
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
 
 /** @} */
 
diff --git a/modules/STM32F407G-DISC1/aosconf.h b/modules/STM32F407G-DISC1/aosconf.h
index 96a38d0..9f9cece 100644
--- a/modules/STM32F407G-DISC1/aosconf.h
+++ b/modules/STM32F407G-DISC1/aosconf.h
@@ -112,7 +112,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Identifier of the instaled bootloader (if any).
  * @note    See aos_bootloader.h file for a list of available settings.
  */
-#define AMIROOS_CFG_BOOTLOADER                  AOS_BOOTLOADER_NONE
+#if !defined(OS_CFG_BOOTLOADER)
+  #define AMIROOS_CFG_BOOTLOADER                AOS_BOOTLOADER_NONE
+#else /* !defined(OS_CFG_BOOTLOADER) */
+  #define AMIROOS_CFG_BOOTLOADER                OS_CFG_BOOTLOADER
+#endif /* !defined(OS_CFG_BOOTLOADER) */
+
+/** @} */
 
 /*===========================================================================*/
 /**
