I think Eric misinterpreted Crazy Casta's position on watchdog, though I'm
very sympathetic to the "least surprise" principle, and yes, it will waste a
lot of people's time if this change isn't made very clear.  But the MSP430
has a watchdog feature, people *should* be aware of it, and consistency with
TI's tools and documentation means mspgcc shouldn't pretend it's not there.

Based on the feedback, I'll make the default behavior to keep it enabled,
and kick it as necessary during the standard startup.  Anybody who doesn't
want to deal with it in user code can put this:

   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

at the top of main(), as is done in every TI example program I've seen (that
doesn't demonstrate use of the watchdog).  Or they can use
-mdisable-watchdog to have the gcc driver select an alternative libcrt0.a
which will save a few bytes of ROM by doing that at the top of the reset
vector, and behave as mspgcc does now without requiring source code changes.

Regarding the change to call instead of jump to main, I can see that saving
two bytes of RAM for stack on the value-line products could be important.
But so is being able to compile main.c with -g, and perhaps so is having
separate recovery code in __stop_progExec__ (e.g. for uncaught exceptions).
All can be accommodated by using this construct:

__attribute__ ((naked,section(".init9")))
void main ()
{
  while (1) {
    ;
  }
}

which will simply put the main routine directly inside the init section
after everything else has been done.  The order in which things are
presented to the linker means the init code will simply fall into (and, if
necessary, out of) main.  If you also add:

/* Redefine __call_main to remove the call from the init section.
 * Retain the reference to __stop_progExec__ so that the standard
 * fini code is linked in. */
__attribute__ ((naked,section(".init9")))
void __call_main ()
{ __asm__ (".global __stop_progExec__"); }

to remove the standard definition of __call_main that comes from libcrt0.a
(and would otherwise follow the "real" main, causing an infinite loop that
slowly consumes the stack), then it will be safe to fall out of main, and
the standard fini code (including any destructor functions) will be
executed.  (Note that I've renamed __jump_to_main.)

I've verified this works in my development branches, and the resulting main
is invoked with a stack pointer pointing to the last word in RAM.  This
trick will also be documented in the manual.

Thanks to all for the feedback.  I think this is going to be a fine
solution, with reasonable default behavior, the freedom for special
situations to be handled without significant impact on either the developer
or the toolchain maintainer, and a clear indication of what's going on made
explicit in the source rather than hidden in compiler options inside a
Makefile or build script.

Peter

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to