2016年6月21日 星期二

mdev 實現 SD card 或 USB mass storage 自動掛載(automount)



Embedded system中實現 SD card 或 USB mass storage 自動掛載(automount) ,是透過
busybox mdev來達成.

我分成幾個部份來討論實做:1.編譯組態  2.設定檔  3.程式流程

[1.編譯組態]

    組態部份需要編譯linux kernel與busybox.
==========
linux kernel:
==========
1. 檢查kernel路徑下 .config當案;確定選取了底下組態:
CONFIG_HOTPLUG = y
CONFIG_PROC_FS=y
CONFIG_SYSFS=y
CONFIG_NET=y
CONFIG_PROC_SYSCTL=y

<note1>如果選項未選取,請經由make menuconfig選取;請不要編輯.config!
<note2> Kernel 選項:
>>> Generic Driver Options
() path to uevent helper    /* 可以不用現在更改;由設定檔來更改;下面說明.*/
[*] Maintain a devtmpfs filesystem to mount at /dev
[*] Automount devtmpfs at /dev, after the kernel mounted the rootfs



==========
busybox-1.19.4
==========
>>> Build Options (我將busybox編譯為靜態連結)
[*] Build BusyBox as a static binary (no shared libs)

>>> Linux System Utilities
[*] mdev
[*] Support /etc/mdev.conf
[*] Support command execution at device addition/removal


[2.設定檔]

在設定檔,首先要更改初始化的script;然後更改/etc/mdev.conf
========
 init script
========
根據busybox說明文件(參考文獻1),需要在初始化過程執行script中加入底下設定!
Here's a typical code snippet from the init script:
[0] mount -t proc proc /proc
[1] mount -t sysfs sysfs /sys
[2] echo /sbin/mdev > /proc/sys/kernel/hotplug
[3] mdev -s

Alternatively, without procfs the above becomes:
[1] mount -t sysfs sysfs /sys
[2] sysctl -w kernel.hotplug=/sbin/mdev
[3] mdev -s


Of course, a more "full" setup would entail executing this before the previous
code snippet:
[4] mount -t tmpfs -o size=64k,mode=0755 tmpfs /dev
[5] mkdir /dev/pts
[6] mount -t devpts devpts /dev/pts

我的範例:/squashfs_init (我的embedded system根目錄下的init)
#!/bin/busybox ash
echo "run squashfs_init"
/bin/busybox mount -t tmpfs -o mode=0755 tmpfs /dev
/bin/busybox mount -t tmpfs -o mode=0777 tmpfs /tmp
/bin/busybox mount -t tmpfs -o mode=0755 tmpfs /var
/bin/busybox mount -t tmpfs -o mode=0755 tmpfs /bin
/bin/busybox mount -t tmpfs -o mode=0755 tmpfs /usr
/bin/busybox mount -t tmpfs -o mode=0755 tmpfs /sbin

/bin/busybox mkdir -p /var/run
/bin/busybox mkdir -p /var/locks

/bin/busybox mkdir -p /dev/sys
/bin/busybox mkdir -p /dev/pts
/bin/busybox mkdir -p /dev/shm
/bin/busybox mkdir -p /usr/bin
/bin/busybox mkdir -p /usr/sbin
/bin/busybox mount -t proc   proc   /proc
/bin/busybox mount -t devpts devpts /dev/pts

/bin/busybox mount -t sysfs sysfs /sys
# Populate /dev according to /sys
#echo /etc/dt_sd.sh  > /proc/sys/kernel/hotplug
/bin/busybox --install -s
/bin/echo /sbin/mdev  > /proc/sys/kernel/hotplug
/sbin/mdev -s
ln -sf /bin/busybox /bin/linuxrc
ln -s /bin/wpa_supplicant  /bin/wpa_supplicant
ln -s /bin/wpa_cli /bin/wpa_cli
/bin/linuxrc
exec /sbin/init "$@" </dev/console >/dev/console 2>&1



<note1> /bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev使用event來實作熱插拔動作(hotplug),上述這個設定會改變Linux kernel中的
event_helper 變數;當熱插拔動作發生時,Linux kernel會呼叫event_helper所指的user mode程式;
如此mdev便會被執行並判斷哪一個裝置發生熱插拔,並且mdev會根據mdev.conf執行內含的command.所以我們只要將對應的動作告訴mdev.conf,它就會完成我們想要完成的熱插拔動作.

=========
made.conf
=========
根據busybox說明文件(參考文獻1),檔案format如下:
<device regex> <uid>:<gid> <permissions> [=path] [@|$|*<command>]
    or
