USB HID bootloader for the MC9S08JM60



Similar documents
Using WinUSB in a Visual Studio Project with Freescale USB device controller

Connecting Low-Cost External Electrodes to MED-EKG

Software Real Time Clock Implementation on MC9S08LG32

Windows 7: Using USB TAP on a Classic CodeWarrior Installation (MGT V9.2 DSC V8.3)

IRTC Compensation and 1 Hz Clock Generation

How To Build A Project On An Eclipse Powerbook For Anarc (Powerbook) On An Ipa (Powerpoint) On A Microcontroller (Powerboard) On Microcontrollers (Powerstation) On Your Microcontroller 2 (Powerclock

How To Control A Motor Control On An Hvac Platform

Blood Pressure Monitor Using Flexis QE128 Gabriel Sanchez RTAC Americas

Connecting to an SMTP Server Using the Freescale NanoSSL Client

Installation of the MMA955xL CodeWarrior Service Pack Author: Fengyi Li Application Engineer

Freescale Embedded GUI Converter Utility 2.0 Quick User Guide

Flexible Active Shutter Control Interface using the MC1323x

Cyclic Redundant Checker Calculation on Power Architecture Technology and Comparison of Big-Endian Versus Little-Endian

etpu Host Interface by:

Using the Performance Monitor Unit on the e200z760n3 Power Architecture Core

Point-of-Sale (POS) Users Guide Lech José Olmedo Guerrero Jaime Herrerro Gallardo RTAC Americas

Local Interconnect Network (LIN) Physical Interface

Hardware Configurations for the i.mx Family USB Modules

Using the Kinetis Security and Flash Protection Features

Emulated EEPROM Implementation in Dual Flash Architecture on MC9S08LG32 With Demo Description

MCF54418 NAND Flash Controller

Understanding LCD Memory and Bus Bandwidth Requirements ColdFire, LCD, and Crossbar Switch

Generate Makefiles from Command Line Support in Eclipse-Based CodeWarrior Software

How to Convert 3-Axis Directions and Swap X-Y Axis of Accelerometer Data within Android Driver by: Gang Chen Field Applications Engineer

Initializing the TSEC Controller

Handling Freescale Pressure Sensors

Robust Over-the-Air Firmware Updates Using Program Flash Memory Swap on Kinetis Microcontrollers

PowerQUICC II Pro (MPC83xx) PCI Agent Initialization

Performance Monitor on PowerQUICC II Pro Processors

MC13783 Buck and Boost Inductor Sizing

Programming Audio Applications in the i.mx21 MC9328MX21

Freescale Semiconductor. Integrated Silicon Pressure Sensor. On-Chip Signal Conditioned, Temperature Compensated and Calibrated MPX4080D.

Improving Embedded Software Test Effectiveness in Automotive Applications

User Interface Design using CGI Programming and Boa Web Server on M5249C3 Board

Freescale Variable Key Security Protocol Transmitter User s Guide by: Ioseph Martínez and Christian Michel Applications Engineering - RTAC Americas

Using eflexpwm Module for ADC Synchronization in MC56F82xx and MC56F84xx Family of Digital Signal Controllers

Data Movement Between Big-Endian and Little-Endian Devices

How to Do EEPROM Emulation Using Double Flash Array on MC9S08LC60 Ronald Gonzalez and Tatiana Orofino RTAC Americas

How To Measure Power Of A Permanent Magnet Synchronous Motor

Avoiding Read While Write Errors When Developing In-Software Flash Programming Applications for Kinetis and ColdFire+ MCUs

Detecting a CPM Overload on the PowerQUICC II

USB Mass Storage Device Host Bootloader

VLE 16-bit and 32-bit Instruction Length Decode Algorithm

Using Program Memory As Data Memory. 1. Introduction Program Memory and Data. Contents. Memory. Freescale Semiconductor Application Note

Comparison of MC9S08QE128 and MCF51QE128 Microcontrollers Scott Pape and Eduardo Montanez Systems Engineering, Freescale Microcontroller Division

Processor Expert Software Microcontrollers Driver Suite Getting Started Guide

Freescale Semiconductor. Integrated Silicon Pressure Sensor. On-Chip Signal Conditioned, Temperature Compensated and Calibrated MPX5500.

3-Phase BLDC Motor Control with Hall Sensors Using 56800/E Digital Signal Controllers

NOT RECOMMENDED FOR NEW DESIGN

Ref Parameters Symbol Conditions Min Typ Max Units. Standby μa. 3 Range kpa. 4 Resolution 0.15 kpa. 5 Accuracy -20ºC to 85ºC ±1 kpa

Techniques and Tools for Software Analysis

Using XGATE to Implement LIN Communication on HCS12X Daniel Malik 8/16-Bit Products Division East Kilbride, Scotland

Configuring the FlexTimer for Position and Speed Measurement with an Encoder

MLPPP in the Evolving Radio Access Network

Real Time Development of MC Applications using the PC Master Software Visualization Tool. 1. Introduction. 2. Development of Motor Control.

MSC8156 and MSC8157 PCI Express Performance

VGA Output using TV-Out Extension Solution i.mx21

PQ-MDS-T1 Module. HW Getting Started Guide. Contents. About This Document. Required Reading. Definitions, Acronyms, and Abbreviations

Implementing Positioning Algorithms Using Accelerometers

NOT RECOMMENDED FOR NEW DESIGN

Enhanced Serial Interface Mapping

MPC8245/MPC8241 Memory Clock Design Guidelines: Part 1

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

How To Fit A 2Mm Exposed Pad To A Dfn Package

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

Adding SDIO Wi-Fi Solution to i.mx Windows CE 5.0/Windows CE 6.0

Developing an Application for the i.mx Devices on the Linux Platform

i.mx28 Ethernet Performance on Linux

White Paper. Freescale s Embedded Hypervisor for QorIQ P4 Series Communications Platform

CodeWarrior Development Studio Floating Licensing Quick Start

Genesi Pegasos II Setup

Using the HC08 SCI Module

ColdFire Security SEC and Hardware Encryption Acceleration Overview

USB Thumb Drive. Designer Reference Manual. HCS12 Microcontrollers. freescale.com. DRM061 Rev. 0 9/2004

BLDC Motor Control with Hall Effect Sensors Using the 9S08MP

NOT RECOMMENDED FOR NEW DESIGN

RF Power Field Effect Transistors N- Channel Enhancement- Mode Lateral MOSFETs

Understanding Pressure and Pressure Measurement

3-Phase BLDC Motor Control with Hall Sensors Using the MC56F8013

Getting Started with the Student Learning Kit Featuring the Freescale HCS12 Microcontroller Application Module

Using the High Input Voltage Charger for Single Cell Li-Ion Batteries (KIT34671EPEVBE)

Efficient Low-Level Software Development for the i.mx Platform

User Guide. Introduction. HCS12PLLCALUG/D Rev. 0, 12/2002. HCS12 PLL Component Calculator

DRM for Driver Information System on S12G128. Reference Design

AN3354 Application note

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

Application Module Student Learning Kit Users Guide featuring the Freescale MC9S08QG8

UART Boot Loader Design on the Kinetis E Series

How To Improve Performance On A P4080 Processor

How To Use A Watt Saver On A Microcontroller (Watt Saver) On A Cell Phone Or Mp3 Player

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

USBSPYDER08 Discovery Kit for Freescale MC9RS08KA, MC9S08QD and MC9S08QG Microcontrollers User s Manual

Pressure Freescale Semiconductor

A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM Overhead

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

ITU-T V.42bis Data Dictionary Search on the StarCore SC140/SC1400 Cores

MPXAZ6115A MPXHZ6115A SERIES. Freescale Semiconductor Technical Data. MPXAZ6115A Rev 4, 01/2007

Motion and Freefall Detection Using the MMA8451, 2, 3Q

Transcription:

Freescale Semiconductor Document Number: AN4252 Application Note Rev. 0, 4/2011 USB HID bootloader for the MC9S08JM60 by: Derek Lau System and Solution Engineering, Microcontroller Solutions Group Hong Kong China 1 Introduction In-circuit programming (ICP) is a process for a microcontroller (MCU) to be programmed or re-programmed on the printed circuit board. It allows the user code to be changed during product development and production, and after sold. The MC9S08JM60 (JM60) is a member of the low-cost, highperformance HCS08 family of 8-bit microcontroller units. It has a 60 KBytes of embedded flash memory that can be programmed or erased without special voltage input. The JM60 has a USB 2.0 full-speed module, making it suitable for in-circuit programming via a USB interface. The using of the human input device class (HID) allows the use of standard HID drivers provided by most operating systems. 2 System overview The system includes: JM60 bootloader firmware JM60 keyboard demo user program JM60 mouse demo user program Windows PC demo software (executive file only) Contents 1 Introduction...1 2 System overview...1 3 Flash utilization...2 4 Bootloader commands...3 4.1 Block erase command...3 4.2 Bytes program command...3 4.3 Status...4 5 Demo...4 5.1 Programming bootloader into JM60...5 5.2 Programming USB keyboard demo...5 5.3 Programming USB mouse demo...6 6 Customization...7 6.1 ROM segment...7 6.2 Reset vector and startup position...7 The bootloader is a small program put into the JM60 that complies with the USB HID class, which receives commands and data from the host to program and erase the flash memory 2011 Freescale Semiconductor, Inc.

Flash utilization of the JM60. The keyboard and mouse demo user programs are two examples showing how user programs can be programed and re-programed into the JM60 by the bootloader via the PC demo software. The firmware and demo user program was tested under the hardware platform of the DEMOJM board. The PC demo software was tested under 32-bit Windows 7 and XP systems. 3 Flash utilization The bootloader is put into the highest flash area of the JM60. The user program and the vectors are put into the flash area below the bootloader flash. The following figure shows the flash memory map. $ 1 0 B 0 $ 1 7 F F $ 1 8 0 0 $ 1 9 5 F $ 1 9 6 0 $ F 7 C 3 $ F 7 C 4 $ F 7 F F $ F 8 0 0 $ F F A F $ F F B 0 $ F F B F $ F F C 0 $ F F F F F la s h 1 1 8 7 2 B y t e s U S B R A M 2 5 6 B y t e s F la s h 2 5 8, 9 6 0 B y t e s N o n v o la t ile r e g is t e r s 1 6 B y t e s F L A S H V e c t o r s 6 4 B y t e s F la s h 1 ( u s e r p r o g r a m o r d a t a ) 1 8 7 2 B y t e s U S B R A M 2 5 6 B y t e s F la s h 2 A ( u s e r p r o g r a m o r d a t a ) 5 6 9 3 2 B y t e s R e d ir e c t io n V e c t o r s 6 0 B y t e s B o o t lo a d e r 1 9 6 8 B y t e s N o n v o la t ile r e g is t e r s 1 6 B y t e s B o o t lo a d e r 6 4 B y t e s Figure 1. Memory map Only continuous protection of blocks starting from the highest address is allowed. Therefore, the bootloader code is put into the flash address of 0xF800 to 0xFFAF and 0xFFC0-0xFFFF which is protected from erasing by writing 0xF6 to the flash protection register. The user program can be put into the flash 1 and flash 2A areas. The protection of the bootloader code ensures that only the user program is changed while the bootloader will never be accidentally erased during user program upgrade. When any block protection is enabled, the reset and interrupt vectors will be protected. Vector redirection allows users to modify interrupt vector information without unprotecting bootloader and reset vector space. The bootloader code therefore has enabled the vector redirection by programming the vector redirection disable (FNORED) bit of the nonvolatile location (NVOPT) register located at address 0xFFBF to zero. Since the flash address from 0xF800 is protected and vector redirection is enabled, all of the interrupt vectors (memory locations 0xFFC4-0xFFFD) except the reset vector are redirected to 0xF7C4-0xF7FD. The user program starting address is put into 0xF7FE-0xF7FF. The bootloader program will jump to the address pointed by 0xF7FE-0xF7FF to run the user program in normal user mode. If the address is blank, bootloader mode is run. 2 Freescale Semiconductor, Inc.

Bootloader commands 4 Bootloader commands The bootloader commands and data are sent by the PC software bootloader.exe to JM60 through USB HID class protocol. The bootloader command format is shown in the following table with 0xA5 as an identifier for starting of command followed by the command, arguments and data. Table 1. Bootloader command format Offset Field Size (byte) Description 0 Command_Start 1 Command identifier (0xA5) 1 Command 1 Command 2-63 Arguments and data 4-62 Arguments and data 4.1 Block erase command The Block_Erase command enables erasing of one flash block. The argument contains any address within the flash block to be erased. The device returns the status after receiving and executing the command. Table 2. Block erase command Command Arguments Description Block_Erase (0x01) Erase_Address Any address within the block to be erased(4 bytes) Table 3. Block erase example From Data Description Host OUT [A5 01 00 DE 00 XX XX XX... XX ] Block erase DE00 to DFFF Device IN [A5 01 XX XX] Device returns status of block erase success 4.2 Bytes program command The Bytes_Program command is with arguments of starting address, number of bytes for program, and data to be programmed. The device returns the status after receiving and executing the command. Table 4. Bytes program command Command Arguments Description Bytes_Program (0x11) Start_Address Len_Data Data Starting address (4 bytes) Number of bytes to be programmed (2 bytes) Data to be programmed (1-56 bytes) Freescale Semiconductor, Inc. 3

Demo Host Table 5. Bytes program example From Data Description OUT [A5 11 00 DE XX XX 38 00 D0 D1 D2 D3 D4... D55] Bytes program 56 bytes of data from DE00 to DE37 Device IN [A5 01 XX XX] Device returns status of program success 4.3 Status The device returns four bytes of data after completing the Block_Erase or Block_Program command, which includes one byte of 0xA5 as the identifier, one byte of status, and two reserved bytes. Table 6. In data command 0x01 0xFF Status Command success Command failure Description 5 Demo The demo shows the procedures of programming the bootloader code into the JM60 using codewarrior, and programming and re-programming of keyboard and mouse user programs through the PC software bootloader.exe. The following table shows how the pins of the JM60 are used in the demo. The figure below shows the JM60 Demo Board (DEMOJM). Table 7. JM60 pins usages PTE2 PTE3 PTF0 PTG0 PTG1 Pins Description Caps Lock LED control for the keyboard demo. Num Lock LED control for the keyboard demo. Scroll Lock LED control for the keyboard demo. Press the button and plug-in the USB cable will cause JM60 to enter bootloader mode. Page Up key for the keyboard demo. Page Down key for the keyboard demo. 4 Freescale Semiconductor, Inc.

Demo USB_VDD PTE2 PTE3 PTF0 Caps Num Scroll PTG0 Page Up PTG1 Page Down MiniUSB_VDD BDM USB Mini USB Figure 2. DemoJM board 5.1 Programming bootloader into JM60 The bootloader code can be programmed into the JM60 using Freescale Codewarrior Development Studio. 1. Connect the USB_VDD jumper to select the V DD from the BDM USB port. 2. Connect a USB cable from the PC to the DBM USB port and install the driver if prompted. 3. Launch Codewarrior version 6.3. 4. Click <File>, then select <Open> to open the project file "hid_bootloader.mcp" under the directory "jm60_hid_bootloader_code". 5. Click <Project>, then select <Debug> to automatically download and program the s-record of the bootloader code into JM60. 6. Close debugger and remove the USB cable. The JM60 has been programmed with the bootloader code. It always runs in bootloader mode when no user program is put into it. 5.2 Programming USB keyboard demo 1. Connect the mini_usb jumper to select the V DD from the mini-usb port. 2. Connect a USB cable from the PC to the mini-usb port. Freescale Semiconductor, Inc. 5

Demo 3. Run the file "HID_Bootloader.exe" in the directory of "jm60_hid_bootloader". Figure 3. HID bootloader PC program 4. In <Select MCU>, select the file "jm60.imp" in the directory of "jm60_hid_bootloader". 5. In <S Record File>, select the file "Project.abs.s19" in the directory "jm60_hid_bootloader_demo1\bin" (customers can choose their own s-record files to program) 6. Click Program to program the USB keyboard demo user program into the JM60. 7. Unplug and replug the USB cable. Now the USB keyboard demo user program has been put into the JM60. The user program runs if PTG0 is not pressed. The system functions as a USB keyboard. PTG0 and PTG1 function as the Page up and Page Down keys while the LEDs connected to the PTE2, PTE3, PTF0 function as the Caps Lock, Num Lock and Scroll Lock indicators. 5.3 Programming USB mouse demo Since the JM60 has been programmed with a user program, the bootloader program runs if PTG0 is pressed during JM60 is power up. 1. Unplug the USB cable. 2. Press PTG0 and plug-in the USB cable 3. In S Record File, select the file "Project.abs.s19" in the directory "jm60_hid_bootloader_demo2\bin". 4. Click <Erase> 5. Click <Program> to program the USB mouse demo user program into the JM60. 6. Unplug and replug the USB cable. Now the JM60 has been programed with the JM60 mouse demo user program. The system emulates a USB mouse making the cursor move from left to right and from right to left. 6 Freescale Semiconductor, Inc.

Customization 6 Customization The major differences between a normal user program and an ICP user program are the flash areas, vector table location and the startup address. This section shows how a normal user program is modified to be used under ICP. 6.1 ROM segment The user program can only be put into the flash area of 0x1000-0x17FF and 0x1960-0xF7FF. The ROM segment defined at the file project.prm may be modified as below: ROM READ_ONLY 0x1960 TO 0xF7FF 6.2 Reset vector and startup position To work with our bootloader code, the interrupt vector table of an ICP user program is located at 0xF7C4-0xF7FC and the startup address is located at 0xF7FE-0xF7FF. The following code is an example to locate the reset vector and the startup address for an ICP user program. #define BOOTLOADER_START_ADDR 0xF800 void (* volatile const _Usr_Vector[])()@(BOOTLOADER_START_ADDR-0x100+0xC4)={ RTC_ISR, // Int.no.29 RTC (at F7C4) I2C_ISR, // Int.no.28 I2C (at F7C6) ACMP_ISR, // Int.no.27 ACMP (at F7C8) ADC_ISR, // Int.no.26 ADC (at F7CA) KBI_ISR, // Int.no.25 KBI (at F7CC) Dummy_ISR, // Int.no.24 SCI2 Transmit (at F7CE) Dummy_ISR, // Int.no.23 SCI2 Receive (at F7D0) Dummy_ISR, // Int.no.22 SCI2 Error (at F7D2) SCI1Tx_ISR, // Int.no.21 SCI1 Transmit (at F7D4) SCI1Rx_ISR, // Int.no.20 SCI1 Receive (at F7D6) SCI1Err_ISR, // Int.no.19 SCI1 error (at F7D8) Dummy_ISR, // Int.no.18 TPM2 Overflow (at F7DA) Dummy_ISR, // Int.no.17 TPM2 CH1 (at F7DC) Dummy_ISR, // Int.no.16 TPM2 CH0 (at F7DE) Dummy_ISR, // Int.no.15 TPM1 Overflow (at F7E0) Dummy_ISR, // Int.no.14 TPM1 CH5 (at F7E2) Dummy_ISR, // Int.no.13 TPM1 CH4 (at F7E4) Dummy_ISR, // Int.no.12 TPM1 CH3 (at F7E6) Dummy_ISR, // Int.no.11 TPM1 CH2 (at F7E8) TPM1CH1_ISR, // Int.no.10 TPM1 CH1 (at F7EA) TPM1CH0_ISR, // Int.no.9 TPM1 CH0 (at F7EC) Dummy_ISR, // Int.no.8 Reserved (at F7EE) USB_ISR, // Int.no.7 USB Statue (at F7F0) Dummy_ISR, // Int.no.6 SPI2 (at F7F2) Dummy_ISR, // Int.no.5 SPI1 (at F7F4) Dummy_ISR, // Int.no.4 Loss of lock (at F7F6) Dummy_ISR, // Int.no.3 LVI (at F7F8) Dummy_ISR, // Int.no.2 IRQ (at F7FA) USB_ISR, // Int.no.1 SWI (at F7FC) _Startup, // startup address (at F7FF) }; Freescale Semiconductor, Inc. 7

How to Reach Us: Home Page: www.freescale.com Web Support: http://www.freescale.com/support USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, EL516 2100 East Elliot Road Tempe, Arizona 85284 +1-800-521-6274 or +1-480-768-2130 www.freescale.com/support Europe, Middle East, and Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen, Germany +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) www.freescale.com/support Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 support.japan@freescale.com Asia/Pacific: Freescale Semiconductor China Ltd. Exchange Building 23F No. 118 Jianguo Road Chaoyang District Beijing 100022 China +86 10 5879 8000 support.asia@freescale.com For Literature Requests Only: Freescale Semiconductor Literature Distribution Center 1-800-441-2447 or +1-303-675-2140 Fax: +1-303-675-2150 LDCForFreescaleSemiconductor@hibbertgroup.com Information in this document is provided solely to enable system and sofware implementers to use Freescale Semiconductors products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any liability, including without limitation consequential or incidental damages. "Typical" parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including "Typicals", must be validated for each customer application by customer's technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claims alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. RoHS-compliant and/or Pb-free versions of Freescale products have the functionality and electrical characteristics as their non-rohs-complaint and/or non-pb-free counterparts. For further information, see http://www.freescale.com or contact your Freescale sales representative. For information on Freescale's Environmental Products program, go to http://www.freescale.com/epp. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. 2011 Freescale Semiconductor, Inc. Document Number: AN4252 Rev. 0, 4/2011