Python flash script

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Mar 31, 2018 by paolo subiaco
Content originally posted in LPCWare by Floyd42 on Thu Mar 20 12:28:51 MST 2014

I've created a python flashing app. Might come handy for other people also.

Usage example to flash "blink.bin", then reset the device and run it:

flushmagic.py -p /dev/ttyUSB1 -r blink.bin

Together with a UART interrupt handler that support resetting the device, one can program and test without even touching the hardware (as long as the programm is working)

typedef void (*IAP)(uint32_t*, uint32_t*);
#define IAP_ENTRY ((IAP)0x1fff1ff1)

void intHdl_UART0(void)
  if (0 != (LPC8xx_UART->stat & UART_STAT_RXRDY))
    char c = (char)(LPC8xx_UART->rxDat)
    switch (c)
      case 'r': // reset
        LPC8xx_SCS->AIRCR = 0x05fa0004;
        for(;;) { } // Loop forever as fail safe option

      case 'i': // reset into ISP
        { uint32_t cmd = 57;
          IAP_ENTRY( &cmd, NULL); }

Then one can use:

$ make && flushmagic.py -p /dev/ttyUSB1 -r blink.bin && picocom -b 115200 /dev/ttyUSB1

And in picocom just type "i" and then press "CTRL+a" and the "x" to get back to the command line to flash again.


Original Attachment has been moved to: flushmagic.py_.txt.zip