<device regex> <uid>:<gid> <permissions> [>path] [@|$|*<command>]
    or
<device regex> <uid>:<gid> <permissions> [!] [@|$|*<command>]

我的範例:/etc/mdev.conf

sd[a-z][0-9] 0:0 660  */etc/init.d/automount.sh
mmcblk[0-9]p[0-9] 0:0 660 */etc/init.d/automount.sh


<note>當熱插拔事件發生,mdev便會根據mdev.conf敘述進而執行automount.sh

我的範例:/etc/init.d/automount.sh
#!/bin/sh 

/bin/touch /var/plog

if [ "$MDEV" == "" ]; then
   echo "automount unknow error!" >> /var/plog
   exit 1
elif [ "$MDEV" == "mmcblk0p1" ]; then
    mmtype=sdcard
elif [ "$MDEV" == "sda1" ]; then 
    mmtype=usb
else
   echo "automount unknow dev:" >> /var/plog
   echo $MDEV >> /var/plog
   exit 1
fi

echo $mmtype >> /var/plog

case "$ACTION" in  
    add|"") 
       echo “Add device $MDEV>> /var/plog
       mount -t vfat /dev/$MDEV /mnt/$mmtype
        ;;  
    remove) 
       echo “remove device $MDEV>> /var/plog 
       umount /mnt/$mmtype
       ;;  
esac


<note1>由於event_helper將輸出轉向至/dev/null,所以我建立一個plog;將輸出全部丟往plog.

<note2> ACTION/MDEV/SUBSYSTEM :是event_helper 參數.


ACTION: add / remove
MDEV: sda1 / mmcblk0p1 ...SUBSYSTEM: block /mmc /drivers /queues /module /ftgpio_pdp /misc /platform /i2C...

以上,熱插拔自動掛載已經完成;接下來要談談發生熱插拔uevent_helper流程!


[3.程式流程]

當熱插拔(hotplug)發生時;kernel會送一個event,是由底下kernel程式負責:
/*./lib/kobject_uevent.c*/

int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
               char *envp_ext[])
{ ...

}


程式分析當下熱插拔是由哪一個subsystem發生;發生什麼事情;並將熱插拔事件所有參數搜集後呼叫call_usermodehelper.


   
    subsystem = uevent_ops->name(kset, kobj); 
...
    retval = add_uevent_var(env, "ACTION=%s", action_string);
    if (retval)
        goto exit;
    retval = add_uevent_var(env, "DEVPATH=%s", devpath);
    if (retval)
        goto exit;
    retval = add_uevent_var(env, "SUBSYSTEM=%s", subsystem);
    if (retail)
        goto exit;
...
    retval = call_usermodehelper(argv[0], argv,
                         env->envp, UMH_WAIT_EXEC);


...


/*./include/linux/kmod.h*/
call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait)
{
     return call_usermodehelper_fns(path, argv, envp, wait,
                        NULL, NULL, NULL);
}


接著經過一些work queue初始化過程;程式呼叫如下:

呼叫>> ____call_usermodehelper(void *data)                // ./kernel/kmod.c

呼叫>> kernel_execve( )                                                  //./arch/arm/kernel/sys_arm.c
int kernel_execve(const char *filename,
            const char *const argv[],
            const char *const envp[])
{
...
    ret = do_execve(filename,
              (const char __user *const __user *)argv,
              (const char __user *const __user *)envp, &regs);
...

}


呼叫>> do_execve_common(  )                                        /* ./fs/exec.c */
static int do_execve_common(const char *filename,
                 struct user_arg_ptr argv,
                 struct user_arg_ptr envy,
                 struct pt_regs *regs)
{
...

}

以上!

[參考文獻]
1. made.txt


Buildroot - 打造Embedded Linux 工作環境

Buildroot for ARM


Buildroot 是一套用來打造 Embedded Linux System工具, 可以在此平台上編譯產生不同系統的Root File System, Toolchain。

打造工作環境:Embedded Linux for ARM

1. 下載Buildroot
     官方網站: https://buildroot.org/download.html

      下載檔案:buildroot-2012.11.1.tar.bz2 / buildroot-2012.11.1.tar.gz

2. 解壓縮
     $tar zxvf buildroot-2012.11.1.tar.gz
2.1安裝其它package

EX:     [GM8138S install package: 64bit ubuntu]
$ sudo apt-get install g++

$ sudo apt-get install lib32z1-dev //compression library - 32 bit runtime

