eclipse?

eclipse arm裸機開發環境.

方法/步驟

軟件eclipse , GDB Server , Jlink軟件

硬件 Jlink硬件

準備工作1:從SD/NOR Flash啟動,格式化nand flash

準備工作2:硬件連接

1. Jlink連接

2. 串口連接

3. nand啟動

eclipse arm裸機開發環境

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

進入目錄:cd arm-linux-gdb-7.5

編譯安裝:./build-all

上面執行好後,gdb工具就安裝好了,安裝在/opt/arm-linux-gdb

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

在交叉編譯鏈的前面添加gdb的環境變量:

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

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

之後保存,退出。這就可以直接運行arm-linux-gdb,如果不行的話則可能是添加錯誤,或者需要註銷。

eclipse arm裸機開發環境

解壓:tar xvzf JLink_Linux_V434a.tgz

進入目錄:cd JLink_Linux_V434a

複製庫:cp -d libjlinkarm.so* /usr/lib -f

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

上面四個命令執行完之後,檢測是否能夠檢測到Jlink的連接:

在虛擬機的下面,點擊顯示為Jlink相關的usb圖標,連接。

執行命令:./JLinkGDBServer

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

eclipse arm裸機開發環境

安裝eclipse:

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

進入目錄:cd eclipse-cpp-helios-SR2-linux-gtk

運行程序:./eclipse

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

eclipse arm裸機開發環境

eclipse arm裸機開發環境

首先得安裝一個插件

點菜單欄的help -> install new software

在Work with輸入插件位置: ,點擊add

等一段時間,找到的插件,點擊選中:

eclipse arm裸機開發環境

點擊next;

eclipse arm裸機開發環境

之後按照提示來。

然後重啟:

eclipse arm裸機開發環境

使用eclipse進行開發

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

eclipse arm裸機開發環境

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

eclipse arm裸機開發環境

點擊finish。

編譯項目:Project ---Build AlL

注意:取消掉【Project】裡面的自動編譯【Build Automatically】

eclipse arm裸機開發環境

配置調試器:甲蟲圖---Debug Configurations

eclipse arm裸機開發環境

eclipse arm裸機開發環境

雙擊Zylin Embedded debu,出現下面界面:

eclipse arm裸機開發環境

選中選項卡main

在C/C++ Application中選要調試的項目,注意是選中 "xxx.elf" 文件:

eclipse arm裸機開發環境

選中選項卡Debugger

去掉Stop on startup at:選項

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

eclipse arm裸機開發環境

選中選項卡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 1010 #11 # CPU core initialization (to be done by user)12 #13 # Set the processor mode14 monitor reg cpsr = 0xd315 #config MMU16 #flush v3/v4 cache17 monitor cp15 7, 7, 0, 0 = 0x018 #/* flush v4 TLB */19 monitor cp15 8, 7, 0, 0 = 0x020 #disable MMU stuff and caches21 monitor cp15 1, 0, 0, 0 =0x100222 #Peri port setup23 monitor cp15 15, 2, 0, 4 = 0x7000001324 #disable watchdog25 monitor MemU32 0x7e004000 = 0x0000000026 monitor sleep 1027 #disable interrupt28 monitor MemU32 0x71200014 = 0x0000000029 monitor MemU32 0x71300014 = 0x0000000030 monitor MemU32 0x7120000C = 0x0000000031 monitor MemU32 0x7130000C = 0x0000000032 monitor MemU32 0x71200F00 = 0x0000000033 monitor MemU32 0x71300F00 = 0x0000000034 #set clock35 monitor MemU32 0x7e00f900 = 0x0000801e36 monitor MemU32 0x7e00f000 = 0x0000ffff37 monitor MemU32 0x7e00f004 = 0x0000ffff38 monitor MemU32 0x7e00f020 = 0x0104331039 monitor MemU32 0x7e00f00C = 0xc215060140 monitor MemU32 0x7e00f010 = 0xc215060141 monitor MemU32 0x7e00f024 = 0x0000000342 monitor MemU32 0x7e00f014 = 0x0020010243 monitor MemU32 0x7e00f018 = 0x0000000044 monitor MemU32 0x7e00f01C = 0x1400000745 #config sdram46 monitor MemU32 0x7e00f120 = 0x0000000847 monitor MemU32 0x7e001004 = 0x0000000448 monitor MemU32 0x7e001010 = 0x0000040f49 monitor MemU32 0x7e001014 = 0x0000000650 monitor MemU32 0x7e001018 = 0x0000000151 monitor MemU32 0x7e00101c = 0x0000000252 monitor MemU32 0x7e001020 = 0x0000000653 monitor MemU32 0x7e001024 = 0x0000000a54 monitor MemU32 0x7e001028 = 0x0000000c55 monitor MemU32 0x7e00102c = 0x0000018f56 monitor MemU32 0x7e001030 = 0x0000000c57 monitor MemU32 0x7e001034 = 0x0000000258 monitor MemU32 0x7e001038 = 0x0000000259 monitor MemU32 0x7e00103c = 0x0000000260 monitor MemU32 0x7e001040 = 0x0000000261 monitor MemU32 0x7e001044 = 0x0000001362 monitor MemU32 0x7e001048 = 0x0000001363 monitor MemU32 0x7e00100C = 0x0001001264 monitor MemU32 0x7e00104C = 0x00000b4565 monitor MemU32 0x7e001200 = 0x000150f866 monitor MemU32 0x7e001304 = 0x0000000067 monitor MemU32 0x7e001008 = 0x000c000068 monitor MemU32 0x7e001008 = 0x0000000069 monitor MemU32 0x7e001008 = 0x0004000070 monitor MemU32 0x7e001008 = 0x0004000071 monitor MemU32 0x7e001008 = 0x000a000072 monitor MemU32 0x7e001008 = 0x0008003273 monitor MemU32 0x7e001004 = 0x0000000074 # Setup GDB for faster downloads75 #set remote memory-write-packet-size 102476 set remote memory-write-packet-size 409677 set remote memory-write-packet-size fixed78 monitor speed 1200079 break _start80 load

