JLink+GDBServer调试S3C6410裸板的初始化代码 For OK6410开发板

发布者:爱笑的猫咪最新更新时间:2024-09-13 来源: cnblogs关键字:JLink  GDBServer  OK6410开发板 手机看文章 扫描二维码
随时随地手机看文章

要调试裸板,有两种初始化方法,一个是用烧好的uboot初始化,再有就是直接用JLink+GDBServer初始化。代码参考了网上的资料,根据手头的OK6410开发板做了修改。整体代码如下:


# Connect to the J-Link GDBServer

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 

#

# Set the processor to service mode

monitor reg cpsr = 0xd3

# Config MMU

# Flush v3/v4 cache

monitor cp15 7, 7, 0, 0 = 0x0

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  =  0xffffffff

monitor MemU32 0x71300014  =  0xffffffff

monitor MemU32 0x7120000C  =  0x00000000

monitor MemU32 0x7130000C  =  0x00000000

monitor MemU32 0x71200F00  =  0x00000000

monitor MemU32 0x71300F00  =  0x00000000

# Set clock 

monitor MemU32 0x7e00f900  =  0x000080de

monitor MemU32 0x7e00f000  =  0x0000ffff

monitor MemU32 0x7e00f004  =  0x0000ffff

monitor MemU32 0x7e00f008 = 0x0000ffff

monitor MemU32 0x7e00f028 = 0x00300000

monitor MemU32 0x7e00f020  =  0x01043310

monitor MemU32 0x7e00f00C  =  0x810a0301

monitor MemU32 0x7e00f010  =  0x810a0301

monitor MemU32 0x7e00f014 = 0x80200102

monitor MemU32 0x7e00f018 = 0x00000000

monitor MemU32 0x7e00f01c = 0x00000007

monitor sleep 1

# UART Init

monitor MemU32 0x7f008000 = 0x00220022

monitor memU32 0x7f008020 = 0x00002222

monitor memU32 0x7f005008 = 0x00000000

monitor memU32 0x7f00500c = 0x00000000

monitor memU32 0x7f005000 = 0x00000003

monitor memU32 0x7f005004 = 0x00000e45

monitor memU32 0x7f005028 = 0x00000033

monitor memU32 0x7f00502c = 0x0000dfdd

monitor memU32 0x7f005020 = 0x4f4f4f4f

monitor memU32 0x7f005020 = 0x4b4b4b4b


# Config Mobile DDR SDRAM

monitor MemU32 0x7e00f120  =  0x0000000d

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  =  0x0000010b

monitor MemU32 0x7e001030  =  0x0000000c

monitor MemU32 0x7e001034  =  0x00000002

monitor MemU32 0x7e001038  =  0x00000002

monitor MemU32 0x7e00103c  =  0x00000002

monitor MemU32 0x7e001040  =  0x00000002

monitor MemU32 0x7e001044  =  0x00000010

monitor MemU32 0x7e001048  =  0x00000010

monitor MemU32 0x7e00100C  =  0x0001001a

monitor MemU32 0x7e00104C  =  0x00000b45

monitor MemU32 0x7e001200  =  0x000150f0

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


下载逐行说明:


Monitor reg cpsr = 0xd3


这一行是把cpu置为管理模式,并且设置中断掩码I F T M4 M3 M2 M1 M0,对应于0xd3为0xB11010011, I、F置位设置中断及快速中断掩码, T清位,说明当前为ARM模式下, M置为0xB10011,为管理模式。



monitor MemU32 0x7e004000 = 0x00000000


这一行失能看门狗,该寄存器说明如下:


  Watchdog timer [5]  0=Disable,  1=Enable


  Clock select [4:3] 00:16  01:32  10:64  11:128


  Interrupt generation [2] 0=Disable,  1=EnableReset enable/disable [0]



Monitor MemU32 0x71200014 = 0xFFFFFFFF


Monitor MemU32 0x71300014 = 0xFFFFFFFF


