PSoC Bootloaders

Created by Scott Schmit, last modified on Oct 01, 2014

image

Purpose

Bootloaders are used extensively in embedded design. A bootloader allows a device to be programmed through common serial communication interfaces, such as USB, UART, I2C, or SPI, when standard programming interfaces, such as JTAG or SWD, are not available. This is common when a device has been implemented in an end product and deployed in the field. Typically, the JTAG or SWD interface is not available in an end product, so a bootloader is placed on the device to allow for firmware updates through a serial communication port. The purpose of this page is to provide a few bootloaders for various PSoC devices and explain how to use them to update device firmware.

How Bootloaders Work

A bootloader is a program that is placed in flash memory of a microcontroller. Therefore, it will use up some of the available memory of your device. The actual application program gets moved to a separate portion of memory. A bootloader program is placed on a device through the standard programming interface (JTAG/SWD). This is typically done at the factory. The bootload process involves a Target and a Host. The device to be updated is considered the Target. The Host can be considered a “Programmer” for the target device and is normally a PC or another microcontroller.

The bootloader program will involve some sort of serial communication port on the Target, such as USB, UART, I2C, SPI, or a custom interface. It could also involve a status LED or other desired peripherals. The bootloader will receive data from the Host and rewrite the application program portion of memory. The bootloader is normally entered automatically on reset, although it can also be invoked directly from application code (button press, or command receipt). Typically a bootloader will wait a finite length of time for a Host to send a “start” command. If no start command is received after the predefined amount of time, the bootloader passes control to the application program. The application that is getting uploaded through the bootload process is commonly referred to as a “Bootloadable”. It’s important to note that a communication port can be shared between a bootloader and an application, since they are operating at different times. Just because your bootloader is using a UART port, doesn’t mean your application can’t use that UART port.

The Host is a separate program all together. It takes a Bootloadable program, breaks it up into chunks, and transmits it over the predefined serial port with some sort of error checking functionality. Many chip vendors provide PC-based bootloader Host applications for their products. Each bootloader Host will follow a certain file upload protocol which is usually unique to the chip vendor. Cypress provides a PC application called Bootloader Host and it is included by default with the PSoC Creator installation. For an application to be uploaded using Bootloader Host , it must be converted to a Bootloadable program. This is accomplished in PSoC Creator through the process described below. When the project is built, PSoC Creator will generate a .cyacd file which can be uploaded using Bootloader Host .

Ready-to-Use PSoC Bootloaders

The following bootloaders can be programmed to the respective PSoC device through the standard programming interface (JTAG for PSoC3, SWD for PSoC4/PSoC5LP). Once the bootloader is flashed to the device, the application code of the device can be updated through the corresponding serial port using Bootloader Host .

To use the bootloaders provided below:

  1. Download the .zip file containing the desired bootloader.
  2. Extract the contents to a known location.
  3. Program the extracted .hex file to your device using PSoC Programmer.
  4. Map your bootloadable application to the downloaded .hex and .elf files as explained in the Creating PSoC Bootloadable Applications section.

PSoC3 Bootloaders
The following bootloaders were tested on the PSoC Development Kit (CY8CKIT-001) as well as the PSoC 3 FirstTouch Starter Kit (CY8CKIT-003).

Bootloader Files Description Device Bootloader Pins
PSoC3_UART_Bootloader.zip (1.7 MB) Bootloader waits 2 seconds for start signal from Host and then passes control to application code. Bootloader UART operates at 56.7kbps, 8-bit data, no parity, 1 stop bit, no flow control. CY8C3866AXI-040 P0[1]UART_RX P0[3]UART_TX
PSoC3_I2C_Bootloader.zip (1.7 MB) Bootloader waits 2 seconds for start signal from Host and then passes control to application code. Need external 2.2k pull-up resistors on I2C pins. Bootloader I2C rate is 100kbps. I2C slave address is 0x08. CY8C3866AXI-040 P0[1]I2C_SCL P0[3]I2C_SDA

Verification:

Bootloadable applications were uploaded successfully to the PSoC3 device using the bootloaders above and Bootloader Host . The following bridges were tested:

  • UART: TTL-232R-3V3 USB/UART bridge
  • I2C: CY8CKIT-002 Miniprog3 USB/I2C bridge

PSoC4 Bootloaders
The following bootloaders were tested on the PSoC4 Pioneer Kit (CY8CKIT-042).

Bootloader Files Description Device Bootloader Pins
PSoC4_UART_Bootloader.zip (463.5 KB) Bootloader waits 2 seconds for start signal from Host and then passes control to application code. Bootloader UART operates at 56.7kbps, 8-bit data, no parity, 1 stop bit, no flow control. CY8C4245AXI-483 P0[4]UART_RX P0[5]UART_TX
PSoC4_I2C_Bootloader.zip (519.2 KB) Bootloader waits 2 seconds for start signal from Host and then passes control to application code. 2.2k pull-up resistors are included on P4[1:0] on the PSoC4 Pioneer Board. Bootloader I2C rate is 100kbps. I2C slave address is 0x08. CY8C4245AXI-483 P4[0]I2C_SCL P4[1]I2C_SDA
Verification:

Bootloadable applications were uploaded successfully to the PSoC4 device using the bootloaders above and Bootloader Host . The following bridges were tested:

  • UART: TTL-232R-3V3 USB/UART bridge
  • I2C: CY8CKIT-002 Miniprog3 USB/I2C bridge.

PSoC5LP Bootloaders

Bootloader Files Description Device Bootloader Pins
PS0C5LP_UART_Bootloader.zip (1014.0 KB) Bootloader waits 2 seconds for start signal from Host and then passes control to application code. Bootloader UART operates at 56.7kbps, 8-bit data, no parity, 1 stop bit, no flow control. CY8C5868AXI-LP035 P0[1]UART_RX P0[3]UART_TX
PSoC5LP_I2C_Bootloader.zip (972.8 KB) Bootloader waits 2 seconds for start signal from Host and then passes control to application code. Need external 2.2k pull-up resistors on I2C pins. Bootloader I2C rate is 100kbps. I2C slave address is 0x08. CY8C5868AXI-LP035 P0[1]I2C_SCL P0[3]I2C_SDA
Verification:

Bootloadable applications were uploaded successfully to the PSoC5LP device using the bootloaders above and Bootloader Host . The following bridges were tested:

  • UART: TTL-232R-3V3 USB/UART bridge
  • I2C: CY8CKIT-002 Miniprog3 USB/I2C bridge

Creating PSoC Bootloaders

