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

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit b92dfd33026647d09a8b650c04c277d2a54497b4
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Fri Oct 4 11:28:51 2024 +0200

    hw/bsp: Disable NVIC interrupts in all hal_bsp_deinit
    
    For CortexM devices add call to Cortex_DisableAll() that
    will disable all interrupts before control is passed from
    bootloader to application
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/bsp/ada_feather_nrf52/src/hal_bsp.c          | 2 ++
 hw/bsp/ada_feather_stm32f405/src/hal_bsp.c      | 2 ++
 hw/bsp/arduino_primo_nrf52/src/hal_bsp.c        | 2 ++
 hw/bsp/arduino_zero/src/hal_bsp.c               | 3 ++-
 hw/bsp/b-l072z-lrwan1/src/hal_bsp.c             | 2 ++
 hw/bsp/b-l475e-iot01a/src/hal_bsp.c             | 2 ++
 hw/bsp/bbc_microbit/src/hal_bsp.c               | 2 ++
 hw/bsp/black_vet6/src/hal_bsp.c                 | 3 +++
 hw/bsp/ble400/src/hal_bsp.c                     | 2 ++
 hw/bsp/bluepill/src/hal_bsp.c                   | 3 +++
 hw/bsp/bmd200/src/hal_bsp.c                     | 2 ++
 hw/bsp/bmd300eval/src/hal_bsp.c                 | 2 ++
 hw/bsp/calliope_mini/src/hal_bsp.c              | 2 ++
 hw/bsp/dialog_da14695-dk-usb/src/hal_bsp.c      | 2 ++
 hw/bsp/dialog_da1469x-dk-pro/src/hal_bsp.c      | 2 ++
 hw/bsp/dwm1001-dev/src/hal_bsp.c                | 2 ++
 hw/bsp/fanstel-ev-bt840/src/hal_bsp.c           | 2 ++
 hw/bsp/frdm-k64f/src/hal_bsp.c                  | 2 ++
 hw/bsp/lpcxpresso55s28/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_pca10028-16k/src/hal_bsp.c        | 2 ++
 hw/bsp/nordic_pca10028/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_pca10040/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_pca10056/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_pca10059/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_pca10090/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_pca10095/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_pca10095_net/src/hal_bsp.c        | 2 ++
 hw/bsp/nordic_pca10121/net/src/hal_bsp.c        | 2 ++
 hw/bsp/nordic_pca10121/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_pca20020/src/hal_bsp.c            | 2 ++
 hw/bsp/nordic_thingy53/src/hal_bsp.c            | 2 ++
 hw/bsp/nrf51-arduino_101/src/hal_bsp.c          | 2 ++
 hw/bsp/nrf51-blenano/src/hal_bsp.c              | 2 ++
 hw/bsp/nucleo-f030r8/src/hal_bsp.c              | 2 ++
 hw/bsp/nucleo-f072rb/src/hal_bsp.c              | 2 ++
 hw/bsp/nucleo-f103rb/src/hal_bsp.c              | 3 +++
 hw/bsp/nucleo-f303re/src/hal_bsp.c              | 2 ++
 hw/bsp/nucleo-f401re/src/hal_bsp.c              | 3 +++
 hw/bsp/nucleo-f411re/src/hal_bsp.c              | 3 +++
 hw/bsp/nucleo-f413zh/src/hal_bsp.c              | 2 ++
 hw/bsp/nucleo-f439zi/src/hal_bsp.c              | 2 ++
 hw/bsp/nucleo-f746zg/src/hal_bsp.c              | 2 ++
 hw/bsp/nucleo-f767zi/src/hal_bsp.c              | 2 ++
 hw/bsp/nucleo-g0b1re/src/hal_bsp.c              | 3 +++
 hw/bsp/nucleo-g491re/src/hal_bsp.c              | 3 +++
 hw/bsp/nucleo-h723zg/src/hal_bsp.c              | 3 +++
 hw/bsp/nucleo-l073rz/src/hal_bsp.c              | 3 +++
 hw/bsp/nucleo-l476rg/src/hal_bsp.c              | 3 +++
 hw/bsp/nucleo-u575zi-q/src/hal_bsp.c            | 3 +++
 hw/bsp/olimex-p103/src/hal_bsp.c                | 2 ++
 hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c | 2 ++
 hw/bsp/p-nucleo-wb55-usbdongle/src/hal_bsp.c    | 3 +++
 hw/bsp/p-nucleo-wb55/src/hal_bsp.c              | 3 +++
 hw/bsp/pinetime/src/hal_bsp.c                   | 2 ++
 hw/bsp/puckjs/src/hal_bsp.c                     | 2 ++
 hw/bsp/rb-blend2/src/hal_bsp.c                  | 2 ++
 hw/bsp/rb-nano2/src/hal_bsp.c                   | 2 ++
 hw/bsp/reel_board/src/hal_bsp.c                 | 2 ++
 hw/bsp/ruuvitag_rev_b/src/hal_bsp.c             | 2 ++
 hw/bsp/stm32f3discovery/src/hal_bsp.c           | 2 ++
 hw/bsp/stm32f411discovery/src/hal_bsp.c         | 3 +++
 hw/bsp/stm32f429discovery/src/hal_bsp.c         | 2 ++
 hw/bsp/stm32f4discovery/src/hal_bsp.c           | 2 ++
 hw/bsp/stm32f7discovery/src/hal_bsp.c           | 2 ++
 hw/bsp/stm32l152discovery/src/hal_bsp.c         | 2 ++
 hw/bsp/telee02/src/hal_bsp.c                    | 2 ++
 hw/bsp/ublox_bmd_345/src/hal_bsp.c              | 2 ++
 hw/bsp/usbmkw41z/src/hal_bsp.c                  | 2 ++
 hw/bsp/vbluno51/src/hal_bsp.c                   | 2 ++
 hw/bsp/vbluno52/src/hal_bsp.c                   | 2 ++
 hw/bsp/weact_g431cb/src/hal_bsp.c               | 3 +++
 71 files changed, 157 insertions(+), 1 deletion(-)

