使用的是萬象奧科維的RK3506G-EVM開發板

vanxoak@vanxoak:/work/rk3506_linux6.1_v1.2.0$ tree -L 1
.
├── app														# 存放上層應用 app,主要是 qcamera/qfm/qplayer/settings 等一些應用程序
├── buildroot												# buildroot文件系統目錄
├── build.sh -> device/rockchip/common/scripts/build.sh		# 編譯腳本
├── common -> device/rockchip/common						
├── device													# 存放各芯片板級配置和Parameter文件,以及一些編譯與打包固件的腳本和預備文件
├── docs													# rockchip 參考文檔 存放芯片模塊開發指導文檔、平台支持列表、芯片平台相關文檔、Linux開發指南等
├── external												# 存放第三方相關倉庫,包括音頻、視頻、網絡、recovery 等
├── hal														# HAL目錄,存放HAL源碼以及Project工程
├── kernel -> kernel-6.1									 
├── kernel-6.1												# 存放 kernel 6.1的目錄
├── Makefile -> device/rockchip/common/Makefile				# makefile 編譯支持文件
├── prebuilts												# 存放交叉編譯工具鏈
├── README.md -> device/rockchip/common/README.md			# README
├── rkbin													# 存放 Rockchip 相關的 Binary 和工具
├── rkflash.sh -> device/rockchip/common/scripts/rkflash.sh						
├── rtos													# RTOS對應目錄
├── tools													# 存放 Linux 和 Windows 操作系統環境下常用工具
├── u-boot													# 存放u-boot源碼
├── vanxoak													# 存放針對項目修改的補丁文件
└── yocto													# yocto目錄

SDK解壓後會得到以上文件夾,接下來我們對每一個文件夾以及子文件進行逐項的學習
首先注意到commen,build.sh,kernel等後面帶有->是軟連接,指向後續文件目錄(之前一直沒注意到,我還尋思為什麼這麼多重複文件。。。)

lipthon@Lipthon:~/rk3506/rk3506_linux6.1_v1.2.0/app$ tree -d
.
├── lvgl_demo
│   ├── amp_monitor
│   │   └── overlay
│   ├── cJSON
│   ├── common
│   ├── flexbus
│   │   └── overlay
│   ├── gallery
│   │   ├── anims
│   │   └── pics
│   ├── lv_demo
│   ├── lvgl8
│   ├── lvgl9
│   ├── motor_demo
│   │   ├── deprecated
│   │   │   └── res
│   │   └── resource
│   ├── rk_demo
│   │   ├── asr
│   │   │   └── pcm
│   │   ├── audio_algorithm
│   │   │   ├── configs
│   │   │   ├── include
│   │   │   └── lib
│   │   ├── furniture_control
│   │   ├── home
│   │   ├── include
│   │   ├── intercom_homepage
│   │   │   ├── intercom_call
│   │   │   └── video_monitor
│   │   ├── layout
│   │   ├── resource
│   │   ├── rockit
│   │   ├── setting
│   │   ├── smart_home
│   │   └── wifibt
│   ├── rk_demo_test
│   │   ├── asr
│   │   │   ├── lib
│   │   │   └── pcm
│   │   ├── board_test
│   │   ├── home
│   │   ├── include
│   │   ├── layout
│   │   ├── resource
│   │   ├── rockit
│   │   ├── setting
│   │   └── wifibt
│   ├── sys
│   └── tools
└── rkadk
    ├── cmake
    ├── docs
    ├── examples
    │   └── common
    │       ├── isp
    │       │   └── rv1103b
    │       └── mp3_header
    ├── include
    ├── inicfg
    │   ├── rk3576
    │   ├── rv1106_1103
    │   └── rv1126_1109
    ├── src
    │   ├── aov
    │   ├── audio
    │   │   ├── decoder
    │   │   └── encoder
    │   ├── common
    │   ├── demuxer
    │   ├── display
    │   ├── live
    │   │   ├── rtmp
    │   │   └── rtsp
    │   ├── muxer
    │   ├── osd
    │   ├── param
    │   ├── photo
    │   ├── player
    │   ├── record
    │   ├── storage
    │   ├── stream
    │   ├── third-party
    │   │   ├── cjson
    │   │   └── iniparser
    │   └── ui
    └── version

