cmake를 사용하여 stm32f4 용 FreeRTOS 프로젝트를 컴파일하려고합니다. syscalls.c를 연결하는 것 외에는 모든 것이 원활하게 진행됩니다.링크 된 라이브러리에있는 함수가 실행 파일에 표시되지 않습니다.
프로젝트 구조는 다음과 같습니다 src
폴더에없는
Everyting 정적 라이브러리 즉 SPL, 시작 파일, FreeRTOS로 컴파일 등 내 마지막 컴파일 단계입니다 :
[100%] Linking C executable bin/stm32f4_template.elf
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/arm-none-eabi-gcc
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -march=armv7e-m -fsingle-precision-constant
-finline-functions -Wdouble-promotion -std=gnu99 -Os -g -Wall -ffunction-sections
-fdata-sections -specs=nano.specs -u _scanf_float -u printf_float -fno-exceptions
-Wl,--gc-sections,-T/home/kript0n/Documents/projects/STM32F4-FreeRTOS/Utilities/stm32_flash.ld,
-Map,/home/kript0n/Documents/projects/STM32F4-FreeRTOS/build/bin/stm32f4_template.elf.map
CMakeFiles/stm32f4_template.elf.dir/src/main.c.obj CMakeFiles/stm32f4_template.elf.dir/src/controller.c.obj -o bin/stm32f4_template.elf
Libraries/STM32F4xx_StdPeriph_Driver/libdriverlib.a FreeRTOS/libFreeRTOS.a hardware/libhardware.a -lm Libraries/TM/libtm.a Libraries/syscall/libsyscalls.a
그리고 출력 :
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg_nano.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg_nano.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg_nano.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg_nano.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg_nano.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg_nano.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg_nano.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x10): undefined reference to `_read'
collect2: error: ld returned 1 exit status
CMakeFiles/stm32f4_template.elf.dir/build.make:126: recipe for target 'bin/stm32f4_template.elf' failed
make[2]: *** [bin/stm32f4_template.elf] Error 1
syscalls.c가 링크되어있는 것을 볼 수 있듯이 시스템 호출은 여전히 발견되지 않습니다.
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "stdio.h"
#include "stm32f4xx_usart.h"
/***************************************************************************/
int _open(const char *name, int flags, int mode){
return -1;
}
int _read(int file, char * ptr, int len) {
ptr = ptr;
len = len;
errno = EINVAL;
return -1;
}
/***************************************************************************/
int _lseek(int file, int ptr, int dir) {
file = file;
ptr = ptr;
dir = dir;
return 0;
}
/***************************************************************************/
int _write(int file, char * ptr, int len) {
int index;
if (!ptr) {
return 0;
}
for (index = 0; index < len; index++) {
while (!(USART3->SR & 0x00000040));
USART_SendData(USART3, ptr[index]);
}
return len;
}
/***************************************************************************/
int _close(int file) {
return 0;
}
/***************************************************************************/
/* Register name faking - works in collusion with the linker. */
register char * stack_ptr asm ("sp");
caddr_t _sbrk(int incr) {
extern char end asm ("end"); // Defined by the linker.
static char * heap_end;
char * prev_heap_end;
if (heap_end == NULL)
heap_end = & end;
prev_heap_end = heap_end;
if (heap_end + incr > stack_ptr) {
// Some of the libstdc++-v3 tests rely upon detecting
// out of memory errors, so do not abort here.
#if 0
extern void abort (void);
_write (1, "_sbrk: Heap and stack collision\n", 32);
abort();
#else
errno = ENOMEM;
return (caddr_t) -1;
#endif
}
heap_end += incr;
return (caddr_t) prev_heap_end;
}
/***************************************************************************/
int _fstat(int file, struct stat * st) {
file = file;
memset (st, 0, sizeof (* st));
st->st_mode = S_IFCHR;
return 0;
}
/***************************************************************************/
int _isatty(int fd) {
fd = fd;
return 1;
}
int _kill(int pid, int sig) {
errno=EINVAL;
return(-1);
}
int _getpid(void) {
return 1;
}
그리고 그 '건물 단계 : 여기 syscalls.c의 내용과 누락 된 모든 기능을 내부 선물됩니다
[ 85%] Building C object Libraries/syscall/CMakeFiles/syscalls.dir/syscalls.c.obj
cd /home/kript0n/Documents/projects/STM32F4-FreeRTOS/build/Libraries/syscall && /home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/arm-none-eabi-gcc -DARM_MATH_CM4 -DHSE_VALUE=8000000 -DSTM32F40_41xxx -DSTM32F4XX -DUSESTD_PERIPH_DRIVER -D__FPU_PRESENT=1 -D__FPU_USED=1 -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/Libraries/CMSIS/Device/ST/STM32F4xx/Include -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/Libraries/CMSIS/Include -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/Libraries/STM32F4xx_StdPeriph_Driver/inc -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/Libraries/TM/TM_SPL -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/FreeRTOS/include -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/FreeRTOS/portable/GCC/ARM_CM4F -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/config -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/hardware -I/home/kript0n/Documents/projects/STM32F4-FreeRTOS/include -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -march=armv7e-m -fsingle-precision-constant -finline-functions -Wdouble-promotion -std=gnu99 -Os -g -Wall -ffunction-sections -fdata-sections -specs=nano.specs -o CMakeFiles/syscalls.dir/syscalls.c.obj -c /home/kript0n/Documents/projects/STM32F4-FreeRTOS/Libraries/syscall/syscalls.c
[ 89%] Linking C static library libsyscalls.a
cd /home/kript0n/Documents/projects/STM32F4-FreeRTOS/build/Libraries/syscall && /usr/bin/cmake -P CMakeFiles/syscalls.dir/cmake_clean_target.cmake
cd /home/kript0n/Documents/projects/STM32F4-FreeRTOS/build/Libraries/syscall && /usr/bin/cmake -E cmake_link_script CMakeFiles/syscalls.dir/link.txt --verbose=1
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/arm-none-eabi-ar qc libsyscalls.a CMakeFiles/syscalls.dir/syscalls.c.obj
/home/kript0n/Applications/EmbeddedArm/gcc-arm-none-eabi-4_9-2015q2/bin/arm-none-eabi-ranlib libsyscalls.a
make[2]: Leaving directory '/home/kript0n/Documents/projects/STM32F4-FreeRTOS/build'
[ 89%] Built target syscalls
그 파일을 라이브러리로 컴파일 것을, 기능을 제시하고 그것은 연결되어 있습니다. 그래서 그게 잘못된거야?
감사합니다.
감사합니다. 최대한 빨리 확인하십시오. 내가 본 가장 이상한 행동을 드러냈다. 커플에서 libc를 syscalls와 연결하면된다. 내가 그 중 하나를 그리워하면 건물이 실패합니다. –