You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/02/08 18:52:45 UTC

[1/5] incubator-mynewt-core git commit: MYNEWT-581; kernel/os - support hw fpu in context switches for cortex-m4.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop a226ca78d -> 1f227f41e


MYNEWT-581; kernel/os - support hw fpu in context switches for cortex-m4.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d557a922
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d557a922
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d557a922

Branch: refs/heads/develop
Commit: d557a9228b4b374fb4f7a7b80452c758e36f5fa9
Parents: a226ca7
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Feb 7 13:26:33 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Feb 7 13:26:33 2017 -0800

----------------------------------------------------------------------
 compiler/arm-none-eabi-m4/syscfg.yml       |  4 ++++
 kernel/os/src/arch/cortex_m4/m4/HAL_CM4.s  | 18 +++++++++++++++++-
 kernel/os/src/arch/cortex_m4/os_arch_arm.c | 13 +++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d557a922/compiler/arm-none-eabi-m4/syscfg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m4/syscfg.yml b/compiler/arm-none-eabi-m4/syscfg.yml
new file mode 100644
index 0000000..a7e0ecf
--- /dev/null
+++ b/compiler/arm-none-eabi-m4/syscfg.yml
@@ -0,0 +1,4 @@
+syscfg.defs:
+   HARDFLOAT:
+       description: 'Use hardware FPU'
+       value: 0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d557a922/kernel/os/src/arch/cortex_m4/m4/HAL_CM4.s
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/cortex_m4/m4/HAL_CM4.s b/kernel/os/src/arch/cortex_m4/m4/HAL_CM4.s
index 9c6ab52..c3def4e 100755
--- a/kernel/os/src/arch/cortex_m4/m4/HAL_CM4.s
+++ b/kernel/os/src/arch/cortex_m4/m4/HAL_CM4.s
@@ -24,8 +24,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *---------------------------------------------------------------------------*/
+#include <syscfg/syscfg.h>
 
-        .file   "HAL_CM4.S"
         .syntax unified
 
 /*----------------------------------------------------------------------------
@@ -155,12 +155,28 @@ PendSV_Handler:
         BXEQ    LR                      /* RETI, no task switch */
 
         MRS     R12,PSP                 /* Read PSP */
+#if MYNEWT_VAL(HARDFLOAT)
+        TST     LR,#0x10                /* is it extended frame? */
+        IT      EQ
+        VSTMDBEQ R12!,{S16-S31}         /* yes; push the regs */
+        STMDB   R12!,{R4-R11,LR}        /* Save Old context */
+#else
         STMDB   R12!,{R4-R11}           /* Save Old context */
