For what you're doing, you'll want to become familiar with the crt0.S
script from the libgcc/config/msp430 directory of the mspgcc gcc
source.  For simple things you won't need a custom linker script; for
complex things, make sure your modified version doesn't deviate too
far from the standard ones.

Yes, if you define a naked function named _reset_vector__ that's in
section .init0 the mspgcc linker scripts will use it instead of the
default one.

You'd want to do something like:

__attribute__((__naked__,__section__(".init0")))
void _reset_vector (void)
{
   /* stuff goes here */
}

Peter

On Fri, Apr 18, 2014 at 12:08 PM, Tomek Lorek <tlo...@gmail.com> wrote:
> Hi,
> My use case is the following: I have a bootloader (up to 4K in size,
> residing at 0x4400 to 0x5400) that has a main() function and
> application (starting from 0x4800) – they are organized as 2 separate
> projects (I want the bootloader to be flashed only once and not
> changed later).
>
> I am using mspgcc.
>
> Bootloader and application linker scripts are defined so that their
> .text sections (that go to “rom” memory region) are separated but they
> use the same “vector” memory region for .vector section (although the
> bootloader does not use any interrupts other than reset):
>
> bootloader’s linker script excerpt:
> MEMORY {
>   …
>   rom (rx)         : ORIGIN = 0x4400, LENGTH = 0x1000 /* END=0x5400,
> size 4K - bootloader code */
>   rom_app (rx)     : ORIGIN = 0x5400, LENGTH = 0xab80 /* END=0xff80,
> size 43904 - the field-updatable application */
>   vectors          : ORIGIN = 0xff80, LENGTH = 0x0080 /* END=0x10000,
> size 128 as 64 2-byte segments */
>   …
> }
>
> and the application’s linker script excerpt:
>
> MEMORY {
>   …
>   rom (rx)         : ORIGIN = 0x5400, LENGTH = 0xab80 /* END=0xff80,
> size 43904 */
>   vectors          : ORIGIN = 0xff80, LENGTH = 0x0080 /* END=0x10000,
> size 128 as 64 2-byte segments */
>   …
> }
>
> I need the bootloader’s init code and main() function be executed upon
> power up of the microcontroller. And this would be the case if I only
> flash the bootloader’s .elf onto the flash (0xFFFE pointing to
> bootloader’s main() function).
>
> But when I then program the application’s image onto the flash the
> 0xFFFE will point to the application’s reset vector which is not a
> bootloader anymore. I'd like to configure my application so that it
> always fills 0xFFFE with a fixed address (0x4400).
>
> The rest of the story is that when bootloader is started then of
> course the bootloader needs to jump to and execute the application’s
> entry point (0x5400) including the app's watchdog preparation, stack
> init etc.
>
> Is that doable? How can I define in the application’s code that the
> reset vector (0xFFFE) shall contain the bootloader’s init code
> (0x4400)?
>
> Best Regards,
> Tomek
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to