Engineer-to-Engineer Note

EE-367

Technical notes on using Analog Devices DSPs, processors and development tools
Visit our Web resources http://w w w .analog.com/ee-notes and http://w w w .analog.com/processors ore-mail processor.support@analog.com or processor.tools.support@analog.com for technical support.

Flash Programmer Drivers for ADSP-BF51xF16 Blackfin® Processors
Contributed by Harrington, David

Intro ductio nAnalog Devices Inc. released a productdiscontinuance notification (PD13_0091[2]‎ ) forADSP-BF51xF Blackfin® processors describing
SPI flash memory die changes. Specifically,ADSP-BF51xF4devicescontaining
anembedded SST25WF040‎[4] SPI flash memory die
were discontinued and replaced by ADSPBF51xF16‎[1] devices containing an embedded
S25FL116K[5]‎SPI flash memory die. Thischange requires adjustments to existing drivers
that were developed to communicate with the onchip SPI flash memory.

Rev 1 – July 8, 2014

VisualDSP++ Flash Pro grammer
Utility Mo dificatio ns
VisualDSP++ flash programmer utility is anembedded program that runs on ADSP-BF51x
Blackfin processor core to configure the SPI portand properly communicate with the on-chip SPI
flash memory device. This includes sector
program/fill/erase commands, as well asfunctions like chip erase. Inclusive of thesecommands is the ability to program the SPI flash
memory with the application boot loader image(.LDR file) so that the processor can boot fromthe internal flash.

This EE-Note describes the modifications
required for the existing VisualDSP++® flash
programmer utility to work with the new ADSPBF51xF16 devices, which can be used as aguideline for any custom-developed drivers. Inaddition, for CrossCore® Embedded Studio(CCES) users, a new driver for use with theCCES Command Line Device Programmer(CLDP) is introduced, which can also serve as aboilerplate for any custom SPI memory device
drivers under CCES.

VisualDSP++ flash programmer utility (release5.1.1 or later) uses the device driver for theSST25WF040 memory, which only supports theADSP-BF51xF4 devices. This driver, however,can be modified to also work with the new
S25FL116K memory die present in the ADSPBF51xF16 devices.

To open the driver from the VisualDSP++ tools,
select File->Open->Project and navigate to thisfolder.
ThenselecttheprojectfileBF518FEzFlashDriver_SST25WF040.dpj .

While the CCES driver provided withthis EE-Note will only support ADSPBF51xF16 devices, VisualDSP++ driver
supports both ADSP-BF51xF16 andADSP-BF51xF4 devices.

The associated .ZIP file includes a VisualDSP++
project for the flash programmer utility in theVDSPInternalSPI folder.

Support for the S25FL116K memory was addedin the detection portion of the code such that theS25FL116K flash device can be recognized andcommunicated with properly. The two files that
requiredmodification
aretheVDSPInternalSPI\sst25wf040.handVDSPInternalSPI\sst25wf040.c.

Copy right 2014, Analog Devices, Inc. All rights reserv ed. Analog Dev ices assumes no responsibility f or customer product design or the use o r application ofcustomers’ 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, howev er noresponsibility is assumed by Analog Devices regarding technical accuracy and topicality of the content prov ided in Analog Dev ices Engineer-to-Engineer Notes.

Detecting the S25FL116K SPI Flash ID

Modifying sst25wf040.h
This file defines the manufacturer/capacity
JEDEC ID codes and the number of physicalsectors for the memory device, which wereadded for the S25FL116K flash device from thememory data sheet[5]‎ , as shown in Listing 1:/* ids for S25FL116K SPI Flash *//* Spansion, Inc. */#define MAN_CODE_SPANSION0x01/* S25FL116K (16Mbit SPI flash) */#define DEV_CODE_S25
0x15/* num sectors */#define NUM_SECTORS_S25

512

Listing 1. JEDEC ID Modifications

These #defines supporting the S25FL116K
flash memory were added after the #defines forthe original SST25WF040 flash memory.
Modifying sst25wf040.c
The sst25wf040.c file contains the mainfunctions for opening, closing, writing andreading the flash device. In this file, support wasadded for:

Start and end addressing
Detecting the S25FL116K SPI flash ID

Start and End Addresses

The VisualDSP++ driver requires mapping of thebeginning and end of the available storage space.
As such, the following #defines were added atline 26, as shown in Listing 2:/* Spansion S25FL116K Start and End
Address - 16Mbit SPI Flash*/#define START_ADDRESS_S250x0#define END_ADDRESS_S25
0x001fffff/* 2 Mbyte */Listing 2. S25FL116K Memory Address Range

