From e2949d0dcfff6be1d03cbdf544464e9ddfc5b4e5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 13 Sep 2019 07:22:00 -0600 Subject: [PATCH] boards/arm/stm32/axoloti, omnibusf4, and stm32f4discovery: If CONFIG_SCHED_CRITMONITOR is selected, then make sure that ITM and DWT resources are enabled before accessing ITM and DWT registers. By default, these registers are disabled. Suggested by Juha Niskanen. --- TODO | 2 ++ arch/arm/src/kinetis/kinetis_usbdev.c | 2 +- boards/arm/stm32/axoloti/src/stm32_boot.c | 5 +++++ boards/arm/stm32/omnibusf4/src/stm32_boot.c | 5 +++++ boards/arm/stm32/stm32f4discovery/src/stm32_boot.c | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 289faee022..599e2852d8 100644 --- a/TODO +++ b/TODO @@ -940,6 +940,8 @@ o Kernel/Protected Build -------- ---------------------------------------------- mkrd ramdisk_register() + See http://www.nuttx.org/doku.php?id=wiki:howtos:protected-ramdisk + Status: Open Priority: Medium/High -- the kernel build configuration is not fully fielded yet. diff --git a/arch/arm/src/kinetis/kinetis_usbdev.c b/arch/arm/src/kinetis/kinetis_usbdev.c index c3a668592a..6707492fa8 100644 --- a/arch/arm/src/kinetis/kinetis_usbdev.c +++ b/arch/arm/src/kinetis/kinetis_usbdev.c @@ -1582,7 +1582,7 @@ static int khci_rdsetup(struct khci_ep_s *privep, uint8_t *dest, int readlen) * in order to improve performance. * * Note that we NULLify the BDT OUT entries. This is so that we can tell - * that the BDT readlly available. No, it is not sufficient to look at the + * that the BDT readily available. No, it is not sufficient to look at the * UOWN bit. If UOWN==0, then the transfer has been completed BUT it may * not yet have been processed. But a completely NULLified BDT is a sure * indication diff --git a/boards/arm/stm32/axoloti/src/stm32_boot.c b/boards/arm/stm32/axoloti/src/stm32_boot.c index b5e54bb271..418f60dcd5 100644 --- a/boards/arm/stm32/axoloti/src/stm32_boot.c +++ b/boards/arm/stm32/axoloti/src/stm32_boot.c @@ -45,6 +45,7 @@ #include #include "up_arch.h" +#include "nvic.h" #include "itm.h" #include "stm32.h" @@ -68,6 +69,10 @@ void stm32_boardinitialize(void) { #ifdef CONFIG_SCHED_CRITMONITOR + /* Enable ITM and DWT resources, if not left enabled by debugger. */ + + modifyreg32(NVIC_DEMCR, 0, NVIC_DEMCR_TRCENA); + /* Make sure the high speed cycle counter is running. It will be started * automatically only if a debugger is connected. */ diff --git a/boards/arm/stm32/omnibusf4/src/stm32_boot.c b/boards/arm/stm32/omnibusf4/src/stm32_boot.c index e39f1a571d..37de061c59 100644 --- a/boards/arm/stm32/omnibusf4/src/stm32_boot.c +++ b/boards/arm/stm32/omnibusf4/src/stm32_boot.c @@ -47,6 +47,7 @@ #include #include "up_arch.h" +#include "nvic.h" #include "itm.h" #include "stm32.h" @@ -70,6 +71,10 @@ void stm32_boardinitialize(void) { #ifdef CONFIG_SCHED_CRITMONITOR + /* Enable ITM and DWT resources, if not left enabled by debugger. */ + + modifyreg32(NVIC_DEMCR, 0, NVIC_DEMCR_TRCENA); + /* Make sure the high speed cycle counter is running. It will be started * automatically only if a debugger is connected. */ diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_boot.c b/boards/arm/stm32/stm32f4discovery/src/stm32_boot.c index 0bf7104266..c604bb7454 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_boot.c +++ b/boards/arm/stm32/stm32f4discovery/src/stm32_boot.c @@ -45,6 +45,7 @@ #include #include "up_arch.h" +#include "nvic.h" #include "itm.h" #include "stm32.h" @@ -68,6 +69,10 @@ void stm32_boardinitialize(void) { #ifdef CONFIG_SCHED_CRITMONITOR + /* Enable ITM and DWT resources, if not left enabled by debugger. */ + + modifyreg32(NVIC_DEMCR, 0, NVIC_DEMCR_TRCENA); + /* Make sure the high speed cycle counter is running. It will be started * automatically only if a debugger is connected. */