mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
cpu/msp430: update to modern gcc & newlib
This commit is contained in:
parent
bf072bdd55
commit
a0aeeb5ff4
@ -104,54 +104,16 @@ init_ports(void)
|
|||||||
P2IE = 0;
|
P2IE = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* msp430-ld may align _end incorrectly. Workaround in cpu_init. */
|
|
||||||
extern int _end; /* Not in sys/unistd.h */
|
|
||||||
static char *cur_break = (char *) &_end;
|
|
||||||
|
|
||||||
void msp430_cpu_init(void)
|
void msp430_cpu_init(void)
|
||||||
{
|
{
|
||||||
irq_disable();
|
irq_disable();
|
||||||
init_ports();
|
init_ports();
|
||||||
irq_enable();
|
irq_enable();
|
||||||
|
|
||||||
periph_init();
|
|
||||||
|
|
||||||
if ((uintptr_t)cur_break & 1) { /* Workaround for msp430-ld bug!*/
|
|
||||||
cur_break++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#define asmv(arg) __asm__ __volatile__(arg)
|
#define asmv(arg) __asm__ __volatile__(arg)
|
||||||
|
|
||||||
#define STACK_EXTRA 32
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate memory from the heap. Check that we don't collide with the
|
|
||||||
* stack right now (some other routine might later). A watchdog might
|
|
||||||
* be used to check if cur_break and the stack pointer meet during
|
|
||||||
* runtime.
|
|
||||||
*/
|
|
||||||
void *sbrk(int incr)
|
|
||||||
{
|
|
||||||
char *stack_pointer;
|
|
||||||
|
|
||||||
asmv("mov r1, %0" : "=r"(stack_pointer));
|
|
||||||
stack_pointer -= STACK_EXTRA;
|
|
||||||
|
|
||||||
if (incr > (stack_pointer - cur_break)) {
|
|
||||||
return (void *) - 1; /* ENOMEM */
|
|
||||||
}
|
|
||||||
|
|
||||||
void *old_break = cur_break;
|
|
||||||
cur_break += incr;
|
|
||||||
/*
|
|
||||||
* If the stack was never here then [old_break .. cur_break] should
|
|
||||||
* be filled with zeros.
|
|
||||||
*/
|
|
||||||
return old_break;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/*
|
/*
|
||||||
* Mask all interrupts that can be masked.
|
* Mask all interrupts that can be masked.
|
||||||
@ -178,17 +140,5 @@ splx_(int sr)
|
|||||||
asmv("bis %0, r2" : : "r"(sr));
|
asmv("bis %0, r2" : : "r"(sr));
|
||||||
asmv("nop");
|
asmv("nop");
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
size_t strnlen(const char *s, size_t maxlen)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
for (len = 0; len < maxlen; len++, s++) {
|
|
||||||
if (!*s)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return (len);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void board_init(void);
|
extern void board_init(void);
|
||||||
|
@ -1,21 +1,24 @@
|
|||||||
# Target architecture for the build. Use msp430 if you are unsure.
|
# Target architecture for the build. Use msp430-elf if you are unsure.
|
||||||
TARGET_ARCH ?= msp430
|
TARGET_ARCH ?= msp430-elf
|
||||||
|
|
||||||
|
MSP430_SUPPORT_FILES ?= $(RIOTCPU)/msp430_common/vendor/msp430-gcc-support-files
|
||||||
|
|
||||||
# define build specific options
|
# define build specific options
|
||||||
CFLAGS_CPU = -mmcu=$(CPU_MODEL)
|
CFLAGS_CPU = -mmcu=$(CPU_MODEL) -isystem $(MSP430_SUPPORT_FILES)/include
|
||||||
# default std set to gnu99 of not overwritten by user
|
|
||||||
ifeq (, $(filter -std=%, $(CFLAGS)))
|
|
||||||
CFLAGS += -std=gnu99
|
|
||||||
endif
|
|
||||||
CFLAGS_LINK = -ffunction-sections -fdata-sections
|
CFLAGS_LINK = -ffunction-sections -fdata-sections
|
||||||
CFLAGS_DBG ?= -gdwarf-2
|
CFLAGS_DBG ?= -g -gdwarf-2
|
||||||
CFLAGS_OPT ?= -Os
|
CFLAGS_OPT ?= -Os
|
||||||
|
|
||||||
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
|
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
|
||||||
ASFLAGS += $(CFLAGS_CPU) --defsym $(CPU_MODEL)=1 $(CFLAGS_DBG)
|
ASFLAGS += $(CFLAGS_CPU) --defsym $(CPU_MODEL)=1 $(CFLAGS_DBG)
|
||||||
# export linker flags
|
|
||||||
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -Wl,--gc-sections -static -lgcc
|
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT)
|
||||||
|
LINKFLAGS += -Wl,--gc-sections -Wl,-L$(MSP430_SUPPORT_FILES)/include
|
||||||
|
|
||||||
OPTIONAL_CFLAGS_BLACKLIST += -fdiagnostics-color
|
OPTIONAL_CFLAGS_BLACKLIST += -fdiagnostics-color
|
||||||
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow
|
||||||
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-truncation
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-truncation
|
||||||
OPTIONAL_CFLAGS_BLACKLIST += -gz
|
OPTIONAL_CFLAGS_BLACKLIST += -gz
|
||||||
|
|
||||||
|
# msp430 uses newlib by default
|
||||||
|
DEFAULT_MODULE += newlib
|
||||||
|
Loading…
Reference in New Issue
Block a user