<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Bootloader STM32 interrupt problem</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/27369/bootloader-stm32-interrupt-problem</link><description> 
I made a bootloader that makes it possible to program the device
in application. The bootloader software uses interrupts and
communicate over an RS485 bus. When I jump to the base address of my
firmware, it seems that the interrupts aren&amp;#39;t working.</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Bootloader STM32 interrupt problem</title><link>https://community.arm.com/thread/139600?ContentTypeID=1</link><pubDate>Fri, 09 Jul 2010 03:38:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3cd595e8-fa8c-42da-9419-6f41d32a5805</guid><dc:creator>Marco Accame</dc:creator><description>&lt;p&gt;&lt;p&gt;
well done ;-).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader STM32 interrupt problem</title><link>https://community.arm.com/thread/130650?ContentTypeID=1</link><pubDate>Fri, 09 Jul 2010 03:32:46 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4cb722e6-2de0-408a-a65f-00fe303479c9</guid><dc:creator>Bjorn van Sabben</dc:creator><description>&lt;p&gt;&lt;p&gt;
I&amp;#39;ve solved the problem. The reset input was connected in such a
way that the internal reset circuit couldn&amp;#39;t drive the reset
correctly. I&amp;#39;ve change de external reset circuit (is now open
collector driver) and the NVIC_SystemReset() works. (The Watchdog
didn&amp;#39;t work either, but works fine now).&lt;/p&gt;

&lt;p&gt;
I&amp;#39;ve also changed part of the code so that I de-initialize all the
periferals before I try to jump to the other application. Every class
will now neatly deinitialize the used periferals on destruction.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader STM32 interrupt problem</title><link>https://community.arm.com/thread/126213?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2010 08:08:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e32a5b9c-43bd-4732-bb44-07c0630a63d2</guid><dc:creator>Marco Accame</dc:creator><description>&lt;p&gt;&lt;p&gt;
The following works on my MCBSTM32C board.&lt;/p&gt;

&lt;p&gt;
You can verify if it works for you too and then find&lt;br /&gt;
what does not make it work in your project.&lt;/p&gt;

&lt;p&gt;
1. Download latest CMSIS at &lt;a href="http://www.onarm.com/download/download396.asp"&gt;www.onarm.com/.../download396.asp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
2. Open project
CM3\Example\arm\STM32F107\CMSIS_Example_STM32F107.uv2 for Keil&amp;#39;s
MCBSTM32C.&lt;/p&gt;

&lt;p&gt;
3. edit main_STM32F107.c and add tagged lines:&lt;/p&gt;

&lt;pre&gt;

int main (void) {

  uint32_t nn = 50; // tag: added to test reset

  if (SysTick_Config(SystemCoreClock / 1000)) { /* Setup SysTick Timer for 1 msec interrupts  */
    while (1);                                  /* Capture error */
  }

  LED_Config();

  // tag: added to test reset
  LED_On (0x100);
  Delay (5*1000);

  while(1) {
    LED_On (0x100);                             /* Turn on the LED. */
    Delay (100);                                /* delay  100 Msec */
    LED_Off (0x100);                            /* Turn off the LED. */
    Delay (100);                                /* delay  100 Msec */

    // tag: added to test reset
    if(--nn == 0)
    {
        NVIC_SystemReset();
    }
  }

}


&lt;/pre&gt;

&lt;p&gt;
If you have a MCBSTM32 board you can use the project
CMSIS_Example_STM32F103.uv2 but remember to chacneh some settings
(type of micro, inhibit use of external memory) and change startup
file.&lt;/p&gt;

&lt;p&gt;
Regards, Marco.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader STM32 interrupt problem</title><link>https://community.arm.com/thread/115821?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2010 07:34:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:42e77a07-5d64-4ada-9cce-9e038267770b</guid><dc:creator>Bjorn van Sabben</dc:creator><description>&lt;p&gt;&lt;p&gt;
If I run the controller without the ULINK2 the code still doesn&amp;#39;t
reset either. It keeps running in the while(1) loop (I guess, can&amp;#39;t
really tell because there is no debug, only can see that a led stops
blinking).&lt;/p&gt;

&lt;p&gt;
Is there some register that has to be set, the only reset that
works right now is the external reset, but than isn&amp;#39;t very practical
to trigger remotely when the device.&lt;/p&gt;

&lt;p&gt;
Can it be that the externa reset-input has some sort of influance
on the functioning of the internal reset circuit?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader STM32 interrupt problem</title><link>https://community.arm.com/thread/102201?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2010 06:25:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:15006abd-3aad-41a8-868e-c4bd9fc44c58</guid><dc:creator>Marco Accame</dc:creator><description>&lt;p&gt;&lt;p&gt;
If you use ulink2, then it is correct that the micro won&amp;#39;t reset
and stay in the forever loop of NVIC_SystemReset().&lt;/p&gt;

&lt;p&gt;
I think that if you dont use ulink2 then your DEBUG() should keep
on repeating &amp;quot;Loop 1&amp;quot; ... &amp;quot;Loop 10&amp;quot;. That would prove an effective
reset.&lt;/p&gt;

&lt;p&gt;
I tested it with something like that, where the led showed me the
effective reset.&lt;/p&gt;

&lt;pre&gt;

int main()
{
    uint32_t cnt = 10;
    &amp;lt;put a led on (or blink it fast) for 5 seconds&amp;gt;

    for(;;)
    {
        &amp;lt;toggle led&amp;gt;
        &amp;lt;wait for 1 second&amp;gt;
        if(--cnt == 0)
        {
            &amp;lt;put a led off&amp;gt;
            NVIC_SystemReset();
            for(;;);
        }
    }
}

&lt;/pre&gt;

&lt;p&gt;
Try again ....&lt;/p&gt;

&lt;p&gt;
Cheers, Marco.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader STM32 interrupt problem</title><link>https://community.arm.com/thread/78404?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2010 05:58:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c214061b-e2d4-499f-8412-2ba9ded7a2c0</guid><dc:creator>Bjorn van Sabben</dc:creator><description>&lt;p&gt;&lt;p&gt;
I&amp;#39;ve tried to reset my system using the following piece of
testcode:&lt;/p&gt;

&lt;pre&gt;
uint8_t loopcounter = 0;
while (1) {
    loopcounter++;
    DEBUG(&amp;quot;Loop %d&amp;quot;,loopcounter);
    if (loopcounter &amp;gt;= 10) {
        __disable_irq();
        NVIC_SystemReset();
        ASSERT(false);
    }
    waitSeconds(1);
}
&lt;/pre&gt;

&lt;p&gt;
What can be the problem for not resetting?&lt;br /&gt;
DEBUG an ASSERT are macro&amp;#39;s for sending information to the USART1
port. When the loop is run for the 10th time the system is reset.&lt;/p&gt;

&lt;p&gt;
With the ULINK2 i can break the operation and find that the system
is waiting to reset in the while(1) loop in
NVIC_SystemReset().&lt;/p&gt;

&lt;pre&gt;
static __INLINE void NVIC_SystemReset(void)
{
  SCB-&amp;gt;AIRCR  = (NVIC_AIRCR_VECTKEY | (SCB-&amp;gt;AIRCR &amp;amp; (0x700)) | (1&amp;lt;&amp;lt;NVIC_SYSRESETREQ)); /* Keep priority group unchanged */
  __DSB();                                                                             /* Ensure completion of memory access */
  while(1);                                                                            /* wait until reset */
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader STM32 interrupt problem</title><link>https://community.arm.com/thread/58305?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2010 03:39:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1a729c01-73ac-438e-b356-207314222bab</guid><dc:creator>Marco Accame</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Bjorn,&lt;/p&gt;

&lt;p&gt;
I have developed a similar library starting from the same
application note, but I approached it in a slightly different
way.&lt;/p&gt;

&lt;p&gt;
The loader is located at 0x08000000 and just jumps (if there is
valid code) at a given location. Actually it can jump at several
locations.&lt;/p&gt;

&lt;p&gt;
I have placed an updater at UPDTADDR = 0x08000000+OFFSETUPDT and
my application at APPLADDR = 0x08000000+OFFSETAPPL. They both
relocate the vector table at the proper address.&lt;/p&gt;

&lt;p&gt;
In normal cases the loader jumps to APPLADDR.&lt;/p&gt;

&lt;p&gt;
But when I need to update the code of the application I force the
bootloader to jump to UPDTADDR and I do whatever I need (in your case
use an USART to communicate, in my case ethernet). At the end of the
operation, I dont jump to any location but I prefer to force a reset
passing again from the loader.&lt;/p&gt;

&lt;p&gt;
The reason is that if I jumped I should deinit every HW
peripheral, every ISR etc.&lt;/p&gt;

&lt;p&gt;
You can use code as in the following to jump or to restart:&lt;/p&gt;

&lt;pre&gt;

static void s_jump_to(uint32_t appaddr)
{
    volatile uint32_t jumpaddr;
    void (*app_fn)(void) = NULL;

    // prepare jump address
    jumpaddr = *(__IO uint32_t*) (appaddr + 4);
    // prepare jumping function
    app_fn = (void (*)(void)) jumpaddr;
    // initialize user application&amp;#39;s stack pointer
    __set_MSP(*(__IO uint32_t*) appaddr);
    // jump.
    app_fn();
}

extern void system_restart(void)
{
    ...

    // disable irqs .... is it really necessary?
    __disable_irq();

    // restart system
    NVIC_SystemReset();

    // should be never in here
    assert(0);
}


&lt;/pre&gt;

&lt;p&gt;
I hope it can help.&lt;/p&gt;

&lt;p&gt;
Reagrds, Marco.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>