본문 바로가기
안드로이드

Khadas VIM3L linux kernel 4.19 빌드하기

by ㅋㅋ잠자 2025. 3. 4.
반응형

여러가지 시도 끝에 android 11 빌드를 성공함

https://blog.djjproject.com/836

 

이때 커널 버전을 4.19로 진행하여 부팅을 성공했음.

4.19 커널을 받아 이미지를 직접 생성해보아야함

 

https://android.googlesource.com/kernel/hikey-linaro

$ mkdir kernel-source
$ cd kernel-source/
$ git clone https://android.googlesource.com/kernel/hikey-linaro -b android-amlogic-bmeson-4.19 .
[~/vim3l-a11/device/amlogic/kernel-source]
$ ls
android                            build.config.gki-debug.x86_64     crypto         MAINTAINERS
arch                               build.config.gki_kasan            Documentation  Makefile
block                              build.config.gki_kasan.aarch64    drivers        mm
build.config.aarch64               build.config.gki_kasan.x86_64     firmware       net
build.config.allmodconfig          build.config.gki_kprobes          fs             OWNERS
build.config.allmodconfig.aarch64  build.config.gki_kprobes.aarch64  include        README
build.config.allmodconfig.arm      build.config.gki_kprobes.x86_64   init           samples
build.config.allmodconfig.x86_64   build.config.gki.x86_64           ipc            scripts
build.config.arm                   build.config.x86_64               Kbuild         security
build.config.common                build.config.yukawa.aarch64       Kconfig        sound
build.config.gki                   certs                             kernel         tools
build.config.gki.aarch64           COPYING                           lib            usr
build.config.gki-debug.aarch64     CREDITS                           LICENSES       virt

 

추가 툴체인 clone

$ git clone https://android.googlesource.com/platform/prebuilts/gas/linux-x86 prebuilts/gas/linux-x86

 

환경변수 설정

[~/vim3l-a11]
$ export TOP=$(pwd)

[~/vim3l-a11]
$ echo $TOP
/home/djjproject/vim3l-a11
$ export PATH=$TOP/prebuilts/clang/host/linux-x86/clang-r383902b/bin:$PATH
$ export PATH=$TOP/prebuilts/gas/linux-x86:$PATH
$ export PATH=$TOP/prebuilts/misc/linux-x86/lz4:$PATH

 

빌드 수행 전, 환경변수 설정

$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ export LLVM=1

 

커널 빌드 수행

$ cd device/amlogic/kernel-source/
$ make meson_defconfig
$ make DTC_FLAGS="-@" -j12
#### build completed successfully (05:38 (mm:ss)) ####

 

파일 배치 전에 원본 파일 확인

[~/vim3l-a11/device/amlogic/kernel-source]
$ ls ../yukawa-kernel/4.19/
Image.lz4                      meson-g12b-a311d-khadas-vim3-android.dtb  meson-sm1-khadas-vim3l.dtb
meson-g12a-sei510-android.dtb  meson-g12b-a311d-khadas-vim3.dtb          meson-sm1-sei610-android.dtb
meson-g12a-sei510.dtb          meson-sm1-khadas-vim3l-android.dtb        meson-sm1-sei610.dtb

 

device 소스에서 어느 dtb 사용하는지 확인

[~/vim3l-a11/device/amlogic/yukawa]
$ cat build/tasks/dtimages.mk

# Please keep this list fixed: add new files in the end of the list
DTB_FILES := \
        $(LOCAL_DTB)/meson-g12a-sei510.dtb \
        $(LOCAL_DTB)/meson-sm1-sei610.dtb \
        $(LOCAL_DTB)/meson-sm1-khadas-vim3l.dtb \
        $(LOCAL_DTB)/meson-g12b-a311d-khadas-vim3.dtb

# Please keep this list fixed: add new files in the end of the list
DTBO_FILES := \
        $(LOCAL_DTB)/meson-g12a-sei510-android.dtb \
        $(LOCAL_DTB)/meson-sm1-sei610-android.dtb \
        $(LOCAL_DTB)/meson-sm1-khadas-vim3l-android.dtb \
        $(LOCAL_DTB)/meson-g12b-a311d-khadas-vim3-android.dtb \

위 목록에서 선택을 어떻게 하는거지?

 

meson-sm1-khadas-vim3l-android.dts 는 overlay 파일

s905d3 CPU이기 때문에 코드명은 sm1 이 맞음

위에서 보이는 sei510 은 S905X2 (g12a) / sei610은 S905X3 (sm1)

# kernel-source/arch/arm64/boot/dts/amlogic/meson-sm1-khadas-vim3l-android.dts

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2019 BayLibre SAS. All rights reserved.
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/phy/phy.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>

/ {
  compatible = "khadas,vim3l", "amlogic,sm1";
  model = "Khadas VIM3L";
  fragment@101 {
        target-path = "/";
        __overlay__ {
                reserved-memory {
                        #address-cells = <2>;
                        #size-cells = <2>;
                        ramoops@0x0d000000 {
                                compatible = "ramoops";
                                reg = <0x0 0x0d000000 0x0 0x00100000>;
                                record-size = <0x8000>;
                                console-size = <0x8000>;
                                ftrace-size = <0x0>;
                                pmsg-size = <0x8000>;
                        };
                };

 

u-boot 소스를 확인해봐야 하지만, 아래 cmdline 을 보면

androidboot.dtbo_idx=2

 

아래의 순서대로 overlay 됨을 알 수 있음

meson-sm1-khadas-vim3l.dtb
--> meson-sm1-khadas-vim3l-android.dtb

 

실제로 meson-sm1-khadas-vim3l.dts 파일을 보면

# arch/arm64/boot/dts/amlogic/meson-sm1-khadas-vim3l.dts

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2019 BayLibre, SAS
 * Author: Neil Armstrong <narmstrong@baylibre.com>
 */

/dts-v1/;

#include "meson-sm1.dtsi"
#include "meson-khadas-vim3.dtsi"

/ {
    compatible = "khadas,vim3l", "amlogic,sm1";
    model = "Khadas VIM3L";

    vddcpu: regulator-vddcpu {
        /*
         * Silergy SY8030DEC Regulator.
         */
        compatible = "pwm-regulator";

        regulator-name = "VDDCPU";
        regulator-min-microvolt = <690000>;
        regulator-max-microvolt = <1050000>;

        vin-supply = <&vsys_3v3>;

        pwms = <&pwm_AO_cd 1 1250 0>;
        pwm-dutycycle-range = <100 0>;

        regulator-boot-on;
        regulator-always-on;
    };
};

&cpu0 {
    cpu-supply = <&vddcpu>;
    operating-points-v2 = <&cpu_opp_table>;
    clocks = <&clkc CLKID_CPU_CLK>;
    clock-latency = <50000>;
};

 

그러면 결국에 복사해야할 파일은 3개임

Image.lz4
meson-sm1-khadas-vim3l.dtb
meson-sm1-khadas-vim3l-android.dtb

 

dtb 파일 복사

[~/vim3l-a11/device/amlogic/kernel-source]
$ cp arch/arm64/boot/dts/amlogic/ meson-sm1-khadas-vim3l.dtb ../yukawa-kernel/4.19/ meson-sm1-khadas-vim3l.dtb
$ cp arch/arm64/boot/dts/amlogic/meson-sm1-khadas-vim3l-android.dtb ../yukawa-kernel/4.19/meson-sm1-khadas-vim3l-android.dtb

 

커널이미지 압축 및 복사

[~/vim3l-a11/device/amlogic/kernel-source]
$ lz4c -f arch/arm64/boot/Image arch/arm64/boot/Image.lz4
Compressed 29659648 bytes into 20010826 bytes ==> 67.47%

$ cp arch/arm64/boot/Image.lz4 ../yukawa-kernel/4.19/Image.lz4

 

boot.img / dtbo.img re-generate

[~/vim3l-a11]
$ rm out/target/product/yukawa/boot.img out/target/product/yukawa/dtbo-unsigned.img
[~/vim3l-a11]
$ make TARGET_VIM3L=true TARGET_KERNEL_USE=4.19 bootimage dtboimage -j12

 

커널 이미지 write / 보드를 USB 부트 모드로 놓고 진행

[~/vim3l-a11/out/target/product/yukawa]
$ sudo boot-g12.py ../../../../device/amlogic/yukawa/bootloader/u-boot_kvim3l_noab.bin
Firmware Version :
ROM: 3.2 Stage: 0.0
Need Password: 0 Password OK: 0
Writing ../../../../device/amlogic/yukawa/bootloader/u-boot_kvim3l_noab.bin at 0xfffa0000...
[DONE]
Running at 0xfffa0000...
[DONE]
AMLC dataSize=16384, offset=65536, seq=0...
[DONE]
AMLC dataSize=49152, offset=393216, seq=1...
[DONE]
AMLC dataSize=16384, offset=229376, seq=2...
[DONE]
AMLC dataSize=49152, offset=245760, seq=3...
[DONE]
AMLC dataSize=16384, offset=65536, seq=4...
[DONE]
AMLC dataSize=49152, offset=393216, seq=5...
[DONE]
AMLC dataSize=16384, offset=229376, seq=6...
[DONE]
AMLC dataSize=49152, offset=245760, seq=7...
[DONE]
AMLC dataSize=49152, offset=294912, seq=8...
[DONE]
AMLC dataSize=16384, offset=65536, seq=9...
[DONE]
AMLC dataSize=1115504, offset=81920, seq=10...
[DONE]
[BL2 END]
[~/vim3l-a11/out/target/product/yukawa]
$ sudo fastboot flash boot boot.img
target reported max download size of 117440512 bytes
sending 'boot' (15806 KB)...
OKAY [  4.034s]
writing 'boot'...
OKAY [  1.506s]
finished. total time: 5.541s

[~/vim3l-a11/out/target/product/yukawa]
$ sudo fastboot flash dtbo dtbo-unsigned.img
target reported max download size of 117440512 bytes
sending 'dtbo' (9 KB)...
OKAY [  0.016s]
writing 'dtbo'...
OKAY [  0.011s]
finished. total time: 0.026s

[~/vim3l-a11/out/target/product/yukawa]
$ sudo fastboot reboot
rebooting...

 

커널 버전 확인 / 빌드 시간이 바뀐걸 확인 가능

vim3l:/ # uname -a
Linux localhost 4.19.269-g9a555badda2a #1 SMP PREEMPT Tue Mar 4 12:44:12 UTC 2025 aarch64

반응형

댓글