设置VIC0INTENCLEAR及VIC1IntENCLEAR寄存器,该寄存器写0无作用,写1会disable相应的中断:


  Clears corresponding bits in the VICINTENABLE Register:0 = no effect1 = interrupt disabled in VICINTENABLE Register.There is one bit of the register for each interrupt source.


  网上其它资料都是往里写0,应该是个错误。



Monitor MemU32 0x7120000C = 0x00000000


Monitor MemU32 0x7130000C = 0x00000000


设置所有中断为IRQ,而不是FIQ,该寄存器写0为IRQ,写1为FIQ:


  Selects type of interrupt for interrupt request:0 = IRQ interrupt (reset)1 = FIQ interruptThere is one bit of the register for each interrupt source



Monitor MemU32 0x71200F00 = 0x00000000


Monitor MemU32 0x71300F00 = 0x00000000


设置VIC0ADDRERSS及VIC1ADDRESS寄存器,清除当前pending的中断:


  Contains the address of the currently active ISR, with reset value0x00000000.A read of this register returns the address of the ISR and sets thecurrent interrupt as being serviced. A read must only be performedwhile there is an active interrupt.A write of any value to this register clears the current interrupt. Awrite must only be performed at the end of an interrupt serviceroutine.



Monitor MemU32 0x7e00f900 = 0x000080de


设置OTHERS寄存器为Synchronous mode,网上资料没有设置sync,要试验一下



Monitor MemU32 0x7e00f000 = 0x0000ffff


Monitor MemU32 0x7e00f004 = 0x0000ffff


Monitor MemU32 0x7e00f008 = 0x0000ffff


设置APLL_LOCK、MPLL_LOCK及EPLL_LOCK寄存器,都设为最大间隔



Monitor MemU32 0x7e00f028 = 0x00300000


设置CLK_DIV2寄存器,主要是设置UART_RATIO:       


  UART_RATIO     [19:16]    


  UART clock divider ratio


  CLKUART = CLKUARTIN / (UART_RATIO + 1)


  这里的设置是CLKUART = CLKUARTIN / 4



Monitor MemU32 0x7e00f020 = 0x01043310


设置CLK_DIV0寄存器, 设置的值如下     


  PCLK_RATIO   [15:12]     0x3     


  HCLKX2_RATIO [11:9]      0x1     


  HCLK_RATIO   [8]         0x1     


  MPLL_RATIO   [4]         0x1     


  APLL_RATIO    [3:0]      0x0


  根据如下的计算公式


  PCLK = HCLKX2 / (PCLK_RATIO + 1)


  HCLKX2 = HCLKX2IN / (HCLKX2_RATIO + 1)


  HCLK = HCLKX2 / (HCLK_RATIO + 1)


  DOUTMPLL = MOUTMPLL / (MPLL_RATIO + 1)


  ARMCLK = DOUTAPLL / (ARM_RATIO + 1)

  得到的计算结果 


  PCLK = HCLKX2 / 4


  HCLKX2 = HCLKX2IN / 2


  HCLK = HCLKX2 / 2


  DOUTMPLL = MOUTMPLL / 2


  ARMCLK = DOUTAPLL  



Monitor MemU32 0x7e00f00c = 0x810a0301


Monitor MemU32 0x7e00f010 = 0x810a0301


设置APLL_CON及MPLL_CON寄存器,


  计算公式为


  FOUT = MDIV X FIN / (PDIV X 2SDIV)


  对于APLL_CON寄存器:             


    Enable   [31]         0x1             


    MDIV    [25:16]   0x10a(266)             


    PDIV     [13:8]    0x3             


    SDIV     [2:0]     0x1


  则FOUT = 266 X 12 / (3 X 2) = 532


  对于MPLL_CON寄存器是一样的,也是532



Monitor MemU32 0x7e00f014 = 0x80200102


Monitor MemU32 0x7300f018 = 0x00000000


