s3c4510 烧写flash

 

原创:s3c4510 烧写flash(sst39vf3201) 补齐了所有文件 参考其他资料

作者:wangkj 栏目:ARM技术

原创:S3C4510 烧写FLASH(SST39VF3201) 补齐了所有文件 参考其他资料

网址:http://www.dzsc.com/dzbbs/20061230/200765182757515562.html

/***********************************************************************
* $Workfile:   39vf160.c  $
* $Revision: 1.3 $
* $Author: meterchen $
* $Date: 2003/08/25 14:03:12 $
*
* Project:     Shenzhen-Nucleus-Grafix
*
* DESCRIPTION:
*    based on sst's reference program
*
* Revision History:
*
***********************************************************************
*
*  COPYRIGHT (c)2003 CHENMENG
*
*  All rights reserved
*
**********************************************************************/

/*
NAME                    Function
------------------------------------------------------------------
Check_SST_39VF160       CheckMANUFACTURER andDEVICE ID
CFI_Query               CFI Query Entry/Exit command sequence
Erase_Entire_Chip       Erase the contents of the entire chip
Erase_One_Sector        Erase a sector of 2048 word
Erase_One_Block         Erase a block of 32K word
Program_One_Word        Alter data in one word
Program_One_Sector      Alter data in 2048 word sector
Program_One_Block       Alter data in 32K word block
Check_Toggle_Ready      End of internal program or erase detection using
                        Toggle bit
Check_Data_Polling      End of internal program or erase detection using
                        Data# polling
*/

#define FALSE                   0
#define TRUE                    1

#define SECTOR_SIZE             2048    /* Must be2048 words for39VF160 */
#define BLOCK_SIZE              32768   /* Must be 32K words for39VF160  */

#define SST_ID                  0xBF    /* SST MANUFACTURER's ID code   */
#define SST_39VF160             0x235B  /* SST39VF160DEVICE code      *///SST39VF3201

#define FLASH_BASE                0x0

typedef unsigned CHAR           UINT8;
typedef unsigned SHORT          UINT16;

/* -------------------------------------------------------------------- */
/*                       EXTERNAL ROUTINES                              */
/* -------------------------------------------------------------------- */

void Delay_150_Nano_Seconds(void);
void Delay_25_Milli_Seconds(void);
void Delay_100_Milli_Seconds(void);
void Check_Toggle_Ready (UINT16 *Dst);

void Delay(int n)
{
    int i=100, j;
    while(i--)
        for(j=0; j<n; j++);
}

void Delay_150_Nano_Seconds(void)
{
    Delay(2);        //about 200ns
}

void Delay_25_Milli_Seconds(void)
{
    Delay(250);
}

void Delay_100_Milli_Seconds(void)
{
    Delay(1000);
}

/*************************************************************************/
/* PROCEDURE:   Check_SST_39VF160                                       */
/*                                                                      */
/* This procedure decides whether a physical HARDWARE DEVICE has a      */
/* SST39VF160 16 Mbit Multi-PurposeFLASH installed or not.             */
/*                                                                      */
/* Input:                                                               */
/*          None                                                        */
/*                                                                      */
/* OUTPUT:                                                              */
/*          return TRUE: &n

2楼: >>参与讨论
wangkj 烧写FLASH的文档参考44b的,有两点不同
1,程序缓冲区的地址是0x1200000
2,初始化文件名是1.ini

-info totals -entry __main -ro-base 0x1000000 -rw-base 0x1100000

image entry point
__main
3楼: >>参与讨论
wangkj 这是1.ini
spp semihosting_enabled 0
spp vector_catch 0

com SDRAM, KS32C50100, SFR BASE=0x3ff,0000,SRAM BASE=0x3fe,0000, no cache
smem 0x3ff0000  0xE7ffffa0 32

com  16bit of SDRAM0 , FLASH0 and all IO
smem 0x3ff3010  0x00002002 32

com FLASH From  FLASH From 0X00,00000 to 0X08,00000    00 00,1000,0000,  0000,0000,00 00,0110,0000
smem 0x3ff3014  0x08000060 32

com ===================================
com +           SDRAM BANK            +
com ===================================

com  0x10,00000~0x20,00000  16-32M SDRAM  01  10,0000,0000,   0100,0000,00  11,1001,0000
smem 0x3ff302c  0x60040390 32

com  extern IO and SDRAM fresh time CONTROL io=0x3fd,0000  
smem 0x3ff303c  0xce3383FD 32

reload
br @main
4楼: >>参与讨论
wangkj multice 烧FLASH.html">FLASH
基于ARM 的系统开发的初期,烧写FLASH 是必不可少的步骤。在实际运
用中,烧写FLASH 共有两大类方法,其基本原理各不相同:方法一,采用JTAG
边界扫描的方法,直接通过JTAG 口控制芯片的引脚,从而实现对FLASH的烧
写,在这种情况下,CPU(ARM)是没有工作的,而且由于每要改变一次引脚
状态,需要将芯片所有引脚进行移位操作,导致烧写速度很慢。方法二,通过
JTAG 仿真器,将烧写FLASH 的程序下载到系统RAM 中,然后运行此程序,
通过此程序来实现对FLASH的烧写,在这种情况下,CPU(ARM)是工作的,
通过CPU(ARM)来执行烧写FLASH 的命令序列,速度很快。
本例主要使用方法二。而在方法二中,如何实现被烧写image 的下载也有多
种方法,本例直接将被烧写的image 下载到系统内存中。
由于大多数情况下,FLASH 中无代码,因而SDRAM 也没有初始化,此时
AXD 下载程序不正确,因此需要手动初始化SDRAM。
启动AXD 的命令行窗口,输入ob c:\1.ini
如果不正确,需重试几次,直至正确为止,方可进行后续的步骤。
装入被烧写的image 到程序中指定的缓冲区。
在烧写结束处设置一断点,以便知道烧写结束,然后运行程序。

也可以在结束出的程序设置led发光,发生等提示程序,这样可以更好
的知道烧写结束。

(我使用firfox,不能上传图片,这个网站不规范)
5楼: >>参与讨论
hqgboy 好文。。。顶。。
 
6楼: >>参与讨论
AceLee 感谢!
好东西,先复制下来再研究研究!
7楼: >>参与讨论
wangkj 这个程序和我所在的公司完全没有关系
是我业余时间自己作的4510的线路版和程序。所以,所有的硬件和源码都可以开放。但不是现在.
8楼: >>参与讨论
AceLee 有点疑问?
楼主,我烧写FLASH的程序跟你上面的也差不多,不同的是我没有用1.ini这个文件,我直接设置了一下编译链接环境就Debug,你说这是初始化RAM用的,是不是相当于这是最先开始运行的代码。但是我没有这个文件也能调试程序(硬件调试)啊?这是怎么回事?刚开始用ADS,忘楼主解答.我打算先把要烧写的代码通过UART放到RAM缓冲区中,再通过程序控制下载,现在串口工作正常,就是这个FLASH操作不正确,连ID也读出来不正确,是不是跟1.ini有关呢,
9楼: >>参与讨论
wangkj 1.ini 是设置ram映射和其他几个寄存器的
只要正确的设置这几个寄存器,方法无所谓。
仔细看 S3C4510的手册。这是和你的硬件线路板的设计有关的。
这个程序是实际运行的程序。
10楼: >>参与讨论
wangkj 这是存储部分的原理图
用烦人的ie上传的。
11楼: >>参与讨论
wangkj 附件
存储原理图pdf格式

http://bbs.21ic.com/upfiles/img/200611/2006112310040115.pdf

12楼: >>参与讨论
wangkj 该给的都给了
你能不能成功就看你自己的实力了。俺实在没功夫。
13楼: >>参与讨论
twentyone re
tO : AceLee

首先确定你的烧写代码是不是运行了。然后在考虑对FLASH进行操作的问题。如果不能确定的话,你自己也不知道问题出在那里。另外,可以用仿真来跟踪实际的运行过程。

14楼: >>参与讨论
John_light 對于wangkj的無私奉獻,贊一個
 
15楼: >>参与讨论
wangkj linux 要讲究奉献,不要像某些团体
说一套作一套。
16楼: >>参与讨论
good02xaut 好,楼主赞一个
 
17楼: >>参与讨论
AceLee 回复
To twentyone:
    你说的烧写的代码是否运行,跟我要烧写FLASH有什么关系吗?是不是用ADX调试FLASH里面必须要有东西了?我要是不用到中断应该不用烧写也可以吧?还有一个疑问就是用ADS调试板子的时候,C代码前面是不是还得有个初始化的代码,ADX自动加上了,我没加也能调试。
18楼: >>参与讨论
leezongfan 本人也有一个。
本人也有一个类似程序。我买的是一块44B0学习板。光盘里附赠了这样一个程序。我看了一下(基于SDT的)。
  其原理是:先用有一个BOOT.ini文件,初始化CPU。
  然后通过JTAG线将程序下载到RAM。在开始写之前设置好一个断点。运行程序到断点处。再通过JTAG将要烧录的映象下载到RAM的一个固定地址。然后继续执行程序。程序会自动把下载到固定RAM地址的映像搬运到FLASH中。从而完成写入。
19楼: >>参与讨论
wangkj 4510 烧FLASH的解答
菜鸟要学会搜索
20楼: >>参与讨论
wangkj 我写这么详细,如果再看不懂,那就没办法了。
 
21楼: >>参与讨论
wangkj 39VF320.new.C
/*
SOFTWARE.html">SOFTWAREDEVICE Driver
SST39VF3201/SST39VF3202
32 Mbit Multi-Purpose FLASH (MPF+)
Jerry Deng, SILICON StorageTECHNOLOGY, Inc.
Revision 2.0, December 2003

ABOUT THE SOFTWARE

This is a SOFTWAREDEVICE driver example forSST39VF3201/3202
32 Mbit Multi-Purpose FLASH (MPF+). The code is written in generic C language,
extensive comments are included in each routine to describe its function and usage.

SST39VF3201/3202 datasheet should be reviewed in conjunction
with this code to completely understand the operation of this DEVICE.

The SST39VF3201 supports bottom boot bLOCK protection, and theSST39VF3202
supports top boot bLOCK protection. The boot bLOCKMEMORY area is protected from
erase/programming when WP# is low and unprotected when WP# is high.

During execution of this code, it's assumed that RST# signal on DEVICE is held in
LOGIC high state, otherwise theDEVICE will be put into reset state (read mode)
as LONG as RST# is low.
*/
#include <../inc/FLASH.h>
#define AddrsShift              1           
// define 2 if it's true that A1 of SYSTEM address bus has been shifted to A0 of DEVICE address, A2 to A1, etc.
// otherwise, change it to look like:
// #define AddrsShift           1

#define DefaultBaseAddress      0x2100000   /* defaultDEVICE base address forSST39VF3201/3202 */
#define ChipEraseTime           714286      /* maximum timeout of read cycles for chip-erase, 50ms/70ns */
#define BLOCKEraseTime          357143      /* maximum timeout of read cycles for bLOCK-erase, 25ms/70ns */
#define SectorEraseTime         357143      /* maximum timeout of read cycles for sector-erase, 25ms/70ns */
#define WordProgramTime         143         /* maximum timeout of read cycles for word-program, 10us/70ns */

#define FALSE                   0
#define TRUE                    1



LONG  BaseAddrs=DefaultBaseAddress;
// In some cases, SYSTEM will assign a DEVICE base address for FLASH ONLY at run time.
// This is the reason that we define BaseAddrs as a variable rather than a CONSTANT.

// The C code in this document contains the following routines in order:
//    NAME                            Function

/* -------------------------------------------------------------------- */
/*                       EXTERNAL ROUTINES                              */
/* -------------------------------------------------------------------- */

LONG  Check_SST_39VF320X(void);       // CheckMANUFACTURER andDEVICE ID
void  CFI_Query(int*);               // Read CFI information
void  SecID_Query(int*, int*);      // Read both SST SecID and User SecID information
CHAR  Erase_One_Sector(LONG);        // Erase one sector (2K words)
CHAR  Erase_One_BLOCK (LONG);        // Erase one bLOCK (32K word)
        

