RTOS MBED OS application error with unmanaged bootloader

Hello

I’m trying to develop a RTOS MBED application with a target.mbed_app_start address at 0x8008800 on a DISCO_L475VG_IOT01A with a custom bootloader.

If I build a bare metal led blink test application and use target.mbed_app_start to compile it at 0x8008800, the application perfectly runs after bootloader jump.

If I build the same application but add RTOS removing bare-metal requirement, and build it using target.mbed_app_start at the same address, I got the following:

++ MbedOS Error Info ++
Error Status: 0x80010131 Code: 305 Module: 1
Error Message: Kernel Error: 0xFFFFFFFA, Not allowed in ISR context
Location: 0x800A423
Error Value: 0xFFFFFFFA
Current Thread: Id: 0x0 Entry: 0x8003E59 StackSize: 0x0 StackMem: 0x8003E59 SP: 0x10000608
For more info, visit: mbedos-error
– MbedOS Error Info –

= System will be rebooted due to a fatal error =
= Reboot count(=5) reached maximum, system will halt after rebooting =�

Can somebody help me?

Thanks in advance for any help
-Alex

Hello

I’ve made some progress.

I think my problem is related to this one:

STM32F401 Problems when relocating vector table on mbed project

because if I change the bootloader code to not set any interrupt (I attach a timeout callback to a Timer object and attached a receive ISR to a Serial) everything works fine when jumped to the application.

In details I’ve removed all .attach() callback functions from the bootloader and now the MBED RTOS application works as expected.

Does someone know how to use interrupt in STM32 bootloader in order to be able to use them also in the loaded application?

Thanks
-Alex

Hello,

you forgot to share an info about what a MbedOs version do you use, but you probably use something lower than 6.

It is not about how to use Interrupt under bootlaoder, the bootloader is normal program. When you will test the same code without bootloader functionality, the result will be probably same.
More it is about a content of your callback fuction. So please share the code or exactly describe what you want to call from the ISR.

For example. From MbedOs 5.12 (before it fail silently but it was working) and above are most of methods of Serial API not usable in ISR because are covered by Mutexes.

  • For usage with ISR is RawSerial recommended.
  • With the bare metal profile there is no RTOS = no Mutex = no crash.

BR, Jan

Hello Johnny

Thanks for helping. I’m using the last MBED OS version, I’ve created a new project yesterday MBED_MAJOR_VERSION 6.

One note, I always use bootloader to run my application code. For instance, my application code is relocated to 0x08008800 with “target.mbed_start_app”.

If I directly jump to the application code trough a bootloader that dosen’t use interrupt, everything is fine once the application is executed (included all application intererrupts and so on).

If I use interrupts in the bootloader (a timeout object for example to start the jump), the application start with interrupts not properly set.

Here the bootloader code:

 #include "mbed.h"

#define POST_APPLICATION_ADDR 0x08008800

Timeout start_app_timeout;

void start_application()
{
  printf ("start_application()\n\r");
  printf ("POST_APPLICATION_ADDR=%x\n\r\n\r", POST_APPLICATION_ADDR);
  mbed_start_application(POST_APPLICATION_ADDR);
}


int main()
{

  printf ("\n\r");
  printf("Bootloader\r\n");

  start_app_timeout.attach(&start_application, 2.0); //led not blinking in the application code
  //start_application(); //application works with this

  while(1);

}

here the application code:


#include "mbed.h"

DigitalOut led(PB_14);


void test_irq()
{
  led = !led;
}


int main()
{

  Ticker t;
  t.attach(&test_irq, 1.0);

  printf("Application!\n\r");

  while(1)
  {
    wait_us(90000);
  }
}

Did you tried something like this?

#include "mbed.h"

#define POST_APPLICATION_ADDR 0x08008800

Timeout start_app_timeout;
volatile bool appStartFlag = false;

void cb_timeout()
{
 appStartFlag = true;
}

void start_application()
{
  printf ("start_application()\n\r");
  printf ("POST_APPLICATION_ADDR=%x\n\r\n\r", POST_APPLICATION_ADDR);
  mbed_start_application(POST_APPLICATION_ADDR);
}


int main()
{

  printf ("\n\r");
  printf("Bootloader\r\n");

  start_app_timeout.attach(&cb_timeout, 2.0); //led not blinking in the application code
  //start_application(); //application works with this
  printf("loop\r\n");
  while(1)
  {
    if(appStartFlag) start_application();
    thread_sleep_for(200);
  }

}

BR, Jan

Yes, it works fine!

Calling mbed_start_application() inside a ISR?

Thank you a lot!
Regards
-Alex

OK, printf in ISR was probably problem as usual.

You must test it I do no know, but if it is not necessary…

BR, Jan