设置EPLL_CON0寄存器           


  Enable      [31]    0x1           


  MDIV       [23:16]   0x20           


  PDIV       [13:8]   0x1           


  SDIV       [2:0]    0x2


  设置EPLL_CON1寄存器           


    KDIV       [15:0]   0x0

  根据计算公式:FOUT = (MDIV + KDIV / 216) X FIN / (PDIV X 2SDIV)


  可以计算得到FOUT = 32 X 12 / (1 X 4) = 96



Monitor MemU32 0x7e00f01c = 0x00000007


  设置CLK_SRC寄存器       


    UART_SEL   [13]   0x0    using MOUT epll    


    EPLL_SEL    [2]    0x1    using FOUT epll       


    MPLL_SEL    [1]    0x1    using FOUT mpll       


    APLL_SEL    [0]     0x1   using FOUT apll



Monitor MemU32 0x7f008000 = 0x00220022


  设置GPACON寄存器     


    GPA0         [3:0]     0x2   UART RXD[0]     


    GPA1         [7:4]     0x2   UART TXD[0]     


    GPA2         [11:8]    0x0   Input     


    GPA3         [15:12]   0x0   Input     


    GPA4         [19:16]   0x2   UART RXD[1]     


    GPA5         [23:20]   0x2   UART TXD[1]



Monitor MemU32 0x7f008020 = 0x00002222


  设置GPBCON寄存器     


    GPB0     UART_RXD[2]     


    GPB1     UART TXD[2]     


    GPB2     UART RXD[3]     


    GPB3     UART TXD[3]



Monitor memU32 0x7f005008 = 0x00000000


设置UFCON0寄存器:           


  FIFO disable



Monitor memU32 0x7f00500c = 0x00000000


设置UMCON0寄存器:           


    Modem interrupt Disable



Monitor MemU32 0x7f005000 = 0x00000003


设置ULCON0寄存器           


    Word Length 8-bit           


    One shop bit per frame           


    No parity Mode           Normal mode operation



Monitor MemU32 0x7f005004 = 0x00000e45


设置UCON0寄存器           


   Clock selection EXT_UCLK1:  DIV_VAL=(EXT_UCLK1/(bps x16))-1           


  Tx Interrupt Type: Level           


  Rx Interrupt Type: Pulse           


  Rx Time Out  Enable: disable           


  Rx Error status interrupt enable: enable           

[1] [2]
关键字:JLink  GDBServer  OK6410开发板 引用地址:JLink+GDBServer调试S3C6410裸板的初始化代码 For OK6410开发板

上一篇:qwt移植到OK6410
下一篇:用crosstool-ng建立自己的ARM交叉编译工具链 (适用于S3C6410以及其它处理器)

推荐阅读最新更新时间:2026-03-19 11:22

