jtagupd.c 1.1 KB

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