20160524_jeffrey - silenceuncrio/diary GitHub Wiki

Index

  • 0920 - 繼續追問題
  • 0950 - i.MX BSP Porting Guide
  • 1105 - 重頭再做一次
  • 1125 - build_u-boot.sh
  • 1330 - porting guide 寫 不好
  • 1630 - Embedded Linux Projects Using Yocto Project Cookbook
  • 1805 - 修改 mx6ul_14x14_evk.h 得到 變小 u-boot.imx 超感動
  • 1905 - Writing a New Recipe

0920

繼續追昨天的問題

在 使用 make menuconfig 把能取消勾選的 module 全部取消後存檔
利用 bitbake force compile 後發現 u-boot.imx 大小根本沒變
再 make menuconfig 會發現剛剛取消的 module 全復原了

YOCTO安装及编译过程 裡說到

1.u-boot

   # cd /work/QorIQ-SDK-V1.7-20141218-yocto 

   # bitbake -c cleansstate u-boot   (两个s)

   # bitbake -c patch u-boot    (如此才可以从本地编译,不从网上fetch代码)

   # cd /work/QorIQ-SDK-V1.7-20141218-yocto /build_p2020rdb_release

   # bitbake -e u-boot |grep ^S=     (获得u-boot代码路径,进入后可修改)

<修改完成,进入release>

   # cd /work/QorIQ-SDK-V1.7-20141218-yocto /build_p2020rdb_release

   # source SOURCE_THIS

   # bitbake -c compile -f u-boot >>  log.txt   (将输出结果显示在log.txt 中)

  # bitbake u-boot

來試試看

沒用阿... make menuconfig 產生的 .config 還是被蓋掉了

不過 source SOURCE_THIS 沒有作用可能要查一下

這個似乎是別的 project 專用的... 跟 yocto 本身沒啥關係

0950

看一下 i.MX BSP Porting GuideChapter 1 Porting U-Boot from an i.MX 6/7 Reference Board to an i.MX 6/7 Custom Board

照表操課一次... 反正也不怕把 u-boot-imx 玩壞

1.2 Obtaining the Source Code for the U-Boot
The following steps describe how to obtain the source code.

  1. Install Yocto Project. See the Freescale Yocto Project User's Guide(IMXLXYOCTOUG).
  2. In Yocto Project, set the U-Boot preferred provider to uboot-imx. Confirm that the sources/meta-fsl-bsp-release/imx/meta-fsl-arm/conf has the line PREFERRED_PROVIDER_u-boot_mx6 = "u-boot-imx"

這裡說的 PREFERRED_PROVIDER_u-boot_mx6 = "u-boot-imx" 我是在 ~/fsl-release-bsp/sources 裡利用
grep -r 'PREFERRED_PROVIDER_u-boot_mx6' * 把東西找出來

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/sources$ grep -r 'PREFERRED_PROVIDER_u-boot_mx6' *
meta-fsl-bsp-release/imx/meta-sdk/conf/distro/include/fsl-imx-preferred-env.inc:PREFERRED_PROVIDER_u-boot_mx6 = "u-boot-imx"
meta-fsl-bsp-release/imx/meta-sdk/conf/distro/include/fsl-imx-preferred-env.inc:PREFERRED_PROVIDER_u-boot_mx6ul = "u-boot-imx"

看一下 meta-fsl-bsp-release/imx/meta-sdk/conf/distro/include/fsl-imx-preferred-env.inc 的內容

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/sources$ cat meta-fsl-bsp-release/imx/meta-sdk/conf/distro/include/fsl-imx-preferred-env.inc 
# Use i.MX Kernel, U-Boot and Gstreamer 1.0 providers
PREFERRED_PROVIDER_u-boot_mx5 = "u-boot-fslc"
PREFERRED_PROVIDER_u-boot_mx6 = "u-boot-imx"
PREFERRED_PROVIDER_u-boot_mx6ul = "u-boot-imx"
PREFERRED_PROVIDER_u-boot_mx7 = "u-boot-imx"
...

1020

ariel 告知我不用太執著於 reduce u-boot 的 image size

不過我現在面對的應該是該怎麼去修改 u-boot 才對... 繼續

The U-Boot code is now located at /tmp/work/-poky-linux-gnueabi/u-boot-imx//git

我們 U_Bott 的 code 目前在 <build directory>/tmp/work/imx6ulevk-poky-linux-gnueabi/u-boot-imx/2015.04-r0/git
所以我們知道

  • <machine> = imx6ulevk
  • <version> = 2015.04-r0

The U-Boot main directory is referred to as <UBOOT_DIR>.

得到 <UBOOT_DIR> = <build directory>/tmp/work/imx6ulevk-poky-linux-gnueabi/u-boot-imx/2015.04-r0/git

