Skip to content
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

soc: stm32l1: Add support for STM32 IWDG #22125

Merged
merged 2 commits into from
Jan 29, 2020

Conversation

KwonTae-young
Copy link
Collaborator

This PR adds support for IWDG in the STM32L1 series.
The test was tested on the STM32L151CBT.

The driver for STM32's independent watchdog already exists and is
compatible with the stm32l1 SoC. Enable the independent watchdog
for the stm32l1 series for use with this driver.

Signed-off-by: Kwon Tae-young <[email protected]>
@erwango
Copy link
Member

erwango commented Jan 23, 2020

@KwonTae-young thanks for this addition.
Can you also add support on in tree L1 board such as nucleo_l152re? It will allow systematic build and seek for regression. I'll do the test if you don't have the board.

@KwonTae-young
Copy link
Collaborator Author

@erwango
I'll add support for the nucleo_l152re board.
Maybe next week :)

Enable the independent watchdog on the nucleo_l152re

Signed-off-by: Kwon Tae-young <[email protected]>
@KwonTae-young
Copy link
Collaborator Author

@erwango
Added IWDG support for nucleo_l152re.

But there is one strange thing.
Calling k_sleep() freezes the board.
Below is the result of running samples/drivers/watchdog.

*** Booting Zephyr OS build zephyr-v1.13.0-13522-g15484828d646  ***                                
Watchdog sample application                                                                        
Feeding watchdog 5 times                                                                           
Feeding watchdog...                                                                                
[00:00:00.062,000] <err> os: ***** MPU FAULT *****                                                 
[00:00:00.062,000] <err> os:   Instruction Access Violation                                        
[00:00:00.062,000] <err> os: r0/a1:  0x00000000  r1/a2:  0x20000190  r2/a3:  0x00000000            
[00:00:00.062,000] <err> os: r3/a4:  0x00000000 r12/ip:  0x0a090807 r14/lr:  0xfffffffd            
[00:00:00.062,000] <err> os:  xpsr:  0x6000000f                                                    
[00:00:00.062,000] <err> os: Faulting instruction address (r15/pc): 0xffff4770                     
[00:00:00.062,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0                      
[00:00:00.062,000] <err> os: Fault during interrupt handling                                       
                                                                                                   
[00:00:00.062,000] <err> os: Current thread: 0x200001e0 (unknown)                                  
[00:00:00.125,000] <err> os: Halting system
*** Booting Zephyr OS build zephyr-v1.13.0-13522-g15484828d646  ***                                
Watchdog sample application                                                                        
Feeding watchdog 5 times                                                                           
Feeding watchdog...                                                                                
[00:00:00.062,000] <err> os: ***** MPU FAULT *****                                                 
[00:00:00.062,000] <err> os:   Instruction Access Violation                                        
[00:00:00.062,000] <err> os: r0/a1:  0x00000000  r1/a2:  0x20000190  r2/a3:  0x00000000            
[00:00:00.062,000] <err> os: r3/a4:  0x00000000 r12/ip:  0x0a090807 r14/lr:  0xfffffffd            
[00:00:00.062,000] <err> os:  xpsr:  0x6000000f                                                    
[00:00:00.062,000] <err> os: Faulting instruction address (r15/pc): 0xffff4770                     
[00:00:00.062,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0                      
[00:00:00.062,000] <err> os: Fault during interrupt handling                                       
                                                                                                   
[00:00:00.062,000] <err> os: Current thread: 0x200001e0 (unknown)                                  
[00:00:00.125,000] <err> os: Halting system

Commenting out k_sleep() works fine.

diff --git a/samples/drivers/watchdog/src/main.c b/samples/drivers/watchdog/src/main.c
index 81e5348ad1..136ff3b40d 100644
--- a/samples/drivers/watchdog/src/main.c
+++ b/samples/drivers/watchdog/src/main.c
@@ -86,7 +86,7 @@ void main(void)
        for (int i = 0; i < WDT_FEED_TRIES; ++i) {
                printk("Feeding watchdog...\n");
                wdt_feed(wdt, wdt_channel_id);
-               k_sleep(K_MSEC(50));
+               //k_sleep(K_MSEC(50));
        }
 
        /* Waiting for the SoC reset. */
*** Booting Zephyr OS build zephyr-v1.13.0-13522-g15484828d646  ***                                
Watchdog sample application                                                                        
Feeding watchdog 5 times                                                                           
Feeding watchdog...                                                                                
Feeding watchdog...                                                                                
Feeding watchdog...                                                                                
Feeding watchdog...                                                                                
Feeding watchdog...                                                                                
Waiting for reset...                                                                               
*** Booting Zephyr OS build zephyr-v1.13.0-13522-g15484828d646  ***                                
Watchdog sample application                                                                        
Feeding watchdog 5 times                                                                           
Feeding watchdog...                                                                                
Feeding watchdog...                                                                                
Feeding watchdog...                                                                                
Feeding watchdog...                                                                                
Feeding watchdog...                                                                                
Waiting for reset...                                                                               

On the nucleo_l152re board, the symptoms can be reproduced with the following simple sources.

/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr.h>
#include <sys/printk.h>

void main(void)
{
	printk("%s() %dLine\n\n", __func__, __LINE__);
	k_sleep(50);
	printk("Hello World! %s\n", CONFIG_BOARD);
}
*** Booting Zephyr OS build zephyr-v1.13.0-13522-g15484828d646  ***                                
main() 12Line                                                                                      
                                                                                                   

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested ok on nucleo_l152re

@erwango
Copy link
Member

erwango commented Jan 29, 2020

@KwonTae-young, the issue you describe seem similar to #22078.
I'm approving the change as issue is not related to it.

@erwango erwango requested a review from galak January 29, 2020 14:01
@erwango erwango added this to the v2.2.0 milestone Jan 29, 2020
@galak galak merged commit 353fc8a into zephyrproject-rtos:master Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants