ENT-AN1144-4.00 Application Note SPI Flash Design for VCore-III Microsemi makes no warranty, representation, or guarantee regarding the information contained herein or the suitability of its products and services for any particular purpose, nor does Microsemi assume any liability whatsoever arising out of the application or use of any product or circuit. The products sold hereunder and any other products sold by Microsemi have been subject to limited testing and should not be used in conjunction with mission-critical equipment or applications. Any performance specifications are believed to be reliable but are not verified, and Buyer must conduct and complete all performance and other testing of the products, alone and together with, or installed in, any end-products. Buyer shall not Microsemi Corporate Headquarters rely on any data and performance specifications or parameters provided by Microsemi. It is the Buyer's responsibility to One Enterprise, Aliso Viejo, independently determine suitability of any products and to test and verify the same. The information provided by Microsemi CA 92656 USA hereunder is provided “as is, where is” and with all faults, and the entire risk associated with such information is entirely Within the USA: +1 (800) 713-4113 with the Buyer. Microsemi does not grant, explicitly or implicitly, to any party any patent rights, licenses, or any other IP Outside the USA: +1 (949) 380-6100 rights, whether with regard to such information itself or anything described by such information. Information provided in this Fax: +1 (949) 215-4996 document is proprietary to Microsemi, and Microsemi reserves the right to make any changes to the information in this Email: [email protected] document or to any products and services at any time without notice. www.microsemi.com About Microsemi

© 2019 Microsemi Corporation. All Microsemi Corporation (Nasdaq: MSCC) offers a comprehensive portfolio of semiconductor and system solutions for aerospace & defense, communications, data center and industrial markets. Products include high-performance and rights reserved. Microsemi and the radiation-hardened analog mixed-signal integrated circuits, FPGAs, SoCs and ASICs; power management products; Microsemi logo are trademarks of timing and synchronization devices and precise time solutions, setting the world's standard for time; voice processing Microsemi Corporation. All other devices; RF solutions; discrete components; enterprise storage and communication solutions, security technologies and trademarks and service marks are the scalable anti-tamper products; Ethernet solutions; Power-over-Ethernet ICs and midspans; as well as custom design property of their respective owners. capabilities and services. Microsemi is headquartered in Aliso Viejo, California, and has approximately 4,800 employees globally. Learn more at www.microsemi.com.

VPPD-04306. 1.0 8/19 Contents

1 Revision History ...... 1 1.1 Revision 1.0 ...... 1 2 Flash Design for VCore-III ...... 2 2.1 Hardware Design ...... 2 2.1.1 Flash Support ...... 2 2.2 Flash Programming ...... 2 2.2.1 Installing Software from Scratch: How to Flash a Board ...... 3 2.2.2 Upgrading Software from Within an Existing Installation ...... 3 2.2.3 Updating an Existing Board with New RedBoot (CLI) ...... 3 2.3 Flash Layout ...... 3 2.3.1 Flash Layout (32 MB) ...... 4 2.3.2 Flash Layout (16 MB) ...... 4 2.4 Creating a Flash Image ...... 4 2.5 Flash Size Recommendations ...... 6

VPPD-04306 ENT-AN1144-4.00 Application Note Revision 1.0 iii Tables

Table 1 Flash Layout Detail (32 MB) ...... 4 Table 2 Flash Layout Detail (16 MB) ...... 4 Table 3 Recommended Flash Size ...... 6

VPPD-04306 ENT-AN1144-4.00 Application Note Revision 1.0 iv Revision History

1 Revision History

The revision history describes the changes that were implemented in the document. The changes are listed by revision, starting with the most current publication. 1.1 Revision 1.0 Revision 1.0 was the first publication of this document.

VPPD-04306 ENT-AN1144-4.00 Application Note Revision 1.0 1 Flash Design for VCore-III

2 Flash Design for VCore-III

This document provides guidelines for designing the SPI NOR flash and NAND flash on a Microsemi Enterprise or Carrier Ethernet switch. It includes hardware design and RedBoot bootloader update guidelines and is relevant for all VCore-III based Ethernet switches. 2.1 Hardware Design The Vcore-III CPU boots from the Serial Interface (SI) and Serial Peripheral Interface (SPI). Initially the CPU uses 24-bit addressing for accessing 16 MB of data, but it can access a larger data area using 32-bit addressing after initial boot. Accessing the SPI NOR flash in 32-bit addressing mode is done under full CPU control (bit-banging). To make sure the SPI NOR flash is brought back to 24-bit addressing mode after a reset, the flash reset should be connected to the switch reset signal through a resistor. For SPI flash programming, a pin header can be used for connecting a flash programmer. The switch reset signal needs to be held low for tri-stating the switch and allowing the flash programmer control of the SPI signals. In this case, the flash reset should not be active. For chip selecting the SPI NOR flash, SI_nEN is used. To extend the total flash memory, NAND flash can be added. NANAD flash are available with both parallel and SPI interface. See the actual reference design for detailed design. Note: NAND flash is only supported under OS, and not by the RedBoot bootloader. 2.1.1 Flash Support The bootloader (and eCos OS) supports m25p80 compatible SPI NOR flash and automatically detects the flash sector size and numbers of sectors through jedec id. A list of supported SPI NOR flash types is found at: /packages/devs/flash/spi/m25pxx/current/src/m25pxx.c The Macronix NAND flash driver SPI NAND MX35LF2GE4AB is included in the Linux kernel. The procedures in this document describe the single-chip flash designs. Designs using multiple flash chips are possible, but outside the scope of this document. Adding a new NOR flash type to RedBoot is done by adding the jedec_id/sector_size/sector_count information into ecos/packages/devs/flash/spi/m25pxx/current/src/m25pxx.c Note: Both application code and bootloader need to be recompiled if NOR flash type is updated of added. 2.2 Flash Programming To support the WebStaX software package family, the NOR must be initialized with the following components. • Bootloader (RedBoot) • Configuration sections • Main eCos-based WebStaX image (dual images for fails-safe upgrade) • RedBoot flash partition info (FIS) The process of initializing the NOR for operating the WebStaX software involves using a SPI NOR programmer with flash images created for the desired switch target system. The flash images are generated as described in Creating a Flash Image, page 4.

VPPD-04306 ENT-AN1144-4.00 Application Note Revision 1.0 2 Flash Design for VCore-III

2.2.1 Installing Software from Scratch: How to Flash a Board The procedure for installing the software from scratch on a new board involves using a SPI programmer. For more information about the requirements and the procedure, see the AN1184 application note. Although the application note is part of the Linux documentation, the information applies to eCos as well. 2.2.2 Upgrading Software from Within an Existing Installation If the system is already capable of and network connectivity, the Web GUI or CLI can be used to update the main application. To update the main application: log in and click Maintenance > Software > Upload, and upgrade using the eCos.dat firmware image. Use the firmware upgrade CLI command to upload the.dat firmware image. A TFTP or HTTP URL might be used to point the network location of the image. The CLI can be accesses by RS232 or SSH. 2.2.3 Updating an Existing Board with New RedBoot (CLI) To update an existing board using CLI, perform the following steps: 1. Ensure that the RedBoot image is available on a TFTP/FTP/HTTP server. 2. Ensure the necessary network connections and IP configuration to create connectivity to the TFTP/FTP/HTTP server. 3. Establish a CLI session on the system to be updated. 4. Enter the debug command enabler: platform debug allow. 5. Execute the debug firmware bootloader CLI command to perform the update. 6. After the update succeeds, restart the device. 7. Identify the new bootloader by the boot banner on the RS232 console. 2.3 Flash Layout Flash is used with the RedBoot flash image system (FIS) and the layout is as shown in Table 1, page 4, Table 2, page 4, and Table 3, page 6. In RedBoot, use the fis list command to display the flash layout. The first area is the RedBoot bootloader, which takes up 32 KB. The next area is the conf used to store board-specific information, such as the MAC address and board ID. Use the following CLI commands to display board data. #platform debug allow #debug board MAC Address: 00-01-c1-00-b6-e0 Board ID: 75 Board Type Conf: 0 Board Type Active: Serval (11)

Note: The debug command for older releases is in the vcli. Type debug vcl debug board. • Stackconf contains the switch configuration. • Syslog is the persistent system log that logs system events like port link-up or -down. • Crashfile contains the information stored after a software crash. For dual images (managed and managed.bk), 6 MB is allocated in a 16-MB flash layout and 12 MB is allocated in a 32-MB flash layout. The Diag area is used to store manufacturing diagnostic data. RedBoot reserves some partition names for internal use; namely: RedBoot, Redundant FIS, and FIS directory. These are created automatically by the fis init command and should not be used.

VPPD-04306 ENT-AN1144-4.00 Application Note Revision 1.0 3 Flash Design for VCore-III

2.3.1 Flash Layout (32 MB) The following table details characteristics of a 32-MB flash layou.

Table 1 • Flash Layout Detail (32 MB)

Name FLASH Address Mem Address Length Entry Point .FisValid 0x00000000 0x00000000 0x00000000 0x00000000 RedBoot 0x40000000 0x00000000 0x00040000 0x00000000 conf 0x40040000 0x00000000 0x00010000 0x00000000 Linux 0x40050000 0x80100000 0x00FC0000 0x80100000 Linux.bk 0x41010000 0x80100000 0x00FC0000 0x80100000 FIS directory 0x41FD0000 0x00000000 0x00010000 0x00000000 RedBoot config 0x41FE0000 0x00000000 0x00001000 0x00000000 Redundant FIS 0x41FF0000 0x00000000 0x00010000 0x00000000 2.3.2 Flash Layout (16 MB) The following table details characteristics of a 16MB flash layout.

Table 2 • Flash Layout Detail (16 MB)

