포팅■


먼저 사이트에 들어가서 자료를 받습니다.


임베디드 포팅에서는 길을 선택하는것과 같다. 

한번 선택한 길이 꼬이면 처음부터 다시시작하는 마음가짐으로 시작한다.



$ 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 .

./Makefile:36:CFLAGS=-Wall -Wextra -D $(RUN_MODE) -D GCC_AT91FR40008 -I. -I../../Source/include 



******옵션을주어서 make를 스크립트로 되어있다.


$ chmod +x ram_arm.bat 

$ ./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


$ ./ram_arm.bat 
컴파일이 된다.



$ date +"%y%m%d%H%M"
1812261019
$ mkdir ~/backup

$ date=$(date +"%y%m%d%H%M");tar zcf ~/backup/backup_FreeRTOS_${date}.tar.gz ~/FreeRTOSv10.1.1/FreeRTOS


$ echo alias b='date=$(date +"%y%m%d%H%M");tar zcf ~/backup/backup_FreeRTOS_${date}.tar.gz ~/FreeRTOSv10.1.1/FreeRTOS' >> ~/.bachrc

편하게 alias 등록


$ vim HISTORY
- ARM7_AT91FR40008_GCC compile ok

기록을 남긴다.

$b


$ ll ~/backup/

-rw-r--r--  1 mds adm 14893056 2018-12-26 10:22 backup_FreeRTOS_1812261022.tar.gz
백업



$ cd ucos2/

$ subl .
$ make


Main.o exception.o libc.o Uart.o syscall.o s3c2450_startup.o libs.o
(필수)                                              (필수:부트코드)
여기에 있는 파일들을 옮긴다. 같은이름이 있는지 주의(최소한의 파일만 가져온다.)
(tip. 복사하지 않고 이동시키면 남아있는 파일 보이가 수월)

~/FreeRTOSv10.1.1/FreeRTOS/Demo/ARM7_AT91FR40008_GCC# subl ../../

1. ARM7_AT91FR40008_GCC에서 main.c를 main_org.c로 이름바꾸고 Main.c를 복사해서 넣는다.

2. ARM7_AT91FR40008_GCC으로 s3c2450_startup.S복사해서 넣는다.
makefile 수정
CRT0=s3c2450_startup.S   으로

3. main_org.c를 다시 main.c로 바꾼다.

4. make

5. ARM7_AT91FR40008_GCC으로 2450addr.inc

6. makefile 수정
THUMB_SRC = \
exception.c \
libc.c \
Uart.c \
syscall.c \
libs.S \
main.c \

7.후 에러나는 파일들을 하나씩 가져온다.

8. makefile에서 libs.S \를 지우고

9. ARM7_AT91FR40008_GCC으로 S3C2450-RAM.ld복사후 원래 atmel-ram.ld와 
CRT0=s3c2450_startup.S libs.S 수정
추가

10.ram_arm.bat을 수정

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. 

s3c2450_startup.S:207: Error: garbage following instruction -- `sub sp,sp,#4//reserved for PC'
오류

        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 

잘된다.


16. 
OCFLAGS = -O binary -R .note -R .comment -S

$(OBJCOPY) $(OCFLAGS) $(TOPDIR)/MDS2450 $(TOPDIR)/$@
cp $(TOPDIR)/$@ /tftpboot
예제 이부분을 가져와서 makefile에 넣는다.



17. rtosdemo    ->    MDS2450 로 모두 바꾼다.





최종 수정후  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)



+ Recent posts