CHAR  Program_One_Word(int,LONG);  // Program one word intoDEVICE
CHAR  SecID_LOCK_Status(void);        // Check User SecIDLOCK status
CHAR  User_SecID_Word_Program(int*,LONG, CHAR); // Program one word into User SecID segment
CHAR  User_SecID_LOCK_Out(void);                   //LOCK out User SecID segment
void  Erase_Suspend(void);                         // Temporarily suspend one sector-erase or bLOCK-erase
CHAR  Erase_Resume(void);                          // Resume suspended sector-erase or bLOCK-erase
CHAR  Check_Data_Polling (LONG, int,LONG);     // Wait until DQ7 outputs true data

void Delay_150_Nano_Seconds(void);        // delay 150ns
void Delay_1_Microsecond(void);           // delay 1us
void Delay_20_Micro_Seconds(void);        // delay 20us

void Delay_25_Milli_Seconds(void);
void Delay_100_Milli_Seconds(void);
CHAR Check_Toggle_Ready (LONG,LONG);

void Delay(int n)
{
    int i=100, j;
    while(i--)
        for(j=0; j<n; j++);
}

void Delay_150_Nano_Seconds(void)
{
    Delay(2);        //about 200ns
}

void Delay_25_Milli_Seconds(void)
{
    Delay(250);
}

void Delay_1_Microsecond(void)
{
    Delay(10);
}

void Delay_20_Micro_Seconds(void)
{
    Delay(200);
}


void Delay_100_Milli_Seconds(void)
{
    Delay(1000);
}



/************************************************************************/
/* PROCEDURE:   Check_SST_39VF320X                                      */
/*                                                                      */
/* This procedure decides whether a physical HARDWARE DEVICE has a      */
/* SST39VF3201/3202 32 Mbit MPF+DEVICE installed or not.                       */
/*                                 &
22楼: >>参与讨论
wangkj init.s
;/*************************************************************************/
;/*                                                                       */
;/* FILE NAME                                            VERSION          */
;/*                                                                       */
;/*      init.s                              SNDS100 Board version 1.0    */
;/*                                                                       */
;/* COMPONENT                                                             */
;/*                                                                       */
;/*                                                                       */
;/* DESCRIPTION                                                           */
;/*                                                                       */
;/*      This file contains the target processor dependent initialization */
;/*      routines (boot code) and data.                                   */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*                                                                       */
;/* DATA STRUCTURES                                                       */
;/*                                                                       */
;/*                                                                       */
;/* FUNCTIONS                                                             */
;/*                                 
23楼: >>参与讨论
wangkj isr.c
/*************************************************************************/
/*                                                                       */
/* FILE NAME                                      VERSION                */
/*                                                                       */
/*      isr.c                               KS32C50100   : version 1.0 */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      Interrupt handler                     &n
24楼: >>参与讨论
wangkj main.c
/*************************************************************************
* FILE NAME                                     VERSION                
*                                                                      
*        44bmain.c                                1.0              
*                                                                      
* COMPONENT                                                            
*                                                                      
*        FLASH Operation such as erase/program                                    
*                                                                      
* DESCRIPTION                                                          
*                                                                      
*            
*                                                                      
* DATA STRUCTURES                                                      
*                                                                      
*               
*                                                                      
* FUNCTIONS                                                            
*
*        
*                                                                      
* DEPENDENCIES                                                         
*        
*       
* HISTORY
*    
*        Meter Chen                2001-7
*                                                               
************************************************************************/

#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "..\inc\snds.h"
//#include "..\inc\flash.h"

#define FLASH_START_ADDR 0x0000
#define FLASH_ADDR_UNLOCK1 0x555
#define FLASH_ADDR_UNLOCK2 0x2aa
25楼: >>参与讨论
wangkj POLLIO.C
/********************************************************************/
/*                                                                  */
/*      Polled I/O  Program for SNDS100                             */
/*                                                                  */
/*------------------------------------------------------------------*/
/*      COPYRIGHT (C)1997 SAMSUNG ELECTRONICS.                     */
/*------------------------------------------------------------------*/
/*                                                                  */
/*      MODIFIED, programmed by qorrha (Jong H. BAIK)               */
/*                                                                  */
/********************************************************************/

