您尚未登录。

楼主 #1 2020-05-09 18:42:12

缥缈九哥
会员
注册时间: 2020-05-09
已发帖子: 93
积分: 96

基于ARM-MDK+JLINK开发环境的新唐N32905的裸奔调试模板-缥缈九哥移植整理

基于ARM-MDK+JLINK开发环境的新唐N32905的裸奔调试模板-缥缈九哥移植整理
   N32905是一个主频高达240MHZ(@2.0V)的ARM926EJ-S核CPU,它内置MJPEG编解码器(VGA 30FPS),CMOS接口(3M),
16Mbitx16 DDR(-20°C~85°C)内存,支持USB2.0 HS从接口,USB1.1 FS主设备口,32通道声音处理单元SPU,
10位麦克风放大ADC, 16位立体声耳机DAC,和TV输出编码器,内置支持FlashLite(FL3.1.7)的2D BitBLT加速器。
支持D1 (720x480)的TV视频输出,支持XVGA(1,024x768)的TFT LCD屏。14X14X1.4MM大小和0.4MM 脚距的S2LQFP-128
小MCP封装。
   它的极高集成度使之仅仅外置一个简单的SPI的FLASH及相关的电源和时钟就可以独立形成最小系统。它可以仅用
双面板设计来降低整机成本及生产工艺难度。它可以用于多媒体处理电子书,学习机,玩具,人机界面,广告指示牌,
WIFI透传模块,IP摄像头,人机界面,二维码识别及机器视觉的应用。
一,N32905的物理寻址空间:
IBR:  0xFFFF_0000 - 0xFFFF_FFFF
保留: 0xFF00_2000 - 0xFFFE_FFFF
SRAM: 0xFF00_0000 - 0xFF00_1FFF
保留: 0xC000_0000 - 0xFEFF_FFFF
APB: 0xB800_0000 - 0xBFFF_FFFF
AHB: 0xB000_0000 - 0xB7FF_FFFF
SSDRAM: 0x8000_0000 - 0xAFFF_FFFF (SDRAM的影射空间)
保留: 0x4000_0000 - 0x7FFF_FFFF
SDRAM: 0x0000_0000 - 0x3FFF_FFFF
二,N32905的内置IBR启动配置:
ND1-0: IBR Boot Mode: 10=Recover; 11=Normal;
ND3-2: Boot crystal : 10=12MHz; 11=27MHz;
others 保留。
三,N32905的内置IBR引导顺序:
1,正常Normal模式串口信息:
Init RTC....OK
DDR size: 32MB
SD Port0 Booting Fail - No/Bad Card Insert
NAND Booting (2K-page 4 Address Cycle) Fail - Not for Booting
SPI Booting Fail - No Check ID
SD Port1 Booting Fail - No/Bad Card Insert
USB Booting
2,修复Recover模式串口信息:
Init RTC....OK
DDR size: 32MB
USB Booting
四,N32905的NANDFLASH配置:
LVDATA[6]:  0=EF((Error Free) NAND;  1=Raw NAND;
LVDATA[5:4]: 0=2K,1=4K,2=8K page size; 3=Ignore NAND;
ND7:   0=4 address cycle;   1=5 address cycle;
ND6:   保留。
ND5-4:   0=SDRAM; 1=mDDR;  2=DDR2;  3=DDR;
五,N32905的物理器件ID:
CHIPID:  0xFA_5C30  ,位于0xB0000000地址
六,9GLoader的简单程序模板
    本程序的串口驱动及头文件移植自新唐的ADS环境的裸奔Non-OS代码包的Loader\NandLoader例子。在建立项目时选择AT91SAM9260及它的启动代码,然后去掉9260的CPU的硬件初始化部分,在MDK的工程配置的执行地址是:0x8000,连接脚本SCT文件用MDK默认产生的,详细可以查看源码包。它能通过JLINK直接下载到CPU里调试,主要是依靠初始化脚本:9G-N32905\cfg\SDRAM.ini进行SDRAM,PLL的初始化及下载AXF文件到SDRAM的8000的执行地址里进行调试。
   附件代码:  http://bbs.21ic.com/forum.php?mod=attachment&aid=MTczNTE2fGZjMTJhNWU3fDE0NjA5NTEyNDJ8NTA1NzExfDU0MjkyOA%3D%3D

( 注:AXF文件是与ELF相兼容的一种调试文件格式,最前面的0-0X33是文件头;接着后面0x34开始就是BIN内容;
再后面是调试信息)

//SDRAM.ini
/******************************************************************************/
/* Dbg_RAM.ini: Initialization Script for Debugging in SDRAM                  */
/******************************************************************************/
/* This file is part of the uVision/ARM development tools.                    */
/* Copyright (c) 2011 Keil Software. All rights reserved.                     */
/* This software may only be used under the terms of a valid, current,        */
/* end user licence from KEIL for a compatible version of KEIL software       */
/* development tools. Nothing else gives you the right to use this software.  */
/******************************************************************************/
DEFINE INT  Entry;
DEFINE LONG GCR_BA;
DEFINE LONG CLK_BA;
DEFINE LONG SDIC_BA;
DEFINE LONG GP_BA;
Entry  = 0x00008000;
GCR_BA  = 0xB0000000;
CLK_BA = 0xB0000200;
SDIC_BA = 0xB0003000;
GP_BA = 0xB8001000;
FUNC void Clock_Setup (void)
{
}
FUNC void SDRAM_Setup(void)
{
_WDWORD(0xb0003000, 0x00130456); // SDOPM Init DDR
_WDWORD(0xb0003030, 0x00001010); // DQSODS
_WDWORD(0xb0003010, 0x00000005); // SDSIZE0
_WDWORD(0xb0003004, 0x00000021); // SDCMD
_WDWORD(0xb0003004, 0x00000023); // SDCMD
_WDWORD(0xb0003004, 0x00000027); // SDCMD
_WDWORD(0xb000301C, 0x00001002); // SDEMR
_WDWORD(0xb0003018, 0x00000122); // SDMR
_WDWORD(0xb0003004, 0x00000027); // SDCMD
_WDWORD(0xb0003004, 0x0000002B); // SDCMD
_WDWORD(0xb0003004, 0x0000002B); // SDCMD
_WDWORD(0xb0003018, 0x00000022); // SDMR
_WDWORD(0xb0003004, 0x00000020); // SDCMD
_WDWORD(0xb0003034, 0x00AAAA00); // CKDQSDS
_WDWORD(0xb0003008, 0x0000805A); // SDREF
_WDWORD(0xb00000A0, 0x00000000); // MISCPCR
_WDWORD(0xb0000224, 0x0000447E); // UPLLCON PLL=192MHz
_WDWORD(0xb000020C, 0x00000018); // CLKDIV0 Divider
_WDWORD(0xb000021C, 0x00000000); // CLKDIV4
_WDWORD(0xb0003028, 0x094E7549); // SDTIME Sdram Timing
    _sleep_(10);
_WDWORD(0xb8001010, 0x00000008); // GPIOB_OMD  PB3=OUTPUT
_WDWORD(0xb8001018, 0x00000008); // GPIOB_DOUT PB3=HIGH
    _sleep_(10);
}
FUNC void Remap (void)
{
}
FUNC void Download (void)
{
    exec("load %L incremental");
}
FUNC void PC_Setup (void)
{
    PC = Entry;
}
FUNC void GoMain (void)
{
    exec("g,main");
}
//Clock_Setup();
SDRAM_Setup();
//Remap();
Download();
PC_Setup();
GoMain();
//main.c文件
#include <stdio.h>
#include "wblib.h"
#define DebugCom 0x100
void Delay(UINT32 k)
{
volatile int j=k*36000;
while(j--);
}
void InitDebugCom(void)
{
WB_UART_T *uart;
//Nornal Speed UART
outp32(REG_GPAFUN, inp32(REG_GPAFUN) | (MF_GPA11 | MF_GPA10));
outp32(REG_APBCLK, inp32(REG_APBCLK) | UART1_CKE);
uart->uiFreq = (((inp32(REG_CHIPCFG)&0xC)==0x8)?12000:27000)*1000; /*Use external clock*/
    uart->uiBaudrate = 115200;
    uart->uiDataBits = WB_DATA_BITS_8;
    uart->uiStopBits = WB_STOP_BITS_1;
    uart->uiParity = WB_PARITY_NONE;
    uart->uiRxTriggerLevel = LEVEL_1_BYTE;
   
/* Reset the TX/RX FIFOs */
outpw(REG_UART_FCR+DebugCom, 0x07);
/* Setup baud rate */
outpw(REG_UART_BAUD+DebugCom, ((0x30<<24)|((uart->uiFreq / uart->uiBaudrate)-2)));
/* Set the modem control register. Set DTR, RTS to output to LOW,
and set INT output pin to normal operating mode */
//outpb(UART_MCR, (WB_DTR_Low | WB_RTS_Low | WB_MODEM_En));
/* Setup parity, data bits, and stop bits */
outpw(REG_UART_LCR+DebugCom,(uart->uiParity | uart->uiDataBits | uart->uiStopBits));
/* Timeout if more than ??? bits xfer time */
outpw(REG_UART_TOR+DebugCom, 0x80+0x20);
/* Setup Fifo trigger level and enable FIFO */
outpw(REG_UART_FCR+DebugCom, uart->uiRxTriggerLevel|0x01);
}
int fputc(int ch, FILE *f)
{
/* Wait until the transmitter buffer is empty */  
while (!(inpw(REG_UART_FSR+DebugCom)&0x400000));
/* Transmit the character */
outpb(REG_UART_THR+DebugCom, ch);
return ch;
}
int fgetc(FILE *f)
{
while((inpw(REG_UART_ISR+DebugCom)&0x01)==0);
return(inpb(REG_UART_RBR+DebugCom));
}
int main(void)
{
int i=0;
InitDebugCom();
printf("\n\r\n\r");
printf("*** 9G-N32905 V1.00 Build by yuanxihua@21cn.com on ("__DATE__ " - " __TIME__ ")\n\r");
printf("*** 9G-N32905 V1.00 Running ...\n\r\n\r");
outp32(REG_GPIOC_OMD,0x0000FFFF);
outp32(REG_GPIOE_OMD,0x0000FFFF);
while(1)
{
  printf("run times %d\n\r",i++);
  outp32(REG_GPIOC_DOUT,0x0000FFFF);
  outp32(REG_GPIOE_DOUT,0x0000FFFF);
  Delay(500);
  outp32(REG_GPIOC_DOUT,0x00000000);
  outp32(REG_GPIOE_DOUT,0x00000000);
  Delay(500);   
}
}

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn