NXP(imx8qxp)系列DDR校准以及android镜像烧录

NXP(imx8qxp)系列DDR校准以及android镜像烧录,第1张

文章目录 一、源码进行编译二、校准DDR三、修改代码四、阶段测试
记录一次关于nxp平台的imx8qxp系列android11的ddr校准笔记和相关的烧录笔记,因为之前公司没人做过,只有一点一点的去百度相关资料进行尝试。

一、源码进行编译

因为我下载的官方最基础的源码,按照官方文档,进行环境搭建过后,进行 source lunch 后,进行./imx-make.sh,无法编译,这里因为缺少对应的交叉编译工具链。在《Android_User’s_Guide.pdf》的4页里面有对应的说明,可能你们需要你们的组长进行帮助,我这里是之前有imx8系列的环境,我直接打的补丁,具体步骤我没有去研究。
下载对应的镜像文件:
在弄好之前的环境后,进行编译,他告诉我找不到mx8qmb0-ahab-container.img,和mx8qxb0-ahab-container.img,和mx8qxc0-ahab-container.img。这里需要下载对应的工具链,进行脚本编译。
这里可以使用 weget获得,对应的网址如下:

http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.1.bin

可以直接进行下载
对应的命令如下:

wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.1.bin
chmod +x firmware-imx-8.1.bin && ./firmware-imx-8.1.bin --auto-accept

编译后就会生成3个img
将对应的img防到

/*mx8qmb0-ahab-container.img 放这里*/
MX8QXP/vendor/nxp-opensource/imx-mkimage/iMX8QM
/*mx8qxb0-ahab-container.img,和mx8qxc0-ahab-container.img 放这里*/
MX8QXP/vendor/nxp-opensource/imx-mkimage/iMX8QX

然后在编译,就ok了

二、校准DDR

按照nxp的平台,我们还是按照之前imx8mp系列的步骤,先进行ddr校准工作。对应的工具可以自己去nxp官网下载。或者我这里https://download.csdn.net/download/weixin_51178981/85090517
对应步骤已经在文档里面说的比较清晰了,与mp不同的是他不会生成对应的xx文件。最后进行压力测试,成功的结果如图:

这个时候就需要你保存你的表格。因为里面的东西比较重要,关于你后面代码ddr的校准,相关的文档已经上传 https://download.csdn.net/download/weixin_51178981/85090561

对应步骤如下:需要下载两个工具进行校准,步骤算比较详细了

3、下载scfw工具链:
https://www.nxp.com/design/software/embedded-software/i-mx-software/embedded-linux-for-i-mx-applications-processors:IMXLINUX?tab=In-Depth_Tab

# imx-scfw-porting-kit-1.9.0.tar.gz

4、下载gcc工具链
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

# 解压到 /opt 目录下
~~~~~
# tar -zxvf imx-scfw-porting-kit-1.9.0.tar.gz
# cd packages
# chmod a+x imx-scfw-porting-kit-1.9.0.bin
# ./imx-scfw-porting-kit-1.9.0.bin
# cd imx-scfw-porting-kit-1.9.0/src
# tar -zxvf scfw_export_mx8qm_b0.tar.gz 		// for i.MX 8QuadMax MEK
# tar -zxvf scfw_export_mx8qx_b0.tar.gz		// for i.MX 8QuadXPlus MEK
# cd scfw_export_mx8qx_b0
//excel表的倒数第二个文件放入/src/scfw_export_mx8qx_b0/platform/board/mx8qx_mek/dcd/ 并重新命名:imx8qx_dcd_1.2GHz.cfg (表格中的倒数第二个文件)
//最后一个表格中的文件命名为xx.ds用于校准(放入对应的校准工具的script目录下)

/*/MX8QXP/vendor/nxp/fsl-proprietary/uboot-firmware/imx8q/board-imx8qxp.c 官方默认是3GB,这里需要你自己去适配自己的ddr大小,比如我的是4GB,修改如下:
index b364b4d..f8456ed 100755
--- a/uboot-firmware/imx8q/board-imx8qxp.c
+++ b/uboot-firmware/imx8q/board-imx8qxp.c
@@ -79,15 +79,7 @@
 
 /* Local Defines */
 
-#ifndef BD_DDR_SIZE
-#if defined(BD_DDR_RET_REGION1_SIZE) && (BD_DDR_RET_REGION1_SIZE <= 32)
-    /*! NXP QXP 16-bit LPDDR4 MEK board */
-    #define BD_DDR_SIZE         SC_1GB
-#else
-    /*! Other NXP QXP MEK boards */
-    #define BD_DDR_SIZE         SC_3GB
-#endif
-#endif
+#define BD_DDR_SIZE         SC_4GB

*/
# cp /MX8QXP/vendor/nxp/fsl-proprietary/uboot-firmware/imx8q/board-imx8qxp.c scfw_export_mx8qx_b0/platform/board/mx8qx_mek/board.c
# PATH=$PATH:/opt/gcc-arm-none-eabi-6-2017-q2-update-linux/gcc-arm-none-eabi-6-2017-q2-update/bin/
# make CROSS_COMPILE=arm-none-eabi- qx R=B0 DDR_CON=ddr_stress_test_parser	//生成对应的 scfw_tcm.bin

//将编译出的scfw_tcm.bin文件改名为mx8qxb0_scfw_download.bin放入工具包bin目录下,将.ds放入script目录下;
//按照文档进行ddr校准
//成功的校准ddr了

如果校准ddr后没有问题,就可以拷贝文件到对应的目录下,《Android_User’s_Guide.pdf》的50页有对应的说明,请细看,我这里附上关键两步

cp ${MY_ANDROID}/vendor/nxp/fsl-proprietary/uboot-firmware/imx8q/board-imx8qxp.c
scfw_export_mx8qx_b0/platform/board/mx8qx_mek/board.c

cp build_mx8qx_b0/scfw_tcm.bin ${MY_ANDROID}/vendor/nxp/fsl-proprietary/uboot-firmware/imx8q/mx8qx-scfw-tcm.bin

./imx-make.sh -j24
三、修改代码

主要修改部分为uboot阶段的代码,对应的修改如下:
设备树

diff --git a/arch/arm/dts/fsl-imx8dx.dtsi b/arch/arm/dts/fsl-imx8dx.dtsi
index a36bf388c7..f4a3297317 100644
--- a/arch/arm/dts/fsl-imx8dx.dtsi
+++ b/arch/arm/dts/fsl-imx8dx.dtsi
@@ -98,8 +98,8 @@
 
        memory@80000000 {
                device_type = "memory";
-               reg = <0x00000000 0x80000000 0 0x40000000>;
-                     /* DRAM space - 1, size : 1 GB DRAM */
+               reg = <0x00000000 0x80000000 0 0x80000000>;
+                     /* DRAM space - 1, size : 2 GB DRAM */
        };
 /*
公版默认3G,我这里4G,需要修改
*/

板级文件

diff --git a/include/configs/imx8qxp_mek.h b/include/configs/imx8qxp_mek.h
index 8e5e48026e..5402c3c1b8 100644
--- a/include/configs/imx8qxp_mek.h
+++ b/include/configs/imx8qxp_mek.h
@@ -220,14 +220,6 @@
 #define CONFIG_SYS_MMC_IMG_LOAD_PART   1
 
 /* On LPDDR4 board, USDHC1 is for eMMC, USDHC2 is for SD on CPU board */
@@ -241,14 +233,8 @@
 #define PHYS_SDRAM_1                   0x80000000
 #define PHYS_SDRAM_2                   0x880000000
 /*这里改为
#define PHYS_SDRAM_1_SIZE              0x80000000 
#define PHYS_SDRAM_2_SIZE              0x80000000 
不需要判断,直接干成4,公版默认3
*/
-#ifdef CONFIG_TARGET_IMX8DX_MEK
-#define PHYS_SDRAM_1_SIZE              0x40000000      /* 1 GB */
-#define PHYS_SDRAM_2_SIZE              0x00000000      /* 0 GB */
-#else
 #define PHYS_SDRAM_1_SIZE              0x80000000      /* 2 GB */
