This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Memory issues when jumping from boot loader to main application

Hello,

At the moment, I'm working on software for a STM32F4 series micro-controller. The software consists out of a boot loader and a main application. The code itself has been working quite nicely for some time now. Recently I've altered the boot loader and released it as a newer version and it works quite nicely as well. However, when testing new versions of the application software, we've been noticing a few oddities that we cannot explain.

From my understanding, when using a properly written boot-loader, it (barely?) affects the main application. For example, the main application has the full RAM available for itself, no matter how much the boot loader uses of it. It seems that this isn't quite the case with our combination. Depending on which boot loader is used, we can allocate more space for the heap in the start up assembly file of the main application. This makes it feel as if the boot loader keeps some memory in use after it has jumped to the main application. (In this specific case, the newer boot loader allows for an additional 1000 bytes to be allocated to the initial heap size.)

Is this behaviour normal/expected, or are we possibly doing something wrong?

In case it is needed, some background info on our boot loader and the main application.
The final part of the boot loader, that makes the jump to the main program, is as follows:

      /* Jump to user application */
      JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
      Jump_To_Application = (pFunction) JumpAddress;
      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
      Jump_To_Application();
      // does not return here

In the SystemInit routine, the vector table is relocated using (the default?)

SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET;


Where FLASH_BASE | VECT_TAB_OFFSET equals the same address as APPLICATION_ADDRESS in the boot loader.

Again, it all seems to work well, but it strikes us as odd that we need to lower the Heap_Size in the startup assembly file of the main application to make it work with the older boot loader.

Any advice is highly appreciated.

Thanks in advance.