When the driver first opens, it reads the device
ID from the SPI memory. Support to recognize
the S25FL116K flash during this operation wasadded at line 190 via an additional ifstatement, as shown in Listing 3.
Once the S25FL116K is detected, the number ofsectors, description, and company name are setup
so the proper configuration appears in the flash
programmer utility. Also, the SPI0 baud rate isincreased to speed up writing to and erasing themuch larger S25FL116K flash device.

Due to the larger capacity of theS25FL116K versus the previous flash
memory device, VisualDSP++ tools
may appear to lock up during
erase/programming operations. It may
take several minutes depending on theemulation device.

// Check if device is S25FL116K
else if(DEV_CODE_S25 == g_DevId){// 512 4KB sectors
gNumSectors = 512;// Change Flash description
pFlashDesc = "S25FL116K";// Change flash company namepDeviceCompany = "Spansion, Inc.";// Increase SPI0 baud
*pSPI0_BAUD = 0x2;}
Listing 3. S25FL116K Device Detection/Configuration

Bo o ting fro m SPI Flash Memo ry
To build the flash programmer utility driver,select Project->Build Project in yourVisualDSP++ session. The executable file (.DXE)
will be located in the VDSPinternalSPI folder.

As the flash programmer utility GUI
makes use of embedded debug
information, make sure that the driver isbuilt in Debug mode (default), and notin Release mode.

Flash Programmer Drivers for ADSP-BF51xF16 Blackfin® Processors (EE-367)

Page 2 of 5

Once the new driver is built, the flash
programmer utility GUI must be directed to it.
Make sure a powered target board is connected
via a VisualDSP++ emulator session and selectTools->Flash Programmer, which opens theGUI. On the Driver tab, click the […] browse
button next to the Driver file dialog box,
navigate to the VDSPInternalSPI folder, andselect the new driver that was just built,

Importing and Building the Driver in CCES
The .ZIP file associated with this EE-Note
includes a CCES project for the flash memory
device driver in the CCESInternalSPI folder. To
import the project in the CCES tools:
Select File->Import.

SelectExisting
Projects
Workspace and click Next.

Ensure Select root directory is selected,
and click the associated Browse... button.

The Browse For Folder window opens.
Navigate to the CCESInternalSPI folder
and click OK.

BF518FEzFlashDriver_SST25WF040.dxe.

When Load Driver is clicked, the Flash
Information from Listing 1 and Listing 3 shouldappear, and the new ADSP-BF51xF16 device isnow supported by the same tools used with theprevious ADSP-BF51xF4 devices. If the target
board were swapped with a board featuring theADSP-BF51xF4 device, this same driver when
loaded would reflect the Flash Information for
the SST25WF040 SPI flash die and function
identically.

CCES Co nsideratio ns
The flash programmer utility present in theVisualDSP++ tools is not currently supported in
the CCES development tools. Rather, there is a
Command Line Device Programmer (CLDP) thatis used to program memory devices.
Similar to the VisualDSP++ flash programmer
utility, the CCES CLDP tool also requires amemory device driver to properly communicate
with the connected SPI memory. However,
because the device driver API was significantly
changed from VisualDSP++ to CCES, the driver
had to be created from scratch for theS25FL116K memory embedded in ADSPBF51xF16 devices.
This driver can be used as the baseline for similar
SPI flash memory drivers required by customer
applications.

intoOnce the project is imported, the driver
executable (.DXE file) can be built by using theProject->Build Project pull-down, and theoutput .DXE file will be located in theCCESInternalSPI\serial\Debug folder. This iswhat the CLDP will use to program the bootimage into the on-chip flash. However, the drivercode itself can be modified to support other SPIflash memory devices, as described next.
S25FL116K Driver Files
In the Project Explorer view, click the arrownext to the bf518f_s25fl116k_dpia project
name to list the source files. The relevant files
for the CCES S25FL116K SPI flash memory
drivercode
areincludedintheCCESInternalSPI\serial\src directory:
bf518f_s25fl116k_dpia.c\s25fl116k\s25fl116k.c
Supported JEDEC Commands

The S25FL116K flash supports the same basic
JEDEC flash memory command structure as the
SST25WF040 featured on the ADSP-BF51xF4devices, namely those depicted in Table 1.

Flash Programmer Drivers for ADSP-BF51xF16 Blackfin® Processors (EE-367)

Page 3 of 5

Command NameInstruction

READ_DATA

0x03

FAST_READ

0x0B

SECTOR_ERASE

0xD8

BULK_ERASE

0xC7

PAGE_PROGRAM

0x02

READ_STATUS_REGISTER

0x05

