You have no items in your shopping cart.

Subtotal: 0.00

Getting started with Flash Magic

Getting started with Flash Magic

1.INTRODUCTION OF FLASH MAGIC

2.FIVE STEP PROGRAMMING

3.ADDITIONAL ISP FEATURES

4.ADVANCED OPTIONS

1.INTRODUCTION OF FLASH MAGIC

NXP Semiconductors produce a range of Microcontrollers that feature both on-chip Flash memory and the ability to be reprogrammed using In-System Programming technology.


Flash Magic is Windows software from the Embedded Systems Academy that allows easy access to all the ISP features provided by the devices. These features include


  • Erasing the Flash memory (individual blocks or the whole device)
  • Programming the Flash memory
  • Modifying the Boot Vector and Status Byte
  • Reading Flash memory
  • Performing a blank check on a section of Flash memory
  • Reading the signature bytes
  • Reading and writing the security bits
  • Direct load of a new baud rate (high speed communications)
  • Sending commands to place device in Boot loader mode

Flash Magic provides a clear and simple user interface to these features. Under Windows, only one application may have access the COM Port at any one time, preventing other applications from using the COM Port.


Flash Magic only obtains access to the selected COM Port when ISP operations are being performed. This means that other applications that need to use the COM Port, such as debugging tools, may be used while Flash Magic is loaded.


Screenshot of Flash Magic Window
<screenshot-of-flash-magic-window

The window is divided up into five sections. Work your way from section 1 to section 5 to program a device using the most common functions.


At the very bottom left of the window is an area where progress messages will be displayed and at the very bottom right is where the progress bar is displayed. In between the messages and the progress bar is a count of the number of times the currently selected hex file has been programmed since it was last modified or selected.


Just above the progress information Embedded Hints are displayed. These are rotating Internet links that you can click on to go to a web page using your default browser.


Menus

There are five menus, File, ISP, Options, Tools and Help.




menus-for-getting-slicker


The File menu provides access to loading and saving Hex Files, loading and saving settings files and exiting the application.




hex-files-loading-and-saving-settings


The Options menu allows access to the advanced options and includes an item to reset all options.

item-to-reset-all-options

The ISP menu provides access to the less commonly used ISP features.

isp-menu

The Tools menu provides features that support the operation and use of Flash Magic.

use-of-flash-magic

The Help menu contains items that link directly to useful web pages and also open the Help About window showing the version number.

Tooltips

use-of-flash-magic

Throughout the Flash Magic user interface extensive use has been made of tooltips. These are small text boxes that appear when you place the pointer over something and keep it still for a second or two.


Note that tooltips do not appear for items that are disabled (grayed out).


Saving Options

The options in the main window and the Advanced Options window are automatically saved to the registry whenever Flash Magic is closed. This removes the need for an explicit save operation. When Flash Magic is restarted the main window and the Advanced Options window will appear as you left it, so you do not have to repeatedly make the same selections every time you start the application. If you wish to reset the options to the original defaults then choose Reset from the Options menu.



2.FIVE STEP PROGRAMMING

For each step there is a corresponding section in the main window as described in the User Interface Tour.


Step 1 – Connection Settings

Before the device can be used the settings required to make a connection must be specified.

step-1--connection-settings
COM Port Settings

Select the desired COM port from the drop down list or type the desired COM port directly into the box. If you enter the COM port yourself then you must enter it in one of the following formats


  • COM n
  • n

Any other format will generate an error. So if you want to use COM 5 (which is not present on the drop down list) you can directly type in either “COM 5” or “5”.


Baud Rate Settings

Select the baud rate to connect at. Try a low speed first. The maximum speed that can be used depends on the crystal frequency on your hardware. You can try connecting at higher and higher speeds until connections fail. Then you have found the highest baud rate to connect at.


Alternatively, some devices support high speed communications.


Device Selection

Select the device being used from the drop down list. Ensure you select the correct one as different devices have different feature sets and different methods of setting up the serial communications.


Interface Selection

Select the interface being used, if any. An interface is a device that connects between your PC and the target hardware. If you simply have a serial cable or USB to serial cable connecting your COM port to the target hardware, then you can choose "None (ISP)". Choosing the correct interface will automatically configure Flash Magic for that interface, along with enabling and disabling the relevant features.


Oscillator Frequency

Enter the oscillator frequency used on the hardware. Do not round the frequency, instead enter it as precisely as possible. Some devices do not require the oscillator frequency to be entered, so this field will not be displayed.


Once the options are set ensure the device is running the on-chip Boot loader if you are using a manual ISP entry method.


Note that the connection settings affect all ISP features provided by Flash Magic.


Step 2 – Erasing

This step is optional, however if you attempt to program the device without first erasing at least one Flash block, then Flash Magic will warn you and ask you if you are sure you want to program the device.

step-2--erasing
  • Select each Flash block that you wish to erase by clicking on its name.
  • If you wish to erase all the Flash then check that option.
  • If you want to check to erase a Flash block and all the Flash then the Flash block will not be individually erased.
  • If you wish to erase only the Flash blocks used by the hex file you are going to select, then check that option.

For most devices erasing all the Flash also results in the Boot Vector and Status Byte being set to default values, which ensure that the Boot loader will be executed on reset, regardless of the state of the PSEN pin or other hardware requirements.


Only when programming a Hex File has been completed will the Status Byte be set to 00H to allow the code to execute.


This is a safeguard against accidentally attempting to execute when the Flash is erased.


On some devices erasing all the Flash will also erase the security bits. This will be indicated by the text next to the Erase all Flash option.


On some devices erasing all the Flash will also erase the speed setting of the device (the number of clocks per cycle) setting it back to the default.


This will be indicated by the text next to the Erase all Flash option.


Step 3 – Selecting the Hex File

This step is optional. If you do not wish to program a Hex File then do not select one.

step-3--selecting-the-hex-file

You can either enter a path name in the text box or click on the Browse button to select a Hex File by browsing to it.


Also you can choose Open… from the File menu.


Note that the Hex file is not loaded or cached in any way. This means that if the Hex File is modified, you do not have to reselect it in Flash Magic. Every time the Hex File is programmed it is first re-read from the location specified in the main window.


The date the Hex file was last modified is shown in this section. This information is updated whenever the hex file is modified. The hex file does not need to be reselected.


Clicking on more info or choosing Information… from the File menu will display additional information about the Hex file.


The information includes the range of Flash memory used by the Hex file, the number of bytes of Flash memory used and the percentage of the currently selected device that will be filled by programming the Hex file.


If the device supports programming and execution from RAM, for example the ARM devices, then the hex file may contain records for the RAM.


First the flash will be programmed followed by the RAM. Programs loaded into RAM via a hex file may be executed using such features as the Go option.


Step 4 – Options

Flash Magic provides various options that may be used after the Hex File has been programmed.


This section is optional; however verify After Programming, Fill Unused Flash and Gen Block Checksums may only be used if a Hex File is selected (and therefore being programmed), as they all need to know either the Hex File contents or memory locations used by the Hex File.

step-4options
Verify After Programming

Checking the Verify after Programming option will result in the data contained in the Hex File being read back from Flash and compared with the Hex File after programming. This helps to ensure that the Hex File was correctly programmed. If the device does not support verifying then this item will be disabled.


Fill Unused Flash

Checking the Fill Unused Flash option will result in every memory location not used by the Hex File being programmed with the value that sets all the bits to a programmed state.


Once a location has been programmed with this feature it cannot be reprogrammed with any other value, preventing someone from programming the device with a small program to read out the contents of Flash or altering the application’s operation.


General Block Checksums

Checking the Gen Block Checksums option will instruct Flash Magic to program the highest location in every Flash block used by the Hex File with a special “checksum adjuster value”.


This value ensures that when a checksum is calculated for the whole Flash Block it will equal 55H, providing the contents of the Flash block have not be altered or corrupted. Please refer to the Block Checksums section for more information.


Execute option

Checking the Execute option will cause the downloaded firmware to be executed automatically after the programming is complete. Note that this will not work if using the Hardware Reset option or a device that does not support this feature.


Step 5 – Performing the Operations

Step 5 contains a Start button.

step-5--performing-the-operations>

Clicking the Start button will result in all the selected operations in the main window taking place. They are:


  • Erasing Flash
  • Programming the Hex File
  • Verifying the Hex File
  • Filling Unused Flash
  • Generating Checksums
  • Programming the clocks bit
  • Programming the Security Bits
  • Executing the firmware

