Kernel Image 빌드 Issue (Kernel Panic)

SMJ·2025년 10월 23일

BSP development

목록 보기
11/17

목적

현재 부팅 되고 있는 전체 이미지에 kernel zImage, Device Tree Binary 파일을 보드 내 특정 RAM sector에 올려 그 부분만 Image를 바꾸어 실행하여 kernel 수정사항을 즉각적으로 확인할 수 있게 한다.


issue 1

  • setting
    • SD 카드 Boot (core-image-minimal로 Boot 설정 [Yocto Project로 빌드])
    • MA35D1_linux git clone 후 makefile로 빌드
    • menuconfig로 수정 (device drivers → graphic support → BootUp 체크)
    • ma35d1-som-256m.dts 소스파일 수정 (Graphic 관련 compatible = ‘okay’ 설정)
    • 새롭게 빌드된 zImage와 .dtb 파일 넣기
  • Command
    U-Boot > setenv ipaddr <EVB's IP>
    U-Boot > setenv serverip <Ubuntu IP>
    U-Boot > saveenv
    
    # /srv/tftp로 이미지파일을 옮겨놔야 인식
    U-Boot > tftp 85000000 ma35d1-som-256m.dtb
    U-Boot > tftp 82000000 Image.gz
    
    #0x82000000은 임시 load_memory
    U-Boot > unzip 82000000 80080000
    U-Boot > booti 80080000 85000000
  • Kernel Panic Issue
    [0.598015] Kernel panic - not syncing: synchronous external abort: Fatal exception
    [0.605642] SMP: stopping secondary CPUs
    [0.609550] Rebooting in 1 seconds..
  • Solution
    • 잘못된 메모리 접근 (가능성 없음)
    • 하드웨어 결함 (이전에 잘 부팅되는 setting이 있었으므로 제외)
    • 디바이스트리/커널 설정 문제 (가장 유력 → 맞지 않는 DTB 파일을 같이 부팅했을 가능성)
    • 드라이버 버그 또는 잘못된 초기화

issue 2

  • setting
    • eMMC Boot (qt 까지 있는 완전체 파일)
    • Yocto Project 내에서 linux_kernel bitbake 후 Image 생성
    • bitbake menuconfig로 수정 (device drivers → graphic support → BootUp 체크)
    • menuconfig로 수정된 심볼링 링크 파일 이미지 사용
  • Command
    U-Boot > setenv ipaddr <EVB's IP>
    U-Boot > setenv serverip <Ubuntu IP>
    U-Boot > saveenv
    
    # /srv/tftp로 이미지파일을 옮겨놔야 인식
    U-Boot > tftp 85000000 ma35d1-som-256m.dtb
    U-Boot > tftp 80080000 Image-numaker-som-ma35d16a81.bin
    
    # 압축파일이 아니므로 바로 부팅 가능
    U-Boot > booti 80080000 85000000
  • Kernel Panic Issue
    [0.598015] Kernel panic - not syncing: synchronous external abort: Fatal exception
  • Solution
    • 디바이스 트리 / 커널 설정 문제 (Yocto로 빌드 했어서 가능성이 낮다고 생각)
    • 심볼릭 링크 파일 tftp 전송문제 (유력)
      • menuconfig로 수정한 이미지를 쓰지 않고 심볼링 링크로 생성된 파일을 그대로 씀
      • TFTP는 매우 단순한 프로토콜 이므로 실제 파일만 전송가능 하고 링크를 따라가지 못함

issue 3

  • setting
    • eMMC Boot (qt 까지 있는 완전체 파일)
    • Yocto Project 내에서 linux_kernel bitbake 후 Image 생성
    • bitbake menuconfig로 수정 (device drivers → graphic support → BootUp 체크)
    • 심볼릭 링크 이미지 파일 사용하지 않고 그대로 생성
  • Command
    U-Boot > setenv ipaddr <EVB's IP>
    U-Boot > setenv serverip <Ubuntu IP>
    U-Boot > saveenv
    
    # /srv/tftp로 이미지파일을 옮겨놔야 인식
    U-Boot > tftp 85000000 ma35d1-som-256m--5.10.140-r0-numaker-som-ma35d16a81-20250911055909.dtb
    U-Boot > tftp 80080000 Image-5.10.140-r0-numaker-som-ma35d16a81-20250911055909.bin
    
    # 압축파일이 아니므로 바로 부팅 가능
    U-Boot > booti 80080000 85000000
  • Kernel Panic Issue
    • 이전과는 다른 kernel panic이 나옴
    • 커널이 ubi0:rootFs 루트 파일 시스템을 마운트하려고 했으나 실패 : -19 → 장치 존재하지 않음
    • 부팅 매개변수 ubi.mtd=4 root=ubi0:rootFs에 따라 MTD 파티션 4번 (nand-rootFs)을 UBI 장치 0으로 attach함
    • 성공적으로 스캔되었으나 유효한 파일시스템이 아니었음
    [3.318694] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0): error -19
    [3.326647] Please append a correct "root=" boot option; here are the available partitions:
    [3.511061] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
  • analyze
	U-Boot > printenv bootargs
	bootargs=noinitrd ubi.mtd=4 root=ubi0:rootfs rootfstype=ubifs rw rootwait=1 		console=ttyS0,115200n8 rdinit=/sbin/init mem=248M
    
	U-Boot > printenv boot_targets
	boot_targets=mmc0 mmc1 ubifs0 legacy_mmc0 nand0 mtd0
    
	U-Boot> printenv bootcmd
	bootcmd=run distro_bootcmd