WRITE_STATUS_REGISTER

0x01

WRITE_ENABLE

0x06

WRITE_DISABLE

0x04

JEDEC_ID

0x9F

READ_SIGNATURE

0xAB

Table 1. Supported Flash CommandsThe #defines for the instructions are located inthe s25fl116k.c file starting at line 5, andadditional commands can be added as needed tosupport other memories.
JEDEC ID

Unlike the VisualDSP++ device driver, thisdevice driver uses three parts of the JEDEC ID toidentify the connected flash device - theManufacturer’s ID, the Memory Type ID, andthe Capacity ID. These three IDs help identify
various flash devices and allow the driver toselect the correct sector map table and commandstructure. The JEDEC ID for the S25FL116K
flash memory is shown in Table 2:
JEDEC ID

Value

Manufacture ID

0x01

Memory Type ID

0x40

Capacity ID

0x15

struct flash_info s25fl116k_info ="s25fl116k", /* name */"Spansion", /* name */0x01,/* manufacturer ID */0xff,/* 0xff */0x40,/* memory type */0x15,/* capacity ID */STANDARD, /* supported modes */Listing 4. JEDEC ID CodeSPI Slave-Select Pin

On ADSP-BF51xFy devices, the SPI SlaveSelect pin (PH8) is internally routed as a
dedicated chip-select for the internal SPI flash
memory. In the bf518f_s25fl116k_dpia.csource file, line 44 configures the SPI SlaveSelect pin along with the SPI pins for SCK,MISO and MOSI. Make sure that the SlaveSelect is set for PH8 for the internal SPI select tooperate.
Flash Sector Map

Each flash memory device has a unique sector
map, which is based on the memory size andmemory block configuration. The sector map isrequired for the programmer driver to determine
which blocks of memory require erasing prior toa new write operation.
The S25FL116K is configured into 512 sectors,
each containing 4 kB (0x1000 bytes). The sector
map can be configured in the s25fl116k.c filein the following #defines starting at line 26(Listing 5):#define NUM_SECTORS 512#define SECTOR_SIZE 0x1000
Listing 5. Sector Map CodeTable 2. JEDEC ID Information for S25FL116K

TheJEDECID

can be changed in thes25fl116k.c file starting at line 320 , as shownin Listing 4.

Flash Programmer Drivers for ADSP-BF51xF16 Blackfin® Processors (EE-367)

Page 4 of 5

Using the CLDP to Program ADSP-BF51xF16Processors
The CLDP utility for CCES (cldp.exe) islocated in the root installation folder (default):\Analog
Devices\CrossCore
Studio CCES_version_number\Embedded

To program the ADSP-BF51xF16 device withthe loader image for an application calledapp.ldr, make sure a powered target board isconnected via emulator, and open a Windows
command prompt (cmd.exe). Navigate to theroot path for the CCES installation and use thefollowing command:This command line assumes theconnected target is the ADSP-BF518
EZ-KIT board via the HPUSB-ICE
emulator and that the associated .ZIParchive was extracted to the C:\ rootdirectory. The processor, emulator,
driver pathname, and/or .ldr file namemay need to be modified.
More information on the CLDP can befound in CCES On-Line Help.

cldp.exe –proc ADSP-BF518 –emu HPUSB –driver“C:\CCESInternalSPI\serial\Debug\bf518f_s25fl116k_dpia.dxe” –cmd prog –erase
affected –format hex –file “app.ldr”

References[1] ADSP-BF512/ADSP-BF514/ADSP-BF514F16/ADSP-BF516/ADSP-BF518/ADSP-BF518F16 Blackfin Embedded
Processor Data Sheet. Rev D, April 2014. Analog Devices, Inc.
[2] Obsolescence and Replacement Options for ADSP-BF512F, BF514F, BF516F and BF518F Processors with Flash
Memory ( http://www.analog.com/static/imported -files/PCN/ADI_PDN_13_0091_Rev_-_Form.pdf ).
November 2014. Analog Devices Inc.
[3] ADSP-BF51x Blackfin Processor Hardware Reference. Rev 1.2, February 2013. Analog Devices, Inc.
[4] SST25WF040 Microchip 4 Mbit Serial Flash Data Sheet. Rev B. December 2012. Microchip Technology Inc.
[5] S25FL116K Spansion 16 Mbit Serial Flash Data Sheet. Rev 1. April 14, 2014. Spansion Inc.

Do cument Histo ryRevisionDescription

Rev 1 – July 8, 2014by D. Harrington

Initial release.

Flash Programmer Drivers for ADSP-BF51xF16 Blackfin® Processors (EE-367)

Page 5 of 5