■포팅■
먼저 사이트에 들어가서 자료를 받습니다.
임베디드 포팅에서는 길을 선택하는것과 같다.
한번 선택한 길이 꼬이면 처음부터 다시시작하는 마음가짐으로 시작한다.
$ pwd
/home/mds/FreeRTOSv10.1.1
$ tree -L 2
.
├── FreeRTOS
│ ├── Demo
│ ├── License
│ ├── links_to_doc_pages_for_the_demo_projects.url
│ ├── readme.txt
│ └── Source
├── FreeRTOS-Plus
│ ├── Demo
│ ├── readme.txt
│ └── Source
├── New - FreeRTOS+TCP.url
├── New - Stream and Message Buffers.url
├── Quick_Start_Guide.url
├── readme.txt
├── Upgrading-to-FreeRTOS-10.url
└── Upgrading-to-FreeRTOS-9.url
7 directories, 9 files
$ cd FreeRTOS/Demo
$ tree -L 2 ==>파일들 확인
여기서 컴파일을 선택해야하는데 이때 소스를 열어본다(makefile) 선택기준 ->>어떻게 해야 빨리 끝날까?
최대한 분석안하고 빨리 끝내는 것이 중요!
$cd ARM7_AT91FR40008_GCC
$make
arm-elf-gcc -c -Wall -Wextra -D -D GCC_AT91FR40008 -I. -I../../Source/include -I../Common/include -mcpu=arm7tdmi -T -Wcast-align -fomit-frame-pointer -fno-strict-aliasing -fno-dwarf2-cfi-asm ../../Source/portable/GCC/ARM7_AT91FR40008/portISR.c -o ../../Source/portable/GCC/ARM7_AT91FR40008/portISR.o
make: execvp: arm-elf-gcc: Not a directory
make: *** [../../Source/portable/GCC/ARM7_AT91FR40008/portISR.o] Error 127
우선 make 해본다
makefile안에
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
ARCH=arm-none-eabi-ar
로 수정
$ make
arm-none-eabi-gcc -c -Wall -Wextra -D -D GCC_AT91FR40008 -I. -I../../Source/include -I../Common/include -mcpu=arm7tdmi -T -Wcast-align -fomit-frame-pointer -fno-strict-aliasing -fno-dwarf2-cfi-asm ../../Source/portable/GCC/ARM7_AT91FR40008/portISR.c -o ../../Source/portable/GCC/ARM7_AT91FR40008/portISR.o
arm-none-eabi-gcc: GCC_AT91FR40008: No such file or directory
<command-line>:0:1: error: macro names must be identifiers
In file included from ../../Source/include/FreeRTOS.h:62:0,
from ../../Source/portable/GCC/ARM7_AT91FR40008/portISR.c:44:
../../Source/include/portable.h:52:24: fatal error: portmacro.h: No such file or directory
compilation terminated.
make: *** [../../Source/portable/GCC/ARM7_AT91FR40008/portISR.o] Error 1
$ grep -rni GCC_AT91FR40008 .
******옵션을주어서 make를 스크립트로 되어있다.
$ ./ram_arm.bat
: command not found 6: make
ram_arm.bat을 수정 (set없애고 한줄로 )
USE_THUMB_MODE=NO DEBUG=-g OPTIM=-O0 RUN_MODE=RUN_FROM_RAM LDSCRIPT=atmel-ram.ld make
$b
$ cd ucos2/
USE_THUMB_MODE=NO DEBUG=-g OPTIM=-O0 RUN_MODE=RUN_FROM_RAM LDSCRIPT=S3C2450-RAM.ld make
11.make clean; ./ram_arm.bat 2>&1 | tee log
log파일로 저장후 검색해서 사용 libs가 .o로 되어있어야한다.
12.
sub sp,sp,#4 //reserved for PC에서
//reserved for PC를 지운다.
13. 메뉴에 find -> replace
정규식 표현 사용
Find : //(.+)
Replace :/* \1 */
모두 바꿔준다.
14.
CRT0_SRC=s3c2450_startup.S libs.S 수정
CRT0_OBJ=$(CRT0_SRC:.S=.o) 추가
rtosdemo.elf : $(ARM_OBJ) $(THUMB_OBJ) $(CRT0_OBJ) Makefile
$(CC) $(CFLAGS) $(ARM_OBJ) $(THUMB_OBJ) -nostartfiles $(CRT0_OBJ) $(LINKER_FLAGS) 수정
$(CRT0_OBJ) : %.o : %.S $(LDSCRIPT) Makefile
$(CC) -c $(CFLAGS) $< -o $@ 추가
15. Main과 main를 바꿔준다.
# make clean ; ./ram_arm.bat
최종 수정후 makefile
#/*
# * FreeRTOS Kernel V10.1.1
# * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# *
# * Permission is hereby granted, free of charge, to any person obtaining a copy of
# * this software and associated documentation files (the "Software"), to deal in
# * the Software without restriction, including without limitation the rights to
# * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# * the Software, and to permit persons to whom the Software is furnished to do so,
# * subject to the following conditions:
# *
# * The above copyright notice and this permission notice shall be included in all
# * copies or substantial portions of the Software.
# *
# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# *
# * http://www.FreeRTOS.org
# * http://aws.amazon.com/freertos
# *
# * 1 tab == 4 spaces!
# */
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
ARCH=arm-none-eabi-ar
CRT0_SRC=s3c2450_startup.S libs.S
#
# CFLAGS common to both the THUMB and ARM mode builds
#
CFLAGS=-Wall -Wextra -D $(RUN_MODE) -D GCC_AT91FR40008 -I. -I../../Source/include \
-I../Common/include $(DEBUG) -mcpu=arm9e -T$(LDSCRIPT) \
-Wcast-align $(OPTIM) -fomit-frame-pointer -fno-strict-aliasing \
-fno-dwarf2-cfi-asm
ifeq ($(USE_THUMB_MODE),YES)
CFLAGS += -mthumb-interwork -D THUMB_INTERWORK
THUMB_FLAGS=-mthumb
endif
LINKER_FLAGS=-o MDS2450 -Xlinker -M -Xlinker -Map=MDS2450.map
#
# Source files that can be built to THUMB mode.
#
THUMB_SRC = \
exception.c \
libc.c \
Uart.c \
syscall.c \
main.c \
serial/serial.c \
ParTest/ParTest.c \
../Common/Minimal/integer.c \
../Common/Minimal/flash.c \
../Common/Minimal/PollQ.c \
../Common/Minimal/comtest.c \
../Common/Minimal/flop.c \
../Common/Minimal/semtest.c \
../Common/Minimal/dynamic.c \
../Common/Minimal/BlockQ.c \
../../Source/tasks.c \
../../Source/queue.c \
../../Source/list.c \
../../Source/portable/MemMang/heap_2.c \
../../Source/portable/GCC/ARM7_AT91FR40008/port.c
#
# Source files that must be built to ARM mode.
#
ARM_SRC = \
../../Source/portable/GCC/ARM7_AT91FR40008/portISR.c \
serial/serialISR.c
#
# Define all object files.
#
ARM_OBJ = $(ARM_SRC:.c=.o)
THUMB_OBJ = $(THUMB_SRC:.c=.o)
CRT0_OBJ=$(CRT0_SRC:.S=.o)
OCFLAGS = -O binary -R .note -R .comment -S
MDS2450.bin : $(ARM_OBJ) $(THUMB_OBJ) $(CRT0_OBJ) Makefile
$(CC) $(CFLAGS) $(ARM_OBJ) $(THUMB_OBJ) -nostartfiles $(CRT0_OBJ) $(LINKER_FLAGS)
$(OBJCOPY) MDS2450 -O binary $@
cp $@ /tftpboot
$(THUMB_OBJ) : %.o : %.c $(LDSCRIPT) Makefile
$(CC) -c $(THUMB_FLAGS) $(CFLAGS) $< -o $@
$(ARM_OBJ) : %.o : %.c $(LDSCRIPT) Makefile
$(CC) -c $(CFLAGS) $< -o $@
$(CRT0_OBJ) : %.o : %.S $(LDSCRIPT) Makefile
$(CC) -c $(CFLAGS) $< -o $@
clean :
touch Makefile
rm $(ARM_OBJ)
rm $(THUMB_OBJ)
이제 디버깅을 시작한다.
필요없는 코드는 주석처리하고 막히는 구간에는 찾아가면서 부팅이 원활하게 되도록 하는 것이다.
디버깅은 led와 시리얼(UART)을 사용한다.
그리고, 예외처리 오류 출력을 잘 활용하자.
예) UART를 활용
Uart_Printf("<TRACE100>\n");
BaseType_t xReturn;
/* Add the idle task at the lowest priority. */
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
{
Uart_Printf("<TRACE101>\n");
StaticTask_t *pxIdleTaskTCBBuffer = NULL;
StackType_t *pxIdleTaskStackBuffer = NULL;
uint32_t ulIdleTaskStackSize;
Uart_Printf("<TRACE102>\n");
<<< 현재 진행중 상황 >>
# cat HISTORY
- ARM7_AT91FR40008_GCC compile ok
- boot ok, led ok
- printf ok
- problem in prvSetupTimerInterrupt(port.c)
'RTOS' 카테고리의 다른 글
[RTOS_Day5]예제 실습(세마포어, 뮤텍스, 이벤트 플래그, 메시지큐) (0) | 2018.12.27 |
---|---|
[RTOS_Day5]RTOS 포팅 진행 기록_2 (0) | 2018.12.27 |
[RTOS_Day3]통계 테스크 (0) | 2018.12.19 |
[RTOS_Day2]임계영역 보호 (0) | 2018.12.18 |
[RTOS_Day2]시간관리 함수 (2) | 2018.12.18 |