레이블이 SoC-Sitara인 게시물을 표시합니다. 모든 게시물 표시
레이블이 SoC-Sitara인 게시물을 표시합니다. 모든 게시물 표시

9/06/2016

TI-Sitara (AM437x) Benchmark Program (참조용)

TI에서 아래와 같이 ARM의 기본성능 TEST 할수 있는 방법제공을 해주어서,
본인도 새로 알게되었으며, 각각의 SOC의 성능을 측정을 할수 있는 App을 간단히 소개한다.

만약 존재하지 않는다면, 아래에 같이 Github에서 Download에서 다운로드에서 사용을해보자.

   https://en.wikipedia.org/wiki/NBench

1. Benchmark Test

1.1 CPU 기본성능 TEST

  • proc/cpuinfo : 가장기본적인 정보 
  • Dhrystone : CPU의 성능을 측정하는 방법으로, 별도의 프로그램이 필요.  
  • Whetstone : 유사하지만, 둘 사이의 차이점은 아직 발견을 못하겠음.
  • Linkpack: FPU 성능측정을 위해서 사용하면 되겠다.

Proc에서 제공해주는 기본적인 BogoMIPS가 있다.

# cat /proc/cpuinfo 
processor : 0
model name : ARMv7 Processor rev 10 (v7l)
BogoMIPS : 598.17
Features : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part : 0xc09
CPU revision : 10

Hardware : Generic AM43 (Flattened Device Tree)
Revision : 0000
Serial  : 0000000000000000 
CPU를 기본적으로 측정하는 프로그램으로, MIPS로 나오며,

1.2 Dhrystone

사용법은 Benchmark할 횟수를 적어줘야한다.
단위는 DMIPS (Dhrystone MIPS) 이며, RISC와 CISC에 따라 알고리즘이 약간식 다르게 동작이 되는 것 같다.


# /usr/bin/dhrystone

Dhrystone Benchmark, Version 2.1 (Language: C)

Program compiled without 'register' attribute

Please give the number of runs through the benchmark: 40000000  // 이 값이 너무 작으면 측정이 제대로 안됨 

Execution starts, 40000000 runs through Dhrystone
Execution ends

Final values of the variables used in the benchmark:

Int_Glob:            5
        should be:   5
Bool_Glob:           1
        should be:   1
Ch_1_Glob:           A
        should be:   A
Ch_2_Glob:           B
        should be:   B
Arr_1_Glob[8]:       7
        should be:   7
Arr_2_Glob[8][7]:    40000010
        should be:   Number_Of_Runs + 10
Ptr_Glob->
  Ptr_Comp:          151560
        should be:   (implementation-dependent)
  Discr:             0
        should be:   0
  Enum_Comp:         2
        should be:   2
  Int_Comp:          17
        should be:   17
  Str_Comp:          DHRYSTONE PROGRAM, SOME STRING
        should be:   DHRYSTONE PROGRAM, SOME STRING
Next_Ptr_Glob->
  Ptr_Comp:          151560
        should be:   (implementation-dependent), same as above
  Discr:             0
        should be:   0
  Enum_Comp:         1
        should be:   1
  Int_Comp:          18
        should be:   18
  Str_Comp:          DHRYSTONE PROGRAM, SOME STRING
        should be:   DHRYSTONE PROGRAM, SOME STRING
Int_1_Loc:           5
        should be:   5
Int_2_Loc:           13
        should be:   13
Int_3_Loc:           7
        should be:   7
Enum_Loc:            1
        should be:   1
Str_1_Loc:           DHRYSTONE PROGRAM, 1'ST STRING
        should be:   DHRYSTONE PROGRAM, 1'ST STRING
Str_2_Loc:           DHRYSTONE PROGRAM, 2'ND STRING
        should be:   DHRYSTONE PROGRAM, 2'ND STRING

Microseconds for one run through Dhrystone:    0.2 
Dhrystones per Second:                      5000000.0 


위의 나온 결과로 아래와 같이 본인이 계산을 해야한다.

5000000.0 / 1757  = 2845.7598178713716562322140011383   // 1757로 나눈다.
2845.7598178713716562322140011383  / 1000MHz (CPU CLOCK) = 2.84 


CPU Clock     =  1000MHz
DMIPS / MHz =  2.84 DMIPS

   아래에서 Dhryston 관련사이트에서 확인 반드시 확인.
   https://en.wikipedia.org/wiki/Dhrystone

   ARM 관련 Chip들 DMIPS 정보를 보고 비교해보자.
   https://en.wikipedia.org/wiki/List_of_ARM_microarchitectures

   DMIPS 계산방법
   http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0273a/ar01s05.html


1.3 Whetstone

사용법은 Loop 횟수를 적어줘야한다.
나온결과는 Millions of Whetstone Instructions Per Second (MWIPS)


/usr/bin/whetstone 100000   // loop count를 입력해야한다. 

Loops: 100000, Iterations: 1, Duration: 6 sec.
C Converted Double Precision Whetstones: 1666.7 MIPS



   Whetstone 관련내용
   https://en.wikipedia.org/wiki/Whetstone_(benchmark)

1.4 Linpack

Floating Point Operation을 TEST하기 위한 Benchmark Program이라고 하며, output은 KFLOPS


# /usr/bin/linpack
Unrolled Single Precision Linpack

Unrolled Single Precision Linpack

     norm. resid      resid           machep         x[0]-1        x[n-1]-1
       1.6        3.80277634e-05  1.19209290e-07 -1.38282776e-05 -7.51018524e-06
    times are reported for matrices of order   100
      dgefa      dgesl      total       kflops     unit      ratio
 times for array with leading dimension of  201
       0.02       0.00       0.02      34333       0.06       0.36
       0.02       0.00       0.02      34333       0.06       0.36
       0.01       0.00       0.01      68667       0.03       0.18
       0.01       0.00       0.01      68667       0.03       0.18
 times for array with leading dimension of 200
       0.00       0.00       0.00        inf       0.00       0.00
       0.02       0.00       0.02      34333       0.06       0.36
       0.00       0.00       0.00        inf       0.00       0.00
       0.01       0.00       0.01     114444       0.02       0.11
Unrolled Single  Precision 68667 Kflops ; 10 Reps 

Linpack에 관련내용
   https://en.wikipedia.org/wiki/LINPACK_benchmarks


1.5 lmbench로 Memory 성능측정

lmbench의 한 bin 파일로 기본 사용법 lmbench package를 넣어 TEST 해보자.

//AM487x EVM TEST 

# bw_mem 1M rd
1.00 359.91

# bw_mem 1M wr
1.00 305.75

# bw_mem 1M rdwr
1.00 281.14

# bw_mem 1M cp
1.00 181.46

# bw_mem 1M fwr
1.00 676.59

# bw_mem 1M frd
1.00 269.40

# bw_mem 1M fcp
1.00 214.76

# bw_mem 1M bzero
1.00 675.68

# bw_mem 1M bcopy
1.00 252.87

  http://lmbench.sourceforge.net/cgi-bin/man?section=8&keyword=bw_mem



  • 시스템 관련 성능 측정

위에서 언급한 lmbench package이며, 다양한 TEST가 가능하다.
  1. RAM 관련 TEST 
  2. File 관련 TEST
  3. Network TEST
  4. TLB 및 Cache TEST
  5. UNIX Function Memory Map TEST 

각각의 지연시간(Latency)를 확인이 가능하며, 성능개선을 위해 알아 둬야 할 것 같다.
더불어 Hardware or Software 적으로 최적화를 진행을 하고 TEST를 해보면 추후
좋을 것 같다.

  http://lmbench.sourceforge.net/cgi-bin/man?keyword=lmbench&section=8


  • lmbench 소스와 관련사용법 TI에서 제공

아래의 사이트에서 자세한 기본사용법과 소스를 다운받아 사용해보자.

   http://processors.wiki.ti.com/index.php/Lmbench
   https://sourceforge.net/projects/lmbench/


2. BenchMark 관련소스 및 Bin Download

상위 CPU 관련 성능 측정관련 Source 및 Bin 파일

   https://github.com/tonyho/ARM_BenchMark

8/31/2016

AM437x 와 AM335x RAM Interface 비교

1. AM43xx 와 AM335x RAM Interface 비교 

AM335x는 RAM Bus가 16bit이며, AM437x는 32bit이다 RAM Interface에 있어 Memory Bandwidth 에서 많은 성능차이를 보인다.
물론 상위 16bit 와 32bit는 SoC 내부에서 연결된 Interface이고 외부는 동일하게 32bit로 구성이 되어있다.
이는 이전에 Davinci Series로 출시된  DM6467 와 DM355 와 거의 동일하다.

만약 Memory Bandwidth의 최대성능을 사용하고 싶다면, 다른 SoC와 같이 AM335x는 RAM을 16bit bus로 2개로 사용하여 32bit로 연결하면 될것이고,
AM437x일 경우 RAM을 8bit bus로 4개로 사용하여 32bit를 연결하면 될 것이다.

Sitara series와 Davinci Series의 ARM의 Version과 GPU의 기능 추가이며, 큰 차이는
기존에 OMAP 일부기능들을 많이 그대로 가져오고 있다.

Power Management부터 시작하여 Graphic Interface, 거의 OMAP과 유사하지만,
Davinci Series에서 사용했던 *DeepSleep모든 존재, 물론 ARM version 차이도 존재하지만
요즘들어 Davinci와 OMAP Series가 모호해지고, Sitara가 나오며, 기능을 섞어서
나오니 좀 애매할 뿐이다.

일단 두 SOC의 RAM Interface에 있어 성능에 있어서도 차이가 있겠지만, 일단 여기서는 두개의 RAM Interface인 EMIF를 비교해보자.

*DeepSleep 모드
DeppSleep모드를 사용해본 경혐이 있어, 이를 사용할 경우, Self Refresh Mode와 TCM(SRAM)사용은 필수였다.
추후 시간이 있다면 이부분도 조사.


  • AM335x
   http://www.ti.com/lit/ds/symlink/am3358.pdf
   http://www.ti.com/lit/ds/symlink/am3359.pdf


  • AM437x
   http://www.ti.com/lit/ds/symlink/am4372.pdf


1.1 AM335x(AM3358)
위에서 설명했듯이 일단 CPU는 32bit 이지만, 32bit를 Data를 저장하기 위해서 EMIF Interface가 16bit이기 때문에 Data를 두번에 나누어서 보내야 할 것이다,
때문에 성능이 거의 반이라고 생각을 하고 있다. 혹시 Thumb Mode를 사용하면 모를까

Errata를 보면, DDR3일 경우 Self refresh mode가 문제가 있다.
이부분은 Power Management와 직접연관이 있으므로 주의해야 겠다.

External Memory Interfaces (EMIF)
  • mDDR(LPDDR), DDR2, DDR3, DDR3L Controller:
    • mDDR: 200-MHz Clock (400-MHz Data Rate)
    • DDR2: 266-MHz Clock (532-MHz Data Rate)
    • DDR3: 400-MHz Clock (800-MHz Data Rate)
    • DDR3L: 400-MHz Clock (800-MHz Data Rate)
    • 16-Bit Data Bus
    • 1GB of Total Addressable Space
    • Supports One x16 or Two x8 Memory Device Configurations
  • General-Purpose Memory Controller (GPMC)
    • Flexible 8-Bit and 16-Bit Asynchronous Memory Interface With up to Seven Chip Selects (NAND, NOR, Muxed-NOR, SRAM)
    • Uses BCH Code to Support 4-, 8-, or 16-Bit ECC
    • Uses Hamming Code to Support 1-Bit ECC
  • Error Locator Module (ELM)
    • Used in Conjunction With the GPMC to Locate Addresses of Data Errors from Syndrome Polynomials Generated Using a BCH Algorithm
    • Supports 4-, 8-, and 16-Bit per 512-Byte Block Error Location Based on BCH Algorithms

   http://www.ti.com/lit/ug/spruh73o/spruh73o.pdf
 

1.2 AM437x(AM4372)  
AM335x와 다르게, 전형적인 일반적인 RAM Interface (EMIF) 를 가지고 있어, 크게 걱정없다.

  • External Memory Interfaces (EMIFs)
    • DDR Controllers:
      • LPDDR2: 266-MHz Clock (LPDDR2-533 Data Rate)
      • DDR3 and DDR3L: 400-MHz Clock (DDR-800 Data Rate)
      • 32-Bit Data Bus
      • 2GB of Total Addressable Space
      • Supports One x32, Two x16, or Four x8 Memory Device Configurations
  • General-Purpose Memory Controller (GPMC)
    • Flexible 8- and 16-Bit Asynchronous Memory Interface With up to Seven Chip Selects (NAND, NOR, Muxed-NOR, and SRAM)
    • Uses BCH Code to Support 4-, 8-, or 16-Bit ECC
    • Uses Hamming Code to Support 1-Bit ECC
  • Error Locator Module (ELM)
    • Used With the GPMC to Locate Addresses of Data Errors From Syndrome Polynomials Generated Using a BCH Algorithm
    • Supports 4-, 8-, and 16-Bit Per 512-Byte Block Error Location Based on BCH Algorithms

   http://www.ti.com/lit/ug/spruhl7f/spruhl7f.pdf

8/24/2016

AM335x 와 AM43xx 기본기능 비교 (추후 문서 통합)

1 TI-Sitara 비교 (AM335x, AM437x) 

Sitara AM335x와 AM437x의 기본구조를 간단히 비교를 해보자.

기본적으로 볼때는 거의 유사하지만, Cortex Version이 다르다.
AM335x에서는 성능상 부분에 필요없는 기능들을 많이 없애고,
가격을 고려하여, SRAM 제거 및 DDR 내부 Interface 16bit 변경하였다.
AM335x는 MIPI Interface가 존재 하지도 않으며, Camera 기능이 존재하지 않는다.
반면, AM437x는 MIPI와 Camera를 지원을 해준다.
AM335x는 성능을 줄이다보니, McASP도 줄이고 다른기능도 역시 줄이게되었다.

하지만 기본적인 Framework은 둘다 거의 유사하며, SW적으로도 거의유사하다.



이를 다시 DM8148과 비교하면, HDVICP2 기능과 HDVPSS기능이 없어졌다.
이로 인하여 HDVPSS기능대신 Camera Inteface 및 Display 관련 모듈로 대체 되었다.
그리고, Sitara는 HDMI가 지원이 되지 않는다.

DM8148도 Opp기능 즉 Power Management 기능은 Sitara도 존재하지만
이는 물론 PMIC와 같이 사용해야 봐야 알겠지만,이부분은 아직 자세히 보지 않았다.

지금보면 SW적으로 OMAP의 모듈과 유사하지만, Sitara라는 동영상재생을 위해 FFmpeg을 사용한다.
이는 기존의 HW Codec을 사용하는 것과 차별성이 있다.





  http://www.ti.com/product/AM3359
  http://www.ti.com/product/am4379


1.1 AM335x 관련 주요기능 


http://www.ti.com/general/docs/datasheetdiagram.tsp?genericPartNumber=AM3358&diagramId=43666

 

  • Power Consumption

   http://wiki.tiprocessors.com/index.php/AM335x_Power_Consumption_Summary

  • PRICE
   http://www.ti.com/product/AM3358/samplebuy






3. Multimedia 지원기능 

일단 AM57xx 제외하고는 기본적으로 AM335x, AM37xx는 FFmpeg으로 Software Codec으로
ARM의 Neon으로 사용동작되기 때문에 성능상의 제약이 따른다. 이는 어쩔수가 없다.


Datasheet에는 OpenMAX가 지원이 되는것 같은데, 아직 이 Processor를 가지고 Multimedia까지 해보지 않아 정확한 한계를 모르겠다.

아래의 Site보면 FFMPEG으로 사용할 경우, AM335x의 경우 지원되는 해상도 및 CPU 성능이 나오지만,
Scale 부분이 정확히 되는지는 궁금하다.

아래정보를 보면, 오직 참고용으로만 사용하라고 한다. 정확한 지원이 아닌것 같다.

OMAP처럼 IVA-HD (Hardware Codec) 는 존재하지 않으며, DSP또한 존재하지 않는다.
  • FFMPEG 지원사항 ( 지원 Codec) (ARM Neon )
  • FFMEPG을 사용할 경우 CPU 점유율 및 기타 정보 
  http://processors.wiki.ti.com/index.php/ARM_Multimedia_Users_Guide#CPU_and_Memory_load


3.1 Graphics Interface (GPU)

  • AM335x 와 AM43xx인 경우 SGX530 ( Datasheet 참고)
       둘다 동일한 SGX530을 사용을 한다.  OpenMAX API는 제공을 하지만,
       HW Encoder/Decoder가 존재하지 않는다. FFMPEG을 이용해야만 하는 것 같다. 
  • AM57xx SGX544와 DSP  (Datasheet 참고)
       추후 사용할 경우 자세히 기술



  • DM81xx

DM81xx 인 경우  Graphic Interface에서 OpenMax API를 제공을 하고,
이를 HDVICP2와 연결하여 HW Encode/Decode를 한다.



  http://processors.wiki.ti.com/index.php/DM81xx_Gstreamer_Plugin


8/14/2015

Uboot Script 이해 및 Device Tree Boot 설정 (Sitara)

1. Uboot Env 환경변수 

setenv or set : 명령이용하여 환경변수 설정가능 uboot에서 많은 환경변수를 제공하며, script기능도 제공

1.1 Uboot Hush Script 이해

환경변수 설정과 기본 script 실행하는 방법은 아래와 같으며, Uboot에서 사용하는 Command는 Uboot 빌드시 CONFIG 옵션에 따라
변경되기 때문에 차이는 있지만, 기본 Command들은 대체적으로 알아두자.

  • UBoot의 기본 env 와 command 이해 
  1. bootcmd:  uboot가 기본적으로 실행되는 변수 (가장중요)
  2. 이외에 암묵적으로 많이 사용하는 환경변수가 존재 (stdin,stdout, 등 ) 
  3. script의 기본은 uboot cmd의 나열로 구성하고 환경변수 및 구분자를 세미콜론사용
  4. run을 이용하여 만들어진 script을 실행가능 
  5. setenv 이용하여 환경변수 및 script 생성  

  • UBoot Script 의 확장이해 
  1. if <list>; then <command list>; [elif <list>; then <list>; ] [else <list>; then <list>;]
  2. while <list>; do <list>; done
  3. until <list>; do <list>; done
  4. for <name> in <word list>; do <list> ; done

1,2,3 앞에 test command를 이용하여 비교가 가능하며,  뒤에 는 script or 환경변수를 넣으면 된다.   

  http://www.compulab.co.il/utilite-computer/wiki/index.php/U-Boot_Scripts

1.2 Uboot Hush Script 의 예제 

위에서 확장으로 사용되는 예제들을 한번 살펴보자.

  • Uboot Script  if 문 test 예제 
test command를 이용하여 비교하고, 그 결과을 적용

findfdt=if test $board_name = AM43EPOS; then setenv fdtfile am43x-epos-evm.dtb; fi; if test $board_name = AM43__GP; then setenv fdtfile am437x-gp-evm.dtb; fi; if test $board_name = AM43__SK; then setenv fdtfile am437x-sk-evm.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree; fi; // if문 예제 

  • Uboot Script for 문 예제 
boot_target 이라는 word_list에서 target이라는 변수를 만들어 반복문을 만들어 여러 bootcmd_target을 실행한다.

boot_targets=mmc0 legacy_mmc0 mmc1 legacy_mmc1 nand0 pxe dhcp    // target list 
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done  //for boot_targets에서 환경변수에서 target을 추출하여 bootcmd_x 실행
bootcmd_dhcp=run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi
bootcmd_legacy_mmc0=setenv mmcdev 0; setenv bootpart 0:2 ; run mmcboot
bootcmd_legacy_mmc1=setenv mmcdev 1; setenv bootpart 1:2 ; run mmcboot
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_mmc1=setenv devnum 1; run mmc_boot
bootcmd_nand=run nandboot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi

uboot script은 쉽게 이해가능하며, 누구나 쉽게 사용가능.


1.3 외부 Uboot Script 사용방법

  • Uboot에서 Uboot Script 실행
Uboot에서 FAT에서 boot.scr를 읽어서 이를 source를 이용하여 실행하며, 보통 SDCard Boot를 했을 때 사용한다.

U-Boot# pri
...
script_addr=0x80900000
loadbootscript=fatload mmc 0 ${script_addr} boot.scr
bootscript= echo Running bootscript from MMC/SD to set the ENV...; source ${script_addr}
bootcmd=if mmc init; then if run loadbootscript; then run bootscript; else if run loaduimage; then run mmcboot; else run nandboot; f
i; fi; else run nandboot; fi
...

  • 외부 Uboot Script 생성방법
$ vi boot-nfs.txt 
setenv bootargs 'console=ttyO0,115200n8 root=/dev/nfs nfsrootdebug rw rootdelay=10 mem=80M vram=4M notifyk.vpssm3_sva=0xBFD00000 nfsroot=192.168.1.100:/home/jhlee/dm8127/work/Source/ipnc_rdk/target/filesys,nolock eth=32:30:3a:63:64:3a ip=192.168.1.168 cmemk.phys_start=0x85000000 cmemk.phys_end=0x89000000 cmemk.allowOverlap=1 earlyprintk'

$ mkimage -A arm -T script -C none -d boot-nfs.txt  boot.scr // Uboot Script 생성

생성된 boot.scr를 FAT에 복사하여 실행가능하여 이외에도 상위의 if문을 비롯하여 다양한 연속적인 Uboot Script을 생성가능하다


  • mkimage 설치
Uboot안에 mkimage가 존재하지만, PATH설정를 비롯하여 귀찮아서 직접 설치
$ sudo apt-get install uboot-mkimage //mkimage가 없을 경우 설치 

  https://wiki.ubuntu.com/ARM/EditBootscr
  http://www.denx.de/wiki/DULG/UBootScripts

2. Uboot 와 Device Tree Boot 설정 

AM437x와 AM335x는 Uboot에서 손쉽게 Device Tree Boot를 설정변경이 가능하며,
이전에 Device Tree File에 대해서 설명했듯이 zImage와 dtb 파일은 filesystem의 /boot라는 곳에 저장이 되어있다.

Device Tree 관련내용
  https://ahyuo79.blogspot.com/2015/08/kernel-boot-kernel-device-tree.html

  • Uboot 와 Device Tree Boot 역할
각각의 File (zImage와 *.dtb) 들을  Load를 하면 Uboot Device Tree 기본역할은 한것이며, 이 관련 script을 수정을하면된다.


  • Device Tree Boot 설정 변경 (다양한 Kernel 및 Device Tree 선택)
Uboot Script or 환경변수 설정을 변경하여 이를 변경하자
특히 findfdt는 device tree의 file을 설정을 하는 것이며, findfdt 대신 직접 설정을 하여도 좋다.


2.1 Uboot의 boot 분석 (AM437x-EVM-GP)

이제 중요한 uboot에서 dtb을 찾고 zImage를 찾아 booting을 해보자
기본명령어는 다음과 같다

bootz ${loadaddr} - ${fdtaddr} 


FDT (Flattened Device Tree) 는  DTB (Device Tree Blob)를 말하며 관련 구조는 Device Tree Spec를 참조

  • Uboot Env MMC BOOT 분석 
  1. bootcmd : dtb를 찾아 설정 후 mmcboot / usbboot/ nand boot로 순차실행
  2. findfdt : 현재 board_name에 따라 fdtfile 에 dtb 파일설정
  3. mmcboot: mmc device를 설정하고 rescan 
  4. mmcboot: uEnv.txt (uboot Env) File이 존재한다면 찾아 설정 
  5. mmcboot: importenv는 외부에 존재 할 경우,  uenvcmd는 존재할 경우 동작  두부분 생략
  6. mmcboot: loadimage로 kernel을  load_addr로 load 한다 ( File system의 /boot) 
  7. mmcboot: loadfdt로 dtb file을 fdt_addr로 load한다   (File system의 /boot)
  8. mmcboot: mmcargs로 kernel argument 설정
  9. mmcboot: bootz ${loadaddr} - ${fdtaddr} 로 kernel과 dtb booting  


U-Boot# pri
arch=arm
baudrate=115200
board=am43xx
board_name=AM43__GP
board_rev=1.4A
bootcmd=run findfdt; run mmcboot;run usbboot;run nandboot; 
bootdelay=1
bootdir=/boot
bootenv=uEnv.txt
bootfile=zImage
bootm_size=0x10000000
bootpart=0:2
console=ttyO0,115200n8
cpu=armv7
dfu_alt_info_emmc=MLO raw 0x100 0x100 mmcpart 0;u-boot.img raw 0x300 0x1000 mmcpart 0
dfu_alt_info_mmc=boot part 0 1;rootfs part 0 2;MLO fat 0 1;spl-os-args fat 0 1;spl-os-image fat 0 1;u-boot.img fat 0 1;uEnv.txt fat 0 1
dfu_alt_info_ram=kernel ram 0x80200000 0x4000000;fdt ram 0x80f80000 0x80000;ramdisk ram 0x81000000 0x4000000
dfu_bufsiz=0x10000
eth1addr=34:b1:f7:30:fb:00
ethact=cpsw
ethaddr=34:b1:f7:30:f7:fe
fdt_addr_r=0x88000000
fdtaddr=0x88000000
fdtfile=undefined
findfdt=if test $board_name = AM43EPOS; then setenv fdtfile am43x-epos-evm.dtb; fi; if test $board_name = AM43__GP; then setenv fdtfile am437x-gp-evm.dtb; fi; if test $board_name = AM43__SK; then setenv fdtfile am437x-sk-evm.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree; fi; 
importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
kernel_addr_r=0x82000000
loadaddr=0x82000000
loadbootenv=load ${devtype} ${devnum} ${loadaddr} ${bootenv}
loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadramdisk=load ${devtype} ${devnum} ${rdaddr} ramdisk.gz
mmcargs=setenv bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}
mmcboot=mmc dev ${mmcdev}; setenv devnum ${mmcdev}; setenv devtype mmc; if mmc rescan; then echo SD/MMC found on device ${devnum};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loadimage; then run loadfdt; echo Booting from mmc${mmcdev} ...; run mmcargs; bootz ${loadaddr} - ${fdtaddr}; fi;fi;
mmcdev=0
mmcroot=/dev/mmcblk0p2 rw
mmcrootfstype=ext4 rootwait
mtdids=nand0=nand.0
mtdparts=mtdparts=nand.0:256k(NAND.SPL),256k(NAND.SPL.backup1),256k(NAND.SPL.backup2),256k(NAND.SPL.backup3),512k(NAND.u-boot-spl-os),1m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup1),7m(NAND.kernel),-(NAND.file-system)
nandargs=setenv bootargs console=${console} ${optargs} root=${nandroot} rootfstype=${nandrootfstype}
nandboot=echo Booting from nand ...; run nandargs; nand read ${fdtaddr} NAND.u-boot-spl-os; nand read ${loadaddr} NAND.kernel; bootz ${loadaddr} - ${fdtaddr}
nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,4096
nandrootfstype=ubifs rootwait=1
netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
netboot=echo Booting from network ...; setenv autoload no; dhcp; tftp ${loadaddr} ${bootfile}; tftp ${fdtaddr} ${fdtfile}; run netargs; bootz ${loadaddr} - ${fdtaddr}
nfsopts=nolock
partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}
ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}
ramdisk_addr_r=0x88080000
ramroot=/dev/ram0 rw
ramrootfstype=ext2
rdaddr=0x88080000
rootpath=/export/rootfs
soc=am33xx
static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
stderr=serial
stdin=serial
stdout=serial
usbargs=setenv bootargs console=${console} ${optargs} root=${usbroot} rootfstype=${usbrootfstype}
usbboot=setenv devnum ${usbdev}; setenv devtype usb; usb start ${usbdev}; if usb dev ${usbdev}; then if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loadimage; then run loadfdt; echo Booting from usb ${usbdev}...; run usbargs;bootz ${loadaddr} - ${fdtaddr}; fi;fi;usb stop ${usbdev};
usbdev=0
usbnet_devaddr=34:b1:f7:30:fb:00
usbroot=/dev/sda2 rw
usbrootfstype=ext4 rootwait
vendor=ti
ver=U-Boot 2014.07-gfb6ab76 (Jul 06 2015 - 16:10:49)

Environment size: 4128/65532 bytes 

  • Uboot Env ( NFS - Network 고정 IP Mode)
현재 dhcp를 사용하며 ip가 바뀌어서 고정 ip로 변경하기로 결정.
만약 AP에서 dhcp 세부설정이 가능하다면 위와 같이 사용.

setenv ipaddr '192.168.1.101'
setenv serverip '192.168.1.100'
setenv netmask '255.255.255.0'
setenv rootpath '/home/jhlee/am437x/targetNFS'
setenv netargs 'setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=${ipaddr}' 
setenv netboot1 'echo Booting from network ...; setenv autoload no; tftp ${loadaddr} ${bootfile}; tftp ${fdtaddr} ${fdtfile}; run netargs; bootz ${loadaddr} - ${fdtaddr}'

setenv bootcmd 'run findfdt; run netboot1;'
setenv bootfile 'zImage'
setenv fdtfile 'am437x-gp-evm.dtb'  //직접 설정 후 run findfdt를 삭제가능 


Linux server의 /tftpboot에 bootfile과 fdtfile을 보관해야한다.


2.2 Uboot Env 분석 (AM335x SK, Start Kit )

AM437x와 거의 동일하며 UBOOT에서  zImage와 *.dtb을 변경을 해주면된다.

  • Device Tree Booting Command
bootz ${loadaddr} - ${fdtaddr} 


  • Uboot Env 분석 
=>pri
arch=arm
args_fit=setenv bootargs console=${console} 
args_mmc=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
baudrate=115200
board=am335x
board_name=A335X_SK
board_rev=1.2B
board_serial=34124P192908
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};elsebootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf
boot_fdt=try
boot_fit=0
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_targets=mmc0 legacy_mmc0 mmc1 legacy_mmc1 nand0 pxe dhcp 
bootcmd=if test ${boot_fit} -eq 1; then run update_to_fit;fi;run findfdt; run init_console; run envboot; run distro_bootcmd
bootcmd_dhcp=run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi
bootcmd_legacy_mmc0=setenv mmcdev 0; setenv bootpart 0:2 ; run mmcboot
bootcmd_legacy_mmc1=setenv mmcdev 1; setenv bootpart 1:2 ; run mmcboot
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_mmc1=setenv devnum 1; run mmc_boot
bootcmd_nand=run nandboot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootcount=4
bootdelay=2
bootdir=/boot
bootenvfile=uEnv.txt
bootfile=zImage
bootm_size=0x10000000
bootpart=0:2
bootscript=echo Running bootscript from mmc${mmcdev} ...; source ${loadaddr}
console=ttyO0,115200n8
cpu=armv7
dfu_alt_info_emmc=rawemmc raw 0 3751936
dfu_alt_info_mmc=boot part 0 1;rootfs part 0 2;MLO fat 0 1;MLO.raw raw 0x100 0x100;u-boot.img.raw raw 0x300 0x400;spl-os-args.raw raw 0x80 0x80;spl-os-image.raw raw 0x900 0x2000;spl-os-args fat 0 1;spl-os-image fat 0 1;u-boot.img fat 0 1;uEnv.txt fat 0 1
dfu_alt_info_nand=SPL part 0 1;SPL.backup1 part 0 2;SPL.backup2 part 0 3;SPL.backup3 part 0 4;u-boot part 0 5;u-boot-spl-os part 0 6;kernel part 0 8;rootfs part 0 9
dfu_alt_info_ram=kernel ram 0x80200000 0xD80000;fdt ram 0x80F80000 0x80000;ramdisk ram 0x81000000 0x4000000
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
envboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootscript; then run bootscript;else if run loadbootenv; then echo Loaded env from ${bootenvfile};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;fi;fi;
eth1addr=d4:94:a1:86:70:e1
ethaddr=d4:94:a1:86:70:e0
fdt_addr_r=0x88000000
fdtaddr=0x88000000
fdtcontroladdr=8ef282f8
fdtfile=undefined
findfdt=if test $board_name = A335BONE; then setenv fdtfile am335x-bone.dtb; fi; if test $board_name = A335BNLT; then setenv fdtfile am335x-boneblack.dtb; fi; if test $board_name = BBG1; then setenv fdtfile am335x-bonegreen.dtb; fi; if test $board_name = A33515BB; then setenv fdtfile am335x-evm.dtb; fi; if test $board_name = A335X_SK; then setenv fdtfile am335x-evmsk.dtb; fi; if test $board_name = A335_ICE; then setenv fdtfile am335x-icev2.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree to use; fi; 
finduuid=part uuid mmc ${bootpart} uuid
fit_bootfile=fitImage.itb
fit_loadaddr=0x88000000
importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}
init_console=if test $board_name = A335_ICE; then setenv console ttyO3,115200n8;else setenv console ttyO0,115200n8;fi;
kernel_addr_r=0x82000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x82000000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr
loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadfit=run args_fit; bootm ${loadaddr}#${fdtfile};
loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_part; fi
mmcboot=mmc dev ${mmcdev}; setenv devnum ${mmcdev}; setenv devtype mmc; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadimage; then if test ${boot_fit} -eq 1; then run loadfit; else run mmcloados;fi;fi;fi;
mmcdev=0
mmcloados=run args_mmc; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdtaddr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
mmcrootfstype=ext4 rootwait
mtdids=nand0=nand.0
mtdparts=mtdparts=nand.0:128k(NAND.SPL),128k(NAND.SPL.backup1),128k(NAND.SPL.backup2),128k(NAND.SPL.backup3),256k(NAND.u-boot-spl-os),1m(NAND.u-boot),128k(NAND.u-boot-env),128k(NAND.u-boot-env.backup1),8m(NAND.kernel),-(NAND.file-system)
nandargs=setenv bootargs console=${console} ${optargs} root=${nandroot} rootfstype=${nandrootfstype}
nandboot=echo Booting from nand ...; run nandargs; nand read ${fdtaddr} NAND.u-boot-spl-os; nand read ${loadaddr} NAND.kernel; bootz ${loadaddr} - ${fdtaddr}
nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,2048
nandrootfstype=ubifs rootwait=1
netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
netboot=echo Booting from network ...; setenv autoload no; dhcp; run netloadimage; run netloadfdt; run netargs; bootz ${loadaddr} - ${fdtaddr}
netloadfdt=tftp ${fdtaddr} ${fdtfile}
netloadimage=tftp ${loadaddr} ${bootfile}
nfsopts=nolock
partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}
pxefile_addr_r=0x80100000
ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}
ramboot=echo Booting from ramdisk ...; run ramargs; bootz ${loadaddr} ${rdaddr} ${fdtaddr}
ramdisk_addr_r=0x88080000
ramroot=/dev/ram0 rw
ramrootfstype=ext2
rdaddr=0x88080000
rootpath=/export/rootfs
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootarm.efi; then echo Found EFI removable media binary efi/boot/bootarm.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x80000000
soc=am33xx
spiargs=setenv bootargs console=${console} ${optargs} root=${spiroot} rootfstype=${spirootfstype}
spiboot=echo Booting from spi ...; run spiargs; sf probe ${spibusno}:0; sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; bootz ${loadaddr}
spibusno=0
spiimgsize=0x362000
spiroot=/dev/mtdblock4 rw
spirootfstype=jffs2
spisrcaddr=0xe0000
static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
stderr=serial@44e09000
stdin=serial@44e09000
stdout=serial@44e09000
update_to_fit=setenv loadaddr ${fit_loadaddr}; setenv bootfile ${fit_bootfile}
usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot_part; fi
usbnet_devaddr=de:ad:be:ef:00:01
vendor=ti
ver=U-Boot 2016.05-g6c5519b6fc (Dec 14 2016 - 19:14:27 -0500)

Environment size: 8557/131068 bytes

8/13/2015

Device Tree 기반 소스수정 및 빌드 (U-Boot 와 Kernel)

1. Device Tree의 DTS 기본구조 및 Build 