`bootargs` : 커널에 전달될 부팅 매개변수 → NAND 플래시 부팅을 가리키는 설정으로 고정되어 있음`root=ubi0:rootfs`
`boot_targets` = mmc0 mmc1 → U-Boot가 자동으로 부팅을 시도하는 저장 장치 목록
자동 부팅 시 : U-Boot는 `boot_targets` 변수에 정의된 순서대로 부팅을 시도 NAND는 1순위가 아님
수동 부팅 시 : `booti` 명령어를 수동으로 실행하면 `boot_targets`를 무시하고 현재 `bootargs` 변수에 저장된 값(NAND 부팅 설정)을 커널에 전달함
`booti` 명령어를 입력하는 순간, `boot_targets`를 따르지 않고 자동 부팅 스크립트 중단 → 메모리에 올려놓은 커널과 현재 U-Boot에 로드된 bootargs 변수 값만을 사용해 부팅을 시도
  • Solution

    • bootargs 환경변수 값을 변경 or 부팅스크립트(bootcmd) 변경
    • bootargs 환경변수 값을 eMMC 부팅으로 설정
      U-Boot > setenv bootargs 'root=/dev/mmcblk1p1 rootfstype=ext4 rw rootwait console=ttyS0,115200n8 rdinit=/sbin/init mem=248M'
      U-Boot > saveenv
    • 부팅스크립트 (bootcmd) 변경하기
      U-Boot > setenv boot_targets 'mmc1 mmc0 ubifs0 legacy_mmc0 nand0 mtd0'
      U-Boot > saveenv
  • Result

    • bootargs 환경변수 값을 eMMC 부팅으로 설정
    • 로그분석
           [3.110220] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
           [3.113022]   #0: ma35d1_IIS
           [3.121582] cfg80211: failed to load regulatory.db
           
           [4.490191] systemd[1]: psplash-start.service: Failed with result 'exit-code'.
           [4.514651] systemd[1]: Failed to start Start psplash boot splash screen.
           [FAILED] Failed to start Start psplash boot splash screen.
           See 'systemctl status psplash-start.service' for details.
           [4.542086] systemd[1]: Dependency failed for Start psplash-systemd progress communication helper.
           [DEPEND] Dependency failed for Star…progress communication helper.
           [4.567766] systemd[1]: psplash-systemd.service: Job psplash-systemd.service/start failed with result 'dependency'.
           
           [6.164707] viv-dc 40260000.display: Failed to read bpp, pixel_fmt and buswidth from DT
           
           [6.322847] viv-dc: probe of 40260000.display failed with error -22
           [FAILED] Failed to start Start psplash boot splash screen.
           See 'systemctl status psplash-start.service' for details.
           [DEPEND] Dependency failed for Star…progress communication helper
           ```
        
           
    • 부팅은 성공 했으나 디스플레이 오류로 인해 원하던 화면이 나오지않음
    • psplash 스플래시 화면 서비스 failed : status=255/EXCEPTION
    • 디스플레이 컨트롤러 드라이버 초기화 실패 viv-dc → 디바이스 트리 관련 설정 누락
    • 무선 규제 데이터 베이스 로드 실패 cfg80211 → wi-fi 드라이버 구성요소
  • conclusion

    • Kernel-Panic의 경우 정말 많은 변수들이 있음
    • 오류메시지, call trace, 에러코드 들로 분석해서 원인을 빠르게 좁혀야함
    • 로그 분석을 하면서 생각하는 해결책들을 세우고 많은 경우의 수들로 셋팅을 바꾸어서 해봐야 함
    • 이슈가 생기면 이를 기록하는 습관을 가질 것
profile
Embedded Junior Developer

0개의 댓글