[原創] NXP i.MX8QXP dev kit notes tutorial 開發紀錄教學 NXP i.MX8QXP mek dev kit 開發板 notes Yocto Project 開發教學 tutorial imx8qxp mek dev kit

相關連結: i.mx8 必讀

i.MXDev Blog: https://imxdev.gitlab.io/

BSP 軟體下載: https://www.nxp.com/design/i.mx-developer-resources/i.mx-software-and-development-tool:IMX-SW

imx_builder — standalone build without Yocto:

https://community.nxp.com/docs/DOC-342702

i.MX Development Miscellanea(i.MX 开发杂记):

https://community.nxp.com/docs/DOC-335198

MX8X_4.14.98_ga_BootLoader_V5-20190903_chn.pdf i.mx8x启动代码定制文档:

https://community.nxp.com/docs/DOC-342448

MX8X_4.14.98_ga_kernel_V3-20190903_chn.pdf .i.mx8x内核代码定制文档:

https://community.nxp.com/docs/DOC-344217

Linux设备驱动开发详解:基于最新的Linux 4.0内核:

https://community.nxp.com/docs/DOC-343799

i.MX8 Boot process and creating a bootable image:

https://community.nxp.com/docs/DOC-343178

System Controller Firmware 101 – Getting started:

https://community.nxp.com/docs/DOC-340327

System Controller Firmware 101 – Pad configuration service:

https://community.nxp.com/docs/DOC-340326

NXP 官方討論區: https://community.nxp.com/community/imx/content

Yocto Training – HOME:

https://community.nxp.com/docs/DOC-94849

開發版: i.MX8QXP MEK

https://imxdev.gitlab.io/tutorial/imx_8qxp_launch_and_preview/

PDF:

i.MX_Yocto_Project_User’s_Guide

i.MX_Linux_User’s_Guide

安裝套件:

$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev

$ sudo apt-get install libsdl1.2-dev xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc

$ sudo apt-get install u-boot-tools

$ mkdir ~/bin

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

$ chmod a+x ~/bin/repo

Add the following line to the .bashrc file to ensure that the ~/bin folder is in your PATH variable.

$ export PATH=~/bin:$PATH

下載 Source Code:

$ mkdir imx-yocto-bsp
$ cd imx-yocto-bsp
$ repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-sumo -m
imx-4.14.98-2.0.0_ga.xml
$ repo sync

編譯 fsl-imx-wayland core-image-minimal

$ EULA=1 DISTRO=fsl-imx-wayland MACHINE=imx8qxpmek source ./fsl-setup-release.sh -b fsl-imx-wayland

$ echo “BB_NUMBER_THREADS ?= \”8\”” >> conf/local.conf
$ echo “PARALLEL_MAKE ?= \”-j 8\”” >> conf/local.conf

$ bitbake -f core-image-minimal

檔案輸出在: tmp/deploy/images/imx8qxpmek

修改 code 之後編譯步驟:

編譯 u-boot:

$ bitbake -f -C compile u-boot-imx;

$ bitbake -f -c deploy u-boot-imx;

編譯打包 imx-boot

$ bitbake -f -C compile imx-boot;

$ bitbake -f -c deploy imx-boot

編譯 Kernel:

$ bitbake -f -C compile linux-imx;

$ bitbake -f -c deploy linux-imx;

Kernel menuconfig:

$ bitbake -f -c menuconfig linux-imx;

Kernel device tree:

