Eclipse+Jlink gdbSever調試mini6410 uboot

來源:互聯網
上載者:User

Eclipse+Jlink gdbSever調試mini6410 uboot
由於mini6410出廠時硬體上不支援模擬器,需要進行修改,具體請看
RVDS2.2 + jlink v8調試 mini6410(http://www.towoo.net/forum.php?mod=viewthread&tid=245&page=1&extra=#pid267)
對於Eclipse圖形化方法調試,網上已經有很多的文章,本文也是從中得到很多,只是把調試用到6410上而已. 
把軟體清單列一下:
1、 Eclipse-SDK-3.6-win32        http://www.eclipse.org/downloads/
2、 Cdt-master-7.0          http://www.eclipse.org/cdt/downloads.php
3、 Zylin外掛程式           http://www.zylin.com/zylincdt/
4、 yagarto-tools-20100703-setup         http://www.yagarto.de/#download
5、 yagarto-bu-2.20.1_gcc-4.5.1-c-gdb-7.1_eabi    http://www.yagarto.de/#download
6、 JLinkARM_V410i        http://www.segger.com/cms/jlink-software.html
注意: 對於Jlink的軟體包,在V4.10下測試。高版本不一定支援的好。
正確串連上mini6410開發板和Jlink後,開啟gdb server,可以正確讀出ARM11.狀態是waiting for connection.
 
本文就該調試環境來調試uboot來簡單介紹一下。我嘗試在 windows下編譯uboot沒有成功, 所以這裡用Linux環境下編譯得到的ELF格式的uboot。把已經編譯好的elf格式的uboot copy到windows下的uboot原代碼檔案夾裡,後面匯入的時候方便。另外6410的uboot用到了MMU,為了簡單起見,把MMU關掉,可以在/include/configs/mini6410.h裡找到這個宏定義開關#define CONFIG_ENABLE_MMU,注釋掉即可。另外還需要修改TEXT_BASE的值,定義在/board/samsung/mini6410/Config.mk,把0xc7e00000修改為0x57e00000.首先建立一個C project, 如所示。
 
然後會出現下面的畫面, 這裡注意的是選擇 Makefile project->Empty Project->Other Toolchain.點擊完成。
 


 
點擊Next,出現,這裡點擊Browse找到uboot的原始碼,把需要的原始碼選中匯入(本文調試基於mini6410的uboot),要不然會出現一點麻煩,多試幾次就可以知道哪些用不到了。
 
點擊完成後,原始碼已經匯入了。
 
下面需要設定一下eclipse,使之能夠編譯調試基於arm的程式。用於設定交叉編譯器arm-none-eabi-gcc.exe.由於本文調試uboot,也可以不設定,但為了以後方便,還是設定一下吧。
 
類似,可以根據設定自己的開發環境。
 
下面設定調試環境,也是本文的核心部分。點擊Run->Debug Configurations,
 
出現:
 
在這裡,我們用的是zylin Embedded debug(Native), 在Main選項卡中,C/C++ Application是重要的選項,就是選中我們需要調試的ELF格式的uboot.

下面設定Debugger選項卡,把GDB debugger設定為arm-none-eabi-gdb.exe.就是我們以後調試用的交叉調試器。把GDB command file: 清空。
 

下面設定Command選項卡,在’Initialize’ Command 添加初始化mini6410的代碼,這個代碼是符合Jlink gdbserver的文法結構的。
 
詳細的代碼如下,做了簡單的注釋。
# connect to the J-Link gdb server
target remote localhost:2331
# Set JTAG speed to 30 kHz
monitor endian little
monitor speed 30
# Reset the target
monitor reset
monitor sleep 10
#
# CPU core initialization (to be done by user)
#
# Set the processor mode
monitor reg cpsr = 0xd3
#config MMU
#flush v3/v4 cache
monitor cp15 7, 7, 0, 0 = 0x0
#/* flush v4 TLB */
monitor cp15 8, 7, 0, 0 = 0x0
#disable MMU stuff and caches
monitor cp15 1, 0, 0, 0 =0x1002
#Peri port setup
monitor cp15 15, 2, 0, 4 = 0x70000013
#disable watchdog
monitor MemU32 0x7e004000  =  0x00000000
monitor sleep 10
#disable interrupt
monitor MemU32 0x71200014  =  0x00000000
monitor MemU32 0x71300014  =  0x00000000
monitor MemU32 0x7120000C  =  0x00000000
monitor MemU32 0x7130000C  =  0x00000000
monitor MemU32 0x71200F00  =  0x00000000
monitor MemU32 0x71300F00  =  0x00000000
#set clock 
monitor MemU32 0x7e00f900  =  0x0000801e
monitor MemU32 0x7e00f000  =  0x0000ffff
monitor MemU32 0x7e00f004  =  0x0000ffff
monitor MemU32 0x7e00f020  =  0x01043310
monitor MemU32 0x7e00f00C  =  0xc2150601
monitor MemU32 0x7e00f010  =  0xc2150601
monitor MemU32 0x7e00f024  =  0x00000003
monitor MemU32 0x7e00f014  =  0x00200102
monitor MemU32 0x7e00f018  =  0x00000000
monitor MemU32 0x7e00f01C  =  0x14000007
#config sdram
monitor MemU32 0x7e00f120  =  0x00000008
monitor MemU32 0x7e001004  =  0x00000004
monitor MemU32 0x7e001010  =  0x0000040f
monitor MemU32 0x7e001014  =  0x00000006
monitor MemU32 0x7e001018  =  0x00000001
monitor MemU32 0x7e00101c  =  0x00000002
monitor MemU32 0x7e001020  =  0x00000006
monitor MemU32 0x7e001024  =  0x0000000a
monitor MemU32 0x7e001028  =  0x0000000c
monitor MemU32 0x7e00102c  =  0x0000018f
monitor MemU32 0x7e001030  =  0x0000000c
monitor MemU32 0x7e001034  =  0x00000002
monitor MemU32 0x7e001038  =  0x00000002
monitor MemU32 0x7e00103c  =  0x00000002
monitor MemU32 0x7e001040  =  0x00000002
monitor MemU32 0x7e001044  =  0x00000013
monitor MemU32 0x7e001048  =  0x00000013
monitor MemU32 0x7e00100C  =  0x00010012
monitor MemU32 0x7e00104C  =  0x00000b45
monitor MemU32 0x7e001200  =  0x000150f8
monitor MemU32 0x7e001304  =  0x00000000
monitor MemU32 0x7e001008  =  0x000c0000
monitor MemU32 0x7e001008  =  0x00000000
monitor MemU32 0x7e001008  =  0x00040000
monitor MemU32 0x7e001008  =  0x00040000
monitor MemU32 0x7e001008  =  0x000a0000
monitor MemU32 0x7e001008  =  0x00080032
monitor MemU32 0x7e001004  =  0x00000000
# Setup GDB for faster downloads
#set remote memory-write-packet-size 1024
set remote memory-write-packet-size 4096
set remote memory-write-packet-size fixed
monitor speed 12000
break start_armboot
load
continue

點擊Debug按鈕,uboot download完成以後,就可以像其他的調試器一樣,設定斷點,單步調試之類的,大家可以嘗試一下,一起進步。
 

轉載:
http://www.towoo.net/forum.php?mod=viewthread&tid=398&page=1&extra=#pid420

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.