Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msp430: Add newlib support #4766

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
msp430: More newlib fixes
  • Loading branch information
Joakim Nohlgård committed Jun 23, 2016
commit a3ef1da16da5811a0e02cba5b932b18bcd9f02da
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