How to set program start location in FLASH?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I have custom hardware with a CY8C4247LQI and I've written a custom bootloader without using the Bootloader component.

   

I would like to write a bootloadable application without using the component.

   

How can I change the application start address in FLASH? I'd like to leave the first 8K for the bootloader.

   

Thanks in advance,

   

Paul.

0 Likes
4 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

This should help, a section on this in ap note -

   

 

   

http://www.cypress.com/?rid=91945     AN89610 - PSoC® 4 and PSoC 5LP ARM Cortex Code Optimization

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Hi Dana,

   

Thank you for the link. By modifying the CY_APPL_ORIGIN definition in cm0gcc.ld and Cm0RealView.scat I am able to move the code to address 0x2000.

   

Is it safe to start the main program from the bootloader with the following code borrowed from bootloader.c?

   

    __attribute__((noinline)) /* Workaround for GCC toolchain bug with inlining */
    __attribute__((naked))
    static void Bootloader_LaunchBootloadable(uint32 appAddr)
    {
        __asm volatile("    BX  R0\n");
    }

   

Bootloader_LaunchBootloadable(0x2000);

   

Regards, Paul.

0 Likes
Anonymous
Not applicable

Hello Paul,

   

This seems to be feasible. Are you facing any issue in the project? 

   

Thanks

   

Ramesh B 

0 Likes
Anonymous
Not applicable

Hi.

   

I took the generated cm0gcc.ld script, copied it to a different folder and renamed it. Changed the  CY_APPL_ORIGIN value to 0x2000. Then referred to it in Build Settings -> Linker -> General -> Custom Linker Script.

   

After recompiling I opened the generated cm0gcc.ld file and the CY_APPL_ORIGIN in it is 0. Isn't it supposed to be 0x2000?

   

Thanks.

0 Likes