debootstrap arm64
1)
-- foreign 패키지 다운로드.
-- chroot 사용
-- --second-stage + QEMU 사용자 모드 에물레이션 사용.(binfmt_misc)
2) 커널 vfs 패닉
[ 0.773665] Please append a correct "root=" boot option; here are the available partitions:
[ 0.774033] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
파일 시스템 지원 확인.
CONFIG_VIRTIO_BLK=y
initrd에서 모듈이 로드되어야 하기 때문에 ISO 이미지를 사용해서 동작 시켜야 할 듯 함.
다른 유형의 파일시스템 유형을 사용하려고 시도했지만 커널 지원 문제가 있어, 커널 컴파일을 해야함.
-drive if= -M virt
데비안 계열 우분투 패키지 커널을 사용할 때 arm64 커널 빌드 명령어.
처음 빌드 시
export ARCH=arm64
export $(dpkg-architecture -aarm64); export CROSS_COMPILE=aarch64-linux-gnu-
fakeroot debian/rules clean
debian/rules build
fakeroot debian/rules binary
두번째 이상 빌드시.
rm debian/stamps/stamp-build*
debian/rules build
fakeroot debian/rules binary
커널 설정 옵션에서 개발자 모드를 활성화.
Ubuntu devs, CONFIG y
인터넷 동작 문제.
systemctl status dhclient.service
cat f
자동 설치 스크립트
#!/usr/bin/env bash
# https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online/1081171#1081171
set -eux
debootstrap_dir=debootstrap
root_filesystem=debootstrap.ext2.qcow2
sudo apt-get install \
gcc-aarch64-linux-gnu \
debootstrap \
libguestfs-tools \
qemu-system-aarch64 \
qemu-user-static \
;
if [ ! -d "$debootstrap_dir" ]; then
sudo debootstrap \
--arch arm64 \
--foreign \
bionic \
"$debootstrap_dir" \
http://ports.ubuntu.com/ubuntu-ports \
;
sudo mkdir -p "${debootstrap_dir}/usr/bin"
sudo cp "$(which qemu-aarch64-static)" "${debootstrap_dir}/usr/bin"
sudo chroot "$debootstrap_dir" /debootstrap/debootstrap --second-stage
sudo rm -f "$root_filesystem"
fi
linux_image="$(printf "${debootstrap_dir}/boot/vmlinuz-"*)"
if [ ! -f "$root_filesystem" ]; then
# Set root password.
echo 'root:root' | sudo chroot "$debootstrap_dir" chpasswd
# Remount root filesystem as rw.
cat << EOF | sudo tee "${debootstrap_dir}/etc/fstab"
/dev/sda / ext4 errors=remount-ro,acl 0 1
EOF
# https://askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution/1080902#1080902
cat << EOF | sudo tee "${debootstrap_dir}/etc/systemd/system/dhclient.service"
[Unit]
Description=DHCP Client
Documentation=man:dhclient(8)
Wants=network.target
Before=network.target
[Service]
Type=forking
PIDFile=/var/run/dhclient.pid
ExecStart=/sbin/dhclient -4 -q
[Install]
WantedBy=multi-user.target
EOF
sudo ln -sf "${debootstrap_dir}/etc/systemd/system/dhclient.service" \
"${debootstrap_dir}/etc/systemd/system/multi-user.target.wants/dhclient.service"
# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/759725
sudo chmod +r "${linux_image}"
# Generate image file from debootstrap directory.
# Leave 1Gb extra empty space in the image.
sudo virt-make-fs \
--format qcow2 \
--size +1G \
--type ext2 \
"$debootstrap_dir" \
"$root_filesystem" \
;
sudo chmod 666 "$root_filesystem"
fi
# 커널 컴파일.
linux_image="$(pwd)/linux/debian/build/build-generic/arch/arm64/boot/Image"
if [ ! -f "$linux_image" ]; then
#git clone --branch Ubuntu-4.15.0-20.21 --depth 1 git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git linux
cd linux
cat << EOF | patch -p1
diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu
index 5ff32cb997e9..8a190d3a0299 100644
--- a/debian.master/config/config.common.ubuntu
+++ b/debian.master/config/config.common.ubuntu
@@ -10153,7 +10153,7 @@ CONFIG_VIDEO_ZORAN_ZR36060=m
CONFIG_VIPERBOARD_ADC=m
CONFIG_VIRTIO=y
CONFIG_VIRTIO_BALLOON=y
-CONFIG_VIRTIO_BLK=m
+CONFIG_VIRTIO_BLK=y
CONFIG_VIRTIO_BLK_SCSI=y
CONFIG_VIRTIO_CONSOLE=y
CONFIG_VIRTIO_INPUT=m
EOF
export ARCH=arm64
export $(dpkg-architecture -aarm64)
export CROSS_COMPILE=aarch64-linux-gnu-
fakeroot debian/rules clean
debian/rules updateconfigs
fakeroot debian/rules DEB_BUILD_OPTIONS=parallel=`nproc` build-generic
cd -
fi
#linux_image=/home/ciro/bak/git/linux-kernel-module-cheat/out/linux/default/aarch64/arch/arm64/boot/Image
#linux_image=/home/ciro/bak/git/linux-kernel-module-cheat/submodules/linux/debian/build/build-generic/arch/arm64/boot/Image
qemu-system-aarch64 \
-append 'console=ttyAMA0 root=/dev/vda rootfstype=ext2' \
-device rtl8139,netdev=net0 \
-drive "file=${root_filesystem},format=qcow2" \
-kernel "${linux_image}" \
-m 2G \
-netdev user,id=net0 \
-serial mon:stdio \
-M virt,highmem=off \
-cpu cortex-a57 \
-nographic \
;
카테고리
asm
(27)
bootloader_x86_grub
(1)
C
(92)
compile
(11)
config
(76)
CPP
(13)
CSS
(1)
debugging
(7)
gimp
(1)
Go
(1)
html
(1)
Java
(1)
JavaScript
(1)
kernel
(19)
LibreOffice
(3)
Linux system progamming
(21)
MFC
(1)
opencv
(4)
OpenGL
(1)
PHP
(1)
Python
(4)
qemu
(29)
shell
(3)
socket
(7)
troubleshooting
(2)
ubuntu18.04
(2)
windows
(1)
2019/01/04
Linux 커널 exec의 시스템 호출 ELF 방식에서 스크립트 언어 #! 인식 shebang 지정.
Linux 커널 exec의 시스템 호출 #! 인식 shebang 지정.
#! 사람이 읽기 편하도록 구성한다는 의미(스크립트 언어)
./something
리눅스 커널 소스
linux/fs/binfmt_script.c
if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!'))
바이트를 읽은 후 비교.
참이면 커널에서 파싱.
경로 /usr/bin/env python 첫 번째 인수 사용하여 또 다른 exec 호출 생성.
/usr/bin/env python /path/to/script.py
#주석 문자 사용하는 모든 스크립팅 언어에서 동작 함.
무한 루프도 만들 수 있음.
printf '#!/a\n' | sudo tee /a
sudo chmod +x /a
/a
bash 오류 인식
-bash: /a: /a: bad interpreter: Too many levels of symbolic links
ELF 실행 파일
linux/fs/binfmt_elf.c
magic.elfmag[EI_MAG0] = ELFMAG0;
바이트 검사. 7f 45 4c 46, 사람이 읽을 수 있으나 이해 하려면 시간이 걸림.
EFL 형식의 파일을 읽고, 메모리에 정확하게 넣고, 새로운 프로세스 시작.
#! 사람이 읽기 편하도록 구성한다는 의미(스크립트 언어)
./something
리눅스 커널 소스
linux/fs/binfmt_script.c
if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!'))
바이트를 읽은 후 비교.
참이면 커널에서 파싱.
경로 /usr/bin/env python 첫 번째 인수 사용하여 또 다른 exec 호출 생성.
/usr/bin/env python /path/to/script.py
#주석 문자 사용하는 모든 스크립팅 언어에서 동작 함.
무한 루프도 만들 수 있음.
printf '#!/a\n' | sudo tee /a
sudo chmod +x /a
/a
bash 오류 인식
-bash: /a: /a: bad interpreter: Too many levels of symbolic links
ELF 실행 파일
linux/fs/binfmt_elf.c
magic.elfmag[EI_MAG0] = ELFMAG0;
바이트 검사. 7f 45 4c 46, 사람이 읽을 수 있으나 이해 하려면 시간이 걸림.
EFL 형식의 파일을 읽고, 메모리에 정확하게 넣고, 새로운 프로세스 시작.
debootstrap이란?
debootstrap이란?
x86 시스템에서 임베디드 ARM 또는 PowerPC 시스템용 데비안/우분투를 설치를 의미, 조금더 큰 의미에서는 네트워 부팅도 여기에 속 할 수 있음, 요즘 클라우드 컴퓨팅 환경 구성이 과도기를 지나 완성도를 높이는 단계로 진입한 듯 함.
1. .deb 패키지 파일을 다운로드 받아 압축해제.
2. qemu-user-static 에물레이트 하기 위해 모든 패키지 구성 스크립트 실행
간단한 사용 예제.
우분투 18.04
sudo apt-get install \
debootstrap \
qemu-user-static \
;
debootstrap_dir=debootstrap
sudo debootstrap \
--arch arm64 \
--foreign \
bionic \
"$debootstrap_dir" \
http://ports.ubuntu.com/ubuntu-ports \
;
sudo mkdir -p "${debootstrap_dir}/usr/bin"
sudo cp "$(which qemu-aarch64-static)" "${debootstrap_dir}/usr/bin"
sudo chroot "$debootstrap_dir" /debootstrap/debootstrap --second-stage
sudo rm -f "$root_filesystem"
x86 시스템에서 임베디드 ARM 또는 PowerPC 시스템용 데비안/우분투를 설치를 의미, 조금더 큰 의미에서는 네트워 부팅도 여기에 속 할 수 있음, 요즘 클라우드 컴퓨팅 환경 구성이 과도기를 지나 완성도를 높이는 단계로 진입한 듯 함.
1. .deb 패키지 파일을 다운로드 받아 압축해제.
2. qemu-user-static 에물레이트 하기 위해 모든 패키지 구성 스크립트 실행
간단한 사용 예제.
우분투 18.04
sudo apt-get install \
debootstrap \
qemu-user-static \
;
debootstrap_dir=debootstrap
sudo debootstrap \
--arch arm64 \
--foreign \
bionic \
"$debootstrap_dir" \
http://ports.ubuntu.com/ubuntu-ports \
;
sudo mkdir -p "${debootstrap_dir}/usr/bin"
sudo cp "$(which qemu-aarch64-static)" "${debootstrap_dir}/usr/bin"
sudo chroot "$debootstrap_dir" /debootstrap/debootstrap --second-stage
sudo rm -f "$root_filesystem"
리눅스 커널 컴파일 init/main.c 부팅시 메세지 출력
init/main.c
커널 소스 다운로드
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git
cd ubuntu-bionic
# 작업할 커널 소스버전 변경.
git checkout Ubuntu-4.15.0-20.21
fakeroot debian/rules clean
debian/rules updateconfigs
fakeroot debian/rules build-generic
linux_image="$(pwd)/debian/build/build-generic/arch/x86_64/boot/bzImage"
커널 정보 추출 확인.
https://nautiluslee.blogspot.com/2019/01/config.html
패치 적용
diff --git a/init/main.c b/init/main.c
index b8b121c17ff1..542229349efc 100644
--- a/init/main.c
+++ b/init/main.c
@@ -516,6 +516,8 @@ asmlinkage __visible void __init start_kernel(void)
char *command_line;
char *after_dashes;
+ pr_info("I'VE Hae Nam Korea Linux Love man!!!");
+
set_task_stack_end_magic(&init_task);
smp_setup_processor_id();
debug_objects_early_init();
빌드
fakeroot debian/rules build-generic
부팅 메시지 출력
I'VE Hae Nam Korea Linux Love man
Kernel: arch/x86/boot/bzImage is ready (#3)
커널 소스 다운로드
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git
cd ubuntu-bionic
# 작업할 커널 소스버전 변경.
git checkout Ubuntu-4.15.0-20.21
fakeroot debian/rules clean
debian/rules updateconfigs
fakeroot debian/rules build-generic
linux_image="$(pwd)/debian/build/build-generic/arch/x86_64/boot/bzImage"
커널 정보 추출 확인.
https://nautiluslee.blogspot.com/2019/01/config.html
패치 적용
diff --git a/init/main.c b/init/main.c
index b8b121c17ff1..542229349efc 100644
--- a/init/main.c
+++ b/init/main.c
@@ -516,6 +516,8 @@ asmlinkage __visible void __init start_kernel(void)
char *command_line;
char *after_dashes;
+ pr_info("I'VE Hae Nam Korea Linux Love man!!!");
+
set_task_stack_end_magic(&init_task);
smp_setup_processor_id();
debug_objects_early_init();
빌드
fakeroot debian/rules build-generic
부팅 메시지 출력
I'VE Hae Nam Korea Linux Love man
Kernel: arch/x86/boot/bzImage is ready (#3)
우분투 커널 .config 환경 설정 부분 확인 및 추출 방법.
우분투 커널 .config 파일 관련
우분투 git 커널 저장소
debian/config 커널 트리 메타 데이터 git 저장소
https://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/
우분투 18.04 linux-image-4.15.0-36-generici 커널 패키지에 대한 태크 정보는 Ubuntu-4.15.0-36.39.
config 파일 저장소
https://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/tree/debian.master/config?h=Ubuntu-4.15.0-36.39
config.common.ubuntu, config.common.amd64, config.flavour.generic 병합 linux-image-4.15.0-36-generic 커널 패키지가 나옴.
병합하는 스크립트
https://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/tree/debian/scripts/misc/kernelconfig?h=Ubuntu-4.15.0-36.39
# Merge configs
# We merge config.common.ubuntu + config.common.<arch> +
# config.flavour.<flavour>
아키텍쳐 별 구성 파일.
https://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/tree/debian.master/config/annotations?h=Ubuntu-4.15.0-36.39
환경 설정없이 컴파일
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git linux
cd linux
git checkout Ubuntu-4.15.0-36.39
fakeroot debian/rules clean
debian/rules updateconfigs
fakeroot debian/rules build-generic
현재 커널 설정 내용과 차이점 비교.
diff debian/build/build-generic/.config /boot/config-4.15.0-36-generic
.deb 파일 구성
최종 커널 환경 설정 값
/boot/config-4.15.0-36-generic
커널 이미지
/boot/vmlinuz-4.15.0-36-generic
패키지 버전 확인
dpkg -S /boot/config-4.15.0-36-generic
패키지 파일은 다음 내용을 제공 함.
linux-modules-4.15.0-36-generic: /boot/config-4.15.0-36-generic
패키지 정보 목록 확인
https://packages.ubuntu.com/bionic-updates/linux-modules-4.15.0-36-generic
환경 구성 파일 추출
mkdir config
cd config
wget http://mirrors.kernel.org/ubuntu/pool/main/l/linux/linux-modules-4.15.0-36-generic_4.15.0-36.39_amd64.deb
ar x linux-modules-4.15.0-36-generic_4.15.0-36.39_amd64.deb
tar -xvf data.tar.xz
cat ./boot/config-4.15.0-36-generic
우분투 git 커널 저장소
debian/config 커널 트리 메타 데이터 git 저장소
https://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/
우분투 18.04 linux-image-4.15.0-36-generici 커널 패키지에 대한 태크 정보는 Ubuntu-4.15.0-36.39.
config 파일 저장소
https://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/tree/debian.master/config?h=Ubuntu-4.15.0-36.39
config.common.ubuntu, config.common.amd64, config.flavour.generic 병합 linux-image-4.15.0-36-generic 커널 패키지가 나옴.
병합하는 스크립트
https://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/tree/debian/scripts/misc/kernelconfig?h=Ubuntu-4.15.0-36.39
# Merge configs
# We merge config.common.ubuntu + config.common.<arch> +
# config.flavour.<flavour>
아키텍쳐 별 구성 파일.
https://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/tree/debian.master/config/annotations?h=Ubuntu-4.15.0-36.39
환경 설정없이 컴파일
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git linux
cd linux
git checkout Ubuntu-4.15.0-36.39
fakeroot debian/rules clean
debian/rules updateconfigs
fakeroot debian/rules build-generic
현재 커널 설정 내용과 차이점 비교.
diff debian/build/build-generic/.config /boot/config-4.15.0-36-generic
.deb 파일 구성
최종 커널 환경 설정 값
/boot/config-4.15.0-36-generic
커널 이미지
/boot/vmlinuz-4.15.0-36-generic
패키지 버전 확인
dpkg -S /boot/config-4.15.0-36-generic
패키지 파일은 다음 내용을 제공 함.
linux-modules-4.15.0-36-generic: /boot/config-4.15.0-36-generic
패키지 정보 목록 확인
https://packages.ubuntu.com/bionic-updates/linux-modules-4.15.0-36-generic
환경 구성 파일 추출
mkdir config
cd config
wget http://mirrors.kernel.org/ubuntu/pool/main/l/linux/linux-modules-4.15.0-36-generic_4.15.0-36.39_amd64.deb
ar x linux-modules-4.15.0-36-generic_4.15.0-36.39_amd64.deb
tar -xvf data.tar.xz
cat ./boot/config-4.15.0-36-generic
debootstrap amd64 전체 이미지 파일 구성 qemu
debootstrap amd64
모든 패키지 다운로드 구성
#!/usr/bin/env bash
# https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online/1081171#1081171
set -eux
debootstrap_dir=debootstrap
root_filesystem=debootstrap.ext2.qcow2
sudo apt-get install \
debootstrap \
libguestfs-tools \
qemu-system-x86 \
;
if [ ! -d "$debootstrap_dir" ]; then
# Create 디렉토리 생성.
# - linux-image-generic: /boot 사용할 커널 이미지 다운로드
# - network-manager: 부팅시 네트워크 사용
sudo debootstrap \
--include linux-image-generic \
bionic \
"$debootstrap_dir" \
http://archive.ubuntu.com/ubuntu \
;
sudo rm -f "$root_filesystem"
fi
linux_image="$(printf "${debootstrap_dir}/boot/vmlinuz-"*)"
if [ ! -f "$root_filesystem" ]; then
# Set root password.
echo 'root:root' | sudo chroot "$debootstrap_dir" chpasswd
# 루투 파일시스템 rw 모드로 마운팅.
cat << EOF | sudo tee "${debootstrap_dir}/etc/fstab"
/dev/sda / ext4 errors=remount-ro,acl 0 1
EOF
# 네트워크 시작.
# 네트워크 명령어 입력 실패시 :
# 일시적 실패....
# https://askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution/1080902#1080902
cat << EOF | sudo tee "$debootstrap_dir/etc/systemd/system/dhclient.service"
[Unit]
Description=DHCP Client
Documentation=man:dhclient(8)
Wants=network.target
Before=network.target
[Service]
Type=forking
PIDFile=/var/run/dhclient.pid
ExecStart=/sbin/dhclient -4 -q
[Install]
WantedBy=multi-user.target
EOF
sudo ln -sf "$debootstrap_dir/etc/systemd/system/dhclient.service" \
"${debootstrap_dir}/etc/systemd/system/multi-user.target.wants/dhclient.service"
# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/759725
sudo chmod +r "${linux_image}"
# debootstrap 디렉토리에 이미지 파일 생성.
# 1Gb 공간 남겨둔.
sudo virt-make-fs \
--format qcow2 \
--size +1G \
--type ext2 \
"$debootstrap_dir" \
"$root_filesystem" \
;
sudo chmod 666 "$root_filesystem"
fi
qemu-system-x86_64 \
-append 'console=ttyS0 root=/dev/sda' \
-drive "file=${root_filesystem},format=qcow2" \
-enable-kvm \
-serial mon:stdio \
-m 2G \
-kernel "${linux_image}" \
-device rtl8139,netdev=net0 \
-netdev user,id=net0 \
;
login: root
pw: root
인터넷 동작 확인
wget그리고 curl기본적으로 설치되지 않기 때문에 다음 명령어로 인터넷 동작 확인
ping 또한 qemu에서 기본적으로 동작 하지 않음.
printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | nc example.com 80
apt-get update
apt-get install hello
hello
모든 패키지 다운로드 구성
#!/usr/bin/env bash
# https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online/1081171#1081171
set -eux
debootstrap_dir=debootstrap
root_filesystem=debootstrap.ext2.qcow2
sudo apt-get install \
debootstrap \
libguestfs-tools \
qemu-system-x86 \
;
if [ ! -d "$debootstrap_dir" ]; then
# Create 디렉토리 생성.
# - linux-image-generic: /boot 사용할 커널 이미지 다운로드
# - network-manager: 부팅시 네트워크 사용
sudo debootstrap \
--include linux-image-generic \
bionic \
"$debootstrap_dir" \
http://archive.ubuntu.com/ubuntu \
;
sudo rm -f "$root_filesystem"
fi
linux_image="$(printf "${debootstrap_dir}/boot/vmlinuz-"*)"
if [ ! -f "$root_filesystem" ]; then
# Set root password.
echo 'root:root' | sudo chroot "$debootstrap_dir" chpasswd
# 루투 파일시스템 rw 모드로 마운팅.
cat << EOF | sudo tee "${debootstrap_dir}/etc/fstab"
/dev/sda / ext4 errors=remount-ro,acl 0 1
EOF
# 네트워크 시작.
# 네트워크 명령어 입력 실패시 :
# 일시적 실패....
# https://askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution/1080902#1080902
cat << EOF | sudo tee "$debootstrap_dir/etc/systemd/system/dhclient.service"
[Unit]
Description=DHCP Client
Documentation=man:dhclient(8)
Wants=network.target
Before=network.target
[Service]
Type=forking
PIDFile=/var/run/dhclient.pid
ExecStart=/sbin/dhclient -4 -q
[Install]
WantedBy=multi-user.target
EOF
sudo ln -sf "$debootstrap_dir/etc/systemd/system/dhclient.service" \
"${debootstrap_dir}/etc/systemd/system/multi-user.target.wants/dhclient.service"
# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/759725
sudo chmod +r "${linux_image}"
# debootstrap 디렉토리에 이미지 파일 생성.
# 1Gb 공간 남겨둔.
sudo virt-make-fs \
--format qcow2 \
--size +1G \
--type ext2 \
"$debootstrap_dir" \
"$root_filesystem" \
;
sudo chmod 666 "$root_filesystem"
fi
qemu-system-x86_64 \
-append 'console=ttyS0 root=/dev/sda' \
-drive "file=${root_filesystem},format=qcow2" \
-enable-kvm \
-serial mon:stdio \
-m 2G \
-kernel "${linux_image}" \
-device rtl8139,netdev=net0 \
-netdev user,id=net0 \
;
login: root
pw: root
인터넷 동작 확인
wget그리고 curl기본적으로 설치되지 않기 때문에 다음 명령어로 인터넷 동작 확인
ping 또한 qemu에서 기본적으로 동작 하지 않음.
printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | nc example.com 80
apt-get update
apt-get install hello
hello
UEFI Cloud image arm64
UEFI Cloud image arm64
sudo apt-get install qemu-efi
자동 스크립트
vi uefi_cloud_image.sh
#!/usr/bin/env bash
set -eux
#sudo apt-get install cloud-image-utils qemu-system-arm qemu-efi
# 이미지 다운로드.
img=ubuntu-18.04-server-cloudimg-arm64.img
if [ ! -f "$img" ]; then
wget "https://cloud-images.ubuntu.com/releases/18.04/release/${img}"
qemu-img resize "$img" +60G
fi
# 암호 설정.
user_data=user-data.img
if [ ! -f "$user_data" ]; then
cat >user-data <<EOF
#cloud-config
password: totoro
chpasswd: { expire: False }
ssh_pwauth: True
EOF
cloud-localds "$user_data" user-data
# EFI 사용:
# https://wiki.ubuntu.com/ARM64/QEMU
dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
dd if=/dev/zero of=flash1.img bs=1M count=64
fi
qemu-system-aarch64 \
-M virt \
-cpu cortex-a57 \
-device rtl8139,netdev=net0 \
-m 4096 \
-netdev user,id=net0 \
-nographic \
-smp 4 \
-drive "if=none,file=${img},id=hd0" \
-device virtio-blk-device,drive=hd0 \
-drive "file=${user_data},format=raw" \
-pflash flash0.img \
-pflash flash1.img \
;
sudo apt-get install qemu-efi
자동 스크립트
vi uefi_cloud_image.sh
#!/usr/bin/env bash
set -eux
#sudo apt-get install cloud-image-utils qemu-system-arm qemu-efi
# 이미지 다운로드.
img=ubuntu-18.04-server-cloudimg-arm64.img
if [ ! -f "$img" ]; then
wget "https://cloud-images.ubuntu.com/releases/18.04/release/${img}"
qemu-img resize "$img" +60G
fi
# 암호 설정.
user_data=user-data.img
if [ ! -f "$user_data" ]; then
cat >user-data <<EOF
#cloud-config
password: totoro
chpasswd: { expire: False }
ssh_pwauth: True
EOF
cloud-localds "$user_data" user-data
# EFI 사용:
# https://wiki.ubuntu.com/ARM64/QEMU
dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
dd if=/dev/zero of=flash1.img bs=1M count=64
fi
qemu-system-aarch64 \
-M virt \
-cpu cortex-a57 \
-device rtl8139,netdev=net0 \
-m 4096 \
-netdev user,id=net0 \
-nographic \
-smp 4 \
-drive "if=none,file=${img},id=hd0" \
-device virtio-blk-device,drive=hd0 \
-drive "file=${user_data},format=raw" \
-pflash flash0.img \
-pflash flash1.img \
;
login: ubuntu
pw:totoro
ubuntu wayland manager qemu kvm 활성화
Unable to init server: Could not connect: Connection refused
사용자 추가(sudo GUI + terminal)
xhost -si:localuser:root
GL에서 GPU 장치 선택
GL에서 GPU 장치 선택
OpenGL 자체가 렌더링 API임.
GLX, WGL, EGL과 같은 윈도우 시스템 바인딩 API는 수 많은 세월에 거쳐 만들어짐.
멀티 GPU 시스템이 찾기 어려웠던 시대...
멀티 GPU API는 제조사 마다 다르지만 MESA 솔루션의 DRI_PRIME를 통해 발전함.
DRI_PRIME란?
초창기의 DRI_PRIME는 2개의 GPU에서 동작 하도록 정의한 환경 변수.
응용 프로그램 호출하기 전에 1로 설정하면 GL 스택이 X서버로 쿼리하고 시스템에 있는 다른 GPU를 사용.
이러한 방법으르로 초기에 발전 함.
- 시스템에 GPU가 3개 이상 있을때?
- x 서버가 없는 시스템일 때?
- 응용 프로그램 개발시 사용할 GPU를 어떻게 선택해 사용할 것인가?
사용자 ID_PATH_TAG가 udev에서 제공 한대로 DRI_PRIME 장치를 나열하여 선택할 수 있다.
EGL의 확장 가능구조 덕분에 EGLDevice 계열의 확장을 통해 해결할 수 있음.
EGLDevice 입력
EGL_EXT_device_base 확장 측면에서 구현된 EGL_EXT_device_enumeration 및 EGL_EXT_device_query.
EGLDevice는 장치고유 속성을 나열해 질문하는 수단 인 EGLDevice의 개념 정의.
또 다른 두 개의 확장 EGL_EXT_device_drm 및 EGL_MESA_device_software은
각각의 하드웨어 DRM 장치 노드 및 소프트웨어와 백업 장치 정의
- 메사로 사용해 GL 구현.
사용 사례
확장 세트를 사용하려면 어떤 장치를 사용할지 명시 적으로 선택한다
그래픽 서버/윈도우 메이지먼트는 전력 소모가 적은 장치로 렌더링한다.
webGL 신뢰할 수 없는 장치로 분류 할 수 있고, 시간 기준으로 GPU 작업을 처리한다.
구현 상태
EGL_EXT_device_base- 구현 모두 EGL_EXT_device_enumeration와EGL_EXT_device_query
EGL_EXT_device_drm
EGL_MESA_device_software
EGL_EXT_platform_device
OpenGL 자체가 렌더링 API임.
GLX, WGL, EGL과 같은 윈도우 시스템 바인딩 API는 수 많은 세월에 거쳐 만들어짐.
멀티 GPU 시스템이 찾기 어려웠던 시대...
멀티 GPU API는 제조사 마다 다르지만 MESA 솔루션의 DRI_PRIME를 통해 발전함.
DRI_PRIME란?
초창기의 DRI_PRIME는 2개의 GPU에서 동작 하도록 정의한 환경 변수.
응용 프로그램 호출하기 전에 1로 설정하면 GL 스택이 X서버로 쿼리하고 시스템에 있는 다른 GPU를 사용.
이러한 방법으르로 초기에 발전 함.
- 시스템에 GPU가 3개 이상 있을때?
- x 서버가 없는 시스템일 때?
- 응용 프로그램 개발시 사용할 GPU를 어떻게 선택해 사용할 것인가?
사용자 ID_PATH_TAG가 udev에서 제공 한대로 DRI_PRIME 장치를 나열하여 선택할 수 있다.
EGL의 확장 가능구조 덕분에 EGLDevice 계열의 확장을 통해 해결할 수 있음.
EGLDevice 입력
EGL_EXT_device_base 확장 측면에서 구현된 EGL_EXT_device_enumeration 및 EGL_EXT_device_query.
EGLDevice는 장치고유 속성을 나열해 질문하는 수단 인 EGLDevice의 개념 정의.
또 다른 두 개의 확장 EGL_EXT_device_drm 및 EGL_MESA_device_software은
각각의 하드웨어 DRM 장치 노드 및 소프트웨어와 백업 장치 정의
- 메사로 사용해 GL 구현.
사용 사례
확장 세트를 사용하려면 어떤 장치를 사용할지 명시 적으로 선택한다
그래픽 서버/윈도우 메이지먼트는 전력 소모가 적은 장치로 렌더링한다.
webGL 신뢰할 수 없는 장치로 분류 할 수 있고, 시간 기준으로 GPU 작업을 처리한다.
구현 상태
EGL_EXT_device_base- 구현 모두 EGL_EXT_device_enumeration와EGL_EXT_device_query
EGL_EXT_device_drm
EGL_MESA_device_software
EGL_EXT_platform_device
Cloud image amd64
1. Cloud image amd64
데스크탑 시스템 설치없이 직접 부팅 할 수있는 이미지임.
이게 가능한 이유는 https://help.ubuntu.com/community/CloudInit
여기 사이트에 설명 되어 있음.
즉 init 개념을 -> Cloudint 개념을 추가해 부팅 시퀀서를 만듬.
이미지 생성 스크립트
vi upstream.sh
#!/usr/bin/env bash
sudo apt-get install cloud-image-utils qemu qemu-system qemu-system-x86
# qcow2 형식.
img=ubuntu-18.04-server-cloudimg-amd64.img
if [ ! -f "$img" ]; then
wget "https://cloud-images.ubuntu.com/releases/18.04/release/${img}"
# sparse resize: 추가 공간을 사용하지 않고 나중 크기 변경 허용.
# https://superuser.com/questions/1022019/how-to-increase-size-of-an-ubuntu-cloud-image
qemu-img resize "$img" +128G
fi
user_data=user-data.img
if [ ! -f "$user_data" ]; then
# 암호.
# https://serverfault.com/questions/920117/how-do-i-set-a-password-on-an-ubuntu-cloud-image
# https://askubuntu.com/questions/507345/how-to-set-a-password-for-ubuntu-cloud-images-ie-not-use-ssh
cat >user-data <<EOF
#cloud-config
password: totoro
chpasswd: { expire: False }
ssh_pwauth: True
EOF
cloud-localds "$user_data" user-data
fi
qemu-system-x86_64 \
-drive "file=${img},format=qcow2" \
-drive "file=${user_data},format=raw" \
-device rtl8139,netdev=net0 \
-enable-kvm \
-m 2G \
-netdev user,id=net0 \
-serial mon:stdio \
-smp 2 \
-vga virtio \
;
:wq
QEMU 시작 후 부트 메뉴가 나타나면, 엔터 입력.
부트 메시지
error: no such device: root.
Press any key to continue...
특정 시간이 지나면 자동 부팅 됨.
사용자 이름: ubuntu
암호: totoro
인터넷 동작 확인.
데스크탑 시스템 설치없이 직접 부팅 할 수있는 이미지임.
이게 가능한 이유는 https://help.ubuntu.com/community/CloudInit
여기 사이트에 설명 되어 있음.
즉 init 개념을 -> Cloudint 개념을 추가해 부팅 시퀀서를 만듬.
이미지 생성 스크립트
vi upstream.sh
#!/usr/bin/env bash
sudo apt-get install cloud-image-utils qemu qemu-system qemu-system-x86
# qcow2 형식.
img=ubuntu-18.04-server-cloudimg-amd64.img
if [ ! -f "$img" ]; then
wget "https://cloud-images.ubuntu.com/releases/18.04/release/${img}"
# sparse resize: 추가 공간을 사용하지 않고 나중 크기 변경 허용.
# https://superuser.com/questions/1022019/how-to-increase-size-of-an-ubuntu-cloud-image
qemu-img resize "$img" +128G
fi
user_data=user-data.img
if [ ! -f "$user_data" ]; then
# 암호.
# https://serverfault.com/questions/920117/how-do-i-set-a-password-on-an-ubuntu-cloud-image
# https://askubuntu.com/questions/507345/how-to-set-a-password-for-ubuntu-cloud-images-ie-not-use-ssh
cat >user-data <<EOF
#cloud-config
password: totoro
chpasswd: { expire: False }
ssh_pwauth: True
EOF
cloud-localds "$user_data" user-data
fi
qemu-system-x86_64 \
-drive "file=${img},format=qcow2" \
-drive "file=${user_data},format=raw" \
-device rtl8139,netdev=net0 \
-enable-kvm \
-m 2G \
-netdev user,id=net0 \
-serial mon:stdio \
-smp 2 \
-vga virtio \
;
:wq
QEMU 시작 후 부트 메뉴가 나타나면, 엔터 입력.
부트 메시지
error: no such device: root.
Press any key to continue...
특정 시간이 지나면 자동 부팅 됨.
사용자 이름: ubuntu
암호: totoro
인터넷 동작 확인.
callback test
/*
* Callback.c - 연결 목록 콜백 구현
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct NODE {
struct NODE *link;
int data;
}Node;
Node **create_sll(const int);
void insert_data(Node **);
void show_list(Node **);
void sort_list(Node **);
int compare_ints(void const *, void const *); /* 프로토타입 함수 */
Node *search_list(Node *, void const *, int(void const *, void const *)); /* 프로토타입 */
int main(void){
int (*compare)(void const *, void const *) = compare_ints;
int value, val2find;
int nodes; /* 노트 카운트 */
Node **rootp; /* 루투 위치 */
Node *desired_node;
puts("\n**Program creates Singly Linked List**");
puts("**And allows users to perform various operations on the"
"list**\n");
puts("User, specify number of nodes in the list, in range 1"
" through some positive no.");
scanf("%d", &nodes);
rootp = create_sll(nodes);
printf("Les's insert %d integers in the list...\n", nodes);
insert_data(rootp);
puts("**Les's show up the list**");
show_list(rootp);
puts("Let's sort the list, in ascending order...");
sort_list(rootp);
puts("Let's show up the list**");
show_list(rootp);
puts("**Let's use Callback() function**");
printf("User, enter an integer you want to see into the "
"Singly Linked List...\n");
scanf("%d", &val2find);
/* 콜밸 함수 호출 */
desired_node = search_list(*rootp, &val2find, compare);
if(desired_node != NULL)
puts("Desired value is found.");
else
puts("Desired value NOT found.");
return 0;
}
Node *search_list(Node *node, void const *value, int compare(void const *, void const *)){
while(node != NULL){
if(compare(&node->data, value) == 0)
break;
node = node->link;
}
return node;
}
int compare_ints(void const *p2nv, void const *p2v){
if(*(int *)p2nv == *(int *)p2v)
return 0;
else
return 1;
}
Node **create_sll(const int nodes){
int i;
Node *current;
static Node *root;
Node **rootp = &root;
root = (Node *)malloc(nodes * sizeof(Node));
if(root == NULL){
puts("Error: Not Enough Memory!");
exit(1);
} else {
current = root;
for(i = 1; i <= nodes; i++){
if(i == nodes) {
current->link = NULL;
} else {
current->link = current + 1;
current++;
}
}
printf("List with %d nodes created successfully!\n", nodes);
puts("");
}
return rootp;
}
void insert_data(Node **linkp){
Node *next = *linkp;
Node *current;
do {
current = next;
scanf("%d", &(current->data));
next = current->link;
}while(current->link != NULL);
puts("");
}
void show_list(Node **linkp){
Node *next = *linkp;
Node *current;
do{
current = next;
printf("%d", current->data);
next = current->link;
}while(current->link != NULL);
puts("\n");
}
void sort_list(Node **linkp){
int temp;
Node *current = *linkp;
Node *next = current->link;
while(current->link != NULL){
while(next != NULL){
if(current->data > next->data){
temp = next->data;
next->data = current->data;
current->data = temp;
}
next = next->link;
}
current = current->link;
next = current->link;
}
}
/*
* ./callback
**Program creates Singly Linked List**
**And allows users to perform various operations on thelist**
User, specify number of nodes in the list, in range 1 through some positive no.
5
List with 5 nodes created successfully!
Les's insert 5 integers in the list...
32
53
1
08
0556
**Les's show up the list**
325318556
Let's sort the list, in ascending order...
Let's show up the list**
183253556
**Let's use Callback() function**
User, enter an integer you want to see into the Singly Linked List...
53
Desired value is found */
* Callback.c - 연결 목록 콜백 구현
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct NODE {
struct NODE *link;
int data;
}Node;
Node **create_sll(const int);
void insert_data(Node **);
void show_list(Node **);
void sort_list(Node **);
int compare_ints(void const *, void const *); /* 프로토타입 함수 */
Node *search_list(Node *, void const *, int(void const *, void const *)); /* 프로토타입 */
int main(void){
int (*compare)(void const *, void const *) = compare_ints;
int value, val2find;
int nodes; /* 노트 카운트 */
Node **rootp; /* 루투 위치 */
Node *desired_node;
puts("\n**Program creates Singly Linked List**");
puts("**And allows users to perform various operations on the"
"list**\n");
puts("User, specify number of nodes in the list, in range 1"
" through some positive no.");
scanf("%d", &nodes);
rootp = create_sll(nodes);
printf("Les's insert %d integers in the list...\n", nodes);
insert_data(rootp);
puts("**Les's show up the list**");
show_list(rootp);
puts("Let's sort the list, in ascending order...");
sort_list(rootp);
puts("Let's show up the list**");
show_list(rootp);
puts("**Let's use Callback() function**");
printf("User, enter an integer you want to see into the "
"Singly Linked List...\n");
scanf("%d", &val2find);
/* 콜밸 함수 호출 */
desired_node = search_list(*rootp, &val2find, compare);
if(desired_node != NULL)
puts("Desired value is found.");
else
puts("Desired value NOT found.");
return 0;
}
Node *search_list(Node *node, void const *value, int compare(void const *, void const *)){
while(node != NULL){
if(compare(&node->data, value) == 0)
break;
node = node->link;
}
return node;
}
int compare_ints(void const *p2nv, void const *p2v){
if(*(int *)p2nv == *(int *)p2v)
return 0;
else
return 1;
}
Node **create_sll(const int nodes){
int i;
Node *current;
static Node *root;
Node **rootp = &root;
root = (Node *)malloc(nodes * sizeof(Node));
if(root == NULL){
puts("Error: Not Enough Memory!");
exit(1);
} else {
current = root;
for(i = 1; i <= nodes; i++){
if(i == nodes) {
current->link = NULL;
} else {
current->link = current + 1;
current++;
}
}
printf("List with %d nodes created successfully!\n", nodes);
puts("");
}
return rootp;
}
void insert_data(Node **linkp){
Node *next = *linkp;
Node *current;
do {
current = next;
scanf("%d", &(current->data));
next = current->link;
}while(current->link != NULL);
puts("");
}
void show_list(Node **linkp){
Node *next = *linkp;
Node *current;
do{
current = next;
printf("%d", current->data);
next = current->link;
}while(current->link != NULL);
puts("\n");
}
void sort_list(Node **linkp){
int temp;
Node *current = *linkp;
Node *next = current->link;
while(current->link != NULL){
while(next != NULL){
if(current->data > next->data){
temp = next->data;
next->data = current->data;
current->data = temp;
}
next = next->link;
}
current = current->link;
next = current->link;
}
}
/*
* ./callback
**Program creates Singly Linked List**
**And allows users to perform various operations on thelist**
User, specify number of nodes in the list, in range 1 through some positive no.
5
List with 5 nodes created successfully!
Les's insert 5 integers in the list...
32
53
1
08
0556
**Les's show up the list**
325318556
Let's sort the list, in ascending order...
Let's show up the list**
183253556
**Let's use Callback() function**
User, enter an integer you want to see into the Singly Linked List...
53
Desired value is found */
2019/01/03
odroid sdcard ubuntu 설치
Ubuntu SD 카드 설치
파티션 정보 확인
fdisk -l
sd card( mmcblk0) 마운트 해제
umount /dev/sdx1
체크썸으로 img 파일 확인
md5sum odroidu2_20130104-linaro-ubuntu-desktop-uSDeMMC.img.xz
해쉬값 odroidu2_20130104-linaro-ubuntu-desktop-uSDeMMC.img.xz
압축 해제
xz -d odroidu2_20130104-linaro-ubuntu-desktop-uSDeMMC.img.xz
루트 파일 시스템 복사
sudo dd if=odroidu2_20130104-linaro-ubuntu-desktop-uSDeMMC.img of=/dev/sdx bs=4M
파티션 정보 확인
fdisk -l
sd card( mmcblk0) 마운트 해제
umount /dev/sdx1
체크썸으로 img 파일 확인
md5sum odroidu2_20130104-linaro-ubuntu-desktop-uSDeMMC.img.xz
해쉬값 odroidu2_20130104-linaro-ubuntu-desktop-uSDeMMC.img.xz
압축 해제
xz -d odroidu2_20130104-linaro-ubuntu-desktop-uSDeMMC.img.xz
루트 파일 시스템 복사
sudo dd if=odroidu2_20130104-linaro-ubuntu-desktop-uSDeMMC.img of=/dev/sdx bs=4M
리눅스 vmware image 다운로드 사이트
개발 환경 구축시 집적 설치 하는 것도 좋지만, 빠르게 진행시... 걍 다운로드 받아 개발 환경 구축 하는게 정신 건강에 좋다.
http://www.trendsigma.net/vmware/
http://www.trendsigma.net/vmware/
루트파일 시스템 이미지 업데이트 방법
루트 파일 시스템 업데이트
이미지용 루트 파일 시스템과, SD 카드의 루트 파일 시스템 구성 방법이 다름.
SD 카드는 전체적 내용이 있으며, 이미지는 부팅에 관한 구성만 있다.
이러한 구성 요소를 이해 하면, 윈도우 메니지먼트를 변경해 gui를 변경 할 수 있다.
부팅:
u-boot 환경 변수 동작
환경 변수에 따른 커널 로드.
커널 initrd -> init 루트 파일 시스템 로드.
rootfs:
배포판 구성 패키지 방법.
루트 파일 시스템 이미지 사용 업데이트 방법
cd /media
# 체크썸 파일
sudo wget http://odroid.us/odroid/odroidu2/ubuntu/odroidu2_20130104-linaro-lbuntu-desktop-1-rootfs.tgz.md5sum
# 루트파일 다운로드
sudo wget http://odroid.us/odroid/odroidu2/ubuntu/odroidu2_20130104-linaro-lbuntu-desktop-1-rootfs.tgz
# 압축 파일 체크
md5sum -c odroidu2_20130104-linaro-lbuntu-desktop-1-rootfs.tgz.md5sum
SD 카드 이동
cd /media/rootfs
SD 카드 내용 삭제
/media/rootfs# sudo rm -rf *
다운로드 받은 파일. 압축해제
sudo tar -xvzf ../odroidu2_20130104-linaro-lbuntu-desktop-1-rootfs.tgz
cd ..
sync
마운트 해제
sudo umount /dev/sdX2
루트 파일 시스템 백업
SD Card 루트 파일 시스템 백업
SD 카드를 호스트에 마운트.
cd /media/rootfs
tar -cvzf ../my-backup-rootfs.tgz
sync
cd ../
umount /media/rootfs
sdcard 루트 파일 시스템 추출
sudo apt-get install parted
루트 파일 시스템 이미지 파일 정보 확인.(개발 또는 사용할 이미지 이름 사용)
parted -s 개발용_odroid_보드-uSDeMMC.img unit B print
1 1572864B 35127295B 33554432B primary fat16
2 35127296B 5874122751B 5838995456B primary ext4
fat16 : dos 파일 시스템
ext4 : 리눅스 파일 시스템
파티션 시작 정보 확인.
두 번째 ext4 offwet 주소 35127296 시작 확인
mkdir mnt
sudo mount -o loop,ro,offset=35127296 개발용_odroid_보드-uSDeMMC.img mnt
파일 압축
cd mnt
sudo tar -cvzf ../rootfs.tgz .
cd ..
sudo umount mnt
이미지용 루트 파일 시스템과, SD 카드의 루트 파일 시스템 구성 방법이 다름.
SD 카드는 전체적 내용이 있으며, 이미지는 부팅에 관한 구성만 있다.
이러한 구성 요소를 이해 하면, 윈도우 메니지먼트를 변경해 gui를 변경 할 수 있다.
부팅:
u-boot 환경 변수 동작
환경 변수에 따른 커널 로드.
커널 initrd -> init 루트 파일 시스템 로드.
rootfs:
배포판 구성 패키지 방법.
루트 파일 시스템 이미지 사용 업데이트 방법
cd /media
# 체크썸 파일
sudo wget http://odroid.us/odroid/odroidu2/ubuntu/odroidu2_20130104-linaro-lbuntu-desktop-1-rootfs.tgz.md5sum
# 루트파일 다운로드
sudo wget http://odroid.us/odroid/odroidu2/ubuntu/odroidu2_20130104-linaro-lbuntu-desktop-1-rootfs.tgz
# 압축 파일 체크
md5sum -c odroidu2_20130104-linaro-lbuntu-desktop-1-rootfs.tgz.md5sum
SD 카드 이동
cd /media/rootfs
SD 카드 내용 삭제
/media/rootfs# sudo rm -rf *
다운로드 받은 파일. 압축해제
sudo tar -xvzf ../odroidu2_20130104-linaro-lbuntu-desktop-1-rootfs.tgz
cd ..
sync
마운트 해제
sudo umount /dev/sdX2
루트 파일 시스템 백업
SD Card 루트 파일 시스템 백업
SD 카드를 호스트에 마운트.
cd /media/rootfs
tar -cvzf ../my-backup-rootfs.tgz
sync
cd ../
umount /media/rootfs
sdcard 루트 파일 시스템 추출
sudo apt-get install parted
루트 파일 시스템 이미지 파일 정보 확인.(개발 또는 사용할 이미지 이름 사용)
parted -s 개발용_odroid_보드-uSDeMMC.img unit B print
1 1572864B 35127295B 33554432B primary fat16
2 35127296B 5874122751B 5838995456B primary ext4
fat16 : dos 파일 시스템
ext4 : 리눅스 파일 시스템
파티션 시작 정보 확인.
두 번째 ext4 offwet 주소 35127296 시작 확인
mkdir mnt
sudo mount -o loop,ro,offset=35127296 개발용_odroid_보드-uSDeMMC.img mnt
파일 압축
cd mnt
sudo tar -cvzf ../rootfs.tgz .
cd ..
sudo umount mnt
odroid qemu ubuntu 18.04 sdcard 동작
참고: https://nautiluslee.blogspot.com/2019/01/ubuntu-1804-odroid-qemu.html
우분투 실행
SD Card 루트 파일 시스템 백업
SD 카드를 호스트에 마운트.
cd /media/rootfs
tar -cvzf ../my-backup-rootfs.tgz
sync
cd ../
umount rootfs
sdcard 루트 파일 시스템 추출
sudo apt-get install parted
루트 파일 시스템 이미지 파일 정보 확인.(개발 또는 사용할 이미지 이름 사용)
parted -s 개발용_odroid_보드-uSDeMMC.img unit B print
1 1572864B 35127295B 33554432B primary fat16
2 35127296B 5874122751B 5838995456B primary ext4
fat16 : dos 파일 시스템
ext4 : 리눅스 파일 시스템
파티션 시작 정보 확인.
두 번째 ext4 offwet 주소 35127296 시작 확인
mkdir mnt
sudo mount -o loop,ro,offset=35127296 개발용_odroid_보드-uSDeMMC.img mnt
파일 압축
cd mnt
sudo tar -cvzf ../rootfs.tgz .
cd ..
sudo umount mnt
mv rootfs.tgz rootfs-ubuntu.ext4
부팅 시작 스크립트
#! /bin/sh
# filename launch-ubuntu
ROOTFS=rootfs-ubuntu.ext4
NETWORK="-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=no"
#NETWORK="-net nic -net user"
KERNEL="-kernel zImage "
qemu-system-arm -append "root=/dev/mmcblk0 rw physmap.enabled=0 console=ttyAMA0" -M vexpress-a9 $KERNEL -sd $ROOTFS $NETWORK -serial stdio
실행
./launch-ubuntu
# UNCONFIGURED FSTAB FOR BASE SYSTEM
UUID=e139ce78-9841-40fe-8823-96a304a09859 / ext4 errors=remount-ro,noatime 0 1
/dev/mmcblk0p1 /media/boot vfat defaults 0 1
To:
# UNCONFIGURED FSTAB FOR BASE SYSTEM
/dev/mmcblk0 / ext4 errors=remount-ro,noatime 0 1
qemu-system-arm 명령어를 사용해 그래픽 모드 활성화
우분투 실행
SD Card 루트 파일 시스템 백업
SD 카드를 호스트에 마운트.
cd /media/rootfs
tar -cvzf ../my-backup-rootfs.tgz
sync
cd ../
umount rootfs
sdcard 루트 파일 시스템 추출
sudo apt-get install parted
루트 파일 시스템 이미지 파일 정보 확인.(개발 또는 사용할 이미지 이름 사용)
parted -s 개발용_odroid_보드-uSDeMMC.img unit B print
1 1572864B 35127295B 33554432B primary fat16
2 35127296B 5874122751B 5838995456B primary ext4
fat16 : dos 파일 시스템
ext4 : 리눅스 파일 시스템
파티션 시작 정보 확인.
두 번째 ext4 offwet 주소 35127296 시작 확인
mkdir mnt
sudo mount -o loop,ro,offset=35127296 개발용_odroid_보드-uSDeMMC.img mnt
파일 압축
cd mnt
sudo tar -cvzf ../rootfs.tgz .
cd ..
sudo umount mnt
mv rootfs.tgz rootfs-ubuntu.ext4
부팅 시작 스크립트
#! /bin/sh
# filename launch-ubuntu
ROOTFS=rootfs-ubuntu.ext4
NETWORK="-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=no"
#NETWORK="-net nic -net user"
KERNEL="-kernel zImage "
qemu-system-arm -append "root=/dev/mmcblk0 rw physmap.enabled=0 console=ttyAMA0" -M vexpress-a9 $KERNEL -sd $ROOTFS $NETWORK -serial stdio
실행
./launch-ubuntu
# UNCONFIGURED FSTAB FOR BASE SYSTEM
UUID=e139ce78-9841-40fe-8823-96a304a09859 / ext4 errors=remount-ro,noatime 0 1
/dev/mmcblk0p1 /media/boot vfat defaults 0 1
To:
# UNCONFIGURED FSTAB FOR BASE SYSTEM
/dev/mmcblk0 / ext4 errors=remount-ro,noatime 0 1
qemu-system-arm 명령어를 사용해 그래픽 모드 활성화
ubuntu 18.04 odroid qemu 테스트 개발 환경 구축
패키지 업데이트 및 필요한 패키지 설치
apt-get update
sudo apt-get install libpixman-1-dev zlib1g-dev libglib2.0-dev shtool build-essential
테스트할 파일 다운로드
작업 디렉토리 생성
mkdir odroidu2
cd odroidu2/
다운로드 및 압축해제.
wget http://odroid.us/odroid/users/osterluk/qemu-example/qemu-example.tgz
tar -xvf qemu-example.tgz
압출파일 설명
launch : 호스트 환경 네트워크 인터페이스 공유해 전체 네트워킹 지원을 스크립트
launch-no-bridge : 가상 LAN 루트파일 시스템 동작.
launch-ubuntu : ext4 SD 카드 이미지 추출
rootfs-buildroot.ext2 : rootfs.tar.gz에서 변환된 ext2 루트 파일 시스템 파티션
rootfs.tar.gz : 루트파일 시스템
vexpress_defconfig : 튜토리얼 사용되는 커널 zImage
vexpress_odroid_qemu_defconfig : 튜토리얼에서 사용 zImage
zImage : linux-3.2 커널 소스에서 vexpress-a9 머신 용으로 빌드 된 커널.
qemu 설치.
sudo apt install qemu-system-arm
qemu 버전 확인.
qemu-system-arm --version
QEMU emulator version 2.12.0 (Debian 1:2.12+dfsg-3ubuntu4+ppa1)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
cortex-9 지원 여부 확인
qemu-system-arm -cpu ? | grep cortex-a9
cpu 유형 확인.
qemu-system-arm -M ? | grep vexpress-a9
최신 버전 설치
sudo apt-get install qemu
현재 우분투 18.04 재공하는 패키지에서는 cotex-a9 지원 없음.
qemu 컴파일
sudo apt-get install libpixman-1-dev zlib1g-dev libglib2.0-dev shtool build-essential
소스 다운로드
cd $HOME
mkdir qemu-build
cd qemu-build
wget http://wiki.qemu-project.org/download/qemu-3.0.0.tar.bz2
tar -xvf qemu-3.0.0.tar
cd $HOME/qemu-build/qemu-3.0.0
./configure --prefix=/usr/local --static --disable-kvm --target-list=arm-linux-user
make
sudo make install
설치 경로 확인
which qemu-arm
정적 파일이름 변경
sudo mv /usr/local/bin/qemu-arm /usr/local/bin/qemu-arm-static
동적 컴파일
cd $HOME/qemu-build/qemu-3.0.0
./configure --enable-system --prefix=/usr/local --disable-kvm --target-list=arm-linux-user
make
sudo make install
버전 확인
qemu-system-arm --version
QEMU emulator version 2.12.0 (Debian 1:2.12+dfsg-3ubuntu4+ppa1)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
cpu 지원 확인
qemu-system-arm -M ? | grep vexpress
vexpress-a15 ARM Versatile Express for Cortex-A15
vexpress-a9 ARM Versatile Express for Cortex-A9
busybox 루트 파일 시스템 생성
cd $HOME/odroidu2
qemu-img create rootfs-buildroot.ext2 200M
ext2 파일 시스템 생성
sudo mkfs.ext2 rootfs-buildroot.ext2
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 204800 1k blocks and 51200 inodes
Filesystem UUID: 36a430ea-6396-4ac8-be2e-33cea4ecf301
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
루트 파일 시스템 마운트
mkdir mnt
sudo mount -o loop rootfs-buildroot.ext2 mnt
루트 파일 시스템 압축해제
cd mnt
sudo tar -xvzf ../rootfs.tar.gz
ls
bin dev etc home lib linuxrc lost+found media mnt opt proc root run sbin sys tmp usr var
마운트 해제
cd ../
sudo umount ./mnt
네트워 브리지 설정
cat launch-no-bridge
#! /bin/sh
# filename: launch-no-bridge
# Set environment variables to make it easier to change
export ROOTFS=rootfs-buildroot.ext2
export NETWORK="-net nic -net user"
export KERNEL="-kernel zImage "
qemu-system-arm -append "root=/dev/mmcblk0 rw physmap.enabled=0 console=ttyAMA0" -M vexpress-a9 $KERNEL -sd $ROOTFS $NETWORK -nographic
부팅 로그인: root
./launch-no-bridge
Welcome to Buildroot
odroidu2-1 login: root
#
apt-get update
sudo apt-get install libpixman-1-dev zlib1g-dev libglib2.0-dev shtool build-essential
테스트할 파일 다운로드
작업 디렉토리 생성
mkdir odroidu2
cd odroidu2/
다운로드 및 압축해제.
wget http://odroid.us/odroid/users/osterluk/qemu-example/qemu-example.tgz
tar -xvf qemu-example.tgz
압출파일 설명
launch : 호스트 환경 네트워크 인터페이스 공유해 전체 네트워킹 지원을 스크립트
launch-no-bridge : 가상 LAN 루트파일 시스템 동작.
launch-ubuntu : ext4 SD 카드 이미지 추출
rootfs-buildroot.ext2 : rootfs.tar.gz에서 변환된 ext2 루트 파일 시스템 파티션
rootfs.tar.gz : 루트파일 시스템
vexpress_defconfig : 튜토리얼 사용되는 커널 zImage
vexpress_odroid_qemu_defconfig : 튜토리얼에서 사용 zImage
zImage : linux-3.2 커널 소스에서 vexpress-a9 머신 용으로 빌드 된 커널.
qemu 설치.
sudo apt install qemu-system-arm
qemu 버전 확인.
qemu-system-arm --version
QEMU emulator version 2.12.0 (Debian 1:2.12+dfsg-3ubuntu4+ppa1)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
cortex-9 지원 여부 확인
qemu-system-arm -cpu ? | grep cortex-a9
cpu 유형 확인.
qemu-system-arm -M ? | grep vexpress-a9
최신 버전 설치
sudo apt-get install qemu
현재 우분투 18.04 재공하는 패키지에서는 cotex-a9 지원 없음.
qemu 컴파일
sudo apt-get install libpixman-1-dev zlib1g-dev libglib2.0-dev shtool build-essential
소스 다운로드
cd $HOME
mkdir qemu-build
cd qemu-build
wget http://wiki.qemu-project.org/download/qemu-3.0.0.tar.bz2
tar -xvf qemu-3.0.0.tar
cd $HOME/qemu-build/qemu-3.0.0
./configure --prefix=/usr/local --static --disable-kvm --target-list=arm-linux-user
make
sudo make install
설치 경로 확인
which qemu-arm
정적 파일이름 변경
sudo mv /usr/local/bin/qemu-arm /usr/local/bin/qemu-arm-static
동적 컴파일
cd $HOME/qemu-build/qemu-3.0.0
./configure --enable-system --prefix=/usr/local --disable-kvm --target-list=arm-linux-user
make
sudo make install
버전 확인
qemu-system-arm --version
QEMU emulator version 2.12.0 (Debian 1:2.12+dfsg-3ubuntu4+ppa1)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
cpu 지원 확인
qemu-system-arm -M ? | grep vexpress
vexpress-a15 ARM Versatile Express for Cortex-A15
vexpress-a9 ARM Versatile Express for Cortex-A9
busybox 루트 파일 시스템 생성
cd $HOME/odroidu2
qemu-img create rootfs-buildroot.ext2 200M
ext2 파일 시스템 생성
sudo mkfs.ext2 rootfs-buildroot.ext2
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 204800 1k blocks and 51200 inodes
Filesystem UUID: 36a430ea-6396-4ac8-be2e-33cea4ecf301
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
루트 파일 시스템 마운트
mkdir mnt
sudo mount -o loop rootfs-buildroot.ext2 mnt
루트 파일 시스템 압축해제
cd mnt
sudo tar -xvzf ../rootfs.tar.gz
ls
bin dev etc home lib linuxrc lost+found media mnt opt proc root run sbin sys tmp usr var
마운트 해제
cd ../
sudo umount ./mnt
네트워 브리지 설정
cat launch-no-bridge
#! /bin/sh
# filename: launch-no-bridge
# Set environment variables to make it easier to change
export ROOTFS=rootfs-buildroot.ext2
export NETWORK="-net nic -net user"
export KERNEL="-kernel zImage "
qemu-system-arm -append "root=/dev/mmcblk0 rw physmap.enabled=0 console=ttyAMA0" -M vexpress-a9 $KERNEL -sd $ROOTFS $NETWORK -nographic
부팅 로그인: root
./launch-no-bridge
Welcome to Buildroot
odroidu2-1 login: root
#
크로스 컴파일 테스트
테스트
$ aarch64-linux-g++ -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-g++
COLLECT_LTO_WRAPPER=/opt/cross/libexec/gcc/aarch64-linux/4.9.2/lto-wrapper
Target: aarch64-linux
Configured with: ../gcc-4.9.2/configure --prefix=/opt/cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 4.9.2 (GCC)
$ aarch64-linux-g++ -std=c++14 test.cpp
$ aarch64-linux-objdump -d a.out
...
0000000000400830 <main>:
400830: a9be7bfd stp x29, x30, [sp,#-32]!
400834: 910003fd mov x29, sp
400838: 910063a2 add x2, x29, #0x18
40083c: 9000
$ aarch64-linux-g++ -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-g++
COLLECT_LTO_WRAPPER=/opt/cross/libexec/gcc/aarch64-linux/4.9.2/lto-wrapper
Target: aarch64-linux
Configured with: ../gcc-4.9.2/configure --prefix=/opt/cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 4.9.2 (GCC)
$ aarch64-linux-g++ -std=c++14 test.cpp
$ aarch64-linux-objdump -d a.out
...
0000000000400830 <main>:
400830: a9be7bfd stp x29, x30, [sp,#-32]!
400834: 910003fd mov x29, sp
400838: 910063a2 add x2, x29, #0x18
40083c: 9000
크로스 컴파일러 제작 스크립트.
변경 이력
TARGET=aarch64-elf
USE_NEWLIB=1
CONFIGURATION_OPTIONS="--disable-multilib --disable-threads"
자동 스크립트
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#-------------------------------------------------------------------------------------------
# 이 스크립트는 GCC 크로스 컴파일러의 패키지 다운로드, 구성, 빌드.
#-------------------------------------------------------------------------------------------
INSTALL_PATH=/opt/cross
TARGET=aarch64-linux
USE_NEWLIB=0
LINUX_ARCH=arm64
CONFIGURATION_OPTIONS="--disable-multilib" # --disable-threads --disable-shared
PARALLEL_MAKE=-j4
BINUTILS_VERSION=binutils-2.24
GCC_VERSION=gcc-4.9.2
LINUX_KERNEL_VERSION=linux-3.17.2
GLIBC_VERSION=glibc-2.20
MPFR_VERSION=mpfr-3.1.2
GMP_VERSION=gmp-6.0.0a
MPC_VERSION=mpc-1.0.2
ISL_VERSION=isl-0.12.2
CLOOG_VERSION=cloog-0.18.1
export PATH=$INSTALL_PATH/bin:$PATH
# 패키지 다운로드
export http_proxy=$HTTP_PROXY https_proxy=$HTTP_PROXY ftp_proxy=$HTTP_PROXY
wget -nc https://ftp.gnu.org/gnu/binutils/$BINUTILS_VERSION.tar.gz
wget -nc https://ftp.gnu.org/gnu/gcc/$GCC_VERSION/$GCC_VERSION.tar.gz
if [ $USE_NEWLIB -ne 0 ]; then
wget -nc -O newlib-master.zip https://github.com/bminor/newlib/archive/master.zip || true
unzip -qo newlib-master.zip
else
wget -nc https://www.kernel.org/pub/linux/kernel/v3.x/$LINUX_KERNEL_VERSION.tar.xz
wget -nc https://ftp.gnu.org/gnu/glibc/$GLIBC_VERSION.tar.xz
fi
wget -nc https://ftp.gnu.org/gnu/mpfr/$MPFR_VERSION.tar.xz
wget -nc https://ftp.gnu.org/gnu/gmp/$GMP_VERSION.tar.xz
wget -nc https://ftp.gnu.org/gnu/mpc/$MPC_VERSION.tar.gz
wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/$ISL_VERSION.tar.bz2
wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/$CLOOG_VERSION.tar.gz
# 압축해제
for f in *.tar*; do tar xfk $f; done
# 심볼링크
cd $GCC_VERSION
ln -sf `ls -1d ../mpfr-*/` mpfr
ln -sf `ls -1d ../gmp-*/` gmp
ln -sf `ls -1d ../mpc-*/` mpc
ln -sf `ls -1d ../isl-*/` isl
ln -sf `ls -1d ../cloog-*/` cloog
cd ..
# Step 1. 구성 환경 설정 적용
mkdir -p build-binutils
cd build-binutils
../$BINUTILS_VERSION/configure --prefix=$INSTALL_PATH --target=$TARGET $CONFIGURATION_OPTIONS
make $PARALLEL_MAKE
make install
cd ..
# Step 2. 커널 헤더
if [ $USE_NEWLIB -eq 0 ]; then
cd $LINUX_KERNEL_VERSION
make ARCH=$LINUX_ARCH INSTALL_HDR_PATH=$INSTALL_PATH/$TARGET headers_install
cd ..
fi
# Step 3. C/C++ 컴파일러
mkdir -p build-gcc
cd build-gcc
if [ $USE_NEWLIB -ne 0 ]; then
NEWLIB_OPTION=--with-newlib
fi
../$GCC_VERSION/configure --prefix=$INSTALL_PATH --target=$TARGET --enable-languages=c,c++ $CONFIGURATION_OPTIONS $NEWLIB_OPTION
make $PARALLEL_MAKE all-gcc
make install-gcc
cd ..
if [ $USE_NEWLIB -ne 0 ]; then
# Steps 4-6: Newlib
mkdir -p build-newlib
cd build-newlib
../newlib-master/configure --prefix=$INSTALL_PATH --target=$TARGET $CONFIGURATION_OPTIONS
make $PARALLEL_MAKE
make install
cd ..
else
# Step 4. C 스텐다드 헤더 및 라이브러리
mkdir -p build-glibc
cd build-glibc
../$GLIBC_VERSION/configure --prefix=$INSTALL_PATH/$TARGET --build=$MACHTYPE --host=$TARGET --target=$TARGET --with-headers=$INSTALL_PATH/$TARGET/include $CONFIGURATION_OPTIONS libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers
make $PARALLEL_MAKE csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $INSTALL_PATH/$TARGET/lib
$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $INSTALL_PATH/$TARGET/lib/libc.so
touch $INSTALL_PATH/$TARGET/include/gnu/stubs.h
cd ..
# Step 5. 컴파일러 지원 라이브러리
cd build-gcc
make $PARALLEL_MAKE all-target-libgcc
make install-target-libgcc
cd ..
# Step 6. Glibc
cd build-glibc
make $PARALLEL_MAKE
make install
cd ..
fi
# Step 7. C++ 라이브러리 GCC
cd build-gcc
make $PARALLEL_MAKE all
make install
cd ..
trap - EXIT
echo 'Success!'
TARGET=aarch64-elf
USE_NEWLIB=1
CONFIGURATION_OPTIONS="--disable-multilib --disable-threads"
자동 스크립트
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#-------------------------------------------------------------------------------------------
# 이 스크립트는 GCC 크로스 컴파일러의 패키지 다운로드, 구성, 빌드.
#-------------------------------------------------------------------------------------------
INSTALL_PATH=/opt/cross
TARGET=aarch64-linux
USE_NEWLIB=0
LINUX_ARCH=arm64
CONFIGURATION_OPTIONS="--disable-multilib" # --disable-threads --disable-shared
PARALLEL_MAKE=-j4
BINUTILS_VERSION=binutils-2.24
GCC_VERSION=gcc-4.9.2
LINUX_KERNEL_VERSION=linux-3.17.2
GLIBC_VERSION=glibc-2.20
MPFR_VERSION=mpfr-3.1.2
GMP_VERSION=gmp-6.0.0a
MPC_VERSION=mpc-1.0.2
ISL_VERSION=isl-0.12.2
CLOOG_VERSION=cloog-0.18.1
export PATH=$INSTALL_PATH/bin:$PATH
# 패키지 다운로드
export http_proxy=$HTTP_PROXY https_proxy=$HTTP_PROXY ftp_proxy=$HTTP_PROXY
wget -nc https://ftp.gnu.org/gnu/binutils/$BINUTILS_VERSION.tar.gz
wget -nc https://ftp.gnu.org/gnu/gcc/$GCC_VERSION/$GCC_VERSION.tar.gz
if [ $USE_NEWLIB -ne 0 ]; then
wget -nc -O newlib-master.zip https://github.com/bminor/newlib/archive/master.zip || true
unzip -qo newlib-master.zip
else
wget -nc https://www.kernel.org/pub/linux/kernel/v3.x/$LINUX_KERNEL_VERSION.tar.xz
wget -nc https://ftp.gnu.org/gnu/glibc/$GLIBC_VERSION.tar.xz
fi
wget -nc https://ftp.gnu.org/gnu/mpfr/$MPFR_VERSION.tar.xz
wget -nc https://ftp.gnu.org/gnu/gmp/$GMP_VERSION.tar.xz
wget -nc https://ftp.gnu.org/gnu/mpc/$MPC_VERSION.tar.gz
wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/$ISL_VERSION.tar.bz2
wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/$CLOOG_VERSION.tar.gz
# 압축해제
for f in *.tar*; do tar xfk $f; done
# 심볼링크
cd $GCC_VERSION
ln -sf `ls -1d ../mpfr-*/` mpfr
ln -sf `ls -1d ../gmp-*/` gmp
ln -sf `ls -1d ../mpc-*/` mpc
ln -sf `ls -1d ../isl-*/` isl
ln -sf `ls -1d ../cloog-*/` cloog
cd ..
# Step 1. 구성 환경 설정 적용
mkdir -p build-binutils
cd build-binutils
../$BINUTILS_VERSION/configure --prefix=$INSTALL_PATH --target=$TARGET $CONFIGURATION_OPTIONS
make $PARALLEL_MAKE
make install
cd ..
# Step 2. 커널 헤더
if [ $USE_NEWLIB -eq 0 ]; then
cd $LINUX_KERNEL_VERSION
make ARCH=$LINUX_ARCH INSTALL_HDR_PATH=$INSTALL_PATH/$TARGET headers_install
cd ..
fi
# Step 3. C/C++ 컴파일러
mkdir -p build-gcc
cd build-gcc
if [ $USE_NEWLIB -ne 0 ]; then
NEWLIB_OPTION=--with-newlib
fi
../$GCC_VERSION/configure --prefix=$INSTALL_PATH --target=$TARGET --enable-languages=c,c++ $CONFIGURATION_OPTIONS $NEWLIB_OPTION
make $PARALLEL_MAKE all-gcc
make install-gcc
cd ..
if [ $USE_NEWLIB -ne 0 ]; then
# Steps 4-6: Newlib
mkdir -p build-newlib
cd build-newlib
../newlib-master/configure --prefix=$INSTALL_PATH --target=$TARGET $CONFIGURATION_OPTIONS
make $PARALLEL_MAKE
make install
cd ..
else
# Step 4. C 스텐다드 헤더 및 라이브러리
mkdir -p build-glibc
cd build-glibc
../$GLIBC_VERSION/configure --prefix=$INSTALL_PATH/$TARGET --build=$MACHTYPE --host=$TARGET --target=$TARGET --with-headers=$INSTALL_PATH/$TARGET/include $CONFIGURATION_OPTIONS libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers
make $PARALLEL_MAKE csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $INSTALL_PATH/$TARGET/lib
$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $INSTALL_PATH/$TARGET/lib/libc.so
touch $INSTALL_PATH/$TARGET/include/gnu/stubs.h
cd ..
# Step 5. 컴파일러 지원 라이브러리
cd build-gcc
make $PARALLEL_MAKE all-target-libgcc
make install-target-libgcc
cd ..
# Step 6. Glibc
cd build-glibc
make $PARALLEL_MAKE
make install
cd ..
fi
# Step 7. C++ 라이브러리 GCC
cd build-gcc
make $PARALLEL_MAKE all
make install
cd ..
trap - EXIT
echo 'Success!'
크로스 컴파일러 제작.
GCC 크로스 컴파일러 만들기
build system : Linux
Host system : Linux
Target system : Linux
필수 패키지 설치
$ sudo apt-get install g++ make gawk
소스 코드 다운로드
http://ftp.kaist.ac.kr/gnu/binutils/
$ wget http://ftpmirror.gnu.org/binutils/binutils-2.24.tar.gz
$ wget http://ftpmirror.gnu.org/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz
$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.17.2.tar.xz
$ wget http://ftpmirror.gnu.org/glibc/glibc-2.20.tar.xz
$ wget http://ftpmirror.gnu.org/mpfr/mpfr-3.1.2.tar.xz
$ wget http://ftpmirror.gnu.org/gmp/gmp-6.0.0a.tar.xz
$ wget http://ftpmirror.gnu.org/mpc/mpc-1.0.2.tar.gz
$ wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2
$ wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz
프로젝트 사이트 정의
Binutils: https://www.gnu.org/software/binutils/
GCC: https://gcc.gnu.org/
Linux kernel: https://www.kernel.org/
Glibc : https://www.gnu.org/software/libc/
크로스 컴파일 구성 방법
Host Programs: X64
C Cross-Compile: aarch64-linux-gcc Built from GCC
C++ Cross-Compiler: aarch64-linux-g++ built from GCC
CROSS-Assember Cross-Link: aarch64-linux-as, aarch64-linux-ld, built from Binutils
Target Programs & libraries : AArch64
a.out: sample program
Standard C++ Library: libstdc++.so built from GCC
Standard C Library : libc.so, built from Glibc
Linux Kernel
Glibc 과련 사이트
Newlib: https://sourceware.org/newlib/
Libgolss: http://ieee.uwaterloo.ca/coldfire/gcc-doc/docs/porting_1.html
빌드
압축 해제
$ for f in *.tar*; do tar xf $f; done
gcc 심볼링크 생성
gcc 의존성 때문에 심볼링크 설정 해주면 자동으로 의존성을 해결함.
https://gcc.gnu.org/install/download.html
$ cd gcc-4.9.2
$ ln -s ../mpfr-3.1.2 mpfr
$ ln -s ../gmp-6.0.0 gmp
$ ln -s ../mpc-1.0.2 mpc
$ ln -s ../isl-0.12.2 isl
$ ln -s ../cloog-0.18.1 cloog
$ cd ..
툴 체인 설치 위치 지정
$ sudo mkdir -p /opt/cross
$ sudo chown jeff /opt/cross
패스 지정.
$ export PATH=/opt/cross/bin:$PATH
1. 빌드
$ mkdir build-binutils
$ cd build-binutils
$ ../binutils-2.24/configure --prefix=/opt/cross --target=aarch64-linux --disable-multilib
$ make -j4
$ make install
$ cd ..
$ cd linux-3.17.2
$ make ARCH=arm64 INSTALL_HDR_PATH=/opt/cross/aarch64-linux headers_install
$ cd ..
$ mkdir -p build-gcc
$ cd build-gcc
$ ../gcc-4.9.2/configure --prefix=/opt/cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
$ make -j4 all-gcc
$ make install-gcc
$ cd ..
--target=aarch64-linux 지정
--disable-multilib 64비트 명령어 세트 사용, 32 명령어 세트 사용하지 않음.
2. 리눅스 커널 헤더
/opt/cross/aarch64-linux/include 새로운 툴 체인을 사용하여 빌드, 시스템 호출 할 수 있게 환경 적용
$ cd linux-3.17.2
$ make ARCH=arm64 INSTALL_HDR_PATH=/opt/cross/aarch64-linux headers_install
$ cd ..
GCC components:
- C/C++ Compilers
-- aarch64-linux-gcc
-- aarch64-linux-g++ ----> Build Order
Glibc Components:
Standard C Library Headers and Startup Files
stdio.h, stdlib.h pthread.h,...
crti.o crtn.o crtl.o/libc.so
<----+
Compile Support Library
- Libgcc.a/libgcc.so ------> Standard C Library:
libc.a/libc.so
<---------+
Standard C++ Library
libstdc++.a/libstdc++.so
3. C/C++ 컴파일
$ mkdir -p build-glibc
$ cd build-glibc
// 20180103 이 옵션 사용.
$ ../gcc-4.9.2/configure --prefix=/opt/cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
$ make -j4 all-gcc
$ make install-gcc
$ cd ..
--target=aarch64-linux : 타켓 이름 지정(aarch64-linux)
--enable-languages=c,c++: Fortran, Go 또는 Java와 같은 GCC 제품군의 다른 컴파일러가 빌드되지 않도록한다.
4. 표준 C 라이브러리 및 헤더
Glibc의 표준 C 라이브러리 헤더 opt/cross/aarch64-linux/include 설치한다.
라이브러리는 설치 경로 /opt/cross/aarch64-linux/lib.
$ mkdir -p build-glibc
$ cd build-glibc
$ ../glibc-2.20/configure --prefix=/opt/cross/aarch64-linux --build=$MACHTYPE --host=aarch64-linux --target=aarch64-linux --with-headers=/opt/cross/aarch64-linux/include --disable-multilib libc_cv_forced_unwind=yes
$ make install-bootstrap-headers=yes install-headers
$ make -j4 csu/subdir_lib
$ install csu/crt1.o csu/crti.o csu/crtn.o /opt/cross/aarch64-linux/lib
$ aarch64-linux-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/cross/aarch64-linux/lib/libc.so
$ touch /opt/cross/aarch64-linux/include/gnu/stubs.h
$ cd ..
--prefix=/opt/cross/aarch64-linuxGlibc의 configure 스크립트에서 헤더와 라이브러리 설치 위지 설정
--build, --host및 --target시스템 유형
$MACHTYP 미리 정의 된 환결 변수
--build=$MACHTYP : 추가 도구 컴파일
5. 컴파일러 지원 라이브러리.
http://www.ifp.illinois.edu/~nakazato/tips/xgcc.html --> 이 구성에서 추가된 방식으로 진행.
$ cd build-gcc
$ make -j4 all-target-libgcc
$ make install-target-libgcc
$ cd ..
두 정적 라이브러리 libgcc.a, libgcc_eh.a 설치
/opt/cross/lib/gcc/aarch64-linux/4.9.2/.
공유 라이브러리 /opt/cross/aarch64-linux/lib64/libgcc_s.so 설치
6. 표준 C 라이브러리
/opt/cross/aarch64-linux/lib/lib.a
/opt/cross/aarch64-linux/lib/libc.so
$ cd build-glibc
$ make -j4
$ make install
$ cd ..
7. 표준 C++ 라이브러리
/opt/cross/aarch64-linux/lib64/libstdc++.a
/opt/cross/aarch64-linux/lib64/libstdc++.so
$ cd build-gcc
$ make -j4
$ make install
$ cd ..
build system : Linux
Host system : Linux
Target system : Linux
필수 패키지 설치
$ sudo apt-get install g++ make gawk
소스 코드 다운로드
http://ftp.kaist.ac.kr/gnu/binutils/
$ wget http://ftpmirror.gnu.org/binutils/binutils-2.24.tar.gz
$ wget http://ftpmirror.gnu.org/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz
$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.17.2.tar.xz
$ wget http://ftpmirror.gnu.org/glibc/glibc-2.20.tar.xz
$ wget http://ftpmirror.gnu.org/mpfr/mpfr-3.1.2.tar.xz
$ wget http://ftpmirror.gnu.org/gmp/gmp-6.0.0a.tar.xz
$ wget http://ftpmirror.gnu.org/mpc/mpc-1.0.2.tar.gz
$ wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2
$ wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz
프로젝트 사이트 정의
Binutils: https://www.gnu.org/software/binutils/
GCC: https://gcc.gnu.org/
Linux kernel: https://www.kernel.org/
Glibc : https://www.gnu.org/software/libc/
크로스 컴파일 구성 방법
Host Programs: X64
C Cross-Compile: aarch64-linux-gcc Built from GCC
C++ Cross-Compiler: aarch64-linux-g++ built from GCC
CROSS-Assember Cross-Link: aarch64-linux-as, aarch64-linux-ld, built from Binutils
Target Programs & libraries : AArch64
a.out: sample program
Standard C++ Library: libstdc++.so built from GCC
Standard C Library : libc.so, built from Glibc
Linux Kernel
Glibc 과련 사이트
Newlib: https://sourceware.org/newlib/
Libgolss: http://ieee.uwaterloo.ca/coldfire/gcc-doc/docs/porting_1.html
빌드
압축 해제
$ for f in *.tar*; do tar xf $f; done
gcc 심볼링크 생성
gcc 의존성 때문에 심볼링크 설정 해주면 자동으로 의존성을 해결함.
https://gcc.gnu.org/install/download.html
$ cd gcc-4.9.2
$ ln -s ../mpfr-3.1.2 mpfr
$ ln -s ../gmp-6.0.0 gmp
$ ln -s ../mpc-1.0.2 mpc
$ ln -s ../isl-0.12.2 isl
$ ln -s ../cloog-0.18.1 cloog
$ cd ..
툴 체인 설치 위치 지정
$ sudo mkdir -p /opt/cross
$ sudo chown jeff /opt/cross
패스 지정.
$ export PATH=/opt/cross/bin:$PATH
1. 빌드
$ mkdir build-binutils
$ cd build-binutils
$ ../binutils-2.24/configure --prefix=/opt/cross --target=aarch64-linux --disable-multilib
$ make -j4
$ make install
$ cd ..
$ cd linux-3.17.2
$ make ARCH=arm64 INSTALL_HDR_PATH=/opt/cross/aarch64-linux headers_install
$ cd ..
$ mkdir -p build-gcc
$ cd build-gcc
$ ../gcc-4.9.2/configure --prefix=/opt/cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
$ make -j4 all-gcc
$ make install-gcc
$ cd ..
--target=aarch64-linux 지정
--disable-multilib 64비트 명령어 세트 사용, 32 명령어 세트 사용하지 않음.
2. 리눅스 커널 헤더
/opt/cross/aarch64-linux/include 새로운 툴 체인을 사용하여 빌드, 시스템 호출 할 수 있게 환경 적용
$ cd linux-3.17.2
$ make ARCH=arm64 INSTALL_HDR_PATH=/opt/cross/aarch64-linux headers_install
$ cd ..
GCC components:
- C/C++ Compilers
-- aarch64-linux-gcc
-- aarch64-linux-g++ ----> Build Order
Glibc Components:
Standard C Library Headers and Startup Files
stdio.h, stdlib.h pthread.h,...
crti.o crtn.o crtl.o/libc.so
<----+
Compile Support Library
- Libgcc.a/libgcc.so ------> Standard C Library:
libc.a/libc.so
<---------+
Standard C++ Library
libstdc++.a/libstdc++.so
3. C/C++ 컴파일
$ mkdir -p build-glibc
$ cd build-glibc
// 20180103 이 옵션 사용.
$ ../gcc-4.9.2/configure --prefix=/opt/cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
$ make -j4 all-gcc
$ make install-gcc
$ cd ..
--target=aarch64-linux : 타켓 이름 지정(aarch64-linux)
--enable-languages=c,c++: Fortran, Go 또는 Java와 같은 GCC 제품군의 다른 컴파일러가 빌드되지 않도록한다.
4. 표준 C 라이브러리 및 헤더
Glibc의 표준 C 라이브러리 헤더 opt/cross/aarch64-linux/include 설치한다.
라이브러리는 설치 경로 /opt/cross/aarch64-linux/lib.
$ mkdir -p build-glibc
$ cd build-glibc
$ ../glibc-2.20/configure --prefix=/opt/cross/aarch64-linux --build=$MACHTYPE --host=aarch64-linux --target=aarch64-linux --with-headers=/opt/cross/aarch64-linux/include --disable-multilib libc_cv_forced_unwind=yes
$ make install-bootstrap-headers=yes install-headers
$ make -j4 csu/subdir_lib
$ install csu/crt1.o csu/crti.o csu/crtn.o /opt/cross/aarch64-linux/lib
$ aarch64-linux-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/cross/aarch64-linux/lib/libc.so
$ touch /opt/cross/aarch64-linux/include/gnu/stubs.h
$ cd ..
--prefix=/opt/cross/aarch64-linuxGlibc의 configure 스크립트에서 헤더와 라이브러리 설치 위지 설정
--build, --host및 --target시스템 유형
$MACHTYP 미리 정의 된 환결 변수
--build=$MACHTYP : 추가 도구 컴파일
5. 컴파일러 지원 라이브러리.
http://www.ifp.illinois.edu/~nakazato/tips/xgcc.html --> 이 구성에서 추가된 방식으로 진행.
$ cd build-gcc
$ make -j4 all-target-libgcc
$ make install-target-libgcc
$ cd ..
두 정적 라이브러리 libgcc.a, libgcc_eh.a 설치
/opt/cross/lib/gcc/aarch64-linux/4.9.2/.
공유 라이브러리 /opt/cross/aarch64-linux/lib64/libgcc_s.so 설치
6. 표준 C 라이브러리
/opt/cross/aarch64-linux/lib/lib.a
/opt/cross/aarch64-linux/lib/libc.so
$ cd build-glibc
$ make -j4
$ make install
$ cd ..
7. 표준 C++ 라이브러리
/opt/cross/aarch64-linux/lib64/libstdc++.a
/opt/cross/aarch64-linux/lib64/libstdc++.so
$ cd build-gcc
$ make -j4
$ make install
$ cd ..
피드 구독하기:
글 (Atom)