eclipse arm裸機開發環境

初始化2440的腳本內容如下:

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 mode13 monitor reg cpsr = 0xd314 #config MMU 配置MMU15 #flush v3/v4 cache16 monitor cp15 7, 7, 0, 0 = 0x017 #/* flush v4 TLB 協處理器*/18 monitor cp15 8, 7, 0, 0 = 0x019 #disable MMU stuff and caches20 monitor cp15 1, 0, 0, 0 =0x100221 #Peri port setup22 monitor cp15 15, 2, 0, 4 = 0x7000001323 #disable watchdog kangear 關閉看門狗24 monitor MemU32 0x53000000 = 0x0000000025 monitor sleep 1026 #disable interrupt kangear 關閉中斷27 monitor MemU32 0x4A000008 = 0xffffffff28 monitor MemU32 0x4A00001C = 0x7fff29 #set clock30 #initialize system clocks --- locktime register31 monitor MemU32 0x4C000000 = 0xFF00000032 #initialize system clocks --- clock-divn register33 monitor MemU32 0x4C000014 = 0x5 #CLKDVIN_400_14834 #initialize system clocks --- mpll register35 monitor MemU32 0x4C000004 = 0x7f021 #default clock36 #config sdram37 monitor MemU32 0x53000000 0x00000000 38 monitor MemU32 0x4A000008 0xFFFFFFFF 39 monitor MemU32 0x4A00001C 0x000007FF 40 monitor MemU32 0x53000000 0x00000000 41 monitor MemU32 0x56000050 0x000055AA 42 monitor MemU32 0x4C000014 0x00000007 43 monitor MemU32 0x4C000000 0x00FFFFFF 44 monitor MemU32 0x4C000004 0x00061012 45 monitor MemU32 0x4C000008 0x00040042 46 monitor MemU32 0x48000000 0x22111120 47 monitor MemU32 0x48000004 0x00002F50 48 monitor MemU32 0x48000008 0x00000700 49 monitor MemU32 0x4800000C 0x00000700 50 monitor MemU32 0x48000010 0x00000700 51 monitor MemU32 0x48000014 0x00000700 52 monitor MemU32 0x48000018 0x0007FFFC 53 monitor MemU32 0x4800001C 0x00018005 54 monitor MemU32 0x48000020 0x00018005 55 monitor MemU32 0x48000024 0x008E0459 56 monitor MemU32 0x48000028 0x00000032 57 monitor MemU32 0x4800002C 0x00000030 58 monitor MemU32 0x48000030 0x0000003059 # Setup GDB for faster downloads60 #set remote memory-write-packet-size 102461 monitor speed auto62 break _start63 load

初始化210的腳本內容如下:

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 downloads10 #set remote memory-write-packet-size 102411 monitor speed auto12 break main13 load

經過上面的設置之後,就可以開始調試了

開始調試

用eclipse調試 ,保證JLinkGDBServer同時在運行

eclipse arm裸機開發環境

保證JLinkGDBServer運行起來了,點擊小甲殼蟲 -- 項目名

開始進調試界面

eclipse arm裸機開發環境

選擇 yes

eclipse arm裸機開發環境

調試界面如下圖

eclipse arm裸機開發環境

點擊【F5】是"Step Into"

【F6】是"Step Over"

等等,這裡可以查看寄存器的值,沒存的值等等。

一步一步下去可以看到開發板上的led點亮了。

相關問題答案