diff --git a/bsp/stm32/stm32f407-atk-explorer/board/SConscript b/bsp/stm32/stm32f407-atk-explorer/board/SConscript index e81e43dcbfd..c3e57428a20 100644 --- a/bsp/stm32/stm32f407-atk-explorer/board/SConscript +++ b/bsp/stm32/stm32f407-atk-explorer/board/SConscript @@ -32,7 +32,7 @@ path += [cwd + '/ports'] startup_path_prefix = SDK_LIB -if rtconfig.CROSS_TOOL == 'gcc': +if rtconfig.CROSS_TOOL == 'gcc' or rtconfig.CROSS_TOOL == 'clang': src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] elif rtconfig.CROSS_TOOL == 'keil': src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s'] diff --git a/bsp/stm32/stm32f407-atk-explorer/board/linker_scripts/link.lds b/bsp/stm32/stm32f407-atk-explorer/board/linker_scripts/link.lds index 7d2d7bc9769..026b2f5aa8e 100644 --- a/bsp/stm32/stm32f407-atk-explorer/board/linker_scripts/link.lds +++ b/bsp/stm32/stm32f407-atk-explorer/board/linker_scripts/link.lds @@ -48,6 +48,9 @@ SECTIONS KEEP(*(SORT(.rti_fn*))) __rt_init_end = .; + . = ALIGN(4); + KEEP(*(FalPartTable)) + . = ALIGN(4); PROVIDE(__ctors_start__ = .); diff --git a/bsp/stm32/stm32f407-atk-explorer/rtconfig.py b/bsp/stm32/stm32f407-atk-explorer/rtconfig.py index 871c33548cf..3d769e288d3 100644 --- a/bsp/stm32/stm32f407-atk-explorer/rtconfig.py +++ b/bsp/stm32/stm32f407-atk-explorer/rtconfig.py @@ -24,6 +24,9 @@ elif CROSS_TOOL == 'iar': PLATFORM = 'iar' EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0' +elif CROSS_TOOL == 'clang': + PLATFORM = 'clang' + EXEC_PATH = r'/opt/LLVMEmbeddedToolchainForArm-13.0.0/bin' if os.getenv('RTT_EXEC_PATH'): EXEC_PATH = os.getenv('RTT_EXEC_PATH') @@ -176,6 +179,38 @@ EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' +elif PLATFORM == 'clang': + # toolchains + PREFIX = 'llvm-' + CC = 'clang' + AS = 'clang' + AR = PREFIX + 'ar' + CXX = 'clang++' + LINK = 'clang' + TARGET_EXT = 'elf' + SIZE = PREFIX + 'size' + OBJDUMP = PREFIX + 'objdump' + OBJCPY = PREFIX + 'objcopy' + + DEVICE = ' --config armv7em_hard_fpv4_sp_d16_nosys -ffunction-sections -fdata-sections' + CFLAGS = DEVICE + AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' + LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-u,Reset_Handler -T board/linker_scripts/link.lds' + + CPATH = '' + LPATH = '' + + if BUILD == 'debug': + CFLAGS += ' -O0 -gdwarf-2 -g' + AFLAGS += ' -gdwarf-2' + else: + CFLAGS += ' -O2' + + CXXFLAGS = CFLAGS + + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' + + def dist_handle(BSP_ROOT, dist_dir): import sys cwd_path = os.getcwd() diff --git a/components/libc/compilers/gcc/partial/mips/SConscript b/components/libc/compilers/gcc/partial/mips/SConscript index 7651233d461..bb2ad09ab50 100644 --- a/components/libc/compilers/gcc/partial/mips/SConscript +++ b/components/libc/compilers/gcc/partial/mips/SConscript @@ -8,7 +8,7 @@ cwd = GetCurrentDir() CPPPATH = [cwd] group = [] -if rtconfig.PLATFORM == 'gcc' and ('mips' in rtconfig.PREFIX): # identify mips gcc tool chain +if (rtconfig.PLATFORM == 'gcc' and ('mips' in rtconfig.PREFIX)) or rtconfig.PLATFORM == 'clang': # identify mips gcc tool chain try: # There is no 'sys/select.h' in tthe mips gcc toolchain; it will be copied from 'nogcc/sys/select.h' copy("../../../common/nogcc/sys/select.h", "./sys/select.h") diff --git a/components/libc/compilers/gcc/partial/mips/sys/select.h b/components/libc/compilers/gcc/partial/mips/sys/select.h index 575ad3a1b59..02fb77dd89b 100644 --- a/components/libc/compilers/gcc/partial/mips/sys/select.h +++ b/components/libc/compilers/gcc/partial/mips/sys/select.h @@ -15,6 +15,10 @@ #include #include +#ifdef _WIN32 +#include +#endif + #ifndef FD_SETSIZE #define FD_SETSIZE 32 #endif @@ -26,16 +30,17 @@ #define FD_SETSIZE DFS_FD_MAX #endif /* SAL_USING_POSIX */ -#define NBBY 8 /* number of bits in a byte */ - typedef long fd_mask; +#ifndef _WIN32 +#ifndef _SYS_TYPES_FD_SET /* MIPS */ + +#define NBBY 8 /* number of bits in a byte */ #define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ #ifndef howmany #define howmany(x,y) (((x)+((y)-1))/(y)) #endif -#ifndef _SYS_TYPES_FD_SET /* MIPS */ typedef struct _types_fd_set { fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; } _types_fd_set; @@ -48,5 +53,6 @@ typedef struct _types_fd_set { #endif /* _SYS_TYPES_FD_SET */ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); +#endif /* _WIN32 */ #endif /* __SYS_SELECT_H__ */