1.2.1 Preparing the Code
The following steps describe how to prepare the code.

  1. Copy the board directory, as shown below:
    $cp -R board/freescale/<mx6 or mx7>_<reference board name> board/freescale/<mx6 or mx7>_<custom board name>

這邊的 <mx6 or mx7> = mx6ul, <reference board name> = 14x14_evk 所以 board/freescale/<mx6 or mx7>_<reference board name> = board/freescale/mx6ul_14x14_evk

那我們就讓 <custom board name> = 'proscend'
所以 board/freescale/<mx6 or mx7>_<custom board name> = board/freescale/mx6ul_proscend

cp -R board/freescale/mx6ul_14x14_evk board/freescale/mx6ul_proscend

Copy the existing mx.h board configuration file as mx.h, as shown below:
$cp include/configs/mx<reference board name>.h include/configs/mx<custom board name>.h

這裡的 <reference board name> = 6ul_14x14_evk
<custom board name> = 6ul_proscend
得到
$cp include/configs/mx6ul_14x14_evk.h include/configs/mx6ul_proscend.h

Create a new file in <UBOOT_DIR>/configs/ for the new i.MX-based configuration.
The instruction is an example for the i.MX 6Quad board:

CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6q<customer_board>/<customer board>.cfg,MX6Q"
CONFIG_ARM=y                                                                    
CONFIG_TARGET_MX6Q<customer_board>=y                                                    
CONFIG_SYS_MALLOC_F=y                                                           
CONFIG_SYS_MALLOC_F_LEN=0x400                                                   
CONFIG_DM=y                                                                     
CONFIG_DM_THERMAL=y

先看一下原本有哪些 files

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small/tmp/work/imx6ulevk-poky-linux-gnueabi/u-boot-imx/2015.04-r0/git/configs$ ls mx6ul_14x14_evk_*
mx6ul_14x14_evk_android_defconfig
mx6ul_14x14_evk_ddr_eol_android_defconfig
mx6ul_14x14_evk_ddr_eol_brillo_defconfig
mx6ul_14x14_evk_ddr_eol_defconfig
mx6ul_14x14_evk_ddr_eol_qspi1_defconfig
mx6ul_14x14_evk_defconfig
mx6ul_14x14_evk_qspi1_defconfig

看一下 mx6ul_14x14_evk_defconfig

p/build_small/tmp/work/imx6ulevk-poky-linux-gnueabi/u-boot-imx/2015.04-r0/git/configs$ cat mx6ul_14x14_evk_defconfig 
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6ul_14x14_evk/imximage.cfg,MX6UL"
CONFIG_ARM=y
CONFIG_TARGET_MX6UL_14X14_EVK=y
CONFIG_DM=y
CONFIG_DM_THERMAL=y

所以 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6q<customer_board>/<customer board>.cfg,MX6Q" 等於
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6ul_14x14_evk/imximage.cfg,MX6UL"

CONFIG_TARGET_MX6Q<customer_board>=y 等於 CONFIG_TARGET_MX6UL_14X14_EVK=y

這個步驟我先等一下

Rename
board/freescale/<mx6 or mx7><reference board name>/<mx6 or mx7><reference board name>.c
to
board/freescale/<mx6 or mx7><custom board name>/<mx6 or mx7><custom board name>.c

找不到 .c 檔阿...

board/freescale/mx6ul_14x14_evk$ ls -al
total 304
drwxr-xr-x 2 jeffrey jeffrey  4096  5月 24 09:58 .
drwxr-xr-x 5 jeffrey jeffrey  4096  5月 24 10:35 ..
-rw-r--r-- 1 jeffrey jeffrey 91132  5月 24 09:58 built-in.o
-rw-r--r-- 1 jeffrey jeffrey   185  5月 24 09:58 .built-in.o.cmd
-rw-r--r-- 1 jeffrey jeffrey  3151  5月 24 09:58 imximage.cfg.cfgtmp
-rw-r--r-- 1 jeffrey jeffrey 14867  5月 24 09:58 .imximage.cfg.cfgtmp.cmd
-rw-r--r-- 1 jeffrey jeffrey 91104  5月 24 09:58 mx6ul_14x14_evk.o
-rw-r--r-- 1 jeffrey jeffrey 85687  5月 24 09:58 .mx6ul_14x14_evk.o.cmd
-rw-r--r-- 1 jeffrey jeffrey  1044  5月 24 09:58 mx6ul_14x14_evk.su

找錯地方了, 真的在 <UBOOT_DIR> 裡面

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small/tmp/work/imx6ulevk-poky-linux-gnueabi/u-boot-imx/2015.04-r0/git$ ls -al board/freescale/mx6ul_14x14_evk/
total 68
drwxr-xr-x  2 jeffrey jeffrey  4096  5月 24 09:58 .
drwxr-xr-x 93 jeffrey jeffrey  4096  5月 24 09:58 ..
-rw-r--r--  1 jeffrey jeffrey  4664  5月 24 09:58 imximage.cfg
-rw-r--r--  1 jeffrey jeffrey  2886  5月 24 09:58 imximage_lpddr2.cfg
-rw-r--r--  1 jeffrey jeffrey   200  5月 24 09:58 Kconfig
-rw-r--r--  1 jeffrey jeffrey   165  5月 24 09:58 MAINTAINERS
-rw-r--r--  1 jeffrey jeffrey   242  5月 24 09:58 Makefile
-rw-r--r--  1 jeffrey jeffrey 28351  5月 24 09:58 mx6ul_14x14_evk.c
-rw-r--r--  1 jeffrey jeffrey  7250  5月 24 09:58 plugin.S

1105

重頭再做一次

  • cp -R board/freescale/mx6ul_14x14_evk board/freescale/mx6ul_proscend
  • cp include/configs/mx6ul_14x14_evk.h include/configs/mx6ul_proscend.h
  • Create a new file in <UBOOT_DIR>/configs/ for the new i.MX-based configuration
  • `cp board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c board/freescale/mx6ul_proscend/mx6ul_proscend.c'

繼續

Change the line
COBJS := <mx6 or mx7><reference board name>.o (inside board/freescale/<mx6 or mx7><custom board name>/Makefile)
to
obj-y := <mx6 or mx7><custom board name>.o

改完之後的樣子

# (C) Copyright 2015 Freescale Semiconductor, Inc.
#
# SPDX-License-Identifier:	GPL-2.0+
#

obj-y  := mx6ul_proscend.o

extra-$(CONFIG_USE_PLUGIN) :=  plugin.bin
$(obj)/plugin.bin: $(obj)/plugin.o
	$(OBJCOPY) -O binary --gap-fill 0xff $< $@

1125

覺得我根本不用改那麼多東西
重頭再來一次

應該只需要寫好 build_u-boot.sh 就好了

#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=<path to cross compiler prefix> (e.g., 
/opt/poky/1.4.1/sysroots/i686-pokysdk-linux/usr/bin/cortexa9hf-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-
make distclean;
make mx<custom board name>_config
make

<path to cross compiler prefix> 是重點ㄚ

`bitbake -e u-boot-imx' 後會看到

STAGING_BINDIR_TOOLCHAIN="/home/jeffrey/fsl-release-bsp/build_small/tmp/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi"

改寫一下

#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=/home/jeffrey/fsl-release-bsp/build_small/tmp/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
make distclean;
make mx6ul_14x14_evk_defconfig
make

試試看

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small/tmp/work/imx6ulevk-poky-linux-gnueabi/u-boot-imx/2015.04-r0/git$ ./build_u-boot.sh 
  CLEAN   scripts/basic
...
  LD      examples/standalone/hello_world
/home/jeffrey/fsl-release-bsp/build_small/tmp/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-ld.bfd: cannot find -lgcc
make[2]: *** [examples/standalone/hello_world] Error 1
make[1]: *** [examples/standalone] Error 2
make: *** [examples] Error 2

shit...

1330

porting guide 也寫得不好... shit

看這篇 Riotboard Yocto : Part2 : Build u-boot using Yocto

If you are planning to modify uboot, Yocto has details steps for patching new recipes, check here.

超麻煩...

1630

找了一本 Embedded Linux Projects Using Yocto Project Cookbook

這邊 build U-Boot 的方式略有不同

We will use a Yocto toolchain to build the U-Boot source externally from the Yocto build system.

試試看吧

首先利用
http://downloads.yoctoproject.org/releases/yocto/yocto-1.7.1/toolchain/
安裝 Yocto project cross-compilation toolchain

發現安裝的位置是 /opt/poky/...

這跟 build_u-boot.sh 所要求的相呼應了

#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=<path to cross compiler prefix> (e.g., 
/opt/poky/1.4.1/sysroots/i686-pokysdk-linux/usr/bin/cortexa9hf-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-
make distclean;
make mx<custom board name>_config
make

很快地改寫一支 build_u-boot.sh 試試

#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=/opt/poky/1.7.1/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
make distclean;
make mx6ul_14x14_evk_defconfig
make

build 過了... YA

試試 menuconfig

感覺是 u-boot 本身的 menuconfig 沒啥用

1805

直接修改 mx6ul_14x14_evk.h, 不去 define CONFIG_VIDEO

然後使用 bitbake u-boot-imx -f -c compile
終於得到一個變小的 u-boot.imx
超感動的啦

明天來進行正規的 yocto patch 吧

1905

明天可以從 5.3. Writing a New Recipe 開始看

⚠️ **GitHub.com Fallback** ⚠️