示例#1
0
XStatus load_srec(char *filename, Xuint32 *start_address)
{
  SYSACE_FILE *infile;
  SRecord      sr;
  XStatus      status;
  Xint32       cpt;

  cpt = 1;
  infile = sysace_fopen(filename, "r");
  if (infile)
  {
    xil_printf("Loading S-record file %s...\r\n", filename);
    status = read_SRecord(infile, &sr);
    while (status == XST_SUCCESS)
    {
      status = check_SRecord(&sr);
      if (status != XST_SUCCESS)
      {
        xil_printf("ERROR: checksum error at line %d", cpt);
        return;
      }
      status = load_SRecord(&sr, start_address);
      if (status != XST_SUCCESS)
      {
        xil_printf("ERROR: memory error at line %d", cpt);
        return;
      }
      cpt++;
      status = read_SRecord(infile, &sr);
    }
    sysace_fclose(infile);
    xil_printf("Loading S-record file %s... done !\r\n", filename);
    xil_printf("Program start address is 0x%08X\r\n", *start_address);
    return XST_SUCCESS;
  }
  else
  {
    xil_printf("Unable to open file %s.\r\n", filename);
  return XST_FAILURE;
  }
}
示例#2
0
文件: bootloader.c 项目: rihuber/ma
int main()
{
    SYSACE_FILE *srec_file;
    char         file_name[20];
    char        *p;
    uint8_t      ret;
    int          choice, bytes, total_bytes;

    /* Set a well-known "return to loader" vector*/
    set_ret_to_loader_vec();

    /* Initialize RS232_Uart_1 - Set baudrate and number of stop bits */
    XUartNs550_SetBaud(XPAR_RS232_UART_1_BASEADDR, XPAR_XUARTNS550_CLOCK_HZ,
                       9600);
    XUartNs550_SetLineControlReg(XPAR_RS232_UART_1_BASEADDR,
                                  XUN_LCR_8_DATA_BITS);

    print("\n\r********************************************************");
    print("\n\r********************************************************");
    print("\n\r**     Xilinx Virtex-6 FPGA ML605 Evaluation Kit      **");
    print("\n\r********************************************************");
    print("\n\r********************************************************\r\n");

    do {
        print("Choose Feature to Test:\r\n");
        print("1: UART Test\r\n");
        print("2: LED Test\r\n");
        print("3: Timer Test\r\n");
        print("4: FLASH Test\r\n");
        print("5: IIC Test\r\n");
        print("6: Ethernet Loopback Test\r\n");
        print("7: Switch Test\r\n");
        print("8: External Memory Test\r\n");
        print("9: System Monitor Test\r\n");
        print("A: PushButton Test\r\n");
        print("B: LCD Test\r\n");
        print("C: System ACE CF Test\r\n");
        print("D: DVI/VGA Test\r\n");
        choice = inbyte();

        if (isalpha(choice)) {
            choice = toupper(choice);
        }

    } while (!isdigit(choice) && (choice < 'A' || choice > 'D')) ;
    xil_printf("%c\r\n", choice);

    sprintf(file_name, "bist\\%c.rec", choice);
    srec_file = sysace_fopen(file_name, "r");
    if (srec_file == 0) {
        printf("\r\nUnable to open %s\r\n", file_name);
        return 1;
    }

    /*
     * Read the SRECORDS in the selected file into RAM.
     */
    flbuf = (char*)(XPAR_DDR3_SDRAM_MPMC_BASEADDR + 0x100000);
    p = flbuf;
    total_bytes = 0;
    xil_printf("Reading SRECORDS from Compact Flash file %s:\r\n", file_name);
    do {
        bytes = sysace_fread(p, 1, 0x100000, srec_file);
        p += bytes;
        total_bytes += bytes;
    } while (bytes > 0);
    sysace_fclose(srec_file);

    xil_printf("\r\n%d bytes read from file. SRECORDS at: 0x%x\r\n",
        total_bytes, (unsigned)flbuf);

    ret = load_exec ();

    /* If we reach here, we are in error */

#ifdef VERBOSE
    if (ret > LD_SREC_LINE_ERROR) {
        print ("ERROR in SREC line: ");
        putnum (srec_line);
        print (errors[ret]);
    } else {
        print ("ERROR: ");
        print (errors[ret]);
    }
#endif

    return ret;
}