diff --git a/hw/bsp/ada_feather_nrf52/src/hal_bsp.c 
b/hw/bsp/ada_feather_nrf52/src/hal_bsp.c
index 41e6d1f66..d49d805a1 100644
--- a/hw/bsp/ada_feather_nrf52/src/hal_bsp.c
+++ b/hw/bsp/ada_feather_nrf52/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -105,4 +106,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/ada_feather_stm32f405/src/hal_bsp.c 
b/hw/bsp/ada_feather_stm32f405/src/hal_bsp.c
index f46cae54e..1c7a0e1f8 100644
--- a/hw/bsp/ada_feather_stm32f405/src/hal_bsp.c
+++ b/hw/bsp/ada_feather_stm32f405/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -309,4 +310,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c 
b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
index 459ae7f55..2a464dd52 100644
--- a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
+++ b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
@@ -20,6 +20,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "bsp/bsp.h"
 #include "hal/hal_bsp.h"
@@ -104,4 +105,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/arduino_zero/src/hal_bsp.c 
b/hw/bsp/arduino_zero/src/hal_bsp.c
index 9f4da9171..06b9fe602 100644
--- a/hw/bsp/arduino_zero/src/hal_bsp.c
+++ b/hw/bsp/arduino_zero/src/hal_bsp.c
@@ -26,6 +26,7 @@
 #include "sysinit/sysinit.h"
 #include "mcu/samd21.h"
 #include "bsp/bsp.h"
+#include "mynewt_cm.h"
 
 /*
  * hw/mcu/atmel/samd21xx/src/sam0/drivers/tc/tc.h
@@ -213,5 +214,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
-
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/b-l072z-lrwan1/src/hal_bsp.c 
b/hw/bsp/b-l072z-lrwan1/src/hal_bsp.c
index 9d29775ab..9631831b7 100644
--- a/hw/bsp/b-l072z-lrwan1/src/hal_bsp.c
+++ b/hw/bsp/b-l072z-lrwan1/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -136,6 +137,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/b-l475e-iot01a/src/hal_bsp.c 
b/hw/bsp/b-l475e-iot01a/src/hal_bsp.c
index 9f10e78e5..cf1a8070b 100644
--- a/hw/bsp/b-l475e-iot01a/src/hal_bsp.c
+++ b/hw/bsp/b-l475e-iot01a/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -173,6 +174,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/bbc_microbit/src/hal_bsp.c 
b/hw/bsp/bbc_microbit/src/hal_bsp.c
index 52802ae41..e09a2692e 100644
--- a/hw/bsp/bbc_microbit/src/hal_bsp.c
+++ b/hw/bsp/bbc_microbit/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "hal/hal_system.h"
 #include "bsp/bsp.h"
@@ -226,4 +227,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/black_vet6/src/hal_bsp.c b/hw/bsp/black_vet6/src/hal_bsp.c
index 589b73d66..c63c10a72 100644
--- a/hw/bsp/black_vet6/src/hal_bsp.c
+++ b/hw/bsp/black_vet6/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -352,6 +353,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = RCC_AHB1ENR_CCMDATARAMEN;
     RCC->AHB2ENR = 0x0;
     RCC->AHB3ENR = 0x0;
diff --git a/hw/bsp/ble400/src/hal_bsp.c b/hw/bsp/ble400/src/hal_bsp.c
index 12405cde7..7a897d2bb 100644
--- a/hw/bsp/ble400/src/hal_bsp.c
+++ b/hw/bsp/ble400/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "hal/hal_bsp.h"
 #include "hal/hal_system.h"
 #include "mcu/nrf51_hal.h"
@@ -228,4 +229,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/bluepill/src/hal_bsp.c b/hw/bsp/bluepill/src/hal_bsp.c
index b8cced159..4161f940d 100644
--- a/hw/bsp/bluepill/src/hal_bsp.c
+++ b/hw/bsp/bluepill/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -95,6 +96,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHBENR = RCC_AHBENR_FLITFEN | RCC_AHBENR_SRAMEN;
     RCC->APB1ENR = 0;
     RCC->APB2ENR = 0;
diff --git a/hw/bsp/bmd200/src/hal_bsp.c b/hw/bsp/bmd200/src/hal_bsp.c
index 12405cde7..7a897d2bb 100644
--- a/hw/bsp/bmd200/src/hal_bsp.c
+++ b/hw/bsp/bmd200/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "hal/hal_bsp.h"
 #include "hal/hal_system.h"
 #include "mcu/nrf51_hal.h"
@@ -228,4 +229,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/bmd300eval/src/hal_bsp.c b/hw/bsp/bmd300eval/src/hal_bsp.c
index 022729629..2156debba 100644
--- a/hw/bsp/bmd300eval/src/hal_bsp.c
+++ b/hw/bsp/bmd300eval/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -105,4 +106,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/calliope_mini/src/hal_bsp.c 
b/hw/bsp/calliope_mini/src/hal_bsp.c
index a39b6136b..70f5da2f9 100644
--- a/hw/bsp/calliope_mini/src/hal_bsp.c
+++ b/hw/bsp/calliope_mini/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "hal/hal_system.h"
 #include "bsp/bsp.h"
@@ -228,4 +229,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/dialog_da14695-dk-usb/src/hal_bsp.c 
b/hw/bsp/dialog_da14695-dk-usb/src/hal_bsp.c
index f5e0ca229..58fa91f27 100644
--- a/hw/bsp/dialog_da14695-dk-usb/src/hal_bsp.c
+++ b/hw/bsp/dialog_da14695-dk-usb/src/hal_bsp.c
@@ -24,6 +24,7 @@
 #include "hal/hal_flash.h"
 #include "hal/hal_system.h"
 #include "mcu/mcu.h"
+#include "mynewt_cm.h"
 #include "mcu/da1469x_hal.h"
 #include "mcu/da1469x_periph.h"
 #include "bsp/bsp.h"
@@ -109,4 +110,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/dialog_da1469x-dk-pro/src/hal_bsp.c 
b/hw/bsp/dialog_da1469x-dk-pro/src/hal_bsp.c
index 809888a78..5509a8834 100644
--- a/hw/bsp/dialog_da1469x-dk-pro/src/hal_bsp.c
+++ b/hw/bsp/dialog_da1469x-dk-pro/src/hal_bsp.c
@@ -24,6 +24,7 @@
 #include "hal/hal_flash.h"
 #include "hal/hal_system.h"
 #include "mcu/mcu.h"
+#include "mynewt_cm.h"
 #include "mcu/da1469x_hal.h"
 #include "mcu/da1469x_periph.h"
 #include "bsp/bsp.h"
@@ -110,4 +111,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/dwm1001-dev/src/hal_bsp.c b/hw/bsp/dwm1001-dev/src/hal_bsp.c
index 3bb0c712c..2e53db04b 100644
--- a/hw/bsp/dwm1001-dev/src/hal_bsp.c
+++ b/hw/bsp/dwm1001-dev/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -106,4 +107,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/fanstel-ev-bt840/src/hal_bsp.c 
b/hw/bsp/fanstel-ev-bt840/src/hal_bsp.c
index 419466728..56f2592b3 100644
--- a/hw/bsp/fanstel-ev-bt840/src/hal_bsp.c
+++ b/hw/bsp/fanstel-ev-bt840/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -90,4 +91,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/frdm-k64f/src/hal_bsp.c b/hw/bsp/frdm-k64f/src/hal_bsp.c
index e0fe43375..bed6255cc 100644
--- a/hw/bsp/frdm-k64f/src/hal_bsp.c
+++ b/hw/bsp/frdm-k64f/src/hal_bsp.c
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 #include <stdio.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "bsp/bsp.h"
 #include "hal/hal_bsp.h"
 #include "hal/hal_flash_int.h"
@@ -270,4 +271,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/lpcxpresso55s28/src/hal_bsp.c 
b/hw/bsp/lpcxpresso55s28/src/hal_bsp.c
index 1e3953dee..42b84ee58 100644
--- a/hw/bsp/lpcxpresso55s28/src/hal_bsp.c
+++ b/hw/bsp/lpcxpresso55s28/src/hal_bsp.c
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 #include <stdio.h>
 #include <os/mynewt.h>
+#include "mynewt_cm.h"
 #include <bsp/bsp.h>
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -182,4 +183,5 @@ hal_bsp_hw_id(uint8_t *id, int max_len)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca10028-16k/src/hal_bsp.c 
b/hw/bsp/nordic_pca10028-16k/src/hal_bsp.c
index 0042519e6..6a7ff7d25 100644
--- a/hw/bsp/nordic_pca10028-16k/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10028-16k/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "hal/hal_bsp.h"
 #include "hal/hal_system.h"
 #include "mcu/nrf51_hal.h"
@@ -230,4 +231,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca10028/src/hal_bsp.c 
b/hw/bsp/nordic_pca10028/src/hal_bsp.c
index 943df0533..8e7590639 100644
--- a/hw/bsp/nordic_pca10028/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10028/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "hal/hal_bsp.h"
 #include "hal/hal_system.h"
 #include "mcu/nrf51_hal.h"
@@ -230,4 +231,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca10040/src/hal_bsp.c 
b/hw/bsp/nordic_pca10040/src/hal_bsp.c
index b33572c17..c7bd06f9c 100644
--- a/hw/bsp/nordic_pca10040/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10040/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -124,4 +125,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca10056/src/hal_bsp.c 
b/hw/bsp/nordic_pca10056/src/hal_bsp.c
index f62e287d7..5d1a289d6 100644
--- a/hw/bsp/nordic_pca10056/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10056/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -108,6 +109,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 #if MYNEWT_VAL(BSP_USE_HAL_SPI)
diff --git a/hw/bsp/nordic_pca10059/src/hal_bsp.c 
b/hw/bsp/nordic_pca10059/src/hal_bsp.c
index f62e287d7..5d1a289d6 100644
--- a/hw/bsp/nordic_pca10059/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10059/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -108,6 +109,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 #if MYNEWT_VAL(BSP_USE_HAL_SPI)
diff --git a/hw/bsp/nordic_pca10090/src/hal_bsp.c 
b/hw/bsp/nordic_pca10090/src/hal_bsp.c
index 1d88dca42..21ee9fe5e 100644
--- a/hw/bsp/nordic_pca10090/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10090/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -99,4 +100,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca10095/src/hal_bsp.c 
b/hw/bsp/nordic_pca10095/src/hal_bsp.c
index c491b9684..b52c095ae 100644
--- a/hw/bsp/nordic_pca10095/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10095/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include <os/mynewt.h>
+#include "mynewt_cm.h"
 #include <nrfx.h>
 #include <flash_map/flash_map.h>
 #include <hal/hal_bsp.h>
@@ -105,4 +106,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca10095_net/src/hal_bsp.c 
b/hw/bsp/nordic_pca10095_net/src/hal_bsp.c
index d26bce94a..7476031be 100644
--- a/hw/bsp/nordic_pca10095_net/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10095_net/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include <os/mynewt.h>
+#include "mynewt_cm.h"
 #include <nrfx.h>
 #include <flash_map/flash_map.h>
 #include <hal/hal_bsp.h>
@@ -105,4 +106,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca10121/net/src/hal_bsp.c 
b/hw/bsp/nordic_pca10121/net/src/hal_bsp.c
index d26bce94a..7476031be 100644
--- a/hw/bsp/nordic_pca10121/net/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10121/net/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include <os/mynewt.h>
+#include "mynewt_cm.h"
 #include <nrfx.h>
 #include <flash_map/flash_map.h>
 #include <hal/hal_bsp.h>
@@ -105,4 +106,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca10121/src/hal_bsp.c 
b/hw/bsp/nordic_pca10121/src/hal_bsp.c
index 68a005417..4be822e72 100644
--- a/hw/bsp/nordic_pca10121/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10121/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include <os/mynewt.h>
+#include "mynewt_cm.h"
 #include <nrfx.h>
 #include <flash_map/flash_map.h>
 #include <hal/hal_bsp.h>
@@ -119,4 +120,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_pca20020/src/hal_bsp.c 
b/hw/bsp/nordic_pca20020/src/hal_bsp.c
index 2ab8a3e4c..c9a8c90bc 100644
--- a/hw/bsp/nordic_pca20020/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca20020/src/hal_bsp.c
@@ -22,6 +22,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -165,4 +166,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nordic_thingy53/src/hal_bsp.c 
b/hw/bsp/nordic_thingy53/src/hal_bsp.c
index c491b9684..b52c095ae 100644
--- a/hw/bsp/nordic_thingy53/src/hal_bsp.c
+++ b/hw/bsp/nordic_thingy53/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include <os/mynewt.h>
+#include "mynewt_cm.h"
 #include <nrfx.h>
 #include <flash_map/flash_map.h>
 #include <hal/hal_bsp.h>
@@ -105,4 +106,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nrf51-arduino_101/src/hal_bsp.c 
b/hw/bsp/nrf51-arduino_101/src/hal_bsp.c
index 26076d650..7b3ad0069 100644
--- a/hw/bsp/nrf51-arduino_101/src/hal_bsp.c
+++ b/hw/bsp/nrf51-arduino_101/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include <mcu/nrf51_hal.h>
 #include <hal/hal_bsp.h>
@@ -228,4 +229,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nrf51-blenano/src/hal_bsp.c 
b/hw/bsp/nrf51-blenano/src/hal_bsp.c
index 5dc79ab38..6170f1c70 100644
--- a/hw/bsp/nrf51-blenano/src/hal_bsp.c
+++ b/hw/bsp/nrf51-blenano/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "hal/hal_system.h"
 #include "bsp/bsp.h"
@@ -229,4 +230,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nucleo-f030r8/src/hal_bsp.c 
b/hw/bsp/nucleo-f030r8/src/hal_bsp.c
index fab06af5c..2eea79404 100644
--- a/hw/bsp/nucleo-f030r8/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f030r8/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -126,4 +127,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nucleo-f072rb/src/hal_bsp.c 
b/hw/bsp/nucleo-f072rb/src/hal_bsp.c
index c5166f47d..33eb9d070 100644
--- a/hw/bsp/nucleo-f072rb/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f072rb/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -133,4 +134,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nucleo-f103rb/src/hal_bsp.c 
b/hw/bsp/nucleo-f103rb/src/hal_bsp.c
index 79530778b..8455bad44 100644
--- a/hw/bsp/nucleo-f103rb/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f103rb/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -143,6 +144,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHBENR = RCC_AHBENR_FLITFEN | RCC_AHBENR_SRAMEN;
     RCC->APB1ENR = 0;
     RCC->APB2ENR = 0;
diff --git a/hw/bsp/nucleo-f303re/src/hal_bsp.c 
b/hw/bsp/nucleo-f303re/src/hal_bsp.c
index 48ff5832e..459b4a316 100644
--- a/hw/bsp/nucleo-f303re/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f303re/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -135,4 +136,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/nucleo-f401re/src/hal_bsp.c 
b/hw/bsp/nucleo-f401re/src/hal_bsp.c
index 306bbd947..bbb9692f2 100644
--- a/hw/bsp/nucleo-f401re/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f401re/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -117,6 +118,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0;
     RCC->AHB2ENR = 0;
     RCC->APB1ENR = 0;
diff --git a/hw/bsp/nucleo-f411re/src/hal_bsp.c 
b/hw/bsp/nucleo-f411re/src/hal_bsp.c
index 8bd11f55d..294798eef 100644
--- a/hw/bsp/nucleo-f411re/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f411re/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -171,6 +172,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0;
     RCC->AHB2ENR = 0;
     RCC->APB1ENR = 0;
diff --git a/hw/bsp/nucleo-f413zh/src/hal_bsp.c 
b/hw/bsp/nucleo-f413zh/src/hal_bsp.c
index cac1f7c4c..bc9ead434 100644
--- a/hw/bsp/nucleo-f413zh/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f413zh/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -123,6 +124,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/nucleo-f439zi/src/hal_bsp.c 
b/hw/bsp/nucleo-f439zi/src/hal_bsp.c
index c32d53752..16e791dbb 100644
--- a/hw/bsp/nucleo-f439zi/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f439zi/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -188,6 +189,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/nucleo-f746zg/src/hal_bsp.c 
b/hw/bsp/nucleo-f746zg/src/hal_bsp.c
index 08815d447..826a73bc9 100644
--- a/hw/bsp/nucleo-f746zg/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f746zg/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -185,6 +186,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/nucleo-f767zi/src/hal_bsp.c 
b/hw/bsp/nucleo-f767zi/src/hal_bsp.c
index 8fc726600..7c9d92a12 100644
--- a/hw/bsp/nucleo-f767zi/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f767zi/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -229,6 +230,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/nucleo-g0b1re/src/hal_bsp.c 
b/hw/bsp/nucleo-g0b1re/src/hal_bsp.c
index 3d2062730..c87ddb9a0 100644
--- a/hw/bsp/nucleo-g0b1re/src/hal_bsp.c
+++ b/hw/bsp/nucleo-g0b1re/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "spiflash/spiflash.h"
 
 #include <hal/hal_bsp.h>
@@ -254,6 +255,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHBENR = 0x00000100;
     RCC->APBENR1 = 0x00000000;
     RCC->APBENR2 = 0x00000000;
diff --git a/hw/bsp/nucleo-g491re/src/hal_bsp.c 
b/hw/bsp/nucleo-g491re/src/hal_bsp.c
index 8384d2322..53fe12429 100644
--- a/hw/bsp/nucleo-g491re/src/hal_bsp.c
+++ b/hw/bsp/nucleo-g491re/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "spiflash/spiflash.h"
 
 #include <hal/hal_bsp.h>
@@ -211,6 +212,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0x00000100;
     RCC->AHB2ENR = 0x00000000;
     RCC->AHB3ENR = 0x80000000;
diff --git a/hw/bsp/nucleo-h723zg/src/hal_bsp.c 
b/hw/bsp/nucleo-h723zg/src/hal_bsp.c
index 6cbf95d1f..5c1073f0b 100644
--- a/hw/bsp/nucleo-h723zg/src/hal_bsp.c
+++ b/hw/bsp/nucleo-h723zg/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "spiflash/spiflash.h"
 
 #include <hal/hal_bsp.h>
@@ -237,6 +238,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0;
     RCC->AHB2ENR = 0;
     RCC->AHB3ENR = 0;
diff --git a/hw/bsp/nucleo-l073rz/src/hal_bsp.c 
b/hw/bsp/nucleo-l073rz/src/hal_bsp.c
index d9f07db3b..9880d7947 100644
--- a/hw/bsp/nucleo-l073rz/src/hal_bsp.c
+++ b/hw/bsp/nucleo-l073rz/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -164,6 +165,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHBENR = 0x00000100;
     RCC->APB1ENR = 0;
     RCC->APB2ENR = 0;
diff --git a/hw/bsp/nucleo-l476rg/src/hal_bsp.c 
b/hw/bsp/nucleo-l476rg/src/hal_bsp.c
index cd3157d16..9020ccb2c 100644
--- a/hw/bsp/nucleo-l476rg/src/hal_bsp.c
+++ b/hw/bsp/nucleo-l476rg/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -147,6 +148,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = RCC_AHB1ENR_FLASHEN;
     RCC->AHB2ENR = 0;
     RCC->AHB3ENR = 0;
diff --git a/hw/bsp/nucleo-u575zi-q/src/hal_bsp.c 
b/hw/bsp/nucleo-u575zi-q/src/hal_bsp.c
index 506de0807..0de8f1c9c 100644
--- a/hw/bsp/nucleo-u575zi-q/src/hal_bsp.c
+++ b/hw/bsp/nucleo-u575zi-q/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "spiflash/spiflash.h"
 
 #include <hal/hal_bsp.h>
@@ -203,6 +204,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0xD0000100;
     RCC->AHB2ENR1 = 0xC0000000;
     RCC->AHB2ENR2 = 0;
diff --git a/hw/bsp/olimex-p103/src/hal_bsp.c b/hw/bsp/olimex-p103/src/hal_bsp.c
index 59a2d9567..91336da09 100644
--- a/hw/bsp/olimex-p103/src/hal_bsp.c
+++ b/hw/bsp/olimex-p103/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -95,6 +96,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c 
b/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
index 297b2b0a3..02cd545d1 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -309,4 +310,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/p-nucleo-wb55-usbdongle/src/hal_bsp.c 
b/hw/bsp/p-nucleo-wb55-usbdongle/src/hal_bsp.c
index 7f276cfb0..13db4f60e 100644
--- a/hw/bsp/p-nucleo-wb55-usbdongle/src/hal_bsp.c
+++ b/hw/bsp/p-nucleo-wb55-usbdongle/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -120,6 +121,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0;
     RCC->AHB2ENR = 0;
     RCC->AHB3ENR = RCC_AHB3ENR_FLASHEN | RCC_AHB3ENR_HSEMEN;
diff --git a/hw/bsp/p-nucleo-wb55/src/hal_bsp.c 
b/hw/bsp/p-nucleo-wb55/src/hal_bsp.c
index 6e289b1c2..8c2caaf08 100644
--- a/hw/bsp/p-nucleo-wb55/src/hal_bsp.c
+++ b/hw/bsp/p-nucleo-wb55/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -95,6 +96,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0;
     RCC->AHB2ENR = 0;
     RCC->AHB3ENR = RCC_AHB3ENR_FLASHEN | RCC_AHB3ENR_HSEMEN;
diff --git a/hw/bsp/pinetime/src/hal_bsp.c b/hw/bsp/pinetime/src/hal_bsp.c
index 723916cb7..66bfe5bcb 100644
--- a/hw/bsp/pinetime/src/hal_bsp.c
+++ b/hw/bsp/pinetime/src/hal_bsp.c
@@ -27,6 +27,7 @@
 #include "hal/hal_bsp.h"
 #include "os/os.h"
 #include "bsp/bsp.h"
+#include "mynewt_cm.h"
 #include "mcu/nrf52_hal.h"
 #include "mcu/nrf52_periph.h"
 #if MYNEWT_VAL(BSP_CHARGER)
@@ -240,4 +241,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/puckjs/src/hal_bsp.c b/hw/bsp/puckjs/src/hal_bsp.c
index 3bb0c712c..2e53db04b 100644
--- a/hw/bsp/puckjs/src/hal_bsp.c
+++ b/hw/bsp/puckjs/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -106,4 +107,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/rb-blend2/src/hal_bsp.c b/hw/bsp/rb-blend2/src/hal_bsp.c
index a2a8ea8e0..9cb5ffec1 100644
--- a/hw/bsp/rb-blend2/src/hal_bsp.c
+++ b/hw/bsp/rb-blend2/src/hal_bsp.c
@@ -20,6 +20,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "bsp/bsp.h"
 #include "hal/hal_bsp.h"
@@ -105,4 +106,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/rb-nano2/src/hal_bsp.c b/hw/bsp/rb-nano2/src/hal_bsp.c
index 00c026e28..2d0e4aff0 100644
--- a/hw/bsp/rb-nano2/src/hal_bsp.c
+++ b/hw/bsp/rb-nano2/src/hal_bsp.c
@@ -20,6 +20,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "bsp/bsp.h"
 #include "hal/hal_bsp.h"
@@ -104,4 +105,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/reel_board/src/hal_bsp.c b/hw/bsp/reel_board/src/hal_bsp.c
index 51c56b320..82c75c797 100644
--- a/hw/bsp/reel_board/src/hal_bsp.c
+++ b/hw/bsp/reel_board/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -98,4 +99,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/ruuvitag_rev_b/src/hal_bsp.c 
b/hw/bsp/ruuvitag_rev_b/src/hal_bsp.c
index 837f0559e..337a199fc 100644
--- a/hw/bsp/ruuvitag_rev_b/src/hal_bsp.c
+++ b/hw/bsp/ruuvitag_rev_b/src/hal_bsp.c
@@ -22,6 +22,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -214,4 +215,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/stm32f3discovery/src/hal_bsp.c 
b/hw/bsp/stm32f3discovery/src/hal_bsp.c
index 0d28425fc..eee167cfd 100644
--- a/hw/bsp/stm32f3discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f3discovery/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -177,4 +178,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/stm32f411discovery/src/hal_bsp.c 
b/hw/bsp/stm32f411discovery/src/hal_bsp.c
index b7a8681fe..14fde03b1 100644
--- a/hw/bsp/stm32f411discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f411discovery/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -171,6 +172,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0;
     RCC->AHB2ENR = 0;
     RCC->APB1ENR = 0;
diff --git a/hw/bsp/stm32f429discovery/src/hal_bsp.c 
b/hw/bsp/stm32f429discovery/src/hal_bsp.c
index 0c6d5c9f3..638e5f792 100644
--- a/hw/bsp/stm32f429discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f429discovery/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -126,6 +127,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/stm32f4discovery/src/hal_bsp.c 
b/hw/bsp/stm32f4discovery/src/hal_bsp.c
index 9fc921c1d..3741c7ec2 100644
--- a/hw/bsp/stm32f4discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f4discovery/src/hal_bsp.c
@@ -21,6 +21,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -144,6 +145,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/stm32f7discovery/src/hal_bsp.c 
b/hw/bsp/stm32f7discovery/src/hal_bsp.c
index 5bb0d5bd8..444b36676 100644
--- a/hw/bsp/stm32f7discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f7discovery/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -163,6 +164,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/stm32l152discovery/src/hal_bsp.c 
b/hw/bsp/stm32l152discovery/src/hal_bsp.c
index 245530961..505580ae8 100644
--- a/hw/bsp/stm32l152discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32l152discovery/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -95,6 +96,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 /**
diff --git a/hw/bsp/telee02/src/hal_bsp.c b/hw/bsp/telee02/src/hal_bsp.c
index 4c32cda3e..ce0f4e1f0 100644
--- a/hw/bsp/telee02/src/hal_bsp.c
+++ b/hw/bsp/telee02/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -121,6 +122,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 #if MYNEWT_VAL(LORA_NODE)
diff --git a/hw/bsp/ublox_bmd_345/src/hal_bsp.c 
b/hw/bsp/ublox_bmd_345/src/hal_bsp.c
index 26bcf4981..43f06bf26 100644
--- a/hw/bsp/ublox_bmd_345/src/hal_bsp.c
+++ b/hw/bsp/ublox_bmd_345/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -116,6 +117,7 @@ void tp_val(uint8_t v)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 #if MYNEWT_VAL(BSP_USE_HAL_SPI)
diff --git a/hw/bsp/usbmkw41z/src/hal_bsp.c b/hw/bsp/usbmkw41z/src/hal_bsp.c
index fab0afbb6..ac743407c 100644
--- a/hw/bsp/usbmkw41z/src/hal_bsp.c
+++ b/hw/bsp/usbmkw41z/src/hal_bsp.c
@@ -24,6 +24,7 @@
 #include "bsp/bsp.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_flash.h"
+#include "mynewt_cm.h"
 
 /*
  * What memory to include in coredump.
@@ -90,4 +91,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/vbluno51/src/hal_bsp.c b/hw/bsp/vbluno51/src/hal_bsp.c
index 7a2eee7bc..63119e4d8 100644
--- a/hw/bsp/vbluno51/src/hal_bsp.c
+++ b/hw/bsp/vbluno51/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "hal/hal_bsp.h"
 #include "hal/hal_system.h"
 #include "mcu/nrf51_hal.h"
@@ -228,4 +229,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/vbluno52/src/hal_bsp.c b/hw/bsp/vbluno52/src/hal_bsp.c
index 3bb0c712c..2e53db04b 100644
--- a/hw/bsp/vbluno52/src/hal_bsp.c
+++ b/hw/bsp/vbluno52/src/hal_bsp.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <assert.h>
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 #include "nrfx.h"
 #include "flash_map/flash_map.h"
 #include "hal/hal_bsp.h"
@@ -106,4 +107,5 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
diff --git a/hw/bsp/weact_g431cb/src/hal_bsp.c 
b/hw/bsp/weact_g431cb/src/hal_bsp.c
index 826f462fb..1dc95719b 100644
--- a/hw/bsp/weact_g431cb/src/hal_bsp.c
+++ b/hw/bsp/weact_g431cb/src/hal_bsp.c
@@ -20,6 +20,7 @@
 
 #include "bsp/bsp.h"
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
@@ -169,6 +170,8 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
+
     RCC->AHB1ENR = 0x00000100;
     RCC->AHB2ENR = 0x00000000;
     RCC->AHB3ENR = 0x80000000;


Reply via email to