linux/yocto

yocto 고정 IP 할당 방법 (systemd-network)

jhinux 2025. 11. 1. 21:37

Yocto systemd-conf 커스텀 네트워크 설정 정리

  1. 문제 상황
    • - systemd-conf_1.0.bb 작성 시 발생한 에러들:
    • - This recipe does not have the LICENSE field set
    • - Unable to get checksum for systemd-conf SRC_URI entry ... file could not be found
    • - the directory ${WORKDIR}/${BP} ... doesn't exist - please set S
    • - Files/directories were installed but not shipped in any package
  1. 원인 분석
  2. LICENSE 누락 → 모든 레시피는 LICENSELIC_FILES_CHKSUM 필요
  3. SRC_URI 파일 경로 문제files/ 디렉토리 구조 불일치
  4. S 변수 문제 → 단순 설정 레시피는 S = "${WORKDIR}"로 지정
  5. 패키징 에러/etc/systemd/networkFILES:${PN}에 포함되지 않음
  1. 해결 방법

(1) 디렉토리 구조

meta-real-time-edge/
└── recipes-core/
└── systemd/
└── systemd-conf/
├── files/
│ ├── 20-eth0.network
│ └── 20-eth1.network
└── systemd-conf_%.bbappend

(2) .bbappend 예제
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

SRC_URI += "file://20-eth0.network"
SRC_URI += "file://20-eth1.network"

LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""

do_install:append() {
install -d ${D}${sysconfdir}/systemd/network
install -m 0644 ${WORKDIR}/20-eth0.network ${D}${sysconfdir}/systemd/network/
install -m 0644 ${WORKDIR}/20-eth1.network ${D}${sysconfdir}/systemd/network/
}

FILES:${PN} += "${sysconfdir}/systemd/network"

(4) .network 파일 예시

20-eth0.network
[Match]
Name=eth0

[Network]
Address=192.168.10.50/24
Gateway=192.168.10.1
DNS=8.8.8.8

20-eth1.network
[Match]
Name=eth1

[Network]
Address=192.168.20.50/24
Gateway=192.168.20.1
DNS=1.1.1.1

(5) 빌드 및 확인 절차

캐시 정리 후 빌드:
bitbake -c clean systemd-conf
bitbake systemd-conf

산출물 확인:
ls tmp/work//systemd-conf/1.0/package/etc/systemd/network/
→ 20-eth0.network, 20-eth1.network 존재 확인

최종 rootfs /etc/systemd/network/에 포함됨

(6) 핵심 요약

• - LICENSE: CLOSED + LIC_FILES_CHKSUM = ""
• - SRC_URI: file://20-eth*.network
• - S: 단순 설정 레시피는 S = "${WORKDIR}" (혹은 생략)
• - FILES:${PN}: /etc/systemd/network 반드시 포함
• - 우선순위: 20- prefix로 기본 50-, 80-보다 먼저 적용

'linux > yocto' 카테고리의 다른 글

linux kernel u-boot audit diable  (0) 2025.11.21
yocto 이미지 고정 방법  (0) 2025.11.03
i.mx93 yocto 진행 요약 정리  (0) 2025.11.01