jtagupd.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "fw.h"
  2. #include "io.h"
  3. #include "sys.h"
  4. #include "console.h"
  5. #define VJTAG_FLASH_CMD 0xabc80046
  6. /* IRQ handler not needed in this system */
  7. IRQHANDLER_DECL(spurious,0);
  8. IRQHANDLER(abc,0)
  9. {
  10. irqhandler_spurious_0(vector, pc);
  11. }
  12. IRQHANDLER(tty,1)
  13. {
  14. irqhandler_spurious_0(vector, pc);
  15. }
  16. IRQHANDLER(romcopy,0)
  17. {
  18. irqhandler_spurious_0(vector, pc);
  19. }
  20. /*
  21. * SDRAM upload buffer - always first in SDRAM
  22. */
  23. static uint8_t __attribute__((section(".jtag_flash_buffer")))
  24. jtag_flash_buf[17 << 20]; /* 16 MB + some slack */
  25. void main(void)
  26. {
  27. static const char hello[] =
  28. "\n\nMAX80 JTAG update firmware compiled on: ";
  29. unmask_irqs((1U << EBREAK_IRQ)|(1U << BUSERR_IRQ));
  30. romcopy_bzero(__dram_bss_start, __dram_bss_end - __dram_bss_start);
  31. con_puts(hello);
  32. con_puts(__datestamp);
  33. con_putc('\n');
  34. while (1) {
  35. uint32_t cmd;
  36. waitfor(VJTAG_IRQ);
  37. cmd = VJTAG_CPUCMD;
  38. if (cmd != VJTAG_FLASH_CMD)
  39. con_printf("JTAG: unknown command: 0x%08x\n", cmd);
  40. con_puts("JTAG: starting firmware flash process\n");
  41. rom_flash_from_memory(jtag_flash_buf, sizeof jtag_flash_buf);
  42. }
  43. }