use newlib
This commit is contained in:
parent
3c4a1ae976
commit
c6c74aaa1b
29
Makefile
29
Makefile
|
@ -26,7 +26,7 @@ BINARY = firmware
|
|||
|
||||
# which development board is used
|
||||
# supported are: SYSTEM_BOARD, MAPLE_MINI, BLUE_PILL
|
||||
BOARD ?= BLUE_PILL
|
||||
BOARD ?= SYSTEM_BOARD
|
||||
|
||||
# source files
|
||||
CSRC = $(wildcard *.c)
|
||||
|
@ -48,9 +48,11 @@ LIB_OBJ = $(patsubst %.c,%.o,$(LIB_CSRC))
|
|||
# cross-compiler tools
|
||||
PREFIX ?= arm-none-eabi
|
||||
# compile using gcc (requires gcc-arm-none-eabi)
|
||||
CC := $(PREFIX)-gcc
|
||||
#CC := $(PREFIX)-gcc
|
||||
# compile using clang (requires clang gcc-multilib)
|
||||
CC := clang -target $(PREFIX)
|
||||
# link using gcc (requires gcc-arm-none-eabi)
|
||||
#LD := $(PREFIX)-gcc
|
||||
# link (requires binutils-arm-none-eabi)
|
||||
LD := $(PREFIX)-ld
|
||||
# create archive (requires binutils-arm-none-eabi)
|
||||
|
@ -88,11 +90,10 @@ endif
|
|||
DEFS += -DSTM32F1 -D$(BOARD)
|
||||
|
||||
# C flags
|
||||
CFLAGS += -Os -g -std=c99 -nostdlib
|
||||
# TODO try to get rid of system libraries (and use -ffreestanding)
|
||||
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
||||
CFLAGS += -Wpedantic -Wall -Werror -Wundef -Wextra -Wshadow -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wstrict-overflow=5
|
||||
CFLAGS += -I. -I$(INCLUDE_DIR) $(patsubst %,-I%,$(LIB))
|
||||
CFLAGS += -Os -g -std=c99 -nostdlib -nostdinc
|
||||
CFLAGS += -fno-common -ffunction-sections -fdata-sections -ffreestanding
|
||||
CFLAGS += -Wpedantic -Wall -Werror -Wextra -Wshadow -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wstrict-overflow=5
|
||||
CFLAGS += -I/usr/include/newlib/ -I/usr/lib/gcc/arm-none-eabi/*/include/ -I. -I$(INCLUDE_DIR) $(patsubst %,-I%,$(LIB))
|
||||
CFLAGS += $(DEFS)
|
||||
|
||||
# linker flags
|
||||
|
@ -101,20 +102,16 @@ LDFLAGS += -static -nostartfiles -nostdlib
|
|||
LDFLAGS += --library-path $(LIB_DIR)
|
||||
LIBNAME = opencm3_stm32f1
|
||||
LDLIBS += --library $(LIBNAME)
|
||||
# TODO use newlib (providing libc, libm, and libg/libnosys) and get rib of the libgcc
|
||||
# curiously newlib seems to require libgcc (In function `_vfprintf_r': undefined reference to `__aeabi_dcmplt')
|
||||
# also even with libcc aliases are missing (In function `cdcacm_data_rx_cb': undefined reference to `__aeabi_memset')
|
||||
#LDFLAGS += --library-path /usr/lib/arm-none-eabi/newlib/armv7-m/
|
||||
# provides libgcc
|
||||
# use newlib (providing libc, libm, libnosys, libg)
|
||||
# TODO retrieve path automatically
|
||||
LDFLAGS += --library-path /usr/lib/arm-none-eabi/newlib/armv7-m/
|
||||
# use libgcc (provides __aeabi_*)
|
||||
# TODO retrieve path automatically (arm-none-eabi-gcc does it on its own)
|
||||
LDFLAGS += --library-path /usr/lib/gcc/arm-none-eabi/*/armv7-m/
|
||||
# provides libc, libm, libnosys
|
||||
# TODO retrieve path automatically (arm-none-eabi-gcc does it on its own)
|
||||
LDFLAGS += --library-path /usr/arm-none-eabi/lib/armv7-m/
|
||||
# own libraries
|
||||
LDFLAGS += --dynamic-linker . $(patsubst %,--dynamic-linker %,$(LIB))
|
||||
# libc and other system libraries
|
||||
LDLIBS += --library c --library gcc --library nosys --library m
|
||||
LDLIBS += --library c --library gcc --library nosys --library g --library m
|
||||
# linker script for micro-controller
|
||||
LDFLAGS += -T $(LDSCRIPT)
|
||||
|
||||
|
|
9
main.c
9
main.c
|
@ -135,7 +135,8 @@ error:
|
|||
/** program entry point
|
||||
* this is the firmware function started by the micro-controller
|
||||
*/
|
||||
int main(void)
|
||||
void main(void);
|
||||
void main(void)
|
||||
{
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz(); // use 8 MHz high speed external clock to generate 72 MHz internal clock
|
||||
|
||||
|
@ -145,8 +146,8 @@ int main(void)
|
|||
// setup USART and USB for user communication
|
||||
usart_setup(); // setup USART (for printing)
|
||||
cdcacm_setup(); // setup USB CDC ACM (for printing)
|
||||
//setbuf(stdout, NULL); // set standard out buffer to NULL to immediately print
|
||||
//setbuf(stderr, NULL); // set standard error buffer to NULL to immediately print
|
||||
setbuf(stdout, NULL); // set standard out buffer to NULL to immediately print
|
||||
setbuf(stderr, NULL); // set standard error buffer to NULL to immediately print
|
||||
|
||||
// minimal setup ready
|
||||
printf("welcome to the STM32F1 CuVoodoo example code\n"); // print welcome message
|
||||
|
@ -225,8 +226,6 @@ int main(void)
|
|||
__WFI(); // go to sleep
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue