<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > eclipse調(diào)試arm裸機(jī)程序

          eclipse調(diào)試arm裸機(jī)程序

          作者: 時(shí)間:2016-11-19 來(lái)源:網(wǎng)絡(luò) 收藏

          一、集成開(kāi)發(fā)環(huán)境

          本文引用地址:http://www.ex-cimer.com/article/201611/318230.htm

          軟件部分:eclipse , GDB Server , Jlink軟件

          硬件部分:Jlink硬件

          準(zhǔn)備工作1:從SD/NOR Flash啟動(dòng),格式化nand flash

          準(zhǔn)備工作2:硬件連接

          1. Jlink連接

          2. 串口連接

          3.nand啟動(dòng)

          二、安裝GDB Server

          解壓:tar xvzf arm-linux-gdb-7.5.tar.gz

          進(jìn)入目錄:cd arm-linux-gdb-7.5

          編譯安裝:./build-all

          上面執(zhí)行好后,gdb工具就安裝好了,安裝在/opt/arm-linux-gdb

          為了方便使用,需要添加環(huán)境變量:vim /root/.bashrc

          在交叉編譯鏈的前面添加gdb的環(huán)境變量:

          export PATH=$PATH:/opt/arm-linux-gdb/bin/

          export PATH=$PATH:/usr/local/arm/4.3.2/bin/

          之后保存,退出。這就可以直接運(yùn)行arm-linux-gdb,如果不行的話則可能是添加錯(cuò)誤,或者需要注銷。

          問(wèn):為什么一定要添加到交叉編譯鏈之前呢?

          答:因?yàn)樵诮徊婢幾g鏈中也包含了arm-linux-gdb,linux系統(tǒng)會(huì)根據(jù)path環(huán)境變量的先后順序來(lái)尋找,我們需要找的是我們上面安裝的,而不是這里的(因?yàn)榘姹究赡懿粚?duì)),所以在添加環(huán)境變量的時(shí)候,一定要添加在交叉編譯鏈的前面。

          三、安裝Jlink軟件

          解壓:tar xvzf JLink_Linux_V434a.tgz

          進(jìn)入目錄:cd JLink_Linux_V434a

          庫(kù):cp -d libjlinkarm.so* /usr/lib -f

          :cp 45-jlink.rules /etc/udev/rules.d/

          上面四個(gè)命令執(zhí)行完之后,檢測(cè)是否能夠檢測(cè)到Jlink的連接:

          在虛擬機(jī)的下面,點(diǎn)擊顯示為Jlink相關(guān)的usb圖標(biāo),連接。

          執(zhí)行命令:./JLinkGDBServer

          如果也切順利的話,會(huì)顯示連接上的ARM核心為ARM11:

          四、安裝Eclipse軟件

          紅帽企業(yè)版6.3中默認(rèn)安裝了eclipse

          執(zhí)行:which eclipse 可以查看在哪個(gè)目錄下

          這個(gè)版本不適合,我們不能用,所以首先我們得卸載這個(gè),其實(shí)我們把查詢到的eclipse修改一個(gè)名字就好了,在查詢到的目錄執(zhí)行:mv eclipse eclipse-back即可。

          安裝自己的eclipse:

          解壓:tar zxvf eclipse-cpp-helios-SR2-linux-gtk.tar.gz

          進(jìn)入目錄:cd eclipse-cpp-helios-SR2-linux-gtk

          運(yùn)行程序:./eclipse

          這就啟動(dòng)eclipse了。

          然后選擇自己的工程目錄:

          配置eclipse:

          首先得安裝一個(gè)插件,這個(gè)插件是要通過(guò)網(wǎng)絡(luò)安裝的,所以linux必須能夠上網(wǎng)。

          安裝插件:點(diǎn)擊菜單欄的help -> install new software

          在Work with輸入插件位置:http://opensource.zylin.com/zylincdt,點(diǎn)擊add

          經(jīng)過(guò)一段時(shí)間,在下面的方框中顯示出找到的插件,點(diǎn)擊選中:

          點(diǎn)擊next;

          之后按照提示來(lái)。

          然后重啟:

          使用eclipse進(jìn)行開(kāi)發(fā)

          新建工程,選擇新建一個(gè)已存在源文件的工程:

          注意:這里的源文件目錄必須是在工作目錄下的另外一個(gè)目錄,比如工作目錄是"/home/S3-ARM/Part1/lesson1",那么【Existing Code Location】的目錄為不能和工作目錄相同,必須是別的目錄,或者是工作目錄下的一個(gè)子目錄,比如"/home/S3-ARM/Part1/lesson1/led/"或者是"/opt/led/"

          點(diǎn)擊finish。

          編譯項(xiàng)目:【Project】 -> 【Build All】

          注意:取消掉【Project】里面的自動(dòng)編譯【Build Automatically】

          配置調(diào)試器:【甲蟲(chóng)圖標(biāo)】 -> 【Debug Configurations】

          雙擊【Zylin Embedded debug】,出現(xiàn)如下界面:

          選中選項(xiàng)卡【main】

          在【C/C++ Application】中選擇要調(diào)試的項(xiàng)目,注意是選中 "xxx.elf" 文件:

          選中選項(xiàng)卡【Debugger】

          去掉【Stop on startup at:】選項(xiàng)

          將【GDB debugger:】修改成" arm-linux-gdb "

          選中選項(xiàng)卡【Commands】

          在【Initialize commands】中填入如下初始化指令:

          下面是初始化S3C6410處理器的初始化腳本

          1 # tiny6410_config 2 # connect to the J-Link gdb server 3 target remote localhost:2331 4 # Set JTAG speed to 30 kHz 5 monitor endian little 6 monitor speed 30 7 # Reset the target 8 monitor reset 9 monitor sleep 10 10 # 11 # CPU core initialization (to be done by user) 12 # 13 # Set the processor mode 14 monitor reg cpsr = 0xd3 15 #config MMU 16 #flush v3/v4 cache 17 monitor cp15 7, 7, 0, 0 = 0x0 18 #/* flush v4 TLB */ 19 monitor cp15 8, 7, 0, 0 = 0x0 20 #disable MMU stuff and caches 21 monitor cp15 1, 0, 0, 0 =0x1002 22 #Peri port setup 23 monitor cp15 15, 2, 0, 4 = 0x70013 24 #disable watchdog 25 monitor MemU32 0x7e004 = 0x00 26 monitor sleep 10 27 #disable interrupt 28 monitor MemU32 0x71214 = 0x00 29 monitor MemU32 0x71314 = 0x00 30 monitor MemU32 0x7120C = 0x00 31 monitor MemU32 0x7130C = 0x00 32 monitor MemU32 0x71200F00 = 0x00 33 monitor MemU32 0x71300F00 = 0x00 34 #set clock 35 monitor MemU32 0x7e00f900 = 0x0801e 36 monitor MemU32 0x7e00f = 0x0ffff 37 monitor MemU32 0x7e00f004 = 0x0ffff 38 monitor MemU32 0x7e00f020 = 0x01043310 39 monitor MemU32 0x7e00f00C = 0xc2150601 40 monitor MemU32 0x7e00f010 = 0xc2150601 41 monitor MemU32 0x7e00f024 = 0x03 42 monitor MemU32 0x7e00f014 = 0x00200102 43 monitor MemU32 0x7e00f018 = 0x00 44 monitor MemU32 0x7e00f01C = 0x14007 45 #config sdram 46 monitor MemU32 0x7e00f120 = 0x08 47 monitor MemU32 0x7e001004 = 0x04 48 monitor MemU32 0x7e001010 = 0x0040f 49 monitor MemU32 0x7e001014 = 0x06 50 monitor MemU32 0x7e001018 = 0x01 51 monitor MemU32 0x7e00101c = 0x02 52 monitor MemU32 0x7e001020 = 0x06 53 monitor MemU32 0x7e001024 = 0x0a 54 monitor MemU32 0x7e001028 = 0x0c 55 monitor MemU32 0x7e00102c = 0x0018f 56 monitor MemU32 0x7e001030 = 0x0c 57 monitor MemU32 0x7e001034 = 0x02 58 monitor MemU32 0x7e001038 = 0x02 59 monitor MemU32 0x7e00103c = 0x02 60 monitor MemU32 0x7e001040 = 0x02 61 monitor MemU32 0x7e001044 = 0x13 62 monitor MemU32 0x7e001048 = 0x13 63 monitor MemU32 0x7e00100C = 0x10012 64 monitor MemU32 0x7e00104C = 0x00b45 65 monitor MemU32 0x7e001200 = 0x150f8 66 monitor MemU32 0x7e001304 = 0x00 67 monitor MemU32 0x7e001008 = 0xc0 68 monitor MemU32 0x7e001008 = 0x00 69 monitor MemU32 0x7e001008 = 0x40 70 monitor MemU32 0x7e001008 = 0x40 71 monitor MemU32 0x7e001008 = 0xa0 72 monitor MemU32 0x7e001008 = 0x80032 73 monitor MemU32 0x7e001004 = 0x00 74 # Setup GDB for faster downloads 75 #set remote memory-write-packet-size 1024 76 set remote memory-write-packet-size 4096 77 set remote memory-write-packet-size fixed 78 monitor speed 12 79 break _start 80 load

          初始化2440的腳本內(nèi)容如下:

          1 # connect to the J-Link gdb server 2 target remote localhost:2331 3 # Set JTAG speed to 30 kHz 4 monitor endian little 5 monitor speed 30 6 # Reset the target 7 monitor reset 8 monitor sleep 10 9 # 10 # CPU core initialization (to be done by user) 11 # 12 # Set the processor mode 13 monitor reg cpsr = 0xd3 14 #config MMU 配置MMU 15 #flush v3/v4 cache 16 monitor cp15 7, 7, 0, 0 = 0x0 17 #/* flush v4 TLB 協(xié)處理器*/ 18 monitor cp15 8, 7, 0, 0 = 0x0 19 #disable MMU stuff and caches 20 monitor cp15 1, 0, 0, 0 =0x1002 21 #Peri port setup 22 monitor cp15 15, 2, 0, 4 = 0x70013 23 #disable watchdog kangear 關(guān)閉看門(mén)狗 24 monitor MemU32 0x53 = 0x00 25 monitor sleep 10 26 #disable interrupt kangear 關(guān)閉中斷 27 monitor MemU32 0x4A008 = 0xffffffff 28 monitor MemU32 0x4A01C = 0x7fff 29 #set clock 30 #initialize system clocks locktime register 31 monitor MemU32 0x4C = 0xFF 32 #initialize system clocks clock-divn register 33 monitor MemU32 0x4C014 = 0x5 #CLKDVIN_400_148 34 #initialize system clocks mpll register 35 monitor MemU32 0x4C004 = 0x7f021 #default clock 36 #config sdram 37 monitor MemU32 0x53 0x00 38 monitor MemU32 0x4A008 0xFFFFFFFF 39 monitor MemU32 0x4A01C 0x007FF 40 monitor MemU32 0x53 0x00 41 monitor MemU32 0x56050 0x055AA 42 monitor MemU32 0x4C014 0x07 43 monitor MemU32 0x4C 0x00FFFFFF 44 monitor MemU32 0x4C004 0x61012 45 monitor MemU32 0x4C008 0x40042 46 monitor MemU32 0x48 0x22120 47 monitor MemU32 0x48004 0x02F50 48 monitor MemU32 0x48008 0x00700 49 monitor MemU32 0x4800C 0x00700 50 monitor MemU32 0x48010 0x00700 51 monitor MemU32 0x48014 0x00700 52 monitor MemU32 0x48018 0x7FFFC 53 monitor MemU32 0x4801C 0x18005 54 monitor MemU32 0x48020 0x18005 55 monitor MemU32 0x48024 0x008E0459 56 monitor MemU32 0x48028 0x32 57 monitor MemU32 0x4802C 0x30 58 monitor MemU32 0x48030 0x30 59 # Setup GDB for faster downloads 60 #set remote memory-write-packet-size 1024 61 monitor speed auto 62 break _start 63 load

          初始化210的腳本內(nèi)容如下:

          1 # connect to the J-Link gdb server 2 target remote localhost:2331 3 # Set JTAG speed to 30 kHz 4 monitor endian little 5 monitor speed 30 6 # Reset the target 7 monitor reset 8 monitor sleep 10 9 # Setup GDB for faster downloads 10 #set remote memory-write-packet-size 1024 11 monitor speed auto 12 break main 13 load

          經(jīng)過(guò)上面的設(shè)置之后,就可以開(kāi)始調(diào)試了

          五、開(kāi)始調(diào)試

          注意:用eclipse進(jìn)行調(diào)試的時(shí)候必須保證JLinkGDBServer同時(shí)在運(yùn)行

          否則會(huì)出現(xiàn)類似下面的錯(cuò)誤:

          保證JLinkGDBServer運(yùn)行起來(lái)了,然后點(diǎn)擊【小甲殼蟲(chóng)】 -> 項(xiàng)目名

          準(zhǔn)備進(jìn)入調(diào)試界面

          選擇【yes】

          調(diào)試界面如下:

          點(diǎn)擊【F5】是"Step Into"

          【F6】是"Step Over"

          等等,這里可以查看寄存器的值,沒(méi)存的值等等。

          一步一步下去可以看到開(kāi)發(fā)板上的led點(diǎn)亮了。



          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();