cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H733 External Flash app Memory Layout problem

AJone.5
Associate II

We are migrating a project from H750 to H733 and I have run into an issue with our custom bootloader.


We have our own External Loader, Bootloader and Application.  Works fine on 750, but I have had to remake the projects for a move to the H733 micro.

We are using external flash to fit our large application, in Octo SPI XIP, similar to the old device.

The bootloader seems to work correctly, loading the app into the XIP or using what is there it jumps to the app code.  This is done by:

 

    SCB->VTOR = APPLICATION_ADDRESS;
    __set_MSP(*(__IO uint32_t *)APPLICATION_ADDRESS);

 

 

All seems to work as expected, what is not working is the APPLICATION_ADDRESS which is

OCTOSPI2_BASE for us.

The application is built to use that address as the start of it's flash.
I can see in the debugger that code has been placed there.
But the first address if used as the stack pointer results in a memory access error,
it is way out of range with the memory space defined.

My linker script for the application is defined this way:

 

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1);    /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200;      /* required amount of heap  */
_Min_Stack_Size = 0x400; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
  FLASH    (rx)    : ORIGIN = 0x70000000,   LENGTH = 16M /* octospi */
  ITCMRAM (xrw)    : ORIGIN = 0x00000000,   LENGTH = 64K
  DTCMRAM (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K
/*internal flash version:  FLASH    (rx)    : ORIGIN = 0x08000000,   LENGTH = 1024K*/
  RAM_D1  (xrw)    : ORIGIN = 0x24000000,   LENGTH = 320K
  RAM_D2  (xrw)    : ORIGIN = 0x30000000,   LENGTH = 32K
  RAM_D3  (xrw)    : ORIGIN = 0x38000000,   LENGTH = 16K
}

/* Define output sections */
SECTIONS
{
  /* The startup code goes first into FLASH */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH

  /* The program code and other data goes into FLASH */
  .text :
  {
    . = ALIGN(4);
    *(.text)           /* .text sections (code) */
    *(.text*)          /* .text* sections (code) */
    *(.glue_7)         /* glue arm to thumb code */
    *(.glue_7t)        /* glue thumb to arm code */
    *(.eh_frame)

    KEEP (*(.init))
    KEEP (*(.fini))

    . = ALIGN(4);
    _etext = .;        /* define a global symbols at end of code */
  } >FLASH

 

With more after that of course, but this should be putting the interrupt vector and SP right

at 0x70000000 right? Is there any other configuration etc. that could override that?

Also, while the debugger immediately hard faults when we jump, we do reach the first line of
the assembly Reset_Handler so it seems like the reset function we are invoking at 0x70000000 +
4 is working. But the stack pointer ain't where we expect it to be.

 

1 REPLY 1
Pavel A.
Evangelist III

I can see in the debugger that code has been placed there.

So: do you see the correct data at 0x70000000 before jump? The first  word must be your MSP value (0x24000000 + 320K) then your reset handler address 0x7000xxxx. Do you see these values there? Single step with the debugger thru the jump.

By the way it should not be necessary to set the MSP. The STM32 startup code should do it.