OS

[OS 개발] qemu-system-arm trouble shooting

Karatus 2021. 10. 6. 21:29
반응형

목차

  1. gtk initialization failed
  2. arm-none-eabi-gdb installation failed

 

1. gtk initialization failed

qemu-system-arm -M realview-pb-a8 -kernel navilos.axf -S -gdb tcp::1234,ipv4

책에서 ELF 실행 파일을 만든 후 위의 커맨드를 입력해서 디버깅을 하기 위한 준비를 한다. 하지만 Ubuntu 20.04 on WSL2 & QEMU 4.2.1 버전 환경에서 실행해보면 책과는 다른 에러가 도출된다.

$ qemu-system-arm -M realview-pb-a8 -kernel navilos.axf -S -gdb tcp::1234,ipv4
Unable to init server: Could not connect: Connection refused
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `lm4549.out'
gtk initialization failed

구글링 해보니까 책에서 나온 QEMU 버전(2.5.0)의 차이와 사운드 드라이버 (alsa)의 설정 문제는 아닌 것 같았다. 사운드 드라이버가 딱히 필요하지 않아 해당 에러는 잡아줄 필요가 없었고 결국 해결해야 할 건 하나다. 바로 맨 마지막 줄에 있는 gtk initialization failed 에러다.

gtk란 리눅스에서 GUI를 다루기 위해 쓰이는 대표적인 라이브러리 중 하나다. 하지만 개발 후 GUI 환경에서 다룰 드라이버들은 책에서도 현재로서도 만들 계획이 없기 때문에 없어도 된다. 그래서 disable 하기 위해 커맨드에 사용할 수 있는 3가지 옵션을 살펴봤다.

 

Options

· -nographic
   : 그래픽 출력을 아예 없애서 QEMU를 CUI로 동작하게 만든다.
· -curses
   : VGA 출력을 curses/ncurses interface를 사용하는 텍스트 모드로 보여준다. 그래픽 모드에서는 아무것도 보이지 않는다.
· -display none
   : display의 출력 타입을 지정해주는 옵션. -sdl/-curses 같은 old style 옵션의 대체다.
     none 타입은 QEMU로의 video output은 없으나 게스트 모드에서는 여전히 볼 수 있다.

필자는 공식 doc에 나온 것처럼 가장 최신 옵션을 사용해서 해보았다.

$ qemu-system-arm -M realview-pb-a8 -kernel navilos.axf -S -gdb tcp::1234,ipv4 -display none
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
...
audio: Failed to create voice `lm4549.out'
qemu-system-arm: -gdb tcp::1234,ipv4: Failed to find an available port: Address already in use

이전처럼 gtk 에러는 뜨지 않는다. 대신 마지막 줄에 보이는 것처럼 새로운 에러가 나왔는데 단순히 내가 실험한다고 여러 명령어 치다가 성공한 커맨드가 이미 1234 포트를 열어놔서 출력되는 에러니 신경 쓰지 않아도 된다.


2. arm-none-eabi-gdb installation failed

내가 현재 wsl2에서 사용하는 리눅스 환경은 Ubuntu 20.02 LTS다. 하지만 막상 포트 열어서 gdb로 디버깅하려고 보면 arm-none-eabi-gdb가 없어서 설치해야 한다. 설치하려고 sudo apt install gdb-arm-none-eabi 입력해도 다음과 같은 에러만 뜬다.

$ sudo apt install gdb-arm-none-eabi
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package gdb-arm-none-eabi

보아하니 20.04의 패키지 리스트에 없는 모양이다. 찾아보니 16.04까지는 패키지 리스트에 존재하는데 그 이후 버전부터 지원을 하지 않는 모양이다. 나와 비슷한 처지에 있는 사람들이 많아 구글링 하다가 이를 해결해줄 좋은 해결책을 발견했다. 

https://askubuntu.com/questions/1243252/how-to-install-arm-none-eabi-gdb-on-ubuntu-20-04-lts-focal-fossa

 

How to install arm-none-eabi-gdb on Ubuntu 20.04 LTS (Focal Fossa)

I tried to install arm-none-eabi-gdb as a part of gcc-arm-embedded. I added PPA: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa and executed: sudo apt install gcc-arm-embedded It respo...

askubuntu.com

해당 링크에서 채택된 답변을 보면 된다. 요약하면 arm 사에서 이제 배포를 안 해주고 자기네 사이트에서 계속 업데이트를 내주니 직접 수동으로 크로스 툴체인들을 설치해줘야 한다. 

해결책에 있는 대로 그대로 해주면 arm-none-eabi-gdb도 아주 잘 동작하고 사용할 수 있다.


Reference
https://web.archive.org/web/20200304204518/https://qemu.weilnetz.de/doc/qemu-doc.html#Display-options
https://jakupsil.tistory.com/36
https://stackoverflow.com/questions/6710555/how-to-use-qemu-to-run-a-non-gui-os-on-the-terminal
https://www.kernelpanic.kr/25

반응형