Ubuntu下移植内核到OK6410开发板
环境:Win7+virsualBox+ubuntu12.04+ok6410开发板 一,下载源码:我这里下载的版本是--linux-3.12.7 http://www.kernel.org/ 二,解压内核: tar -xvf linux-3.12.7-tar.xz 三,更改权限(最好赋予全部权限) sudo chmod -R 777 linux-3.12.7/* 四,修改源码(针对基于smdk6410架构的ok6410开发板) 1,在arch/arm/mach-s3c64xx/目录下的mach-smdk6410.c 复制一份在当前文件下命名为mach-ok6410.c wu@wu-VirtualBox:/opt
[单片机]
Ubuntu下移植内核到<font color='red'>OK6410</font><font color='red'>开发板</font>
OK6410开发板uboot烧写
uboot的移植完成以后,满以为很快能烧写到板子上并安装linux,结果uboot烧写了三天才终于成功,这其中碰到了不少的问题,在此做个总结。 首先,飞凌的OK6410开发板并不支持JLink烧写uboot,只能通过SD卡来烧写,这一点我事先并不知道,他们网店介绍里并未说明,而且销售人员也没有做出任何提示,结果我花了整整一天时间尝试所有通过JLink烧写uboot的可能方法,结合网上个别人反映,最终意识到通过JLink完成uboot烧写是不可能成功的了,后来在销售人员那里确认了这一点,对飞凌表示不满。 当时买板的时候没有买SD卡,因为感觉没什么用,就想给老板省点钱,现在没SD卡不行了,但在寻找JLink烧写uboot方法的过程中我
[单片机]
OK6410开发板裸机DS18B20驱动
相信玩过51的童鞋应该都玩过DS18B20吧,虽然用在ARM11上面,但是操作还是一样,多了一点就是读写IO前需要切换IO方向,其实51在读取之前需要切换到高电平的,这个一般由编译器完成的, /************************************************************************************************************* * 文件名: ds18b20.c * 功能: S3C6410 DS18B20驱动 * 作者: cp1300@139.com * 创建时间: 2012年9月17日22:45 * 最后修改时间:
[单片机]
ok6410开发板交叉编译器的安装
1.上篇文章中我们说了已经在虚拟机里面的ubuntu12根目录下建立了 forlinx文件夹,现将arm-linux-gcc.4.3.2.tgz拷贝到forlinx中,我用的是上次建立好的xftp,相当爽啊 2. cd ../../ ls cd forlinx mkdir /usr/local/arm tar zxvf arm-linux-gcc-4.3.2.tgz -C /,注意这里的斜杠不要丢掉 这样解压到了 /usr/local/arm 然后运行这个命令 gedit /etc/profile 再把以下四行加入文件的头部(尾部我试了反正我的不管用,不知道为啥)
[单片机]
<font color='red'>ok6410</font><font color='red'>开发板</font>交叉编译器的安装
ubuntu下使用Code::blocks + JLink调试stm32f103c8
Code::Blocks的安装   打开终端,输入:sudo apt-get install codeblocks   指令执行完成后在菜单中出现 即为安装成功 JLink配置   Linux下JLink的安装   打开网址:https://www.segger.com/downloads/jlink/下载J-Link驱动,我下载的是Linux 64bit DEB版本的。 下载好后,直接双击运行.deb文件,系统会自动安装驱动;   运行JLinkGDBServer   系统默认会将JLink安装在/opt/SEGGER/JLink下,进入到该路径下,执行:./JLinkGDBServer -device stm32f10
[单片机]
ubuntu下使用Code::blocks + <font color='red'>JLink</font><font color='red'>调试</font>stm32f103c8
记录ok6410 jlink 命令行调试uboot
1启动ok6410 进入uboot命令行 2\启动JLinkGDBServer -device ARM11 3arm-none-eabi-gdb u-boot 初始化脚本 # Connect to the J-Link GDBServer 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 # # Set the processor to s
[单片机]
使用jlink直接烧norflash或者nandflash不借助uboot的猜想
由于喜欢折腾,我是在linux下使用jlink的,既然JLinkExe可以进行内存读写操作,loadbin等操作,并且通过指定命令文件支持批量指令输入,那么首先jlink是可以直接访问内部存储器的,包括它的RAM和各种Soc上外设如存储控制器,串口配置寄存器等,但是不能直接访问外部存储器,如Norflash。这样一来,先关狗,设好时钟,然后通过wmem32一系列命令,操作存储控制器,这样就可以访问SRAM,然后loadbin到内存,再写回到norflash,或者nandflash,其中nandflash应该略复杂,需要设置好flash控制器,然后还要额外写一个操作nandflash的bin,并将它也loadbin至内存,setpc
[单片机]
Jlink调试S5PV210
安装CDT C/C++ Development Toolkit,使eclipse可以开发C/C++项目 Help– Install New Software中输入: http://download.eclipse.org/tools/cdt/releases/galileo 如果出现安装缓慢,可以尝试将最后一个选项勾选掉 安装MinGW Minimalist GNU on Windows,C/C++编译器。并且安装make命令 http://www.mingw.org/ 下载安装,并添加到环境变量 安装gdb 参考: http://blog.csdn.net/cbbbc/article/details/46708437 测
[单片机]
<font color='red'>Jlink</font><font color='red'>调试</font>S5PV210
小广播
最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

厂商技术中心

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

电子工程世界版权所有 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2026 EEWORLD.com.cn, Inc. All rights reserved