Developing with Eclipse
Developing with Eclipse 이클립스로 개발하기
환경 설정은 윈도우와 리눅스에서는 상단 메뉴 바의 "Windows → Preferences" 항목을 선택해 열 수 있고, 맥오에스에서는 상단 메뉴 바의 "Eclipse → 환경 설정..." 항목을 선택해 열 수 있다.
프로젝트 속성은 "Project Explorer" 뷰에서 프로젝트를 우클릭하면 나타나는 팝업 메뉴의 "Properties" 항목을 선택해 열 수 있다.
환경 설정 수정하기
이클립스를 연 후, 환경 설정에서 다음 항목을 수정한다.
이 과정은 이클립스 워크스페이스 생성 후 한번만 수행하면 된다.
General → Workspace
Text file encoding
Other: UTF-8
New text file line delimiter
Default
Apply
General → Editors → Text Editors → Spelling
Enable spell checking: Uncheck
Apply
C/C++ → Build → Settings
Discovery
CDT Cross GCC Build-in Compiler Settings :
arm-none-eabi-${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}" @${ProjDirPath}/output/${ConfigName}/compile_flags_c.txt
Apply
C/C++ → Code Analysis
Uncheck all
Apply
C/C++ → Code Style → Formatter
New
Profile name: BSD/Allman [ubinos]
Initialize settings with the following profile: BSD/Allman [built-in]
Open the edit dialog now: Check
OK
Profile BSD/Allman [ubinos]
Indentation
Tab policy: Space only
Line Wrapping
Maximum line width: 160
'enum' declaration
Force split, even if line is shorter than maximum width: check
New Lines
before empty state: uncheck
OK
Apply
C/C++ → Indexer
Indexer options
Index source files not included in the build: Uncheck
Index unused headers: Uncheck
Allow heuristic resolution of includes: Uncheck
Apply
Run/Debug
Launching
Wait for ongoing build to complete before launching:
Never
Default Launchers
Launcher Type/Mode
C/C++ Remote Application
[Debug]
Preferred Launcher
GDB (DSF) Manual Remote Debugging Launcher: Check
Launch Bar
Enable the Launch Bar: Check
Enable the Build button: Uncheck
Apply and Close
프로젝트 가져오기
파일 메뉴의 "Import"를 선택해 프로젝트를 이클립스에 등록한다.
프로젝트 생성 방법은 "시작 안내서 - 소스 코드 가져오기"에서 설명한다.
Import → General → Existing Projects into Workspace
Next
Select root directory
Browse...
Select <project directory>
Finish
구성 및 프리프로세서 설정하기
이클립스는 프리프로세싱된 결과를 반영해 소스 코드를 보여준다.
다음과 같이 프로젝트 속성을 수정해 주면 실제 빌드될 때와 거의 동일한 프리프로세싱 결과가 반영된다.
이 과정은 프로젝트를 가져온 후, 그리고 프로젝트 구성 변경 시에 한번만 수행하면 된다.
1. 빌드 타겟 뷰에서 메이크 타겟 "configd"를 더블클릭한다.
2. 프로젝트 속성에서 다음 항목을 수정한다.
C/C++ General → Preprocessor Include Paths, Macros etc. → Providers
CDT Cross GCC Build-in Compiler Settings
Use global provider shared between projects: Check
Apply
Use global provider shared between projects: Uncheck
Apply and Close
* 주의 사항
library/ubinos의 version이 v03.00.09 이상이어야 한다.
같은 이름의 symbol이 여러 개 존재할 경우, 실제로 사용하는 symbol을 특정하지 못해 그 symbol이 "could not be resolved"로 표시되는 경우가 있다. 그럴 경우 다음 방법으로 문제를 해결할 수 있다.
프로젝트 속성에서 C/C++ General → Paths and Symbols -> Source Location 을 수정해 분석 범위를 실제로 사용하는 source들이 있는 directory로 제한한다.
같은 이름의 header file이 여러개 존재할 경우, 잘못된 header file을 include 한 것으로 분석해 실제로 사용하는 header file에서 정의한 symbol이 "could not be resolved"로 표시되는 경우가 있다. 그럴 경우 다음 방법들 중 하나로 문제를 해결할 수 있다.
프로젝트 속성에서 C/C++ General → Paths and Symbols -> Includes 를 수정해 실제로 사용하는 header file이 있는 directory를 지정한다.
Source에서 include 시 file이 위치하는 path 정보를 추가한다.
Example:
"#include "bsp.h"" 를 "#include "bsp/bsp.h""로 변경
프로젝트 빌드하기
빌드 타겟 뷰에서 메이크 타겟 "build"를 더블클릭해 프로젝트를 빌드한다.
디버그 구성 등록하기
다음 과정을 수행해 디버그 구성을 등록한다.
1. 프로젝트 탐색 뷰에서 디버그 구성을 등록한다.
Right click on <project name>
Debug As → Debug Configurations...
Double click C/C++ Remote Application
Main
C/C++ Application: output/Default/app.elf
Disable auto build: Select
Debugger
Main
GDB debugger: arm-none-eabi-gdb
Connection
Host name or IP address: localhost
Port number: 2331
Apply
Close
2. 런치 바를 다음과 같이 구성한다.
Launch mode:
Debug
Launch configuration:
ubiworks Default
Launch target:
New Launch Target
GDB Remote TCP
Hostname or IP: localhost
Port 2331
Finish
타겟 보드 연결하기
타겟 보드 연결 방법은 "시작 안내서"의 "타겟 보드 연결하기" 장에서 설명한다.
이클립스의 내장 터미널을 UART 통신 프로그램으로 사용할 경우 "시작 안내서"의 UART 통신 프로그램 실행 과정은 생략한다.
이클립스 내장 터미널 열기
터미널 뷰의 "Open A Terminal"을 클릭한 후, 다음과 같이 설정해 UART 포트를 연다.
Choose terminal: Serial Terminal
Settings
Serial port: <JLink CDC UART Port Name>
Baud rate: 115200
Data size: 8
Parity: None
Stop bits: 1
타겟 보드에 적재하기
빌드 타겟 뷰에서 메이크 타겟 "load"를 더블클릭해 실행 이진 파일을 타겟 보드에 적재한다.
디버거로 실행하기
런치 바의 "Launch in 'Debug' mode" 아이콘을 클릭해 디버거를 실행한다.
디버거로 재실행하기
실행 이진 파일이 변경되지 않았다면, 다음 과정 통해 적재 과정을 수행하지 않고 재실행할 수 있다.
1. 런처 바의 "Stop" 아이콘을 클릭해 디버거를 멈춘다.
2. 빌드 타겟 뷰에서 메이크 타겟 "reset"을 더블클릭해 실행한다.
3. 런치 바의 "Launch in 'Debug' mode" 아이콘을 클릭해 디버거를 실행한다.