+#endif
         STR     R12,[R1,#0]             /* Update stack pointer in current task */
         STR     R2,[R3]                 /* g_current_task = highest ready */
 
         LDR     R12,[R2,#0]             /* get stack pointer of task we will start */
+#if MYNEWT_VAL(HARDFLOAT)
+        LDMIA   R12!,{R4-R11,LR}        /* Restore New Context */
+        TST     LR,#0x10                /* is it extended frame? */
+        ITTE    EQ
+        VLDMIAEQ R12!,{S16-S31}         /* yes; pull the regs */
+        MVNEQ   LR,#~0xFFFFFFED         /* BX treats it as extended */
+        MVNNE   LR,#~0xFFFFFFFD         /* BX treats is as basic frame */
+#else
         LDMIA   R12!,{R4-R11}           /* Restore New Context */
+#endif
         MSR     PSP,R12                 /* Write PSP */
         BX      LR                      /* Return to Thread Mode */
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d557a922/kernel/os/src/arch/cortex_m4/os_arch_arm.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/cortex_m4/os_arch_arm.c b/kernel/os/src/arch/cortex_m4/os_arch_arm.c
index 59cee8a..c914cae 100755
--- a/kernel/os/src/arch/cortex_m4/os_arch_arm.c
+++ b/kernel/os/src/arch/cortex_m4/os_arch_arm.c
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+#include <syscfg/syscfg.h>
 
 #include "os/os.h"
 #include "os/os_arch.h"
@@ -36,6 +37,12 @@ extern void SysTick_Handler(void);
 #define INITIAL_xPSR    0x01000000
 
 /*
+ * Initial LR indicating basic frame.
+ * See ARMv7-M Architecture Ref Manual
+ */
+#define INITIAL_LR      0xfffffffd;
+
+/*
  * Exception priorities. The higher the number, the lower the priority. A
  * higher priority exception will interrupt a lower priority exception.
  */
@@ -55,6 +62,9 @@ struct stack_frame {
     uint32_t    r9;
     uint32_t    r10;
     uint32_t    r11;
+#if MYNEWT_VAL(HARDFLOAT)
+    uint32_t    exc_lr;
+#endif
     uint32_t    r0;
     uint32_t    r1;
     uint32_t    r2;
@@ -165,6 +175,9 @@ os_arch_task_stack_init(struct os_task *t, os_stack_t *stack_top, int size)
     sf->xpsr = INITIAL_xPSR;
     sf->pc = (uint32_t)t->t_func;
     sf->r0 = (uint32_t)t->t_arg;
+#if MYNEWT_VAL(HARDFLOAT)
+    sf->exc_lr = INITIAL_LR;
+#endif
 
     return (s);
 }


[5/5] incubator-mynewt-core git commit: MYNEWT-581; bsps - add cflags for FPU use.

Posted by ma...@apache.org.
MYNEWT-581; bsps - add cflags for FPU use.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1f227f41
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1f227f41
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1f227f41

Branch: refs/heads/develop
Commit: 1f227f41e351acc35e78152d6bdd00f1411167da
Parents: 4e0e901
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Feb 8 10:50:59 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Feb 8 10:50:59 2017 -0800

----------------------------------------------------------------------
 hw/bsp/arduino_primo_nrf52/pkg.yml | 3 +++
 hw/bsp/bmd300eval/pkg.yml          | 3 +++
 hw/bsp/nrf52840pdk/pkg.yml         | 3 +++
 hw/bsp/nucleo-f401re/pkg.yml       | 3 +++
 hw/bsp/rb-nano2/pkg.yml            | 3 +++
 hw/bsp/stm32f4discovery/pkg.yml    | 3 +++
 6 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1f227f41/hw/bsp/arduino_primo_nrf52/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/pkg.yml b/hw/bsp/arduino_primo_nrf52/pkg.yml
index 43312c5..5ff1c14 100644
--- a/hw/bsp/arduino_primo_nrf52/pkg.yml
+++ b/hw/bsp/arduino_primo_nrf52/pkg.yml
@@ -79,6 +79,9 @@ pkg.cflags:
     - '-DUART0_ENABLED=1'
     - '-DWDT_ENABLED=1'
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - hw/mcu/nordic/nrf52xxx
     - libc/baselibc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1f227f41/hw/bsp/bmd300eval/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/bmd300eval/pkg.yml b/hw/bsp/bmd300eval/pkg.yml
index eb5cb64..8c498a8 100644
--- a/hw/bsp/bmd300eval/pkg.yml
+++ b/hw/bsp/bmd300eval/pkg.yml
@@ -79,6 +79,9 @@ pkg.cflags:
     - '-DUART0_ENABLED=1'
     - '-DWDT_ENABLED=1'
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - hw/mcu/nordic/nrf52xxx
     - libc/baselibc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1f227f41/hw/bsp/nrf52840pdk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52840pdk/pkg.yml b/hw/bsp/nrf52840pdk/pkg.yml
index b0e599c..dcb928c 100644
--- a/hw/bsp/nrf52840pdk/pkg.yml
+++ b/hw/bsp/nrf52840pdk/pkg.yml
@@ -78,6 +78,9 @@ pkg.cflags:
     - '-DUART0_ENABLED=1'
     - '-DWDT_ENABLED=1'
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - boot/bootutil
     - hw/mcu/nordic/nrf52xxx

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1f227f41/hw/bsp/nucleo-f401re/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nucleo-f401re/pkg.yml b/hw/bsp/nucleo-f401re/pkg.yml
index 1bd6ef7..5974e99 100644
--- a/hw/bsp/nucleo-f401re/pkg.yml
+++ b/hw/bsp/nucleo-f401re/pkg.yml
@@ -30,6 +30,9 @@ pkg.keywords:
 pkg.cflags:
     - -DSTM32F401xE
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - hw/mcu/stm/stm32f4xx
     - libc/baselibc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1f227f41/hw/bsp/rb-nano2/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/rb-nano2/pkg.yml b/hw/bsp/rb-nano2/pkg.yml
index 5967841..5a5bb88 100644
--- a/hw/bsp/rb-nano2/pkg.yml
+++ b/hw/bsp/rb-nano2/pkg.yml
@@ -79,6 +79,9 @@ pkg.cflags:
     - '-DUART0_ENABLED=1'
     - '-DWDT_ENABLED=1'
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - hw/mcu/nordic/nrf52xxx
     - libc/baselibc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1f227f41/hw/bsp/stm32f4discovery/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f4discovery/pkg.yml b/hw/bsp/stm32f4discovery/pkg.yml
index 77178f7..09b5cf7 100644
--- a/hw/bsp/stm32f4discovery/pkg.yml
+++ b/hw/bsp/stm32f4discovery/pkg.yml
@@ -29,6 +29,9 @@ pkg.keywords:
 
 pkg.cflags: -DSTM32F407xx
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - hw/mcu/stm/stm32f4xx
     - libc/baselibc


[2/5] incubator-mynewt-core git commit: MYNEWT-581; set compiler flags to use FPU when HARDFLOAT is set.

Posted by ma...@apache.org.
MYNEWT-581; set compiler flags to use FPU when HARDFLOAT is set.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/522d97b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/522d97b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/522d97b6

Branch: refs/heads/develop
Commit: 522d97b671b02b12ba0bb45c067b38a5cce5b26e
Parents: d557a92
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Feb 7 13:28:36 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Feb 7 13:28:36 2017 -0800

----------------------------------------------------------------------
 hw/bsp/frdm-k64f/pkg.yml                  | 4 +++-
 hw/bsp/nrf52dk/pkg.yml                    | 3 +++
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/522d97b6/hw/bsp/frdm-k64f/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/frdm-k64f/pkg.yml b/hw/bsp/frdm-k64f/pkg.yml
index 24d337f..a8dd573 100644
--- a/hw/bsp/frdm-k64f/pkg.yml
+++ b/hw/bsp/frdm-k64f/pkg.yml
@@ -27,7 +27,6 @@ pkg.keywords:
 pkg.cflags:
     - -DDEBUG
     - -fno-builtin -fno-common -ffreestanding
-    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
     - -DCPU_MK64FN1M0VMD12
     - -DPRINTF_FLOAT_ENABLE=0
     - -DSCANF_FLOAT_ENABLE=0
@@ -39,6 +38,9 @@ pkg.cflags:
     - -Wl,--defsym=__ram_vector_table__=1
     - -D__STARTUP_CLEAR_BSS
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - hw/mcu/nxp/MK64F12
     - libc/baselibc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/522d97b6/hw/bsp/nrf52dk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/pkg.yml b/hw/bsp/nrf52dk/pkg.yml
index 2dd56c5..a2bb7c2 100644
--- a/hw/bsp/nrf52dk/pkg.yml
+++ b/hw/bsp/nrf52dk/pkg.yml
@@ -78,6 +78,9 @@ pkg.cflags:
     - '-DUART0_ENABLED=1'
     - '-DWDT_ENABLED=1'
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - hw/mcu/nordic/nrf52xxx
     - libc/baselibc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/522d97b6/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
index 99daebe..7aefaab 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
@@ -31,6 +31,9 @@ pkg.cflags:
     # STM SDK files require these defines.
     - '-DSTM32F407xx'
 
+pkg.cflags.HARDFLOAT:
+    - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
 pkg.deps:
     - hw/mcu/stm/stm32f4xx
     - libc/baselibc


[3/5] incubator-mynewt-core git commit: MYNEWT-581; kernel/os - deal with extended frames when calculating sp for corefile.

Posted by ma...@apache.org.
MYNEWT-581; kernel/os - deal with extended frames when calculating
sp for corefile.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f5d48ad6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f5d48ad6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f5d48ad6

Branch: refs/heads/develop
Commit: f5d48ad634a01294757b88d27aa213e7bf9ddaeb
Parents: 522d97b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Feb 7 17:53:10 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Feb 7 17:53:10 2017 -0800

----------------------------------------------------------------------
 kernel/os/src/arch/cortex_m4/os_fault.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d48ad6/kernel/os/src/arch/cortex_m4/os_fault.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/cortex_m4/os_fault.c b/kernel/os/src/arch/cortex_m4/os_fault.c
index 8bd881f..f1ddc00 100644
--- a/kernel/os/src/arch/cortex_m4/os_fault.c
+++ b/kernel/os/src/arch/cortex_m4/os_fault.c
@@ -6,7 +6,7 @@
  * 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,
@@ -93,14 +93,26 @@ trap_to_coredump(struct trap_frame *tf, struct coredump_regs *regs)
     /*
      * SP just before exception for the coredump.
      * See ARMv7-M Architecture Ref Manual, sections B1.5.6 - B1.5.8
-     * SP is adjusted by 0x20.
-     * If SCB->CCR.STKALIGN is set, SP is aligned to 8-byte boundary on
-     * exception entry.
+     * If floating point registers were pushed to stack, SP is adjusted
+     * by 0x68.
+     * Otherwise, SP is adjusted by 0x20.
+     * If SCB->CCR.STKALIGN is set, or fpu is active, SP is aligned to
+     * 8-byte boundary on exception entry.
      * If this alignment adjustment happened, xPSR will have bit 9 set.
      */
-    regs->sp = ((uint32_t)tf->ef) + 0x20;
-    if ((SCB->CCR & SCB_CCR_STKALIGN_Msk) & tf->ef->psr & (1 << 9)) {
-        regs->sp += 4;
+    if ((tf->lr & 0x10) == 0) {
+        /*
+         * Extended frame
+         */
+        regs->sp = ((uint32_t)tf->ef) + 0x68;
+        if (tf->ef->psr & (1 << 9)) {
+            regs->sp += 4;
+        }
+    } else {
+        regs->sp = ((uint32_t)tf->ef) + 0x20;
+        if ((SCB->CCR & SCB_CCR_STKALIGN_Msk) & tf->ef->psr & (1 << 9)) {
+            regs->sp += 4;
+        }
     }
     regs->lr = tf->ef->lr;
     regs->pc = tf->ef->pc;


[4/5] incubator-mynewt-core git commit: kernel/os; document the purpose of OS_COREDUMP.

Posted by ma...@apache.org.
kernel/os; document the purpose of OS_COREDUMP.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4e0e9010
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4e0e9010
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4e0e9010

Branch: refs/heads/develop
Commit: 4e0e9010b507fe42b42d1fe0d3d32deb4769f326
Parents: f5d48ad
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Feb 7 18:12:30 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Feb 7 18:12:30 2017 -0800

----------------------------------------------------------------------
 kernel/os/syscfg.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4e0e9010/kernel/os/syscfg.yml
----------------------------------------------------------------------
diff --git a/kernel/os/syscfg.yml b/kernel/os/syscfg.yml
index 0a6f219..a45fc96 100644
--- a/kernel/os/syscfg.yml
+++ b/kernel/os/syscfg.yml
@@ -31,7 +31,7 @@ syscfg.defs:
         restrictions:
             - SHELL_TASK
     OS_COREDUMP:
-        description: 'TBD'
+        description: 'Attempt to dump corefile when system crashes'
         value: 0
     OS_SCHEDULING:
         description: 'Whether OS will be started or not'