Skip to content

Commit

Permalink
msp430: More newlib fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Nohlgård committed Jun 23, 2016
1 parent cb28ebc commit a3ef1da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cpu/msp430-common/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ NORETURN void cpu_switch_context_exit(void)
UNREACHABLE();
}

#if !(MODULE_NEWLIB)
/**
* mspgcc handles main specially - it does not return but falls
* through to section .fini9.
* To "fix" this, we put a return in section .fini9 to make main
* behave like a regular function. This enables a common
* thread_stack_init behavior. */
__attribute__((section (".fini9"))) void __main_epilogue(void) { __asm__("ret"); }
#endif

//----------------------------------------------------------------------------
// Processor specific routine - here for MSP
Expand Down
8 changes: 7 additions & 1 deletion cpu/msp430-common/msp430-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ init_ports(void)
}

/*---------------------------------------------------------------------------*/
#if !(MODULE_NEWLIB)
/* msp430-ld may align _end incorrectly. Workaround in cpu_init. */
extern int _end; /* Not in sys/unistd.h */
static char *cur_break = (char *) &_end;
#endif

void msp430_cpu_init(void)
{
Expand All @@ -115,15 +117,18 @@ void msp430_cpu_init(void)
// lpm_init();
irq_enable();

#if !(MODULE_NEWLIB)
if ((uintptr_t)cur_break & 1) { /* Workaround for msp430-ld bug!*/
cur_break++;
}
#endif
}
/*---------------------------------------------------------------------------*/
#define asmv(arg) __asm__ __volatile__(arg)

#define STACK_EXTRA 32
#if !(MODULE_NEWLIB)

#define STACK_EXTRA 32

/*
* Allocate memory from the heap. Check that we don't collide with the
Expand All @@ -150,6 +155,7 @@ void *sbrk(int incr)
*/
return old_break;
}
#endif
/*---------------------------------------------------------------------------*/
/*
* Mask all interrupts that can be masked.
Expand Down

0 comments on commit a3ef1da

Please sign in to comment.