I have purchased this LPC1788FBD144,551 MCU and this LPC1313FBD48/01,15 MCU and I want to install a bootloader in assembly on them which can call a function in C. How can I install the bootloader on the ARM MCU? Would I install it directly on the MCU or on a separate component (if so can you show me which part on the newark website)?

  • \$\begingroup\$ Have you verified that there is not already one there from the factory? Bootloader for what external interface? \$\endgroup\$ Mar 21, 2013 at 15:20
  • \$\begingroup\$ @ChrisStratton I want to create a custom bootloader for the device. \$\endgroup\$
    – Coder404
    Mar 21, 2013 at 15:32
  • \$\begingroup\$ So you say, but first you are going to have to decide what you want your bootloader to do, and research the capabilities of the target chips - what they already do, if they support partial locking of pages, if they have enough ram to run the bootloaded application there rather than flashing it (if you prefer), etc. \$\endgroup\$ Mar 21, 2013 at 15:41

2 Answers 2


Both devices have on-chip bootloaders that will always be executed. With the LPC17xx, you can write a secondary bootloader to execute custom code that will run directly after. You simply need to direct your IDE to place the code at location 0x00.

On the documentation page, have a look at AN11257 and AN11258. These discuss creating secondary bootloaders (SBL) to load code from SPI or I2C respectively. This could retrieve code from a PC or an external memory device.

From AN11257:

In these MCUs, the primary boot loader resides in the boot block. The boot loader is executed every time the part is powered on or reset. It can execute the ISP command handler or the user application code, which is stored in sector 0 of internal flash memory.

The SBL in this project refers to a user-defined application that provides the user with an option to update the User Application Firmware or execute the previously programmed User Application Firmware. It is placed from the address 0x00 so that when the primary boot loader runs user application, it executes first.

I couldn't find similar documentation on the LPC13xx. But it's primary bootloader has a bit more functionality built-in. Specifically the ability to load new programs via UART. Your version lacks the USB functionality they talk about in the User Guide:

The bootloader code is executed every time the part is powered on or reset (see Figure 63). The loader can either execute the ISP command handler or the user application code, or it can obtain the boot image as an attached MSC device through USB. A LOW level during reset at the PIO0_1 pin is considered an external hardware request to start the ISP command handler or the USB device enumeration without checking for a valid user code first. The state of PIO0_3 determines whether the UART or USB interface will be used:

• If PIO0_3 is sampled HIGH, the bootloader connects the LPC134x as a MSC USB device to a PC host. The LPC134x flash memory space is represented as a drive in the host’s Windows operating system.

• If PIO0_3 is sampled LOW, the bootloader configures the UART serial port and calls the ISP command handler.

Remark: On the LPC131x parts (no USB), the state of pin PIO0_3 does not matter.

You can still make the first instructions executed after the primary bootloader act as a custom secondary bootloader. You just need to locate that code at the proper address. How this is done is heavily dependent on your IDE. Refer to your IDE's documentation on how to properly control code placement into the desired sectors.

  • \$\begingroup\$ If I do this from my mac how could I set my IDE so that it sets the address to 0x00? Specifically with nasm or gcc? \$\endgroup\$
    – Coder404
    Mar 21, 2013 at 20:28
  • \$\begingroup\$ @Coder404 You'll have to create a linker file for gcc that places the object file of your bootloader code at a specific section located at a specific address. Take a look at the second to last example here where they place the all object file into the outputa section at address 0x10000. I would also suggest telling gcc to print a map file to make sure you got it right. \$\endgroup\$ Mar 21, 2013 at 20:43
  • \$\begingroup\$ What kind of a physical connection would I use to install the code onto the MCU? \$\endgroup\$
    – Coder404
    Mar 22, 2013 at 3:07
  • \$\begingroup\$ @Coder404 The short answer is: serial bus. But each chip is slightly different. See Chapter 32 of the LPC17xx User Manual and Chapter 21 of the LPC13xx User Manual for the details. \$\endgroup\$ Mar 22, 2013 at 12:03
  • \$\begingroup\$ You would not install the bootloader since it is already there from the factory. To communicate with the bootloader you would need to use an interface it supports - you'll need to see the documentation for the specific chip, but commonly some subset of logic-level serial, SPI, or USB is supported. \$\endgroup\$ Mar 27, 2013 at 4:52

I would say everything you need is already provided by NXP.

It is the same principle for all LPC1700 microcontrollers, so either use the Flashmagic tool, or call IAP (In Application Programming) functions to provide your own custom bootloader. You usually have to do so if you need the boot loadwer running over Ethernet or USB, and not via the RS232. Still, it does make sense to call IAP functions for Flash programming, and not to do it yourself.

Check this thread, answers provided by Zero and Rob68 are always high quality straight to the problem.

Download the Flashmagic tool, and study it's users manual (provided in PDF). Your devices are supprted.

Check also this link where some more specific problems were discussed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.