jtagupd.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. IRQHANDLER(abc,0)
  8. {
  9. irqhandler_spurious_0(vector);
  10. }
  11. IRQHANDLER(tty,1)
  12. {
  13. irqhandler_spurious_0(vector);
  14. }
  15. /*
  16. * SDRAM upload buffer - always first in SDRAM
  17. */
  18. static uint8_t __attribute__((section(".jtag_flash_buffer")))
  19. jtag_flash_buf[17 << 20]; /* 16 MB + some slack */
  20. void main(void)
  21. {
  22. static const char hello[] =
  23. "\n\nMAX80 JTAG update firmware compiled on: ";
  24. unmask_irqs((1U << ROMCOPY_IRQ)|(1U << EBREAK_IRQ)|(1U << BUSERR_IRQ));
  25. con_puts(hello);
  26. con_puts(__datestamp);
  27. con_putc('\n');
  28. wait_romcopy_done();
  29. while (1) {
  30. uint32_t cmd;
  31. waitfor(VJTAG_IRQ);
  32. cmd = VJTAG_CPUCMD;
  33. if (cmd == VJTAG_FLASH_CMD) {
  34. con_puts("JTAG: starting firmware flash process\n");
  35. rom_flash_from_memory(jtag_flash_buf, sizeof jtag_flash_buf);
  36. con_puts("JTAG: firmware flash process failed\n");
  37. } else {
  38. con_printf("JTAG: unknown command: 0x%08x\n", cmd);
  39. }
  40. }
  41. }