Device Tree Syntax의 약자이며, Kernel 와  Uboot에 존재하며, 보통 두개의 dts 파일은 동일하다
  1. Kernel PATH:  arch/arm/boot/dts 
  2. Uboot PATH:  arch/arm/dts/

Device Tree Boot 방식
  https://ahyuo79.blogspot.com/2015/08/am437x-kernel-device-tree.html
  https://ahyuo79.blogspot.com/2015/08/device-tree-2-am437xam335x.html

Device Tree Syntax 구성방법
  https://ahyuo79.blogspot.com/2015/08/device-tree.html

지향하는 바는 DTS를 한번 설정하면 손쉽게 Uboot 와 Kernel 의 HW 설정변경 가능하도록하는 것이다.
물론 예외적으로 보면, 각 Image들과 결합을 하게되어 사용을 한다면, 따로 사용도 가능하겠다.

DTSI와 DTS파일이 존재하며, DTSI는 DTS에서 include하는 파일이며, 구조 또한 동일하다.
하지만, dt-bindings도 include를 하지만 header 파일로 사용이 된다.

Build 전에는 DTS와 DTSI만 존재하지만, Build 후에 DTB가 생성이된다.
  1. Main files: ./arch/arm/boot/dts 
  2. Include Files: ./arch/arm/boot/dts/include/dt-bindings
  3. Makefile./arch/arm/boot/dts/Makefile

1.1 AM437x Example
AM437x-GP-EVM 을 사용을 하며 TEST을 하고 있다.

$ ls arch/arm/boot/dts/am4*
am4372.dtsi             am437x-gp-evm.dtb  am437x-sk-evm.dtb  am43x-epos-evm-hdmi.dts  am43x-epos-evm.dts
am437x-gp-evm-hdmi.dts  am437x-gp-evm.dts  am437x-sk-evm.dts  am43x-epos-evm.dtb       am43xx-clocks.dtsi 


1.2 I.MX6 인 Example

I.MX6를 수정을 할때, 참고하던 Device Tree 예제들이며, 현재 Device Tree로 대부분의 CPU들이 지원을 하는 것 같다.
특히 한 것은 pinctl (iomuxc) 하는 방식이 TI와 다르게 사용되며, 관련부분은 별도로 봐야한다.

$ cat arch/arm/boot/dts/imx6ull-pinfunc.h  // 핀확인 IOMUXC Register 확인 (Kernel 소스)
$ vi arch/arm/boot/dts/imx6ul*   //

&iomuxc {
...
    pinctrl_can_int: canintgrp {
        fsl,pins = < 
            /*
               IOMUXC_SW_MUX_CTL_PAD : MX6UL_PAD_ENET1_TX_DATA1__GPIO2_IO04
               IOMUXC_SW_PAD_CTL_PAD : 0x13010   (세부설정가능 Open Drain / Pull / Hysteresis Enable)
                                     : 0x80000000  상위 설정과 다르게 PAD Register를 변경을 막는다고 하는데, bit31/30은 자세한내용은 커널문서 
             */
            MX6UL_PAD_ENET1_TX_DATA1__GPIO2_IO04    0x13010      /* SODIMM 73 */ 
        >;
    };
...
};

/sys/kernel/debug 가 되는 경우 아래와 같이 Pin 설정확인

$ ls /sys/kernel/debug/pinctrl/  // Target Device에서 debug 모드로 연결하여 확인 

$ cat /sys/kernel/debug/pinctrl/pinctrl-handles  // Target Device에서 설정확인 
Requested pin control handlers their pinmux maps:
device: 20e0000.iomuxc current state: default
........

$ cat /sys/kernel/debug/pinctrl/pinctrl-maps     // 관련정보 
$ cat /sys/kernel/debug/pinctrl/20e0000.iomuxc/pingroups


// GPIO 의 경우 sysfs에서 도 사용가능하지만, 직접 device tree의 모듈에 연결이 되어 사용가능하므로 주의
// 이때 아래와 같이 확인한 후 device tree에서 연결된 모듈의 gpio부분을 제거한 후 사용 

$ cat /sys/kernel/debug/gpio  // GPIO 정보 Debug 
..........
 gpio-112 (                    |peri_3v3            ) out hi
 gpio-114 (                    |sysfs               ) out lo
 gpio-116 (                    |sysfs               ) out lo
 gpio-117 (                    |sysfs               ) out lo
 gpio-118 (                    |sysfs               ) out lo
 gpio-119 (                    |sysfs               ) out lo
 gpio-122 (                    |sysfs               ) out lo
 gpio-123 (                    |can-stby            ) out hi
 gpio-127 (                    |sysfs               ) out lo

최근에 찾은 자료이며, i.MX6의 Device Tree 구조를 아래 사이트에서 쉽게 볼수 있어 업데이트한다.

  • i.MX의 Device Tree

i.MX6 관련내용 
  http://developer.toradex.com/device-tree-customization
  https://developer.toradex.com/device-tree-customization#2-imx-6ull-based-modules

/sys/kernel/debug 관련내용
  https://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/ch09s07.html

2. Device Tree 의 수정 및 사용법

Device Tree를 이해한다고, ARM BOOT를 다시 전체 분석을 할 필요는 없다.
지금 현재 제대로 동작을 하고 있으며, 필요한 모듈과 그기능을 찾아 그 부분만 수정을 하면 되기에 dts 파일과 dtsi파일을 이해하고 수정을 하면 되겠다.

2.1  DTS와 각 Driver의 구조 (AM437x 인 경우)

DTS파일과 각 Driver의 기본구조는 다음과 같다.
device tree의 기본동작 방식은 dts파일 안의 compatible의 이름과 driver의 맞을 경우 그 해당하는 driver에게 맞게 동작하게 되어있다.


그러므로, Kernel을 빌드후 다음과 같이 dts의 compatible의 이름을 검색하여 찾아 수정을하면 된다.



Device Tree의 위치는 위에서 설명했듯이 arch/arm/boot/dts/ 보면될 것이지만,관련된 부분을 전부 검색을 해보자.

  • Device Tree Source 관련소스 (driver) 검색  
  1. Kernel을 빌드 후, find들 이용하여 *.o file list 생성된다. 
  2. 이 file list들을 *.o에서 *.c 변경한다.
  3. 빌드된 file list의 *.c  중심으로 dts파일의 'compatible'로 검색진행 

$ cd kernel source 
$ find . -name '*.o' | sed -e 's/o$/c/g' | xargs grep -rs 'ti,am4372'
$ find . -name '*.o' | sed -e 's/o$/c/g' | xargs grep -rs 'arm,coretex-a9-gic'
$ find . -name '*.o' | sed -e 's/o$/c/g' | xargs grep -rs 'syscon'

or 

$ MY_KERENL=./kernel_source 
$ find $MY_KERENL -name '*.o' | sed -e 's/o$/c/g' | xargs grep -rs 'syscon' $MY_KERENL



2.2 DTS파일 수정 및 추가방법 (AM437x 경우)  

상위에서 DTS파일을 수정하고, 추가한다면, Kernel 내부의 Makefile 수정하면된다.
DTS파일을 빌드를 원한다면, Kernel로 이동 후에 빌드를 하자.

  • AM437x는 기본 Makefile 구성 (DTS관련부분만)
  1. Main Makefile ( U-BOOT , Kernel, Filesystem 모두 관리)
  2. Rule.make     ( 관련 설정)
  3. Kernel Source 내부 Makefile 

  • Main Makefile (DTB File Build 수정) 
현재 dtb 파일은 3개만 빌드를하게 만들었으며, 본인이 추가한다면 이곳에서 수정하자

$ vi Makefile
linux: linux-dtbs        ### linux kernel 부분 build 
        @echo =================================
        @echo     Building the Linux Kernel
        @echo =================================
        $(MAKE) -C $(LINUXKERNEL_INSTALL_DIR) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) $(DEFCONFIG)
        $(MAKE) -j $(MAKE_JOBS) -C $(LINUXKERNEL_INSTALL_DIR) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zImage
        $(MAKE) -j $(MAKE_JOBS) -C $(LINUXKERNEL_INSTALL_DIR) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules
.....
# Kernel DTB build targets
linux-dtbs:
        @echo =====================================
        @echo     Building the Linux Kernel DTBs
        @echo =====================================
        $(MAKE) -C $(LINUXKERNEL_INSTALL_DIR) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) $(DEFCONFIG)
        $(MAKE) -j $(MAKE_JOBS) -C $(LINUXKERNEL_INSTALL_DIR) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) am43x-epos-evm.dtb am437x-gp-evm.dtb am437x-sk-evm.dtb


  • Linux Kernel/Uboot 에서 상위 dtb 생성확인 (check DTB files)

$ cd board-support/linux*  // Linux Kernel Source 이동 

$ find . -name *dtb    // 상위 Makefile로 인하여 dtb 파일은 이미 3개 생성됨 확인  
./arch/arm/boot/dts/am437x-sk-evm.dtb
./arch/arm/boot/dts/am43x-epos-evm.dtb
./arch/arm/boot/dts/am437x-gp-evm.dtb
./include/config/arm/atag/dtb

  • Linux Kernel/Uboot 에서 내부 Makefile 수정 (for new DTS File)
상위 Makefile에서 3개만 빌드했기 때문에, 3개이며, 추가를 원한다면 상위 Makefile 수정하자.
새로운 dtb/dts을 추가한다고 하면 Kernel 내부의 dts 관련 Makefile 파일을 수정하자.

$ cd board-support/linux*  // Linux Kernel Source 이동 

$ vi .config  // Kernel Config 확인 
...
CONFIG_SOC_AM43XX=y
# CONFIG_SOC_DRA7XX is not set
CONFIG_ARCH_OMAP2PLUS=y
....

$ vi arch/arm/boot/dts/Makefile   // new dts file 추가 , 본인의 dts 설정파일 만들어 추가하자

dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \
        omap2430-sdp.dtb \
        omap2420-n800.dtb \
        omap2420-n810.dtb \
        omap2420-n810-wimax.dtb \
        omap3430-sdp.dtb \
        omap3-beagle.dtb \
        omap3-cm-t3730.dtb \
        omap3-sbc-t3730.dtb \
        omap3-devkit8000.dtb \
        omap3-beagle-xm.dtb \
        omap3-evm.dtb \
        omap3-evm-37xx.dtb \
        omap3-ldp.dtb \
        omap3-n900.dtb \
        omap3-n9.dtb \
        omap3-n950.dtb \
        omap3-overo-tobi.dtb \
        omap3-overo-storm-tobi.dtb \
        omap3-gta04.dtb \
        omap3-igep0020.dtb \
        omap3-igep0030.dtb \
        omap3-zoom3.dtb \
        omap4-panda.dtb \
        omap4-panda-a4.dtb \
        omap4-panda-es.dtb \
        omap4-var-som.dtb \
        omap4-sdp.dtb \
        omap4-sdp-es23plus.dtb \
        omap5-uevm.dtb \
        am335x-evm.dtb \
        am335x-evmsk.dtb \
        am335x-bone.dtb \
        am335x-boneblack.dtb \
        am335x-nano.dtb \
        am335x-base0033.dtb \
        am3517-craneboard.dtb \
        am3517-evm.dtb \
        am3517_mt_ventoux.dtb \
        am43x-epos-evm.dtb \
        am43x-epos-evm-hdmi.dtb \
        am437x-gp-evm.dtb \
        am437x-gp-evm-hdmi.dtb \
        am437x-sk-evm.dtb \
        dra7-evm.dtb \
        dra7-evm-lcd10.dtb \
        dra72-evm.dtb \
        dra72-evm-lcd10.dtb \
        am57xx-beagle-x15.dtb \
        am57xx-evm.dtb


  • Linux Kernel 내부 Makefile 에서 zImage 확인 
 zImage 빌드 할 경우 정확한 설정 확인하고, dtb와 연관성을 확인하자.
 아래의 *.cmd는 실행한 결과들이며, 이것을 확인을 하면, 어떻게 생성이 되었는지 쉽게  이해를 할수 있다.

$ cd board-support/linux*  // Linux Kernel Source 이동 

$ find . -name zImage   //zImage 와 Image 위치파악  
./arch/arm/boot/zImage

$ ls -a arch/arm/boot/    // zImage와 Image 생성 부분 분석 ( Makefile , *.cmd) 
.  ..  .Image.cmd  .gitignore  .zImage.cmd  Image  Makefile  bootp  compressed  dts  install.sh  zImage

$ cat ./arch/arm/boot/.zImage.cmd   //제대로 빌드되었다면 아래와 같이 확인가능 
cmd_arch/arm/boot/zImage := /home/jhlee/am437x/works/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-objcopy -O binary -R .comment -S  arch/arm/boot/compressed/vmlinux arch/arm/boot/zImage

$ vi arch/arm/boot/Makefile  // zImage 확인 
....
targets := Image zImage xipImage bootpImage uImage

ifeq ($(CONFIG_XIP_KERNEL),y)        // 현재 XIP 모드가 아님 ( NOR NAMD 이면, 가능하겠지만?)

$(obj)/xipImage: vmlinux FORCE
        $(call if_changed,objcopy)
        @$(kecho) '  Kernel: $@ is ready (physical address: $(CONFIG_XIP_PHYS_ADDR))'

$(obj)/Image $(obj)/zImage: FORCE
        @echo 'Kernel configured for XIP (CONFIG_XIP_KERNEL=y)'
        @echo 'Only the xipImage target is available in this case'
        @false

else

$(obj)/xipImage: FORCE
        @echo 'Kernel not configured for XIP (CONFIG_XIP_KERNEL!=y)'
        @false

$(obj)/Image: vmlinux FORCE
        $(call if_changed,objcopy)
        @$(kecho) '  Kernel: $@ is ready'

$(obj)/compressed/vmlinux: $(obj)/Image FORCE
        $(Q)$(MAKE) $(build)=$(obj)/compressed $@

$(obj)/zImage:  $(obj)/compressed/vmlinux FORCE
        $(call if_changed,objcopy)                 ## OBJCOPYFLAGS 사용하며, objcopy를 이용하여 object를 binary를 만들때 사용한다  
        @$(kecho) '  Kernel: $@ is ready'          ## 자세한 내용은 Kernel 문서와 GCC 참조 

endif


  • Filesytem 에서 DTB와 Kernel zImage 확인 
Partition 과 Booting 부분에 있어, Partition은 2개이며, (fat32 와 filesystem 으로 존재) uboot는 fat32에 존재하며, 설정값도 그곳에 존재한다.
그리고 Filesystem 안의 boot에는  dtb 파일과 zImage는 File 형태로 존재하며 아래의 NFS File system에서도 동일하다.

$ cd board-support/linux*  // Linux Kernel Source 이동 
$ sudo cp arch/arm/boot/zImage /boot   // File System의 Boot에 저장 
$ sudo cp arch/arm/boot/dts/
.dtb /boot // File System의 Boot에 저장 $ targetNFS/boot //Kernel Image 와 *.dtb File 확인 (File system 안에 존재) $ ll drwxr-xr-x 2 jhlee jhlee 4096 7월 7 2015 ./ drwxr-xr-x 21 jhlee jhlee 4096 7월 7 2015 ../ lrwxrwxrwx 1 jhlee jhlee 40 7월 7 2015 am437x-gp-evm-hdmi.dtb -> devicetree-zImage-am437x-gp-evm-hdmi.dtb lrwxrwxrwx 1 jhlee jhlee 35 7월 7 2015 am437x-gp-evm.dtb -> devicetree-zImage-am437x-gp-evm.dtb lrwxrwxrwx 1 jhlee jhlee 35 7월 7 2015 am437x-sk-evm.dtb -> devicetree-zImage-am437x-sk-evm.dtb lrwxrwxrwx 1 jhlee jhlee 41 7월 7 2015 am43x-epos-evm-hdmi.dtb -> devicetree-zImage-am43x-epos-evm-hdmi.dtb lrwxrwxrwx 1 jhlee jhlee 36 7월 7 2015 am43x-epos-evm.dtb -> devicetree-zImage-am43x-epos-evm.dtb -rw-r--r-- 1 jhlee jhlee 49048 7월 7 2015 devicetree-zImage-am437x-gp-evm-hdmi.dtb -rw-r--r-- 1 jhlee jhlee 48112 7월 7 2015 devicetree-zImage-am437x-gp-evm.dtb -rw-r--r-- 1 jhlee jhlee 42675 7월 7 2015 devicetree-zImage-am437x-sk-evm.dtb -rw-r--r-- 1 jhlee jhlee 48544 7월 7 2015 devicetree-zImage-am43x-epos-evm-hdmi.dtb -rw-r--r-- 1 jhlee jhlee 47461 7월 7 2015 devicetree-zImage-am43x-epos-evm.dtb -rw-r--r-- 1 jhlee jhlee 105402448 7월 7 2015 vmlinux-3.14.43-g875c69b lrwxrwxrwx 1 jhlee jhlee 23 7월 7 2015 zImage -> zImage-3.14.43-g875c69b -rw-r--r-- 1 jhlee jhlee 4355472 7월 7 2015 zImage-3.14.43-g875c69b


  • TI-Kernel User Guide
  많은 부분이 아래에 내용에 나오며 아래부분을 참고하자.
  http://processors.wiki.ti.com/index.php/Linux_Kernel_Users_Guide