/*************************************************************************/
/*                                                                       */
/* FILE NAME                                      VERSION                */
/*                                                                       */
/*      hwinit.c                            KS32C50100   : version 1.0 */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      InitInterrupt(); //Interrupt mode & vector table initialized     */
/*      Rtc_init() ;     //Timer0 used for Rtc clock tick                */
/*                                                                       */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*                                                                       */
/* DATA STRUCTURES                      &nb
26楼: >>参与讨论
wangkj POLLIO.C
/*---------------------------------------------------------------------*/
    /* While val is greater than zero, OUTPUT characters to the string     */
    /* from right to left.                                                 */
    /*---------------------------------------------------------------------*/
    do
    {
        LONG i, tmp;

        /*-----------------------------------------------------------------*/
        /* The next two statements cause problems on the 68000, since that */
        /* processor does not have a 32-bit divide instruction.  They are  */
        /* replaced by functionally equivalent routines.                   */
        /*-----------------------------------------------------------------*/

        /*  *(pt--) = val % 10 + '0';  */
        tmp = val;
        
        
        while (tmp >= 10000.html">10000) tmp -=10000.html">10000;
        while (tmp >= 1000) tmp -= 1000;
        while (tmp >= 100) tmp -= 100;
        
        while ((tmp -= 10) >= 10);
        if (tmp < 0) tmp += 10;
        *(pt--) = (UCHAR)(tmp + '0');
        
        /*   val /= (SHORT)10;        */
        if (val >= 10)
        {
            for (i = 0; val >= 10000.html">100000; i +=10000.html">10000) val -=10000.html">100000;
            for (     ; val >=  10000.html">10000; i +=  1000) val -= 10000.html">10000;
            for (     ; val >=   1000; i +=   100) val -=1000;
            for (     ; val >=    100; i +=    10) val -= 100;
            for (     ; val >=     10; i++) val -= 10;
            val = i;
        }
        else
            val = 0;

        t_count++;
    } while (val != 0);

    while (t_count < f_flags->PRECISION)
    {
        *(pt--) = '0';
        t_count++;
    }

    /*---------------------------------------------------------------------*/
    /* Next check to see if the 0 flag was used in the format and if the   */
    /* current count is less than the specified field width.  If TRUE then */
    /* fill in the leading zeros.  Temporarily leave room in the field for */
    /* an optional plus or minus sign.                                     */
    /*---------------------------------------------------------------------*/
    pt++;
    if (f_flags->zero)
    {
        s_length = strlen(pt);
        while (f_flags->width > s_length + 1)
        {
           *(--pt) = '0';
            s_length += 1;
        }
    }

    /*---------------------------------------------------------------------*/
    /* Add leading plus or minus sign, and/or leading zero if needed.      */
    /*---------------------------------------------------------------------*/
    if (neg)
       *(--pt) = '-';
    else if (f_flags->plus)
       *(--pt) = '+';
    else if (f_flags->space)
        *(--pt) = ' ';
    else if ((f_flags->zero) && (f_flags->width > s_length))
       *(--pt) = '0';
    f_flags->PRECISION = DEFAULT;
    strout(f_flags, pt, strlen(pt));
}

/***********************************************************************/
/*      hexout: OUTPUT a VALUE as a hexadecimalNUMBER                 */
/*                                                                     */
/*      INPUTS: f_flags = ptr to format data structure                 */
/*              arg_pt = ptr to next argument in list                  */
/*                                                         &
27楼: >>参与讨论
wangkj uart.c
/*************************************************************************/
/*                                                                       */
/* FILE NAME                                      VERSION                */
/*                                                                       */
/*      uart.c                                KS32C50100  SNDS100 Ver1.0  */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*                                                                       */
/*************************************************************************/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "apdialog.h"
#include "snds.h"
#include "uart.h"
#include "isr.h"
#include "pollio.h"
#include "sysconf.h"

//#define EX_UCLK    0
/********************************************************************/
/*               INITIALIZE UART GLOBAL VARIABLE                    */
/********************************************************************/

/* Define references to external structures */
SERIAL_DEV   uart_dev_init;
UART_BUFFER  RxQ[NUM_OF_SERIAL_DEV],TxQ[NUM_OF_SERIAL_DEV];



BaudTable U_BaudRate[BAUD_TABLE] = {

#ifdef EX_UCLK
/* for 29.4912MHZ UART clock */
           9600,  0x000bf,
          19200,  0x0005f,
          38400,  0x0002f,
          57600,  0x0001f,
          115200, 0x0000f,
          230400, 0x00007,
          460800, 0x00003
#else
//#ifdef KS32C50100
#if 1
/* for 50MHz/2 UART clock */
           9600,  0x00a20,
          19200,  0x00500,
          38400,  0x00280,
          57600,  0x001a0,
          115200, 0x000d0,
          230400, 0x00060,
          460800, 0x00020   // not available

#else
/* for 33MHZ UART clock */
           9600,  0x000d6,
          19200,  0x0006a,
          38400,  0x00035,
          57600,  0x00023,
          115200, 0x00011,
          230400, 0x00008,
          460800, 0x00008   // not available
#endif
#endif
};


/************************************************************************/
/*                                              
28楼: >>参与讨论
wangkj uart.c

void UARTRxIntOff(uint32 channel)
{
     if(channel) {
    /* Disable Interrupt */
    Disable_Int(nUART1_RX_ERR_INT);
        //Clear_PendingBit(nUART1_RX_ERR_INT) ;
     }
     else {
        /* Disable Interrupt */
    Disable_Int(nUART0_RX_ERR_INT);
        //Clear_PendingBit(nUART0_RX_ERR_INT) ;
     }
}