-/* LPDDR4 board total DDR is 3GB */
-#define PHYS_SDRAM_2_SIZE              0x40000000      /* 1 GB */
-#endif
+#define PHYS_SDRAM_2_SIZE              0x80000000      /* 2 GB */
/*
因为框架不一样,这里我需要删除对应的CONFIG_USB_TCPC有关的代码
*/
diff --git a/board/freescale/imx8qxp_mek/imx8qxp_mek.c b/board/freescale/imx8qxp_mek/imx8qxp_mek.c
index a4f9fab986..5ef6ad2276 100644
--- a/board/freescale/imx8qxp_mek/imx8qxp_mek.c
+++ b/board/freescale/imx8qxp_mek/imx8qxp_mek.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include "../common/tcpc.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -213,11 +212,7 @@ int board_phy_config(struct phy_device *phydev)
 
 int checkboard(void)
 {
-#ifdef CONFIG_TARGET_IMX8DX_MEK
-       puts("Board: iMX8DX MEK\n");
-#else
-       puts("Board: iMX8QXP MEK\n");
-#endif
+       puts("Board: Vantron iMX8QXP M08\n");
 
        print_bootinfo();
 
@@ -226,102 +221,15 @@ int checkboard(void)
 
 #ifdef CONFIG_USB
 
-#ifdef CONFIG_USB_TCPC
-struct gpio_desc type_sel_desc;
-static iomux_cfg_t ss_mux_gpio[] = {
-       SC_P_ENET0_REFCLK_125M_25M | MUX_MODE_ALT(4) | MUX_PAD_CTRL(GPIO_PAD_CTRL),
-};
-
-struct tcpc_port port;
-struct tcpc_port_config port_config = {
-       .i2c_bus = 1,
-       .addr = 0x50,
-       .port_type = TYPEC_PORT_DFP,
-};
-
-void ss_mux_select(enum typec_cc_polarity pol)
-{
-       if (pol == TYPEC_POLARITY_CC1)
-               dm_gpio_set_value(&type_sel_desc, 0);
-       else
-               dm_gpio_set_value(&type_sel_desc, 1);
-}
-
-static void setup_typec(void)
-{
-       int ret;
-       struct gpio_desc typec_en_desc;
-
-       imx8_iomux_setup_multiple_pads(ss_mux_gpio, ARRAY_SIZE(ss_mux_gpio));
-       ret = dm_gpio_lookup_name("GPIO5_9", &type_sel_desc);
-       if (ret) {
-               printf("%s lookup GPIO5_9 failed ret = %d\n", __func__, ret);
-               return;
-       }
-
-       ret = dm_gpio_request(&type_sel_desc, "typec_sel");
-       if (ret) {
-               printf("%s request typec_sel failed ret = %d\n", __func__, ret);
-               return;
-       }
-
-       dm_gpio_set_dir_flags(&type_sel_desc, GPIOD_IS_OUT);
-
-       ret = dm_gpio_lookup_name("gpio@1a_7", &typec_en_desc);
-       if (ret) {
-               printf("%s lookup gpio@1a_7 failed ret = %d\n", __func__, ret);
-               return;
-       }
-
-       ret = dm_gpio_request(&typec_en_desc, "typec_en");
-       if (ret) {
-               printf("%s request typec_en failed ret = %d\n", __func__, ret);
-               return;
-       }
-
-       /* Enable SS MUX */
-       dm_gpio_set_dir_flags(&typec_en_desc, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
-
-       tcpc_init(&port, port_config, &ss_mux_select);
-}
-#endif
-
 int board_usb_init(int index, enum usb_init_type init)
 {
-       int ret = 0;
-
-       if (index == 1) {
-               if (init == USB_INIT_HOST) {
-#ifdef CONFIG_USB_TCPC
-                       ret = tcpc_setup_dfp_mode(&port);
-#endif
-#ifdef CONFIG_USB_CDNS3_GADGET
-               } else {
-#ifdef CONFIG_USB_TCPC
-                       ret = tcpc_setup_ufp_mode(&port);
-                       printf("%d setufp mode %d\n", index, ret);
-#endif
-#endif
-               }
-       }
-
-       return ret;
+       return 0;
 
 }
 
 int board_usb_cleanup(int index, enum usb_init_type init)
 {
-       int ret = 0;
-
-       if (index == 1) {
-               if (init == USB_INIT_HOST) {
-#ifdef CONFIG_USB_TCPC
-                       ret = tcpc_disable_src_vbus(&port);
-#endif
-               }
-       }
-
-       return ret;
+       return 0;
 }
 #endif
 
@@ -329,9 +237,6 @@ int board_init(void)
 {
        board_gpio_init();
 
-#if defined(CONFIG_USB) && defined(CONFIG_USB_TCPC)
-       setup_typec();
-#endif
 
 #ifdef CONFIG_IMX_SNVS_SEC_SC_AUTO
        {
@@ -382,14 +287,8 @@ int board_late_init(void)
 
        build_info();
 
-#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
        env_set("board_name", "MEK");
-#ifdef CONFIG_TARGET_IMX8DX_MEK
-       env_set("board_rev", "iMX8DX");
-#else
        env_set("board_rev", "iMX8QXP");
-#endif
-#endif
 
        env_set("sec_boot", "no");
 #ifdef CONFIG_AHAB_BOOT

下面的修改比较重要,会影响到你烧写镜像是否成功,我在这里卡了几天,如果这里没有修后,可能会导致你烧录镜像,烧录完uboot后就停止了,不会再往下进行。

diff --git a/configs/imx8qxp_mek_android_defconfig b/configs/imx8qxp_mek_android_defconfig
index 2862f273c8..bd608d9df9 100644
--- a/configs/imx8qxp_mek_android_defconfig
+++ b/configs/imx8qxp_mek_android_defconfig
@@ -145,7 +145,7 @@ CONFIG_SPL_PHY=y
 
 CONFIG_SPL_USB_GADGET=y
 CONFIG_SPL_USB_SDP_SUPPORT=y
-CONFIG_SPL_SDP_USB_DEV=1
+CONFIG_SPL_SDP_USB_DEV=0
 CONFIG_SDP_LOADADDR=0x80400000
 
 CONFIG_FASTBOOT=y
@@ -156,7 +156,7 @@ CONFIG_FASTBOOT_UUU_SUPPORT=n
 CONFIG_FASTBOOT_BUF_ADDR=0x98000000
 CONFIG_FASTBOOT_BUF_SIZE=0x19000000
 CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_USB_DEV=1
+CONFIG_FASTBOOT_USB_DEV=0
 
 CONFIG_SYS_I2C_IMX_VIRT_I2C=y
 CONFIG_I2C_MUX_IMX_VIRT=y

diff --git a/configs/imx8qxp_mek_android_uuu_defconfig b/configs/imx8qxp_mek_android_uuu_defconfig
index 4ab7632e3e..f4c4a35acd 100644
--- a/configs/imx8qxp_mek_android_uuu_defconfig
+++ b/configs/imx8qxp_mek_android_uuu_defconfig
@@ -145,7 +145,7 @@ CONFIG_SPL_PHY=y
 
 CONFIG_SPL_USB_GADGET=y
 CONFIG_SPL_USB_SDP_SUPPORT=y
-CONFIG_SPL_SDP_USB_DEV=1
+CONFIG_SPL_SDP_USB_DEV=0
 CONFIG_SDP_LOADADDR=0x80400000
 
 CONFIG_FASTBOOT=y
@@ -156,7 +156,7 @@ CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x98000000
 CONFIG_FASTBOOT_BUF_SIZE=0x19000000
 CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_USB_DEV=1
+CONFIG_FASTBOOT_USB_DEV=0
 
 CONFIG_SYS_I2C_IMX_VIRT_I2C=y
 CONFIG_I2C_MUX_IMX_VIRT=y

diff --git a/include/configs/imx8qxp_mek_android.h b/include/configs/imx8qxp_mek_android.h
index c914336029..720bb9eef7 100644
--- a/include/configs/imx8qxp_mek_android.h
+++ b/include/configs/imx8qxp_mek_android.h
@@ -11,8 +11,6 @@
 
 #define FSL_FASTBOOT_FB_DEV "mmc"
 
-#define CONFIG_FASTBOOT_USB_DEV 1
-
 #undef CONFIG_EXTRA_ENV_SETTINGS
 #undef CONFIG_BOOTCOMMAND

这几处修改在《Android_User’s_Guide.pdf》的45页里面说了的,但是开始我没有修改完。
还有《Android_User’s_Guide.pdf》的52页的修改也要计的修改,因为i我是4GB所以这里也要修改。

diff --git a/common/partition/device-partitions-13GB-ab_super.bpt b/common/partition/device-
partitions-13GB-ab_super.bpt
index e6e7f1a..829821c 100644
--- a/common/partition/device-partitions-13GB-ab_super.bpt
+++ b/common/partition/device-partitions-13GB-ab_super.bpt
@@ -39,7 +39,7 @@
},
{
"label": "super",
-
"size": "4096 MiB",
+
"size": "3584 MiB",
"guid": "auto",
"type_guid": "c1dedb9a-a0d3-42e4-b74d-0acf96833624"
},
diff --git a/imx8m/BoardConfigCommon.mk b/imx8m/BoardConfigCommon.mk
index 20d65a3..ae42220 100644
--- a/imx8m/BoardConfigCommon.mk
+++ b/imx8m/BoardConfigCommon.mk
@@ -135,8 +135,8 @@ ifeq ($(TARGET_USE_DYNAMIC_PARTITIONS),true)
BOARD_NXP_DYNAMIC_PARTITIONS_SIZE := 4024434688
endif
else
-
BOARD_SUPER_PARTITION_SIZE := 4294967296
-
BOARD_NXP_DYNAMIC_PARTITIONS_SIZE := 4284481536
+
BOARD_SUPER_PARTITION_SIZE := 3758096384
+
BOARD_NXP_DYNAMIC_PARTITIONS_SIZE := 3747610624
endif
ifeq ($(IMX_NO_PRODUCT_PARTITION),true)
BOARD_NXP_DYNAMIC_PARTITIONS_PARTITION_LIST := system system_ext vendor
diff --git a/imx8q/BoardConfigCommon.mk b/imx8q/BoardConfigCommon.mk
index 85d3561..c7352a2 100644
--- a/imx8q/BoardConfigCommon.mk
+++ b/imx8q/BoardConfigCommon.mk
@@ -164,8 +164,8 @@ ifeq ($(TARGET_USE_DYNAMIC_PARTITIONS),true)
BOARD_NXP_DYNAMIC_PARTITIONS_SIZE := 4024434688
endif
else
-
BOARD_SUPER_PARTITION_SIZE := 4294967296
-
BOARD_NXP_DYNAMIC_PARTITIONS_SIZE := 4284481536
+
BOARD_SUPER_PARTITION_SIZE := 3758096384
+
BOARD_NXP_DYNAMIC_PARTITIONS_SIZE := 3747610624
endif
ifeq ($(IMX_NO_PRODUCT_PARTITION),true)
BOARD_NXP_DYNAMIC_PARTITIONS_PARTITION_LIST := system system_ext vendor

到这里,所有的android的代码已经修改完成,我也成功的启动了开发板。

四、阶段测试

其实阶段测试最重要的就是你flash.bin和uboot阶段命令的测试。
flash.bin测试:
在我们编译完过后,在

/MX8QXP/vendor/nxp-opensource/imx-mkimage/iMX8QX

目录下会有一个flash.bin

/MX8QXP/vendor/nxp-opensource/imx-mkimage/iMX8QX$ ls
bl31.bin                head.hash           mkimage_uboot               scfw_tcm.bin  u-boot-atf.bin   u-boot-spl.bin
boot-spl-container.img  m4_image.bin        mx8qxb0-ahab-container.img  scripts       u-boot.bin       uuu
flash.bin               mkimage_fit_atf.sh  mx8qxc0-ahab-container.img  soc.mak       u-boot-hash.bin

把对应的uuu工具拷贝到这里,或者把flash.bin拷贝到uuu工具目录下,执行下面的命令:

#  ./uuu SDPS: boot -f flash.bin

如果成功的话可以在串口打印上看到下列信息:

U-Boot 2021.04-00001-gce52836f5e (Apr 07 2022 - 19:48:17 +0800)

CPU:   NXP i.MX8QXP RevC A35 at 1200 MHz at 39C

Model: NXP i.MX8QXP MEK
Board: Vantron iMX8QXP M08
Boot:  USB
/*
这里就是你的ddr的大小,imx8qxp公版默认是3我这里改为了4,如果这里没有对,是不是你对应的${MY_ANDROID}/vendor/nxp/fsl-proprietary/uboot-firmware/imx8q/board-imx8qxp.c文件没有修改和include/configs/imx8qxp_mek.h文件没有修改,看上面的说明。
*/
DRAM:  4 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... MMC: no card present
*** Warning - No block device, using default environment

[*]-Video Link 0probe device is failed, ret 3
 (1280 x 720)
        [0] dpu@56180000, video
        [1] lvds-channel@0, display
        [2] lvds-to-hdmi-bridge@4c, video_bridge
In:    serial
Out:   serial
Err:   serial

 BuildInfo: 
  - SCFW 549b1e18, SECO-FW f449a0d2, IMX-MKIMAGE 1112c884, ATF 1545255
  - U-Boot 2021.04-00001-gce52836f5e 

Detect USB boot. Will enter fastboot mode!
Net:   Could not get PHY for FEC0: addr 0
Could not get PHY for FEC0: addr 0
Could not get PHY for FEC1: addr 0
Could not get PHY for FEC1: addr 0
No ethernet found.

MMC: no card present
Block device mmc 1 not supported
bcb_rw_block, get_block_size return 0
read_bootctl, bcb_rw_block read failed
read command failed
Fastboot: Normal
Boot from USB for uuu
Hit any key to stop autoboot:  0 

如果执行烧录命令卡住

cluo@cluo:/sd2/VT-MX8QXP-M08-A/out/target/product/mek_8q$ sudo ./uuu_imx_android_flash.sh -f imx8qxp -e -u c0
This script is validated with uuu 1.4.139 version, it is recommended to align with this version.
dtbo is supported
dual slot is supported
dynamic parttition is supported
vendor_boot parttition is supported
generate lines to flash u-boot-imx8qxp-c0.imx to the partition of bootloader0
generate lines to flash partition-table.img to the partition of gpt
generate lines to flash dtbo-imx8qxp.img to the partition of dtbo_a
generate lines to flash boot.img to the partition of boot_a
generate lines to flash vendor_boot.img to the partition of vendor_boot_a
generate lines to flash vbmeta-imx8qxp.img to the partition of vbmeta_a
generate lines to flash dtbo-imx8qxp.img to the partition of dtbo_b
generate lines to flash boot.img to the partition of boot_b
generate lines to flash vendor_boot.img to the partition of vendor_boot_b
generate lines to flash vbmeta-imx8qxp.img to the partition of vbmeta_b
generate lines to flash super.img to the partition of super
uuu script generated, start to invoke uuu with the generated uuu script
uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.4.139-0-g1a8f760

Success 0   Failure    0                                                                                                                     
                                                                                                                                                                                                                                                                                          
3:10    0/1 [-------------100%------>] u-boot-imx8qxp-c0.imx

如果他一直卡在这里就是你defconfig文件的USB的宏没有修改。

这份笔记只作为自己的参考,希望对调试imx8qxp的朋友有帮助。还有疑问可以私信,能帮则帮。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/993014.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存