3. How To compile DTS Files
    위에서 언급했듯이 Kernel에서 직접 DTS를 빌드하고자 한다면, 아래와 같이 빌드하자.
    다만 새로 추가했다면, Kernel 내부 Makefile을 수정해야하며, DTS에 맞는 Kernel Config를 확인하자.

    $ cd board-support/linux*  // linux kernel 이동  
    $ ls .config // DTS에 맞는 config 설정이 되어있어야 함.
    $ make ARCH=arm CROSS_COMPILE=arm-xxxxx            
    $ make ARCH=arm CROSS_COMPILE=arm-xxxxx am43x-epos-evm.dtb
    

    만약, 위의 Makefile 파일에 추가 및 Makefile Config가 추가 되지 않았다면, target이 추가되지 않아 dtb를 compile를 할수가 없다.


    3.1 How To use DTC(Device Tree Compiler)

    위와 같이 Kernel Makefile를 이용하여 빌드하는 방법도 있지만,
    직접 dtc를 사용하여 compile 하는 방법도 가능하다

    *참고사항:  처음 Kernel source를 받으면, dtc file은 존재하지 않는다. build 도중 생김
    • DTC (Device Tree Compiler)
    $ cd board-support/linux*  // linux kernel 이동  
    $ ./scripts/dtc/dtc -I dtb -O dts -o (devicetree name).dts (devicetree name).dtb  // 직접 build 
    

      http://www.wiki.xilinx.com/Build+Device+Tree+Blob


    4. Device Tree Guide


    • Device Tree Syntax Spec (중요)  
    ** Device Tree의 Spec이 별도 존재하며 지속적으로 Update되고 있으므로, 각 Spec을 반드시 읽고 확인
      https://www.devicetree.org/specifications/ (문법)
      http://devicetree.org/Device_Tree_Usage  (수정방법)

    • TI Device Tree 사용법  
      http://omappedia.org/wiki/Device_Tree

    • Kernel/Uboot 내부 문서  
    ** Device Tree 사용 및 방법이 Chip Vendor마다 조금씩 다르므로 반드시 Kernel 문서를 확인해야함
      https://www.kernel.org/doc/Documentation/arm/Booting


    • 쉽게 Device Tree를 설명해주는 사이트  
    Device Tree를 쉽게 설명해주는 Guide이고, 아래의 문서에서 위의 그림을 복사하여 넣었다.

      http://www.elinux.org/images/a/ad/Arm-soc-checklist.pdf
      http://events.linuxfoundation.org/sites/events/files/slides/petazzoni-device-tree-dummies.pdf
      http://schedule2012.rmll.info/IMG/pdf/LSM2012_ArmKernelConsolidation_Petazzoni.pdf
      http://events.linuxfoundation.org/sites/events/files/slides/presentation_3.pdf
      http://lxr.free-electrons.com/source/Documentation/devicetree/booting-without-of.txt

    8/12/2015

    Device Tree 구조 및 구성 Sitara (AM437x)

    1. Device Tree Syntax 

    DTS의 전체구조도 에대해 간단히 알아보고 어떻게 수정을 해야할지를 알아보자.

    • am437x-gp-evm-dts 전체구조 및 수정방법

    dtsi를 이용하여 참조하여 구성되며, 최종 dts file은 AM437x-gp-evm.dts 이며, 이는 dtc를 이용하여 dtb로 변환이 된다.


    • 본인이 별도로 DTS 관련부분들을 수정하고 싶은 경우
    1. 상위 관련 DTSI 파일들과 DTS파일들을 직접 다 수정하는 방법
    2. 새로운 DTS 파일을 생성 후 기존 최종 DTS를 include를 이용하여 포함하고 수정을 진행 

    DTS는 DTS or DTSI를 참조를 하므로 표현중복을 허용하므로 HW표현이 중복 될 경우 마지막의 DTS 정보기반으로 DTB를 생성하므로
    상위 2번이 가능하다.

    예를들면, 이미 이전 DTS에서 설정이 중복되는 부분이 존재하더라도 마지막에 추가된 syntax가 최종적용되므로 최종 DTS에서 수정을하면된다.

    중복허용Kernel Config/ Uboot Config도 허용하므로, 필요한 부분만 나중에 추가해서 설정을 하면된다.

    1.1 dts의 기본문법 이해 


    /dts-v1/; 
    
    [memory reservations] 
    
    / { 
           [property definitions] 
           [child nodes] 
    };
    
    

    1. // or  /* */ 주석을 의미한다. C 문법과 동일
    2. #include  , 프리프로세서로 동작 C 문법과 동일 
    3. /include/ 사용시 뒤 dts를 포함시킨다고 한다. 

    각 address-cells or size-cell 기본문법이해
      http://devicetree.org/Device_Tree_Usage


    Kernel의 Documentation/devicetree를 참조하면 대부분의 이해가능.
    자세한 부분은 source와 datasheet를 참조해야한다.


    1.2 am4372.dtsi 의 기본분석 

    • 기본작업
    1. AM4372의 기본적인 device 선언
    2. 각 device들은 ocp안에 선언이 되고, address와 size만 할당.
    3. 각 device의 상태는 대부분 disable 유지.

    • gic
           *INTERRUPT 설정

           http://Documentation/devicetree/bindings/open-pic.txt

    • 전체구조
           *ARM과 OMAP의 기본구조

           http://Documentation/devicetree/bindings/arm/vexpress.txt
           http://lDocumentation/devicetree/bindings/arm/omap/

    • vpfe
           *EDMA을 사용하지 않고 자체 전용 DMA사용
           *VENC와 VPBE를 미지원 대신 SGX사용해야할 것 같음
           *DM81xx HDVICP지원, AM38xx HDVPSS지원,  AM432x는 미지원

           https://en.wikipedia.org/wiki/PowerVR
           http://processors.wiki.ti.com/index.php/DM816x_C6A816x_AM389x_Overview
    • edma
           *EDMA설정을 위해 datasheet에서 아래 사항을 필독
           *현재 EVENT 설정만 사용 (세부설정 변경 모색)

           TPTC(Third-Party Transfer Controller),
           TPCC(Third-Party Channel Controller0~2) : 10.2.1 관련내용
           CROSSBAR (10.3.20.2 Crossbar Mapped)

           http://Documentation/devicetree/bindings/dma/ti-edma.txt

    1.3 am43-clocks.dtsi 구조 

    Clock 구조는 간단하며, scrm_clocks (CONTROL_MODULE) 과 prcm_clocks(PRCM)
    2가지로 구분이 되며, 개별 deivce clock 설정한다.

    * datasheet와 함께 분석필요


    1.4 am4372-gp-evm.dts 구조

    • 주요작업 
    1. 기존의 status 변경 및 pinctrl 변경
    2. i2c (ov2659-camera, aic3105-audio) 및 uart 설정 
    3. lcd와 backlight, keypad 구조 선언
    4. sound 구조선언 (mcasp와 별도)
    5. power control도 같이 하기에 LDO도 같이 설정

    • btwilink (bluetooth)

    8/11/2015

    Device Tree 기본설명 및 문법, 부팅방법 (AM437x,AM335x)

    1. Device Tree 의 기본구성

    Device Tree에서 사용되어지는 기본 용어들을 알아두자.
    • DTB : Deivce Tree Blob (DTC에 의해  DTS를 Compile하면 생성되는 파일) 
    • DTC:  Device Tree Compiler 
    • DTS :  Device Tree Syntax  
    • DTSI : Device Tree Syntax Include 

    개발자는  DTS와 DTSI를 이용하여 Driver 설정 (HW 설정)구성 한 후 이를 DTC로 Compile 후 이를  DTB 형태로 사용하면 된다 

    DTB를 적용하기 위해서는 Kernel에서도 .config에서도 적용이 되게 설정을 해야한다. 

    최근에 사이트를 방문하니, Spec이 만들어져 있어 아래 부분을 링크

      http://www.devicetree.org/specifications/


    1.1 DTS(Device Tree Source) 기본문법 

    Device Tree는 현재 문법이 조금씩 다른것 같으며, 표준화가 진행이 되는 것 같으며,
    이를 아래의 사이트에서 Version에 맞게 사용해야 할 것 같다.
    하지만 각 Chip Vendor마다 조금씩 다르므로 각각의 Datasheet를 보고 파악을하는 것이 나을 것 같다.
    다만 기본문법만  아래의 링크들을 보고 알아두자

    • Device Tree Spec 
     현재 이곳에서 인터넷에서 기재되고, 이곳에서 Device Tree를 관리한다.
      https://www.devicetree.org

    • Ubuntu 에서 ARM Device 를 위하여 Device Tree를 사용 할 경우 
      https://wiki.ubuntu.com/Kernel/Dev/ARMDeviceTrees?action=show&redirect=KernelTeam%2FARMDeviceTrees

    • Device Tree 사용법 ( Spec 및 관련문서 중요)
      https://www.kernel.org/doc/Documentation/devicetree/usage-model.txt
      http://www.devicetree.org/Device_Tree_Usage
      http://www.devicetree.org/specifications/

    • 현재 Device Tree의 적용되는 예
      https://en.wikipedia.org/wiki/Device_tree
      http://omappedia.org/wiki/Device_Tree     (TI)

    • Device Tree 사용법 소개
      http://elinux.org/Device_Tree
      http://elinux.org/Linux_Drivers_Device_Tree_Guide


    1.2 DTS/DTSI(Device Tree Source)  위치확인  

    이제 본인의 Kernel로 가서 아래와 같이 DTS의 위치를 확인하고, ARM64 or ARM32를 본인 CPU로 확인 후, 이제 본격적으로 자신의 DTS를 찾아보자.
    빌드를 하면 본인의 dtb가 생성되므로 이 기준으로 찾아도 좋다

    $ find . -name dts  // DTS 관련부분 전부 검색  
    ./arch/xtensa/boot/dts
    ./arch/arc/boot/dts
    ./arch/arm/boot/dts
    ./arch/arm64/boot/dts
    ./arch/nios2/boot/dts
    ./arch/powerpc/boot/dts
    ./arch/c6x/boot/dts
    ./arch/metag/boot/dts
    ./arch/mips/boot/dts
    ./arch/openrisc/boot/dts
    ./arch/cris/boot/dts
    ./arch/h8300/boot/dts
    ./arch/microblaze/boot/dts

    • DTS 와 DTSI 
    Kernel의 arch/x/boot/dts에  DTS와 DTSI파일들이 존재하며, 이 파일로 설정이 가능하다.
    DTS는 C언어 처럼 include가 가능하여, DTSI를 사용한다.

        arch/arm/boot/dts/
        arch/powerpc/boot/dts/


    1.3 DTC(Device Tree Compiler) 위치확인 

    DTC는 kernel에서 빌드되며 아래와 같이 Version이 존재하고, 관련 Source도 Kernel 내부에 존재한다.
    1. DTC의 빌드      : Kernel Config의  CONFIG_DTC=y 추가 
    2. DTC 의 Source :  ./script/dtc 


    $ find . -name dtc   // Complier 확인 
    ./scripts/dtc        // dtc parser and lexer 및 기타소스 확인   
    ./scripts/dtc/dtc    // dtc bin 
    
    
    $ cd ./scripts/dtc 
    $ ./dtc -v
    Version: DTC 1.4.1-g9d3649bd   // DTC Version 확인 


    2. Device Tree를 이용한 Kernel Boot

    우선 기존의 Kernel Image Boot 와 과 Device Tree를 이용한 Kernel Image을 비교하고, Device Tree를 이용할 경우 DTB 전달방법을 알아보자.


    2.1 Kernel Image 비교

    Bootloadr에서 DTB(Device Tree Blob)파일을 load 한 후 이를 Kernel로 넘겨주고, 이는 기존의 Kernel의 board-*.c를 대체하고 기존에 사용하던 
    platform_device_registraition 방식을 제거를 하고 이 DTB를 사용하여 동적으로 변경한다.


    • uImage의  Old style 과 New Style 비교 

     
    http://www.elinux.org/images/a/ad/Arm-soc-checklist.pdf


    • 3가지 모델로 제안하여 DTB도 두가지방식 
    1. OLD Style: 기존방식 MACHINE IDMACHINE_START/END 사용 
    2. 1stNew Style: DTB와 uImage 분리되며, U-BOOT에서 uImage 와 DTB 주소 전달
    3. 2ndNew Style: uImage 와 DTB File을 포함  (Uboot에서 DTB를 전달필요없음)



    • Kernel Image는 uImage or zImage로도 가능
    1. vmlinux : linux kernel의 ELF format으로 실행가능한 kernel이며 기본적인 kernel 
    2. image  : vmlinux 기반에서 objcopy에서 -O binary -R .comment -S 
    3. zImage : vmlinux기반에서 linkscript 기반으로 piggy 및 head 와 gzip 등을 포함한 Kernel Image 
    4. uImage : zImage 기반으로 작성되며 uboot용으로 변경 


    $ cd board-support/linux*  //kernel source 이동
    $ cd arch/arm/boot
    $ ls -a
    .Image.cmd  .gitignore  .zImage.cmd  Image  Makefile  bootp  compressed  dts  install.sh  zImage
    
    $ cat .Image.cmd   // Image 만들어지는 방법 
    cmd_arch/arm/boot/Image := /home/jhlee/am437x/works/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-objcopy -O binary -R .comment -S  vmlinux arch/arm/boot/Image
    
    $ cat .zImage.cmd  // zImage 만들어지는 방법 
    cmd_arch/arm/boot/zImage := /home/jhlee/am437x/works/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-objcopy -O binary -R .comment -S  arch/arm/boot/compressed/vmlinux arch/arm/boot/zImage
    
    $ cd compressed
    $ ls 
    Makefile        big-endian.S  decompress.o  fdt_ro.o   head-sa1100.S    head.o       libfdt.h           misc.o          piggy.lz4.S     sdhi-shmobile.c  vmlinux.lds
    ashldi3.S       bswapsdi2.S   fdt.c         fdt_rw.c   head-sharpsl.S   hyp-stub.S   libfdt_env.h       mmcif-sh7372.c  piggy.lzma.S    sdhi-shmobile.h  vmlinux.lds.in
    ashldi3.o       bswapsdi2.o   fdt.h         fdt_rw.o   head-shmobile.S  hyp-stub.o   libfdt_internal.h  piggy.gzip      piggy.lzo.S     string.c
    atags_to_fdt.c  debug.S       fdt.o         fdt_wip.c  head-xscale.S    lib1funcs.S  ll_char_wr.S       piggy.gzip.S    piggy.xzkern.S  string.o
    atags_to_fdt.o  decompress.c  fdt_ro.c      fdt_wip.o  head.S           lib1funcs.o  misc.c             piggy.gzip.o    sdhi-sh7372.c   vmlinux
    


    • Kernel Image 구조 
      https://en.wikipedia.org/wiki/Vmlinux
      https://wiki.kldp.org/KoreanDoc/html/EmbeddedKernel-KLDP/kernel-image-file-structure.html


    • AM437x EVM Kernel Config 설정 

    $ vi .config  //AM437x Kernel config  
    ....
    CONFIG_DTC=y
    CONFIG_OF=y
    
    #
    # Device Tree and Open Firmware support
    #
    CONFIG_PROC_DEVICETREE=y
    # CONFIG_OF_SELFTEST is not set
    CONFIG_OF_FLATTREE=y
    CONFIG_OF_EARLY_FLATTREE=y
    .....
    
    #
    # Boot options
    #
    CONFIG_USE_OF=y
    CONFIG_ATAGS=y
    # CONFIG_DEPRECATED_PARAM_STRUCT is not set
    CONFIG_ZBOOT_ROM_TEXT=0x0
    CONFIG_ZBOOT_ROM_BSS=0x0
    CONFIG_ARM_APPENDED_DTB=y
    CONFIG_ARM_ATAG_DTB_COMPAT=y
    CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y
    # CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND is not set
    CONFIG_CMDLINE="root=/dev/mmcblk0p2 rootwait console=ttyO2,115200"
    CONFIG_CMDLINE_FROM_BOOTLOADER=y
    # CONFIG_CMDLINE_EXTEND is not set
    # CONFIG_CMDLINE_FORCE is not set
    CONFIG_KEXEC=y
    CONFIG_ATAGS_PROC=y
    # CONFIG_CRASH_DUMP is not set
    CONFIG_AUTO_ZRELADDR=y
    


    Kernel의 설정에 따라 전달방식은 두가지 설정
    (CONFIG_ARM_APPENDED_DTB 와 ATAG)


    • 아래의 ARM 파트와 DT 전달방식을 확인
      아래의사이트에 너무자세하게 나와있다.
      http://lxr.free-electrons.com/source/Documentation/devicetree/booting-without-of.txt

    • DTC 생성 
        CONFIG_DTC=y 에 의해 ./script/dtc/dtc가 생성이 된다.

    • DTB Data를 전달하는 두가지 방식 
    1. uImage와 DTB를 합쳐서 설정하는 방식  
    2. DTB 와 uImage를 분리하며, uboot에서 이를 전달하는 방식 (3.1/2/3 설명 )  

    2.2 Kernel설정 (1st New Style)

    DTB와 Kernel이 분리된 경우 사용하며, 문서에도 보면 이부분을 선호하며, UBOOT에서 동적으로 맘대로 DTB만 변경만 하면 되기 때문에 편할 것으로 보인다.
    2nd New Style 부분은 uImage와 DTB를 합치는 것이며 별도의 Kernel 설정이 필요하며 이부분은 생략

    • ATAGS 사용 및 소개 
    UBOOT에서 Kernel에게 Taglist 를 전달해주는 개념이며, 이 Taglist에 받아 Kernel이 이를 사용한다.
    Device Tree가 나오기전의 개념이며, 이것 단독으로 Device Tree를 사용할 수 없지만,이를 Device Tree에 적용하여 사용이 가능하다.


    • Kernel Config 설정
    1. CONFIG_ATAGS      //ATAGS 사용하여 TAG LIST로 받음 
    2. CONFIG_ARM_ATAG_DTB_COMPAT // TAG LIST에서 DTB를 받아 호환 
    3. CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER // TAG LIST DTB 포함 
    4. CONFIG_ARM_APPENDED_DTB // DTB가 Kernel Image에 포함
    5. CONFIG_ATAGS_PROC // ATGAS PROC 정보 


    2.3 UBOOT의 Kernel DTB 전달과정 (1st New Style)


     A. UBOOT에서 KERNEL 의 ATAGS의 TAGLIST 전달방식

    아래와 같이 ATAGS 기능 사용할 경우 전달 방식이 변경이 된다.r2에 Taglist를 전달해준다.
    ATAGS 방식은 기존부터 존재하던 방식으로 ATAGS에 다양한 정보를 넣어 전달가능.
    http://events.linuxfoundation.org/sites/events/files/slides/petazzoni-device-tree-dummies.pdf
           
    B. 상위 ATAGS의 TAGLIST 미사용하고 DTB 주소설정

    DTB를 전달할 경우, 아래와 같이 R2에 DTB의 주소를 넣어서 전달

    http://events.linuxfoundation.org/sites/events/files/slides/petazzoni-device-tree-dummies.pdf


    3. UBOOT의 Kernel DTB 전달방식 (1st New Style)

    • UBOOT 의 Kernel 의 DTB 전달 방식  (ATAG 사용)
    bootm 은 uImage를 사용할이며, bootz는 zImage 사용할때이다.
    앞에 kernel의 이미지를 address 주고  "-" 함께  dtb file address 주소를 준다.

    $ bootm ${loadaddr} - ${fdtaddr} 
    $ bootz ${loadaddr} - ${fdtaddr}
    


    • ATAGS 미사용과 Device Tree Mapping된 경우 전달형태

     CPU register contents
           r0 = 0
           r1 = Linux SOC family DT machine number  (Machine ID)
                (as defined in the ARM Linux machine database). 
                Unlike legacy ATAG booting, there is one unique ID is per SOC family not per machine.
           r2 = Physical address of FDT blob in system RAM
    
    
       
    Kernel 소스 :
      arch/arm/kernel/atags_parse.c
      arch/arm/boot/compressed/atags_to_fdt.c

    관련링크
      http://devicetree.org/Boot_Environment    ( Mapping 반드시 참조 )

    Machine ID 와 ATAG 관련설명
      http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html (ATAG)
      http://devicetree.org/BootingLinuxOnArm  ( Booting 과정 설정)
      http://stackoverflow.com/questions/21014920/arm-linux-atags-vs-device-tree  (ATAGS , DT차이)
      https://www.kernel.org/doc/Documentation/arm/Booting (BOOTing 과정 설명)


    4. Device Tree 사용한 Kernel 분석 

    • AM437x/AM335x일 경우,
    Linux Kernel Image는 DTB파일은 받아 이 설정값 기준으로 각각의 Device Driver를 설정을 하게된다.
    다만 주의해야할 것은 Kernel Config에서 관련설정을 해야한다.

    이제 EVM Board에 관련설정은 board-generic.c  DTB로 변경하여 설정하게 되므로, 동작방식을 아래의 Kernel 소스에서 부터 확인해볼 필요가 있다.

    • Kernel config 확인
    $ vi .config //AM437x 일 경우
    ...
    #
    # OMAP Feature Selections
    #
    CONFIG_OMAP_RESET_CLOCKS=y
    CONFIG_OMAP_MUX=y
    CONFIG_OMAP_MUX_DEBUG=y
    CONFIG_OMAP_MUX_WARNINGS=y
    CONFIG_OMAP_32K_TIMER=y
    CONFIG_OMAP_DM_TIMER=y
    CONFIG_OMAP_PM_NOOP=y
    CONFIG_MACH_OMAP_GENERIC=y
    CONFIG_ARCH_OMAP=y
    # CONFIG_ARCH_OMAP3 is not set
    # CONFIG_ARCH_OMAP4 is not set
    # CONFIG_SOC_OMAP5 is not set
    # CONFIG_SOC_AM33XX is not set
    CONFIG_SOC_AM43XX=y
    # CONFIG_SOC_DRA7XX is not set
    CONFIG_ARCH_OMAP2PLUS=y
    ....
    
    $ vi .config   //AM335x 일 경우 
    ...
    #
    # TI OMAP/AM/DM/DRA Family
    #
    # CONFIG_ARCH_OMAP3 is not set
    # CONFIG_ARCH_OMAP4 is not set
    # CONFIG_SOC_OMAP5 is not set
    CONFIG_SOC_AM33XX=y
    # CONFIG_SOC_AM43XX is not set
    # CONFIG_SOC_DRA7XX is not set
    CONFIG_ARCH_OMAP2PLUS=y
    ...
    


    • DT_MACHINE_START 확인
    기존에 사용하던 MACHINE_START 대신 Device Tree는 DT_MACHINE_START를 사용하므로 관련부분 확인

    $ grep -r DT_MACHINE_START ./arch/arm/mach-omap2/ // 본인 보드의 Board_init을 찾는다. DT_MACHINE_START
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(OMAP3_N900_DT, "Nokia RX-51 board")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(OMAP36XX_DT, "Generic OMAP36xx (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(OMAP3_GP_DT, "Generic OMAP3-GP (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(AM3517_DT, "Generic AM3517 (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(TI814X_DT, "Generic ti814x (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(TI816X_DT, "Generic ti816x (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(AM33XX_DT, "Generic AM33XX (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(OMAP5_DT, "Generic OMAP5 (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(AM43_DT, "Generic AM43 (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(DRA74X_DT, "Generic DRA74X (Flattened Device Tree)")
    ./arch/arm/mach-omap2/board-generic.c:DT_MACHINE_START(DRA72X_DT, "Generic DRA72X (Flattened Device Tree)")
    


    $ vi ./arch/arm/mach-omap2/board-generic.c
    .....
    #ifdef CONFIG_SOC_AM43XX
    static const char *const am43_boards_compat[] __initconst = {
        "ti,am4372",
        "ti,am43",
        NULL,
    };
    
    DT_MACHINE_START(AM43_DT, "Generic AM43 (Flattened Device Tree)")
        .l2c_aux_val    = OMAP_L2C_AUX_CTRL,
        .l2c_aux_mask   = 0xcf9fffff,
        .l2c_write_sec  = omap4_l2c310_write_sec,
        .map_io     = am33xx_map_io,                  // vi ./arch/arm/mach-omap2/io.c
        .init_early = am43xx_init_early,              // vi ./arch/arm/mach-omap2/io.c
        .init_late  = am43xx_init_late,               // vi ./arch/arm/mach-omap2/io.c
        .init_irq   = omap_gic_of_init,               // vi ./arch/arm/mach-omap2/omap4-common.c
        .init_machine   = omap_generic_init,          // vi ./arch/arm/mach-omap1/board-generic.c
        .init_time  = omap3_gptimer_timer_init,       // vi ./arch/arm/mach-omap2/timer.c 
        .dt_compat  = am43_boards_compat,             // 위에 정의  
        .restart    = omap44xx_restart,               // vi ./arch/arm/mach-omap2/omap4-restart.c
    MACHINE_END
    #endif
    .......
    $ vi ./arch/arm/mach-omap2/board-generic.c   // 본인 보드의 설정을 확인하자 machine_desc 내용, 이 부분은 동적으로 설정이 되기때문에 찾아봐도 존재하지 않는다. 
    ....
    #ifdef CONFIG_SOC_AM33XX
    static const char *const am33xx_boards_compat[] __initconst = {
        "ti,am33xx",
        NULL,
    };
    
    DT_MACHINE_START(AM33XX_DT, "Generic AM33XX (Flattened Device Tree)")
        .reserve    = omap_reserve,
        .map_io     = am33xx_map_io,           // vi ./arch/arm/mach-omap2/io.c 
        .init_early = am33xx_init_early,       // vi ./arch/arm/mach-omap2/io.c 
        .init_machine   = omap_generic_init,   // vi ./arch/arm/mach-omap1/board-generic.c
        .init_late  = am33xx_init_late,        // vi ./arch/arm/mach-omap2/io.c 
        .init_time  = omap3_gptimer_timer_init, // vi ./arch/arm/mach-omap2/timer.c
        .dt_compat  = am33xx_boards_compat,     // 위에 정의 
        .restart    = am33xx_restart,           // vi ./arch/arm/mach-omap2/am33xx-restart.c
    MACHINE_END
    #endif
    .....
    
    

    • Kernel 의 Linker Script 분석


    $ vi arch/arm/kernel/vmlinux.lds   //kernel의 linkscript (AM43xx)
    .......
    
     .init.arch.info : {              //MACHINE_START or DT_MACHIN_START
      __arch_info_begin = .;
      *(.arch.info.init)
      __arch_info_end = .;           //MACHINED_END
     }
     .init.tagtable : {              //ATAGS
      __tagtable_begin = .;     
      *(.taglist.init)
      __tagtable_end = .;
     }
     .init.pv_table : {              // phy to virtual , 이것은 이곳의 범위에 상관이 없어 넘어감
      __pv_table_begin = .;
      *(.pv_table)
      __pv_table_end = .;
     }
     .init.data : {
      *(.init.data) *(.meminit.data) *(.init.rodata) *(.meminit.rodata) . = ALIGN(8); __clk_of_table = .; *(__clk_of_table) *(__clk_of_table_end) . = ALIGN(8); __reservedmem_of_table = .; *(__reservedmem_of_table) *(__reservedmem_of_table_end) . = ALIGN(8); __clksrc_of_table = .; *(__clksrc_of_table) *(__clksrc_of_table_end) . = ALIGN(32); __dtb_start = .; *(.dtb.init.rodata) __dtb_end = .; . = ALIGN(8); __irqchip_begin = .; *(__irqchip_of_table) *(__irqchip_of_end)
      . = ALIGN(16); __setup_start = .; *(.init.setup) __setup_end = .;
      __initcall_start = .; *(.initcallearly.init) __initcall0_start = .; *(.initcall0.init) *(.initcall0s.init) __initcall1_start = .; *(.initcall1.init) *(.initcall1s.init) __initcall2_start = .; *(.initcall2.init) *(.initcall2s.init) __initcall3_start = .; *(.initcall3.init) *(.initcall3s.init) __initcall4_start = .; *(.initcall4.init) *(.initcall4s.init) __initcall5_start = .; *(.initcall5.init) *(.initcall5s.init) __initcallrootfs_start = .; *(.initcallrootfs.init) *(.initcallrootfss.init) __initcall6_start = .; *(.initcall6.init) *(.initcall6s.init) __initcall7_start = .; *(.initcall7.init) *(.initcall7s.init) __initcall_end = .;
      __con_initcall_start = .; *(.con_initcall.init) __con_initcall_end = .;
      __security_initcall_start = .; *(.security_initcall.init) __security_initcall_end = .;
      . = ALIGN(4); __initramfs_start = .; *(.init.ramfs) . = ALIGN(8); *(.init.ramfs.info)
     }
     .exit.data : {
      *(.exit.data) *(.memexit.data) *(.memexit.rodata)
     }
     __init_end = .;
    ....
    
    $ vi arch/arm/kernel/vmlinux.lds   //kernel의 linkscript (AM33xx)
    .......
    
     .init.arch.info : {              //MACHINE_START or DT_MACHIN_START
      __arch_info_begin = .;
      *(.arch.info.init)
      __arch_info_end = .;           //MACHINED_END
     }
     .init.tagtable : {              //ATAGS
      __tagtable_begin = .;     
      *(.taglist.init)
      __tagtable_end = .;
     }
     .init.pv_table : {              // phy to virtual , 이것은 이곳의 범위에 상관이 없어 넘어감
      __pv_table_begin = .;
      *(.pv_table)
      __pv_table_end = .;
     }
    ....
    


    $ vi System.map   // AM43xx
    
    c0813594 T __arch_info_begin
    c0813594 t __mach_desc_GENERIC_DT.20839
    c0813594 T __proc_info_end
    c08135ec t __mach_desc_AM43_DT
    c0813644 T __arch_info_end
    c0813644 T __tagtable_begin
    c0813644 t __tagtable_parse_tag_cmdline
    c081364c t __tagtable_parse_tag_revision
    c0813654 t __tagtable_parse_tag_serialnr
    c081365c t __tagtable_parse_tag_ramdisk
    c0813664 t __tagtable_parse_tag_videotext
    c081366c t __tagtable_parse_tag_mem32
    c0813674 t __tagtable_parse_tag_core
    c081367c t __tagtable_parse_tag_initrd2
    c0813684 t __tagtable_parse_tag_initrd
    c081368c T __pv_table_begin
    c081368c T __tagtable_end
    c0813a70 T __pv_table_end
    ......
    
    $ vi System.map   // 각 함수 확인 (AM33xx)
    c09924e4 T __arch_info_begin
    c09924e4 t __mach_desc_GENERIC_DT.24345
    c09924e4 T __proc_info_end
    c099254c t __mach_desc_AM33XX_DT
    c09925b4 T __arch_info_end
    c09925b4 T __tagtable_begin              // tagslist 에 들어가는 정보들  
    c09925b4 t __tagtable_parse_tag_cmdline     // cmdline
    c09925bc t __tagtable_parse_tag_revision    // revision 
    c09925c4 t __tagtable_parse_tag_serialnr
    c09925cc t __tagtable_parse_tag_videotext
    c09925d4 t __tagtable_parse_tag_mem32
    c09925dc t __tagtable_parse_tag_core
    c09925e4 t __tagtable_parse_tag_initrd2
    c09925ec t __tagtable_parse_tag_initrd
    c09925f4 T __pv_table_begin
    c09925f4 T __tagtable_end
    c09927bc T __pv_table_end
    ....
    


    • MACHINE_START/END 와 DT_MACHINE_START
    위에서 설명했듯이 위 두기능는 동일하며, machine_desc를 Device Tree를 사용하냐 Old Style이냐 따라 보면되겠다.

    $ vi arch/arm/include/asm/mach/arch.h  
    
    struct machine_desc {
        unsigned int        nr;     /* architecture number  */
        const char      *name;      /* architecture name    */
        unsigned long       atag_offset;    /* tagged list (relative) */
        const char *const   *dt_compat; /* array of device tree
                             * 'compatible' strings */
    
        unsigned int        nr_irqs;    /* number of IRQs */
    
    #ifdef CONFIG_ZONE_DMA
        phys_addr_t     dma_zone_size;  /* size of DMA-able area */
    #endif
    
        unsigned int        video_start;    /* start of video RAM   */
        unsigned int        video_end;  /* end of video RAM */
    
        unsigned char       reserve_lp0 :1; /* never has lp0    */
        unsigned char       reserve_lp1 :1; /* never has lp1    */
        unsigned char       reserve_lp2 :1; /* never has lp2    */
        enum reboot_mode    reboot_mode;    /* default restart mode */
        unsigned        l2c_aux_val;    /* L2 cache aux value   */
        unsigned        l2c_aux_mask;   /* L2 cache aux mask    */
        void            (*l2c_write_sec)(unsigned long, unsigned);
        const struct smp_operations *smp;   /* SMP operations   */
        bool            (*smp_init)(void);
        void            (*fixup)(struct tag *, char **);
        void            (*dt_fixup)(void);
        long long       (*pv_fixup)(void);
        void            (*reserve)(void);/* reserve mem blocks  */
        void            (*map_io)(void);/* IO mapping function  */
        void            (*init_early)(void);
        void            (*init_irq)(void);
        void            (*init_time)(void);
        void            (*init_machine)(void);
        void            (*init_late)(void);
    #ifdef CONFIG_MULTI_IRQ_HANDLER
        void            (*handle_irq)(struct pt_regs *);
    #endif
        void            (*restart)(enum reboot_mode, const char *);
    };
    
    
    
    
    
    
    #define MACHINE_START(_type,_name)          \
    static const struct machine_desc __mach_desc_##_type    \
     __used                         \
     __attribute__((__section__(".arch.info.init"))) = {    \
        .nr     = MACH_TYPE_##_type,        \
        .name       = _name,
    
    #define MACHINE_END             \
    };
    
    #define DT_MACHINE_START(_name, _namestr)       \
    static const struct machine_desc __mach_desc_##_name    \
     __used                         \
     __attribute__((__section__(".arch.info.init"))) = {    \
        .nr     = ~0,               \
        .name       = _namestr,
    
    #endif
    

    • Kernel config
    아래와 같이 ATAGS와 관련있는 파일을 확인

    $ vi .config 
    ....
    CONFIG_ATAGS=y                 # arch/arm/kernel/atags_parse.c
    ...
    CONFIG_ARM_APPENDED_DTB=y
    CONFIG_ARM_ATAG_DTB_COMPAT=y   # arch/arm/boot/compressed/atags_to_fdt.c
    CONFIG_ATAGS_PROC=y            # arch/arm/kernel/atags_proc.c
    CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y
    # CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND is not set
    ....
    


    각 옵션에 대해 간단히 알아보자.
    1. CONFIG_ATAGS=y
    2. CONFIG_ARM_ATAG_DTB_COMPAT=y
    3. CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y

    상위에서 ATAG는 DTB를 받기위한 한 통로이며, 물론 다르게 구성하여 확장도 가능하겠지만 현재는 그렇게 동작되지는 않는다.

    ATAGS의 주소는 U-BOOT에서 FDT(Flattened Device Tree)라는 주소로 이를 받고, uImage와 DTB는 결합이 될 것이다.

      https://www.denx.de/wiki/DULG/UBootCmdFDT



    • Kernel에서 Machine ID 확인 
    아래와 같이 arch/arm/tools/mach-types에서 확인가능

    $ vi arch/arm/tools/mach-types
    #
    # machine_is_xxx        CONFIG_xxxx             MACH_TYPE_xxx           number
    #
    ....
    omap_generic            MACH_OMAP_GENERIC       OMAP_GENERIC            452
    ...
    
    $ vi .config
    ....
    CONFIG_MACH_OMAP_GENERIC=y   # 상위와 동일 
    CONFIG_ARCH_OMAP=y
    ...
    


    4.1 U-Boot 와 Kernel의 DTS 위치 및 호환성 ( DTB 공유)

    Device Tree도 문법은 지속적으로 변경되겠지만, 최근 TI의 Sitara것을 보면 아래와 같이 AM335x의 경우 DTS File이 Kernel과 U-BOOT가 같이 존재하며 내용도 동일하다.
    만약 UBOOT의 내용과 Kernel의 내용이 맞지 않는다면, 둘중 하나를 선택해서 사용해야할 것 같다

    UBOOT or KERNEL의 DTS는 반드시 DTC가 존재해야 하며, Uboot도 DTB를 공유되어 사용되어진다.

    보통 1st Boot Loader가 존재하며, 2nd Boot Loader (UBoot)를 사용하므로 DTB 역시 UBoot 와 Kernel 에서도 동일하게 사용하기 위해서 공유가 되어져야 할 것이다.

    • Devcie Tree의 Booting 방법 (참조)
    처음에는 알지 못했는데, Kernel 뿐만 아니라 Uboot에도 DTB를 적용하여 이를 공유해 사용하면 될 것 같다.
      https://ahyuo79.blogspot.com/2015/08/am437x-kernel-device-tree.html

    Uboot의 FDT Command
      https://www.denx.de/wiki/view/DULG/UBootCmdFDT

    • U-BOOT에서 Device Tree 위치 
    $ cd board-support
    $ cd u-boot*  // Uboot Source 로 이동 
    
    $ ls arch/arm/dts // Uboot 용 Device Tree Syntax (Kernel과 동일)
    -rw-r--r--  1 jhlee jhlee  9346 12월 15 09:05 am335x-bone-common.dtsi
    -rw-rw-r--  1 jhlee jhlee 30487  3월 14 14:30 am335x-bone.dtb
    -rw-r--r--  1 jhlee jhlee   618 12월 15 09:05 am335x-bone.dts
    -rw-rw-r--  1 jhlee jhlee 31186  3월 14 14:30 am335x-boneblack.dtb
    -rw-r--r--  1 jhlee jhlee  3377 12월 15 09:05 am335x-boneblack.dts
    -rw-rw-r--  1 jhlee jhlee 30818  3월 14 14:30 am335x-bonegreen.dtb
    -rw-r--r--  1 jhlee jhlee  1184 12월 15 09:05 am335x-bonegreen.dts
    -rw-rw-r--  1 jhlee jhlee 36854  3월 14 14:30 am335x-evm.dtb
    -rw-r--r--  1 jhlee jhlee 19058 12월 15 09:05 am335x-evm.dts
    -rw-rw-r--  1 jhlee jhlee 35799  3월 14 14:30 am335x-evmsk.dtb
    -rw-r--r--  1 jhlee jhlee 20720 12월 15 09:05 am335x-evmsk.dts
    -rw-rw-r--  1 jhlee jhlee 31726  3월 14 14:30 am335x-icev2.dtb
    -rw-r--r--  1 jhlee jhlee 10299 12월 15 09:05 am335x-icev2.dts
    -rw-r--r--  1 jhlee jhlee 13955 12월 15 09:05 am33xx-clocks.dtsi
    -rw-r--r--  1 jhlee jhlee 20273 12월 15 09:05 am33xx.dtsi
    -rw-r--r--  1 jhlee jhlee 24483 12월 15 09:05 am4372.dtsi
    -rw-r--r--  1 jhlee jhlee 22179 12월 15 09:05 am437x-gp-evm.dts
    -rw-r--r--  1 jhlee jhlee 10493 12월 15 09:05 am437x-idk-evm.dts
    -rw-r--r--  1 jhlee jhlee 17847 12월 15 09:05 am437x-sk-evm.dts
    -rw-r--r--  1 jhlee jhlee 21643 12월 15 09:05 am43x-epos-evm.dts
    -rw-r--r--  1 jhlee jhlee 16774 12월 15 09:05 am43xx-clocks.dtsi
    -rw-r--r--  1 jhlee jhlee  6797 12월 15 09:05 am571x-idk.dts
    -rw-r--r--  1 jhlee jhlee  7153 12월 15 09:05 am572x-idk.dts
    -rw-r--r--  1 jhlee jhlee 20598 12월 15 09:05 am57xx-beagle-x15.dts
    -rw-r--r--  1 jhlee jhlee  8073 12월 15 09:05 am57xx-idk-common.dtsi       
    ....
    


    • Kernel에서의 Device Tree 위치 
    $ cd board-support
    $ cd linux*  // Linux Kernel 로 이동 
    
    $ ls arch/arm/boot/dts/
    -rw-r--r--  1 jhlee jhlee  9346 12월 15 09:05 am335x-bone-common.dtsi
    -rw-rw-r--  1 jhlee jhlee 30487  3월 14 14:30 am335x-bone.dtb
    -rw-r--r--  1 jhlee jhlee   618 12월 15 09:05 am335x-bone.dts
    -rw-rw-r--  1 jhlee jhlee 31186  3월 14 14:30 am335x-boneblack.dtb
    -rw-r--r--  1 jhlee jhlee  3377 12월 15 09:05 am335x-boneblack.dts
    -rw-rw-r--  1 jhlee jhlee 30818  3월 14 14:30 am335x-bonegreen.dtb
    -rw-r--r--  1 jhlee jhlee  1184 12월 15 09:05 am335x-bonegreen.dts
    -rw-rw-r--  1 jhlee jhlee 36854  3월 14 14:30 am335x-evm.dtb
    -rw-r--r--  1 jhlee jhlee 19058 12월 15 09:05 am335x-evm.dts
    -rw-rw-r--  1 jhlee jhlee 35799  3월 14 14:30 am335x-evmsk.dtb
    -rw-r--r--  1 jhlee jhlee 20720 12월 15 09:05 am335x-evmsk.dts
    -rw-rw-r--  1 jhlee jhlee 31726  3월 14 14:30 am335x-icev2.dtb
    -rw-r--r--  1 jhlee jhlee 10299 12월 15 09:05 am335x-icev2.dts
    -rw-r--r--  1 jhlee jhlee 13955 12월 15 09:05 am33xx-clocks.dtsi
    -rw-r--r--  1 jhlee jhlee 20273 12월 15 09:05 am33xx.dtsi
    -rw-r--r--  1 jhlee jhlee 24483 12월 15 09:05 am4372.dtsi
    -rw-r--r--  1 jhlee jhlee 22179 12월 15 09:05 am437x-gp-evm.dts
    -rw-r--r--  1 jhlee jhlee 10493 12월 15 09:05 am437x-idk-evm.dts
    -rw-r--r--  1 jhlee jhlee 17847 12월 15 09:05 am437x-sk-evm.dts
    -rw-r--r--  1 jhlee jhlee 21643 12월 15 09:05 am43x-epos-evm.dts
    -rw-r--r--  1 jhlee jhlee 16774 12월 15 09:05 am43xx-clocks.dtsi
    -rw-r--r--  1 jhlee jhlee  6797 12월 15 09:05 am571x-idk.dts
    -rw-r--r--  1 jhlee jhlee  7153 12월 15 09:05 am572x-idk.dts
    -rw-r--r--  1 jhlee jhlee 20598 12월 15 09:05 am57xx-beagle-x15.dts
    -rw-r--r--  1 jhlee jhlee  8073 12월 15 09:05 am57xx-idk-common.dtsi       
    ....