Once started the progress information and a progress bar will be displayed at the bottom of the main window.


In addition the Start button will change to a cancel button. Click on the cancel button to cancel the operation.


Note that if you cancel during erasing all the Flash, it may take a few seconds before the operation is cancelled.


Once the operations have finished the progress information will briefly show the message “Finished”.


The Programmed Count shown next to the progress bar will increment. This shows the total number of times the hex file has been programmed.


Modifying the hex file or selecting another hex file will reset the count.


Alternatively, right-clicking over the count provides a menu with the option to immediately reset the count.



3..ADDITIONAL ISP FEATURES


Saving a Hex File

Once connected choosing Save As… from the File menu opens the Hex File save window. It is possible to save a section of Flash memory to a Hex File.


Enter the start address and the end address (inclusive) that you wish to save. Note that the start and end addresses do not have to correspond to a Flash block.


If desired you can save a single memory location by entering it as both the start and end address.


Next select the location and name of the Hex file to save by either entering a path in the text box or clicking on the Browse button and browsing to a folder.


Finally, click on the Save button to start save. Progress information on the save will be shown at the bottom of the window.


Blank Check

Choose Blank Check… from the ISP menu to perform a blank check on all the Flash blocks present on the device.

blank-check

Once complete the Blank Check window will look something like the following:


  • The status column indicates if a block is blank or not.

Checking the option to Mark non-blank blocks to be erased will have the effect of checking the relevant items in the Erase section of the main window.


For example if Block 0 is not blank, then checking the Mark option will result in Block 0 in the Erase section of the main window being checked.


Reading the Security Settings

When Flash Magic is first started it will attempt to read the security bits of any device that is connected to the specified COM Port.

reading-the-security-settings

If no device is connected then you may connect a device and choose Read Security from the ISP menu. The security settings will be read and the following window opened


  • If a security bit is set then it will be highlighted.

Reading the Device Signature

The device signature is comprised of two or three bytes that identify the device or a single 32-bit value. To read the device signature choose Read Device Signature from the ISP menu.

reading-the-device-signature

The signature will be read and the following window will open showing the three bytes:


  • A manufacturer ID of 15H corresponds to NXP Semiconductors.
  • Some devices will also display the boot loader version in this window.

Modifying the Boot Vector and Status Byte

The Status Byte indicates how the device will operate after a reset. A value of 00H will result in the device checking the PSEN pin to determine whether it should run the Boot loader or the user application. Any other value will result in the device running the Boot loader.


The Boot Vector contains the page that the Boot loader (or user boot loader) starts at. The default varies depending on the device but as an example FCH corresponds to the address FC00H for 8051 non-LPC devices, and F8H, corresponds to the address F800H for the XA devices.


Once programming is completed it is possible to change both the Boot Vector and Status Byte by selecting Boot Vector and Status Byte from the ISP menu. You will be presented with the following window

boot-vector-and-status-byte

The current Boot Vector and Status Byte settings will be shown. Modify the settings as desired and click on the Reprogram button.


Setting the Boot Vector to a value other than the default may result in the inability to run the Boot loader on the device. This will mean that the ISP features of the device cannot be accessed until the device has been erased in a Parallel Programmer.


Because of this danger, you will be presented with a confirmation window if you try to reprogram the Boot Vector to a non-default value

confirm-changeing-boot-victor

Following the below instructions in the window carefully to reprogram the Boot Vector.


Once the Boot Vector and Status Byte have been reprogrammed a confirmation message will be displayed.


Some devices do not support a Boot Vector. However, the Status Byte may still be changed by selecting Status Byte from the ISP menu.


The following dialog window will be displayed

check-psen

Modify the settings and click on the Reprogram button.


Displaying Memory

A useful feature is the ability to view the contents of memory. Choosing Display Memory from the ISP menu accesses this feature.


Memory is shown one block at a time. The block being displayed may be selected from the drop-down list at the bottom of the Display Memory window

display-memory-window-of-flash-magic

Each line shows 16 bytes of data starting at the address given at the start of the line. If a line contains question marks then data has not yet been read in for those locations. The memory is read in the background allowing viewing of the memory that has been loaded in without having to wait for all of it to be read.


At any time a new range may be selected or the window closed.


