본문 바로가기

Embedded SW/Cortex-A

qemu code 받아 설치

반응형
git clone https://gitlab.com/qemu-project/qemu.git
cd qemu

./configure
make

 

cd qemu 작업 후 git branch -a 로 branch 를 살펴보면 버전 정보를 알 수 있다.

The latest development happens on the master branch. The stable trees are located in branches named stable-X.YY branch, where X.YY is the release version.

 

./configure 작업 중, mac의 경우

ERROR: Cannot find Ninja
-->
brew install ninja

 

../meson.build:995:10: ERROR: Dependency lookup for glib-2.0 with method 'pkgconfig' failed: Pkg-config for machine host machine not found. Giving up.
--> 
brew install pkg-config

 

 

make 까지 끝났다면,

그럼 build 디렉토리에가면 qemu-system- 등등이 빌드된 것을 확인 할 수 있다.

 

 

qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -kernel img.elf -s -S

옵션 설명

-M virt QEMU의 가상 ARM "virt" 보드 사용
-cpu cortex-a57 AArch64 아키텍처의 Cortex-A57 CPU 사용
-nographic 그래픽 출력을 끄고, UART를 터미널로 연결
-kernel img.elf 실행할 ELF 바이너리 (img.elf) 지정
-s gdb 서버를 기본 포트 (localhost:1234)에서 시작 (-gdb tcp::1234와 동일)
-S CPU를 정지 상태로 시작 (gdb로 붙을 때까지 실행 멈춤)

 

 

gdb 연결하고싶다면, 다른 터미널을 열고

aarch64-elf-gdb img.elf
gdb창에서 target remote:1234

 

 

 

 

FYI)

  • -kernel 옵션으로 ELF를 지정하면:
    • QEMU는 img.elf의 entry point를 읽어서,
    • 해당 entry point 주소(대개 0x40000000 또는 그 근처)부터 실행을 시작합니다.
  • -bios 로 bin 파일을 지정하면
    qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -bios bootrom.bin
    이렇게 하면 바이너리를 0x00000000에 로드하고 PC도 거기서 시작합니다 (ROM처럼 동작).

qemu/hw/arm/virt.c

우리가 사용할 virt 에 대한 memory map 정보는 코드에서 얻을 수 있다. 

반응형

'Embedded SW > Cortex-A' 카테고리의 다른 글

qemu, cross compiler 환경 셋업하기  (0) 2025.05.31