从kernel.org下载最新版本的内核:
https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.19.114.tar.xz
解压:tar -Jxvf linux-4.19.114.tar.xz
ARCH ?= arm
CROSS_COMPILE ?= /usr/local/arm/gcc-linaro-6.5.0-2018.12-x86_64/bin/arm-linux-gnueabihf-
注意:根据自己的实际情况修改交叉编译工具链路径,交叉编译工具链版本太旧的话请更新到6.5.0
gcc-linaro:https://releases.linaro.org/components/toolchain/binaries/6.5-2018.12/arm-linux-gnueabihf/
复制 arch/arm/configs/ 下的 s5pv210_defconfig 命名为 tq-e8_defconfig(名字无所谓可以随便)
cd arch/arm/configs/
cp s5pv210_defconfig tq-e8_defconfig
注意:文章中每一部分文件操作命令都是在内核文件夹linux-4.19.114下为起点开始的
复制 arch/arm/boot/dts/ 下的 s5pv210-smdkv210.dts 命名为 s5pv210-tq-e8.dts(名字无所谓可以随便)
cd arch/arm/boot/dts/
cp s5pv210-smdkv210.dts s5pv210-tq-e8.dts
文件复制后还需要再 arch/arm/boot/dts/Makefile 中添加一行 s5pv210-tq-e8.dts
打开文件:arch/arm/boot/dts/s5pv210-tq-e8.dts
/ {
model = "YIC System TQ-E8 based on S5PV210";
compatible = "yic,tq-e8", "samsung,s5pv210";
chosen {
bootargs = "console=ttySAC0,115200n8 root=/dev/nfs nfsroot=192.168.0.200:/root/hanxiaohu/rootfs ip=192.168.0.50 rw rootwait ignore_loglevel earlyprintk";
};
memory@20000000 {
device_type = "memory";
reg = <0x20000000 0x20000000>; //内存起始地址0x20000000,内存大小512MB(0x20000000)
};
ethernet@88000000 { //修改DM9000
compatible = "davicom,dm9000";
reg = <0x88000000 0x2 0x88000004 0x2>;
interrupt-parent = <&gph1>;
interrupts = <2 4>;
local-mac-address = [00 00 de ad be ef];
davicom,no-eeprom;
clocks = <&clocks CLK_SROMC>;
clock-names = "sromc";
};
backlight {
compatible = "pwm-backlight";
pwms = <&pwm 3 5000000 0>;
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;
pinctrl-names = "default";
pinctrl-0 = <&pwm3_out>;
};
};
//设置xxti的时钟频率,不然会导致计时器卡死无法启动系统!!!
&xxti {
clock-frequency = <24000000>;
};
&xusbxti {
clock-frequency = <24000000>;
};
.........
因为内核启动过程成关闭了SROM的时钟,所以要在dm9000.c中开启时钟。
打开文件: drivers/net/ethernet/davicom/dm9000.c
(1)添加头文件引用
#include
(2)在 1425 行左右的dm9000_probe()函数中添加一个
const char *clk_name;
(3)在 1578 行左右增加
/* Enable clock if specified */
if (!of_property_read_string(dev->of_node, "clock-names", &clk_name)) {
struct clk *clk = devm_clk_get(dev, clk_name);
if (IS_ERR(clk)) {
dev_err(dev, "cannot get clock of %s\n", clk_name);
ret = PTR_ERR(clk);
goto out;
}
clk_prepare_enable(clk);
dev_info(dev, "enable clock '%s'\n", clk_name);
}
修改结果如下:
-- linux-4.19/drivers/net/ethernet/davicom/dm9000.c
+++ linux-4.19.ok/drivers/net/ethernet/davicom/dm9000.c
@@ -40,6 +40,8 @@
#include
#include
+#include //add zb
+
#include
#include
#include
@@ -1436,6 +1438,7 @@
enum of_gpio_flags flags;
struct regulator *power;
bool inv_mac_addr = false;
+ const char *clk_name;
power = devm_regulator_get(dev, "vcc");
if (IS_ERR(power)) {
@@ -1572,6 +1575,20 @@
ret = -EINVAL;
goto out;
}
+
+ /* Enable clock if specified */
+ if (!of_property_read_string(dev->of_node, "clock-names", &clk_name)) {
+ struct clk *clk = devm_clk_get(dev, clk_name);
+ if (IS_ERR(clk)) {
+ dev_err(dev, "cannot get clock of %s\n", clk_name);
+ ret = PTR_ERR(clk);
+ goto out;
+ }
+ clk_prepare_enable(clk);
+ dev_info(dev, "enable clock '%s'\n", clk_name);
+ }
+
/* fill in parameters for net-dev structure */
ndev->base_addr = (unsigned long)db->io_addr;
make tq-e8_defconfig
make menuconfig
(1)配置默认调试输出串口
Kernel hacking --->
[*] Kernel low-level debugging functions (read help!)
Kernel low-level debugging port (Use Samsung S3C UART 0 for low-level debug)
[*] Early printk
(2)支持网络功能
[*] Networking support --->
Networking options --->
<*> Packet socket
<*> Unix domain sockets
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
[*] IP: DHCP support
[*] IP: BOOTP support
[*] IP: RARP support
(3)启用dm9000驱动
Device Drivers --->
[*] Network device support --->
[*] Network core driver support
......
[*] Ethernet driver support --->
<*> DM9000 support
最后只留下DM9000其他全部取消
(4)支持网络文件系统
File systems --->
[*] Network File Systems --->
<*> NFS client support
<*> NFS client support for NFS version 2 (NEW)
<*> NFS client support for NFS version 3 (NEW)
[*] Root file system on NFS
(1)编译内核
make -j8
(2)编译设备树
make dtbs
自己在ubuntu上搭建好tftp服务器和nfs服务器,将编译好的内核放到tftp。
准备好网络启动的根文件系统
setenv bootcmd 'tftp 30000000 s5pv210-tq-e8.dtb;tftpboot 20008000 zImage;fdt addr 30000000; bootz 20008000 - 30000000'
setenv bootargs 'console=ttySAC0,115200 root=/dev/nfs rw nfsroot=192.168.0.200:/home/hanxiaohu/linux/netboot/nfs/s5pv210/rootfs ip=192.168.0.41:192.168.0.200:192.168.0.1:255.255.255.0::eth0:off earlyprintk'
saveenv
u-boot下执行boot启动
boot
U-Boot 2017.01-g499aa08-dirty (Mar 17 2020 - 08:28:38 +0800), Build: S5PV210 for TQ-E8
CPU: S5PC110 @ 1 GHz
Model: Samsung Goni based on S5PC110
Board: TQ-E8 S5PV210
DRAM: 512 MiB
MMC: SAMSUNG SDHCI: 0, SAMSUNG SDHCI: 1
In: serial
Out: serial
Err: serial
Net: dm9000
TQ-E8 #
TQ-E8 # setenv bootcmd 'tftp 30000000 s5pv210-tq-e8.dtb;tftpboot 20008000 zImage;fdt addr 30000000; bootz 20008000 - 30000000'
TQ-E8 #
TQ-E8 # setenv bootargs 'console=ttySAC0,115200 root=/dev/nfs rw nfsroot=192.168.0.200:/home/hanxiaohu/linux/netboot/nfs/s5pv210/rootfs ip=192.168.0.41:192.168.0.200:192.168.0.1:255.255.255.0::eth0:off earlyprintk'
TQ-E8 #
TQ-E8 # saveenv
Saving Environment to MMC...
Writing to MMC(0)... done
TQ-E8 # boot
dm9000 i/o: 0x88000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:19:d3:fe:56:33
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.0.200; our IP address is 192.168.0.50
Filename 's5pv210-tq-e8.dtb'.
Load address: 0x30000000
Loading: ##
1.6 MiB/s
done
Bytes transferred = 24979 (6193 hex)
dm9000 i/o: 0x88000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:19:d3:fe:56:33
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.0.200; our IP address is 192.168.0.50
Filename 'zImage'.
Load address: 0x20008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
1.6 MiB/s
done
Bytes transferred = 3807360 (3a1880 hex)
Kernel image @ 0x20008000 [ 0x000000 - 0x3a1880 ]
## Flattened Device Tree blob at 30000000
Booting using the fdt blob at 0x30000000
Loading Device Tree to 3af5f000, end 3af68192 ... OK
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 4.19.114 (hanxiaohu@Ubuntu16) (gcc version 6.5.0 (Linaro GCC 6.5-2018.12)) #1 PREEMPT Thu Apr 9 22:24:37 CST 2020
CPU: ARMv7 Processor [412fc082] revision 2 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt: Machine model: YIC System TQ-E8 based on S5PV210
bootconsole [earlycon0] enabled
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
random: get_random_bytes called from start_kernel+0x94/0x410 with crng_init=0
Built 1 zonelists, mobility grouping on. Total pages: 130048
Kernel command line: console=ttySAC0,115200 root=/dev/nfs rw nfsroot=192.168.0.200:/home/hanxiaohu/linux/netboot/nfs/s5pv210/rootfs ip=192.168.0.41:192.168.0.200:192.168.0.1:255.255.255.0::eth0:off earlyprintk
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 509952K/524288K available (6144K kernel code, 207K rwdata, 1536K rodata, 1024K init, 249K bss, 14336K reserved, 0K cma-reserved)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0xa0800000 - 0xff800000 (1520 MB)
lowmem : 0x80000000 - 0xa0000000 ( 512 MB)
modules : 0x7f000000 - 0x80000000 ( 16 MB)
.text : 0x(ptrval) - 0x(ptrval) (7136 kB)
.init : 0x(ptrval) - 0x(ptrval) (1024 kB)
.data : 0x(ptrval) - 0x(ptrval) ( 208 kB)
.bss : 0x(ptrval) - 0x(ptrval) ( 250 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
rcu: Preemptible hierarchical RCU implementation.
Tasks RCU enabled.
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
VIC @(ptrval): id 0x00041192, vendor 0x41
VIC @(ptrval): id 0x00041192, vendor 0x41
VIC @(ptrval): id 0x00041192, vendor 0x41
VIC @(ptrval): id 0x00041192, vendor 0x41
S5PV210 clocks: mout_apll = 1000000000, mout_mpll = 667000000
mout_epll = 80000000, mout_vpll = 54000000
sched_clock: 32 bits at 33MHz, resolution 29ns, wraps every 64392313329ns
clocksource: samsung_clocksource_timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57309158834 ns
Console: colour dummy device 80x30
Calibrating delay loop... 996.14 BogoMIPS (lpj=4980736)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
CPU0: Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable
Setting up static identity map for 0x20100000 - 0x20100060
rcu: Hierarchical SRCU implementation.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 256 (order: 0, 7168 bytes)
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
clocksource: Switched to clocksource samsung_clocksource_timer
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 6144 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 4, 81920 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 12288 bytes)
UDP-Lite hash table entries: 256 (order: 1, 12288 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.
Initialise system trusted keyrings
workingset: timestamp_bits=30 max_order=17 bucket_order=0
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
Key type asymmetric registered
Asymmetric key parser 'x509' registered
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
io scheduler mq-deadline registered
io scheduler kyber registered
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
e2900000.serial: ttySAC0 at MMIO 0xe2900000 (irq = 58, base_baud = 0) is a S3C6400/10
console [ttySAC0] enabled
console [ttySAC0] enabled
bootconsole [earlycon0] disabled
bootconsole [earlycon0] disabled
e2900400.serial: ttySAC1 at MMIO 0xe2900400 (irq = 59, base_baud = 0) is a S3C6400/10
e2900800.serial: ttySAC2 at MMIO 0xe2900800 (irq = 60, base_baud = 0) is a S3C6400/10
e2900c00.serial: ttySAC3 at MMIO 0xe2900c00 (irq = 61, base_baud = 0) is a S3C6400/10
exynos4-fb f8000000.fimd: failed to get system register.
OF: graph: no port node found in /soc/fimd@f8000000
[drm] Exynos DRM: using f8000000.fimd device for DMA mapping operations
exynos-drm exynos-drm: bound f8000000.fimd (ops fimd_component_ops)
[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[drm] No driver support for vblank timestamp query.
Console: switching to colour frame buffer device 100x30
exynos-drm exynos-drm: fb0: frame buffer device
[drm] Initialized exynos 1.1.0 20180330 for exynos-drm on minor 0
brd: module loaded
loop: module loaded
dm9000 88000000.ethernet: 88000000.ethernet supply vcc not found, using dummy regulator
dm9000 88000000.ethernet: Linked as a consumer to regulator.0
dm9000 88000000.ethernet: enable clock 'sromc'
eth0: dm9000b at (ptrval),(ptrval) IRQ 144 MAC: 00:00:de:ad:be:ef (platform data)
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-exynos: EHCI EXYNOS driver
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
ohci-exynos: OHCI EXYNOS driver
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdhci eb000000.sdhci: clock source 0: mmc_busclk.0 (133400000 Hz)
s3c-sdhci eb000000.sdhci: clock source 2: mmc_busclk.2 (80000000 Hz)
mmc0: SDHCI controller on samsung-hsmmc [eb000000.sdhci] using ADMA
s3c-sdhci eb100000.sdhci: clock source 0: mmc_busclk.0 (133400000 Hz)
s3c-sdhci eb100000.sdhci: clock source 2: mmc_busclk.2 (80000000 Hz)
mmc1: SDHCI controller on samsung-hsmmc [eb100000.sdhci] using ADMA
s3c-sdhci eb200000.sdhci: clock source 0: mmc_busclk.0 (133400000 Hz)
s3c-sdhci eb200000.sdhci: clock source 2: mmc_busclk.2 (80000000 Hz)
mmc0: new high speed MMC card at address 0001
mmcblk0: mmc0:0001 004G90 3.69 GiB
mmcblk0boot0: mmc0:0001 004G90 partition 1 2.00 MiB
mmcblk0boot1: mmc0:0001 004G90 partition 2 2.00 MiB
mmc2: SDHCI controller on samsung-hsmmc [eb200000.sdhci] using ADMA
s3c-sdhci eb300000.sdhci: clock source 0: mmc_busclk.0 (133400000 Hz)
s3c-sdhci eb300000.sdhci: clock source 3: mmc_busclk.3 (80000000 Hz)
mmcblk0rpmb: mmc0:0001 004G90 partition 3 512 KiB, chardev (252:0)
mmcblk0: p1 p2 p3
mmc3: Internal clock never stabilised.
mmc3: sdhci: ============ SDHCI REGISTER DUMP ===========
mmc3: sdhci: Sys addr: 0x00000000 | Version: 0x00002401
mmc3: sdhci: Blk size: 0x00000000 | Blk cnt: 0x00000000
mmc3: sdhci: Argument: 0x00000000 | Trn mode: 0x00000000
mmc3: sdhci: Present: 0x00fa0000 | Host ctl: 0x00000000
mmc3: sdhci: Power: 0x0000000e | Blk gap: 0x00000000
mmc3: sdhci: Wake-up: 0x00000000 | Clock: 0x00008001
mmc3: sdhci: Timeout: 0x00000000 | Int stat: 0x00000000
mmc3: sdhci: Int enab: 0x00ff0043 | Sig enab: 0x00ff0043
mmc3: sdhci: ACmd stat: 0x00000000 | Slot int: 0x00000000
mmc3: sdhci: Caps: 0x05e80080 | Caps_1: 0x00000000
mmc3: sdhci: Cmd: 0x00000000 | Max curr: 0x00000000
mmc3: sdhci: Resp[0]: 0x00000000 | Resp[1]: 0x00000000
mmc3: sdhci: Resp[2]: 0x00000000 | Resp[3]: 0x00000000
mmc3: sdhci: Host ctl2: 0x00000000
mmc3: sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x00000000
mmc3: sdhci: ============================================
mmc2: new high speed SDHC card at address 2177
mmcblk2: mmc2:2177 APPSD 3.77 GiB
mmcblk2: p1
mmc3: SDHCI controller on samsung-hsmmc [eb300000.sdhci] using ADMA
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
NET: Registered protocol family 10
Segment Routing with IPv6
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered protocol family 17
Key type dns_resolver registered
Loading compiled-in X.509 certificates
hctosys: unable to open rtc device (rtc0)
dm9000 88000000.ethernet eth0: link down
dm9000 88000000.ethernet eth0: link down
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
random: fast init done
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
IP-Config: Complete:
device=eth0, hwaddr=00:00:de:ad:be:ef, ipaddr=192.168.0.41, mask=255.255.255.0, gw=192.168.0.1
host=192.168.0.41, domain=, nis-domain=(none)
bootserver=192.168.0.200, rootserver=192.168.0.200, rootpath=
VFS: Mounted root (nfs filesystem) on device 0:12.
devtmpfs: mounted
Freeing unused kernel memory: 1024K
Run /sbin/init as init process
dm9000 88000000.ethernet eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
Please press Enter to activate this console.
[root@S5PV210 ]#
[root@S5PV210 ]# ls
bin etc hello.c linuxrc proc sbin tmp var
dev hello lib mnt root sys usr
[root@S5PV210 ]# ./hello
hello world!
hello world!
hello world!
[root@S5PV210 ]#
到此内核移植成功!
参考文章:
https://blog.csdn.net/JerryGou/article/details/85109733
https://blog.csdn.net/qq_16777851/article/details/87207159