Freescale Semiconduct or Li t erature Distribution Center
P.O. Box 5405
Denver, Colorado 80217
1-800-521-6274 or 480-768-2130
Japan:
Freescale Semiconductor Japan Ltd.
Technical Information Cent er
3-20-1, Minami-Azabu, Minat o-ku
Tokyo 106-8573, Japan
81-3-3440-3569
Asia/Pacific:
Freescale Semiconductor Hong Kong Ltd.
2 Dai King Street
Tai Po Industrial Estate
Tai Po, N.T., Hong Kong
852-26668334
Home Page:
www.freescale.com
Information in this doc um ent is provided solely to enable system and sof t ware
implementers to use Freescale Semiconductor products . There are no express or
implied copyright lic enses granted hereunder to design or fabricate any integrated
circuits or integrated circuits based on the inform ation in this document.
Freescale Semiconduct or reserves the right to make c hanges without further notice
to any products herein. Freescale Semiconductor makes no warranty, representation
or guarantee regarding the suitability of its produc ts for any particular purpose, nor
does Freescale Semiconductor assume any liabilit y arising out of the application or
use of any product or circuit, and specifically disclaims any and all liability, including
without limitation consequential or incidental damages. “Typical” parameters that may
be provided in Freescale Semic onductor data sheets and/or speci fications can and
do vary in different applic ations and actual performance may vary over time. All
operating parameters, including “Typicals”, must be val i dated for each customer
application by custom er’ s technical experts. Freescale Semiconductor does not
convey any license under i ts patent rights nor the rights of others. Freescale
Semiconductor products are not designed, intended, or authorized f or use as
components in systems intended for surgical implant i nto the body, or other
applications intended to s upport or sustain life, or for any other application in which
the failure of the Freescale S em i conductor product could create a situation where
personal injury or death may occur. Should Buyer purchase or use Frees cale
Semiconductor products for any such unintended or unauthorized appli cation, Buyer
shall indemnify and hold Freescale Semiconductor and its officers, employees,
subsidiaries, affiliates, and dis t ribut ors harmless against all claims, cos t s, damages,
and expenses, and reasonable attorney fees arising out of, directly or indirectly, any
claim of personal injury or death associated with suc h uni ntended or unauthorized
use, even if such cl ai m al l eges that Freescale Semiconductor was negligent
regarding the design or manufacture of the part.
Learn More: For more information about Freescale products, please visit
www.freescale.com.
Revision History ........................................................................................................................................viii
Freescale Semiconductor Embedded Bootloader Reference Manual, Rev. 0.0 v
About This Book
This guide provides a detailed description of Freescale’s Embedded Bootloader and describes how to port
Freescale’s Embedded Bootloader to a specific PCB/target..
The Embedded Bootloader is intended for use with the IEEE® 802.15.4 evaluation kits (EVK). However,
it is possible to upload applications with the Embedded Bootloader in the development phase, but the
Embedded Bootloader will not provide any debug functions.
The Embedded Bootloader provides an easy and inexpensive way to upload new firmware and eliminate
the requirements for expensive debug/development tools. The only requirement is a standard PC with an
RS232 UART/USB interface running Windows 2000 or XP.
The Embedded Bootloader must be used with the Zigbee Flash Tool which can be found in the Test Tool
Suite ‘Test Tool.exe’.
This document describes Embedded Bootloader version 5.01.
Audience
This document is intended for application developers.
Organization
This document is organized into eight chapters and one appendix.
Chapter 1 Embedded Bootloader Description — This chapter gives an overview of the
Embedded Bootloader.
Chapter 2 Using the Embedded Bootloader — This chapter describes the basic
functionality of the Embedded Bootloader.
Chapter 3 Test Tool, Zigbee Flash Tool — This chapter describes the Zigbee Flash Tool.
The GUI and Command Line versions are covered.
Chapter 4 Programming the Embedded Bootloader — This chapter describes how to
program the Embedded Bootloader to flash memory.
Chapter 5 Application Integration Reference Guide — This chapter describes the
deliverables required to build an 802.15.4/Zigbee Application with the
Embedded Bootloader.
Chapter 6 Port Integration Reference Guide — This chapter describes the deliverables
required and how to integrate them to make an executable Embedded
Bootloader for a specific PCB.
Chapter 7 Embedded BootloaderPublic Function Description — This chapter provides
a description of the, from an 802.15.4/Zigbee application, accessible functions
in the Embedded Bootloader.
Chapter 8 Memory Map — This chapter describes the Bootloader Memory Map.
Appendix A Release Folder and File Structure — This appendix shows the folder and file
structure for this release.
vi Embedded Bootloader Reference Manual, Rev 0.0 Freescale Semiconductor
Conventions
This document uses the following notational conventions:
• Courier monospaced type indicates commands, command parameters, code examples,
expressions, data types, and directives.
• Italic type indicates replaceable command parameters.
• All source code examples are in C.
Definitions, Acronyms, and Abbreviations
BDM debugger A debugger using the BDM interface for communication with the MCU. An
example is the P&E BDM Multilink debugger for HCS08.
BDM Background Debug Module
EVB Evaluation Boards - this term covers the DIG-528-2 (EVK) and DIG536-2
(SARD) boards.
EVK Evaluation Kit
GUI Graphical User Interface
MAC Medium Access Control
MCU MicroController Unit
NVM None-Volatile Memory
PC Personal Computer
PCB Printed Circuit Board
S19 ‘S19’ is the file extension used for the Motorola binary image format. The S19
file encapsulates the binary image as a list of ASCII records. Each record
contains a length -, address -, data - and checksum field. The 16 bit address field
allows a memory space for up to 64 KB. The S19 can be generated with
Metroworks Codewarrior IDE and is the product from the linking process. S19
does not contain additional information to a debugger (where to look for source
files).
Safe Mode Boot The Embedded Bootloader boots up using safe default system values.
HIWAVE P&E HCS08 debugger GUI.
CPROG P&E HCS08 flash programming tool called from HIWAVE. The tool is also
available in a command line version where scripts can be made.
Freescale Semiconductor Embedded Bootloader Reference Manual, Rev. 0.0 vii
The following table summarizes revisions to this manual since the previous release (Rev. 0.0).
Revision History
Location Revision
Entire Document
This document supercedes revision 2.4 of the
Freescale Embedded Bootloader User’s Guide,
MC13192FLUG/D.
viii Embedded Bootloader Reference Manual, Rev 0.0 Freescale Semiconductor
Chapter 1
Embedded Bootloader Description
The Embedded Bootloader is intended for use with the IEEE® 802.15.4 evaluation kits (EVK). However,
it is possible to upload applications with the Embedded Bootloader in the development phase, but the
Embedded Bootloader will not provide any debug functions.
The Embedded Bootloader provides an easy and inexpensive way to upload new firmware and eliminate
the requirements for expensive debug/development tools. The only requirement is a standard PC with an
RS232 UART/USB
The Embedded Bootloader must be used with the Zigbee Flash Tool which can be found in the Test Tool
Suite ‘Test Tool.exe’.
This document describes Embedded Bootloader version 5.01.
The Embedded Bootloader is located in a protected 4 KB flash block in the highest memory area
(0xF000-0xFFFF) of the Freescale MC908HCS08GB60/GT60 microcontroller. (It cannot be accidentally
erased.) A BDM debugger is required to erase the Embedded Bootloader. See the Handling MAC Address Erasure Application Note, AN2825/D
1)
At least one of these communication interfaces must be supported by the target PCB.
1)
interface running Windows 2000 or XP.
1.1 Target
The Embedded Bootloader runs on the Freescale MC908HCS08GB60/GT60 MCU.
The MC908HCS08GB60/GT60 is a member of Freescale’s low-cost, high-performance HCS08 family. It
has 60 KB embedded flash (flash sector size of 512 bytes) and 4 KB embedded RAM..
The Embedded Bootloader uses the MC13192 CLKO. See Chapter 2 for more information.
The Embedded Bootloader must be ported (I/O mapped) to a specific PCB for proper functionality and is
currently ported to the following Freescale PCBs:
Axiom AXM-0308:
• PC Communication Interface: RS232/UART on COM1 (SCI1)/
RS232/UART on COM2 (SCI2)
• Safe Mode Boot Short pins 2-3 on COM1 (SCI1)/
COM2 (SCI2)
• Version Number “AX-0308 Ver 5.01”
DIG528-2 EVK
• PC Communication Interface: RS232/UART on COM1 (SCI1)/
USB (SCI2)
• Safe Mode Boot Short pins 2-3 on COM1-port (SCI1)
• Version Number “528&536 Ver 5.01”
DIG536-2 SARD
• PC Communication Interface: RS232/UART on COM1 (SCI1)
• Safe Mode Boot Short pins 2-3 on COM1-port (SCI1)
• Version Number “528&536 Ver 5.01”
RD01
• PC Communication Interface: RS232/UART/USB on COM1 (SCI1)/
RS232/UART/USB on COM2 (SCI2)
• Safe Mode Boot Short pins 2-3 on COM1 (SCI1)/
COM2 (SCI2)
• Version Number “ RD01 Ver 5.01”
NOTE
The generic RD01 target can be used with any PCB using the Freescale
Reference Design version 01 I/O layout. The PCB must support at least
one communication interface. If a USB is the only interface, use a
jumper to short SCI pins 2 and 3 to make Safe Mode Boot available.
Refer to Section 6.3 for details on how to port the Embedded Bootloader to a specific PCB.
o Disabled The 802.15.4/Application/NVM (except production data section) is erased
(default)
o Enabled The 802.15.4/Application/NVM is NOT erased
• Erase production data (get production data from firmware file)
o Disabled The production data section (with MAC address) in NVM are preserved. All
other NVM values are updated with the values from the S19 record file
(default)
o Enabled The production data (with MAC address) and all other values in NVM are
erased. All NVM values are updated with the values from the S19 record file
NOTE
Care must be taken when enabling this option. The user must save a
backup of vital production data (MAC address). The production data can
be manually added to the NVM structure in the NV_Data.c file.
• Do not reset after upload
o Disabled The system is automatically reset after upload (default)
o Enabled The system must be manually reset by user
• Skip firmware checksum verification
o Disabled A checksum verification of the S19 file data record is performed
NOTE
The Embedded Bootloader will report the address of the first data
mismatch found in the current S19 data record. System must be reset if
an error is reported. Check the optional settings and try again.
o Enabled No checksum verification is performed. Flash programming errors cannot be
detected.
2)
The UART/USB communication channel is also protected with a protocol checksum.
This chapter describes the Embedded Bootloader functionality. A detailed description of the functions
briefly mentioned in this chapter can be found in Chapter 7.
2.1 Upload Firmware
The Embedded Bootloader can be used in different system configurations depending on the PCB and the
application. The application should have a user interface feature that makes it possible for the application
to call the Enable_Download_Firmware() function:
The application can optionally call the Hard_Reset() function to perform a reset, or the board can be reset
manually. The board will now start up in Embedded Bootloader mode.
Start the PC-Tool. See Chapter 3 for more information.
2.1.1 Use Case One
In this case, users send a specific command via the UART to enable firmware upload
(1)
MC908HCS08GB60
B Application Test Tool
o
o NVM
t
l 802.15.4 MAC
o
a
d 802.15.4 PHY
e RS232
r Device Driver UART
1)
Or MC908HCS08GT60
2)
Or USB
/MC13192 PC
(2)
UART or USB
Figure 1 Application Supporting RS232 UART or USB Inter face
In this use case, users push a button on the board to enable firmware upload.
MC908HCS08GB60
B Application
o
o NVM
t
l 802.15.4 MAC
o
a User Interface
d 802.15.4 PHY Push Buttons
e I/O
r Device Driver GPIO S101 S102 S103 S104
(1)
/MC13192
1)
Or MC908HCS08GT60
Figure 2 Application Supporting an I/O Interface
2.1.3 Safe Mode Boot
The Safe Mode Boot Mode is a special startup mode where the Embedded Bootloader boots using safe
system settings thereby resetting the system to a known (default) state.
The Safe Mode Boot can be used to disable the detection of an invalid/malfunctioning application due to
items such as code errors, corrupt NVM data, or internal flash programming errors among others. All the
NVM memory (except production data and MAC address) is completely erased.
The Safe Mode Boot can also be used to upload firmware without first calling the
Enable_Download_Firmware() function. This could be useful if the use cases (as shown in Section 2.1,
Upload Firmware) are not applicable.
Users must perform the following steps to conduct a Safe Mode Boot.
1. Power off the board
2. Disconnect RS232 UART cable (if the RS232 UART interface is used)
3. Short UART TX and RX (pin 2-3) (This works even though the 802.15.4/Zigbee application does not
use the UART interface.)
The MC908HCS08GB60/GT60 starts in 4 MHz self clocked mode. The init code changes this to 8 MHz
after a few instructions from reset.
If NVM data is found, the system clock (MC908HCS08GB60/GT60 ICG module and MC13192 CLKO)
and other options are setup as specified by the uploaded application. See the Freescale 802.15.4 MAC/PHY Software Reference Manual, 802154MPSRM/D, for more details.
If no NVM data can be found, the following (safe mode boot) values are used:
• MC13192 CLKO = 62.5 KHz
• MC908HCS08GB60/GT60 bus clock = 16 MHz
2.4 UART Baud Rate
If NVM data is found, the UART baud rate is setup as specified by the uploaded application. Several
values can be used. See the MC908HCS08GB60/GT60 MCU Data Sheet, MC9S08GB60/D for more
information.
The baud rate depends on the NVM values specified by the application. See the Freescale 802.15.4 MAC/PHY Software Reference Manual, 802154MPSRM/D, for more details.
If no NVM data is found, the following (safe mode boot) values are used:
The Zigbee flash tool is a part of the general Zigbee Test Tool. This chapter provides a brief description
of how to use the Zigbee Test Tool to upload new firmware. For more details about installation and other
features, see the documentation for the Zigbee Test Tool and the Zigbee.hlp file in Test Tool installation
directory .\help.
The flash programming part of the Test Tool can be used with two different user interfaces.
1. The GUI-version in ‘Test Tool.exe’
2. The command line version in ‘Bootloader.exe’ in the ‘S19’ folder.
This description covers Embedded Bootloader version 5.00 of the Zigbee Test Tool.
Uploadable applications in Motorola S19 file format must be copied to the
[installation directory]\Freescale\Test Tool\S19 directory in advance.
Copy any new applications in S19 format to this folder.
NOTE
The actual window layout may differ from the figures shown in this
document. Refer to the Freescale Zigbee/802.15.4 web page for new or
updated applications.
After clicking on the Tools menu option, click the Communication Settings option to choose the baud rate
specified for the current embedded application.
Notice that applications require that you push one or more buttons or some other functions to enable
upload of new firmware. See the Zigbee/802.15.4 Evaluation Kit Quick Start Guide, AN2772/D, for a
description of what to do for a specific application.
If no application is downloaded, use the default settings specified for the Embedded Bootloader. See
In the ‘Flash Section’ window, click on the application file to upload and then click on the “Upload”
button. The upload progress bar begins to indicate upload progress.
Upload Button
Upload
Progress Field
Application
Files
Status/Error
Information Field
Figure 5 Firmware Upload
The Status/Error Information Field shows the Status/Error Information received from the Embedded
Bootloader.
Click on the Embedded Bootloader About box to see the Embedded Bootloader sub version number.
Figure 7 Embedded Bootloader Tool Version
NOTE
The last line is reported from the Embedded Bootloader on the PCB.
This version number is only sent to the PC from power up (not on
reset).
3.1.5 Changing the NVM Data in Flash or File
If users click on an application in the list, it displays the NVM values in the selected application file. If
the uploaded application supports NVM dump, it is possible to read the NVM from the board.
The NVM data can be changed in two different ways:
1. If the uploaded application does not support NVM data editing it is possible to edit the NVM data
in the application file before it is uploaded to the board and save it back in the application file for
later upload.
2. If the uploaded application does support NVM data editing it is possible to edit the NVM data
after the board has been uploaded with the application. For example, the file contains default
values. The Freescale EVK PTC application supports this feature.
NOTE
No production specific information is available in this example window.
Use caution when editing the clock related configuration values. The
values must match each other. There is no sanity check on the user
entered values, though there is a check on length. See the
MC908HCS08GB60/GT60 MCU Data Sheet, MC9S08GB60/D about
how to specify valid register values for the HCS08.
Figure 11 Command Line Version (Flash Erase Disable Option)
NOTE
The flash is not erased and a flash programming error is detected at
address 0xEFFE. This is the address of the Embedded Bootloader control
flags, which was not erased. The error message is expected.
This chapter describes how to program the Embedded Bootloader with a P&E Multilink for HCS08 BDM
debugger. The Embedded Bootloader is normally downloaded to the PCB where production data is also
written. Users must employ different procedures depending on what needs to be programmed. Users can
program the Embedded Bootloader to an empty (erased) PCB or they can upgrade to a newer version of
the Embedded Bootloader. Follow the procedures in Section 4.1, Programming To An Empty (Erased)
Board if the PCB is empty (erased).
Users must make a copy of the production data section in the NVM (see Section 5.3.5, NV_Data.c and
NV_Data.h) if they need to upgrade the Embedded Bootloader. This can be done either manually or
automatically by a custom made script with the command line version of the CPROG tool. The command
line version is not described further. Follow the procedures as shown in Section 4.2 on how to make a
copy of the production data.
4.1 Programming To An Empty (Erased) Board
This section describes how to program the Embedded Bootloader to an empty (erased) board.
1. Execute the HIWAVE.EXE file from your chosen installation directory. For example,
[installation directory]\Metrowerks\CodeWarrior_CW08_V3.0\Prog\
2. From the main window, setup the target by selecting the “Component” menu, then click on “Set
Target”. The “Set Target” window appears as shown in Figure 12.
Figure 12 Set Target Window
3. In the “Processor” drop down menu, select HCS08. From the “Target Interface” drop down menu,
select P&E Target Interface, the click on the “OK” button.
The “Connection Assistant” window appears where you can select the debugger interface connection.
As shown in Figure 13, a USB connection was chosen and the HCS08 was selected as the CPU type.
Click the “OK” button.
4. Click on “Load Application” under the “File” menu to open the “Load Executable File” window.
Specify application file to program in the “Load Executable File” window as shown in Figure 14.
Select “Motorola S-Record (*.s19)” using the “Files of type:” drop down menu. Navigate to the
folder where a copy of the Embedded Bootloader is located. Select the “Embedded Bootloader.s19”
file and click the “Open” button.
The Embedded Bootloader is now programmed to the PCB as shown in the Status Window in Figure 15.
Figure 15 Status Window
5. Remove power and disconnect the BDM cable from the PCB. Next, power up the PCB. The PCB is
now ready to upload an application. See Chapter 2 for details about how to upload an application.
This section describes how to upgrade the Embedded Bootloader to a newer version with the P&E
Multilink BDM debugger.
1. Execute the HIWAVE.EXE file from your chosen installation directory. For example,
[installation directory]\Metrowerks\CodeWarrior_CW08_V3.0\Prog\
2. From the main window, setup the target by selecting Setup Target, the select the “Component” menu,
and click on “Set Target”. The “Set Target” window appears as shown in Figure 16.
Figure 16 Set Target Window
3. From the “Processor” drop down menu, select HCS08. From the “Target Interface” drop down menu,
select P&E Target Interface, then click the “OK” button.
4. The “Connection Assistant” window appears where you can select the debugger interface connection.
As shown in Figure 17, a USB connection was chosen and the HCS08 was selected as the CPU type.
Click the “OK” button.
5. Make a copy of the NVM sector (both NVM0 and NVM1) with the production data.
Select the “PEDebug” menu, select “Programming Options”, and then choose “Start Expert Mode
Programmer”. The “Programmer Expert” window appears as shown in Figure 18.
Figure 18 Programmer Expert Window
6. In the “Programmer Expert” window, click on “UR Upload Range”. The “Start Address” window
appears as shown in Figure 19. Here you specify the start address for the NVM section. Click the
“OK” button. For NVM0 use 0x152F and for NVM1 use 0x172F.
Figure 19 Start Address Window
7. In the “End Address” window, which looks very similar to the “Start Address” window, specify the
end address for the NVM section and then click the “OK” button. For NVM0 use 0x155B and for
NVM1 use 0x175B.
8. As shown in Figure 20, use the S19 window to specify which S19 file to store active NVM data to
and then click the “OK” button. For NVM0 use ‘PD_NVM0.s19’ and for NVM1 use
‘PD_NVM1.s19’.
Figure 20 S19 File Window
9. Close “Programmer Expert” window.
10. Use the PC tool “Production_Data_Converter.exe” to convert the production data in NVM to default
NVM sector NVM0. Copy the “Production_Data_Converter.exe” tool to the folder that contains the
PD_NVM0.s19 and PD_NVM1.s19 files. Execute the ‘Production_Data_Converter.exe’. The output
is an PD_NVM.s19 file containing the production data from the active NVM sector.
NOTE
The “Production_Data_Converter.exe” tool can be found in the EVK release
“EVK_3_0B” in folder .\source\Zigbee_EVK\EVK_Common\CPROG_Tool\Scripts\
11. Click on “Load Application” under the “File” menu to open the “Load Executable File” window.
Specify the application file to program using the “Load Executable” window as shown in Figure 21.
Select the “Motorola S-Record (*.s19)” under “Files of type:”, then navigate to the folder where a
copy of the Embedded Bootloader is located. Select the “Embedded Bootloader.s19” file and click the
“Open” button.
The Embedded Bootloader is now programmed to the PCB as shown in Figure 22.
Figure 22 Status Window
12. Write NVM production data back by selecting the “PEDebug” menu. Then select “Programming
Options” and “Start Expert Mode Programmer”. Select “SS Specify S-record” and locate the
PD_NVM.s19 file built in Step 10. Select the “PM Program Module” option and production data is
written to flash.
13. Remove power and disconnect the BDM cable from PCB. Next, power up the PCB.
The PCB is now ready to upload an application. See Chapter 2 for more information about how to
upload an application.
NOTE
The applications must have the production section in the NVM cleared.
That is, the application image must contain 0xFF's in the production data
section of the NVM.
This chapter describes the deliverables required to build an 802.15.4/Zigbee Application with the
Embedded Bootloader.
NOTE
The Freescale Switch Demonstration application is available with
complete source code. The Switch Demonsration shows how to make an
802.15.4 application with the Embedded Bootloader. Refer to the Switch Demonstration Application Note, AN2773, for more details.
5.1 Product Deliverables
To be able to make an application with the Freescale Embedded Bootloader, you need three major
components.
• Embedded Bootloader Image
• Application Support Files
• Application Linker File
5.1.1 Embedded Bootloader Image
The Embedded Booloader executable image for a specific PCB must exist on the PCB in advance. If not,
it must be downloaded to the PCB with a BDM debugger like the P&E Multilink BDM debugger for
HCS08. See Section 1.1.1 Ported Targets for more details.
NOTE
Use caution when making an 802.15.4/Zigbee Application with the
Embedded Bootloader. Several versions (different version numbers) exist
with different supported features. Ensure that you do not use a feature
that is not supported by the Embedded Bootloader version on the PCB
and that a version of the Embedded Bootloader is preloaded on the PCB.
5.1.2 Application Suppor t Files
A few application source files must be included in the 802.15.4/Zigbee application for proper interface to
the Embedded Bootloader. See Section 5.3, Application Support Files for more details.
The 802.15.4/Zigbee application code must be linked with the following linker file in order to work with
the Embedded Bootloader interface. The linker file specifies fixed data and code segments. See linker file
for more details. Make sure to use the linker file matching the Embedded Bootloader on the PCB:
Ptc_w_Embedded_Bootloader.ach
NOTE
This file can be used with the MC908HCS08GB60/GT60 MCU.
5.2 Application
This section describes build environment topics and source files necessary to build a working
802.15.4/Zigbee application with the Embedded Bootloader.
5.2.1 Compiler Defines
The following compiler #define must be specified to enable Embedded Bootloader functionality in an
802.15.4/Zigbee application:
#define BOOTLOADER_ENABLED
5.2.2 Unreferenced Symbols
The Embedded Bootloader interface variables, NVM, and strings with version numbers, are not
referenced directly from the 802.15.4/Zigbee application code. Because of this, it is required to add
dummy references to these (and other) unreferenced symbols to prevent the linker file from removing the
symbols during optimization. The dummy references can be placed in any reference function, but
Freescale recommends adding them to the main() function.
The following code is an example from a SMAC application main() function:
{
// Do something to aviod that code is removed by linker
}
5.2.3 System Clock Setup
The Embedded Bootloader contains the ICG_Setup() function which is called if the Embedded
Bootloader must start. The Embedded Bootloader sets up the system clock as specified in the NVM
section (ICG) if available. If not a default value is used.
The 802.15.4/Zigbee application must include a system clock setup function. The 802.15.4/Zigbee
application can access the clock setup FL_ICG_Setup() function in the Embedded Bootloader. This
allows the application to save code space for implementing a system clock setup function. Any clock
setting can be setup by specifying the proper ICG register values in the NVM data section.
The 802.15.4/Zigbee application should also have a “lost clock lock” ISR function which calls the
FL_ICG_Setup() function. This function must be added to the ISR vector table.
The following is an example of an ISR function to handle lost lock of clock (CLKO).
__interrupt void FLL_Lost_Lock_ISR(void)
{
// Setup ICG module again to prevent that system hangs forever.
ICGS1 |= 0x01; // Clear FLL lost lock interrupt
#if defined BOOTLOADER_ENABLED
FL_ICG_Setup(); // Call ICG_Setup()in Embedded Bootloader
#endif defined BOOTLOADER_ENABLED
}
5.3 Application Support Files
The 802.15.4/Zigbee application must include some support source code to make an interface to the
Embedded Bootloader application. The needed files are delivered to users who want to use the Embedded
Bootloader in their system.
NOTE
Some of the files are global header files from the 802.15.4 MAC/PHY release.
Look for new or updated application support files at the Freescale
Zigbee/802.15.4 web page.
5.3.1 DigiType.h
This file contains some C-language type definitions used in the source files.
5.3.2 Gb60_io.h
This is an MC908HCS08GB60 MCU interface file. All peripherals embedded in the MCU are listed with
their absolute addresses.
This file can also be used with the MC908HCS08GT60 MCU.
5.3.3 Crt0.c and Crt.h
These files contain the basic initialization code (basic system clock, memory and stack setup). The normal
basic init file(s) (like the start08.c from Metrowerks) is not needed when the Embedded Bootloader is
embedded.
In an 802.15.4/Zigbee application with Embedded Bootloader, these files only contain the _startupdata
structure. The Embedded Bootloader handles all the basic initialization (memory and stack setup) of the
application. That is, the application’s main() function will be the first item called (entry point).
NOTE
Do not include basic initialization (memory and stack setup) when
building an application with the Embedded Bootloader. Place any
necessary initialization function calls in the main() function. Whatever,
the initialization function or only the _startupdata structure is included is
controlled by compiler #defines. See Section 5.2.1, Compiler Defines
5.3.4 Embedded_Bootloader.h and Embedded_Bootloader .c
These are the interface files for the 802.14.4/Zigbee application. They contain function pointers to
functions accessible in the Embedded Bootloader. These files also contain absolute addresses, which
should not be changed.
Ensure that the two Embedded Bootloader control flags, which control whether the 802.15.4/Zigbee
application starts or not, are included in the 802.15.4/Zigbee application build. See Section 5.2.2 for more
details.
#pragma CONST_SEG APP_BOOTLOADER_FLAGS
// Default setting for how BootLoader downloads firmware
const uint8_t boot_loader_control = ALL_BIT_ENABLED;
const uint8_t boot_loader_flag = EXECUTE_APPLICATION;
#pragma CONST_SEG DEFAULT
The 802.15.4/Zigbee application must also call the “void BootLoader_Interface_Init(void)” function to
set up pointers to the Embedded Bootloader accessible function. The function must be called once during
system initialization.
NOTE
In earlier versions, these files were titled “FreeLoader_inf.c” and
“FreeLoader_inf.h”. Do not user the “FreeLoader_inf.c” and
“FreeLoader_inf.h” files with the Embedded Bootloader.
5.3.5 NV_Data.c and NV_Data.h
The NVM is not a part of the Embedded Bootloader. However, it is advised to make the NVM a part of
the 802.15.4/Zigbee application.
The Embedded Bootloader can use the information in NV memory, but it has default values (safe mode
boot) to cover scenarios where no NV memory is available, that is, the Embedded Bootloader would be
locked to use the default values.
5.3.6 ISR_Vectors.c
The Embedded Bootloader redirects the ISR vector table to 0x0EFC0, i.e. the 802.15.4/Zigbee application
ISR vector table must be locate at 0x0EFC0 to 0xEFFD (see linker file).
The file also contains a reset vector. The reset vector is not used (defined out) when using the Embedded
Bootloader. The system reset vector is in the Embedded Bootloader address space (0xFFFE). The
Embedded Bootloader has two system variables located where the redirected “reset vector” is locate at
0xEFFE to 0xEFFF. The variables control the startup of the Embedded Bootloader.
This file contains a dummy ISR function which makes a break if a BDM debugger is attached to the
BDM connector. An illegal instruction reset occurs if no BDM debugger is attached. The function is
added to all unused ISR vectors in the ISR_Vector.c file.
NOTE
Users can change this function to any desired functionality.
This chapter describes the Embedded Bootloader source code release deliverables and how to integrate
them to make an executable Embedded Bootloader for a specific PCB.
NOTE
For user convenience, several readme.txt files containing more
information are located in various subfolders.
6.1 Embedded Bootloader Build Environment
This chapter describes the Embedded Bootloader build environment. The Embedded Bootloader
application is built under the Metrowerks IDE CodeWarrior Development Studio for Freescale HC08 3.0,
build 030506.
6.1.1 HCS08 Compiler
All Embedded Bootloader source files are compiled with the following compiler and with the ‘Generate
Code for HCS08’ Code Generation option enabled.
Specific allocated code and variables must not be reallocated, but users can add new code and data
segments.
The 802.15.4 and Zigbee applications that interface to the Embedded
Bootloader must be linked with the "Ptc_w_Embedded_Bootloader.ach"
file for proper functionality.
WStdoutOn
NOTE
6.1.3 HCS08 LibMaker
The delivered libraries were made with the following libmaker.
Source file: hw_hc08_libmaker.dll, version 5.0.8.0
Setting: None
6.2 Product Deliverables
The Freescale Embedded Bootloaader consists of four major components. Refer to Appendix A for a
complete list of released files.
6.2.1 Embedded_Bootloader.mcp
This is the Metrowerks Codewarrior mcp project file. This file is used to build the release of the
Embedded Bootloader.
NOTE
It is required that you have Metrowerks Codewarrior installed on your PC to build the
Embedded Bootloader.
6.2.2 HCS08_Flash_Lib.Lib
The library contains functions to write to the internal flash of the HCS08 MCU. The library also contains
functions to handle NVM run-time updates.
The flash library version number is found by searching for the ASCII text string “HCS08 Flash Lib” in
the ‘HCS08_Flash_Lib.Lib’. The version number is only available from flash library version 5.00.
NOTE
The HCS0_Flash_Lib.Lib can also be included directly in an application
for run-time update of NVM. Refer to the HCSO8 Flash Application
Note, AN2770/D for more information.
6.2.3 Embedded_Bootloader_Functionality_Lib. Lib
The library contains the internal functionality of the Embedded Bootloader. For example, the state
machine which handles the firmware download, the UART drivers, checksum verification functions and
others.
The Embedded Bootloader functionality library version number is found by searching for the ASCII text
string “EB Func Lib” in the ‘Embedded_Bootloader_Functionality_Lib.Lib’ file.
6.2.4 Source Files
This section provides a brief description of the source files. Refer to Appendix A for more details. The
source files described are those which define the PCB interface. For example, the I/O mapping that
connects the MCU and RF chip.
Embedded_Bootloader_Target.h Specific Embedded Bootloader defines
For example, the Embedded Bootloader version number.
This section provides guidelines on how to port the Embedded Bootloader to a specific PCB/target.
6.3.1 Code and Data Segments
The Embedded Bootloader must be linked with the linker file as specified in Section 6.1.2. Several code
and data segments are listed and must not be changed. Refer to the map file as described in Chapter 8 for
more details.
6.3.2 Standard Libraries
The Embedded Bootloader must include the ansiis.lib from Metrowerks for a successful build. The
library is part of the Metrowerks CodeWarrior installation and is located in the following path:
The user must define the PCB target specific #defines in the Target.h in the
.\802.15.4_Headers\Ghdr. file for a successful port.
NOTE
Several other #defines are made in the target description in target.h. The
#defines are used by the 802.15.4 MAC/PHY build. The listed #defines
are the ones which must (also) be defined for the Embedded Bootloader:
Example for the Freescale TARGET_DIG528_2 and TARGET_DIG536_2:
The application does not have a reset vector. If a reset occurs in an
application, the Embedded Bootloader’s reset vector is called.
6.4.3 Embedded_Bootloader_Target.h
Users must define the following #defines in the Embedded_Bootloader_Target.h to achieve a
successful port.
Version number of the build:
// Version number update:
// - Big change (interface/main code structure/new feature) Y.xx, increment
Y
// - Smaller change (function code structure/bug fix) x.Yx, increment Y
// - Small change (bug fix) x.xY, increment Y
#define EMBEDDED_BOOTLOADER_VERSION "5.01" // Number used with all PCB/Targets
NOTE
Use caution if the version number is changed. You should only change
the PCB board number (
to indicate a special PCB version.
Example for the TARGET_DIG528_2 and TARGET_DIG536_2:
#if defined TARGET_DIG528_2 || defined TARGET_DIG536_2
// PCB board number for release
#define EMBEDDED_BOOTLOADER_TARGET "528&536"
// Setup port as output where "signal" must be set/cleared to indicate
safe mode boot
#define SAFE_MODE_PORT_SETUP PTDDD |= 0x01; // Port D bit 0
#endif defined TARGET_DIG528_2 || defined TARGET_DIG536_2
6.4.4 HW_Init.h
This file contains prototypes of all the init functions and defines.
6.4.5 HW_Init.c
This file contains some hardware init functions which depend on the PCB layout.
void HWResetAbel(void) Reset of MC13192 RF chip (do not change)
void Safe_Boot_Mode_Indicator(void) Users can change this function so it matches the
functions available for a particular PCB. The
function can also be left empty. Default is a GPIO
pin set low to light an LED.
void HW_Init() The init main function.
NOTE
User can add more functions if required for a particular PCB.
Do not change the calling sequence.
6.4.6 main.c
This file contains the Embedded Bootloader main function and the Embedded version number.
void main(void) It calls the hardware init function and then the
Embedded Bootloader state machine. The state
machine never returns.
NOTE
Dummy references are made to the version number strings for the
Embedded_Bootloader_Functionality_Lib and HCS08_Flash_Lib to
place the numbers in the executable image. If the version numbers are
not required, they can be removed by removing the reference to the
version number which frees up more code memory for user code.
The following functions, located in the Embedded Bootloader, are made accessible for 802.15.4/Zigbee
applications. For example, an 802.15.4/Zigbee application is not required to have programming routines
to store NVM data in flash. A function pointer, for each function of the below listed functions, is defined
in Embedded Bootloader.c:
The Embedded_Bootloader.h file contains function pointer prototypes and must be included in source
files calling these functions. The function pointers are setup to point to functions with the same name in
the Embedded Bootloader.
The application must call this function to make the system ready for a new firmware download. The
application must provide a way for the user to interact with the system to call this function.
The Embedded Bootloader control flags correspond to the “optional
firmware upload settings” which can be disabled/enabled in the Zigbee
Flash Tool. See Section 1.4.1, Embedded Bootloader Description for
details.
The value is inverted. To enable the bit mask option, the setting must be
set to 0. To disable the bit mask option, the setting must be set to 1.
Use firmware_state – control if Embedded Bootloader or the application must be started.
To enable download, the setting must be = DO_UPDATE_FIRMWARE.
The application can call this function to update any NVM parameter with new values specified in the
input parameters. There is no validation of input parameters.
NOTE
NVM can in code be read as a normal construct.
Input:
NV_RAM_Distination_ptr A pointer to current NV RAM data (ex. The MAC address), which must be changed.
Source_ptr A pointer to new NVM data, which must be stored.
Source_Length The length (number of bytes) of the new NVM data to store.
Output:
True – NVM data stored.
False - Something went wrong (should never happen).
This function should never be called under normal conditions. However, it should be called if any of the
other Embedded Bootloader functions malfunctions. The function sets up the flash functions (again), i.e.
copies the flash routines to RAM for execution and initialize the HCS08 flash module.
Input:
None
Output
None
7.1.5 FL_ICG_Setup
Prototype:
void FL_ICG_Setup(void)
Description:
This function can be called by the application. The function could be automatically called if the external
system clock is unstable/removed (from ISR function) and on power down/up (doze). This requires that
the FL_ICG_Setup is called from an ISR function.
NOTE
Application programmers can make their own system clock setup
function or call this function and just modify the ICG and MC13192
register values in the NVM section.
This function can be called when the application has detected the active communication interface if used
by the application. The communication interface can be any of the two SCI-ports (SCI1 or SCI2). When
called with the proper parameters the Embedded Bootloader knows the active communication interface.
Input:
data_reg_address the address of the active SCI port data register (SCI1 = 0x1F or SCI2 = 0x27 )
status_reg_address the address of the active SCI port status 1 register (SCI1 = 0x1C or SCI2 = 0x24)
= May be used by Embedded Bootloader. 802.15.4/App.
can reuse this space (overwrite).
= Used by Embedded Bootloader. Data/code which must be located on the specified
address and (must/will) exists when the application is running
= May be used by
802.15.4/App.
= Used by 802.15.4/App. Data/code which must be
located on the specified address
If either the Embedded Bootloader and/or the 802.15.4/App. must not use a particular resource the color
from the "General HCS08 Map and Usage" is kept.
Cursive = fixed register and vectors in flash
Bold = MUST be located on this particular address - DO NOT
CHANGE.
Flash sector 120-127 is block protected and cannot be erased by SW.
Embedded Bootloader
Application
RAM 4096 bytes available
bytes available (not including ISR vectors and
Code 4016
NV-RAM 1024
reset vector)
bytes available. Read and written by Embedded Bootloader (2 sectors are used,
so it occupies 1024 bytes flash).
This appendix describes the folder and file structure for this release.
A.1. Folder Structure
802.15.4_Headers
Ghdr Global headers from the 802.15.4 MAC/PHY Release
Bin
Embedded_Bootloader When target is built, the output files are stored here.
AX-0308RevC Freescale’s reference build of the Embedded Bootloader
for the Axiom AXM-0308
development board
DIG-528-2_DIG-536-2_RD01 DIG-528-2 and DIG-536-2 are Freescale’s reference
build for the DIG-528-2 and DIG-536-2 EVB’s.
RD01 is Freescale's reference build for all PCB's using
the Freescale Reference Design version 01.