Analog Devices EE257v01 Application Notes

Engineer-to-Engineer Note EE-257
a
Technical notes on using Analog Devices DSPs, processors and development tools
Contact our technical support at dsp.support@analog.com and at dsptools.support@analog.com Or vi sit our o n-li ne r esou rces htt p:/ /www.analog.com/ee-notes and http://www.analog.com/processors
A Boot Compression/Decompression Algorithm for Blackfin® Processors
Contributed by Bob Nakib Rev 1 – December 9, 2004

Introduction

This application note describes a boot compression/decompression algorithm for ADSP-BF533 and ADSP-BF561 Blackfin® processors.
The code included with this document was verified using the VisualDSP++® 3.5 tools suite for Blackfin processors. The project was run on an EZ-KIT Lite® evaluation system for ADSP­BF533 Blackfin processors (ADDS-BF533­EZLITE, Rev 1.2) and on an EZ-KIT Lite evaluation system for ADSP-BF561 Blackfin processors (ADDS-BF561-EZLITE, Rev 1.1).

Purpose

Normally, loader files created by VisualDSP++ are not compressed, except possibly with a simple run-length compression scheme used on strings of 0s in the compiled code. For large projects that must be stored in non-volatile memory, compression provides significant savings in hardware, such as on-board flash. Decompression code can then be executed at boot time by creating a 2nd-stage loader or initialization code containing the decompression algorithm. For more information regarding the initialization code or any aspect of the booting process, refer to ADSP-BF533 Blackfin Booting
Process (EE-240)
[1]
.

Boot Compression/Decompression Algorithm

This compression algorithm requires about 50 KB of overhead (extra) memory. Therefore, it is useful only in applications of a significantly larger size. The compression/decompression functions are handled by a simple open-source compression library called Zlib. For more information, see
http://www.gzip.org/zlib/.
As an example, a compressed Blink application is included with this EE-Note for your convenience. It is suggested that you try the following steps using the included Blink application to familiarize yourself with the compression process, then try programming the last generated file (CompressedAppIntelHex
with the Flash Programmer to verify
.ldr)
correct functionality. Figure 3 shows the entire process.

Step 1

You must allocate an unused area of SDRAM memory in your user-application to store the uncompressed user-application loader image. The .LDF file of your user-application project must be modified to free a section of SDRAM memory of appropriate size. This region must be large enough to hold an entire loader build of your user-application, allowing uncompress() to deflate to that area in memory.
Copyright 2004, Analog Devices, Inc. All rights reserved. Analog Devices assumes no responsibility for customer product design or the use or application of customers’ products or for any infringements of patents or rights of others which may result from Analog Devices assistance. All trademarks and logos are property of their respective holders. Information furnished by Analog Devices applications and development tools engineers is believed to be accurate and reliable, however no responsibility is assumed by Analog Devices regarding technical accuracy and topicality of the content provided in Analog Devices’ Engineer-to-Engineer Notes.
a
The user-application loader image will then be loaded by the Boot ROM out of SDRAM.
For ADSP-BF561 processors, you must also free L2 memory addresses 0xFEB1 FC00 through
0xFEB1 FFE7 by keeping them out of any section
in your user-application's
.LDF file. These
addresses are reserved for the 2nd-stage boot kernel. This is done in the
.LDF file of the
example ADSP-BF561 Blink program.

Step 2

Set the UNCOMPR_ADDR field at the top of the
Init_code.c file (Init folder) to the intended
destination address for the output of the uncompress function (that is, the starting address of the reserved section or kept empty in the SDRAM memory of your user-application in
Step 1). In the given example, this address is set
to 0x4000.

Step 3

Specify the user-application project to be built as a Loader file (via Load page of Project Options dialog box) and use SPI/ASCII/8-bit format. Note that the SPI setting is a workaround used to generate the output in ASCII format.
For ADSP-BF533 processors, specify the following path to the initialization project file:
../Init/Debug/Init.dxe. (See Figure 1.)
For ADSP-BF561 processors, select Boot
kernel options Use boot kernel, and specify the path to the
kernel file as: under
./debug/p0.dxe.
from the Category list, select
../Init/Debug/p0.dxe. Also,
Additional options, insert:
When executed at the start of the boot process, this object file initializes SDRAM memory, finds the compressed user-application code, and decompresses it to the appropriate area in SDRAM memory.
Figure 1. Loader Options for ADSP-BF533 Processors
A Boot Compression/Decompression Algorithm for Blackfin® Processors (EE-257) Page 2 of 7
a

Step 4

Build the Init code project first, and then build your user-application. Ensure that the project to be built is active (highlighted in the Project window) and that project dependencies are set, if necessary. This should create an .LDR file in the Debug directory of your user-application.

Step 5

In the root folder, edit the compress.bat file (use any text editor) to specify the path of the target loader file that has just been built from your user-application, as well as the desired level of compression (see Table 1 in the Appendix for compression levels). Note that the entered path must be enclosed in double-quotes (") and must use forward-slashes or double-backslashes. An incorrectly specified path name or compression level may cause undesirable results.

Step 6

Execute compress.bat (root folder) and ensure the result of the compression (returned on line 6 of the Output window) is successful by matching
your return code with those listed in Table 2 in the Appendix.
The Output window (Figure 2) returns important values calculated during compression, notably:
Source file size (line 1) Source buffer start address (line 2) Number of bytes used for the source buffer
(line 3)
Application start address and number of
bytes used for the Init code buffer (line 4)
Application size and output buffer start
address (line 5)
Compression result (0 = success) and
compressed application size (line 6)
Path of the output file (line 7)
If successful, a file called CompressedApp.ldr is created in the same directory as your source loader file (that is, the Debug directory of your user-application). This ASCII format file contains both the Init (decompression) code and your compressed user-application code.
Figure 2. Compression Script Output Window, RESULT = 0 (SUCCESS)
A Boot Compression/Decompression Algorithm for Blackfin® Processors (EE-257) Page 3 of 7
Loading...
+ 4 hidden pages