New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PANIC on TIM7 IRQ in timer example on armv6-m without FRAME_POINTERS #6624
Comments
stm32f072-disco:btimer defconfig diff with stm32f072-disco:nsh defconfig: Board timer initialization: diff --git a/boards/arm/stm32f0l0g0/stm32f072-discovery/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/stm32f072-discovery/src/stm32_bringup.c
index f52f9d545..fb9981ba4 100644
--- a/boards/arm/stm32f0l0g0/stm32f072-discovery/src/stm32_bringup.c
+++ b/boards/arm/stm32f0l0g0/stm32f072-discovery/src/stm32_bringup.c
@@ -30,6 +30,11 @@
#include <syslog.h>
+#ifdef CONFIG_TIMER
+#include <nuttx/irq.h>
+#include "stm32_tim.h"
+#endif
+
#include "stm32f072-discovery.h"
#ifdef CONFIG_EXAMPLES_MODBUS
@@ -80,6 +85,17 @@ int stm32_bringup(void)
}
#endif
+#if defined(CONFIG_TIMER)
+ /* Initialize the timer, at this moment it's only Basic timers 6,7 */
+
+ #if defined(CONFIG_STM32F0L0G0_TIM6)
+ ret = stm32_timer_initialize("/dev/timer6", 6);
+ #endif
+ #if defined(CONFIG_STM32F0L0G0_TIM7)
+ ret = stm32_timer_initialize("/dev/timer7", 7);
+ #endif
+#endif
+
UNUSED(ret);
return OK;
} Hardware header aborting the build: diff --git a/arch/arm/src/stm32f0l0g0/hardware/stm32_tim.h b/arch/arm/src/stm32f0l0g0/hardware/stm32_tim.h [170/593]
index ceb057d57..8d69c3024 100644
--- a/arch/arm/src/stm32f0l0g0/hardware/stm32_tim.h
+++ b/arch/arm/src/stm32f0l0g0/hardware/stm32_tim.h
@@ -26,7 +26,7 @@
****************************************************************************/
#if defined(CONFIG_STM32F0L0G0_STM32F0) || defined(CONFIG_STM32F0L0G0_STM32L0)
-#error "Timer definitions should be validated for target before use"
+#warning "Timer definitions should be validated for target before use"
#endif
/* TODO Missing TIM2 definitions available on STM32G0x1 */
@@ -1101,7 +1101,9 @@
#define BTIM_CR1_URS (1 << 2) /* Bit 2: Update Request Source */
#define BTIM_CR1_OPM (1 << 3) /* Bit 3: One Pulse Mode */
#define BTIM_CR1_ARPE (1 << 7) /* Bit 7: Auto-Reload Preload enable */
+#if defined(CONFIG_STM32F0L0G0_STM32G0)
#define BTIM_CR1_UIFREMAP (1 << 11) /* Bit 11: UIF status bit remapping */
+#endif
/* Control register 2 */
@@ -1126,6 +1128,8 @@
/* Counter register */
+#if defined(CONFIG_STM32F0L0G0_STM32G0)
#define BTIM_CNT_UIFCPY (1 << 31) /* Bit 31: UIF copy */
+#endif
#endif /* __ARCH_ARM_SRC_STM32F0L0G0_HARDWARE_STM32_TIM_H */ Basic timers work fine, and I don't need the rest yet. I also have backported DEBUG_OPT_UNUSED_SECTIONS and ARCH_HAVE_BACKTRACE for arm_backtrace_thumb. |
stm32f072-disco crash log, stackdump and backtrace:
Notice it tries to jump into peripheral region ($pc=0x4000140a), that's TIM7 0x40001400-0x400017ff. |
Milandr mdr32f1qi stackdump/backtrace:
This time, $pc is at 0x0, which is start of Flash. OS crashes in processing TIMER1 interrupt while trying to do the timer_notify callback to send a 17 signal to timer_main POSIX signal handler and switch tasks in up_block_task, (but g_readytorun.head->xcp.regs is bad? -- investigate). I can catch it with a hardware breakpoint at *0x0 and *0x2. |
It's definitely "-fomit-frame-pointers" option and not "-foptimize-sibling-calls" option.
|
@ALTracer did this also happens on STM32F1/F4 or only STM32F0 ? |
BTW, never heard about Milandr MDR32 before and there is not much info about it on Internet. Are you planing to add support to it on mainline? |
@acassis I could verify timers on STM32F429I-disco board sometime next week, though it's armv7e-m. I don't have access to any STM32F1-based boards. Milandr has a line of MCUs produced since ~2010, see the official manufacturer site https://ic.milandr.ru/products/mikrokontrollery_i_protsessory/ and unofficial wiki http://startmilandr.codepx.ru/doku.php/prog:start (both sites in Russian). The LDM-Systems company sells evaluation boards https://ldm-systems.ru/catalog/helper?cat=milandr&scat=op I am not affiliated with them, we're only evaluating their chips for our next network-connected device with all silicon components originating from Russia. I thought about bringing mainline support, but I've been porting NuttX/10.3 for a month now, the only board is only 50% feature-complete, and I still rely on vendor's open-source (?) HAL for a couple of drivers. I will consult with my employer by the end of August 2022 if anything useful comes out of this project. |
Summary
I get consistent crashes while testing apps/examples/timer with disabled CONFIG_FRAME_POINTERS.
With them enabled, it works, but .text consumes +4.5KiB flash.
Impact
armv6-m thumb MCUs using basic timer peripherals.
Testing
stm32f072b-disco with custom config, Milandr mdr32f1qi with custom config.
Details
After porting basic timer functionality from stm32f0l0g0 onto mdr32, I tried to launch some userspace demos. It worked from time to time. It crashed when I tried to reduce consumed flash space. I even enabled tmrinfo debug prints, but they didn't help much in case of crashes -- though they showed successfull signal passing when everything worked.
I think I found a single Kconfig option that breaks it: CONFIG_FRAME_POINTERS=n. It changes CFLAGS from
-fno-omit-frame-pointers -fno-optimize-sibling-calls
to-fomit-frame-pointers
and saves space. I couldn't get anything else to break at runtime.Stackdumps/backtraces, defconfigs and workdir patches will follow. I used release/10.3 branch.
The text was updated successfully, but these errors were encountered: