10/12/2018

dd 와 hd/hexdump 사용법

1. dd 명령어

일반적으로 리눅스에서 block device의 data를 backup or data를 block device에 저장할때 주로 많이 사용이 되어지며, 본인이 원하는 image file을 생성시 사용된다.

사용법은 입력과 출력을 정하고 본인이 원하는 옵션을 넣어 복사를 진행한다. 그리고 복사되는 시간을 알려준다.


1.1 dd의 기본사용법 

dd의 기본사용법 아래와 같은 방법으로 사용

$ dd if=(input file)  of=(output file) bs=(block size) skip=(input offset) seek=(output offset) conv=(conversion) 
$ dd if=test1 | cat          // 파이프 사용 stdout   
$ cat test1   | dd of=test2 //  파이프 사용 stdin  

bs는 2의 지수이며, 일반적으로 512단위로 사용 (ie, 512, 1024, 2048, 4096, 8192, 16384)



1.2  dd의 세부옵션  


주요 옵션은 다음과 같으며, 자세한 정보를 알고 싶으면, $man dd 로 알아보자.

OPERAND DESCRIPTION
bs=BYTES read and write up to BYTES bytes at a time (한번에 사용가능 Block Size 설정 in/out)
conv=CONVS convert the file as per the comma separated symbol list (옵션은 아래 참조)
count=N copy only N input blocks (default: 512 , 상위 bs 변경가능)
ibs=BYTES read up to BYTES bytes at a time (default: 512) 상위 bs의 input 세부설정
if=FILE read from FILE instead of stdin (Input File)
iflag=FLAGS read as per the comma separated symbol list
obs=BYTES write BYTES bytes at a time (default: 512) 상위 bs의 output 세부설정
of=FILE write to FILE instead of stdout (Onput File)
oflag=FLAGS write as per the comma separated symbol list
seek=N skip N obs-sized blocks at start of output (output 의 offset 기능 ,단위는 상위 bs,obs)
skip=N skip N ibs-sized blocks at start of input (input 의 offset 기능 ,단위는 상위 bs,ibs)


  1. N은 Block의 갯수 
  2. bs/ibs/obs는 Block의 크기 결정 (default:512)

  • N/BYTES 에 사용되는 suffix
N/BYTE의 suffix 단위Bytes
c1
w2
b512
K1024
kB1000
M1024*1024
MB1000*1000
G1024*1024*1024
xM1000*1000*1000

  • conv 옵션
CONVS DESCRIPTION
nocreat do not create the output file
notrunc do not truncate the output file (output file를 크기 줄이지 않고 유지)
noerror continue after read errors
fdatasync physically write output file data before finishing

  • iflag/oflag 옵션 
FLAG DESCRIPTION
dsync use synchronized I/O for data
sync dsync기능과 metadata도 포함 (MBR)
noerror continue after read errors
count_bytes treat 'count=N' as a byte count (iflag only)
skip_bytes treat 'skip=N' as a byte count (iflag only)
seek_bytes treat 'seek=N' as a byte count (oflag only)


1.3 MBR의 구성

Master Boot Record 약자이며 MBR 은 1 Sector (512 Byte)에 존재하며, 구조는 wiki를 보면 설명이 자세히 나온다.
이는 fdisk 와 parted 방식으로 사용할 경우 각각의 MBR이 조금씩 다른것으로 파악됨 

  • Classical generic MBR구성 (fdisk 사용할 경우)
  1. 446 bytes bootstrap 
  2. 064 bytes Partition table(16bytes x 4)
  3. 002 bytes Signature (0x55 0xAA)

MBR 구성
  https://en.wikipedia.org/wiki/Master_boot_record
  https://ko.wikipedia.org/wiki/%EB%A7%88%EC%8A%A4%ED%84%B0_%EB%B6%80%ED%8A%B8_%EB%A0%88%EC%BD%94%EB%93%9C

GPT (parted 기반구성)
  https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface


1.4. dd의 기본사용법 


  • 자주사용하는 장치 FILE
  1. /dev/zero  : 0값 
  2. /dev/random : random 값
  3. /dev/urandom : random 값
  4. /dev/null   : remove
  5. /dev/sdx(a,b,c,d)   : SATA Device   (1st,2nd,3st,4st)
  6. /dev/sda(1,2,3,4)   : SATA Partition (1st,2nd,3st,4st)
  7. /dev/mmcblkx(0,1,2) : SD Card Device   (1st,2nd,3st,4st)  
  8. /dev/mmcblkxp(0,1,2) : SD Card Partition (1st,2nd,3st,4st) 
  9. /dev/mem  : memory map I/O ( offset: virtual address)
  10. /dev/loop(0,12,3): loop device  


  https://ko.wikipedia.org/wiki//dev/random
  https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.files/mem.htm
  
  • losetup 기본 사용법
간단하게 loop device를 이용하여 image를 만들고자 할때 많이 사용하여, 이와 함께 dd /fdisk/ mount를 이용하여 세부구성한다.
//losetup은 attach 를 한 후 반드시 사용 후 detach
$ sudo losetup /dev/loop0 ./data.img          //attach device ( data.img는 /dev/loop0를 통해 접근가능)
$ sudo losetup -a                             //현재 연결된 loop device 확인  
....    // fdisk or dd or mount를 이용하여 /dev/loop0으로 접근하여 data.img를 구성 
$ sudo losetup -d /dev/loop0                  //detach device ( data.img 와 /dev/loop0 연결끊음)

//losetup은 attach 를 하지만 offset를 정해서 사용
$ sudo losetup -o0 /dev/loop0 ./data.img     //attach device (offset 0 byte에 연결) 
....
$ sudo losetup -d /dev/loop0                 //detach device


$ sudo losetup -e des /dev/loop0 ./data.img   //attach device 와 encrytion 함
....
$ sudo losetup -d /dev/loop0




  • 일반적인 장치 복사 및 Backup 
$ dd if=/dev/sda of=/dev/sdb bs=4096 conv=noerror,sync    //SDA 장치 전부 
$ dd if=/dev/mmcblk0 of=/dev/mmcblk1 bs=4096 conv=noerror,sync         //mmcblk0 장치전부

//한번에 4096 byte씩 input 에서 읽어서 output 전송 , 물론 output은 input보다 작으면 안된다.

$ dd if=/dev/sda1 of=sda1.img      // sda 1st partition , Backup  

$ dd if=sda.img of=/dev/sda      // sda에 sda.img write


  • 압축이미지 생성 및 복구 
$ dd if=/dev/sda | gzip -c > sda.img.gz 
$ md5sum sda.img.gz  > sda.img.gz.md5sum
//Backup 압축 이미지 생성 

$ gzip -dc sda.img.gz | dd of=/dev/sda
//Backup Image로 복구 


  • MBR Delete, Backup ,  Restore
$ dd if=/dev/zero of=file1 bs=512 count=1 conv=notrunc  
// file의 길이를 줄이지 않고, 앞에 512byte만 삭제 

$ dd if=/dev/sda of=sda.img bs=512 count=1
//Backup MBR   

$ dd if=sda.img of=/dev/sda bs=512 count=1
//Restore MBR

$ dd if=/dev/sda of=/tmp/sdambr2.img bs=446 count=1
//Backup only boot data of MBR , Remove partition table  


1.5 dd 와 losetup 같이 File Image 생성 

  • data.img 생성 과 data.img 구성방법

//1. 빈 500MB data.img Image 생성
$ dd if=/dev/zero of=data.img bs=1k count=500k 
....
524288000 바이트 (524 MB) 복사됨, 1.91343 초, 274 MB/초
// 0으로 채우며, 한번에 1024byte 씩 500*1024 반복하여 Image 생성 (500*1024*1024)

//2. 새로 생성된 data.img  파티션 설정 
$ fdisk ./data.img   // fdisk를 사용하여 Partition 설정

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1023999, default 2048): 204800
Last sector, +sectors or +size{K,M,G} (204800-1023999, default 1023999): //Enter 

Command (m for help): w
The partition table has been altered!
//상위 204800x512 ~ 1023999x512 Partition 생성완료

$ fdisk -l ./data.img  // fdisk를 사용하여 Partition 생성확인
Disk ./data.img: 500 MiB, 524288000 bytes, 1024000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5591d382