Cypress makes it very simple to create bootloader programs. This section will walk through the process of creating a bootloader application in PSoC Creator 3.0 for PSoC 3, 4, and 5LP devices. PSoC Creator 3.0 can be downloaded for free here.

  1. Open PSoC Creator 3.0.
  2. Navigate to File → New → Project.
  3. Select Empty PSoC 3, 4, 5LP Design - whichever device family you are using.
  4. Type a descriptive name for your bootloader program in the “Name” field. I usually indicate which device family I’m using, which serial port I’m using, and the fact that it’s a bootloader. i.e. PSoC4_UART_Bootloader
  5. Browse to whatever directory you wish to save the project in.
  6. Click the ‘+ Advanced’ button.
  7. Select your specific device.
  8. Select “Bootloader” as the application type and click ‘OK’.
  9. PSoC Creator should bring up the schematic view. If not, double click “TopDesign.cysch” from the Project Explorer window.
  10. From the Component Catalog, drag the desired communication port for your bootloader into your design. For example, if you would like a UART-based bootloader, click and drag the UART component into your design.
  11. Double-click on your component after it has been added to the design to configure it. Name it whatever you would like and setup your desired communication settings. For a UART, you will need to verify the baud rate, number of data bits, parity type, number of stop bits, and flow control setting. You will also need to change the RX and TX buffer sizes to 64 bytes if using UART. If using I2C, you’ll need to use an I2C Slave component. You’ll need to verify the slave address and data rate. You can use any serial com you would like, or create your own custom serial com. However, that is out of the scope of this page. Apply any changes and click ‘OK’.
  12. From the Component Catalog, drag a Bootloader component into your design.
  13. Double-click on the Bootloader to configure it. Name it whatever you’d like. Your com port should be available in the Communication Component drop-down. The Wait Time defines how long the bootloader will wait for the start signal from the Host before passing control to the application program. Multi-application bootloader is out of the scope of this page. Every other option can be set however you wish. I usually leave default settings. Apply any changes and click ‘OK’.
  14. Open the .cydwr file for your project from the Project Explorer window. Assign physical pins to your communication port. Save and close the .cydwr file.
  15. Open the main.c file from the Project Explorer window. Nothing needs to be changed in main.c for the bootloader to function properly. You could light up an LED before starting the bootloader, if you wish, but for a simple bootloader program, main.c can be left alone.
  16. Save and build the project. This will create bootloader .hex and .elf files and in the Debug folder of your project directory. These files are necessary for your Bootloadable application.
  • For PSoC3 devices, they will be in your project directory under < project name >.cydsn → DP8051 → DP8051_Keil_9xx → Debug.
  • For PSoC4 devices, they will be in your project directory under < project name >.cydsn → CortexM0 → ARM_GCC_4xx → Debug.
  • For PSoC5 devices, they will be in your project directory under < project name >.cydsn → CortexM3 → ARM_GCC_4xx → Debug.
  1. Program the bootloader to your device like you would normally program a PSoC device using Debug → Program from within your bootloader project. You can also use PSoC Programmer to program your device.

Congratulations! If you completed all of these steps, you just created and flashed a bootloader to your PSoC device! Give yourself a pat on the back…but not too hard. We don’t need anybody getting hurt. We haven’t even used our bootloader yet! Now we need to create a Bootloadable application.

Creating PSoC Bootloadable Applications

Cypress makes it very simple to create a bootloadable application from scratch. This section will walk through the process of creating a bootloadable application in PSoC Creator 3.0 for PSoC 3, 4, and 5LP devices.

  1. Open PSoC Creator 3.0.
  2. Navigate to File → New → Project.
  3. Select Empty PSoC 3, 4, 5LP Design - whichever device family your are using.
  4. Type a descriptive name for your bootloadable program in the “Name” field. I usually type my application name preceded by which device family I’m using, which serial port I’m using, and the fact that it’s bootloadable. i.e. PSoC4_UART_Bootloadable_TempSensor.
  5. Browse to whatever directory you wish to save the project in.
  6. Click the ‘+ Advanced’ button.
  7. Select your specific device.
  8. Select “Bootloadable” as the application type and click ‘OK’.
  9. PSoC Creator should bring up the schematic view. If not, double click “TopDesign.cysch” from the Project Explorer window.
  10. Click and drag a Bootloadable component into your schematic from the Component Catalog. Double-click the Bootloadable to configure it. The General tab can be left alone. Under the Dependencies tab, you will need to map the project to the bootloader .hex and .elf files you previously created.
  11. At this point you should develop your program exactly as you would any other PSoC application. Add any components you need for your design and develop firmware in main.c as you normally would.
  12. Save and build your bootloadable program. Just like any normal PSoC project, building will create a program .hex file in the Debug folder of your project directory. However, for a bootloadable project, a .cyadc file will also be generated. This is the file needed by the Bootloader Host application that actually uploads the device firmware using your bootloader.
  • For PSoC3 devices, the .cyacd file will be in your project directory under < project name >.cydsn → DP8051 → DP8051_Keil_9xx → Debug.
  • For PSoC4 devices, the .cyacd file will be in your project directory under < project name >.cydsn → CortexM0 → ARM_GCC_4xx → Debug.
  • For PSoC5 devices, the .cyacd file will be in your project directory under < project name >.cydsn → CortexM3 → ARM_GCC_4xx → Debug.

Cheers! If you completed all of these steps, you just created a bootloadable application that can be uploaded to your device using the bootloader that you already programmed to memory. Now we need to upload the bootloadable program using Bootloader Host .

