jtagupd.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. rom_print_serial();
  32. while (1) {
  33. uint32_t cmd;
  34. waitfor(VJTAG_IRQ);
  35. eoi(VJTAG_IRQ);
  36. cmd = VJTAG_CPUCMD;
  37. if (cmd == VJTAG_FLASH_CMD) {
  38. con_puts("JTAG: starting firmware flash process\n");
  39. rom_flash_from_memory(jtag_flash_buf, sizeof jtag_flash_buf);
  40. con_puts("JTAG: firmware flash process failed\n");
  41. } else {
  42. con_printf("JTAG: unknown command: 0x%08x\n", cmd);
  43. }
  44. }
  45. }