CE95391 PSoC® USB HID Bootloader.pdf

CE95391 - PSoC® USB HID Bootloader
Objective
This example demonstrates usage of the PSoC Creator Bootloader and Bootloadable Components in a USB-based bootloader
system. It also demonstrates a PC-based bootloader host program.
Overview
This example uses two PSoC Creator projects – bootloader and bootloadable – to demonstrate the PSoC Creator bootloader
system. The bootloader project communicates with a PC host via USB HID, to program an application image. The
bootloadable project is the application image that is programmed.
Requirements
Tool: PSoC Creator 3.3 SP1 or higher
Programming Language: C (GCC 4.7.3)
Associated Parts: All PSoC 3, PSoC 4 L-series, and PSoC 5LP parts with USB
Related Hardware: CY8CKIT-030, CY8CKIT-046, CY8CKIT-050, CY8CKIT-059
Design
USB HID Bootloader
The bootloader project design features the PSoC Creator Bootloader and USBFS Components, as Figure 1 shows. The
USBFS Component communicates with the PC host to get commands and a new application image. The Bootloader
Component does flash programming, host command / response protocol, and launches the bootloadable application.
Figure 1. USB HID Bootloader Schematic (Pins and LED are Selected for CY8CKIT-046)
www.cypress.com
Document No. 001-95391 Rev.**
1
PSoC® USB HID Bootloader
Bootloadable
The design of the bootloadable projects features the PSoC Creator Bootloadable Component, as Figure 2 shows. Other
Components implement the desired application. This code example has two bootloadable projects, which do slightly different
functions.
Figure 2. Bootloadable Schematic (Pins and LED are Selected for CY8CKIT-046)
Design Considerations
This design can be extended by changing the Bootloader Component to implement a dual-application function. Then two
bootloadable projects can be programmed into flash.
This code example is designed for two PSoC device families and associated kits:


The PSoC 4 L-series family and associated CY8CKIT-046 kit
The PSoC 5LP device family and associated CY8CKIT-059 kit
The design is easily portable to other PSoC 3, PSoC 4 L-series, and PSoC 5LP devices and kits, typically by just changing the
LED or button pin assignments.
The PSoC Creator bootloader system is designed to be used with most communication channels, and it is easy to change this
2
example to be an I C, UART, or SPI-based bootloader. For more information, see AN73854, PSoC Introduction to
Bootloaders.
www.cypress.com
Document No. 001-95391 Rev.**
2
PSoC® USB HID Bootloader
PSoC Creator Components
Table 1 and Table 2 list the PSoC Creator Components used in this example, as well as the hardware resources used by each
Component.
Table 1. List of PSoC Creator Components for USB HID
Bootloader Project
Table 2. List of PSoC Creator Components for
Bootloadable Projects
Component
Hardware Resources
Component
Hardware Resources
BL
none
Bootloadable
none
USBFS
1 USBFS
Pin_StartBootloader
1 pin
Wait_Forever
1 pin
isr_EnterBootloader
1 interrupt vector
LED
1 pin
LED
1 pin
Parameter Settings
This section shows the changed configuration settings for the PSoC Creator Components in the code example projects.
Bootloader
Figure 3 shows the changed settings for the Bootloader Component. The Component Name change is optional.
Figure 3. Bootloader Component Configuration
www.cypress.com
Document No. 001-95391 Rev.**
3
PSoC® USB HID Bootloader
USBFS
The USBFS Component is configured for HID bootloader by using an import file provided with PSoC Creator:
<PSoC Creator InstallDir> \ psoc \ content \ cycomponentlibrary \ CyComponentLibrary.cylib \ USBFS_v_x_xx \ Custom \
template \ Bootloader.root.xml
For details on how to import this file, see application note AN73053, PSoC USB HID Bootloader.
Bootloadable
A bootloadable project is always linked to the output .hex and .elf files of an associated bootloader project, as Figure 4 shows.
Selecting the .hex file automatically selects the associated .elf file. Before configuring a Bootloadable Component, you should
completely build the associated bootloader project.
For this code example, the bootloader .hex file is at a relative path within this PSoC Creator workspace. However, this need
not be the case; bootloader and bootloadable projects can be in different workspaces.
For more information on bootloader and bootloadable files, see AN73854, PSoC Introduction to Bootloaders.
Figure 4. Bootloadable Component Configuration
www.cypress.com
Document No. 001-95391 Rev.**
4
PSoC® USB HID Bootloader
Input Pins
In all of the projects, digital input Pin Components are used to read the state of a kit button. The buttons short to ground when
pressed, therefore the Pin Component must be configured for resistive pull up, as Figure 5 shows. This causes the Pin input
state to be 0 when the button is pressed and 1 when it is released.
Figure 5. Digital Input Pin Configuration for Resistive Pull Up
Figure 6 shows the configuration for the input Pin Component to generate an interrupt.
Figure 6. Digital Input Pin Configuration for Interrupt
www.cypress.com
Document No. 001-95391 Rev.**
5
PSoC® USB HID Bootloader
Design-Wide
The design-wide clocks are configured for USB, as Figure 7 shows for PSoC 4 L-series, and Figure 8 shows for PSoC 3 and
PSoC 5LP.
Figure 7. PSoC 4 L-series USB Clock Configuration
Figure 8. PSoC 3 and PSoC 5LP USB Clock Configuration
www.cypress.com
Document No. 001-95391 Rev.**
6
PSoC® USB HID Bootloader
Operation
1.
Connect a USB cable between the host PC and the kit programming USB connector. Note that some kits plug directly into
the USB port.
2.
Program the USB HID Bootloader project into the kit. Confirm that the kit LED is on constantly, indicating that the
bootloader is running.
3.
Unplug the USB cable, and plug it into the kit general usage USB connector. If the kit is plugged into a USB port, remove
it. The kit should be able to be powered from the USB connection.
4.
Run the PSoC Creator Bootloader Host program (menu item Tools > Bootloader Host...).
5.
Select a Bootloadable1 project .cyacd file and program it using the bootloader. Confirm that the LED blinks at a 1-second
rate, indicating that the bootloadable is running.
6.
Press the kit button to switch from bootloadable to bootloader. Confirm that the LED stays on (the bootloader is running).
7.
Select a bootloadable2 project .cyacd file and program it using the bootloader. Confirm that the LED now blinks at a
200-msec rate, indicating that the other bootloadable is running.
8.
Press the kit button to switch from bootloadable to bootloader. Confirm that the LED stays on (the bootloader is running).
The remaining steps are optional:
9.
Start programming a bootloadable project .cyacd file, as in steps 5 and 7, but during programming disconnect the USB
cable.
10. Repeat step 5 or 7 and confirm the successful completion of bootloading.
Related Documents
Table 3 lists all relevant application notes, code examples, knowledge base articles, device datasheets, and Component
datasheets.
Table 3. Related Documents
Application Notes
AN73854
PSoC 3, PSoC 4, and PSoC 5LP
Introduction to Bootloaders
Describes the bootloader architecture used in PSoC 3, PSoC 4 and PSoC 5LP
AN73503
PSoC 3 and PSoC 5LP USB HID
Bootloader
Shows how to build a USB HID -based bootloader for PSoC 3 and PSoC 5LP
AN60317
PSoC 3 and PSoC 5LP I2C Bootloader
Shows how to build an I2C-based bootloader for PSoC 3 and PSoC 5LP
AN89611
PSoC 3 and PSoC 5LP Getting Started
with Chip-Scale Packages
Describes the I2C bootloader that is factory-installed in PSoC 3 and PSoC 5LP
CSP devices
AN86526
PSoC 4 I2C Bootloader
Shows how to build an I2C-based bootloader for PSoC 4 family devices
AN68272
PSoC 3 and PSoC 5LP UART Bootloader
Shows how to build a UART-based bootloader for PSoC 3 and PSoC 5LP
AN84401
PSoC 3 and PSoC 5LP SPI Bootloader
Shows how to build a SPI-based bootloader for PSoC 3 and PSoC 5LP
AN2100
PSoC 1 Bootloader
Describes a UART-based bootloader for PSoC 1
Code Examples
CE69310
PSoC 1 I2C Bootloader
CE82634
Host Code for Bootloading PSoC 1 Via I2C
PSoC Creator Component Datasheets
Bootloader and Bootloadable
Describes the bootloader and bootloadable components required for implementing a
bootloader system
Full Speed USB (USBFS)
Provides a USB full-speed compliant device framework
www.cypress.com
Document No. 001-95391 Rev.**
7
PSoC® USB HID Bootloader
Device Documentation
PSoC 3 Datasheets
PSoC 3 Technical Reference Manuals
PSoC 4 Datasheets
PSoC 4 Technical Reference Manuals
PSoC 5LP Datasheets
PSoC 5LP Technical Reference Manuals
Development Kit (DVK) Documentation
PSoC 3 and PSoC 5LP Kits
PSoC 4 Kits
www.cypress.com
Document No. 001-95391 Rev.**
8
PSoC® USB HID Bootloader
Document History
®
Document Title: CE95391 - PSoC USB HID Bootloader
Document Number: 001-95391
Revision
ECN
Orig. of
Change
Submission
Date
**
5093124
SJLE
01/19/2016
www.cypress.com
Description of Change
New code example
Document No. 001-95391 Rev.**
9
PSoC® USB HID Bootloader
Worldwide Sales and Design Support
Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find
the office closest to you, visit us at Cypress Locations.
PSoC® Solutions
psoc.cypress.com/solutions
Products
PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP
Automotive
cypress.com/go/automotive
Clocks & Buffers
cypress.com/go/clocks
Interface
cypress.com/go/interface
Lighting & Power Control
cypress.com/go/powerpsoc
cypress.com/go/plc
Memory
cypress.com/go/memory
PSoC
cypress.com/go/psoc
Touch Sensing
cypress.com/go/touch
USB Controllers
cypress.com/go/usb
Wireless/RF
cypress.com/go/wireless
Cypress Developer Community
Community | Forums | Blogs | Video | Training
Technical Support
cypress.com/go/support
PSoC is a registered trademark and PSoC Creator is a trademark of Cypress Semiconductor Corp. All other trademarks or registered trademarks
referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone
Fax
Website
: 408-943-2600
: 408-943-4730
: www.cypress.com
© Cypress Semiconductor Corporation, 2016. The information contained herein is subject to change without notice. Cypress Semiconductor
Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any
license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or
safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as
critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies
Cypress against all charges.
This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide
patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative
works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the
right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or
use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a
malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems
application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
www.cypress.com
Document No. 001-95391 Rev.**
10
Similar pages