dtb-$(CONFIG_ARCH_FSL_IMX8QXP) += fsl-imx8qxp-lpddr4-arm2.dtb \
fsl-imx8qxp-mek.dtb \
fsl-imx8qxp-mek-rpmsg.dtb \
fsl-imx8qxp-mek-dsp.dtb \
fsl-imx8qxp-mek-dom0.dtb \
fsl-imx8qxp-mek-ov5640.dtb \
fsl-imx8qxp-mek-ov5640-rpmsg.dtb \
fsl-imx8qxp-mek-enet2.dtb \
fsl-imx8qxp-mek-enet2-tja1100.dtb \
fsl-imx8qxp-mek-dsi-rm67191.dtb \
fsl-imx8qxp-mek-a0.dtb \
fsl-imx8qxp-mek-lcdif.dtb \
fsl-imx8qxp-mek-it6263-lvds0-dual-channel.dtb \
fsl-imx8qxp-mek-it6263-lvds1-dual-channel.dtb \
fsl-imx8qxp-mek-jdi-wuxga-lvds0-panel.dtb \
fsl-imx8qxp-mek-jdi-wuxga-lvds1-panel.dtb \
fsl-imx8qxp-mek-root.dtb \
fsl-imx8qxp-mek-inmate.dtb \
fsl-imx8qxp-lpddr4-arm2-enet2.dtb \
fsl-imx8qxp-lpddr4-arm2-enet2-tja1100.dtb \
fsl-imx8qxp-lpddr4-arm2-gpmi-nand.dtb \
fsl-imx8qxp-lpddr4-arm2-lpspi.dtb \
fsl-imx8qxp-lpddr4-arm2-lpspi-slave.dtb \
fsl-imx8qxp-lpddr4-arm2-spdif.dtb \
fsl-imx8qxp-lpddr4-arm2-mlb.dtb \
fsl-imx8qxp-lpddr4-arm2-mqs.dtb \
fsl-imx8qxp-lpddr4-arm2-wm8962.dtb \
fsl-imx8qxp-lpddr4-arm2-dsp.dtb \
fsl-imx8qxp-lpddr4-arm2-dsi-rm67191.dtb \
fsl-imx8qxp-lpddr4-arm2-a0.dtb \
fsl-imx8qxp-17x17-val.dtb \
fsl-imx8qxp-ddr3l-val.dtb \
fsl-imx8dx-17x17-val.dtb \
fsl-imx8dx-lpddr4-arm2.dtb \
fsl-imx8dxp-lpddr4-arm2.dtb

Busybox menuconfig:

$ bitbake -c devshell busybox

$ make menuconfig

cross_prefix = aarch64-poky-linux-

sysroot=在上兩層目錄內有

LDFLAG += -L/home/ericlu/D/5G_TCU/fsl-imx-wayland-spi/tmp/sysroots-components/aarch64/glibc/usr/lib

U-boot menuconfig:

$ bitbake -c devshell u-boot-imx;

$ make imx8qxp_mek_fspi_defconfig

$ make menuconfig;

燒錄 SD card image:

$ bunzip2 -dk -f <image_name>.sdcard.bz2
$ sudo dd if=<image name>.sdcard of=/dev/sd<partition> bs=1M conv=fsync

RootFs 快速打包使用 make_ext4fs :

$ sudo apt-get -y install android-tools-fsutils

$ make_ext4fs -l 大小(ex:35M) -J -b 1024 輸出IMG名稱 檔案路徑

手動打包:

DD 一塊空間:

$ sudo dd if=/dev/zero of=35MB bs=1M count=35

格式化:

$ mkfs.ext4 35MB 

掛載:

$ mkdir tmp

$ sudo mount 35M tmp

$ cp XXXX tmp

卸載:

sudo umount tmp

DD 0xFF bin size 35M:

dd if=/dev/zero bs=1M count=35 | tr “\000” “\377” > 35M_0xFF.bin

DD 覆蓋 file 不更改 size:

dd if=inputFile.bin of=35M_0xFF.bin conv=notrunc

EX:

sudo dd if=imx-boot-imx8qxpmek-fspi.bin of=XXX seek=0 bs=1M count=4M conv=notrunc

U-boot 客製化 bootcmd:

修改 U-boot source code include\configs\imx8qxp_mek.h

Yocto 產生 SDK:

$ bitbake -c populate_sdk

SDK 位置 :

tmp/deploy/sdk/fsl-imx-wayland-glibc-x86_64-meta-toolchain-aarch64-toolchain-4.14-sumo.sh

安裝:

$ tmp/deploy/sdk/fsl-imx-wayland-glibc-x86_64-meta-toolchain-aarch64-toolchain-4.14-sumo.sh

使用:

$ source /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux

使用 UUU 燒錄 QSPI 的 u-boot:

uuu -b qspi imx-boot-imx8qxpmek-fspi.bin-flash_flexspi

使用 UUU 腳本:

uuu uuu_script.txt

腳本內容第一行必須為 uuu 版本名稱 ex:

uuu_version 1.2.39

SDP: boot -f imx-boot-imx8qxpmek-sd_USB2.bin-flash

FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f FLASH.bin
FB: ucmd sf probe
FB[-t 180000]: ucmd sf erase 0 +${fastboot_bytes}
FB[-t 180000]: ucmd sf write ${fastboot_buffer} 0 ${fastboot_bytes}
FB: done

U-boot 內與 PC 連線,使用 UUU 需先執行: fastboot 0

U-boot modify env offset and size 環境變數大小:

