cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F207IG w/ STM3220G eval bootloading issue

stbbrad3
Associate II
Posted on September 21, 2011 at 17:35

Hello everyone. This is my first time posting here and I am having issues with the IAP found here at STM's website. I am using Rowley Crossworks and the IAP files do not support that. Instead I created my own project and got the bootloader to run fine using USART communication. The first problem I ran into was when downloading my *.bin blinky program in FLASH_If_Write when it checks the data written to flash it was coming back and saying it did not match the SRAM content. I commented this out and was able to upload my whole bin file. If I look where blinky was written the code looks 100% fine. I am writing to 0x08008000 and my bootloader is at 0x08000000. I made sure the code doesn't overlap.

Now my real issue is jumping to the blinky application. The code sequence

      JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);

      /* Jump to user application */

      Jump_To_Application = (pFunction) JumpAddress;

      /* Initialize user application's Stack Pointer */

      __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);

      Jump_To_Application();

Jump address ends up pointing to location 0x08000351 and my debugger just goes to

 DEFAULT_ISR_HANDLER reset_wait      in startup.s.

Now I know my blinky app works as I tested stand alone. Two questions: While debugging should I expect the blinky app the execute after the jump? Has anyone experienced this or can provide an insight to what the issue maybe?

Thanks in advance and sorry if anything I posted is confusing this is my first technical post.
14 REPLIES 14
Posted on September 23, 2011 at 17:37

The odd address infers that it's calling Thumb code (Cortex-M3 can't run 32-bit ARM code)

Calling 0x08008004 will not work, it's a vectoring address not an instruction. Further, as an even address the core thinks it's ARM code, and will trap.

The value at 0x08008004 points to 0x08000351, which suggests that the code is not compiled/linked correctly for a basis of 0x08008000 which you need for your application image.

The vector should point to the c startup code, which should set up the stack, move/clear the static segment, set the stack, then call main().

I need to dig up my 1.6/1.7 licence, and try the 2.x eval

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stbbrad3
Associate II
Posted on September 23, 2011 at 17:58

Clive,

A little update. I defined STARTUP_FROM_RESET in my blinky project and it now appears that 0x08008004 has the address of the reset_handler ( 0x080000289). Still end up at the hardfault handler and I will see what I can figure out. Thanks again.
Posted on September 23, 2011 at 18:31

Looks like it's still pointing back into the Boot Loader region, and not the Application region.

A quick look at one of the 1.6 linker scripts (.ld)

You'd need to shrink the FLASH size by 0x8000 (32KB), and advance the base, at all places it's specified.

You'd need to expand the __STACKSIZE__ to reflect the application's needs.

MEMORY

{

  UNPLACED_SECTIONS (wx) : ORIGIN = 0x100000000, LENGTH = 0

  FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x00080000

  SRAM (wx) : ORIGIN = 0x20000000, LENGTH = 0x00010000

  USB_CAN_RAM (wx) : ORIGIN = 0x40006000, LENGTH = 0x00000200

  CM3_System_Control_Space (wx) : ORIGIN = 0xe000e000, LENGTH = 0x00001000

}

SECTIONS

{

  __FLASH_segment_start__ = 0x08000000;

  __FLASH_segment_end__ = 0x08080000;

  __SRAM_segment_start__ = 0x20000000;

  __SRAM_segment_end__ = 0x20010000;

  __USB_CAN_RAM_segment_start__ = 0x40006000;

  __USB_CAN_RAM_segment_end__ = 0x40006200;

  __CM3_System_Control_Space_segment_start__ = 0xe000e000;

  __CM3_System_Control_Space_segment_end__ = 0xe000f000;

  __STACKSIZE__ = 128;

  __STACKSIZE_IRQ__ = 0;

  __STACKSIZE_FIQ__ = 0;

  __STACKSIZE_SVC__ = 0;

  __STACKSIZE_ABT__ = 0;

  __STACKSIZE_UND__ = 0;

  __HEAPSIZE__ = 128;

....

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 23, 2011 at 19:35

With 2.1 I created a custom ''Memory Map File'' in the project directory

ie $(ProjectDir)/STM32F207IG_MemoryMap_App.xml

and associated the project option ''Memory Map File'' with it instead of the default one.

And replaced the last line

  <MemorySegment size=''0x100000'' access=''ReadOnly'' name=''FLASH'' start=''0x08000000''/>

with

  <MemorySegment size=''0xF8000'' access=''ReadOnly'' name=''FLASH'' start=''0x08008000''/>

The original file will be installed wherever you put the packages, for example

C:\Users\YourUserNameHere\AppData\Local\Rowley Associates Limited\CrossWorks for ARM\packages\targets\STM32\STM32F207IG_MemoryMap.xml

Now the map file looks like this :

...

Memory Configuration

Name             Origin             Length             Attributes

UNPLACED_SECTIONS 0xffffffff         0x00000000         xw

FLASH            0x08008000         0x000f8000         xr

RAM              0x20000000         0x00020000         xw

SRAM1            0x20000000         0x0001c000         xw

SRAM2            0x2001c000         0x00004000         xw

BKPSRAM          0x40024000         0x00001000         xw

PCCARD           0x90000000         0x00000000         xw

NAND2            0x80000000         0x00000000         xw

NAND1            0x70000000         0x00000000         xw

NOR_PSRAM4       0x6c000000         0x00000000         xw

NOR_PSRAM3       0x68000000         0x00000000         xw

NOR_PSRAM2       0x64000000         0x00000000         xw

NOR_PSRAM1       0x60000000         0x00000000         xw

CM3_System_Control_Space 0xe000e000         0x00001000         xw

*default*        0x00000000         0xffffffff

Linker script and memory map

                0x08009044                __do_debug_operation = __do_debug_operation_bkpt

                0x08008368                __vfprintf = __vfprintf_int

                0x08008ad4                __vfscanf = __vfscanf_int

                0x08008000                __FLASH_segment_start__ = 0x8008000

                0x08100000                __FLASH_segment_end__ = 0x8100000

                0x20000000                __RAM_segment_start__ = 0x20000000

                0x20020000                __RAM_segment_end__ = 0x20020000

                0x20000000                __SRAM1_segment_start__ = 0x20000000

...

.init           0x08008184      0x1dc

                0x08008184                __init_start__ = .

 *(.init .init.*)

 .init          0x08008184      0x104 THUMB Debug/thumb_crt0.o

                0x08008184                _start

                0x08008202                exit

 .init          0x08008288       0xd8 THUMB Debug/STM32_Startup.o

                0x08008288                reset_handler

                0x0800829a                SystemInit

 ...

Bit of a pain, but not too hard to do.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stbbrad3
Associate II
Posted on September 23, 2011 at 19:50

Clive thanks again for your help! I modified the linker file in my blinky project to have flash start at 0x08008000 and this fixed my issue! I cannot thank you enough for your help!!!

I will modify the xml to be included in my real project!

Thanks,

Brad