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

📄 burn.c

📁 一个44b0的例子
💻 C
字号:
#include "burnlib.h"

//***************************************************************************
#define U32 unsigned int
#define U16 unsigned short
#define S32 int
#define S16 short int
#define U8  unsigned char
#define S8  char
#define uint unsigned int

extern char Uart_GetKey(U8 ch);
extern void Uart_Printf(U8 ch,char *fmt,...);

 
uint Burn(void)
{
  char c;
  uint len,wlen,slen;
  uint index, offset;
  char *buf = (char *)(0x0C700000);
  
  while (Uart_GetKey(0));
  
  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);
      if (!c)  c = Uart_GetKey(1);
    } 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;
  }

  index = GetIndex(offset);
  
  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 + -