vi ./include/configs/imx8qxp_mek.h U-BOOT env offset 4MB and size 128 KB
#ifdef CONFIG_QSPI_BOOT
#define CONFIG_ENV_IS_IN_SPI_FLASH
#define CONFIG_ENV_OFFSET (4 * 1024 * 1024)
#define CONFIG_ENV_SECT_SIZE (128 * 1024)

U-boot add flash id:

./drivers/mtd/spi/spi_flash_ids.c: {“mt35xu512g”, INFO6(0x2c5b1a, 0x104100, 128 * 1024, 512, E_FSR) },

Kernel add flash id:

./drivers/mtd/spi-nor/spi-nor.c: {“mt35xu512aba”, INFO(0x2c5b1a, 0, 128 * 1024, 512, SECT_4K | SPI_NOR_OCTAL_READ | SPI_NOR_SKIP_SFDP) },

DDR TEST Board Bring-up 記憶體測試:

Setup ER9_LPDDR4-v12 (NDA)

Connect UUU usb port and debug UART usb port

Switch serial mode and boot up.

Open MX8_DDR_Teste.exe

Connect UART port

Load DDR script

Run Download

Run Stress Test

Systemd boot script:

將要啟動的腳本 link 到 etc 下:

$ ln -s /lib/systemd/system/XXX /etc/systemd/system/XXX

build rootfs 燒錄

進 Linux 後使用 list-unit-files and list-dependencies 查看:

$ systemctl list-dependencies

$ systemctl list-unit-files | grep enabled

SD card img partition 製作方法:

parted 分割後 dd 燒錄

generate_imx_sdcard () {
        # Create partition table
        parted -s ${SDCARD} mklabel msdos
        parted -s ${SDCARD} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED})
        parted -s ${SDCARD} unit KiB mkpart primary $(expr  ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${B    OOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE)
        parted ${SDCARD} print

        # Burn bootloader
        case "${IMAGE_BOOTLOADER}" in
                imx-bootlets)
                bberror "The imx-bootlets is not supported for i.MX based machines"
                exit 1
                ;;
                imx-boot)
                dd if=${DEPLOY_DIR_IMAGE}/imx-boot-${MACHINE}-${UBOOT_CONFIG}.bin of=${SDCARD} conv=notrunc seek=${IMX_BOOT_SEEK} bs=1K
                ;;
                u-boot)
                if [ -n "${SPL_BINARY}" ]; then
                    if [ -n "${SPL_SEEK}" ]; then
                        dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY} of=${SDCARD} conv=notrunc seek=${SPL_SEEK} bs=1K
                        dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=${UBOOT_SEEK} bs=1K
                    else
                        dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY} of=${SDCARD} conv=notrunc seek=2 bs=512
                        dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=69 bs=1K
                    fi
                else
                    dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=2 bs=512
                fi
                ;;
                barebox)
                dd if=${DEPLOY_DIR_IMAGE}/barebox-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 skip=1 bs=512
                dd if=${DEPLOY_DIR_IMAGE}/bareboxenv-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 bs=512k
                ;;
                "")
                ;;
                *)
                bberror "Unknown IMAGE_BOOTLOADER value"
                exit 1
                ;;
        esac

        _generate_boot_image 1

        # Burn Partition
        dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
        dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
}

parted 分割後的 partition 掛載方法:

mount -o loop,offset=$((4096 * 512)) xxx.img /xxx

SC firmware PMIC 代碼如下:

PMIC初始化代碼:
Power_up_cpus-> prep_cpu-> pm_force_resource_power_mode-> pm_update_ridx-> ss_trans_power_mode->
sc_ss_ep [ss] .ss_trans_power_mode-> ss_trans_power_mode_base-> ss_trans_pd
soc_trans_pd-> board_set_power_mode-> board_get_pmic_info-> pmic_init(board.c)
PMIC調用API
board_set_voltage-> board_get_pmic_info
pmic_init-> pmic_ignore_current_limit
|-> pmic_update_timing
所以如果修改了電源設計,如換了PMIC,需要重新編寫以下代碼:
\ IMX-scfw-移植-KIT-1.1 \ SRC \ scfw_export_mx8qx_b0 \平台\板\ mx8qx_mek \ board.c
的以下函數:
pmic_init / board_set_power_mode / board_set_voltage / board_get_pmic_info / pmic_ignore_current_limit /
pmic_update_timing
然後在
\ imx-scfw-porting-kit-1.1 \ src \ scfw_export_mx8qx_b0 \ platform \ board \ pmic.c pmic.h
的pmic上層函數要增加新的PMIC訪問代碼。
最後還需要添加相應PMIC驅動在如下目錄
\ imx-scfw-porting-kit-1.1 \ src \ scfw_export_mx8qx_b0 \ platform \ drivers \ pmic,在此處添加新的PMIC驅動,可以
參考fsl_pmic.h的I2C訪問API i2c_write / read來訪問新的PMIC(僅指可以通過I2C訪問的PMIC,
例如說通過SPI口訪問的則SPI訪問驅動接口沒有開源)
\ imx-scfw-porting-kit-1.1 \ src \ scfw_export_mx8qx_b0 \ platform \ board \ pmic.h中的pmic訪問API:
#ifdef PMIC / *用定義的PMIC替換功能前綴* /
#定義FUNC_PRE(名稱,功能)FUNC_PREPRE(名稱,功能)
#定義FUNC_PREPRE(名稱,功能)名稱##功能
#定義PMIC_SET_MODE FUNC_PRE(PMIC,_pmic_set_mode)
#定義PMIC_GET_MODE FUNC_PRE(PMIC,_pmic_get_mode)
#定義PMIC_SET_VOLTAGE FUNC_PRE(PMIC,_pmic_set_voltage)
#定義PMIC_GET_VOLTAGE FUNC_PRE(PMIC,_pmic_get_voltage)
#定義PMIC_IRQ_SERVICE FUNC_PRE(PMIC,_pmic_irq_service)
#定義PMIC_REGISTER_ACCESS FUNC_PRE(PMIC,_pmic_register_access)
#定義GET_PMIC_VERSION FUNC_PRE(PMIC,_get_pmic_version)
#定義GET_PMIC_TEMP FUNC_PRE(PMIC,_get_pmic_temp)
#定義SET_PMIC_TEMP_ALARM FUNC_PRE(PMIC,_set_pmic_temp_alarm)
#else / *
所以還是強烈客戶參考NXP開發板的設計,不用修改相應電源設計。
另外注意一下scfw中有為A35核和GPU開電的代碼,這段代碼不開源,所以A35與GPU
電源在上電時是沒有電的,由SCU開電。

cross compiler 需要路徑:

# –sysroot=/opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux \
# -I/home/askey/D/5G_TCU/fsl-imx-wayland-spi/tmp/sysroots-components/aarch64/glibc/usr/include \
# -L/opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux \
# -L/opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux/lib \
# -L/opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux/usr/lib \
# -L/home/ericlu/D/5G_TCU/fsl-imx-wayland-spi/tmp/sysroots-components/aarch64 \
# -L/home/ericlu/D/5G_TCU/fsl-imx-wayland-spi/tmp/sysroots-components/aarch64/glibc/ \
# -L/home/ericlu/D/5G_TCU/fsl-imx-wayland-spi/tmp/sysroots-components/aarch64/glibc/lib/ \
# -L/home/ericlu/D/5G_TCU/fsl-imx-wayland-spi/tmp/sysroots-components/aarch64/glibc/usr/lib 

pinctrl:

Documentation : Documentation/devicetree/bindings/pinctrl/fsl,imx8qxp-pinctrl.txt

Device Tree: 可用 i.MX Pins Tool 配置 pinctrl ,省去看 datasheet memory map 的時間。

Driver: drivers/pinctrl/freescale/pinctrl-imx8qxp.c

driver 內使用 scfw api 與 scfw (System Controller Firmware) 溝通。

ex:

err = sc_pad_set_all(ipc, INIT_GPIO_PINS_BB_IOEXP_CAN_INT_B_PIN_FUNCTION_ID, 2U, SC_PAD_CONFIG_NORMAL, SC_PAD_ISO_OFF, 0x40 ,SC_PAD_WAKEUP_OFF);/* IOMUXD_ADC_IN4 register modification value */
if (SC_ERR_NONE != err)
{
assert(false);
}

RoadLINK SAF5400 V2X DSRC:

現有產品,請參考:

https://www.u-blox.com/en/product/vera-p1-series#tab-documentation-resources

https://cohdawireless.com/solutions/hardware/mk5-obu/

https://www.unex.com.tw/products/dsrc-v2x/solutions/v2x-system

透過 SDIO 開機:

透過 sdio boot-up SAF5400。

最上層使用 LLC software layer 開發透過 SDIO 控制 SAF5400。

SXF1800: Secure Element IC for V2X Communication:

https://www.nxp.com/products/wireless/dsrc-safety-modem/secure-element-ic-for-v2x-communication:SXF1800

未經允許不得轉載:GoMCU » [原創] NXP i.MX8QXP dev kit notes tutorial 開發紀錄教學

評論 搶沙發

  • 暱稱 (必填)
  • 郵箱 (必填)
  • 網址