一、下载与编译
源码下载:
$ repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v4.0-Beta1 --no-repo-verify
$ repo sync -c
$ repo forall -c 'git lfs pull'
编译工具链下载:
$ bash build/prebuilts_download.sh
编译:
$ ./build.sh --product-name dayu210
二、编译过程遇到的问题
2.1 kernel 补丁无法打入
[OHOS ERROR] patching file drivers/usb/host/xhci-pci.c
[OHOS ERROR] Hunk #2 FAILED at 57.
[OHOS ERROR] Hunk #3 succeeded at 148 (offset 1 line).
[OHOS ERROR] Hunk #4 FAILED at 236.
[OHOS ERROR] Hunk #5 succeeded at 253 (offset 2 lines).
[OHOS ERROR] Hunk #6 succeeded at 285 (offset 2 lines).
[OHOS ERROR] Hunk #7 succeeded at 319 (offset 2 lines).
[OHOS ERROR] 2 out of 7 hunks FAILED -- saving rejects to file drivers/usb/host/xhci-pci.c.rej
...
[OHOS ERROR] patching file drivers/usb/serial/option.c
[OHOS ERROR] Hunk #4 FAILED at 246.
[OHOS ERROR] Hunk #5 succeeded at 435 (offset 1 line).
[OHOS ERROR] Hunk #6 succeeded at 570 (offset 1 line).
[OHOS ERROR] Hunk #7 succeeded at 1068 (offset 1 line).
[OHOS ERROR] Hunk #8 succeeded at 1109 (offset 1 line).
[OHOS ERROR] Hunk #9 FAILED at 1117.
[OHOS ERROR] Hunk #10 succeeded at 1231 (offset 3 lines).
[OHOS ERROR] Hunk #11 succeeded at 1245 (offset 3 lines).
[OHOS ERROR] Hunk #12 succeeded at 1263 (offset 3 lines).
[OHOS ERROR] Hunk #13 succeeded at 1275 (offset 3 lines).
[OHOS ERROR] Hunk #14 succeeded at 1649 (offset 3 lines).
[OHOS ERROR] Hunk #15 succeeded at 1676 (offset 3 lines).
[OHOS ERROR] Hunk #16 succeeded at 1956 (offset 3 lines).
[OHOS ERROR] Hunk #17 succeeded at 2094 (offset 3 lines).
[OHOS ERROR] 2 out of 17 hunks FAILED -- saving rejects to file drivers/usb/serial/option.c.rej
...
解决方法:
修改 OpenHarmony-4.0-Beta1/kernel/linux/linux-5.10
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 9168b492c..0ee11a937 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -59,7 +59,6 @@
#define PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI 0x9a13
#define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138
#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed
-#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_PCH_XHCI 0x54ed
#define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9
#define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba
@@ -243,8 +242,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
xhci->quirks |= XHCI_MISSING_CAS;
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
- (pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI ||
- pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_PCH_XHCI))
+ pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI)
xhci->quirks |= XHCI_RESET_TO_DEFAULT;
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 5636b8f52..537ef276c 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -255,7 +255,6 @@ static void option_instat_callback(struct urb *urb);
#define QUECTEL_PRODUCT_EP06 0x0306
#define QUECTEL_PRODUCT_EM05G 0x030a
#define QUECTEL_PRODUCT_EM060K 0x030b
-#define QUECTEL_PRODUCT_EM05G_SG 0x0311
#define QUECTEL_PRODUCT_EM12 0x0512
#define QUECTEL_PRODUCT_RM500Q 0x0800
#define QUECTEL_PRODUCT_RM520N 0x0801
@@ -1161,8 +1160,6 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
{ USB_DEVICE_INTERFACE_CLASS(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM05G, 0xff),
.driver_info = RSVD(6) | ZLP },
- { USB_DEVICE_INTERFACE_CLASS(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM05G_SG, 0xff),
- .driver_info = RSVD(6) | ZLP },
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM060K, 0xff, 0x00, 0x40) },
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM060K, 0xff, 0xff, 0x30) },
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM060K, 0xff, 0xff, 0x40) },
2.2 lz4 版本太旧
[OHOS ERROR] LZ4C arch/arm64/boot/Image.lz4
[OHOS ERROR] Incorrect parameters
[OHOS ERROR] Usage :
[OHOS ERROR] lz4 [arg] [input] [output]
[OHOS ERROR]
[OHOS ERROR] input : a filename
[OHOS ERROR] with no FILE, or when FILE is - or stdin, read standard input
[OHOS ERROR] Arguments :
[OHOS ERROR] -1 : Fast compression (default)
[OHOS ERROR] -9 : High compression
[OHOS ERROR] -d : decompression (default for .lz4 extension)
[OHOS ERROR] -z : force compression
[OHOS ERROR] -f : overwrite output without prompting
[OHOS ERROR] -h/-H : display help/long help and exit
解决方法:
$ sudo mv /usr/bin/lz4 /usr/bin/lz4.bak
$ git clone https://github.com/lz4/lz4.git
$ cd lz4
$ make
# it will be installed in /usr/local/bin
$ sudo make install
三、关键目录/文件
板级配置:
OpenHarmony-4.0-Beta1/device/board/hihope/dayu210
kernel 补丁路径:
OpenHarmony-4.0-Beta1/device/board/hihope/dayu210/kernel/kernel_patch/linux-5.10/dayu210_patch
kernel 配置:
OpenHarmony-4.0-Beta1/device/board/hihope/dayu210/kernel/kernel_config/linux-5.10/arch/arm64/rk3588_standard_defconfig
kernel 编译工作目录:
OpenHarmony-4.0-Beta1/out/kernel/src_tmp/linux-5.10
固件生成路径:
OpenHarmony-4.0-Beta1/out/rk3588/packages/phone/images
四、参考资料
Docker 编译环境:
zh-cn/device-dev/get-code/gettools-acquire.md · OpenHarmony/docs - Gitee.com