The LPC11xx IAP provides function to call the ISP in the BootROM from user code. Here's an example of how to use it. The code is based on UART example for LPC1114 (for LPCXpresso)

The first thing is that, if you have LPC11xx UART enabled, you need to disable it, including the interrupts

static void StopUART(void)
{
  uint32_t temp;

  /* Disable UART interrupts */
  LPC_UART->IER = 0;
  /* Disable UART interrupts in NVIC */
  NVIC_DisableIRQ(UART_IRQn);

  /* Ensure a clean start, no data in either TX or RX FIFO. */
  while (( LPC_UART->LSR & (LSR_THRE|LSR_TEMT)) != (LSR_THRE|LSR_TEMT) );
  while ( LPC_UART->LSR & LSR_RDR )
  {
temp = LPC_UART->RBR; /* Dump data from RX FIFO */
  }

  /* Read to clear the line status. */
  temp = LPC_UART->LSR;
}

Then, turn on Timer32B1, GPIO and IOCON block in the SYSAHBCLKCTRL, set the stack pointer to the BootROM's requirement, and execute the IAP command 57.

typedef void (*IAP)(unsigned int[], unsigned int[]);

static void ReinvokeISP(void) {
  IAP iap_entry = (IAP) 0x1fff1ff1;
  uint32_t command[5], result[4];

  /* make sure 32-bit Timer 1 is turned on before calling ISP */
  LPC_SYSCON->SYSAHBCLKCTRL |= 0x00400;
  /* make sure GPIO clock is turned on before calling ISP */
  LPC_SYSCON->SYSAHBCLKCTRL |= 0x00040;
  /* make sure IO configuration clock is turned on before calling ISP */
  LPC_SYSCON->SYSAHBCLKCTRL |= 0x10000;
  /* make sure AHB clock divider is 1:1 */
  LPC_SYSCON->SYSAHBCLKDIV = 1;

  /* Send Reinvoke ISP command to ISP entry point*/
  command[0] = 57;

  /* Set stack pointer to ROM value (reset default).
     This must be the last piece of code executed before calling ISP,
     because most C expressions and function returns will fail after
     the stack pointer is changed.
   */

  __set_MSP(*((uint32_t *) 0x1FFF0000)); /* inline asm */

  /* Invoke ISP. We call "iap_entry" to invoke ISP because the ISP entry
     is done through the same command interface as IAP. */

  iap_entry(command, result);

  // Code will never return!
}

Lastly, before you can run your new code (assuming you are upgrading / replacing the firmware using ISP), you will need to reset the MCU.

 

Вот и я озаботился подобной проблемой.

И так, предположим, мы имеем нужный нам BIN файл, который нормально прошивается под Windows XP/7.

При подключении под Linux LPC1343 видится как страндартный диск, к примеру на /dev/sdc, тогда команды для прошивки девайса будут следующие:

 sudo mdel -i /dev/sdc ::/firmware.bin
 sudo mcopy -i /dev/sdc firmware.bin ::/
 sudo umount /dev/sdc

В принципе, кому надо могут оформить это для удобства в скрипт.

 

Конечно, можно воспользоваться уже готовыми, например: CodeSourcery G++ Lite or Yagarto, но мы не ищем легких путей!

Для чего это надо?

Лишь в новой версии GCC 4.5 появилась поддержка ARM Cortex-M0, на этом ядре сделан новый микроконтроллер от NXP — LPC11xx, который я планирую использовать в одной из своих новых разработок. Маленький, энергоэффективный, и дешевый!

Сборка.

 

Шаг 1. MinGW и MSYS

Если у вас не установлены MinGW и MSYS с возможным вариантом установки вы можете ознакомится в моем посте «Установка MinGW32 и MSYS в Windows»

Если у вас они уже установлены, необходимо проверить наличие библиотек:

© 2011 ADTL Blog Suffusion theme by Sayontan Sinha