Python flash script

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Python flash script

1,049 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Floyd42 on Thu Mar 20 12:28:51 MST 2014
Hi,

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
        break;

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


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.


Axel

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

Labels (1)
1 Reply

611 Views
psubiaco
Contributor II

Hi. I'm new with LPC8xx programming. I'd like to know how long it takes to program 16 or 32kb of flash, by Linux, using

1. ISP via USART

2. SWD with SEGGER jLink or similar

3. which cheap tool do you suggest for mass production (3000pcs/month, not too much)

I'm just drawing a PCB for LPC804M101JDH20 and I don't know if it's better to use ISP or SWD to program flash, in production.

Thanks for any suggestion! (I'm just starting)