Each line shows the 16 bytes of data first in hexadecimal format then in ASCII format. For characters that are not printable a period is displayed instead.


Erasing Flash

There are two ways Flash can be erased. Either as part of the five step process described earlier in this manual, or without performing any other ISP operations by choosing Erase Flash from the ISP menu.


The Erase Flash window will be opened. Its operation is identical to the erase section in the main window. Once settings have been chosen click on the Erase button to erase.

erase-flash-window

Progress information is displayed at the bottom of the window.


Verifying a Hex File

A Hex File can be verified without programming it into the device first. To access the verify feature choose Verify… from the ISP menu.


You will be presented with the following dialog window:

verify-hex-files

Select a Hex File to verify either by entering the path to the file of clicking on the Browse button and choosing it.


If checksums were used when the device was programmed then check the option to ignore checksum locations, as they will be different in memory to any reserved checksum locations stored in the Hex file.


Click on the Verify button to start verification. Progress information is shown at the bottom of the window.


Reset and Execute

Selecting the Reset item on the ISP menu will cause a reset command to be sent to the device.


Depending on the hardware and the status byte, the device is either reset to the execute code or reset to the Boot loader.


If the Reset command is sent after successfully programming the device then the reset will execute the downloaded code.


If the Reset command is sent after erasing the device then the device will reset to the Boot loader.


Selecting the Execute item on the ISP menu will cause Flash Magic to program the Boot Vector to the default and the Status Byte to zero (for devices that have this feature), followed by sending a reset command to the device.


This will force any downloaded code to be executed.


Start Boot loader Description

The Start Boot loader feature allows a textual command or break condition to be sent to the device to place it into Boot loader mode. In order for this to work however it must be supported by the user’s application or the device.


For textual commands the user’s application must watch the UART for the command to be received.


Once received the application must echo back the command and a single full stop, then use In-Application Programming to program the Boot Vector to the default and the Status Bit/Byte to non-zero, and then reset the device.


Once the device completes the reset the Boot loader will be executed, allowing the device to be reprogrammed.


If a break condition is sent, then Flash Magic does not expect the break condition to be echoed back and assumes the device has been placed in Boot loader mode.


Choosing “Start Boot loader…” from the ISP menu accesses the Start Boot loader feature. The following dialog window will be displayed.

start-boot-loader-feature

Select to either send a textual command or a break condition.


The baud rate used is completely independent from the baud rate in the main window. This allows the user’s application to use the UART at say 9600 baud, but allow Flash Magic to use say 19200 baud either with or without high-speed communications turned on. However the COM Port used is the same as the one selected in the main window.


Select the baud rate, enter the textual command (which may be anything you desire), select the append option you want and click on Start Boot loader to send. If successful the ISP features of Flash Magic can now be used.


The append options allow a carriage return and line feed to be added to the command. This is useful if your application implements a command line via the serial port and expects all commands to end in these control characters. Select the setting that matches your implementation.


Combined with the automatic Reset after programming option, devices may be programmed and tested repeatedly without ever having to touch the hardware.


Erase Pages

Some devices allow the flash to be erased in pages. If this feature is supported by the device then the Erase Flash Pages… item on the ISP menu will be enabled.

erase-flash-pages

Select the pages to erase and click on the Erase button to erase them.


Device Configuration

Some devices allow configuration via ISP. If the selected device supports this feature then the Device Configuration… item on the ISP menu will be enabled. When selected the current configuration will be read from the device and displayed in the configuration dialog window.


The configuration may then be changed and by clicking on Reprogram the new configuration will be programmed into the device.

device-configuration

Some devices support protecting the device configuration, along with the boot vector and status bit/byte. On these devices a Clear configuration Protect button will be shown, which when clicked will send the command to clear the protection for the configuration of the device.


Cyclic Redundancy Check

Some devices instead of a verify option provide a Cyclic Redundancy Check (CRC) option, where the device can calculate a 32-bit CRC value for a single Flash Block or the entire device. CRCs are a form of checksum, therefore if the contents of the memory change, there is a very high probability the CRC will also change.


If the selected device supports CRCs then the Cyclic Redundancy Check… item on the ISP menu will be enabled. Selecting it displays the CRC window.

serial-number-of-fash

When the window is first opened the CRC value is read from the device for each Flash Block and the entire device. These values are shown in the “Device CRC” column.


