Accessing Serial Flash Memory Using SPI Interface Su pe rs ed ed Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Accessing Serial Flash Memory Using SPI Interface Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Table of Contents Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Tutorial Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Associated Project Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Target Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 ed ed Design Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Step 1: Creating a Libero SoC Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Launching Libero SoC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Connecting Components in SPI_Flash_0 SmartDesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Configuring and Generating Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Step 2: Generating the Program File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 3: Programming the SmartFusion2 Board Using FlashPro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 4: Building the Software Application Using Keil uVision 5 IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 5: Configuring Serial Terminal Emulation Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 6: Connecting the ULINK-ME to the Board and PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 7: Debugging the Application Project using Keil uVision 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 15 17 31 32 34 41 rs Appendix A - Board Setup for Debugging from Keil uVision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Appendix B - Board Setup for Programming the Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 pe Appendix C- SmartFusion2 Development Kit Board Jumper Locations . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Product Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Su Customer Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Customer Technical Support Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Contacting the Customer Technical Support Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 45 45 45 45 Email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 My Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Outside the U.S. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 ITAR Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Revision 1 2 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Introduction ed ed The Libero® System-on-Chip (SoC) software generates firmware projects using Keil, SoftConsole, and IAR tools. This tutorial describes the process to build a Keil uVision application that can be implemented and validated using the SmartFusion®2 system-on-chip (SoC) field programmable gate array (FPGA) Development Kit. The same firmware project can be built using IAR and Keil tools. Refer to the respective tutorials: • Accessing Serial Flash Memory using SPI Interface - Libero SoC and SoftConsole Flow Tutorial for SmartFusion2 SoC FPGA • Accessing Serial Flash Memory using SPI Interface - Libero SoC and IAR Embedded Workbench Flow Tutorial for SmartFusion2 SoC FPGA After completing this tutorial, you will be able to perform the following tasks: • Create a Libero SoC project using System Builder • Generate the programming file to program the SmartFusion2 device Open the project in Keil uVision from Libero SoC • Compile application code • Debug and run code using Keil uVision rs • Tutorial Requirements pe Table 1 • Reference Design Requirements and Details Reference Design Requirements and Details Description Hardware Requirements • SmartFusion2 Development Kit Rev C or later – FlashPro4 programmer Su – USB A to Mini-B cable – 12 V adapter Keil debugger - Host PC or Laptop Any 64-bit Windows Operating System Software Requirements 11.3 Libero SoC • Keil uVision 5 • FlashPro programming software v11.3 USB to UART drivers - One of the following serial terminal emulation programs: - • HyperTerminal • TeraTerm • PuTTY Revision 1 3 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Associated Project Files Download the associated project files for this tutorial from the Microsemi® website: http://soc.microsemi.com/download/rsc/?f=SF2_SPI_Flash_Keil_Tutorial_DF The demo design files include: • Libero project • Source files • Flash drivers • Readme file Refer to the Readme.txt file provided in the design files for the complete directory structure. ed ed Target Board SmartFusion2 Development Kit board (SF2_DEV_KIT) Rev C (or later). Design Overview This design example demonstrates the execution of basic read and write operations on the SPI flash present on the SmartFusion2 Development Kit board. This kit has a built-in Atmel SPI flash memory AT25DF641, which is connected to the SmartFusion2 microcontroller subsystem (MSS) through dedicated MSS SPI_0 interface. Read and write data information is displayed using HyperTerminal which communicates to the SmartFusion2 MSS using the MMUART_1 interface. For more information on SPI, refer to the SmartFusion2 Microcontroller Subsystem User Guide. rs Figure 1 shows interfacing the external SPI flash to MSS SPI_0. 6PDUW)XVLRQ 008$57BB5;' Su +\SHU7HUPLQDO 63,BB'2 WH[W )DEULF Figure 1 • SPI Flash Interfacing Block Diagram 4 R e vi s i o n 1 63,B +RVW3& 008$57BB7;' 008$57B pe 066 63,BB&/. 63,BB662 63,BB', 6, 6&. &6 62 ([WHUQDO)ODVK 0HPRU\ Step 1: Creating a Libero SoC Project Step 1: Creating a Libero SoC Project Launching Libero SoC 1. Click Start > Programs > Microsemi Libero SoC v11.3 > Libero SoC v11.3, or click the shortcut on desktop to open the Libero SoC v11.3 Project Manager. rs ed ed 2. Create a new project by selecting New on the Start Page tab (highlighted in Figure 2), or by clicking Project > New Project from the Libero SoC menu. Figure 2 • Libero SoC Project Manager pe 3. Enter the information as required for the new project and the device in the New Project dialog box as shown in Figure 3 on page 6. – Project - Name: SPI_Flash - Location: Select an appropriate location (for example, D:/Microsemi_prj) - Preferred HDL type: Verilog – Device (select the following values using the drop-down list provided): Su - Family: SmartFusion2 - Die: M2S050T - Package: 896 FBGA - Speed: STD - Core Voltage: 1.2 – Operating conditions: COM Revision 1 5 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Su pe rs ed ed 4. Check the Use Design Tool check box and select Use System Builder in the Design Templates and Creators section of the New Project window as shown in Figure 3. Figure 3 • New Project Dialog Box Note: System Builder is a graphical design wizard. It creates a design based on high-level design specifications by taking the user through a set of high-level questions that will define the intended system. 6 R e vi s i o n 1 Step 1: Creating a Libero SoC Project 5. Clicking Edit Tool Profiles (highlighted in Figure 3 on page 6) displays the Tool Profiles window as shown in Figure 4. Check the following tool settings: Software IDE: Keil – Synthesis: Synplify Pro ME I-2013.09M-SP1 – Simulation: ModelSim ME 10.2c – Programming: FlashPro 11.3 Figure 4 • Tool Profiles rs ed ed – 6. Click OK on the Tool Profiles window. 7. Click OK on the New Project window. The System Builder dialog box is displayed. Su pe 8. Enter a name for your system, enter SPI_Flash as the name of the system and click OK. The System Builder dialog box is displayed with the Device Features page open by default, as shown in Figure 5. Figure 5 • Create New System Builder Dialog Box Revision 1 7 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA rs ed ed 9. In the System Builder – Device Features page, check the Peripheral DMA check box under Microcontroller Options as shown in Figure 6. Su pe Figure 6 • System Builder – Device Features Page 8 R e vi s i o n 1 Step 1: Creating a Libero SoC Project pe rs ed ed 10. Click Next. The System Builder – Peripherals page is displayed. Under the MSS Peripherals section, uncheck all the check boxes except MM_UART_1 and MSS_SPI_0, as shown in Figure 7. Su Figure 7 • System Builder Configurator – Peripherals Page Revision 1 9 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA rs ed ed 11. Configure MMUART_1 for Fabric by clicking on the MM_UART_1 configurator highlighted as shown in Figure 8. Su pe Figure 8 • System Builder – Peripherals Page 10 R e visio n 1 Step 1: Creating a Libero SoC Project Figure 9 • Configuring MM_UART_1 ed ed 12. In the MM_UART_1 configurator window, select Fabric from the Connect To drop-down list, as shown in Figure 9. Su pe rs 13. Click Next. The System Builder – Clocks page is displayed, as shown in Figure 10. Select System Clock source as On-chip 25/50 MHz RC Oscillator. The M3_CLK is configured to 100 MHz by default. Figure 10 • System Builder – Clocks Page Revision 1 11 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA 14. Click Next. The System Builder – Microcontroller page is displayed. Leave the default settings. 15. Click Next. The System Builder – SECDED page is displayed. Leave the default settings. 16. Click Next. The System Builder – Security page is displayed. Leave the default settings. 17. Click Next. The System Builder – Interrupts page is displayed. Leave the default settings. 18. Click Next. The System Builder – Memory Map page is displayed. Leave the default settings. 19. Click Finish. ed ed The System Builder generates the system based on the selected options. The System Builder block is created and added to the Libero SoC project automatically, as shown in Figure 11. Figure 11 • System Builder Generated System Connecting Components in SPI_Flash_0 SmartDesign Perform the following steps to connect the SmartDesign components: 1. Right-click FAB_RESET_N and select Tie High. rs 2. Right-click POWER_ON_RESET_N and select Mark Unused. 3. Right-click MSS_READY and select Mark Unused. 4. Right-click MMUART_1_FABRIC and select Promote to Top Level. 5. Expand INIT_PINS, right-click INIT_DONE and select Mark Unused. pe 6. Expand FAB_CCC_PINS, right-click FAB_CCC_GL0 and select Mark Unused. Su 7. Click File > Save. The SPI_Flash_0 is displayed as shown in Figure 12. Figure 12 • SPI_Flash_0 Design Configuring and Generating Firmware The Design Firmware window displays compatible firmware drivers based on peripherals configured in the design. Following drivers are used in this tutorial: 12 • CMSIS • MMUART • PDMA • SPI R e visio n 1 Step 1: Creating a Libero SoC Project 1. To generate the required drivers click Design > Configure Firmware and clear all drivers except CMSIS, MMUART, PDMA, and SPI as shown in Figure 14. Figure 13 • Configuring Firmware ed ed Note: Select the latest version of the drivers. rs 2. From the SPI_Flash_top tab, click Generate Component, as shown in Figure 14. Figure 14 • Generate Component Su pe If the design is generated without any errors, a message, ’SPI_Flash_top’ was generated is displayed on the Libero SoC Log window as shown in Figure 15. Figure 15 • Log Window Revision 1 13 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Step 2: Generating the Program File pe rs ed ed 1. Double-click I/O Constraints in the Design Flow window as shown in Figure 16. The I/O Editor window is displayed after completing Synthesize and Compile. Figure 16 • I/O Constraints Su 2. In the I/O Editor window, make the pin assignments as shown in Table 2. Table 2 • Port to Pin Mapping Port Name 14 Pin Number MMUART_1_RXD_F2M R29 MMUART_1_TXD_M2F R24 R e visio n 1 Step 3: Programming the SmartFusion2 Board Using FlashPro ed ed These pin assignments are for connecting MMUART_1 ports TX and RX to the mini-B USB through fabric I/Os. After the pins are assigned, the I/O Editor window is displayed as shown in Figure 17. Figure 17 • I/O Editor 3. After updating the I/O Editor, click Commit and Check. 4. Close the I/O Editor window. pe rs 5. Click Generate Programming Data as shown in Figure 18 to complete place-and-route and generate the programming file. Su Figure 18 • Generate Programming Data Step 3: Programming the SmartFusion2 Board Using FlashPro 1. Connect the FlashPro4 programmer to the J59 connector of the SmartFusion2 Development Kit. 2. Connect the jumpers on the SmartFusion2 Development Kit board as listed in Table 3 on page 16. For more information on jumper locations, refer to the "Appendix C- SmartFusion2 Development Kit Board Jumper Locations" on page 44. CAUTION: While making the jumper connections, the SW7 power supply switch on the board must be in OFF position. Revision 1 15 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Table 3 • SmartFusion2 Development Kit Jumper Settings Jumper Number Settings Notes J70, J93, J94, J117, J123, J142, J157, J160, J167, J225, J226, J227 1-2 closed J2 1-3 closed J23 2-3 closed J121, J110, J119, J118 1-2 closed These are the default jumper settings of the Development Kit. Ensure that these jumpers are set properly. To connect the SmartFusion2 SPI0 to the external flash 3. Connect the power supply to the J18 connector. ed ed 4. Switch ON the SW7 power supply switch. Refer to "Appendix B - Board Setup for Programming the Tutorial" on page 43 for information on board setup for running the tutorial. Su pe rs 5. To program the SmartFusion2 device, double-click Run PROGRAM Action in the Design Flow window as shown in Figure 19. Figure 19 • Run Programming Action 16 R e visio n 1 Step 4: Building the Software Application Using Keil uVision 5 IDE Step 4: Building the Software Application Using Keil uVision 5 IDE pe rs ed ed 1. After successful programming, open the Keil uVision project by double-clicking Write Application Code under Develop Firmware in the Design Flow window as shown in Figure 20. Su Figure 20 • Invoking Keil uVision from the Libero SoC Software Revision 1 17 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA pe rs ed ed The Keil uVision workspace is displayed, as shown in Figure 21. Figure 21 • uVision Workspace 2. Browse to the main.c file location in the design files folder: <download_folder>/SF2_SPI_Flash_Keil_Tutorial_DF\SourceFiles. Su 3. Copy the main.c file and replace the existing main.c file under SPI_Flash_MSS_CM3_0_app project in the uVision workspace. 18 R e visio n 1 Step 4: Building the Software Application Using Keil uVision 5 IDE pe rs ed ed The uVision window displays the main.c file, as shown in Figure 22. Figure 22 • uVision Workspace main.c file Su 4. at25df641 SPI flash drivers are not included in the Libero generated uVision workspace. To include the drivers in the uVision workspace, browse to the location of the at25df641 drivers in the design files folder: <download_folder>\SF2_SPI_Flash_Keil_Tutorial_DF\SPI_Flash_Drivers folder. 5. Copy the at25df641 folder to the drivers folder of SPI_Flash_MSS_CM3_hw_platform project in the uVision workspace. Revision 1 19 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA pe rs ed ed 6. Right-click drivers and add the driver file (at25df641.c) to SPI_Flash_MSS_CM3_hw_platform project in the Keil uVision workspace as shown in Figure 23. Su Figure 23 • Project Explorer Window 20 R e visio n 1 Step 4: Building the Software Application Using Keil uVision 5 IDE pe rs ed ed 7. Change SPI_Flash_MSS_Cm3_hw_platform debug mode to Cortex-M3_SRAM by selecting Cortex-M3_SRAM from the drop-down list, as shown in Figure 24. Figure 24 • Cortex-M3_SRAM Settings Su This tutorial uses printf statements to display memory read data. Redirection of the output of printf() to a UART is enabled by adding the MICROSEMI_STDIO_THRU_UART symbol. Revision 1 21 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Follow the steps given below to add MICROSEMI_STDIO_THRU_UART symbol: pe rs ed ed a. Right-click Cortex - M3 SRAM under SPI_Flash_MSS_CM3_hw_platform and click Options for SPI_Flash_MSS_Cm3_hw_platform - Target Cortex - M3 SRAM. Figure 25 • Target Options Su b. Go to C/C++ tab and enter MICROSEMI_STDIO_THRU_UART at Define under Preprocessor Symbols as shown in Figure 26 on page 23. c. Click OK. 22 R e visio n 1 rs ed ed Step 4: Building the Software Application Using Keil uVision 5 IDE Su pe Figure 26 • Target Options-Add Symbols Revision 1 23 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA pe rs ed ed 8. Right-click Cortex-CM3_SRAM under SPI_Flash_MSS_Cm3_hw_platform and select Build SPI_Flash_MSS_Cm3_hw_platform (Cortex-CM3 SRAM) as shown in Figure 27. Su Figure 27 • Build HW Platform Window 24 R e visio n 1 Step 4: Building the Software Application Using Keil uVision 5 IDE pe rs ed ed 9. Right-click SPI_Flash_MSS_CM3_app and select Set as Active Project. Su Figure 28 • Set as Active Project Revision 1 25 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA pe rs ed ed 10. Change SPI_Flash_MSS_CM3_app debug mode to Cortex-M3_SRAM by selecting CortexM3_SRAM from the drop-down menu as shown in Figure 29. Su Figure 29 • Cortex-M3_SRAM Settings 26 R e visio n 1 Step 4: Building the Software Application Using Keil uVision 5 IDE pe rs ed ed 11. Right-click Cortex-M3 SRAM under SPI_Flash_MSS_CM3_app and click Options for project. Su Figure 30 • Target Options Revision 1 27 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA rs ed ed 12. Click the Debug tab and browse the //SF2_SPI_Flash_Keil_Tutorial_DF/SourceFiles/ folder for initialization file provided as shown in Figure 31. Figure 31 • Target Options - Initialization File Su pe 13. Click the Utilities tab and uncheck Use Debug Driver and Update Target before Debugging check boxes. 28 R e visio n 1 Step 4: Building the Software Application Using Keil uVision 5 IDE rs ed ed 14. Select ULINK2/ME Cortex Debugger from the drop-down list and click OK as shown in Figure 32. Su pe Figure 32 • Target Options - Utilities Settings Revision 1 29 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA pe rs ed ed 15. Right-click Cortex-M3 SRAM under SPI_Flash_MSS_CM3_app and select Build SPI_Flash_MSS_CM3_app (Cortex-M3 SRAM) as shown in Figure 33. It compiles all of the source files and links the object files into an AXF file to debug. Make sure that there are no errors. Correct any syntax errors and rebuild if necessary. Figure 33 • Build Application Window Su Figure 34 shows the messages that are displayed in the console after the build. Figure 34 • Build Output 30 R e visio n 1 Step 5: Configuring Serial Terminal Emulation Program Step 5: Configuring Serial Terminal Emulation Program 1. Install the USB driver. For serial terminal communication through the FTDI mini USB cable, install the FTDI D2XX driver. Download the drivers and the installation guide from: www.microsemi.com/soc/documents/CDM_2.08.24_WHQL_Certified.zip. pe rs ed ed 2. Connect the host PC to the J24 connector using the USB Mini-B cable. The USB to UART bridge drivers are automatically detected. Of the four COM ports, select the one with Location as on USB Serial Converter D. Figure 35 shows an example Device Manager window. Figure 35 • Device Manager Window Su 3. Start the HyperTerminal session. If the HyperTerminal program is not available in the computer, any free serial terminal emulation program such as PuTTY or TeraTerm can be used. Refer to the Configuring Serial Terminal Emulation Programs Tutorial for configuring the HyperTerminal, TeraTerm, or PuTTY. The HyperTerminal settings are as follows: – 57,600 baud rate – 8 data bits – 1 stop bit – No parity – No flow control Revision 1 31 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Step 6: Connecting the ULINK-ME to the Board and PC This section describes the connection between the SmartFusion2 Development Kit board, ULINK-ME, and host PC. Use the appropriate settings for the board that is in use. 1. Connect Pin 2 and Pin 3 on the jumper J93 on the SmartFusion2 Development Kit board. 2. Connect the USB A-Mini B cable between the host PC and the SmartFusion2 Development Kit board. This is used to display the HyperTerminal communications. 3. Verify that the ULINK-ME debugger is connected to the SmartFusion2 Development Kit board RVI Header as shown in Figure 36 and also to the host PC through a USB A-Mini B cable. The ULINK-ME adapter has one LED that indicates connection status in the following ways: Blinking slowly indicates that ULINK-ME is ready to communicate with the debugger. – Blinking speedily indicates that the target board is executing the program under debugger control. – Remaining ON during debugging indicates that the debugger has halted the target board. – Remaining ON during download indicates that target download and verification is in progress. ed ed – Su pe rs 4. Switch ON the SW7 power supply switch. Figure 36 • ULINK-ME Connections 32 R e visio n 1 Step 6: Connecting the ULINK-ME to the Board and PC Su pe rs Figure 37 • ULINK-ME Debugger ed ed Refer to "Appendix A - Board Setup for Debugging from Keil uVision" on page 42 for information on the board setup for running the tutorial. Revision 1 33 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA Step 7: Debugging the Application Project using Keil uVision 5 Su pe rs ed ed 1. Select Start/Stop Debug Session from the Debug menu in the uVision window to run it through the debug hardware as shown in Figure 38. The processor code will be downloaded to the SmartFusion2 eSRAM. Figure 38 • Selecting Start/Stop Debug Session 34 R e visio n 1 Step 7: Debugging the Application Project using Keil uVision 5 pe rs ed ed The code will automatically 'run to main' and then stop as shown in Figure 39. Su Figure 39 • Debug Menu Revision 1 35 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA rs ed ed 2. Click Run from the Debug menu as shown in Figure 40. Su pe Figure 40 • Selecting Run from the Debug Menu 36 R e visio n 1 Step 7: Debugging the Application Project using Keil uVision 5 rs ed ed On successful operation, the HyperTerminal window displays a message as Read Data From Flash as shown in Figure 41. Su pe Figure 41 • HyperTerminal Window Revision 1 37 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA pe rs ed ed The Disassembly window is displayed in the middle of the Debug section as shown in Figure 42. If not, click the Disassembly icon to display the Disassembly section. Su Figure 42 • Disassembly Window 38 R e visio n 1 Step 7: Debugging the Application Project using Keil uVision 5 pe rs ed ed 3. Check the Registers section to view the values of the ARM® Cortex™-M3 processor internal registers. Su Figure 43 • Values of the Cortex-M3 Internal Registers Revision 1 39 Accessing Serial Flash Memory using SPI Interface - Libero SoC and Keil uVision Flow Tutorial for SmartFusion2 SoC FPGA pe rs ed ed 4. When debug process is finished, terminate execution of the code by choosing Debug > Start/Stop Debug Session as shown in Figure 44. Su Figure 44 • Keil uVision Workbench - Stop Debug Option 40 R e visio n 1 Conclusion pe rs ed ed 5. The Step Level Debugging can be performed before running the application using Run. These can be accessed from the Debug menu or on the Keil uVision workbench as shown in Figure 45: Figure 45 • Keil uVision Workbench - Step Level Debugging Source code can be single-stepped by selecting from the Debug menu Debug > Step, Debug > Step Over, Debug > Step Out or by selecting the respective options from the Keil uVision workbench as shown in Figure 45. Observe the changes in the source code window and Disassembly section. Performing a step over provides an option for stepping over functions. The entire function is run but there is no need to single-step through each instruction contained in the function. Su – – Select Debug > Step Out to exit the instruction in stepping mode. 6. Add breakpoints from the Debug menu in workbench to force the code to halt, start Debug session, and then single-step and observe the instruction sequence. 7. Close uVision using File > Exit. 8. Close the HyperTerminal using File > Exit. Conclusion This tutorial provides steps to create a Libero SoC software design using the System Builder. It describes how to build, debug, and run Keil uVision application. It also provides a simple design to access the SPI flash. Revision 1 41 Appendix A - Board Setup for Debugging from Keil uVision Su pe rs ed ed Figure 1 shows the board setup for debugging the Keil uVision on the SmartFusion2 Development Kit board. Figure 1 • SmartFusion2 Development Kit in Debug Mode using Keil uVision Revision 1 42 Appendix B - Board Setup for Programming the Tutorial pe rs ed ed Figure 1 shows the board setup for running the tutorial on the SmartFusion2 Development Kit board. Su Figure 1 • SmartFusion2 Development Kit in Programming Mode Revision 1 43 Appendix C- SmartFusion2 Development Kit Board Jumper Locations J1 R26 C7 R24 R23 R21 R22 D6 D5 R36 R56 DS11 PGOOD R52 R35 OFF C42 6 AT FLAG DS10 R55 C44 SC1 U15 R104 L5 C58 C61 SC2 C68 SC3 SC4 R123 R130 D11 U20 J44 C71 R131 R137 C74 R143 J80 1P0V_PHY 3 1 ON R102 R103 R100 R111 R112 R150 R151 R152 R157R153 R154 C78 C79 R158R155 R132 1 DS22 J103 U33 C84 GND T2 J112 1 R170 789 J132 Q18 DS25 J116 1 R185 R184 R27 R25 CONN1 C32 C33 R50 R80 R113 R81 R114 DS16 P1LED3 J31 DS17 P1LED2 R82 DS18 P1LED1 DS19 P1LED0 R83 DS12 P0LED3 DS13 P0LED2 DS14 P0LED1 DS15 P0LED0 J29 J67 R178 R179 R189 C105 U37 GND 123 L10 TXP0 TXN0 RXP0 RXN0 TXP2 TXN2 TXP1 TXN1 RXN1 RXP1 TXP3 TXN3 C119 C120 C121 C94 C95 R182 R183 1 A B C D E F G H J J142 1 J186 J182 J171 C134 J150 J148 J149 J169 J191 RXN2 RXP2 RXN3 RXP3 D14 J190 J189 J192 TP25 TS_MDIO J185 TS_MDC J170 R219 J156 J166 J168 U45 R220 R221 R243 R242 1 R247 R244 1P0V_PHY R238 R239 R240 R241 C152 C153 R278 R279 J147 J151 C128 C129 C130 C131 L13 J160 RS6 1 J167 1 C150 C151 R276 R277 4 HPOUTCLK5 R32 R46 R93 R94 C67 SW8 J82 U36 R662 R203 R204 R206 R207 R212 R217 C148 C149 R274 R275 POE PWR ENB J16 R30 J15 J14 C28 C29 R45 C76 C75 C73 C72 C69 C62 C60 C59 1 2 4 R149 R159 R160 Q24 R383 Q23 R381 R380 Q22 R382 Q21 Q25 Q26 Q27 1 DDR3_1P5V TP21 R354 R355 D18 R365 C204 R366 D20 TP20 J207 U61 D17 C200 C202 DVDD12 R375 D15 D16 R339 R346 TP12 U59 R338 C186 R350 TP24 C198 J220 J229 1 GND R325 U60 2P5V_LDO R326 C191 R353 LED8 LED7 R374 R364 LED5 R372 R362 LED6 R373 R363 LED4 R371 R361 LED2 R369 R359 J219 J228 Q20 J206 J205 SERDES1 REFCLK0_N J208 GND R356 C189 C91 C92 R312 POE CONN J10 C6 TP10 R29 J13 R47 R48 R49 R60 R61 1 3 R146 U23 4 J81 3 C146 R2 C147 66 R2 86 R282 R283 U56 1 R670 R230 J177 TP14 J211 LED1 R368 R358 Q15 C111 1 SF2 DEV KIT R367 R357 C173 3P3V_LDO J230 J152 DDR3_VTT R377 1 C70 T1 GND DVP-102-000400-001 REFCLK0_P RevC U55 1 C164 TP22 R376 R384 B14 R311 1 R385 J223 B11 J117 C159 U54 C184 GND C203 B1 C98 C100 C96 C103 C104 R680 R681 R678 R679 R677 R675 C172 3 TP7 PLLXVDDA 2 VPP 3 J233 J227 1 A B C D E F G H KJ L M N Q14 ON 1 R256 U51 C167 789 123 789 A B DC E F G H J K L M N J226 1 123 789 PLLMDDRVDDA 3 R187 123 A B DC E F G H J K L M N J225 J234 J130 R205 C125 Q19 R271 C155 R272 R249 R273 C142 R287 C160 R288 R319 R320 R317 R318 C177 C178 C182 R340 C192 R341 R342 1 R335 R336 C190 R337 R351 R344 R345 C195 2 1 C199 J222 R343 C196 R348 R349 R352 C201 1 J215 R290 R291 C187 J217 R295 R332 R296 R333R334 1 R299 R302 R303 R304 R305 R306 R307 R308 R309 R280 C162 C197 C193C194 J216 J203 R329 C188 C183 C185 R327 R328 R331 R330 U58 8 R289 C143 U53 J212 R322R314 R323 C181 R321 J204 1 C180 C176 GND U57 DB9-RS232 1 ANALOG INPUT J218 1 1 HDR-RS485 R347 C175 R315 R313 R316 C179 R324 1 R281 R226 R229 R231 R232 R234 R235 R236 R237 R267 R269 R268 GND_0 C54 7 7 U62 L15 C171 1 C174 U42 R270 C63 D10 1 2 20 J221 19 1 J193 C165 U52 R293 R300R294 C169C166 U50 TP26 VDDIO R292 C168 R298 R297 C170 R301 U48 A1 TP29 C51 J153 R218 RS5 A30 J224 U49 C145 R259 R260R250 R248 R255 C144 R264 C161 C163 J172 K23 J175 L26 J179 H26 J184 J29 J188 H30 J195 H28 J197 G29 J200 F30 J202 K25 J210 L23 J214 N23 1 L12 R213 R215 3 85 R2 5 R284 C141 R251 1 R97 TP13 SW10 65 R2 1 1 V2J21 M2 J20 M2J20 H2 J19G3 J196 H2J19 J2 J18 J3 J18 J2 J17 K2 J174 9 4 8 7 0 3 6 8 4 63 4 9 5 1 7 9 0 J157 C158 3 1 J128 ON U40 RS4 C37 R74 C48 R86 C77 R671 R181 R186 R188 J126 J127 J124 J125 C114 J139 P24 J141 N26 J144 M27 J146 L29 J155 L28 J159 K30 J162 J27 C40 C43 GND R166 R167 R168 Y3 R180 J123 RS3 LED3 R370 R360 3 3 3 AK1 R378 J173 J180 1 1 1 PCIEXVDD R379 3 L8 PLLFDDRVDDA R674 R673 R672 R676 AK30 R310 DS26 R190 D12 1 R202 J13 C110 C108 R193 DS27 C112 HVDD C117 C118 R200 R197 R199 C123 C124 TP27 TP28 R208 R209 R210 R211 U47 C137 1 L14 R261 C139 R262 R245 C154 R263 C126 C127 R222 J137 1 J138 P23 J140 N25 J143 N24 J145 M26 J154 L30 J158 K29 C133 J161 K28 1 J165 Su J198 C113 R227 C140 R246 R254 HVDD R252 R253 R257 R258 R233 J181 C156 C157 1 J176 4 3 C138 R192 HVSS U39 U38 J113 U46 2 J164 5 1 J163 1 R196 R198 D13 R216 HVSS R223 R225 C132 R224 U44 R228 1 C136 R214 C106 R194 1 CR4 P1 C135 J121 5 USB MICRO AB OTG Support 1 U43 CR3 R195 U41 R177 C38 4 R201 TP5 W28 R29 R24 C97 C101 C102 1 Y1 3 C115 C116 TP4 C107 C93 2 1 50 MHZ R28 D7 U10 R69 R70 R73 R78 C46 J49 A14 P14 C80 L7 R175 R176 20 10 pe R172 R173 J105 12 J4 C39 Q13 P3LED2 TC2 P3LED3 TC1 TC4 P3LED1 J32 P3LED0 TC3 TC6 P2LED3 P2LED2 TC5 TC7 P2LED0 R121 A1 3 Y2 J104 TP3 C99 U19 R59 TP30 GND_C 2 L11 C122 R191 J115 AA29 J119 Y30 J122 M23 J131 T27 J134 T26 J135 V23 J232 U24 GND 1 C109 - - 6 6 U34 L9 1 C66 J70 4 3 J111 V24 R85 P1 REFCLK0_P REFCLK0_N SERDES0 C85 C86 C87 C88 C89 C90 1J106 U22 A12 J30 1 1 R117 R118 R119 R122 R125 R126 R127 R129 R133 R135 R136 R138 R139 R141 R144 R145 R76 SW6 R58 L4 R64 R161 R162 1 1 2 U27 SW9 R663 JTAG SEL C81 C82 U28 ZL RST J54 R148 LED9 RST LED J59 U25 J94 1 1 R174 J120 1 J19 J26 GND J37 J38 J43 J55 1 J93 RESET 1 3 J11 R14 J12 SW1 R53 R54 R39 SW4 R38 U8 J28 1 rs J99 J102 J101 J100 C83 1 V22 J110 AA28 J114 W27 J118 TP8 DS24 FP4 HEADER R147 RS2 J91 J88 J60 J98 J66 R171 9 J79 U32 J83 J92 R165 GND 1 R664 REMOTE PWR ENB DS23 1 U69 1 U31 J78 J84 J89 J90 TP11 J231 J34 J75 U26 J42 R169 1 U35 J61 J95 1 J109 R164 J40 J53 J69 J64 R163 U29 J77 J87 Q17 2 J63 1 J76 J71 M12 GND R134 10 17 1 J74 GND 7 20 5 J62 J68 R156 J73 1 19 R128 GND 10 J58 R142 J86 J97 J85 9 1 U30 U24 J96 J65 2 1 R140 J57 J56 J48 J41 J39 L6 U21 X1 J45 20 J51 2 19 J50 3 1 J72 1 DB9-CAN2 U12 J27 C55 C64 C65 1 1 U18 J47 1 5 20 R115 J107 J108 R120 U17 DS21 GND J46 SFP CONN A1 R62 R65 R66 R68 R71 R72 R75 R77 R79 R84 REFP6 ETM HEADER RS1 J35 R51 U9 R67 C49R87 J33 C50R88 R89 R90 R106 R107 R108 R109 R110 R95 C52 R91 C53 R92 D8 R98 U11 R105 D9 C56 DB9-CAN1 R116 2 1 5 DS20 J6 SW2 SW5 R13 C35 R44 J18 1 C47 1.2V VDD_REG J36 R124 J52 REFP5 TP15 R101 TP19 C57 J20 3 J21 3 J22 3 J25 3 RVI HEADER U14 U13 1 J23 C45 3P3V_LDO U16 R63 Q12 TP2 J17 M1 C34 12 J5 Q10 J7 U7 5 1.0V CR2 FTDI INTERFACE R96 J24 1 6 17 C20 U4 C27 R37 R33 C25 C26 C23 C24 R41 C30 R42 C31 R43 3 CR1 1 7 C694 1 1 SW7 C41 1 C21 R57 ON USB MINI B TP1 SW3 C17 C18 U5 R99 Q11 C10 C13 C19 C16 L3 R34 4 J9 1 GND 10 C22 1 HPDIFFN4 HPDIFFP4 FMC HEADER C14 C15 2P5V 1 R40 Q8 J8 1 R31 D1 R17 R18 R19 R20 C12 6 ed ed DS7 DS8 DS9 3P3V 5P0V C1 R10 R9 3P3V J3 C3 C4 U6 3 Q7 1 C693 D3 R15 D2 D4 C682 R16 L2 1P8V OFF FMC HEADER L1 TP17 TP23 TP18 DC JACK12V/6A A1 A40 7 1 7 C11 C9 1 K1 12P0V DS4 DS5 DS6 VDD_REG R4 2P5V_LDO R5 2P5V U1 R12 R11 C2 R669 U3 C8 R6 Q5 GND R7 R8 5P0V TP16 Q6 Q4 DS3 R3 3P3V_LDO R1 1P8V R2 DDR3-1P5V DS2 Q1 Q2 Q3 12V 12V_POE 12V_PCIE R668 C36 C683 R660 TP9 U2 12_DCJACK Q9 K40 1 J2 1 DS1 Figure 1 shows the jumper locations on the SmartFusion2 Development Kit board. D19 C205 B49 Figure 1 • SmartFusion2 Development Kit Board Jumper Locations Note: • Jumpers highlighted in red are set by default. • Jumpers highlighted in green to be set manually. • The location of the jumpers in Figure 1 are searchable. Revision 1 44 Product Support Microsemi SoC Products Group backs its products with various support services, including Customer Service, Customer Technical Support Center, a website, electronic mail, and worldwide sales offices. This appendix contains information about contacting Microsemi SoC Products Group and using these support services. Customer Service ed ed Contact Customer Service for non-technical product support, such as product pricing, product upgrades, update information, order status, and authorization. From North America, call 800.262.1060 From the rest of the world, call 650.318.4460 Fax, from anywhere in the world, 408.643.6913 Customer Technical Support Center rs Microsemi SoC Products Group staffs its Customer Technical Support Center with highly skilled engineers who can help answer your hardware, software, and design questions about Microsemi SoC Products. The Customer Technical Support Center spends a great deal of time creating application notes, answers to common design cycle questions, documentation of known issues, and various FAQs. So, before you contact us, please visit our online resources. It is very likely we have already answered your questions. Technical Support pe Visit the Customer Support website (www.microsemi.com/soc/support/search/default.aspx) for more information and support. Many answers available on the searchable web resource include diagrams, illustrations, and links to other resources on the website. Website Su You can browse a variety of technical and non-technical information on the SoC home page, at www.microsemi.com/soc. Contacting the Customer Technical Support Center Highly skilled engineers staff the Technical Support Center. The Technical Support Center can be contacted by email or through the Microsemi SoC Products Group website. Email You can communicate your technical questions to our email address and receive answers back by email, fax, or phone. Also, if you have design problems, you can email your design files to receive assistance. We constantly monitor the email account throughout the day. When sending your request to us, please be sure to include your full name, company name, and your contact information for efficient processing of your request. The technical support email address is [email protected]. Revision 1 45 Product Support My Cases Microsemi SoC Products Group customers may submit and track technical cases online by going to My Cases. Outside the U.S. Customers needing assistance outside the US time zones can either contact technical support via email ([email protected]) or contact a local sales office. Sales office listings can be found at www.microsemi.com/soc/company/contact/default.aspx. ITAR Technical Support Su pe rs ed ed For technical support on RH and RT FPGAs that are regulated by International Traffic in Arms Regulations (ITAR), contact us via [email protected]. Alternatively, within My Cases, select Yes in the ITAR drop-down list. For a complete list of ITAR-regulated Microsemi FPGAs, visit the ITAR web page. 46 R e visio n 1 ed ed rs pe Su Microsemi Corporate Headquarters One Enterprise, Aliso Viejo CA 92656 USA Within the USA: +1 (800) 713-4113 Outside the USA: +1 (949) 380-6100 Sales: +1 (949) 380-6136 Fax: +1 (949) 215-4996 E-mail: [email protected] Microsemi Corporation (Nasdaq: MSCC) offers a comprehensive portfolio of semiconductor and system solutions for communications, defense and security, aerospace, and industrial markets. Products include high-performance and radiation-hardened analog mixed-signal integrated circuits, FPGAs, SoCs, and ASICs; power management products; timing and synchronization devices and precise time solutions, setting the world's standard for time; voice processing devices; RF solutions; discrete components; security technologies and scalable anti-tamper products; Power-over-Ethernet ICs and midspans; as well as custom design capabilities and services. Microsemi is headquartered in Aliso Viejo, Calif. and has approximately 3,400 employees globally. Learn more at www.microsemi.com. © 2014 Microsemi Corporation. All rights reserved. Microsemi and the Microsemi logo are trademarks of Microsemi Corporation. All other trademarks and service marks are the property of their respective owners. 50200548-1/04.14