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

📄 burn.c

📁 可以在三星的ARM处理器s3c44b0上移植的bootLoader源代码
💻 C
字号:
/****************************************************************************/
//
// FLASH burnning routine
// Created by Strong Embeded Studio
//         www.8800.org
// If there are any concerns on the code
// go to www.8800.org for discussion
//
/****************************************************************************/

extern char Uart_GetKey(unsigned char ch);
extern void Uart_Printf(unsigned char ch,char *fmt,...);
extern unsigned int GetIndex(unsigned int offset);
extern unsigned int WriteSector(int index,char *data_buffer);

int Burn(void)
{
  char c;
  unsigned int len,wlen,slen;
  unsigned int index, offset;
  //
  // Define the temporary buffer base for burnning flash
  //
  char *buf = (char *)(0x0C700000);
  
  //
  // Clear serial port buffer
  //
  while (Uart_GetKey(0));
  
  //
  // Display the menu
  //
  c = 0;
  while (c<1 || c>3) {
    Uart_Printf(0,"\n1. Burn boot loader!\n");
    Uart_Printf(0,  "2. Burn linux core!\n");
    Uart_Printf(0,  "3. Burn romfs!\n");
    Uart_Printf(0,  "Please choose:");
    
    do {
      c = Uart_GetKey(0);
    } while (!c) ;
    
    Uart_Printf(0,"%c\n\n",c);
    c -= '0';
  }
  
  Uart_Printf(0,"Ready for burning Flash...\n");
  
  c--;
  switch(c) {
    case 0:
      offset = 0x000000;
      len    = 0x010000;
      break;
    case 1:
      offset = 0x020000;
      len    = 0x0D0000;
      break;
    case 2:
      offset = 0x100000;
      len    = 0x0D0000;
      break;
  }

  //
  // Get the sector index from the offset
  //
  index = GetIndex(offset);
  
  //
  // Burn the flash
  //
  slen = 0;
  wlen = 0;
  while (1) {
    Uart_Printf(0,"Burning Flash sector %02d... ", index); 
    slen = WriteSector(index,buf);
    if (slen!=0) Uart_Printf(0,"OK!\n");
    else {
      Uart_Printf(0,"BAD!\n");
      break; 
    }
    wlen += slen;
    if (wlen >= len) break;
    buf += slen;
    index ++;
  }
  Uart_Printf(0,"Finished programming!\n\n");
  Uart_Printf(0,"Please reset your system!\n\n");
  while(1);
  return 1;
}

⌨️ 快捷键说明

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