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 2015/10/30 20:52:48 UTC
incubator-mynewt-larva git commit: Make the system restart happen via
system_reset(). For Cortex,
drop into debugger (if present) before doing system reset.
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master 209290bfa -> 0c7295431
Make the system restart happen via system_reset(). For Cortex, drop
into debugger (if present) before doing system reset.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/0c729543
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/0c729543
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/0c729543
Branch: refs/heads/master
Commit: 0c7295431119e9c3d2f6f99c971cbc3d2f4c6e07
Parents: 209290b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Oct 30 12:51:41 2015 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Oct 30 12:51:41 2015 -0700
----------------------------------------------------------------------
hw/bsp/nrf52pdk/src/libc_stubs.c | 3 ++-
hw/bsp/nrf52pdk/src/os_bsp.c | 4 +--
.../olimex_stm32-e407_devboard/src/libc_stubs.c | 3 ++-
hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c | 4 +--
hw/bsp/stm32f3discovery/src/libc_stubs.c | 4 ++-
hw/bsp/stm32f3discovery/src/os_bsp.c | 6 ++---
hw/hal/include/hal/hal_system.h | 2 +-
hw/mcu/native/src/hal_system.c | 4 ++-
hw/mcu/nordic/nrf52xxx/src/hal_system.c | 27 ++++++++++++++++++++
hw/mcu/stm/stm32f3xx/src/hal_system.c | 27 ++++++++++++++++++++
hw/mcu/stm/stm32f4xx/src/hal_system.c | 10 +++++---
libs/os/src/arch/cortex_m4/os_fault.c | 5 ++--
12 files changed, 81 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/bsp/nrf52pdk/src/libc_stubs.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/src/libc_stubs.c b/hw/bsp/nrf52pdk/src/libc_stubs.c
index 450b5ec..cc52848 100644
--- a/hw/bsp/nrf52pdk/src/libc_stubs.c
+++ b/hw/bsp/nrf52pdk/src/libc_stubs.c
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <hal/hal_system.h>
void * _sbrk(int c);
int _close(int fd);
@@ -41,7 +42,7 @@ _fstat(int fd, void *s)
void
_exit(int s)
{
- while (1) {}
+ system_reset();
}
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/bsp/nrf52pdk/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/src/os_bsp.c b/hw/bsp/nrf52pdk/src/os_bsp.c
index 1756448..833cfb9 100644
--- a/hw/bsp/nrf52pdk/src/os_bsp.c
+++ b/hw/bsp/nrf52pdk/src/os_bsp.c
@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <stddef.h>
-
void *_sbrk(int incr);
+void _close(int fd);
void
os_bsp_init(void)
@@ -24,4 +23,5 @@ os_bsp_init(void)
* XXX this reference is here to keep this function in.
*/
_sbrk(0);
+ _close(0);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/bsp/olimex_stm32-e407_devboard/src/libc_stubs.c
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/libc_stubs.c b/hw/bsp/olimex_stm32-e407_devboard/src/libc_stubs.c
index 450b5ec..cc52848 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/libc_stubs.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/libc_stubs.c
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <hal/hal_system.h>
void * _sbrk(int c);
int _close(int fd);
@@ -41,7 +42,7 @@ _fstat(int fd, void *s)
void
_exit(int s)
{
- while (1) {}
+ system_reset();
}
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
index bb8a0ed..383173a 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <stddef.h>
-
void *_sbrk(int incr);
+void _close(int fd);
void
os_bsp_init(void)
@@ -24,6 +23,7 @@ os_bsp_init(void)
* XXX this reference is here to keep this function in.
*/
_sbrk(0);
+ _close(0);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/bsp/stm32f3discovery/src/libc_stubs.c
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/src/libc_stubs.c b/hw/bsp/stm32f3discovery/src/libc_stubs.c
index 0d2ff7e..cc52848 100644
--- a/hw/bsp/stm32f3discovery/src/libc_stubs.c
+++ b/hw/bsp/stm32f3discovery/src/libc_stubs.c
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <hal/hal_system.h>
+
void * _sbrk(int c);
int _close(int fd);
int _fstat(int fd, void *s);
@@ -40,7 +42,7 @@ _fstat(int fd, void *s)
void
_exit(int s)
{
- while (1) {}
+ system_reset();
}
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/bsp/stm32f3discovery/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/src/os_bsp.c b/hw/bsp/stm32f3discovery/src/os_bsp.c
index 4bd2614..865b804 100644
--- a/hw/bsp/stm32f3discovery/src/os_bsp.c
+++ b/hw/bsp/stm32f3discovery/src/os_bsp.c
@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <stddef.h>
-
void *_sbrk(int incr);
+void _close(int fd);
void
os_bsp_init(void)
{
/*
- * XXX this reference is here to keep this function in so libc can find it.
+ * XXX these references are here to keep the functions in for libc to find.
*/
_sbrk(0);
+ _close(0);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/hal/include/hal/hal_system.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_system.h b/hw/hal/include/hal/hal_system.h
index 3d5569c..19f5ed1 100644
--- a/hw/hal/include/hal/hal_system.h
+++ b/hw/hal/include/hal/hal_system.h
@@ -17,6 +17,6 @@
#ifndef H_HAL_SYSTEM_
#define H_HAL_SYSTEM_
-void system_reset(void);
+void system_reset(void) __attribute((noreturn));
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/mcu/native/src/hal_system.c
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/hal_system.c b/hw/mcu/native/src/hal_system.c
index 00a981e..230faa2 100644
--- a/hw/mcu/native/src/hal_system.c
+++ b/hw/mcu/native/src/hal_system.c
@@ -18,4 +18,6 @@
void
system_reset(void)
-{ }
+{
+ while(1);
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/mcu/nordic/nrf52xxx/src/hal_system.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_system.c b/hw/mcu/nordic/nrf52xxx/src/hal_system.c
new file mode 100644
index 0000000..37ebd6e
--- /dev/null
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_system.c
@@ -0,0 +1,27 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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.
+ */
+
+#include <mcu/cortex_m4.h>
+#include "hal/hal_system.h"
+
+void
+system_reset(void)
+{
+ while (1) {
+ asm("bkpt");
+ NVIC_SystemReset();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/mcu/stm/stm32f3xx/src/hal_system.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f3xx/src/hal_system.c b/hw/mcu/stm/stm32f3xx/src/hal_system.c
new file mode 100644
index 0000000..8329f7f
--- /dev/null
+++ b/hw/mcu/stm/stm32f3xx/src/hal_system.c
@@ -0,0 +1,27 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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.
+ */
+#include <mcu/cortex_m4.h>
+#include "hal/hal_system.h"
+
+void
+system_reset(void)
+{
+ while (1) {
+ asm("bkpt");
+ NVIC_SystemReset();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/hw/mcu/stm/stm32f4xx/src/hal_system.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_system.c b/hw/mcu/stm/stm32f4xx/src/hal_system.c
index 81befad..2199024 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_system.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_system.c
@@ -4,7 +4,7 @@
* Licensed 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
@@ -14,14 +14,16 @@
* limitations under the License.
*/
-#include "mcu/stm32f407xx.h"
-#include "mcu/stm32f4xx_hal_def.h"
+#include <mcu/cortex_m4.h>
#include "hal/hal_system.h"
void
system_reset(void)
{
- NVIC_SystemReset();
+ while (1) {
+ asm("bkpt");
+ NVIC_SystemReset();
+ }
}
uint32_t
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0c729543/libs/os/src/arch/cortex_m4/os_fault.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/cortex_m4/os_fault.c b/libs/os/src/arch/cortex_m4/os_fault.c
index e542b98..b10760e 100644
--- a/libs/os/src/arch/cortex_m4/os_fault.c
+++ b/libs/os/src/arch/cortex_m4/os_fault.c
@@ -15,6 +15,7 @@
*/
#include <console/console.h>
+#include <hal/hal_system.h>
#include "os/os.h"
#include <stdint.h>
@@ -36,7 +37,7 @@ __assert_func(const char *file, int line, const char *func, const char *e)
os_die_module = file;
console_blocking_mode();
console_printf("Assert '%s; failed in %s:%d\n", e, file, line);
- _exit(1);
+ system_reset();
}
struct exception_frame {
@@ -80,5 +81,5 @@ os_default_irq(struct trap_frame *tf)
console_printf("ICSR:%8.8x HFSR:%8.8x CFSR:%8.8x",
SCB->ICSR, SCB->HFSR, SCB->CFSR);
console_printf("BFAR:%8.8x MMFAR:%8.8x", SCB->BFAR, SCB->MMFAR);
- while(1);
+ system_reset();
}