$ sudo apt-get install lib32z1
$ sudo apt-get install libncurses5-dev //shared libraries for terminal handling
$ sudo apt-get install libncurses5
$ sudo apt-get install bison //YACC-compatible parser generator - development library
$ sudo apt-get install flex //A fast lexical analyzer generator.
$ sudo apt-get install texinfo //Documentation system for on-line information and printed output

EX:     [GM8138S install package: 32bit ubuntu]
$ sudo apt-get install g++
$ sudo apt-get install bison
$ sudo apt-get install flex
$ sudo apt-get install texinfo


3. 設定組態
  
      $ make menuconfig
    #組態選擇
    (1)選擇 arm
Target Architecture (arm)  ---> 
    (2)選擇 generic_arm
Target Architecture Variant (generic_arm)  ---> 
    (3)選擇 EABI
Target ABI (EABI)  --->

   ABI:  application binary interface
OABI: old application binary interface
    (4)選擇 Linux kernel 3.2 / busybox 1.19.x/ binutils 2.21.1 / uClibc 0.9.32.x /gcc 4.6.4 


    $ make
    $ ls -al output/                             //編譯成功輸出於output folder
   
   

[Note ***]
   #if 編譯錯誤1:
   buildroot You may have to install 'g++' on your build machine
   
   #[解決1] 安裝上述提示軟體套件:
   $ sudo apt-get install g++
   $ sudo apt-get install texinfo
   $ sudo apt-get install unzip

  #if 編譯錯誤2: ./output/build/host-m4-1.4.16/lib/stdio.in.h

In file included from clean-temp.h:22:0,
                 from clean-temp.c:23:
./stdio.h:477:1: error: 'gets' undeclared here (not in a function)
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
 ^
mv -f .deps/c-stack.Tpo .deps/c-stack.Po
/usr/bin/gcc -std=gnu99  -I.     -O2 -I/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/host/include -I/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/host/usr/include -MT close-hook.o -MD -MP -MF .deps/close-hook.Tpo -c -o close-hook.o close-hook.c
mv -f .deps/close-hook.Tpo .deps/close-hook.Po
/usr/bin/gcc -std=gnu99  -I.     -O2 -I/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/host/include -I/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/host/usr/include -MT execute.o -MD -MP -MF .deps/execute.Tpo -c -o execute.o execute.c
make[4]: *** [clean-temp.o] Error 1
make[4]: *** Waiting for unfinished jobs....
mv -f .deps/execute.Tpo .deps/execute.Po

   #[解決2]patch file下:
   +diff -purN host-m4-1.4.16.orig/lib/stdio.in.h host-m4-1.4.16/lib/stdio.in.h
+--- host-m4-1.4.16.orig/lib/stdio.in.h 2012-07-21 19:11:40.196541826 +0200
++++ host-m4-1.4.16/lib/stdio.in.h 2012-07-21 20:46:05.405850751 +0200
+@@ -162,7 +162,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+ #undef gets
++#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
++#endif

  #if 編譯錯誤3: ./output/build/host-autoconf-2.65/doc/autoconf.texi 
conftest.c:14625: must be after `@defmac' to use `@defmacx'
make[3]: *** [autoconf.info] Error 1
make[3]: Leaving directory `/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/build/host-autoconf-2.65/doc'
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory `/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/build/host-autoconf-2.65'
make[1]: *** [install] Error 2

 #[解決3]patch file下:
--- autoconf-2.65/doc/autoconf.texi 2009-11-05 10:42:15.000000000 +0800
+++ autoconf-2.65/doc/autoconf.texi.new 2013-05-28 05:41:09.243770263 +0800
@@ -15,7 +15,7 @@
 @c The ARG is an optional argument.  To be used for macro arguments in
 @c their documentation (@defmac).
 @macro ovar{varname}
-@r{[}@var{\varname\}@r{]}@c
+@r{[}@var{\varname\}@r{]}
 @end macro
 @c @dvar(ARG, DEFAULT)
@@ -23,7 +23,7 @@
 @c The ARG is an optional argument, defaulting to DEFAULT.  To be used
 @c for macro arguments in their documentation (@defmac).
 @macro dvar{varname, default}
-@r{[}@var{\varname\} = @samp{\default\}@r{]}@c
+@r{[}@var{\varname\} = @samp{\default\}@r{]}
 @end macro

以上!


2016年5月30日 星期一

Ubuntu 將語系由中文改為英文

Ubuntu 將語系由中文改為英文



Step 1. 修改設定檔:

# vim /var/lib/locales/supported.d/local


將en_US.UTF-8 UTF-8放在第一列,
en_US.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8



Step 2. 修改設定檔:

# vim /etc/default/locale 


將相關字串放在最前面如下,

LANG="en_US.UTF-8"
LANGUAGE="en_US:en"


Step 3. 重新開機

#reboot


以上!



2016年5月27日 星期五

解決MT7620A "squashfs3.2-r2" 編譯問題


解決MT7620A "squashfs3.2-r2" 編譯問題

SDK Version: 4.3.0.0

編譯問題:

問題1.

cc   mksquashfs.o read_fs.o sort.o  -lz -L/home/paddy/workspace/project/mediatek/apsoc/RT288x_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_Alone -L/home/paddy/workspace/project/mediatek/apsoc/RT288x_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_C -lpthread -lunlzma_r -llzma_r -lstdc++  -o mksquashfs
/usr/bin/ld: mksquashfs.o: undefined reference to symbol 'log10@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [mksquashfs] Error 1
make[1]: Leaving directory `/home/paddy/workspace/project/mediatek/apsoc/RT288x_SDK/toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools'

make: *** [all] Error 2

解決: 在mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools/Makefile中增加 -lm

 24 mksquashfs: LDLIBS += -lpthread -lunlzma_r -llzma_r -lstdc++ 
 25 mksquashfs: mksquashfs.o read_fs.o sort.o
 26 


修改成
 24 mksquashfs: LDLIBS += -lpthread -lunlzma_r -llzma_r -lstdc++ -lm
 25 mksquashfs: mksquashfs.o read_fs.o sort.o
 26 



問題2.

cc   unsquashfs.o  -lz -L/home/paddy/workspace/project/mediatek/apsoc/RT288x_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_Alone -L/home/paddy/workspace/project/mediatek/apsoc/RT288x_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_C -lunlzma -o unsquashfs
/home/paddy/workspace/project/mediatek/apsoc/RT288x_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_C/libunlzma.a(uncomp.o): In function `sqlzma_un':
uncomp.c:(.text+0x4b): 未定義參考到「inflateReset」
uncomp.c:(.text+0x8c): 未定義參考到「inflate」
uncomp.c:(.text+0x180): 未定義參考到「zError」
/home/paddy/workspace/project/mediatek/apsoc/RT288x_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_C/libunlzma.a(uncomp.o): In function `sqlzma_init':
uncomp.c:(.text+0x3a3): 未定義參考到「inflateInit_」
collect2: error: ld returned 1 exit status
make[1]: *** [unsquashfs] Error 1
make[1]: Leaving directory `/home/paddy/workspace/project/mediatek/apsoc/RT288x_SDK/toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools'
make: *** [all] Error 2

解決: 在mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools/Makefile中增加 -lz

 30 
 31 unsquashfs: LDLIBS += -lunlzma

 32 unsquashfs: unsquashfs.o


修改成

 30 
 31 unsquashfs: LDLIBS += -lunlzma -lz

 32 unsquashfs: unsquashfs.o



以上!



MT7620A 編譯問題:mksquashfs


MT7620A 編譯問題:mksquashfs


問題1.  liblzma.so.0: cannot open shared object file: No such file ...


# update version info
echo ""WM102A"-0.0.4 (Beta, Build 64321.435)" > /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version
LC_ALL=C date -u >> /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version
mkdir -p /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/opt
cp -af /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/opt/version
/home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/tools/mksquashfs: error while loading shared libraries: liblzma.so.0: cannot open shared object file: No such file or directory
make[1]: *** [platform_rt7620-image] Error 127
make[1]: Leaving directory `/home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336'
make: *** [target] Error 2

解決:
1.downlod xz-5.0.3.tar.bz2
2. 解壓縮:#tar jxvf xz-5.0.3.tar.bz2
3. #cd xz-5.0.3
4. #make
5. copy liblzma.so.5.0.3 至 /opt/buildroot-gcc342/lib
6.#cd  /opt/buildroot-gcc342/lib
7.#ln -s lib liblzma.so.5.0.3  liblzma.so
8.#ln -s lib liblzma.so.5.0.3  liblzma.so.0



問題2. liblzma.so.0: wrong ELF class: ELFCLASS64


# update version info

echo ""WM102A"-0.0.4 (Beta, Build 64331.424)" > /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version
LC_ALL=C date -u >> /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version
mkdir -p /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/opt
cp -af /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/opt/version
/home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/tools/mksquashfs: error while loading shared libraries: liblzma.so.0: wrong ELF class: ELFCLASS64
make[1]: *** [platform_rt7620-image] Error 127
make[1]: Leaving directory `/home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336'
make: *** [target] Error 2


解決:重新編譯 squashfs4.2.tar.gz
1. download squashfs4.2.tar.gz
2. #tar zxvf   squashfs4.2.tar.gz
3. #cd  squashfs4.2/squashfs-tools
4. #vi Makefile (問題3 需要修改)

 GZIP_SUPPORT = 1
 19 
 20 ########### Building XZ support #############
 21 #
 22 # LZMA2 compression.
 23 #
 24 # XZ Utils liblzma (http://tukaani.org/xz/) is supported
 25 #
 26 # To build using XZ Utils liblzma - install the library and uncomment
 27 # the XZ_SUPPORT line below.
 28 #
 29 XZ_SUPPORT = 1


5.#make
6.將編譯好的mksquashfs 取代舊的
#cp mksquashfs  /opt/buildroot-gcc342/bin/mksquashfs_lzma-4.2

問題3 mksquashfs compressor xz is not supported

# update version info
echo ""WM102A"-0.0.4 (Beta, Build 64331.424)" > /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version
LC_ALL=C date -u >> /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version
mkdir -p /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/opt
cp -af /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/etc/version /home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/build/rootfs/opt/version
/home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336/tools/mksquashfs: invalid option
mksquashfs compressor "xz" is not supported
make[1]: *** [platform_rt7620-image] Error 127
make[1]: Leaving directory `/home/paddy/workspace/project/mediatek/apsoc2/WM102A-0.0.4.10336'
make: *** [target] Error 2

解決:請看問題2.


以上!

2016年5月23日 星期一

編譯問題解決: MT7620A Uboot


解決MT7620A "Uboot" 編譯問題

SDK Version: 4.3.0.0

編譯問題:ERROR: ... mkimage: invalid entry point -n


進入Uboot路徑:執行make最後要產生boot.img時產生錯誤.


./tools/mkimage -A mips -T standalone -C none \
-a 0x80200000 -e  \
-n "SPI Flash Image" \
-r DDR2 -s 16 -t 64 -u 32 \
-y 0xFF -z 0xFF -w 0xFF -d uboot.bin uboot.img
./tools/mkimage: invalid entry point -n

make: *** [uboot.img] Error 1




解決方法:


        此一錯誤是由於系統語言不是英文導致,請進入Uboot路徑;編輯Makefile;找到
mkimage ...-e $(shell readelf -h u-boot | grep "Entry" | awk '{print $$4}')                        
這一行,這就是出錯的地方.
        看看出什麼錯誤;在command line下執行: #readelf -h u-boot
Uboot# readelf -h u-boot
ELF 檔頭:
  魔術位元組:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  類別:                              ELF32
  資料:                              2 的補數,小尾序(little endian)
  版本:                              1 (current)
  OS/ABI:                            UNIX - System V
  ABI 版本:                          0
  類型:                              EXEC (可執行檔案)
  系統架構:                          MIPS R3000
  版本:                              0x1
  進入點位址:               0x80200000
  程式標頭起點:          52 (檔案內之位元組)
  區段標頭起點:          217472 (檔案內之位元組)
  旗標:             0x50001007, noreorder, pic, cpic, o32, mips32
  此標頭的大小:       52 (位元組)
  程式標頭大小:       32 (位元組)
  Number of program headers:         2
  區段標頭大小:         40 (位元組)
  區段標頭數量:         153

  字串表索引區段標頭: 150

原來是Makefile找不到”Entry“字串;將字串改成“進入點位址”再執行一次:


Uboot# readelf -h u-boot| grep '進入點位址'
  進入點位址:               0x80200000


終於找到進入點位址, 接著修改分析參數.
 awk '{print $$4}'

改成

 awk '{print $$2}'



重新編譯;終於成功了:


./tools/mkimage -A mips -T standalone -C none \
-a 0x80200000 -e 0x80200000 \
-n "SPI Flash Image" \
-r DDR2 -s 16 -t 64 -u 32 \
-y 0xFF -z 0xFF -w 0xFF -d uboot.bin uboot.img
Image Name:   SPI Flas
Created:      Mon May 23 15:33:25 2016
Image Type:   MIPS Linux Standalone Program (uncompressed)
Data Size:    88104 Bytes = 86.04 kB = 0.08 MB
Load Address: 0x80200000
Entry Point:  0x80200000
DRAM Parameter: 29 (Parm0=0 Parm1=0)

===============<<IMPORTANT>>==================
Notes:Uboot firmware in flash is uboot.img NOT uboot.bin

================================================



以上!