Changchun Master Li

pcduino3 nano 移植 openwrt 19.07.6

2021-01-25

pcduino3 is on openwrt official supported device list https://openwrt.org/toh/pcduino/pcduino3
pcduino3 nano spec也差不多,所以只需小改就可以完美使用

bring up

  • ethernet rtl8211e
  • openssl
  • openclash libcap/dnsmasq/luci-compat
  • nand flash H27UBG8T2BTR-BC

build process

clone code

1
2
git clone https://github.com/openwrt/openwrt.git
git checkout v19.07.6

create a new device entry to build system

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
diff --git a/package/boot/uboot-sunxi/Makefile b/package/boot/uboot-sunxi/Makefile
index 6b83bd27c6..00101ad90c 100644
--- a/package/boot/uboot-sunxi/Makefile
+++ b/package/boot/uboot-sunxi/Makefile
@@ -126,6 +126,12 @@ define U-Boot/Linksprite_pcDuino3
BUILD_DEVICES:=sun7i-a20-pcduino3
endef

+define U-Boot/Linksprite_pcDuino3_Nano
+ BUILD_SUBTARGET:=cortexa7
+ NAME:=Linksprite pcDuino3 nano
+ BUILD_DEVICES:=sun7i-a20-pcduino3-nano
+endef
+
define U-Boot/Lamobo_R1
BUILD_SUBTARGET:=cortexa7
NAME:=Lamobo R1
@@ -265,6 +271,7 @@ UBOOT_TARGETS := \
OLIMEX_A13_SOM \
Linksprite_pcDuino \
Linksprite_pcDuino3 \
+ Linksprite_pcDuino3_Nano \
Lamobo_R1 \
nanopi_m1_plus \
nanopi_neo \
diff --git a/target/linux/sunxi/image/cortex-a7.mk b/target/linux/sunxi/image/cortex-a7.mk
index ce0cbe5a5c..b0e5e9a28d 100644
--- a/target/linux/sunxi/image/cortex-a7.mk
+++ b/target/linux/sunxi/image/cortex-a7.mk
@@ -217,4 +217,13 @@ endef

TARGET_DEVICES += sun7i-a20-pcduino3

+define Device/sun7i-a20-pcduino3-nano
+ DEVICE_TITLE:=LinkSprite pcDuino3 Nano
+ DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi kmod-usb-hid kmod-usb-net kmod-usb-net-asix
+ SUPPORTED_DEVICES:=linksprite,pcduino3-nano
+ SUNXI_DTS:=sun7i-a20-pcduino3-nano
+endef
+TARGET_DEVICES += sun7i-a20-pcduino3-nano
+
endif

then config the kernel to make peripherals run properly

1
2
3
4
5
6
7
8
9
10
11
12
# add to target/linux/sunxi/config-4.14
CONFIG_GENERIC_IRQ_MIGRATION=y
# nand flash
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_NAND_SUNXI=y
# rtl8211e
CONFIG_REALTEK_PHY
# CONFIG_SPI_DYNAMIC is not set
# ax88772b usb to ethernet adaptor
CONFIG_USB_NET_AX8817X=y
CONFIG_USB_USBNET=y

replace with the master libcap https://github.com/vernesong/OpenClash/issues/839

1
2
rm -rf feeds/packages/libs/libcap
svn co https://github.com/openwrt/packages/trunk/libs/libcap feeds/packages/libs/libcap

create dts patch to bring up nand flash target/linux/sunxi/patches-4.14/500-sun7i-a20-nand.patch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--- a/arch/arm/boot/dts/sun7i-a20-pcduino3-nano.dts
+++ b/arch/arm/boot/dts/sun7i-a20-pcduino3-nano.dts
@@ -232,3 +232,19 @@
usb2_vbus-supply = <&reg_usb1_vbus>;
status = "okay";
};
+
+&nfc {
+ pinctrl-names = "default";
+ pinctrl-0 = <&nand_pins_a>, <&nand_cs0_pins_a>, <&nand_rb0_pins_a>;
+ status = "okay";
+
+ nand@0 {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ reg = <0>;
+ allwinner,rb = <0>;
+
+ nand-ecc-mode = "hw";
+ nand-on-flash-bbt;
+ };
+};
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -1322,6 +1322,45 @@
pins = "PI20", "PI21";
function = "uart7";
};
+
+ nand_pins_a: nand_pins@0 {
+ pins = "PC0", "PC1", "PC2",
+ "PC5", "PC8", "PC9", "PC10",
+ "PC11", "PC12", "PC13", "PC14",
+ "PC15", "PC16";
+ function = "nand0";
+ };
+
+ nand_cs0_pins_a: nand_cs@0 {
+ pins = "PC4";
+ function = "nand0";
+ };
+
+ nand_cs1_pins_a: nand_cs@1 {
+ pins = "PC3";
+ function = "nand0";
+ };
+
+ nand_cs2_pins_a: nand_cs@2 {
+ pins = "PC17";
+ function = "nand0";
+ };
+
+ nand_cs3_pins_a: nand_cs@3 {
+ pins = "PC18";
+ function = "nand0";
+ };
+
+ nand_rb0_pins_a: nand_rb@0 {
+ pins = "PC6";
+ function = "nand0";
+ };
+
+ nand_rb1_pins_a: nand_rb@1 {
+ pins = "PC7";
+ function = "nand0";
+ };
+
};
timer@01c20c00 {

compiling!!!
choose Target System (Allwinner A1x/A20/A3x) Subtarget (Allwinner A20/A3x) Target Profile (LinkSprite pcDuino3 Nano)

1
./scripts/feeds update -a && ./scripts/feeds install -a && make menuconfig && make download -j 16 && make -j1 V=s

nand flash might not work

1
2
3
4
5
6
7
[    0.970062] nand: Could not find valid ONFI parameter page; aborting   
[ 0.976571] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xd7
[ 0.982942] nand: Hynix NAND 4GiB 3,3V 8-bit
[ 0.987211] nand: 4096 MiB, MLC, erase size: 2048 KiB, page size: 4096, OOB size: 128
[ 0.995068] sunxi_nand 1c03000.nand: ECC init failed: -22
[ 1.000463] sunxi_nand 1c03000.nand: failed to init nand chips
[ 1.006441] sunxi_nand: probe of 1c03000.nand failed with error -22
使用支付宝打赏
使用微信打赏

若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏

扫描二维码,分享此文章