Using Bootloader Host

Bootloader Host is included by default in the PSoC Creator installation. You can use this application to upload PSoC bootloadable programs to a PSoC device containing the mapped bootloader program. This section will walk through the process of uploading a bootloadable application using Bootloader Host.

Bootloader Host supports numerous serial communication protocols. However, keep in mind, you will need to physically connect the target device to the PC somehow. In many cases, the only connectivity options on a PC are USB or RS232. You may need some sort of bridge device to actually connect your target to the PC.

USB / UART Bridges:

    • TTL-232R-3V3: This is a USB to 3.3V TTL bridge cable from FTDI. If your bootloader uses UART, this can be used to connect the UART of your target to the USB port of a PC.
    • CYUSBS232: This kit contains a USB to RS232 bridge device that can be used to connect your target to the USB port of a PC if your bootloader uses UART.

USB / I2C Bridges:

    • CY8CKIT-002: Miniprog3 can be used as a USB to I2C bridge if your bootloader uses I2C.
    • CY3240-I2USB: This kit contains a USB to I2C bridge device that can be used to connect your target to the USB port of a PC if your bootloader uses I2C.
    • If using the PSoC4 Pioneer Kit, the on-board PSoC5LP device can be used as a USB to I2C bridge device (no external bridge device needed for bootloading).

Upload Process

  1. Open the Bootloader Host application. It should be installed within the Cypress → PSoC Creator folder from the start menu of Windows.
  2. On the left side of the Bootloader Host application, you should be able to see the available COM ports. Connect your target device to the PC using one of the bridge devices listed above. As you connect/disconnect devices from the PC, the available ports should update in real-time.
  3. When you see the device appear in the available ports, click on it and the Port Configuration/Information should update for you.
  4. Browse to the bootloadable program you created by clicking the ‘…’ button, or you can manually type in the directory.
  5. Configure the communication settings as you did when you created your bootloader.
  6. Reset your target device and it should automatically start the bootloader application that already exists in memory. Press the ‘Program’ button to begin uploading the bootloadable program to the target. Keep in mind, after hitting reset, you will have to press the ‘Program’ button within the ‘Wait Time’ you specified when you created the bootloader. For example, if I defined a 2 second Wait Time, I would have to hit the ‘Program’ button within 2 seconds after resetting the device for the transfer to start properly.

Success! If everything is connected and configured properly, you should be able to successfully upload your bootloadable program to your device through the specified COM port.

Troubleshooting Program Failures

If you get a program failure:

  • Re-check your physical connections to the target.
  • Re-check the pins you assigned in your bootloader project.
  • Re-check the serial communication settings you specified in your bootloader project.
  • Verify the COM port isn’t being used by another application.
  • Make sure you are pressing ‘Program’ before the defined Wait Time expires
  • Verify you mapped the correct bootloader .hex and .elf files in your bootloadable project.
  • Verify the Device specified in your bootloadable project matches the Device specified in your bootloader project.
  • If it’s still not working, try restarting Bootloader Host
  • Last resort, restart the PC

Reference Material

  • AN68272 AN68272.pdf (1.8 MB) - This app note from Cypress does a good job explaining the entire bootloader process and provides another example of PSoC3/4/5LP UART Bootloader.
  • MiniProg3 User Guide] Miniprog3_User Guide_001-59350.pdf (664.6 KB) - This document describes the process of programming PSoC devices with the MiniProg3. It also explains how to use MiniProg3 as USB/I2C bridge.
  • UART Datasheet UART_v2_30.pdf (649.8 KB) - This document describes the UART software component (v2.30) for PSoC Creator.
  • I2C Datasheet SCB_P4_v1_10.pdf (1.4 MB) - This document describes the I2C software component for PSoC Creator.

Questions/Comments

I hope this page helped get you familiar with PSoC bootloaders. For questions or feedback about information on this or any other page, please go to the TechForum: TechForum. I hope you are successful implementing PSoC bootloaders!

  • Scott

*The image at the top of the page originated at cypress.com.