Saturday , September 23 2017

USB Secondary Bootloader LPC1768 Cortex-M3

USB Secondary bootloader LPC1768 Cortex-M3 is cool trick one can use to program Microcontroller over USB without a use of any JTAG Programmer/hardware adapter. NXP has provided a USB secondary bootloader as a sample program along with its application note on how to use mass storage device class. We’ll focus on its application. You’ll need Keil µVision4 to compile the code. You can download entire project from here USB Secondary Bootloader LPC1768 Cortex-M3.

What is Bootloader?

A bootloader is an application whose primary purpose is to allow a systems software to be updated without use of any specialized hardware such as a JTAG Programmer. In certain cases, It can also be the earliest point at which the integrity of an embedded system can be checked. The bootloader manages the system images. They can communicate over a variety of protocols such as USART, USB, CAN, SPI, I2C and list goes on for as many protocols that exist. Systems with bootloader have at least two program images coexisting on the same microcontroller. It must include branch code that performs a check to see if an attempt to update software is in progress.

Why would you use USB Bootloader?

Bootloader is not a new idea; in fact bootloading & bootstrapping are very commonly used techniques in embedded systems from 1950’s. As a embedded software developer you’ll often use this technique to update firmware when your device is situated into end product. As JTAG Debugger has been working quite well but it needs a parallel port which most laptops including my own lacks. Also loading code into the LPC1768 ARM Cortex-M3 over serial port is painfully slow process. Instead LPC17xx conveniently support USB device interface which can be used for bootloading.

How do you use USB Secondary Bootloader?

First of all we need to program hex file from USB Secondary Bootloader project. We can do this using either JTAG Programmer or serial port (UART0 ISP Mode). The bootloader code will upon RESET check the status of certain pin and decide whether to enter into bootloader mode or execute the user code. If you have development board then you have to press RESET switch followed by ISP switch (connected to pin P2.10). And you’ll quickly notice that your board will detect as a USB mass storage device. The idea is to capture status of pin P2.10 (not immediately after RESET but after a gap of a second or two). Now just copy your binary image of latest microcontroller firmware(.bin file) onto newly detected drive. Then you only have to press RESET switch and you’re done. You’ll find that your microcontroller execute latest firmware on the device. This is how you can press few buttons and update your firmware or bug fixes in your application/project.

Please watch this video demonstration. We have shown step-by-step, how to update firmware of microcontroller using USB Secondary Bootloader LPC1768 Cortex-M3.

Now you know everything about USB Secondary Bootloader in LPC1768 Cortex-M3 Microcontroller. Feel free to experiment with code and have a fun. I hope you’ll find this post educational and entertaining.

Buy Cortex-M3 LPC1768 Microcontroller Kit

Buy Cortex-M3 LPC1768 Microcontroller Kit

About Umesh Lokhande

Umesh Lokhande holds a Master degree in Scientific Instrumentation from University of Applied Sciences Jena, Germany. and has previously worked at Orbotech, Alere Technologies etc. Umesh is also a founder and first author of BINARYUPDATES.COM

