⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 u241mon.c

📁 2410 boot loader,usb ftp
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************
 NAME: u241mon.c
 DESC: u241mon entry point,menu,download
 HISTORY:
 Mar.25.2002:purnnamu: S3C2400X profile.c is ported for S3C2410X.
 Mar.27.2002:purnnamu: DMA is enabled.
 Apr.01.2002:purnnamu: isDownloadReady flag is added.
 Apr.10.2002:purnnamu: - Selecting menu is available in the waiting loop. 
                         So, isDownloadReady flag gets not needed
                       - UART ch.1 can be selected for the console.
 Aug.20.2002:purnnamu: revision number change 0.2 -> R1.1       
 Sep.03.2002:purnnamu: To remove the power noise in the USB signal, the unused CLKOUT0,1 is disabled.
 ****************************************************************/

#include <stdlib.h>
#include <string.h>
#include "def.h"
#include "option.h"
#include "2410addr.h"
#include "2410lib.h"
#include "2410slib.h"
#include "mmu.h"
#include "profile.h"
#include "memtest.h"

#include "usbmain.h"
#include "usbout.h"
#include "usblib.h"
#include "2410usb.h"

static void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void Lcd_Off(void);
int  WaitDownload(void);
void Menu(void);

//#define DOWNLOAD_ADDRESS _RAM_STARTADDRESS
extern U32 downloadAddress;

static void (*restart)(void)=(void (*)(void))0x0;
static void (*run)(void);


static volatile unsigned char *downPt;
volatile U32 downloadFileSize;
volatile U16 checkSum;
volatile unsigned int err=0;
volatile U32 totalDmaCount;

volatile int isUsbdSetConfiguration;

int download_run=0;
U32 tempDownloadAddress;
int menuUsed=0;
static int easymode=0;

extern char Image$$RW$$Limit[];
U32 *pMagicNum=(U32 *)Image$$RW$$Limit;
int consoleNum;

void u241mon(void)
{
    char *mode;
    int i;
    U8 key;
   
    
    #if ADS10   
    __rt_lib_init(); //for ADS 1.0
    #endif

    menuUsed=0;
    
    //ChangeClockDivider(1,1);    // 1:2:4    
    //ChangeMPllValue(82,2,1);  //FCLK=135.0Mhz     
    //ChangeMPllValue(82,1,1);    //FCLK=180.0Mhz     
    //ChangeMPllValue(161,3,1); //FCLK=202.8Mhz     
    
    //Port_Init();
    rGPGUP &= ~(1<<9); /* Enable GPG9 */
    rGPGDAT |= (1<<9); /* set GPG9 high */    
    
    rGPHCON = rGPHCON&~(0xf<<18)|(0x5<<18);   
    //To enhance the USB signal quality.
    //CLKOUT 0,1=OUTPUT to reduce the power consumption.
    
    Isr_Init();
    if(*pMagicNum!=0x12345678)
    	consoleNum=0;
    else
    	consoleNum=1;
    	
    //Uart_Init(0,115200);
    //Uart_Select(consoleNum);

    rMISCCR=rMISCCR&~(1<<3); // USBD is selected instead of USBH1 
    rMISCCR=rMISCCR&~(1<<13); // USB port 1 is enabled.

//
//  USBD should be initialized first of all.
//
    isUsbdSetConfiguration=0;

#if 0
    UsbdMain(); 
    MMU_Init(); //MMU should be reconfigured or turned off for the debugger, 
    //After downloading, MMU should be turned off for the MMU based program,such as WinCE.	
#else
    MMU_EnableICache();  
    UsbdMain(); 
#endif
    Delay(0);  //calibrate Delay()
    
    pISR_SWI=(_ISR_STARTADDRESS+0xf0);    //for pSOS

    Led_Display(0x6);

#if USBDMA
    mode="DMA";
#else
    mode="Int";
#endif

    Uart_Printf("\n\n");
    Uart_Printf("+---------------------------------------------+\n");
    Uart_Printf("| S3C2410X USB Downloader ver R1.11 SEP/03/02 |\n");
    Uart_Printf("+---------------------------------------------+\n");
    Uart_Printf("FCLK=%dMHz,%s mode\n",FCLK/1000000,mode); 
    Uart_Printf("USB: IN_ENDPOINT:1 OUT_ENDPOINT:3\n"); 
    Uart_Printf("FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>\n");
    Uart_Printf("NOTE: 1. Power off/on or press the reset button for 1 sec\n");
    Uart_Printf("         in order to get a valid USB device address.\n");
    Uart_Printf("      2. For additional menu, Press any key. \n");
    Uart_Printf("\n");

    download_run=1; //The default menu is the Download & Run mode.

    while(1)
    {
    	if(menuUsed==-1)
    	{
    	 rGPGUP  &= ~(1<<9); /* Enable GPG9 */
         rGPGDAT &= ~(1<<9); /* set GPG9 low */ 	 
    	 return;
    	}
    	else if(menuUsed==1)Menu();
    	WaitDownload();    
    }

}