Click on the Add button and select each of the Hex files programmed into the device. Each Hex file will appear in the list at the bottom of the window.


To remove a Hex file from the list select it in the list and click on the Remove button.


Click on the Calculate CRC button to calculate the CRCs for each block and the whole device, as if the chosen Hex files were programmed into the device. These values will appear in the “Hex Files CRC” column. If the contents of the device exactly match the contents of the chosen Hex files then the CRCs on each row of the table will match.


MISR

Some devices instead of a verify option provide a MISR option, where the device can calculate a 128-bit MISR value for a single Flash Block or the entire device. MISR values are a form of checksum, therefore if the contents of the memory change, there is a very high probability the MISR value will also change.


If the selected device supports MISR values then the Read MISR… item on the ISP menu will be enabled. Selecting it displays the MISR window, which is functionally identical to the CRC window described in the previous section.


When the window is first opened the MISR value is read from the device for each Flash Block and the entire device. These values are shown in the “Device MISR” column.


Click on the Add button and select each of the Hex files programmed into the device. Each Hex file will appear in the list at the bottom of the window.


To remove a Hex file from the list select it in the list and click on the Remove button.


Click on the Calculate MISR button to calculate the MISR values for each block and the whole device, as if the chosen Hex files were programmed into the device. These values will appear in the “Hex Files MISR” column.


If the contents of the device exactly match the contents of the chosen Hex files then the MISR values on each row of the table will match.


Go

Some devices support executing from specific addresses in flash or RAM and using specific options or modes, for example the ARM devices.


To perform a Go operation and start execution choose Go… from the ISP menu.


Enter the address to start execution from and choose the mode to execute in. Click on Go to start execution.


Serial Number

Some devices provide a serial number feature, which protects access to the device via ISP.


If a serial number is supplied to the device then on the next reset the device will block most ISP operations until it is unlocked by supplying the correct serial number. The serial number may be reset being erased stopping unauthorized access to the code.


Check the device datasheet for the exact details of the implementation.


If the selected device supports serial numbers then the Serial Number… item on the ISP menu will be enabled. Selecting it displays the serial number window.

serial-number-of-fash

To set a serial number, enter it into box boxes indicated. The contents of the boxes must match. Then click on Set Serial Number.


For reset a serial number click on the Reset Serial Number button. To unlock a device using a serial number, enter the correct serial number into the box and click on Unlock Device.


Serial numbers may be entered in ASCII or Hexadecimal, by selecting from the drop-down list. Examples of ASCII serial numbers


  • 2A45bc2
  • foobar
  • MyOldMan

Examples of Hexadecimal serial numbers:


  • 23BD4C2101ED3451
  • 112233AABBCC

Serial numbers may be any length up to the maximum allowed. Hexadecimal serial numbers must not include the 0x prefix or the H/h suffix.


Update Boot loader

Some devices allow the boot loader to be updated via ISP. This can only be performed using a special boot loader update hex file supplied by NXP Semiconductors. Flash Magic supports these hex files.


If the currently selected device supports this feature, then "Update Boot loader…" on the ISP menu will be enabled. Choosing the menu item displays the dialog window.

update-boot-loader

Simply select the boot loader update hex file by entering the path to the file or clicking on the Browse… button to select it. Click on Update to start the update process.

Status information will be shown at the bottom of the dialog window.


Once complete Flash Magic will indicate that the boot loader was updated or the reason why the update failed.


Only use special boot loader update hex files supplied by NXP Semiconductors that are created for this feature. Do not interrupt the power supply or reset the device during the update. Failure to follow these warnings may result in a device that no longer has a functional boot loader.


Additional Security Bits

Some devices support additional security bits that are not related to specific section of Flash memory. If the selected device has this feature then the Additional Security Bits… option on the ISP menu will be available. Choosing the option will display a dialog window showing the additional security bits for that device.


When the window is opened the current settings for the security bits will be read from the device and displayed in the window. Checking a security bit will set that bit. Un- checking a security bit will attempt to unset it.


Note that setting these security bits may have significant repercussions on the functionality of the device. It is strongly recommended to consult the data sheet or user manual and understand the functionality of these bits before setting them.



4.ADVANCED OPTIONS


High Speed Communications

Some devices feature the ability to switch from the initial baud rate to a high speed communications mode, allowing speeds higher than the auto baud method in the Boot loader would be able to accurately measure.


Flash Magic will calculate the highest possible baud rate that may be used by both the device and the PC COM Port and automatically switch to it after connecting at the initial baud rate specified in the main window


If you experience problems with this feature, then try limiting how fast the high speed communications mode can go. Select the maximum speed from the drop-down list. If in doubt, select 9600 and start increasing until the problems appear.


Half-duplex Communications

When communicating with the device Flash Magic can send and receive data at the same time to achieve the fastest data rate. This type of transmission is called full-duplex. Turning the half-duplex option on will cause Flash Magic to only transmit one byte at a time, waiting for the byte to be echoed from the Boot loader before transmitting the next byte? While this will slow the data rate down it allows ISP to be performed via half-duplex serial buses.


Note however that you must design your hardware such that the PC and the Boot loader do not receive the bytes they transmit otherwise each will be confused.


Hardware Configuration

For some devices, Flash Magic can control DTR and RTS to enter ISP mode or execute newly downloaded code. To implement this requires a hardware design that supports controlling of the device using DTR and RTS.


The options for controlling this feature are accessed by clicking on the Hardware Configuration tab.


The advantages of this feature include


  • Faster development
  • ISP is now possible on hardware that is hard to reach or enclosed in a box
  • Removes the need for switches or jumpers on the hardware

LPC2xxx

DTR and RTS need to be connected to RST and P0.14 to allow Flash Magic to control the reset and ISP entry of the device.


The following simplified circuit diagram for an LPC2xxx is one possible way of connecting the DTR and RTS signals to RST and P0.14 of the device.

circuit-diagram-for-lpc2xxx

When the COM Port is not in use or the serial cable is not connected, the RS232 signals are pulled low by the transceiver. This results in the TTL signals being high. Therefore when the TTL DTR and RTS signals are high, P0.14 and RST must be in a state that allows the device to reset normally and execute code.


By checking the option to assert RTS while the COM Port is open, the RTS signal will remain asserted while the ISP operation is performed. This allows hardware to be designed that can reset or reconfigure hardware for an ISP operation.


Protect ISP

Some devices contain the ISP code – which allows Flash Magic to communicate with the device – in the main Flash memory. This means that it is possible to erase or corrupt the ISP code. Once erased or corrupted ISP operations can no longer be performed and the device would have to be physically removed from the hardware


In order to stop the ISP code from being accidentally erased the Protect ISP option is provided. When checked, Flash Magic will modify erase and programming operations such that the ISP code is not erased or corrupted.


For example:


  • A full device erase will be achieved by erasing Flash blocks and pages, to erase the Flash without erasing the section of Flash containing the ISP code.
  • A block erase for a block that contains the ISP code will be achieved by erasing pages in the block – if they exist on the device – to avoid erasing the ISP code.
  • The programming of any Hex file containing data that would corrupt the ISP code will be aborted.
  • The section of Flash containing the ISP code will not be filled.
  • Any checksums that are in the same locations as ISP code will not be programmed.

If the Protect ISP option is unchecked then erasing or programming a device has the potential to erase or corrupt the ISP code. Any attempt to perform one of these operations will result in Flash Magic asking for confirmation first.


Erasing or corrupting the ISP code will immediately render the ISP functionality of the device non-functional.


Timeouts

In the Timeouts section the timeouts Flash Magic should use when performing ISP operations are specified. Normally default settings are used, however if you wish to change the timeouts then check the option to use my timeouts and fill in the values in the boxes.


Flash Magic uses two timeouts, regular and long. Each timeout is specified in seconds. The regular timeout is used for most ISP operations. The long timeout is used for erasing and performing blank checks.


The default settings are four seconds for the regular timeout and 60 seconds for the long timeout. It is strongly recommended to use the default settings.


If you are using a USB to COM port converter then you may find that increasing the timeouts will resolve communication problems that are sometimes present with those converters.


Misc

In the Misc section miscellaneous settings relating to Flash Magic can be found.


Flash Magic includes the ability to play a Wave file when programming is completed.


To do this check the option to play a Wave file, then either enter the path to the Wave file into the box or click on the Browse button and select the Wave file. For hearing the Wave file click on the purple arrow.