11 comments

  1. Dear Sir/Madam,

    I am new in ARM LPC1768 processor. I have lot of confusion to buy one LPC1768 development bord. So, you could share your suggestion. I saw your how to update firmware of microcontroller using USB Secondary Bootloader LPC1768 Cortex-M3 video from youtube. so, you could share your development procurement link.

    Please kindly do needful.

    Thanks and Regards,
    Rajavel R
    email id : [email protected]

    • Hello Rajavel,

      I received your mail and wait for my reply. As long as board selection concern, i know in India(Bangalore) we have plenty of suppliers you can either use from Coinel Technology solution or from NGX Technologies. They called it BlueBord which is compatible with the hardware that I have shown in video and post.

      *Soon you’ll find affiliate links of products to buy from BINARYUPDATES.COM itself. As I am doing busy it may take a while

      Anythig more feel free to post in comment section

      Happy Programming

      CHeers

  2. Thank you for your response.

    I have one doubt. First time how did you dump USB secondary boot loader to lpc1768 processor via JTAG, USB or some other programming method.?

    Please share your valuable thought’s.

    • Hello Rajavel,

      I have shown all of three processes to program LPC1768 in my video series/blog post. Loading bootloader code is same as loading any other .HEX file into LPC1768. I have programmed USB Secondary bootloader code using FTDI Cable in ISP Mode. Here is post for your reference: http://www.binaryupdates.com/flash-magic-to-program-lpc1768-cortex-m3/

      Once you load your .HEX file from USB Secondary Bootloader project which shared on post for free to download. If you’re chip running USB bootloader code then you just simply need to press button ISP switch followed by RESET switch and your board will recognized as USB device. Then simply paste your .BIN file all the time on newly detected USB device and you get your chip programmed.

      I hope this would answered your question. If you have any more questions feel free to post in comment section of post so that it would be easy to navigate problem/issue.

      I wish you beautiful day

      CHeers

  3. Hi Umesh Lokhande, and first I think you for your email replay 🙂

    I have seen the video and read this post, and I found theme very educational and helpful. I thank you so much.

    Now, I want to ask you some questions if you dont mind, and hope you will help me to get the right way to reach my objectives.

    I wish to build a system around a LPC1788. I’m working on the following development bord for prototyping:
    https://www.olimex.com/Products/Modules/LCD/MOD-LCD4.3”/open-source-hardware

    Before this challenge, I have always worked on Microchip PIC or the mbed board (LPC1768). It was funny but easy, you see :).

    My objective now is:
    – Learn more about LPC1788 programming,
    – Building a custom PCB that include RS485,
    – USB Bootloader (to update .bin just using copy past, like you show it in the video)
    – 4 x 24V I/O,
    – LCD Touchscreen,
    – Programming a C (or C++) library for the graphic.

    I cant see where to start. Maybe you have some tutorial to show me that help me to getting started with LPC1788 quickly.

    My second question is: where to find th USB Secondary bootloader program (.bin or .hex) and how to upload it to the LPC1788 (on the dev board and later on the custom PCB)?
    Witch LPC pin’s are used like USB (for bootloader)?

    Thank you

    • Hello Dev

      I am happy that you find my tutorials useful. As far as I understand your question, Its always challenging when anybody migrate from 8/16-bit micros to 32 bit micros. These tutorials would not be enough for your task but i feel these tutorial will be good to have reference all the time.

      About your project and LPC1788, LPC1768 is quite different from LPC1788 in terms of resource available on chip. Also configuring USB is also bit different. Any ways the good news is NXP provide CMSIS wrapper for all their chips. I recomemnd you first download all documents from link: Click Here to Download

      You will find some ready to go example projects for KEIL IDE. As Olimex has provided IAR compatible source code. I am not sure which IDE you prefer to work with. Download “AN_LPC177x_8x_Secondary_USB_Host_Bootloader” .ZIP file where you will find bootloader project. YOu just need to compile and load .HEX file on LPC1788 to use it with USB Secondary Bootloader mode.

      Coming back to your question, In my video I have uploaded bootloader code (“bootloader.hex”) file onto LPC1768 using FTDI Cable into ISP Mode.Now about Pins i cant say because it needs me to read user manual.
      I don’t have much to time to spend with.

      *The important distinction here is that if the factory wants to use ISP to program the chip initially, they either needs to use JTAG or (if using FlashMagic with serial port) the UART0 port. Because of this, it’s quite useful to consider UART0 as “the” UART to use for software updates.

      Lets me know your progress, if possible I will try to work around datasheet

      I wish you good day

      Good Luck

  4. hi umesh lokhande,nice video and explanation it was very useful for me.
    I have a small request, can you please explain how to use IAP(In-Application Programming) in lpc-1768.

    Thank you,
    Regards A.Arjun

  5. thx Umesh.

    It is excellent article for beginner like me.

    in fact, i’m having a trouble to burn bootloader(nxp lpc1768).

    my flashmagic can not read the signature of lpc1769.

    i tried followings…

    1. Press isp reset btn and isp btn and relese them.

    2. flashmagic’s menu > isp > read signature.

    -> the flashmagic failed.

    If u can help me, plz send me a email.

    [email protected]

    thx good article,Umesh~

    Byebye~

  6. Hi I am Nuthan … I bought a loc1768 … The thing is working fine except that it doesn’t have firmware when bought.. and now I had written a program … I need to dump it to the lpc1768 …. I am using flash magic but I am unable to know for which port the arm cortex is connected…. I checked device manager but it had nothing in COM PORTS … what can I do to dump … Even to dump in USB bootloader it doesn’t contain any firmware

  7. The download rar link seems to be broken? Be great if you could fix it 🙂

  8. hello sir i can interface my pic24 board with dock light, but i need to interface USB to communicate with pic24 controller.how i should start .i dont have any knowledge on programming .iam new to programming.please help me step my step.i need a gui interface to communicate with the pic24 controller.please help me

Leave a Reply

Your email address will not be published. Required fields are marked *

Login

Register | Lost your password?