# BSP Linux 内核编译
由于主线内核暂不支持摄像头控制器,所以需要使用BSP内核来使能摄像头驱动。
下面讲解编译启动BSP内核的方法。
## BSP源码下载编译
BSP源码在网盘中的camdriod和lichee里。
camdriod是camdriod代码,lichee是linux代码和打包相关脚本。
下载解压这两个文件到工作目录下。
在camdriod目录下使用下述命令进行camdriod编译,其中的选项都选第一个即可。
~~~
source build/envsetup.sh
lunch
mklichee
extract-bsp
make -j8
pack
~~~
执行过程中会生成内核文件:
~~~
Image Name: Linux-3.4.39
Created: Tue Sep 5 06:55:03 2017
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2275400 Bytes = 2222.07 kB = 2.17 MB
Load Address: 40008000
Entry Point: 40008000
Image arch/arm/boot/uImage is ready
'arch/arm/boot/Image' -> 'output/bImage'
'arch/arm/boot/uImage' -> 'output/uImage'
'arch/arm/boot/zImage' -> 'output/zImage'
Building modules
compile Kernel successful
~~~
从主线uboot启动内核,一般使用uImage。
## BSP内核配置
BSP内核源码在lichee/linux-3.4下。
一般来说是通过make ARCH=arm menuconfig来配置内核(配置文件为.config),但是camdriod的构建系统中,会使用
`camdriod/device/softwinner/tiger-cdr/custom/dualCam/lichee/sun8iw8p1smp_tiger_cdr_defconfig`
来覆盖该配置,所以需要在menuconfig里配置好内核后,覆盖该配置文件。
使能摄像头需要修改的一些内核配置:
使能USB摄像头驱动:
~~~
-> Device Drivers
x -> Multimedia support (MEDIA_SUPPORT [=y])
x -> Video capture adapters (VIDEO_CAPTURE_DRIVERS [=y])
x -> V4L USB devices (V4L_USB_DRIVERS [=y])
x -><M> USB Video Class (UVC) CONFIG_USB_VIDEO_CLASS
~~~
使能DVP/MIPI摄像头
~~~
-> Device Drivers
x -> Multimedia support (MEDIA_SUPPORT [=y])
x -> Video capture adapters (VIDEO_CAPTURE_DRIVERS [=y])
x -> V4L platform devices (V4L_PLATFORM_DRIVERS [=y])
x -> SoC camera support (SOC_CAMERA [=y])
x x <M> ov2640 camera support
x x <M> ov5647 camera support
x x <M> sunxi video front end (camera and etc)driver
x x <M> v4l2 driver for SUNXI
<*> sunxi video encoder and decoder support
~~~
由于camdriod原始的内核配置是为了在spi nor flash上运行而配置的,没有ext4支持,所以需要额外添加ext4支持:
~~~
<*> The Extended 4 (ext4) filesystem
x x [*] Use ext4 for ext2/ext3 file systems (NEW)
x x [*] Ext4 extended attributes (NEW)
x x [ ] Ext4 POSIX Access Control Lists (NEW)
x x [ ] Ext4 Security Labels (NEW)
x x [ ] EXT4 debugging support (NEW)
x x [ ] JBD2 (ext4) debugging support (NEW)
~~~
另外还要加上CONFIG_LBDAF(大文件支持,否则无法挂载文件系统)
~~~
-> Enable the block layer (BLOCK [=y])
[*] Support for large (2TB+) block devices and files
~~~
再加上CGROUPS支持:
~~~
-> General setup
[*] Control Group support --->
~~~
如果在文件系统(如debian)中使用了SWAP等特性,则还需要在内核中开启SWAP。
debian下还需要开启 FHANDLE 特性,否则会出现以下错误
~~~
A start job is running for dev-ttyS0.device
timeout
~~~
如果需要使用wifi功能,则还需要勾选RTL8723BS的支持(注意需要选择模块方式),和AW_RF_PM选项。
以及下节所说的fex修改。
## uboot启动BSP内核
使用主线uboot启动BSP内核,需要修改下启动脚本,放入BSP内核需要的script.bin配置文件(相当于主线linux的dtb)
修改boot.cmd:
~~~
setenv bootargs console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw
setenv bootm_boot_mode sec
setenv machid 1029
load mmc 0:1 0x41000000 uImage
load mmc 0:1 0x41d00000 script.bin
bootm 0x41000000
~~~
重新生成boot.scr:
`mkimage -C none -A arm -T script -d boot.cmd boot.scr`
将boot.scr放入第一分区。
再配置生成script.bin.
复制一份lichee/tools/pack/chips/sun8iw8p1/configs/tiger-cdr/sys_config.fex
修改其中的摄像头配置:
首先修改SD卡检测策略,设置为不检测,默认插入
`sdc_detmode=3`
使能RTL8723bs无线网卡的话,需要使能mmc1,也设置为不检测sd卡。
在设置摄像头型号,csi0是mipi摄像头,csi1是dvp摄像头。
这里默认以mipi摄像头为ov5647, dvp摄像头为ov2640 为例。
~~~
;--------------------------------------------------------------------------------
;vip (video input port) configuration
;vip_used: 0:disable 1:enable
;vip_mode: 0:sample one interface to one buffer 1:sample two interface to one buffer
;vip_dev_qty: The quantity of devices linked to capture bus
;
;vip_define_sensor_list: If you want use sensor detect function, please set vip_define_sensor_list = 1, and
; verify that file /system/etc/hawkview/sensor_list_cfg.ini is properly configured!
;
;vip_dev(x)_pos: sensor position, "rear" or "front", if vip_define_sensor_list = 1,vip_dev(x)_pos must be configured!
;
;vip_dev(x)_isp_used 0:not use isp 1:use isp
;vip_dev(x)_fmt: 0:yuv 1:bayer raw rgb
;vip_dev(x)_stby_mode: 0:not shut down power at standby 1:shut down power at standby
;vip_dev(x)_vflip: flip in vertical direction 0:disable 1:enable
;vip_dev(x)_hflip: flip in horizontal direction 0:disable 1:enable
;vip_dev(x)_iovdd: camera module io power handle string, pmu power supply
;vip_dev(x)_iovdd_vol: camera module io power voltage, pmu power supply
;vip_dev(x)_avdd: camera module analog power handle string, pmu power supply
;vip_dev(x)_avdd_vol: camera module analog power voltage, pmu power supply
;vip_dev(x)_dvdd: camera module core power handle string, pmu power supply
;vip_dev(x)_dvdd_vol: camera module core power voltage, pmu power supply
;vip_dev(x)_afvdd: camera module vcm power handle string, pmu power supply
;vip_dev(x)_afvdd_vol: camera module vcm power voltage, pmu power supply
;x indicates the index of the devices which are linked to the same capture bus
;fill voltage in uV, e.g. iovdd = 2.8V, vip_devx_iovdd_vol = 2800000
;fill handle string as below:
;axp22_eldo3
;axp22_dldo4
;axp22_eldo2
;fill handle string "" when not using any pmu power supply
;--------------------------------------------------------------------------------
[csi0]
vip_used = 1
vip_mode = 0
vip_dev_qty = 1
vip_define_sensor_list = 0
vip_csi_mck = port:PE20<3><default><default><default>
vip_csi_sck = port:PE21<2><default><default><default>
vip_csi_sda = port:PE22<2><default><default><default>
vip_dev0_mname = "h22_mipi"
vip_dev0_pos = "rear"
vip_dev0_lane = 1
vip_dev0_twi_id = 0
vip_dev0_twi_addr = 0x60
vip_dev0_isp_used = 1
vip_dev0_fmt = 1
vip_dev0_stby_mode = 0
vip_dev0_vflip = 0
vip_dev0_hflip = 0
vip_dev0_iovdd = ""
vip_dev0_iovdd_vol = 3000000
vip_dev0_avdd = "csi-avdd"
vip_dev0_avdd_vol = 3000000
vip_dev0_dvdd = "csi-dvdd"
vip_dev0_dvdd_vol = 3000000
vip_dev0_afvdd = ""
vip_dev0_afvdd_vol = 2800000
vip_dev0_power_en =
vip_dev0_reset = port:PG00<1><default><default><default>
vip_dev0_pwdn = port:PG01<1><default><default><default>
vip_dev0_flash_en =
vip_dev0_flash_mode =
vip_dev0_af_pwdn =
vip_dev0_act_used = 0
vip_dev0_act_name = "dw9714_act"
vip_dev0_act_slave = 0x18
vip_dev1_mname = ""
vip_dev1_pos = "front"
vip_dev1_lane = 1
vip_dev1_twi_id = 0
vip_dev1_twi_addr =
vip_dev1_isp_used = 0
vip_dev1_fmt = 1
vip_dev1_stby_mode = 0
vip_dev1_vflip = 0
vip_dev1_hflip = 0
vip_dev1_iovdd = ""
vip_dev1_iovdd_vol = 2800000
vip_dev1_avdd = ""
vip_dev1_avdd_vol = 2800000
vip_dev1_dvdd = ""
vip_dev1_dvdd_vol = 1500000
vip_dev1_afvdd = ""
vip_dev1_afvdd_vol = 2800000
vip_dev1_power_en =
vip_dev1_reset =
vip_dev1_pwdn =
vip_dev1_flash_en =
;fill handle string as below:
;axp22_eldo3
;axp22_dldo4
;axp22_eldo2
;fill handle string "" when not using any pmu power supply
;--------------------------------------------------------------------------------
[csi0]
vip_used = 1
vip_mode = 0
vip_dev_qty = 1
vip_define_sensor_list = 0
vip_csi_mck = port:PE20<3><default><default><default>
vip_csi_sck = port:PE21<2><default><default><default>
vip_csi_sda = port:PE22<2><default><default><default>
vip_dev0_mname = "h22_mipi"
vip_dev0_pos = "rear"
vip_dev0_lane = 1
vip_dev0_twi_id = 0
vip_dev0_twi_addr = 0x60
vip_dev0_isp_used = 1
vip_dev0_fmt = 1
vip_dev0_stby_mode = 0
vip_dev0_vflip = 0
vip_dev0_hflip = 0
vip_dev0_iovdd = ""
vip_dev0_iovdd_vol = 3000000
vip_dev0_avdd = "csi-avdd"
vip_dev0_avdd_vol = 3000000
vip_dev0_dvdd = "csi-dvdd"
vip_dev0_dvdd_vol = 3000000
vip_dev0_afvdd = ""
vip_dev0_afvdd_vol = 2800000
vip_dev0_power_en =
vip_dev0_reset = port:PG00<1><default><default><default>
vip_dev0_pwdn = port:PG01<1><default><default><default>
vip_dev0_flash_en =
vip_dev0_flash_mode =
vip_dev0_af_pwdn =
vip_dev0_act_used = 0
vip_dev0_act_name = "dw9714_act"
vip_dev0_act_slave = 0x18
vip_dev1_mname = ""
vip_dev1_pos = "front"
vip_dev1_lane = 1
vip_dev1_twi_id = 0
vip_dev1_twi_addr =
vip_dev1_isp_used = 0
vip_dev1_fmt = 1
vip_dev1_stby_mode = 0
vip_dev1_vflip = 0
vip_dev1_hflip = 0
vip_dev1_iovdd = ""
vip_dev1_iovdd_vol = 2800000
vip_dev1_avdd = ""
vip_dev1_avdd_vol = 2800000
vip_dev1_dvdd = ""
vip_dev1_dvdd_vol = 1500000
vip_dev1_afvdd = ""
vip_dev1_afvdd_vol = 2800000
vip_dev1_power_en =
vip_dev1_reset =
vip_dev1_pwdn =
vip_dev1_flash_en =
vip_dev1_flash_mode =
vip_dev1_af_pwdn =
[csi1]
vip_used = 0
vip_mode = 0
vip_dev_qty = 1
vip_define_sensor_list = 0
vip_csi_pck = port:PE00<2><default><default><default>
vip_csi_mck = port:PE01<2><default><default><default>
vip_csi_hsync = port:PE02<2><default><default><default>
vip_csi_vsync = port:PE03<2><default><default><default>
vip_csi_d0 = port:PE04<2><default><default><default>
vip_csi_d1 = port:PE05<2><default><default><default>
vip_csi_d2 = port:PE06<2><default><default><default>
vip_csi_d3 = port:PE07<2><default><default><default>
vip_csi_d4 = port:PE08<2><default><default><default>
vip_csi_d5 = port:PE09<2><default><default><default>
vip_csi_d6 = port:PE10<2><default><default><default>
vip_csi_d7 = port:PE11<2><default><default><default>
vip_csi_d8 = port:PE12<2><default><default><default>
;vip_csi_d9 = port:PE13<2><default><default><default>
vip_csi_d10 = port:PE14<2><default><default><default>
vip_csi_d11 = port:PE15<2><default><default><default>
vip_csi_sck = port:PE21<2><default><default><default>
vip_csi_sda = port:PE22<2><default><default><default>
vip_dev0_mname = "ov5640"
vip_dev0_pos = "front"
vip_dev0_twi_id = 4
vip_dev0_twi_addr = 0x78
vip_dev0_isp_used = 0
vip_dev0_fmt = 0
vip_dev0_stby_mode = 0
vip_dev0_vflip = 0
vip_dev0_hflip = 0
vip_dev0_iovdd = ""
vip_dev0_iovdd_vol = 2800000
vip_dev0_avdd = ""
vip_dev0_avdd_vol = 2800000
vip_dev0_dvdd = ""
vip_dev0_dvdd_vol = 1500000
vip_dev0_afvdd = ""
vip_dev0_afvdd_vol = 2800000
vip_dev0_power_en =
vip_dev0_reset = port:PE23<1><default><default><default>
vip_dev0_pwdn = port:PE24<1><default><default><default>
vip_dev0_flash_en =
vip_dev0_flash_mode =
vip_dev0_af_pwdn =
vip_dev0_act_used = 0
vip_dev0_act_name = "ad5820_act"
vip_dev0_act_slave = 0x18
vip_dev1_mname = "gc2035"
vip_dev1_pos = "front"
vip_dev1_lane = 1
vip_dev1_twi_id = 4
vip_dev1_twi_addr = 0x78
vip_dev1_isp_used = 0
vip_dev1_fmt = 1
vip_dev1_stby_mode = 0
vip_dev1_vflip = 0
vip_dev1_hflip = 0
vip_dev1_iovdd = ""
vip_dev1_iovdd_vol = 2800000
vip_dev1_avdd = ""
vip_dev1_avdd_vol = 2800000
vip_dev1_dvdd = ""
vip_dev1_dvdd_vol = 1500000
vip_dev1_afvdd = ""
vip_dev1_afvdd_vol = 2800000
vip_dev1_power_en =
vip_dev1_reset =
vip_dev1_pwdn =
vip_dev1_flash_en =
vip_dev1_flash_mode =
vip_dev1_af_pwdn =
~~~
将其中的摄像头信息改成自己使用的摄像头信息。
保存,并使用fex2bin sys_config.fex script.bin 生成script.bin文件。
将script.bin也放入第一分区。
再将前面编译的uImage放入第一分区。
此时就可以使用主线Uboot启动bsp内核了。
## BSP内核使用摄像头
经过上述操作后,将硬件正确连线,启动系统后在/dev目录下可见video0,video1等设备节点,即可使用ffmpeg等软件进行摄像头操作。
- 前言
- 荔枝派TODO任务领取
- linux使用小贴士
- 入门篇
- 板卡介绍
- 开箱指南
- 烧录启动系统
- 联网方法
- 镜像使用
- 镜像说明
- buildroot系统使用
- debian系统使用
- 外设操作
- 外设操作概览
- 低速外设
- GPIO
- GPIO模拟低速接口
- UART
- PWM
- I2C
- SPI
- 高速接口
- SDIO
- USB
- EtherNet
- DVP CSI
- MIPI CSI
- 模拟外设
- CODEC
- LRADC
- 常见设备驱动
- USB摄像头
- USB 3G/4G 网卡
- 舵机
- 开发篇
- UBOOT适配
- UBOOT编译
- UBOOT配置
- UBOOT配置屏幕分辨率
- UBOOT配置SPI启动
- Linux内核开发
- Linux内核编译
- BSP Linux内核编译.md
- Linux内核选项
- 外设驱动与设备树
- RTL8723BS驱动
- 根文件系统定制
- buildroot定制系统
- buildroot添加软件包
- openwrt定制系统
- emdebian定制系统
- camdriod开发
- camdriod编译
- 主线Uboot引导Camdriod
- 系统镜像打包
- XBOOT适配
- 荔枝运行XBOOT
- 应用篇
- 游戏机-基于EmulationStation
- 游戏机-gnuboy
- 语音识别-科大讯飞云
- GUI-QT5
- 语音识别-离线关键词识别
- 路由器-Lichee Zero
- 投稿文章
- 荔枝派Zero开箱指南
- Zero i2c oled使用指南
- zero SPI LCD使用指南
- Zero u-boot编译和使用指南
- TF WiFi使用方法
- Zero Ethernet使用指南
- Zero 移植Qt5.4.1
- ZeroSpiNorFlash启动系统制作指南
- Visio-uboot-sunxi流程
- lichee 编译踩坑记录(ilichee ZERO)
- lichee_zero_外设GPIO接口
- TF WIFI 小白编
- 从零开始LicheePi Zero的开发
- 认识Zero的硬件
- 搭建Zero的开发环境
- 主线Uboot
- 主线kernel
- BSP kernel
- BSP内核启动
- bsp内核的摄像头使用
- BSP内核中的保留内存
- uboot启动BSP内核常见错误
- BSP内核 FBTFT移植
- BSP内核启动错误及警告解决
- buildroot 根文件系统
- emdebian 根文件系统
- SPI Flash 系统编译
- sunxi-fel增加对16M 以上flash的支持
- overlayfs的使用
- jffs2系统挂载不上的常见原因
- JFFS2 文件系统简介
- uboot对spi flash的识别
- bsp内核的SPI flash启动
- Docker开发环境
- Docker 命令速查
- 基础ubuntu系统配置
- docker离线镜像
- Zero系统烧录
- dd镜像烧录
- 分区镜像烧录
- SPI Flash系统烧录
- 一键镜像烧录
- Zero外设把玩
- I2C操作
- PWM输出
- CODEC的使用
- 以太网使用指南
- GPIO操作
- 文件IO方式
- C语言接口(mmap)
- Python操作GPIO
- pinctrl-sunxi介绍
- UART操作
- 点屏
- 点屏之RGB屏
- 点屏之SPI屏 ili9341
- 点屏之SPI OLED
- 点屏之I2C OLED
- 点屏之SPI屏 ili9488
- 点屏之MCU屏
- 点屏之触摸屏驱动
- 点屏之simple-framebuffer
- 点屏之屏幕时序
- 时钟控制器CCM
- 摄像头
- BSP DVP摄像头
- BSP MIPI 摄像头
- 主线DVP摄像头
- 主线 MIPI摄像头
- SPI 操作
- 应用层开发
- 开机自启动
- Segment Fault调试
- Zero通过OTG共享PC网络
- USB摄像头使用
- 基于QT的GUI开发
- 移植tslib
- 移植QT5.9.1
- 移植QT4.8.7
- QtCreator使用
- Qt5.x移植到Qt4.8
- Qt字体相关
- Qt移植总结
- Qt裁剪
- Qt去除鼠标指针显示
- zero_imager使用
- 驱动开发
- 设备树简介
- GPU/DRM 显示驱动
- sys下设备树查看
- atmel触摸屏驱动分析
- atmel触摸屏中断改轮询
- uboot下gpio操作
- helloworld驱动编译演示
- FBTFT分析
- 内核模块静态加载的顺序
- SPI驱动分析
- SPI 驱动编写
- Uboot开发
- 开机logo
- 看门狗的使用
- 关于系统reboot
- 内核printk等级设置