Skip to content

Commit a573cba

Browse files
committed
Merge branch 'tiny4412-nxt' into all-in-one
2 parents c28f9df + 884c380 commit a573cba

File tree

15 files changed

+806
-0
lines changed

15 files changed

+806
-0
lines changed

tiny4412/README.md

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
# kernel_drivers_examples
2+
3+
Codes test on the kernel version below
4+
5+
4.4.0
6+
7+
# tiny4412_devicetree
8+
9+
tiny4412内核移植(支持device tree)
10+
11+
[参考文章](http://www.cnblogs.com/pengdonglin137/tag/TINY4412/)
12+
13+
内核版本:Linux-4.4.0
14+
15+
u-boot版本:友善之臂自带的 U-Boot 2010.12
16+
17+
busybox版本:busybox 1.25
18+
19+
交叉编译工具链arm-none-linux-gnueabi-gcc:[下载地址](https://launchpad.net/gcc-arm-embedded/+download)
20+
21+
gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29)
22+
23+
## 说明
24+
25+
4412> 表示在开发板上执行
26+
27+
PC> 表示在开发主机上执行
28+
29+
## U-boot
30+
31+
代码下载
32+
33+
git clone https://github.com/54shady/uboot_tiny4412.git --depth=1
34+
35+
配置编译
36+
37+
mkdir out
38+
make O=out ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- tiny4412_config
39+
make O=out ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -j8
40+
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -C sd_fuse
41+
42+
烧写uboot到SD卡里(sdb)
43+
44+
cd sd_fuse/tiny4412/
45+
./sd_fusing.sh /dev/sdb
46+
47+
uboot下对SD卡进行分区
48+
49+
fdisk -c 0 608 2057 520
50+
51+
uboot下格式化FAT分区
52+
53+
fatformat mmc 0:1
54+
55+
## U-Boot环境变量
56+
57+
EMMC或SD卡里文件系统启动
58+
59+
set bootcmd "movi read kernel 0 0x40600000; mmc read 0 0x41000000 0x3421 0x2800; mmc read 0 0x42000000 0x5c21 0x800; bootm 0x40600000 0x41000000 0x42000000"
60+
61+
setenv bootargs 'root=/dev/ram0 rw rootfstype=ext4 console=ttySAC0,115200 ethmac=1C:6F:65:34:51:7E init=/linuxrc'
62+
63+
nfs网络文件系统启动
64+
65+
set bootcmd "movi read kernel 0 0x40600000; mmc read 0 0x42000000 0x5c21 0x800; bootm 0x40600000 - 0x42000000"
66+
67+
setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.1.100:/home/zeroway/android/src/rootfs_for_tiny4412/rootfs ethmac=1C:6F:65:34:51:7E ip=192.168.1.230:192.168.1.100:192.168.1.1:255.255.255.0::eth0:off console=ttySAC0,115200 init=/linuxrc'
68+
69+
## Kernel
70+
71+
配置
72+
73+
make O=out ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- exynos_defconfig
74+
75+
编译内核
76+
77+
make O=out ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage -j8 LOADADDR=0x40008000
78+
79+
编译模块
80+
81+
make O=out ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules -j8
82+
83+
编译设备树
84+
85+
make O=out ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- dtbs -j8
86+
87+
## ramdisk制作
88+
89+
使用脚本make_ramdiskimage.sh或手工执行
90+
91+
```shell
92+
rm -rvf ramdisk*
93+
sudo dd if=/dev/zero of=ramdisk bs=1k count=8192
94+
sudo mkfs.ext4 -F ramdisk
95+
sudo mkdir -p ./initrd
96+
sudo mount -t ext4 ramdisk ./initrd
97+
sudo cp rootfs/* ./initrd -ravf
98+
sudo mknod initrd/dev/console c 5 1
99+
sudo mknod initrd/dev/null c 1 3
100+
sudo umount ./initrd
101+
sudo gzip --best -c ramdisk > ramdisk.gz
102+
sudo mkimage -n "ramdisk" -A arm -O linux -T ramdisk -C gzip -d ramdisk.gz ramdisk.img
103+
```
104+
105+
## DNW烧写
106+
107+
block size = 512 byte(0x200)
108+
109+
### 下载内核(uImage)
110+
111+
下载内核到DDR里
112+
113+
4412>
114+
115+
dnw 0x40600000
116+
117+
PC>
118+
119+
dnw uImage
120+
121+
将DDR里的内核写入EMMC
122+
123+
写起始地址 0x421
124+
125+
写大小0x3000
126+
127+
0x3000 * 0x200 / 0x400 / 0x400 = 6M(大于内核大小即可)
128+
129+
4412>
130+
131+
mmc write 0 0x40600000 0x421 0x3000
132+
133+
将写入EMMC的文件读出来对比(测试烧写是否正确)
134+
135+
mmc read 0 0x41600000 0x421 0x3000
136+
cmp.b 0x41600000 0x40600000 0x3000
137+
138+
### 下载文件系统(ramdisk.img)
139+
140+
下载文件统到DDR里
141+
142+
写起始地址 0x3421
143+
144+
写大小0x2800
145+
146+
0x2800 * 0x200 / 0x400 / 0x400 = 5M(大于文件系统大小即可)
147+
148+
4412>
149+
150+
dnw 0x41000000
151+
152+
PC>
153+
154+
dnw ramdisk.img
155+
156+
将DDR里的文件系统写入EMMC
157+
158+
4412>
159+
160+
mmc write 0 0x41000000 0x3421 0x2800
161+
162+
将写入EMMC的文件读出来对比(测试烧写是否正确)
163+
164+
165+
mmc read 0 0x41600000 0x3421 0x2800
166+
cmp.b 0x41600000 0x41000000 0x2800
167+
168+
### 下载设备树(exynos4412-tiny4412.dtb)
169+
170+
下载设备树到DDR里
171+
172+
写起始地址 0x5c21
173+
174+
写大小0x500
175+
176+
0x800 * 0x200 / 0x400 / 0x400 = 1M(大于设备树大小即可)
177+
178+
4412>
179+
180+
dnw 0x42000000
181+
182+
PC>
183+
184+
dnw exynos4412-tiny4412.dtb
185+
186+
将DDR里的设备树写入EMMC
187+
188+
4412>
189+
190+
mmc write 0 0x42000000 0x5c21 0x800
191+
192+
将写入EMMC的文件读出来对比(测试烧写是否正确)
193+
194+
195+
mmc read 0 0x40600000 0x7530 0x800
196+
cmp.b 0x40600000 0x42000000 0x800
197+
198+
## bootm启动
199+
200+
bootm + uImage + ramdisk + dtb
201+
202+
bootm 0x40600000 0x41000000 0x42000000
203+
204+
## fastboot烧写镜像
205+
206+
### 烧写内核
207+
208+
4412>
209+
210+
fastboot
211+
212+
PC>
213+
214+
fastboot flash kernel uImage
215+
216+
### 烧写文件系统
217+
218+
4412>
219+
220+
fastboot
221+
PC>
222+
223+
fastboot flash ramdisk ramdisk.img
224+
225+
## USB
226+
227+
### 网卡配置(dm9621)
228+
229+
BUG
230+
需要冷启动才能正常使用,估计是复位异常,待排查
231+
232+
busybox ifconfig eth0 192.168.1.200 up
233+
234+
### 测试U盘挂载
235+
236+
mount -o loop /dev/sda4 /mnt/
237+
238+
## 挂载网络文件系统
239+
240+
mount -t nfs -o nolock,vers=2 192.168.1.100:/home/zeroway/android/src/rootfs_for_tiny4412/rootfs /mnt/
241+
242+
## 驱动实例
243+
244+
下载代码
245+
246+
git clone https://github.com/54shady/kernel_drivers_examples.git -b tiny4412 --depth=1
247+
248+
[中断方式按键驱动](./debug/buttons/README.md)
249+
250+
[LED驱动](./debug/leds/README.md)

tiny4412/debug/buttons/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Makefile
2+
# Comment/uncomment the following line to disable/enable debugging
3+
# DEBUG = y
4+
5+
# Usage
6+
# make KERNEL_DIR=/home/zeroway/github/4412dt/new_kernel/linux-4.4 KERNEL_BUID_OUTPUT=/home/zeroway/github/4412dt/new_kernel/linux-4.4/out ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
7+
8+
# Add your debugging flag (or not) to CFLAGS
9+
ifeq ($(DEBUG),y)
10+
DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
11+
else
12+
DEBFLAGS = -O2
13+
endif
14+
15+
obj-m := buttons.o
16+
KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build
17+
KERNEL_BUID_OUTPUT ?=$(KERNEL_DIR)
18+
CC = $(CROSS_COMPILE)gcc
19+
LD = $(CROSS_COMPILE)ld
20+
PWD := $(shell pwd)
21+
22+
modules:
23+
$(MAKE) -C $(KERNEL_DIR) M=$(PWD) O=$(KERNEL_BUID_OUTPUT) modules
24+
25+
clean:
26+
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions modules.order Module.symvers
27+
28+
depend .depend dep:
29+
$(CC) $(CFLAGS) -M *.c > .depend
30+
31+
ifeq (.depend,$(wildcard .depend))
32+
include .depend
33+
endif

tiny4412/debug/buttons/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 按键驱动
2+
3+
## 硬件连接
4+
5+
当按键按下后电平由高变低
6+
7+
![button1](./button1.png)
8+
9+
![button2](./button2.png)
10+
11+
## 使用方法
12+
13+
在主设备树文件里包含下面的文件
14+
15+
#include "buttons.dtsi"
16+
17+
## 测试
18+
19+
按下每个按键后会打印日志

tiny4412/debug/buttons/button1.png

40.6 KB
Loading

tiny4412/debug/buttons/button2.png

33.7 KB
Loading

0 commit comments

Comments
 (0)