Device      Boot  Start     End Sectors  Size Id Type
./data.img1      204800 1023999  819200  400M 83 Linux

//3. EXT4 FS 포맷 (204800x512 ~ 1023999x512) 상위주소 확인
$ sudo losetup -o $((512 * 204800)) /dev/loop0 data.img
$ sudo mkfs -t ext4 /dev/loop0
$ sudo losetup -d /dev/loop0

//4. data.img 내부의 EXT4 mount 후 내부 Filesystem 확인 
$ mkdir tmp1
$ sudo mount -o loop,offset=$((512 * 204800)) data.img ./tmp1  //loop device 사용 
or 
$ sudo mount -o ro,offset=$((512*204800)) data.img ./tmp1 // read only 
$ ls ./tmp1/
lost+found
$ umount tmp1 

//5. MBR을 제외한 부분 1*512 ~ 512*204800  각 Image 복사 default bs 는 512 bytes 
$ sudo losetup -o0 /dev/loop0 ./data.img     //attach device (0 byte에 연결) 
$ dd if=tmp1 of=data.img seek=1  //seek=01 , tmp1 파일을 data.img 01 x 512 byte 부터 복사 
$ dd if=tmp2 of=data.img seek=31 //seek=31 , tmp2 파일을 data.img 31 x 512 byte 부터 복사
$ dd if=tmp3 of=data.img seek=63 //seek=31 , tmp2 파일을 data.img 63 x 512 byte 부터 복사 
$ sudo losetup -d /dev/loop0   //detach device

  • 상위 data.img 구성 (fdisk사용시만)
  1. 0~512 byte : MBR ( Partition 정보)
  2. 01 x 512 ~ 31 x 512 : tmp1
  3. 31 x 512 ~ 63 x 512 : tmp2
  4. 63 x 512 ~ 31 x 512 : tmp3

GPT의 경우 parted 사용하며, 이부분은 Partition 구성이 다르므로 생략 

dd 사용예제
  https://ahyuo79.blogspot.com/2014/08/tmp.html
  https://ahyuo79.blogspot.com/2014/08/odroid-build2.html


dd 명령어 관련내용 
  http://wiki.linuxquestions.org/wiki/Some_dd_examples
  https://linoxide.com/linux-command/linux-dd-command-create-1gb-file/
  http://forum.falinux.com/zbxe/index.php?document_srl=561988&mid=lecture_tip
  https://en.wikipedia.org/wiki/Dd_(Unix)
  https://linoxide.com/linux-command/linux-dd-command-create-1gb-file/


2. hexdump/hd 기본사용법 

dd와 함께 data를 검증하기 위해서 사용해보자

  • hd/hexdump 옵션
  1. -s offset
  2. -n length
  3. -v display all input data.
  • hexdump 옵션
  1. -C hex와 ascii 값도 출력 


$ hd -s 512 -n 1024 -v data.img  // 512byte 부터 길이 1024 bytes 만 보기 

00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000220  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000230  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000240  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
........

$ hd -n 512 -v data.img  // 앞에 512 byte만 보기 

$ hd -v data.img  // 전체보기 

$ hd data.img | less // 전체를 보지만 less로 위치이동가능 (g 와 line 입력)

10/10/2018

SSH/Serial Program

1. Window SSH/ Serial Program 

Window에서 내가 개인적으로 좋아하는 Serial Program 과 SSH Program을 간단히 정리한다.
SSH를 지원을 한다면, 확인해야 할 것이 SFTP or SCP의 기능도 확인을 해야 할 것이다.

  • XSHELL
SSH 사용과 Serial 사용시 필요한 잘 사용하는 프로그램으로, 평가판/가정 및 학교사용자는 무료로 사용이 가능하지만, 기업은 유료라는 사실을 잊으면 안된다.

Download
  https://www.netsarang.co.kr/download/down_form.html?code=612

Ubuntu 16.04 사용시 주의사항
  https://ahyuo79.blogspot.com/2018/05/ubuntu-1604-lts-version.html

기타내용
  https://ahyuo79.blogspot.com/2015/02/vi.html
  https://ahyuo79.blogspot.com/2013/12/virtual-box-network-nat.html




  • Teraterm 
완전무료이며, SSH 와 Serial 을 지원하고 있으며, 상위와 비슷한 기능을 가지고 있지만, 나에게는 크게 매력적으로 다가오지는 않는다.
다만 회사에서만 사용하면 모를까

Download
  https://download.cnet.com/Tera-Term/3000-2094_4-75766675.html



10/05/2018

Prebuilt Toolchain Download

1. Prebuilt Toolchain

Cross Compiler를 Prebuilt toolchains에서 배포하는 곳은 많으며, 대체적으로  BSP에서 제공해주는 것에  맞추어서 설치하면된다.
오래전 같으면 Cross Compiler를 직접빌드해서 사용했지만, 지금은 설치만 하면되니까,
그래도 직접 빌드는 안하지만 개념은 까먹지 않아야 할꺼 같아 정리한다.


  GCC (GNU Compiler)
  https://www.gnu.org/software/gcc/

일단 GCC의 동작 및 기본구성원리를 들을 알아보자.

1.1 GCC의 구성 및 동작 

GCC의 C Compiler만을 의미하는 것이 아니며, C, C++, Objective-C, Fortran, Ada, and Go 다양한 언어를 제공해주는 GNU의 Compiler이다


  • GCC의 구성도 
  1. Front End (각 언어에 (C/C++/Fortran) 맞게 Parsing 및 구조화 ) 
  2. Middle End ( Front End에서 생긴 것을 최적화) 
  3. Back End ( 각 Architecture에 맞게 PowerPC/ARM/X86  Machine Code 생성)


상위 그림은 LLVM에서 가져온것이지만 GCC도 거의 동일하다.

각 프로그래밍 언어는 Frontend에서 담당을 하므로, GCC에 추가한다면 Front End이다.
그래서 GCC C/C++만을 위한 것이 아니며, 다양한 언어를 지원한다.

  http://www.aosabook.org/en/llvm.html
  https://www.gnu.org/software/gcc/frontends.html

  • LLVM 
LLVM의 경우는 빌드성능이 좋다고는 하는데, 아직 사용해본 경험이 없으며, TI Compiler or 다른 컴파일러 사용해본 경험밖에 없어 뭐라고 하기가 그렇다.

  http://releases.llvm.org/

  • GCC Manual 
GCC를 이용할 경우 제공되어지는 옵션을 확인이 가능하며, Architecture별 옵션을 확인가능하다

GCC-4.8.5 전체 Manual
  https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/


  • Preprocessor 사용되는 Command 및 Manual 보는법 
GCC 과 다른 Compiler를 보면 Preprocessor 를 사용하는 방법이 다소 다를때가 많으며, 이는 어쩔수 없이 봐야할 부분인 것 같다.
많이 사용되는 곳이 Kernel 과 초기화 코드 및 관련부분이며, 일반 Application에서는 사실 거의 사용하지 않을 것이다.

아래와 같이 상위 Manual을 보면될 것이며, 자료가 방대하다보니 목록을 반드시 확인하고 보자.

#pragma
  https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Pragmas.html#Pragmas
  https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Function-Specific-Option-Pragmas.html#Function-Specific-Option-Pragmas

__attribute__ (함수/변수 시)
  https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Function-Attributes.html#Function-Attributes
  https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Variable-Attributes.html#Variable-Attributes


1.2 How To Build Cross Compiler 

아래의 사이트에서 크로스 컴파일러가 어떻게 만들어지는 간단하게 알아보자.

  https://rtime.felk.cvut.cz/hw/index.php/How_to_build_GNU_cross-compilers
  https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
  https://wiki.osdev.org/GCC_Cross-Compiler

  • C만 지원하는 일반적 GCC 필요구성 
  1. binutils (linker 및 assember 포함) 
  2. gcc 
  3. glibc/uclibc/musl/newlib  (C library 의 종류)
  4. linux header  ( kernel 정보)

1.3 일반적인 GCC의 필요사항 

일반적인 GCC라면, C만 지원이 되는 glibc를 말할 것이며, 구성요소는 다음과 같다.

  • Linux Kernel header
  https://www.kernel.org/

  • GNU Binutils
  GCC에서 필요한 부분이며, Assembler 및 Linker / readelf/ objdump 및 각 필요한 tool
  https://www.gnu.org/software/binutils/

  • GNU GCC 
  https://gcc.gnu.org/releases.html

  • GNU C Library (다른 Library 생략)
  https://www.gnu.org/software/libc/
  https://en.wikipedia.org/wiki/Newlib


1.4. ABI 관련사항 

ABI(Application Binary Interface)는 CPU Architecture에서 어떻게 Register를 사용 및 할당할 것이지,
그리고CPU 입장에서 함수에 어떻게 변수를 전달할 것인지, 모든 규칙을 정의해놓은 Interface 규격이다.

예를들면, ARM의 PCS(Procedure Call Standard)를 보면, 함수를 호출시  Register로 어떻게 변수를 전달 할 것인지를 설명해준다.
이는 ARM만이 아니라 PowerPC/MIPS 다 존재하며 CPU의 Register 구조가 다르기 때문에 개별 ABI 가 필요하다. (이전 PowerPC는 GP Register 32개)
좀더 들어가면, Data Type , File Format, Stack 의 구조사용법 및  ELF의 동적링크 부분도 다 이 문서에 포함이 되어있다.


  • ABI의 관련사항 
  https://en.wikipedia.org/wiki/Application_binary_interface

  • ARM ABI 관련문서 
  http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.subset.swdev.abi/index.html

  • MIPS ABI 관련문서 
  http://www.cygwin.com/ml/binutils/2003-06/msg00436.html


1.4.1 EABI와 OABI

EABI(embedded-application binary interface) 는 embedded system에서 최적화하기 위해서 만들어졌다고 한다.
더 자세히 말하면 ARM의 EABI는 ARM의 ABI의 일부사양일 뿐이라고 한다.
그리고, 기존의 ABI는 OABI(Old-ABI)로 불린다고 한다.
그러므로, 만약 설정할 일이 있다면, 설정추가를 하는것이지 설정을 변경할일은 아니다.

  • ARM EABI의 탄생배경
기존의 OABI는 FPU를 사용한다고 가정하 만들었기에 FPU와 통신을 해서 문제가 발생한다고 한다 ARM은 FPU가 있는 버전과 없는 버전이 존재한다.
그리고 이를 FPU관련 부분을 효율적으로 사용하기위해서 EABI가 나왔다고 한다.

Debian에서는 ToolChain도 ABI에 따라 3가지 Version으로 구분되어 나온다고 한다.

Architecture ABI FPU Releases
ARM OABI Not required, but very slow without All debian releases upto and including Lenny were OABI. It has since been deprecated.
ARMEL EABI Does not make use of FPU Lenny and beyond
ARMHF EABI FPU required. Specifically benefits from NEON architecture and VFP. Wheezy and beyond

참고로, 상위 Lenny, Wheezy는 Version의 이름이다.

  https://wiki.embeddedarm.com/wiki/EABI_vs_OABI


  • ARM EABI 관련내용 
  https://wiki.debian.org/ArmEabiPort

  • EABI 관련장점 정리사항  
  1. Floating point performance, with or without an FPU is fast and mixing soft and hardfloat code is possible
  2. Structure packing is not as painful as it used to be 
  3. More compatibility with various tools (in future - currently linux-elf is well supported)
  4. A more efficient syscall convention 

  • EABI의 관련장점 설명  
  1. 1번은 상위에서 설명했듯이 EABI의 탄생배경이며 근본적인 문제해결인 것 같다. 
  2. 2번의 경우 구조체의 packed의 문제가 뭔지 모르겠다. e.g.  __attribute__((packed, aligned(4)))
  3. 3번의 경우 binutil과 gcc에서 호환성을 의미하는 것 같다. 
  4. 4번의 syscall convention 변화 (syscall 의 규칙)
  http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=3105/4

  • ARM EABI와 OABI 비교사항 
  http://jake.dothome.co.kr/abi/


  • Android ABI(EABI) 관련내용 
Android에서 EABI를 사용한다고 하면 Kernel Config에서 다음을 설정한다고 한다.
  1. CONFIG_AEABI
  2. CONFIG_OABI_COMPAT
  https://developer.android.com/ndk/guides/abis?hl=ko
  https://wiki.kldp.org/wiki.php/AndroidPortingOnRealTarget/ko


2. 많이 이용되어지는 Prebuilt Toolchain for Linux 

  1. CodeSourcery  (SoC의 BSP/SDK와 함께 배포)
  2. Free Electrons (최근 bootlin 변경됨)
  3. Linaro (ARM) 

SoC와 함께 많이 제공해주던 곳이 CodeSourcery 이며, 이전에 OdroidX2를 가지고 놀때, Linaro도 같이 이용을 했지만 Linaro Version을 좀더 자세히 알고자 한다.

참고자료 및 경험
  https://elinux.org/Toolchains
  https://gcc.gnu.org/install/binaries.html


2.1 Free Electrons (Bootlin)

리눅스 관련된 최신문서가 잘 정리된 사이트이며, Tool chain도 Architecture 및 Library에 별로 다양하게 제공을 할 뿐더러
본인이 원하는 GCC의 내부구성 정보도 잘 보여준다.

uclibc의 경우는 오래전에 uclinux (ARM7, PowerPC) 할때 빼고는 거의 사용한 기억이없는것 같다.
uclibc를 가지고 opensource를 porting할 때마다 제한적이어서 고생한 기억만 나서 그런지,
참고로 uclinux의 경우 오랜전에 MMU가  없이도 가능 부팅이 가능(ARM7)하며, Power PC인 경우는 linux를 최적화하기위해서 사용했었다.

  • GNU Toolchain Download 
  https://toolchains.free-electrons.com
  https://toolchains.bootlin.com/


2.2 Mentor (CodeSourcery)

SoC와 같이 대부분 오래전부터 배포진행했으며, mentor사가 인수하여 지속적으로 배포를 하고 있다.
이전에는 montavista에서도 제공을 했던거 사용했는데 요즘은 어떻게 되었는지 잘모르겠다.

이전에 사용한 version
  https://ahyuo.blogspot.com/2015/11/arm-tool-chain.html 

각 기본정보를 확인
  https://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/

  • GNU Toolchain Download (정보 확인가능)
  https://sourcery.mentor.com/GNUToolchain/release1294
  https://sourcery.mentor.com/GNUToolchain/release2635
  https://sourcery.mentor.com/GNUToolchain/release2032

Mentor(CodeSourcery) 역시 보면 아래의 Linaro Version 처럼 EABI로 인해 나누어져 배포한다.

2.3 Linaro 

Linaro도 SoC와 함께 배포되어 Download하기가 쉽고 Ubuntu에서 설치가 쉬워서 요즘 많이 이용되어지는 것 같다.

  • Linaro 회사정보
  https://ko.wikipedia.org/wiki/%EB%A6%AC%EB%82%98%EB%A1%9C


  • GNU ToolChain Download
  https://www.linaro.org/downloads/
  https://releases.linaro.org/components/toolchain/
  https://releases.linaro.org/components/toolchain/binaries/latest-5/
  https://releases.linaro.org/components/toolchain/binaries/5.2-2015.11-2/


  • linaro 전체 release site 및 Git 
  http://releases.linaro.org/
  https://web.archive.org/web/20121031094507/http://git.linaro.org/gitweb


  • Tool Chain 관련전체문의  (컴파일러 옵션설명)
  https://wiki.linaro.org/WorkingGroups/ToolChain/FAQ

  • 컴파일러 Prefix의 의미 ( A-B-C)
A 는 target architecture 의미한다고 한다. 
(e.g. arm for AArch32 little-endian, aarch64 for AArch64 little-endian)

B 는 vendor 의미이며, 사용여부는 옵션 (배포한 Vendor) (none or unknown for generic)
일반적으로는 거의 사용하지 않는다고 하며, 아래에도 사용하지 않음 (e.g  not present in arm-linux-gnueabihf)

C 는 사용중인 ABI 의미를 말하며 관련 system(OS)도 기술한다.   
(e.g linux-gnu* for Linux, linux-android* for Android, elf or eabi for ELF based bare-metal).

Bare Metal ABI는 New Lib를 사용하고 NonOS용으로 사용한다고 한다   

  • 컴파일러 기능요약
본인이 Download or 설치한 컴파일러의 옵션의 지원여부를 정확히 알자. 
  1. hw fpu 지원/미지원
  2. little / big endian 
  3. glibc / newlib 사용 ( bare-metal : newlib 사용 (NonOS용) or glibc 이용)


e.g
arm-linux-gnueabihf -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=vfpv4
-mcpu=cortex-a7 -mfpu=vfpv4 -mfloat-abi=softfp|hard
-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=softfp|hard


  • ARMv7
arm-linux-gnueabihf
 Toolchains for little-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems

arm-linux-gnueabi
Toolchains for little-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems

arm-none-eabi
Toolchains for little-endian, soft-float, 32-bit ARMv7 (and earlier) for bare-metal systems

armv8l-linux-gnueabihf
Toolchains for little-endian, 32-bit ARMv8 for GNU/Linux systems


  • ARMv8
aarch64-linux-gnu
Toolchains for little-endian, 64-bit ARMv8 for GNU/Linux systems

aarch64-none-elf
Toolchains for little-endian, 64-bit ARMv8 for bare-metal systems

aarch64_be-linux-gnu
Toolchains for big-endian, 64-bit ARMv8 for GNU/Linux systems

aarch64_be-none-elf
Toolchains for big-endian, 64-bit ARMv8 for bare-metal systems



2.3.1. Linaro의 Ubuntu Package 지원

상위에서 linaro version에 대해 알았으니, Ubuntu에서 쉽게 설치하는 법을 알아보자

  • Ubuntu APT Package 사용법
  https://ahyuo.blogspot.com/2015/07/ubuntu.html


  • Ubuntu Toolchain 지원확인  
본인의 Ubuntu에서 지원되는 Toolchain을 찾아보자

$ sudo apt-cache search gcc-arm*  //현재 지원되는 Package를 찾아보자 
gcc-arm-linux-gnueabihf - The GNU C compiler for armhf architecture
gcc-arm-linux-androideabi - cross toolchain and binutils for Android/Bionic on ARM
gcc-arm-none-eabi - GCC cross compiler for ARM Cortex-A/R/M processors
gcc-arm-linux-gnueabi - The GNU C compiler for armel architecture

  • Ubuntu Toolchain 설치 
나의 선택은 당연히 hw float point가 지원되는 기능으로 선택했지만, androideabi와 차이는 아직 잘모르겠다.

$ sudo apt-get install gcc-arm-linux-gnueabihf
$ sudo find / -name arm-linux-gnueabihf* 
/usr/bin/xxxx //binutils , gprof gcov, gcc 설치 
/usr/share/man/man1/xxx
/usr/lib/gcc-cross/arm-linux-gnueabihf 
/usr/arm-linux-gnueabihf
/usr/x86_64-linux-gnu/arm-linux-gnueabihf
...  
 

기존의 TI의 am335x/am437x bsp에도 이미 동일한 이름으로 이미 설치가 되어있네요(arago project)
다음부터 가급적 Download해서 사용하고 PATH를 정하고 사용해야겠네요.

  https://blog.thinkbee.kr/linux/crosscompile-arm/
  https://blog.thinkbee.kr/linux/linux-update-alternatives/


3. Prebuilt Toolchain for Window

오래전에, Cygwin용을 자주 사용했는데, 개발환경의 제약으로 인해 점점 사용하지 않게되었다.
다시 사용할 일이 있다면 다음아래의 사이트에서 Download하자

Cygwin용
  http://cygwin.com/

Mingw 용
  https://mingw-w64.org/doku.php


4. Eclipse GCC 사용 

아직 적용을 해보지 못했으며, 궁극적으로 모든것을 Eclipse 기반으로 하고 싶은 생각을 가지고 있다.
매번 Terminal에서 make와 shell script를 이용하여 하고 싶지 않으며, 이용하더라도 Eclipse에서 편하게 사용하는 방법을 찾고자 한다.

Eclipse와 함께사용
  https://www.codeguru.com/cpp/cpp/getting-started-with-c-for-eclipse.html