커널에 모듈을 추가하기 위해선 현재 시스템과 동일한 리눅스 커널 헤더가 있어야 한다.
우선 /usr/src 에 리눅스 커널 헤더가 있는지 확인해 본다.
pi@raspberrypi:/usr/src $ ls
sense-hat
제가 가지고 있는 라즈베리 파이에는 리눅스 커널 헤더가 없어서 다운로드하였다.
pi@raspberrypi:/usr/src $ sudo apt-get install linux-headers
<실행 결과>
pi@raspberrypi:/usr/src $ sudo apt-get install linux-headers
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'raspberrypi-kernel-headers' instead of 'linux-headers'
The following package was automatically installed and is no longer required:
libfuse2
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
raspberrypi-kernel-headers
0 upgraded, 1 newly installed, 0 to remove and 99 not upgraded.
Need to get 28.7 MB of archives.
After this operation, 183 MB of additional disk space will be used.
Get:1
http://archive.raspberrypi.org/debian
bullseye/main armhf raspberrypi-kernel-headers armhf 1:1.20221104-1 [28.7 MB]
Fetched 28.7 MB in 12s (2,304 kB/s)
Selecting previously unselected package raspberrypi-kernel-headers.
(Reading database ... 106127 files and directories currently installed.)
Preparing to unpack .../raspberrypi-kernel-headers_1%3a1.20221104-1_armhf.deb ...
Unpacking raspberrypi-kernel-headers (1:1.20221104-1) ...
Setting up raspberrypi-kernel-headers (1:1.20221104-1) ...
pi@raspberrypi:/usr/src $ ls
linux-headers-5.15.76+ linux-headers-5.15.76-v7l+
linux-headers-5.15.76-v7+ sense-hat
// 다운로드한 linux-headers 가 있다.
그리고 다운로드한 버전과 시스템에 설치되어 있는 헤더 버전을 일치시켜야 한다.
uname 이란 명령어를 통해서 현재 시스템의 커널 버전을 확인해봤다.
pi@raspberrypi:/usr/src $ uname -r
5.15.61+
다운로드한 버전이 현재 시스템 버전보다 더 최신이라 버전이 맞지 않았다.
* raspberrypi 커널을 받을 때 현재 시스템의 버전을 받으면 좋은데 무조건 최신 버전만 내려받을 수밖에 없다.
이럴 때는 현재 시스템 커널 버전을 다운로드한 것으로 최신화해주면 된다. (아래 명령어 순차 실행)
pi@raspberrypi:/usr/src $ sudo apt update
pi@raspberrypi:/usr/src $ sudo apt upgrade
pi@raspberrypi:/usr/src $ sudo reboot
<실행결과>
pi@raspberrypi:/usr/src $ sudo apt update
Hit:1 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
99 packages can be upgraded. Run 'apt list --upgradable' to see them.
pi@raspberrypi:/usr/src $
pi@raspberrypi:/usr/src $ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
libfuse2
Use 'sudo apt autoremove' to remove it.
The following packages will be upgraded:
agnostics arandr bind9-host bind9-libs bluez bluez-firmware dbus dbus-user-session
dbus-x11 dhcpcd5 ffmpeg firmware-atheros firmware-brcm80211 firmware-libertas
firmware-misc-nonfree firmware-realtek gir1.2-gtk-3.0 gtk-update-icon-cache
isc-dhcp-client isc-dhcp-common libavcodec58 libavdevice58 libavfilter7
libavformat58 libavresample4 libavutil56 libbluetooth3 libc-bin libc-dev-bin
libc-devtools libc-l10n libc6 libc6-dbg libc6-dev libcamera-apps libcamera-tools
libcamera0 libdbus-1-3 libexpat1 libexpat1-dev libgssapi-krb5-2 libgtk-3-0
libgtk-3-common libjavascriptcoregtk-4.0-18 libk5crypto3 libkms++0 libkrb5-3
libkrb5support0 libksba8 libmutter-7-0 libntfs-3g883 libpixman-1-0 libpostproc55
libswresample3 libswscale5 libuv1 libvlc-bin libvlc5 libvlccore9
libwebkit2gtk-4.0-37 libxml2 linux-libc-dev locales lxplug-ejecter
(생략)
재부팅 전에는 완료가 되어도 업그레이드 이전 버전을 유지하고 있다.
pi@raspberrypi:/usr/src $ uname -r
5.15.61+
pi@raspberrypi:/usr/src $ sudo reboot
(재부팅 후)
pi@raspberrypi:~ $ uname -r
5.15.76+
pi@raspberrypi:/usr/src $ ls
linux-headers-5.15.76+ linux-headers-5.15.76-v7l+
linux-headers-5.15.76-v7+ sense-hat
다운로드한 커널 버전과 시스템의 버전이 같다.
'개발 > 환경구축' 카테고리의 다른 글
mock object(모의 객체) 파일 자동 생성 툴 (0) | 2023.09.12 |
---|---|
코드 커버리지 설치 및 사용 방법(VS 2017+OpenCppCoverage) (0) | 2023.08.29 |
TDD : Unit Test 환경 설정(Visual Studio 2017 + gtest) (2) | 2023.03.22 |
TDD : Unit Test 환경 설정(IntelliJ + java + JUnit) (0) | 2023.01.10 |
[C/C++]VSCode + MinGW + makefile 환경 설정 하기 (2) | 2022.12.11 |