/************************************************************************/
/*                                                                      */
/*  FUNCTION                               "UART INTERRUPT FUNCTIONS"   */
/*                                                                      */
/*                                                                      */
/*      TxQWr                    Write data to transmit Que.            */
/*      RxQRd                    Read data from receive Que.            */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      These Que management functions can be used in interrupt mode.   */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*      Application routines                                            */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                       &n
29楼: >>参与讨论
wangkj 这是经过我验证,花了我好几个星期的时间。
我没有jtag线,我就是用这个程序把u-boot烧进我的线路板的。
30楼: >>参与讨论
wangkj 线路板完成后的测试验证程序 是在烧FLASH前完成的。
//验证方法是串口看到不断发出的字符,这样证明cpu和串口部分电路是正常的
//然后在进行下一步的调试

/*******************************************************************************

* Institute of AUTOMATION, Chinese Academy of Sciences

* File NAME: main.c

* DESCRIPTION: P0,P1 LEDFLASH.

* Author: JuGuang,Lee

* Date:
ro=0x0 rw=0x0100
******************************************************************************/

#define ULCON0 (*(volatile unsigned *)0x03FFD000) //UART channel0 LINE CONTROL register
#define UCON0 (*(volatile unsigned *)0x03FFD004) //UART channel0 CONTROL register
#define USTAT0 (*(volatile unsigned *)0x03FFD008) //UART channel0 status register
#define UTXBUF0 (*(volatile unsigned *)0x03FFD00c) //UART channel0 transimit holding register
#define URXBUF0 (*(volatile unsigned *)0x03FFD010) //UART channel0 recieve buffer register
#define UBRDIV0 (*(volatile unsigned *)0x03FFD014) //Baud rate divisor register0
#define ULCON1 (*(volatile unsigned *)0x03FFE000) //UART channel1 LINE CONTROL register
#define UCON1 (*(volatile unsigned *)0x03FFE004) //UART channel1 CONTROL register
#define USTAT1 (*(volatile unsigned *)0x03FFE008) //UART channel1 status register
#define UTXBUF1 (*(volatile unsigned *)0x03FFE00c) //UART channel1 transimit holding register
#define URXBUF1 (*(volatile unsigned *)0x03FFE010) //UART channel1 recieve buffer register
#define UBRDIV1 (*(volatile unsigned *)0x03FFE014) //Baud rate divisor register1

