当前位置: 首页 > 工具软件 > icore > 使用案例 >

全志h3linux移植教程,Openwrt1806在全志H3上移植(银杏icore5)

姚兴安
2023-12-01

目录下的linux内核源码压缩包解压到上述路径,并且将<.>目录内的补丁按照补丁的编号依次打上,如果出错则退出。准备好源码树后,就可以针对icore5,在dts目录下添加自己板子的设备树。直接添加的代码,在运行 make target/linux/clean时会被删除,只建议在测试时使用,测试通过后一定要制作补丁,否则代码丢了就得不偿失。

b. 打补丁添加

由上述步骤可知,编译时,会自动打补丁,也就是我们可以将补丁放到指定目录中,让系统自动打,这样也不会污染源码,更方便后续维护。制作补丁的方法,简单点就是准备好源码树后,进入源码目录,执行quilt new num-new.patch; 然后通过quilt edit 修改代码或者添加代码,最后执行quilt refresh生成补丁,将补丁拷贝至<.>目录内即可。

重新make menuconfig 选择icore5板子,编译;失败,看提示,应该时uboot缺失,因为更改了目标,uboot中还没有添加相应的规则。类似的,uboot 在<.>目录,发现该目录下也有个patch目录,是的,这个目录跟linux源码patch目录的作用时一样的。首先修改Makefile,添加icore5的配置

define U-Boot/icore5

BUILD_SUBTARGET:=cortexa7

NAME:=Icore5

BUILD_DEVICES:=sun8i-h3-icore5

endef

并在下边的UBOOT_TARGETS中添加icore5, 注意定义的名字应该与 **_defconfig 一致,如上述定义,我们应该在uboot源码树中添加icore5_defconfig; 这样在编译uboot时就会自动执行 make icore5_defconfig.

同样的,我们建议在uboot下打补丁修改代码。

最终验证

在目录添加配置 ,当前只有rgmii phy这一路通了,就先配一路, 内容如下:

config interface 'loopback'

option ifname 'lo'

option proto 'static'

option ipaddr '127.0.0.1'

option netmask '255.0.0.0'

config globals 'globals'

option ula_prefix 'fd71:468e:86c5::/48'

config interface 'lan'

option type 'bridge'

option ifname 'eth0'

option proto 'static'

option netmask '255.255.255.0'

option ip6assign '60'

option ipaddr '192.168.10.2'

config device 'lan_eth0_dev'

option name 'eth0'

option macaddr '0c:ef:af:c3:14:9e'

最终在bin目录下生成了 ext4和squashfs两种类型的镜像,我选择ext4镜像,解压到当前目录,使用dd命令下载到sd卡中,插上sd卡,使用dd命令将镜像烧录在sd卡起始位置。系统跑起来了:

U-Boot SPL 2017.11 (Dec 26 2019 - 13:02:32)

DRAM: 0 MiB

### ERROR ### Please RESET the board ###

U-Boot SPL 2017.11 (Dec 26 2019 - 13:02:32)

DRAM: 1024 MiB

Trying to boot from MMC1

U-Boot 2017.11 (Dec 26 2019 - 13:02:32 +0000) Allwinner Technology

CPU: Allwinner H3 (SUN8I 1680)

Model: icore5

DRAM: 1 GiB

MMC: SUNXI SD/MMC: 0, SUNXI SD/MMC: 1

*** Warning - bad CRC, using default environment

In: serial

Out: serial

Err: serial

Net: No ethernet found.

starting USB...

No controllers found

Hit any key to stop autoboot: 0

switch to partitions #0, OK

mmc0 is current device

Scanning mmc 0:1...

Found U-Boot script /boot.scr

reading /boot.scr

377 bytes read in 14 ms (25.4 KiB/s)

## Executing script at 43100000

reading uImage

2518520 bytes read in 134 ms (17.9 MiB/s)

reading dtb

14332 bytes read in 22 ms (635.7 KiB/s)

## Booting kernel from Legacy Image at 42000000 ...

Image Name: ARM OpenWrt Linux-4.14.160

Image Type: ARM Linux Kernel Image (uncompressed)

Data Size: 2518456 Bytes = 2.4 MiB

Load Address: 40008000

Entry Point: 40008000

Verifying Checksum ... OK

## Flattened Device Tree blob at 43000000

Booting using the fdt blob at 0x43000000

Loading Kernel Image ... OK

Using Device Tree in place at 43000000, end 430067fb

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0

[ 0.000000] Linux version 4.14.160 (yhangzzz@yhangzzz-virtual-machine) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 unknown)) #0 SMP PREEMPT Thu Dec 26 13:02:32 2019

[ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=30c5387d

[ 0.000000] CPU: div instructions available: patching division code

[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

...

root@OpenWrt:/# ifconfig

br-lan Link encap:Ethernet HWaddr 0C:EF:AF:C3:14:9E

inet addr:192.168.10.2 Bcast:192.168.10.255 Mask:255.255.255.0

inet6 addr: fe80::eef:afff:fec3:149e/64 Scope:Link

inet6 addr: fd71:468e:86c5::1/60 Scope:Global

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:692 errors:0 dropped:0 overruns:0 frame:0

TX packets:218 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:97464 (95.1 KiB) TX bytes:22147 (21.6 KiB)

eth0 Link encap:Ethernet HWaddr 0C:EF:AF:C3:14:9E

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:1130 errors:0 dropped:7 overruns:0 frame:0

TX packets:403 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:154722 (151.0 KiB) TX bytes:78851 (77.0 KiB)

Interrupt:28

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:65536 Metric:1

RX packets:192 errors:0 dropped:0 overruns:0 frame:0

TX packets:192 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:13056 (12.7 KiB) TX bytes:13056 (12.7 KiB)

最后附上,uboot和linux的补丁文件。

uboot补丁文件:

--- /dev/null

+++ b/configs/icore5_defconfig

@@ -0,0 +1,15 @@

+CONFIG_ARM=y

+CONFIG_ARCH_SUNXI=y

+CONFIG_NR_DRAM_BANKS=1

+CONFIG_SPL=y

+CONFIG_MACH_SUN8I_H3=y

+CONFIG_DRAM_CLK=408

+CONFIG_MMC0_CD_PIN="PF6"

+CONFIG_MMC_SUNXI_SLOT_EXTRA=2

+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set

+CONFIG_SPL_TEXT_BASE=0x60

+# CONFIG_CMD_FLASH is not set

+# CONFIG_SPL_DOS_PARTITION is not set

+# CONFIG_SPL_EFI_PARTITION is not set

+CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-icore5"

+CONFIG_SUN8I_EMAC=y

--- /dev/null

+++ b/arch/arm/dts/sun8i-h3-icore5.dts

@@ -0,0 +1,44 @@

+

+/dts-v1/;

+#include "sun8i-h3.dtsi"

+#include "sunxi-common-regulators.dtsi"

+

+#include

+

+/ {

+model = "icore5";

+compatible = "icore5", "allwinner,sun8i-h3";

+

+aliases {

+serial0 = &uart0;

+};

+

+chosen {

+stdout-path = "serial0:115200n8";

+};

+

+};

+

+&mmc0 {

+vmmc-supply = ;

+bus-width = <4>;

+cd-gpios = ; /* PF6 */

+status = "okay";

+};

+

+&uart0 {

+pinctrl-names = "default";

+pinctrl-0 = ;

+status = "okay";

+};

+

+

+&mmc2 {

+pinctrl-names = "default";

+pinctrl-0 = ;

+vmmc-supply = ;

+bus-width = <8>;

+non-removable;

+status = "okay";

+};

+

--- a/arch/arm/dts/Makefile

+++ b/arch/arm/dts/Makefile

@@ -331,7 +331,8 @@ dtb-$(CONFIG_MACH_SUN8I_H3) += \

sun8i-h3-nanopi-m1.dtb \

sun8i-h3-nanopi-m1-plus.dtb \

sun8i-h3-nanopi-neo.dtb \

-sun8i-h3-nanopi-neo-air.dtb

+sun8i-h3-nanopi-neo-air.dtb \

+sun8i-h3-icore5.dtb

dtb-$(CONFIG_MACH_SUN8I_R40) += \

sun8i-r40-bananapi-m2-ultra.dtb

dtb-$(CONFIG_MACH_SUN8I_V3S) += \

linux 补丁文件:

--- /dev/null

+++ b/arch/arm/boot/dts/sun8i-h3-icore5.dts

@@ -0,0 +1,63 @@

+/dts-v1/;

+#include "sun8i-h3.dtsi"

+#include "sunxi-common-regulators.dtsi"

+

+#include

+#include

+

+

+/ {

+model = "icore5";

+compatible = "xinda,icore5", "allwinner,sun8i-h3";

+

+aliases {

+serial0 = &uart0;

+ethernet0 = &emac;

+};

+

+chosen {

+stdout-path = "serial0:115200n8";

+};

+

+};

+

+&uart0 {

+pinctrl-names = "default";

+pinctrl-0 = ;

+status = "okay";

+};

+

+&mmc0 {

+vmmc-supply = ;

+bus-width = <4>;

+cd-gpios = ; /* PF6 */

+status = "okay";

+};

+

+&mmc2 {

+pinctrl-names = "default";

+pinctrl-0 = ;

+vmmc-supply = ;

+vqmmc-supply = ;

+bus-width = <8>;

+non-removable;

+status = "okay";

+};

+

+&emac {

+pinctrl-names = "default";

+pinctrl-0 = ;

+phy-handle = ;

+phy-mode = "rgmii";

+snps,reset-gpio = ;

+snps,reset-active-low;

+snps,reset-delays-us = <0 10000 30000>;

+status = "okay";

+};

+

+&external_mdio {

+rgmii_phy: ethernet-phy@1 {

+compatible = "ethernet-phy-ieee802.3-c22";

+reg = <1>;

+};

+};

注意: linux补丁文件不全,没有在 dts/Makefile中添加 sun8i-h3-icore5.dtb ,测试时直接再源码树修改了Makefile,有兴趣的同学可以再做一个补丁。

文章来源: www.oschina.net,作者:yhangzzz,版权归原作者所有,如需转载,请联系作者。

原文链接:https://my.oschina.net/u/4232364/blog/3159558

 类似资料: