1、 控制器:MT7620(A9内核)
1、开发环境:Ubuntu12.04
2、SDK内核包:MT7620 SDK软件开发包(MediaTek_ApSoC_SDK_4320_20150414.tar.bz2)
3、内核版本:linux-2.6.36.x
4、Uboot版本:U-Boot 1.1.3
采用Ralink的SDK开发包,编译出的内核,以前烧录到MT7620上,可以正常运行。后来,编译出的内核,烧录之后,开发板反复重启,一直在不停的Uboot,陷入死循环,无法加载内核。
错误提示:
stream version is not supported, outSize = FFFFFFFF
LZMA ERROR 1 - must RESET board to recover
本文目的在于解决这个问题。
参考文档:《MTK_APSoC_SDK_User_Manual.pdf》
文档下载路径:http://download.csdn.net/detail/xhoufei2010/9478004
U-Boot 1.1.3 (Aug 31 2015 - 17:33:25)
Board: Ralink APSoC DRAM: 256 MB
relocate_code Pointer at: 8ffb8000
enable ephy clock...done. rf reg 29 = 5
SSC disabled.
******************************
Software System Reset Occurred
******************************
spi_wait_nsec: 29
spi device id: 20 ba 20 10 44 (ba201044)
find flash: MT25QL512AB
raspi_read: from:30000 len:1000
raspi_read: from:30000 len:1000
============================================
Ralink UBoot Version: 4.3.0.0
--------------------------------------------
ASIC 7620_MP (Port5<->None)
DRAM component: 2048 Mbits DDR, width 16
DRAM bus: 16 bit
Total memory: 256 MBytes
Flash component: 16 MBytes NOR Flash
Date:Aug 31 2015 Time:17:33:25
============================================
icache: sets:512, ways:4, linesz:32 ,total:65536
dcache: sets:256, ways:4, linesz:32 ,total:32768
##### The CPU freq = 580 MHZ ####
estimate memory size =256 Mbytes
raspi_read: from:50000 len:40
raspi_read: from:850000 len:40
=================================================
Check image validation:
Image1 Header Magic Number --> OK
Image2 Header Magic Number --> OK
Image1 Header Checksum --> OK
Image2 Header Checksum --> OK
Image1 Data Checksum --> raspi_read: from:50040 len:6634b2
OK
Image2 Data Checksum --> raspi_read: from:850040 len:663d95
OK
Image1 Stable Flag --> Stable
Image1 Try Counter --> 3
Image1: OK Image2: OK
=================================================
Please choose the operation:
1: Load system code to SDRAM via TFTP.
2: Load system code then write to Flash via TFTP.
3: Boot system code via Flash (default).
4: Entr boot command line interface.
7: Load Boot Loader code then write to Flash via Serial.
9: Load Boot Loader code then write to Flash via TFTP.
0
3: System Boot system code via Flash.
## Booting image at bc050000 ...
raspi_read: from:50000 len:40
Image Name: Linux Kernel Image
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 6698162 Bytes = 6.4 MB
Load Address: 80000000
Entry Point: 8000c150
raspi_read: from:50040 len:6634b2
Verifying Checksum ... OK
Uncompressing Kernel Image ...
stream version is not supported, outSize = FFFFFFFF
LZMA ERROR 1 - must RESET board to recover
U-Boot 1.1.3 (Aug 31 2015 - 17:33:25)
Board: Ralink APSoC DRAM: 256 MB
relocate_code Pointer at: 8ffb8000
enable ephy clock...done. rf reg 29 = 5
SSC disabled.
******************************
(1)由于Uboot可以正常启动,说明硬件的Flash无问题,从错误信息提示,可以看出,Uboot可以正常加载,但是Kernel 完全无法加载,说明无法从Uboot跳转到Kernel。
(2)对于Uboot加载内核,是通过解压内核文件,然后导入。从错误现象,设备不停的Uboot,说明解压有问题,如日志所提示。
内核的校验值无问题,出现问题的环节,在于解压内核镜像。
Verifying Checksum ... OK
Uncompressing Kernel Image ...
stream version is not supported, outSize = FFFFFFFF
LZMA ERROR 1 - must RESET board to recover
(3)从错误提示,可以看出,问题在于"LZMA"的解压出的问题。
LZMA ERROR 1 - must RESET board to recover
从Ralink官方的《MTK_APSoC_SDK_User_Manual.pdf》手册第44页和45页,章节“5.2 Install LZMA Utility”查看LZMA的工具安装。
原文如图4-1和4-2所示。
图4-1 安装LZMA
图4-2 设置内核镜像压缩方式
从文档中,可以看到提示:LZMA算法,并不会反向(向后)兼容,必须采用lzma如果版本4.32.0beta3工具压缩内核镜像,否则会出现解压问题。
Notes: lzma algorithm is not backward-compatible, so you have to use this lzma-4.32.0beta3 tool to
compress your kernel image otherwise you will encounter lzma decompression issue.
进入source/vendors/Ralink/MT7620/,查看Makefile,其中原版的Makefile,压缩方式的设置代码如下:
CUR_DIR = $(shell pwd)
COMP = lzma
image: mkimage
$(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -S $(ROOTDIR)/$(LINUXDIR)/vmlinux $(KERNELZ)
cd $(IMAGEDIR) ; rm -f $(KERNELZ).*; $(COMP) -9 -f -S .$(COMP) $(KERNELZ)
从代码可得知,压缩方式采用lzma,而且没有设置路径,直接就是Ubuntu系统安装的lzma版本和路径。
如果严格参考《MTK_APSoC_SDK_User_Manual.pdf》步骤操作,自然不会出问题。但是如果用户自己安装了新的lzma,且版本更高,则必然出现lzma版本不兼容问题。
在ubuntu下,输入命令“ lzma -V”查看系统lzma版本,如图4-3所示。
lzma -V
图4-3 查看系统lzma版本
Uboot采用的为"lzma-4.32.0beta3",内核镜像压缩的工具版本为“lzma5.2”,所以uboot无法兼容比它更新的版本5.2,所以导致uboot解压kernel 失败。
修改内核的makefile,使之lzma路径,采用绝对路径,指向“lzma-4.32.0beta3”版本。makefile的路径为“source/vendors/Ralink/MT7620/Makefile”
原始的makefile第8行
COMP = lzma
增加COMP_PATH宏定义,指向“lzma-4.32.0beta3”版本,本文章的工具编译后(本文4.3章节图4-1安装方法),安装的路径为:/opt/lzma-4.32.7/src/lzma,修改之后的makefile
COMP = lzma
COMP_PATH = /opt/lzma-4.32.7/src/lzma
将" $(COMP)"修改为“ $(COMP_PATH)/$(COMP)”,增加了绝对路径索引。
修改之前的makefile:
image: mkimage
$(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -S $(ROOTDIR)/$(LINUXDIR)/vmlinux $(KERNELZ)
cd $(IMAGEDIR) ; rm -f $(KERNELZ).*; $(COMP) -9 -f -S .$(COMP) $(KERNELZ)
修改之后的makefile:
image: mkimage
$(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -S $(ROOTDIR)/$(LINUXDIR)/vmlinux $(KERNELZ)
cd $(IMAGEDIR) ; rm -f $(KERNELZ).*; $(COMP_PATH)/$(COMP) -9 -f -S .$(COMP) $(KERNELZ)
将新编译的内核烧录至开发板,开机启动,可以正常的从uboot解压内核,并开启内核,日志如下,说明解决问题。
raspi_read: from:50040 len:663d95
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
No initrd
## Transferring control to Linux (at address 8000c150) ...
## Giving linux memsize in MB, 256
Starting kernel ...
怘fffxfffnux version 2.6.36 (root@wm-VirtualBox) (gcc version 4.6.3 (Buildroot 2012.11.1) ) #65 Fri Dec 4 12:17:11 CST 2015
The CPU feqenuce set to 580 MHz
MIPS CPU sleep mode enabled.
PCIE: bypass PCIe DLL.
PCIE: Elastic buffer control: Add