Exemple #1
0
void fpga_pgm(uint8_t* filename) {
  int MAXRETRIES = 10;
  int retries = MAXRETRIES;
  uint8_t data;
  int i;
  tick_t timeout;
  do {
    i=0;
    timeout = getticks() + 100;
    fpga_set_prog_b(0);
if(BITBAND(PROGBREG->FIOPIN, PROGBBIT)) {
  printf("PROGB is stuck high!\n");
  led_panic();
}
    uart_putc('P');
    fpga_set_prog_b(1);
    while(!fpga_get_initb()){
      if(getticks() > timeout) {
        printf("no response from FPGA trying to initiate configuration!\n");
        led_panic();
      }
    };
    if(fpga_get_done()) {
      printf("DONE is stuck high!\n");
      led_panic();
    }
    LPC_GPIO2->FIOMASK1 = ~(BV(0));
    uart_putc('p');


    /* open configware file */
    file_open(filename, FA_READ);
    if(file_res) {
      uart_putc('?');
      uart_putc(0x30+file_res);
      return;
    }
    uart_putc('C');

    for (;;) {
      data = rle_file_getc();
      i++;
      if (file_status || file_res) break;   /* error or eof */
      FPGA_SEND_BYTE_SERIAL(data);
    }
    uart_putc('c');
    file_close();
    printf("fpga_pgm: %d bytes programmed\n", i);
    delay_ms(1);
  } while (!fpga_get_done() && retries--);
  if(!fpga_get_done()) {
    printf("FPGA failed to configure after %d tries.\n", MAXRETRIES);
    led_panic();
  }
  printf("FPGA configured\n");
  fpga_postinit();
}
Exemple #2
0
void fpga_rompgm() {
  int MAXRETRIES = 10;
  int retries = MAXRETRIES;
  uint8_t data;
  int i;
  tick_t timeout;
  do {
    i=0;
    timeout = getticks() + 100;
    fpga_set_prog_b(0);
    uart_putc('P');
    fpga_set_prog_b(1);
    while(!fpga_get_initb()){
      if(getticks() > timeout) {
        printf("no response from FPGA trying to initiate configuration!\n");
        led_panic(LED_PANIC_FPGA_NO_INITB);
      }
    };
    timeout = getticks() + 100;
    while(fpga_get_done()) {
      if(getticks() > timeout) {
        printf("DONE is stuck high!\n");
        led_panic(LED_PANIC_FPGA_DONE_STUCK);
      }
    }
    LPC_GPIO2->FIOMASK1 = ~(BV(0));
    uart_putc('p');

    /* open configware file */
    rle_mem_init(cfgware, sizeof(cfgware));
    printf("sizeof(cfgware) = %d\n", sizeof(cfgware));
    for (;;) {
      data = rle_mem_getc();
      if(rle_state) break;
      i++;
      FPGA_SEND_BYTE_SERIAL(data);
    }
    uart_putc('c');
    printf("fpga_rompgm: %d bytes programmed\n", i);
    delay_ms(1);
  } while (!fpga_get_done() && retries--);
  if(!fpga_get_done()) {
    printf("FPGA failed to configure after %d tries.\n", MAXRETRIES);
    led_panic(LED_PANIC_FPGA_NOCONF);
  }
  printf("FPGA configured\n");
  fpga_config = FPGA_ROM;
  fpga_postinit();
}