app文件夾中主要存放的為官方給出的應用層開發中間件,向上提供簡單易用的 API,向下對接底層驅動和硬件,

本文件夾提供了LVGL,RKADK兩個實例,LVGL常用於做屏幕顯示界面設計,這個大家應該都熟悉,

RKADK則提供了大量的音視頻處理的API,可以用於音頻解碼,視頻錄製等

慢慢學Linux驅動開發,第八篇,LDD3中第三章scull註釋詳解_linux

buildroot文件夾存放buildroot源碼,用於固件的編譯構建,不做過多解釋,會用圖形化界面就行

慢慢學Linux驅動開發,第八篇,LDD3中第三章scull註釋詳解_固件_02

common文件夾指向device/rockchip/common

lipthon@Lipthon:~/rk3506/rk3506_linux6.1_v1.2.0/common$ tree -d
.
├── build-hooks
├── configs
│   └── post
├── data
├── extra-parts
│   ├── dtbo
│   ├── oem
│   │   ├── cvr
│   │   │   ├── cvr_res
│   │   │   │   ├── font
│   │   │   │   ├── sound
│   │   │   │   ├── string
│   │   │   │   └── ui_1280x720
│   │   │   └── etc
│   │   │       └── rkadk
│   │   │           ├── 5M
│   │   │           └── 8M
│   │   ├── facial_gate
│   │   ├── ipc
│   │   ├── normal
│   │   ├── nvr
│   │   ├── sample
│   │   └── uvcc
│   └── userdata
│       ├── normal
│       └── sl
├── fonts
├── kconfig
│   ├── lxdialog
│   └── patches
├── linux-kbuild
│   ├── aarch64
│   │   ├── linux-kbuild-4.19
│   │   │   ├── scripts
│   │   │   │   ├── basic
│   │   │   │   ├── genksyms
│   │   │   │   ├── kconfig
│   │   │   │   └── mod
│   │   │   └── tools
│   │   │       └── objtool
│   │   ├── linux-kbuild-4.4
│   │   │   └── scripts
│   │   │       ├── basic
│   │   │       ├── genksyms
│   │   │       ├── kconfig
│   │   │       └── mod
│   │   ├── linux-kbuild-5.10
│   │   │   ├── scripts
│   │   │   │   ├── basic
│   │   │   │   ├── genksyms
│   │   │   │   ├── kconfig
│   │   │   │   └── mod
│   │   │   └── tools
│   │   │       └── objtool
│   │   └── linux-kbuild-6.1
│   │       ├── scripts
│   │       │   ├── basic
│   │       │   ├── genksyms
│   │       │   ├── kconfig
│   │       │   └── mod
│   │       └── tools
│   │           └── objtool
│   └── armhf
│       ├── linux-kbuild-4.19
│       │   ├── scripts
│       │   │   ├── basic
│       │   │   ├── genksyms
│       │   │   ├── kconfig
│       │   │   └── mod
│       │   └── tools
│       │       └── objtool
│       ├── linux-kbuild-4.4
│       │   └── scripts
│       │       ├── basic
│       │       ├── genksyms
│       │       ├── kconfig
│       │       └── mod
│       ├── linux-kbuild-5.10
│       │   ├── scripts
│       │   │   ├── basic
│       │   │   ├── genksyms
│       │   │   ├── kconfig
│       │   │   └── mod
│       │   └── tools
│       │       └── objtool
│       └── linux-kbuild-6.1
│           ├── scripts
│           │   ├── basic
│           │   ├── genksyms
│           │   ├── kconfig
│           │   └── mod
│           └── tools
│               └── objtool
├── overlays
│   ├── buildroot
│   ├── debian
│   ├── recovery
│   ├── rootfs
│   │   ├── bootanim
│   │   │   └── etc
│   │   │       └── bootanim.d
│   │   ├── chromium
│   │   ├── default
│   │   ├── fonts -> ../../fonts/
│   │   ├── frecon
│   │   │   ├── etc
│   │   │   │   └── frecon
│   │   │   │       └── term-switch.d
│   │   │   └── usr
│   │   │       └── bin
│   │   ├── fstrim
│   │   ├── generate-logs
│   │   │   ├── etc
│   │   │   │   └── generate_logs.d
│   │   │   └── usr
│   │   │       └── bin
│   │   ├── input-event-daemon
│   │   │   ├── etc
│   │   │   │   └── input-event-daemon.conf.d
│   │   │   └── usr
│   │   │       └── bin
│   │   ├── irqbalance
│   │   │   ├── etc
│   │   │   │   └── irqbalance.d
│   │   │   └── usr
│   │   │       ├── sbin
│   │   │       └── share
│   │   │           └── man
│   │   │               └── man1
│   │   ├── tools -> ../../tools/
│   │   └── usb-gadget
│   └── yocto
│       ├── pulseaudio
│       │   └── etc
│       │       ├── pulse
│       │       └── rcS.d
│       └── weston
│           ├── etc
│           │   ├── default
│           │   ├── profile.d
│           │   └── xdg
│           │       └── weston
│           │           └── weston.ini.d
│           └── usr
│               └── share
│                   ├── backgrounds
│                   └── icons
├── post-hooks
├── scripts
├── tests
│   └── debian
│       ├── bookworm
│       │   ├── aarch64
│       │   └── armhf
│       ├── bullseye
│       │   ├── aarch64
│       │   └── armhf
│       └── buster
│           ├── aarch64
│           └── armhf
└── tools
    ├── aarch64
    ├── armhf
    └── x86_64

首先我們來看build.sh文件,該文件幫我們完成了環境的配置,聲明瞭調用的配置文件,輸出文件位置,我們只需要簡單調用該腳本就可以輕鬆完成整個系統的構建

慢慢學Linux驅動開發,第八篇,LDD3中第三章scull註釋詳解_固件_03


除了build.sh腳本,scripts文件夾還提供了其他的腳本

慢慢學Linux驅動開發,第八篇,LDD3中第三章scull註釋詳解_linux_04

kconfig文件,buildroot根據kconfig提供的配置生成圖形化界面,給出所有選項類似於菜單,然後我經過圖形化配置之後生成.config文件來進行編譯我的固件,也就是點菜

device文件夾,存放各芯片板級配置和Parameter文件,以及一些編譯與打包固件的腳本和預備文件

lipthon@Lipthon:~/rk3506/rk3506_linux6.1_v1.2.0/device/rockchip$ ls -a -l
total 24
drwxr-xr-x  5 lipthon lipthon 4096 Nov 13 22:14 .
drwxr-xr-x  3 lipthon lipthon 4096 Oct 12  2024 ..
lrwxrwxrwx  1 lipthon lipthon   13 Nov 13 14:49 .chip -> .chips/rk3506
drwxr-xr-x  3 lipthon lipthon 4096 Oct 12  2024 .chips
drwxr-xr-x  2 lipthon lipthon 4096 Nov  4 13:36 .git
-rw-r--r--  1 lipthon lipthon   24 Oct 12  2024 .gitignore
drwxr-xr-x 14 lipthon lipthon 4096 Jun  4 16:59 common
lrwxrwxrwx  1 lipthon lipthon   13 Nov 13 22:14 rk3506 -> .chips/rk3506

.chip,rk3506同時都指向.chips下的rk3506文件夾(到底為什麼要在這裏面放一隻蛋蛋下巴的大兔子啊!!!油餅啊!!!)

慢慢學Linux驅動開發,第八篇,LDD3中第三章scull註釋詳解_linux_05


慢慢學Linux驅動開發,第八篇,LDD3中第三章scull註釋詳解_linux_06


rk3506_linux6.1_v1.2.0/device/rockchip/rk3506/rockchip_rk3506_evm_nand_defconfig 是我們使用的默認配置文件