commit 82b6a25cc9834eefaef917f30b3f8e9f2af5e21b
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Fri Dec 13 15:41:03 2019 +0100

    ChibiOS patch for thread hierarchy fixed.
    kernelsetup script slightly optimized
    ChibiOS updated

diff --git a/kernel/ChibiOS b/kernel/ChibiOS
index a9ba0b8..9a5761d 160000
--- a/kernel/ChibiOS
+++ b/kernel/ChibiOS
@@ -1 +1 @@
-Subproject commit a9ba0b88416cff96c60c59f1d8bf8469fd328ef2
+Subproject commit 9a5761d8a6a46a8ae917697914af74e17d8fccf2
diff --git a/kernel/kernelsetup.sh b/kernel/kernelsetup.sh
index 8266729..9fe30ba 100755
--- a/kernel/kernelsetup.sh
+++ b/kernel/kernelsetup.sh
@@ -502,16 +502,13 @@ function patchChibiOS {
     cd $chibiosdir
     git checkout -b "$git_branch_patched" 2>&1 | tee -a $LOG_FILE
     for patch in $patches; do
-      cp $patch .
-      patch=$(basename $patch)
-      printInfo "applying ${patch}...\n"
+      printInfo "applying $(basename ${patch})...\n"
       git apply --whitespace=nowarn --ignore-space-change --ignore-whitespace < $patch 2>&1 | tee -a $LOG_FILE
-      rm $patch
 #      # These lines are disabled for safety reasons:
 #      #   Filed commits are detected as valid changes by the super-project.
-#      #   This may lead to errorneous updates of the super-project, as to point to one of these commit hashes.
+#      #   This would lead to errorneous updates of the super-project, so to point to one of those (local) commits.
 #      #   Since these commits are not pushed upstream, initialization of the super-project will therefore fail, because
-#      #   the referenced hashed (after patching) do not exist in a clean copy of this sub-project.
+#      #   the referenced hashes (after patching) do not exist in a clean copy of this sub-project.
 #      git add $(git ls-files -dmo --exclude-standard --exclude=/doc) $(git diff --name-only) 2>&1 | tee -a $LOG_FILE
 #      git commit --message="$patch applied" 2>&1 | tee -a $LOG_FILE
     done
diff --git a/kernel/patches/introduce-thread-hierarchy.patch b/kernel/patches/introduce-thread-hierarchy.patch
index 5eabff4..5d6b318 100644
--- a/kernel/patches/introduce-thread-hierarchy.patch
+++ b/kernel/patches/introduce-thread-hierarchy.patch
@@ -194,7 +194,7 @@ diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
  #if CH_CFG_USE_WAITEXIT == TRUE
    list_init(&tp->waiting);
  #endif
-@@ -190,7 +246,11 @@ thread_t *chThdCreateSuspendedI(const thread_descriptor_t *tdp) {
+@@ -190,7 +244,11 @@ thread_t *chThdCreateSuspendedI(const thread_descriptor_t *tdp) {
    PORT_SETUP_CONTEXT(tp, tdp->wbase, tp, tdp->funcp, tdp->arg);
  
    /* The driver object is initialized but not started.*/
@@ -206,7 +206,7 @@ diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
  }
  
  /**
-@@ -300,6 +360,7 @@ thread_t *chThdCreate(const thread_descriptor_t *tdp) {
+@@ -300,6 +358,7 @@ thread_t *chThdCreate(const thread_descriptor_t *tdp) {
    return tp;
  }
  
@@ -214,7 +214,7 @@ diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
  /**
   * @brief   Creates a new thread into a static memory area.
   * @post    The created thread has a reference counter set to one, it is
-@@ -315,13 +376,20 @@ thread_t *chThdCreate(const thread_descriptor_t *tdp) {
+@@ -315,13 +374,20 @@ thread_t *chThdCreate(const thread_descriptor_t *tdp) {
   * @param[in] pf        the thread function
   * @param[in] arg       an argument passed to the thread function. It can be
   *                      @p NULL.
@@ -235,7 +235,7 @@ diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
    thread_t *tp;
  
    chDbgCheck((wsp != NULL) &&
-@@ -358,7 +426,11 @@ thread_t *chThdCreateStatic(void *wsp, size_t size,
+@@ -358,7 +424,11 @@ thread_t *chThdCreateStatic(void *wsp, size_t size,
    /* Setting up the port-dependent part of the working area.*/
    PORT_SETUP_CONTEXT(tp, wsp, tp, pf, arg);
  
@@ -247,7 +247,7 @@ diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
  
    /* Starting the thread immediately.*/
    chSchWakeupS(tp, MSG_OK);
-@@ -529,6 +601,30 @@ void chThdExitS(msg_t msg) {
+@@ -529,6 +599,30 @@ void chThdExitS(msg_t msg) {
  #endif
  #endif
  
@@ -278,7 +278,7 @@ diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
    /* Going into final state.*/
    chSchGoSleepS(CH_STATE_FINAL);
  
-@@ -610,6 +706,43 @@ tprio_t chThdSetPriority(tprio_t newprio) {
+@@ -610,6 +704,43 @@ tprio_t chThdSetPriority(tprio_t newprio) {
  #else
    oldprio = currp->prio;
    currp->prio = newprio;
@@ -451,7 +451,7 @@ diff --git a/test/rt/source/test/rt_test_sequence_003.c b/test/rt/source/test/rt
      test_wait_threads();
      test_assert_sequence("ABCDE", "invalid sequence");
    }
-@@ -325,6 +339,405 @@ static const testcase_t rt_test_003_004 = {
+@@ -325,6 +339,408 @@ static const testcase_t rt_test_003_004 = {
  };
  #endif /* CH_CFG_USE_MUTEXES */
  
@@ -511,11 +511,7 @@ diff --git a/test/rt/source/test/rt_test_sequence_003.c b/test/rt/source/test/rt
 +    siblings[2] = threads[2]->sibling;
 +    siblings[3] = threads[3]->sibling;
 +    siblings[4] = threads[4]->sibling;
-+    chThdTerminate(threads[0]);
-+    chThdTerminate(threads[1]);
-+    chThdTerminate(threads[2]);
-+    chThdTerminate(threads[3]);
-+    chThdTerminate(threads[4]);
++    test_terminate_threads();
 +    test_wait_threads();
 +    test_assert(parents[0] == chThdGetSelfX() &&
 +                parents[1] == threads_cpy[0] &&
@@ -660,6 +656,10 @@ diff --git a/test/rt/source/test/rt_test_sequence_003.c b/test/rt/source/test/rt
 +    threads_cpy[2] = threads[2];
 +    threads_cpy[3] = threads[3];
 +    threads_cpy[4] = threads[4];
++#if CH_CFG_USE_REGISTRY == TRUE
++    chThdAddRef(threads[1]);
++    chThdAddRef(threads[4]);
++#endif
 +    chThdTerminate(threads[1]);
 +    chThdTerminate(threads[4]);
 +    chThdWait(threads[1]);
@@ -707,6 +707,9 @@ diff --git a/test/rt/source/test/rt_test_sequence_003.c b/test/rt/source/test/rt
 +    threads_cpy[2] = threads[2];
 +    threads_cpy[3] = threads[3];
 +    threads_cpy[4] = threads[4];
++#if CH_CFG_USE_REGISTRY == TRUE
++    chThdAddRef(threads[0]);
++#endif
 +    chThdTerminate(threads[0]);
 +    chThdWait(threads[0]);
 +    parents[0] = threads_cpy[0]->parent;
@@ -857,7 +860,7 @@ diff --git a/test/rt/source/test/rt_test_sequence_003.c b/test/rt/source/test/rt
  /****************************************************************************
   * Exported data.
   ****************************************************************************/
-@@ -338,6 +751,9 @@ const testcase_t * const rt_test_sequence_003_array[] = {
+@@ -338,6 +754,9 @@ const testcase_t * const rt_test_sequence_003_array[] = {
    &rt_test_003_003,
  #if (CH_CFG_USE_MUTEXES) || defined(__DOXYGEN__)
    &rt_test_003_004,
@@ -1215,3 +1218,6 @@ diff --git a/test/rt/source/test/rt_test_sequence_010.c b/test/rt/source/test/rt
    }
  
    /* [10.8.2] Waiting one second then terminating the 5 threads.*/
+-- 
+2.17.1
+
