================================ Outline ====================================
ARM 데이터시트 및 소스파일 분석
----------------------------------------------------------------------------
보드(board)를 사용할 때 우선적으로 해야 할 것은 보드에 대한 제어권을 얻는 것이다. 데이터 시트와 driver, 컴파일러를 다운 받아 설치한다.(개발 환경을 만든다.)

압축을 푼 폴더를 열어 index.html을 실행시킨다.

프로젝트 부분에 가면 몇가지 예제들이 소스 코드와 함께 나와 있다.. 무료 컴파일러인 GNU소스를 참조하면 된다.

ATmega를 사용할 때 WinAVR에서 make파일과 컴파일러를 링크 파일을 사용하여 연결해준다.
//Booting은 프로그램을 시작하기 위한 작업을 한다. 이 때 Boot Code를 사용한다. Boot Code는 기계어 또는 Asseble어를 사용하여 만든다.
예제 소스코드가 있는 폴더를 열어보자.

elf32-littlearm.lds 코드를 열어본다.



// 헤더 파일에는 본문의 형식이 적혀 있다.
.text 영역에는 code가 적혀있다. ‘.rodata’는 읽기 전용 데이터로써 변수가 적혀있다. ‘.data’형식에는 전역 변수가 적혀있다.
PE format(Portable Executable)은 마이크로소프트의 윈도우 3.1부터 지원하는 실행 파일의 형식을 말한다.

SECTIONS
{
/*** 코드 영역 ***/
.text : {
_stext = .;
*(.text)
*(.rodata)
*(.rodata*)
. = ALIGN(4); //4byte 단위로 최적화
_etext = . ;
}
/*** 데이터 영역 ***/
.data : AT ( ADDR (.text) + SIZEOF (.text) ) {
//코드 영역과 데이터 영역이 붙어있다.
_sdata = .;
*(.vectors)
*(.data)
_edata = .;
}
/* collect all uninitialized .bss sections that go into FLASH */
.bss (NOLOAD) : {
. = ALIGN(4);
_sbss = .;
*(.bss)
_ebss = .;
}
}
end = .;
지역변수(stack영역)는 파일을 실행할 때(메모리에 올릴 때) 크기를 차지한다. 전역변수(data, bss, code영역)은 컴파일 시 할당된다.
BSS영역의 데이터(값이 ‘0’인 전역변수) code영역에서 크기가 얼마나 되는지 기입만 해놓는다. 때문에 따로 load할 필요가 없다.



code 영역이 늘어나는 경우는 코딩의 양이 많거나 상수를 많이 쓰는 경우이다. 때문에 중복되는 상수를 사용할 경우에는 포인터를 사용하여 해당 상수를 출력해 주어야 한다.
lowlevel.c는 cstartup.S가 사용하는 코드이다.(cstartup.S의 일부이다.)
makefile의 내용은 아래와 같다.

all: sram flash 에서 사용하는 code영역(-Ttext)의 메모리 주소를 기억해 두자.
CDMA는 미국의 Qualcomm사가 만들어서 한국에서 1996년에 최초로 상용화하였다. 이 때 사용한 칩이 ARM사의 MSM이다.
과거에는 CPU와 CDMA가 일체형으로 들어있었지만 현재는 CPU와 CDMA가 분리되어 있다.
include 폴더에 있는 AT91SAM7S256.h 헤더파일은 ARM사에서 제공하는 메모리 값이 정의된 파일이다. 이것을 사용하지 않고 직접 작성하여 사용하기로 한다. -_ㅠ
ARM7TDMI
ICE: core를 외부에서 조작할 수 있다.
JTAG: 외부에서 연결가능, 프로그램 동작 중 정지 시킬 수 있다. visual studio의 debug 기능과 유사하다.
//block diagram에서 굵은 화살표는 bus를 가리킨다.
ARM 폰 노이만 구조를 띈다.
internal flash메모리가 첫 번째 메모리의 주소를 가지고 있다.
//메모리 위치를 바꾸는 것을 전문 용어로 remap이라 한다.
실제로 조작 가능한 메모리는 internal memories에 3mb만 사용하고 그 중에서도 실제로 사용하는 메모리는 260kb에 불가하다.
flash는 코드 영역이고 sram은 시스템 영역이다. heap은 동작 중에 사용 된다.
Peripheral mapping GPIO를 말한다. Internal Peripherals에 SYSC에 PIOA의 주소를 찾아서 조작하여야 한다.
20150720.hwp