void Main(void)

{

int i,j;

*((volatile unsigned LONG *) 0x3ff5000) = 0x00001000;

ULCON1=0x03;
UCON1=0x09;
UBRDIV1=0x500; //19200
UBRDIV1=0x0d0; //115200
//UBRDIV1=0x100; //for slow mode 19200
while(1)            
{

*((volatile unsigned LONG *) 0x3ff5008) = 0x00001000;  //GPIO12

for(j=0; j<0x7fff;j++)
    for(i=0; i<0x10; i++);

*((volatile unsigned LONG *) 0x3ff5008) = 0x00000000;

//for(j=0; j<0x90;j++)
for(i=0; i<0x10; i++)
{
    for(;(!(USTAT1&0x40)););
    //UTXBUF1=0x30+i%9;
    UTXBUF1=0x30+i;
    UTXBUF0=0x36;
    //UTXBUF1=0x36;
}
for(;(!(USTAT1&0x40)););
UTXBUF1='\n';
for(;(!(USTAT1&0x40)););
UTXBUF1='\r';

}

31楼: >>参与讨论
wangkj multice reg 初始化文件
spp semihosting_enabled 0
spp vector_catch 0

com SDRAM, KS32C50100, SFR BASE=0x3ff,SRAM BASE=0x00, Wbuffer dis, cache dis
smem 0x3ff0000  0xE7FF0020 32
smem 0x3ff5000  0x00001000 32
smem 0x3ff5008  0x00001000 32
smem 0x3ff5008  0x00000000 32
reload
br @main
go
32楼: >>参与讨论
wangkj init.S
    IMPORT Main                 ;通知编译器该标号为一个外部标号
    AREA Init,CODE,READONLY     ;定义一个代码段
    ENTRY                         ;定义程序的入口点
    LDR R0,=0x03FF0000             ;初始化系统配置寄存器,disable cache
    LDR R1,=0xE7FF0020            ;SRAM addr is 0,conf addr:0x3ff,0000
    STR R1,[R0]                    ;data and code in 0-0x1fff
    LDR SP,=0x2000-4            ;初始化用户堆栈 booton of SRAM
    BL Main                     ;跳转到Main()函数处的C/C++代码执行
    END                         ;标识汇编程序的结束
33楼: >>参与讨论
wangkj 我已经把我所有的关于FLASH部分的代码贴出来了
关于u-boot,kernel,filesystem部分的修改更多。
甚至我自己用OE完成了一个针对uclinux的cross tool.
估计OE这个东东应该没几个人听说过,别说会用了。
这些部分以后有空了继续贴。
已经贴出的这些,已经够大部分菜鸟消化几个月的了。
我的项目没有完全完成,欢迎高手参与。我可以把我的所有软件硬件共享。
但是,必须是能看得懂的,不欢迎菜鸟。
菜鸟也别伤心,老鸟都是从菜鸟起飞的。只要努力,终究有翱翔蓝天的时刻。
34楼: >>参与讨论
wangkj 我把文件都贡献出来了,没有任何保留。
如果谁再问4510 FLASH的问题,自己从楼上跳下去吧。
35楼: >>参与讨论
wangkj 关于指示灯
*((volatile unsigned LONG *) 0x3ff5008) = 0x00001000;  //GPIO12

for(j=0; j<0x7fff;j++)
    for(i=0; i<0x10; i++);

*((volatile unsigned LONG *) 0x3ff5008) = 0x00000000;
我用GPIO12作程序运行指示灯,这样,UART部分出问题也可以证明cpu部分正常。
如果LED没有变化,说明cpu或LED有问题。可检查GPIO12,如果GPIO12没有电瓶变化,说明cpu有问题。GPIO有变化,则说明led有问题。

之后是uart的验证.UART1以115200bps不断的输出数据。注意是uart1,不是uart0.
我线路板是这么作的。如果用uart0,请在程序中改动。
36楼: >>参与讨论
xwj 赞一个,高风亮节啊
建议将代码加亮显示

告诉你怎样发语法加亮显示的程序代码

37楼: >>参与讨论
bluefire3 好不容易啊,终于找到了
21ic的搜索不是很好用哈,

我用的是4510+1601,ads,MULTI,来烧写

想问问达人几个问题:

0x5555<<1  这个是产生半字地址么?

我的1601接的就是半字,但是不是说4510会自己产生相应的字,半字,字节地址么?为什么还要自己移位呢?


早上打了一下FLASH的几个控制信号,都是好的。
用lumit的sjf4510,找得到cpu,id是0x1d0f0f0f
但是怎么也找不到,FLASH ,是什么原因呢?
绝对不会是虚焊,一个老技术帮忙焊的板
自己仔细对比了1601的datasheep,信号线,地址数据线接的都是对的
而且FLASH是刚换上去的,也不会是坏的。

用axd加MULTI来调试,我用的办法是开代理软件以后,在axd里面setmem来设置几个特殊寄存器,设定为下面的值:
setmem 0x3ff0000,0xE7ffff82,32
setmem 0x3ff3010,0x00003002,32
setmem 0x3ff3014,0x02000060,32
setmem 0x3ff302c,0x4e010390,32
setmem 0x3ff303c,0xce3383f0,32

然后载入一个小程序,汇编开始直接是bl main
然后在main里面试着去读FLASH的id,但是运行的时候,读出来的id老是不对,经常是0xff,这有是为什么呢?

和配置的特殊寄存器有关么?改了很多次,就是没有效果?

下面的是我的main


int Main()
{volatile UINT16 *TEMP;
    UINT16 SST_id1;
    volatile UINT16 *TEMP1;
    UINT16 SST_id2;
    int  ReturnStatus;

  /*  Issue the SOFTWARE PRODUCT ID code to 39VF160   */

    TEMP1 = (volatile UINT16 *)((0x5555<<1)+FLASH_BASE);
    *TEMP1= 0xAAAA;         /* write data 0xAAAA to the address */
    Delay(100);
    TEMP1 = (volatile UINT16 *)((0x2AAA<<1)+FLASH_BASE);
    *TEMP1= 0x5555;       /* write data 0x5555 to the address */
    Delay(100);
    TEMP1 = (volatile UINT16 *)((0x5555<<1)+FLASH_BASE);
    *TEMP1= 0x9090;           /* write data 0x9090 to the address */

    Delay_150_Nano_Seconds();
    /* Read the PRODUCT ID from 39VF160 */
    Delay(100);
    TEMP  = (volatile UINT16 *)((0x00000000<<1)+FLASH_BASE);
    SST_id1  =  *TEMP;         /* get first ID word      */
    SST_id1  =  SST_id1 & 0xFF;      /* mask of higher byte     */
    Delay(100);
    TEMP1 = (volatile UINT16 *)((0x00000001<<1)+FLASH_BASE);
    SST_id2  =  *TEMP1;             /* get second ID word    */

    /* Determine whether there is a SST39VF160 installed or not */

    if ((SST_id1 == SST_ID) && (SST_id2 ==0x234b))
        ReturnStatus = TRUE;
    else
        ReturnStatus = FALSE;





还有一个问题是,4510的datasheep里面的几个特殊寄存器介绍的时候有一些没有用到的位,比如说默认值是000,但是datasheep要求配置成001
但是我看见很多人的代码里面都没有管这个,不影响么?
我应该配置成怎么样的呢?

还有一个问题也是和特殊寄存器有关系。1601连到rom bank0以后,我应该怎么去配置这个特殊寄存器呢?你是怎么确定那些时间应该是几个周期?tas什么的
38楼: >>参与讨论
wangkj 这个程序是我几个月以前搞的,具体我忘记了。
这个程序是我几个月以前搞的,具体我忘记了。肯定是可用的。
读出的ID有问题,看看是不是你的 rom/ram 配置寄存器地址设置错误。就是我的test.ini里面的文件。
至于jtag线我没用过。

你可能感兴趣的:(c,vector,File,Flash,dependencies,delay)