hi3516a内核启动后的rcS所在的文件夹里共有5个文件,如下。本文将对文件夹中的内容进行解析和记录。
无私分享,从我做起!如有错误,还请指出!
rcS文件内容如下:
#! /bin/sh
/bin/mount -a
echo "
_ _ _ _ _ _ _ _ _ _ _ _
\ _ _ _ _ _ ___
/ /__/ \ |_/
/ __ / - _ ___
/ / / / / /
_ _ _ _/ / / \_/ \_ ______
___________\___\__________________
"
for initscript in /etc/init.d/S[0-9][0-9]*
do
if [ -x $initscript ] ;
then
echo "[RCS]: $initscript"
$initscript
fi
done
########################################
#set ip
ifconfig eth0 192.168.1.22 netmask 255.255.255.0 up
route add default gw 192.168.1.1
ifconfig lo 127.0.0.1
telnetd &
# uart1 mux
himm 0x200f007c 0x01
himm 0x200f0084 0x01
mount -t ramfs none /tmp
# insmod
cd /ko
./load3516a -i -sensor bt1120 -osmem 128 -offline
insmod /ko/extdrv/gpioi2c.ko
insmod /ko/extdrv/sil9135.ko
##########################################
source /etc/profile
#audio mux
himm 0x20120004 0x00400000
himm 0x201200e0 0x0d
himm 0x200f01c4 0x02
cd /mnt/app
./Hi3516a_hdmi_rtsp &
第一步:/bin/mount -a
mount -a 是在系统启动后去执行fstab中mount;
-a:自动挂载所有支持自动挂载的设备;(定义在了/etc/fstab文件中,且挂载选项中有“自动挂载”功能)
如果想实现开机自动挂载某设备,只要修改/etc/fstab文件即可。
查看fstab文件,vi /etc/fstab,如下图:
第二步:执行脚本文件
文件表达式
if [ -f file ] 如果文件存在
if [ -d … ] 如果目录存在
if [ -s file ] 如果文件存在且非空
if [ -r file ] 如果文件存在且可读
if [ -w file ] 如果文件存在且可写
if [ -x file ] 如果文件存在且可执行
第三步:set ip
第四步:设置串口复用,uart1 mux
himm 0x200f007c 0x01
himm 0x200f0084 0x01
mount -t ramfs none /tmp
至于为什么要用none,目前还没查到合理的解释,知道的朋友留言告知一下。
tmpfs,临时文件系统,是一种基于内存的文件系统,tmpfs可以使用RAM,但它也可以使用swap分区来存储。
另外,还有一个ramfs文件系统。
ramfs和tmpfs都是在内存上建立的文件系统(Filesystem)。其优点是读写速度很快,但存在掉电丢失的风险。如果一个进程的性能瓶颈是硬盘的读写,那么可以考虑在ramfs或tmpfs上进行大文件的读写操作。
从表格可知,ramfs会因为数据的写入自动增长空间,所以可能导致最后系统所有的内存耗完。
tmpfs可以在mount时限定大小,不会自动增长。
ramfs不会用swap。
tmpfs会使用swap。
两者都是用来提升效率,但是tmpfs比ramfs的性能更好。
第五步:insmod加载 ko文件
./load3516a -i -sensor bt1120 -osmem 128 -offline
-i ,加载所有模块, insmod all modules
-sensor bt1120,指定sensor类型是bt1120;
-osmem 128,指定os内核的内存大小是128M;
-offline,离线模式。
load3516a文件详解见传送门
加载外部模块:gpioi2c.ko和/sil9135.ko 。
insmod /ko/extdrv/gpioi2c.ko
insmod /ko/extdrv/sil9135.ko
第六步:audio mux ,设置音频管脚的复用
himm 0x20120004 0x00400000
具体还是配置寄存器的工具himm使用方法见: 传送门
himm 0x201200e0 0x0d
himm 0x200f01c4 0x02
第七步:后台执行应用程序 ,&是后台执行。
./Hi3516a_hdmi_rtsp &
S00devs文件的内容如下所示:
#!/bin/sh
mknod /dev/console c 5 1
mknod /dev/ttyAMA0 c 204 64
mknod /dev/ttyAMA1 c 204 65
mknod /dev/ttyS000 c 204 64
mknod /dev/null c 1 3
主要是利用mknod命令创建一些设备文件,后面的数字是主设备号和次设备号。
mknod命令的使用:
mknod [options] name {bc} major minor
mknod [options] name p
mknod 命令建立一个目录项和一个特殊文件的对应索引节点。第一个参数是 Name 项设备的名称。选择一个描述性的设备名称。mknod 命令有两种形式,它们有不同的标志。
第一种形式中,使用了b 或 c 标志。b 标志表示这个特殊文件是面向块的设备(磁盘、软盘或磁带)。c 标志表示这个特殊文件是面向字符的设备(其他设备)。
第一种形式的最后两个参数是指定主设备的数目,它帮助操作系统查找设备驱动程序代码,和指定次设备的数目,也就是单元驱动器或行号,它们是十进制或八进制的。一个设备的主要和次要编号由该设备的配置方法分配,它们保存在 ODM 中的 CuDvDr 类里。在这个对象类中定义了主要和次要编号以确保整个系统设备定义的一致性,这是很重要的。
在 mknod 命令的第二种形式中,使用了 p 标志来创建 FIFO(已命名的管道)。
S01udev的文件内容如下:
#!/bin/sh
mkdir /dev/pts
mount -t devpts devpts /dev/pts
mkdir -p /dev/.udev
udevd --daemon
udevadm trigger
mount -t devpts devpts /dev/pts
内核虚拟文件。
和proc一样。
Linux提供给管理员通过文件系统和内核进行沟通(读\写)的一种渠道。
pts是远程虚拟终端。devpts即远程虚拟终端文件设备。通过/dev/pts可以了解目前远程虚拟终端的基本情况。
通过对相应的设备文件进行操作,就可以达到操作硬件的目的。
而所谓的虚拟内核文件设备,是直接和内核打交道的。内核是在内存中的,所以说才叫虚拟,因为这个设备文件并不代表真正的硬件,只是存在于内存中的虚拟设备。通过访问这样的文件,可以达到和内核即使通信的目的(读/写)。
mkdir -p /dev/.udev
udevd --daemon
udevadm trigger
描述:systemd-udevd是监听内核发出的设备事件,并根据udev规则处理每个事件。
选项: --daemon 脱离控制台,并作为后台守程运行。
主要功能是创建Udevd守护进程,插入即插即拔的时候udevd会传消息给内核。
S80network文件是网络相关的,查找cmdline中的和ip相关的信息,然后读出ip信息并打印。如果ip信息不存在,就直接退出。
#!/bin/sh
ipaddr=
bootp=
gateway=
netmask=
hostname=
netdev=
autoconf=
for ipinfo in `cat /proc/cmdline`
do
case "$ipinfo" in
ip=*)
for var in ipaddr bootp gateway netmask hostname netdev autoconf
do
eval read $var
done << EOF
`echo "$ipinfo" | sed "s/:/\n/g" | sed "s/^[ ]*$/-/g"`
EOF
ipaddr=`echo "$ipaddr" | cut -d = -f 2`
[ x$ipaddr == x ] && ipaddr=x
;;
esac
done
[ -z "$ipaddr" ] && exit 0
echo " IP: $ipaddr"
echo " BOOTP: $bootp"
echo " GATEWAY: $gateway"
echo " NETMASK: $netmask"
echo "HOSTNAME: $hostname"
echo " NETDEV: $netdev"
echo "AUTOCONF: $autoconf"
if [ x$ipaddr == x- ] ; then
# use DHCP
:
else
cmd="ifconfig $netdev $ipaddr"
[ x$netmask != x- ] && cmd="$cmd netmask $netmask"
eval $cmd
[ x$gateway != x- ] && route add default gw $gateway
fi
ifconfig lo 127.0.0.1
S90hibernate文件与电源管理相关的
#!/bin/sh
echo "/root/pm_callback" > /proc/sys/kernel/pm_notifier
cmdline=`cat /proc/cmdline`
hbtype=resume
for str in $cmdline
do
case $str in
hbtype=*)
hbtype=`echo "$str" | awk -F"=" '{print $2}'`
esac
done
if [ "$hbtype"x = "snap"x ]; then
echo "hibernate start"
echo disk > /sys/power/state
fi
hi3516a启动后打印log:
U-Boot 2010.06 (Mar 10 2015 - 15:17:40)
NAND: Check nand flash controller v610. found
Special NAND id table Version 1.36
Nand ID: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
No NAND device found!!!
0 MiB
Check spi flash controller v350... Found
Spi(cs1) ID: 0xC2 0x20 0x18 0xC2 0x20 0x18
Spi(cs1): Block:64KB Chip:16MB Name:"MX25L128XX"
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
16384 KiB hi_sfc at 0:0 is now current device
## Booting kernel from Legacy Image at 82000000 ...
Image Name: Linux-3.4.35
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2962072 Bytes = 2.8 MiB
Load Address: 80008000
Entry Point: 80008000
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0
Linux version 3.4.35 (root@ubuntu) (gcc version 4.8.3 20131202 (prerelease) (Hisilicon_v300) ) #1 Sun Jun 18 23:30:03 PDT 2017
CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: hi3516a
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: mem=64M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hi_sfc:1M(boot),3M(kernel),12M(rootfs)
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 59100k/59100k available, 6436k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
vmalloc : 0xc4800000 - 0xff000000 ( 936 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.text : 0xc0008000 - 0xc0540000 (5344 kB)
.init : 0xc0540000 - 0xc0561a7c ( 135 kB)
.data : 0xc0562000 - 0xc0591080 ( 189 kB)
.bss : 0xc05910a4 - 0xc05b09f8 ( 127 kB)
SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:128
sched_clock: 32 bits at 49MHz, resolution 20ns, wraps every 86767ms
Console: colour dummy device 80x30
Calibrating delay loop... 1196.85 BogoMIPS (lpj=5984256)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
Initializing cgroup subsys freezer
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x80416e68 - 0x80416ec0
dummy:
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
uart:0: ttyAMA0 at MMIO 0x20080000 (irq = 40) is a PL011 rev2
console [ttyAMA0] enabled
uart:1: ttyAMA1 at MMIO 0x20090000 (irq = 41) is a PL011 rev2
uart:2: ttyAMA2 at MMIO 0x200a0000 (irq = 42) is a PL011 rev2
uart:3: ttyAMA3 at MMIO 0x20230000 (irq = 43) is a PL011 rev2
bio: create slab at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Switching to clocksource timer0
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
VFS: Disk quotas dquot_6.5.2
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
squashfs: version 4.0 (2009/01/31) Phillip Lougher
NFS: Registering the id_resolver key type
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
fuse init (API version 7.18)
SGI XFS with security attributes, large block/inode numbers, no debug enabled
msgmni has been set to 115
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered (default)
io scheduler cfq registered
brd: module loaded
Spi id table Version 1.22
Spi(cs1) ID: 0xC2 0x20 0x18 0xC2 0x20 0x18
SPI nor flash boot mode is 3 Bytes
Spi(cs1):
Block:64KB
Chip:16MB
Name:"MX25L128XX"
spi size: 16MB
chip num: 1
3 cmdlinepart partitions found on MTD device hi_sfc
3 cmdlinepart partitions found on MTD device hi_sfc
Creating 3 MTD partitions on "hi_sfc":
0x000000000000-0x000000100000 : "boot"
0x000000100000-0x000000400000 : "kernel"
0x000000400000-0x000001000000 : "rootfs"
Found Nand Flash Controller V610.
Nand ID: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
No NAND device found
Higmac dma_sg_phy: 0x83a00000
higmac_mdio_bus: probed
ETH0: rgmii, phy_addr=1, mii_name=mdio0
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
hiusb-ehci hiusb-ehci.0: HIUSB EHCI
hiusb-ehci hiusb-ehci.0: new USB bus registered, assigned bus number 1
hiusb-ehci hiusb-ehci.0: irq 53, io mem 0x100b0000
hiusb-ehci hiusb-ehci.0: USB 0.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
hiusb-ohci hiusb-ohci.0: HIUSB OHCI
hiusb-ohci hiusb-ohci.0: new USB bus registered, assigned bus number 2
hiusb-ohci hiusb-ohci.0: irq 54, io mem 0x100a0000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mousedev: PS/2 mouse device common for all mice
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP: cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 17
NET: Registered protocol family 15
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
VFS: Mounted root (jffs2 filesystem) on device 31:2.
Freeing init memory: 132K
_ _ _ _ _ _ _ _ _ _ _ _
\ _ _ _ _ _ ___
/ /__/ \ |_/
/ __ / - _ ___
/ / / / / /
_ _ _ _/ / / \_/ \_ ______
___________\___\__________________
[RCS]: /etc/init.d/S00devs
[RCS]: /etc/init.d/S01udev
Not recognise ACTION:change
Not recognise ACTION:change
[RCS]: /etc/init.d/S80network
[RCS]: /etc/init.d/S90hibernate
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x200f007c: 0x00000000 --> 0x00000001
[END]
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x200f0084: 0x00000000 --> 0x00000001
[END]
mmz_start: 0x88000000, mmz_size: 384M
Hisilicon Media Memory Zone Manager
Module himedia: init ok
hi3516a_base: module license 'Proprietary' taints kernel.
Disabling lock debugging due to kernel taint
load sys.ko for Hi3516A...OK!
load tde.ko ...OK!
load region.ko ....OK!
load vgs.ko for Hi3516A...OK!
ISP Mod init!
load viu.ko for Hi3516A...OK!
load vpss.ko ....OK!
load vou.ko ....OK!
load hifb.ko OK!
load rc.ko for Hi3516A...OK!
load venc.ko for Hi3516A...OK!
load chnl.ko for Hi3516A...OK!
load h264e.ko for Hi3516A...OK!
load h265e.ko for Hi3516A...OK!
load jpege.ko for Hi3516A...OK!
load vda.ko ....OK!
load ive.ko for Hi3516A...OK!
sensor_i2c: Unknown symbol i2c_new_device (err 0)
sensor_i2c: Unknown symbol i2c_get_adapter (err 0)
sensor_i2c: Unknown symbol i2c_master_recv (err 0)
sensor_i2c: Unknown symbol i2c_unregister_device (err 0)
sensor_i2c: Unknown symbol i2c_put_adapter (err 0)
sensor_i2c: Unknown symbol i2c_master_send (err 0)
insmod: can't insert 'extdrv/sensor_i2c.ko': unknown symbol in module, or unknown parameter
sil9024: Unknown symbol i2c_new_device (err 0)
sil9024: Unknown symbol i2c_get_adapter (err 0)
sil9024: Unknown symbol i2c_master_recv (err 0)
sil9024: Unknown symbol i2c_unregister_device (err 0)
sil9024: Unknown symbol i2c_put_adapter (err 0)
sil9024: Unknown symbol i2c_master_send (err 0)
insmod: can't insert 'extdrv/sil9024.ko': unknown symbol in module, or unknown parameter
==== Your input Sensor type is bt1120 ====
acodec inited!
insert audio
==== Your input Sensor type is bt1120 ====
mipi_init
init phy power successful!
load hi_mipi driver successful!
Sil9135 Driver Check V1.0
sil9135 driver init successful:1!
Now sil9135 driver init successful!
Welcome to HiLinux.
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x20120004: 0x00000000 --> 0x00400000
[END]
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x201200e0: 0x0000000E --> 0x0000000D
[END]
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x200f01c4: 0x00000002 --> 0x00000002
[END]
Auto login as root ...
Jan 1 00:00:08 login[1010]: root login on 'ttyS000'
Welcome to HiLinux.
None of nfsroot found in cmdline.
~ # 1970-01-01 00:00:10.213 info | caster_init(554)
########
ViMode=1
SDI_Input=1
RcMode=0
VideoEncType=1
VideoType=4
VideoFrameRate=25
VideoBitRate=4096
SaveMode=0
AudioEncType=0
get hdmi pixel error
get hdmi pixel error