int u241mon_easy(unsigned int downaddr)
{
    char *mode;
    int i;
    U8 key;
   
    #if ADS10   
    __rt_lib_init(); //for ADS 1.0
    #endif

try_again:

    menuUsed=0;
    Uart_SendString("\n");

    //ChangeClockDivider(1,1);    // 1:2:4    
    //ChangeMPllValue(82,2,1);  //FCLK=135.0Mhz     
    //ChangeMPllValue(82,1,1);    //FCLK=180.0Mhz     
    //ChangeMPllValue(161,3,1); //FCLK=202.8Mhz  

    
    //Port_Init();
    
   
    rGPHCON = rGPHCON&~(0xf<<18)|(0x5<<18);   
    //To enhance the USB signal quality.
    //CLKOUT 0,1=OUTPUT to reduce the power consumption.
 
    
    Isr_Init();
    if(*pMagicNum!=0x12345678)
    	consoleNum=0;
    else
    	consoleNum=1;
    	
    //Uart_Init2(0,115200);
    //Uart_Select(0);

    rMISCCR=rMISCCR&~(1<<3); // USBD is selected instead of USBH1 
    rMISCCR=rMISCCR&~(1<<13); // USB port 1 is enabled.
    Delay(100);  //calibrate Delay()
 
//
//  USBD should be initialized first of all.
//
    isUsbdSetConfiguration=0;

#if 0
    UsbdMain(); 
    MMU_Init(); //MMU should be reconfigured or turned off for the debugger, 
    //After downloading, MMU should be turned off for the MMU based program,such as WinCE.	
#else
    MMU_EnableICache();     
    UsbdMain(); 
#endif
    Delay(0);  //calibrate Delay()
  
    
    pISR_SWI=(_ISR_STARTADDRESS+0xf0);    //for pSOS

    Led_Display(0x6);

 
#if USBDMA
    mode="DMA";
#else
    mode="Int";
#endif
    /*
    Uart_SendString("\n\n");
    Uart_SendString("+---------------------------------------------+\n");
    Uart_SendString("| S3C2410X USB Downloader ver R1.11 SEP/03/02 |\n");
    Uart_SendString("+---------------------------------------------+\n");
    Uart_Printf("FCLK=%dMHz,%s mode\n",FCLK/1000000,mode); 
    Uart_SendString("USB: IN_ENDPOINT:1 OUT_ENDPOINT:3\n"); 
    Uart_SendString("FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>\n");
    Uart_SendString("NOTE: 1. Power off/on or press the reset button for 1 sec\n");
    Uart_SendString("         in order to get a valid USB device address.\n");
    Uart_SendString("      2. For additional menu, Press any key. \n");
    Uart_SendString("\n");
    */
    
     rGPGUP &= ~(1<<9); /* Enable GPG9 */
     rGPGDAT |= (1<<9); /* set GPG9 high */
     Delay(1000);  //calibrate Delay()    
    
    easymode = 1;
    
     if(menuUsed==1)Menu();
     
     tempDownloadAddress=downaddr;
     download_run = 0;   
      
     i = WaitDownload();

     rGPGUP &= ~(1<<9); /* Enable GPG9 */
     rGPGDAT &= ~(1<<9); /* set GPG9 low */
          
    easymode = 0;

    if(!i)
    {
      Uart_SendString("\nTry again? [Y/N] ");
      key = Uart_Getch();
      Uart_Printf("%c\n", key);
      Delay(1000);  //calibrate Delay()      
      Delay(1000);  //calibrate Delay()            
      if(key=='y' || key=='Y')   
        goto try_again;	
    }

    if(downloadFileSize)
     return 0;
    else
     return -1;
 
}

void Menu(void)
{
    int i;
    U8 key;
    menuUsed=1;
    while(1)
    {
        Uart_Printf("\n###### Select Menu ######\n");
        Uart_Printf(" [0] Download & Run\n");
        Uart_Printf(" [1] Download Only\n");
        Uart_Printf(" [2] Test SDRAM \n");
        Uart_Printf(" [3] Change The Console UART Ch.\n");
        Uart_Printf(" [4] Exit\n");

        if(!easymode)
         key=Uart_Getch();
        else
         key='1';
        
        switch(key)
        {
        case '0':
            Uart_SendString("\nDownload&Run is selected.\n\n");
            download_run=1;
            return;
        case '1':
            Uart_SendString("\nDownload Only is selected.\n");
            Uart_SendString("Enter a new temporary download address(0x3...):");
            if(!easymode)
             tempDownloadAddress=Uart_GetIntNum();
            else
            {
             tempDownloadAddress=DOWN_RAM_ADDR;
             Uart_Printf("0x%08x\n", DOWN_RAM_ADDR);
            }
            download_run=0;
            Uart_Printf("The temporary download address is 0x%x.\n\n",tempDownloadAddress);
            return; 
        case '2':
            Uart_SendString("\nMemory Test is selected.\n");        
	    MemoryTest();
	    Menu();
	    return;
            break;
        case '3':
            Uart_SendString("\nWhich UART channel do you want to use for the console?[0/1]\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -