準備工作-1
從/nor flash啓動,格式化nand flash。
準備工作-2
- Jlink鏈接
- 串口連接
- nand flash啓動
安裝gdb server
cd /home/s3-arm/part1/lesson1/ARM-tools/
tar xvzf arm-linux-gdb-7.5.tgz
cd ./arm-linux-gdb-7.5
./build all
配置環境變量
vim /root/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export PATH=$PATH:/opt/arm-linux-gdb/bin/
export PATH=$PATH:/usr/local/arm/4.3.2/bin/
安裝Jlink軟件
cd /home/s3-arm/part1/lesson1/ARM-tools/
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/
安裝Eclipse
redhat6已經有安裝了eclipse,但版本不對。
[root@localhost JLink_Linux_V434a]# which eclipse
/usr/bin/eclipse
註銷版本不對的eclipse
cd /etc/bin/
mv ./eclipse ./eclipse_backup
安裝ARM-tools中的eclipse
cd /home/s3-arm/part1/lesson1/ARM-tools/
tar xvzf eclipse-cpp-helios-SR2-linux-gtk.tar.gz
cd ./eclipse
./eclipse
安裝插件
爲了能讓eclipse和armJlink協同工作,需要安裝插件
Work with:http://opensource.zylin.com/zylincdt
Next–>Next–>Finish–>Restart Now
到這裏eclipse已安裝好
使用eclipse建立裸機代碼工程並配置調試
首先拷貝這3個文件
打開eclipse
File---->New---->Makefile Projict with Existing Code
找到代碼位置,確定,Finish
去掉自動編譯
選擇工程右鍵,Build Project
配置調試
把代碼粘貼到下面
# 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 配置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 kangear 關閉看門狗
monitor MemU32 0x53000000 = 0x00000000
monitor sleep 10
#disable interrupt kangear 關閉中斷
monitor MemU32 0x4A000008 = 0xffffffff
monitor MemU32 0x4A00001C = 0x7fff
#set clock
#initialize system clocks --- locktime register
monitor MemU32 0x4C000000 = 0xFF000000
#initialize system clocks --- clock-divn register
monitor MemU32 0x4C000014 = 0x5 #CLKDVIN_400_148
#initialize system clocks --- mpll register
monitor MemU32 0x4C000004 = 0x7f021 #default clock
#config sdram
monitor MemU32 0x53000000 0x00000000
monitor MemU32 0x4A000008 0xFFFFFFFF
monitor MemU32 0x4A00001C 0x000007FF
monitor MemU32 0x53000000 0x00000000
monitor MemU32 0x56000050 0x000055AA
monitor MemU32 0x4C000014 0x00000007
monitor MemU32 0x4C000000 0x00FFFFFF
monitor MemU32 0x4C000004 0x00061012
monitor MemU32 0x4C000008 0x00040042
monitor MemU32 0x48000000 0x22111120
monitor MemU32 0x48000004 0x00002F50
monitor MemU32 0x48000008 0x00000700
monitor MemU32 0x4800000C 0x00000700
monitor MemU32 0x48000010 0x00000700
monitor MemU32 0x48000014 0x00000700
monitor MemU32 0x48000018 0x0007FFFC
monitor MemU32 0x4800001C 0x00018005
monitor MemU32 0x48000020 0x00018005
monitor MemU32 0x48000024 0x008E0459
monitor MemU32 0x48000028 0x00000032
monitor MemU32 0x4800002C 0x00000030
monitor MemU32 0x48000030 0x00000030
# Setup GDB for faster downloads
#set remote memory-write-packet-size 1024
monitor speed auto
break _start
load
Apply---->Close,一切就緒
啓動調試
特別提醒
啓動eclipse之前請先啓動JlinkGDBServer