Name FLASH Address Mem Address Length Entry Point .FisValid 0x00000000 0x00000000 0x00000000 0x00000000 RedBoot 0x40000000 0x00000000 0x00040000 0x00000000 conf 0x40040000 0x00000000 0x00040000 0x00000000 Linux 0x40080000 0x80100000 0x00740000 0x80100000 Linux.bk 0x407C0000 0x80100000 0x00740000 0x80100000 FIS directory 0x40F40000 0x00000000 0x00040000 0x00000000 RedBoot config 0x40F80000 0x00000000 0x00001000 0x00000000 Redundant FIS 0x40FC0000 0x00000000 0x00040000 0x00000000 2.4 Creating a Flash Image It is possible to create flash images by replacing individual sections with data and rearranging the standard flash layout through the flash_builder tool hosted on: https://github.com/vtss/flash_builder. The tool can be downloaded by executing git clone https://github.com/vtss/flash_builder.git on a Linux system. This will create a flash_builder/directory in the current directory. The tool is written in perl and requires the YAML::Tiny module installed. The tool enables a text template to be defined, outlining the flash layout.The tool produces a flash image with the same name in the out/ directory by running the script buildflash.pl with the text template as argument. The templates/ directory holds a number of flash layouts for a number of Microsemi reference boards. While defining a custom image, use the template matching eCos, a target switch, and the geometry of the flash device design. The geometry is defined by the total size—erase block size of the flash chip. When the best starting point for the template has been found, copy the file to a new file and name it.

VPPD-04306 ENT-AN1144-4.00 Application Note Revision 1.0 4 Flash Design for VCore-III

Here is the reference template: ecos-jaguar2-cu8sfp16-32mb-64kb.txt: # Flash template: ecos-jaguar2-cu8sfp16-32mb-64kb # The first section describe the flash geometry: capacity, blocksize --- - capacity: 32M blocksize: 64K # # Subsequent sections describe individual flash sections: # - name: The FIS name. 1 to 15 characters # - size: Flash section size. Units 'M' or 'K' # - flash: Hex address of section # - entry: Hex address of execution entrypoint (optional) # - memory: Hex address of memory load address (optional) # - datafile: File name to load data from (optional) - name: 'RedBoot' size: 256K flash: 0x40000000 datafile: artifacts/redboot-jaguar2.img - name: 'conf' size: 64K flash: 0x40040000 - name: 'stackconf' size: 256K flash: 0x40050000 - name: 'syslog' size: 256K flash: 0x40090000 - name: 'crashfile' size: 256K flash: 0x400d0000 - name: 'managed' size: 15744K flash: 0x40110000 memory: 0x80040000 entry: 0x800400bc datafile: artifacts/web_switch_jr2_ref.gz - name: 'managed.bk' size: 15744K flash: 0x41070000 memory: 0x80040000 entry: 0x800400bc datafile: artifacts/web_switch_jr2_ref.gz - name: 'FIS directory' size: 64K flash: 0x41fd0000 - name: 'RedBoot config' size: 4K flash: 0x41fe0000 datafile: files/fconfig-ecos.bin - name: 'Redundant FIS' size: 64K flash: 0x41ff0000

The command lines in the files (starting with #) describe the sections and define the keywords. Obey the following rules: • Let the bootloader be the first entry, as the system will start to execute from the start of the flash.

VPPD-04306 ENT-AN1144-4.00 Application Note Revision 1.0 5 Flash Design for VCore-III

• Leave the last three sections as they are—they are assumed to be at the fixed address by the bootloader. • Shuffle around, resize, and initialize the remaining sections with data as needed. • Do not overlap Flash sections (unused sections are fine). The following example modifies the template and generates a new flash image. $ cp templates/ecos-jaguar2-cu8sfp16-32mb-64kb.txt templates/custom-jaguar2- cu8sfp16-32mb-64kb.txt $ vi templates/custom-jaguar2-cu8sfp16-32mb-64kb.txt $ perl ./buildflash.pl --verbose templates/custom-jaguar2-cu8sfp16-32mb- 64kb.txt Completed custom-jaguar2-cu8sfp16-32mb-64kb $ ls -lh images/custom-* -rw-rw-r-- 1 lpovlsen lpovlsen 32M Sep 13 14:10 images/custom-jaguar2- cu8sfp16-32mb-64kb.bin

Note: Creating flash images with the flash_builder tool requires a RedBoot image (for example, redboot- jaguar2.img) and a software application image (for example, web_switch_jr2_ref.gz) to be present as artifacts (see datafile path in the template) because these will be included in the generated flash image. 2.5 Flash Size Recommendations The following table shows the recommended flash size for different application packages. Flash size also depends on the and whether customer applications are added.

Table 3 • Recommended Flash Size

Description WebStaX SMBStaX ISTaX CEServices Linux Image 16 MB SPI NOR + 16 MB SPI NOR + 16 MB SPI NOR + 16 MB SPI NOR + 128 MB SPI NAND 128 MB SPI NAND 128 MB SPI NAND 128 MB SPI NAND

Note: The firmware parts, stored in NAND, require about 10 MB per image (total 20 MB in worst case). This include all Linux file system components. The remainder NAND storage may be used for customer applications.

VPPD-04306 ENT-AN1144-4.00 Application Note Revision 1.0 6