歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 搭建GCC+JLINK開發調試環境(裸機調試)

搭建GCC+JLINK開發調試環境(裸機調試)

日期:2017/2/28 16:20:21   编辑:Linux教程

a) 安裝VMware --- just do it.
b) 安裝arm-elf-gcc toolset --- we can get it from: http://www.gnuarm.com/
c) 安裝JLINK軟件 --- just get it from SEGGER website.

d) 實現2440 gdb 啟動腳本:
1) 參閱JLinkGDBServer文檔,如下:

文件: UM08005_JLinkGDBServer.pdf 大小: 509KB

本文要用到的相關文件下載在Linux公社的1號FTP服務器裡,下載地址:

FTP地址:ftp://www.linuxidc.com

用戶名:www.linuxidc.com

密碼:www.muu.cc

在 2011年LinuxIDC.com\3月\搭建GCC+JLINK開發調試環境(裸機調試)

下載方法見 http://www.linuxidc.net/thread-1187-1-1.html


2) 此gdb啟動腳本的主要任務是初始化內存控制器,禁止WatchDog,禁止中斷。
參考JLinkGDBServer文檔後,經測試,以下代碼可以正常工作:
##main function defined for initial the S3C2440 CPU.

define reset_2440
monitor endian little ##little endian, should be the same as your application.

##copied from JLinkGDBServer Document.
monitor reset ##reset the S3C2440
monitor reg cpsr = 0xd3 ##setup cpsr register.
monitor speed auto ##Link Speed.

##translated from VIVI S3C2440 version.
#disable watchdog
monitor MemU32 0x53000000 = 0

#disalbe interrupt --- int-mask register
monitor MemU32 0x4A000008 = 0xFFFFFFFF

#disalbe interrupt --- int-sub-mask register
monitor MemU32 0x4A00001C = 0x7FFF ## vivi set it as 0x7FF, why???

#initialize system clocks --- locktime register
monitor long 0x4C000000 = 0xFF000000

#initialize system clocks --- clock-divn register
monitor long 0x4C000014 = 0x5 #CLKDVIN_400_148

#initialize system clocks --- mpll register
monitor long 0x4C000004 = 0x7f021 #default clock

#setup memory controller
monitor MemU32 0x48000000 = 0x22111110 #conw
monitor MemU32 0x48000004 = 0x00000700 #bank0
monitor MemU32 0x48000008 = 0x00000700 #bank1
monitor MemU32 0x4800000c = 0x00000700 #bank2
monitor MemU32 0x48000010 = 0x00000700 #bank3
monitor MemU32 0x48000014 = 0x00000700 #bank4
monitor MemU32 0x48000018 = 0x00000700 #bank5
monitor MemU32 0x4800001c = 0x00018009 #bank6
monitor MemU32 0x48000020 = 0x00018009 #bank7
monitor MemU32 0x48000024 = 0x008e04eb #vREFRESH
monitor MemU32 0x48000028 = 0xB2 #vBANKSIZE -- 128M/128M --- should
according to the physical
memory size? --- 0xB0 ??
monitor MemU32 0x4800002c = 0x30 #vMRSRB6
monitor MemU32 0x48000030 = 0x30 #vMRSRB7
end

##main function defined for connect to the TARGET.
##arg0 = IP address.
##arg1 = PORT number of JLINK gdb server.

define connect_jei
if $argc == 2
target remote $arg0:$arg1
reset_2440
end
end

3) 腳本做好以後,以下命令為怎樣使用該腳本---假設該腳本名字為targets.cmd,編譯出的程序文件為main.out

arm-elf-gdb -x targets.cmd -ex "connect_jei 192.168.1.168 2331" main.out

然後在gdb命令行中輸入以下命令即可調試了:
load
b main
c

Copyright © Linux教程網 All Rights Reserved