Lab4 Writing Basic Software Applications Lab: MicroBlaze

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Copyright © 2005 Rockwell Automation, Inc. All rights reserved. 1 Micro Logix 1100 RSLogix 500 LAB#2 Timing, Counting & Comparing.
1 Lab 3 Objectives  Case study: “Hello world” program on motes  Write you first program on mote.
The Xilinx EDK Toolset: Xilinx Platform Studio (XPS) Building a base system platform.
Using PDG with e2studio: Example
ECE Department: University of Massachusetts, Amherst Lab 1: Introduction to NIOS II Hardware Development.
Guide To UNIX Using Linux Third Edition
Lab4 Writing Basic Software Applications Lab: MicroBlaze.
Lab5 Advanced Software Writing Lab : MicroBlaze. for EDK 6.3i1 Objectives Utilize the OPB timer. Assign an interrupt handler to the OBP timer. Develop.
Part 1 Using the ARM board And start working with C Tutorial 5 and 6
Chapter 2 Software Tools and Assembly Language Syntax.
Silicon Labs ToolStick Development Platform
Renesas Technology America Inc. 1 M16C/Tiny SKP Tutorial 2 Creating A New Project Using HEW4.
© 2003 Xilinx, Inc. All Rights Reserved Address Management.
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
© 2004 Xilinx, Inc. All Rights Reserved EDK Overview.
This material exempt per Department of Commerce license exception TSU Writing Basic Software Applications Lab 4 Introduction.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
Active-HDL Interfaces Debugging C Code Course 10.
Active-HDL Interfaces Building VHPI Applications C Compilation Course 9.
Objective At the conclusion of this chapter you will be able to:
LAB1 Summary Zhaofeng SJTU.SOME. Embedded Software Tools CPU Logic Design Tools I/O FPGA Memory Logic Design Tools FPGA + Memory + IP + High Speed IO.
© 2004 Xilinx, Inc. All Rights Reserved Embedded Processor Design.
Assembly Language for x86 Processors 7th Edition Chapter 13: High-Level Language Interface (c) Pearson Education, All rights reserved. You may modify.
Renesas Technology America Inc. 1 M16C Seminars Lab 3 Creating Projects Using HEW4 14 March 2005 M16C Seminars Lab 3 Creating Projects Using HEW4 Last.
© 2004 Xilinx, Inc. All Rights Reserved Adding a Processor System to an FPGA Design.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
1 How to Install OpenGL u Software running under Microsoft Windows makes extensive use of "dynamic link libraries." A dynamic link library (DLL) is a set.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
XP New Perspectives on Creating Web Pages With Word Tutorial 1 1 Creating Web Pages With Word Tutorial 1.
A+ Guide to Managing and Maintaining Your PC, 7e Chapter 2 Introducing Operating Systems.
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
Workshop Setup The software/hardware used in this workshop are:
Programming and Debugging with the Dragon and JTAG
Arria 10 External Memory Interface Example Design Guidelines
Lab 1: Using NIOS II processor for code execution on FPGA
Working in the Forms Developer Environment
Practical Office 2007 Chapter 10
TDA Direct Certification
Chapter 2 – Introduction to the Visual Studio .NET IDE
Objectives Identify the built-in data types in C++
Incorporating Databases with ADO.NET
Computer Organization & Assembly Language Chapter 3
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
My First Nios II for Altera DE2-115 Board
Incorporating Databases with ADO.NET
Chapter 1: Introduction to Computers and Programming
MicroEconomix 1500 RSLogix 500 LAB#2
MicroEconomix 1500 RSLogix 500 LAB#1
NORMA Lab. 7 Generating Reports More Display Options
Chapter 2 – Introduction to the Visual Studio .NET IDE
Lab2 Adding IP to a Hardware Design Lab: MicroBlaze
Lab6 HW/SW System Debug Lab : MicroBlaze
CIS16 Application Development Programming with Visual Basic
Stratix 10 External Memory Interface Example Design Guidelines
Lab 1 Introduction to C++.
Lab3 Adding Custom IP Lab: MicroBlaze
Founded in Silicon Valley in 1984
Accessing Databases with ADO.NET, Handling Exceptions, and Printing
Software Setup & Validation
How to Execute TSR Program
Using Eclipse.
How to Execute TSR Program
Java Code Review with CheckStyle
ECE 3567 Microcontrollers Lab
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Lab4 Writing Basic Software Applications Lab: MicroBlaze

Objectives Write a basic application to access an IP peripheral. Utilize XPS to generate a MSS file. Generate a bit file. Download the bit file and verify in hardware. Develop a simple linker script. for EDK 6.3i

Procedure The first three labs defined the hardware for the processor system. This lab comprises several steps, including the writing of a basic software application to access one of the peripherals specified in Lab2. Below each general instruction for a given procedure, you will find accompanying step-by-step directions and illustrated figures providing more detail for performing the general instruction. for EDK 6.3i

Opening the Project Create a lab4 folder in the X:\EDKLab\ directory. If you wish to continue with your completed design from lab3 then copy the contents of the lab3 folder into the lab4 folder. 1. 2. 3. 4. for EDK 6.3i

Opening the Project Open XPS, click File → Open Project and browse to the project which is in the directory: X:\EDKLab\lab4, then click system.xmp to open the project. 1. 2. for EDK 6.3i

Creating a BSP Double-click microblaze_0 from the System BSP hierarchy, as shown in following Figure. You can also open the same dialog box by clicking Project  Software Platform Settings. for EDK 6.3i

Creating a BSP This will open the Software Platform Settings dialog with the Software Platform tab. In the Software Platform tab, the Driver can be selected for each of the peripherals in the system. You can also select the Kernel and Operating Systems for each of the processor instances. In addition, supporting libraries can be selected if they will be used. for EDK 6.3i

Creating a BSP Click on the Processor and Driver Parameters tab and specify the following parameters: Processor Parameters: Compiler – mb-gcc Archiver – mb-ar EXTRA_COMPILER_FLAGS – -g xmdstub_peripheral – none CORE_CLOCK_FREQ_HZ – 100000000 Driver Parameters: Leave Blank for EDK 6.3i

Creating a BSP Click the Library/OS Parameters tab. Click the Current Value field for stdin and select RS232. Similarly, click the Current Value field for stdout and select RS232. This will assign the uart device as the stdin and stdout. Base System Builder already set these when the RS232 peripheral was included. If a system does not have any stdin/stdout devices, then keep the current value as None. Leave the Current Value for need_xil_malloc as false because your application does not use any malloc function call. Click 確定 to accept the settings. for EDK 6.3i

Generate the BSP Double-click the system.mss file under the System tab in XPS, as shown in following Figure. for EDK 6.3i

Generate the BSP This will open the MSS file for this project. XPS has written the parameters that are specified in the Peripheral Options to the system.mss file. Close the system.mss file. for EDK 6.3i

Generate the BSP Generate the BSP by clicking Tools  Generate Libraries or click the button. This will run LibGen on the system.mss file to generate the BSP library files. for EDK 6.3i

Creating a Basic C File In the Applications Tab double Click on Software Projects. This will open a dialog box to create a new project. Enter the name MyProj and click OK. 1. 2. for EDK 6.3i

Creating a Basic C File Click File  New. This will open a dialog box to create a new project and open a new document in the XPS editor. for EDK 6.3i

Creating a Basic C File The first step is to add the header files for the required functions. All of the header files related to this project were placed in the …\microblaze_0\include directory when LibGen was run. Add the following to the C file: #include "xparameters.h" #include "xgpio.h“ for EDK 6.3i

Creating a Basic C File Click File  Save As, this will open the Save As dialog. Create a new directory named code in the lab4mb directory and save the file as system.c, as shown in following Figure. 1. 2. 3. for EDK 6.3i

Creating a Basic C File Add the following to the C file. main() { The first step in main is to initialize the GPIO peripheral. for EDK 6.3i

Creating a Basic C File From the Windows start menu Click 開始  程式集  Xilinx Platform Studio 6.3i  Documentation  EDK 6.3i Reference & User Guides. Scroll down and click Driver Reference Guide. 1. 2. for EDK 6.3i

Creating a Basic C File Scroll down and click Driver API Links. Scroll down and click 2.00.a of the gpio. This will open the Xilinx Processor IP Library to gpio v2_00_a. 1. 2. for EDK 6.3i

Creating a Basic C File Click Globals to view list of all documented functions, variables, defines, enums, and typedefs with links to the documentation. Click xgpio.c of XGpio_Initialize(). 1. 2. for EDK 6.3i

Creating a Basic C File This documentation contains a detailed description of the XGpio_Initialize function. The documentation outlines two parameters that XGpio_Initialize requires: InstancePtr is a pointer to an XGpio instance. The memory the pointer references must be pre-allocated by the caller. Further calls to manipulate the component through the XGpio API must be made with this pointer. DeviceId is the unique id of the device controlled by this XGpio component. Passing in a device id associates the generic XGpio instance to a specific device, as chosen by the caller or application developer. for EDK 6.3i

Creating a Basic C File Define an XGpio type variable named gp_out. This variable will be used as the first parameter in the Xgpio_Initialize function call. Add the variable to the function call. It should now look like the following: XGpio_Initialize(&gp_out, The second parameter is the device ID for the device that you want to initialize. This information can be found in the xparameters.h file. for EDK 6.3i

Creating a Basic C File Under the System BSP microblaze_0 instance, double-click the Generated Header: microblaze_0/include/xparameters.h entry, as shown in following Figure. for EDK 6.3i

Creating a Basic C File LibGen writes the xparameters.h file, and the file provides critical information for driver function calls. This function call initializes the GPIO that is used as an output for the LEDs found on the board. In the xparameters.h file, find the following #define used to identify the LEDS_1BIT peripheral: #define XPAR_LEDS_1BIT_DEVICE_ID 1 for EDK 6.3i

Creating a Basic C File This #define can be used as the device ID in the function call. Add the device ID to the function call so that it looks like the following: XGpio gp_out; XGpio_Initialize(&gp_out, XPAR_LEDS_1BIT_DEVICE_ID); The file should now look like following Figure. for EDK 6.3i

Creating a Basic C File Refer to the documentation to determine how to set all of the bits of the GPIO bus as outputs. This will involve using the XGpio_SetDataDirection function call. Add code to perform this function, and then save the file. XGpio_SetDataDirection (&gp_out, 1, 0x0); for EDK 6.3i

Creating a Basic C File Write code to implement a counter that continuously counts from 0 to 1(Only 1 led on the board). The count will be used to drive the output of the LEDs_1Bit peripheral. The following code is provided as an example: Int j=0; while (1) { j = (j+1) % 2; } You will also need to include the declaration of the variable j. Output the current value of j to the LEDs_1Bit. Using the information in the gpio.h documentation, the function XGpio_DiscreteWrite() will be used. XGpio_DiscreteWrite (&gp_out, 1, j); for EDK 6.3i

Creating a Basic C File Because the MicroBlaze™ processor does not have an internal timer or counter, a delay loop must be created in the software. Add the following code to create a software delay to pause between each count that gets displayed: int i=0; for (i=0; i<10; i++); Save and close the file. for EDK 6.3i

Compile the source code Click the Application tab to view the current project’s Compiler Options and Sources. Right-click Project: TestApp and unselect Mark to Initialize BRAMs. Verify that the small green arrow next to Project: MyProj does not have a red x through it. If it does, Right-click Project: MyProj and toggle Mark to Initialize BRAMs. 1. 2. for EDK 6.3i

Compile the source code Right-click Sources under Project: MyProj and select Add File. Browse to the code directory under the current project (lab4) and select the system.c file. 2. 1. 3. for EDK 6.3i

Compile the source code Double-click Compiler Options under Project: MyProj in the Application tab. Click the Directories tab to set the directory options. Change the Output ELF File entry to place the executable.elf file in the microblaze_0\code directory under the current project directory. For Linker Script Browse to the TestAppLinkScr file in the TestApp\Src directory. The directory options should be set as shown in following Figure. Click 確定 to accept the setting. for EDK 6.3i

Compile the source code Compile the C code by clicking the button. After the program has compiled determine the sizes of the program sections. for EDK 6.3i

Linker Script Start a Xygwin shell by clicking the button. This should place you in the project directory. Change the directory to …\lab4\microblaze_0\code by using the cd command. Type mb-objdump –h executable.elf at the prompt in the Xygwin shell window to list various sections of the program, along with the starting address and size of each section. for EDK 6.3i

Linker Script There are many sections are listed in the output. for EDK 6.3i

Linker Script In XPS, double-click the TestAppLinkScr file under Compiler Options in the Applications tab. for EDK 6.3i

Linker Script Change the stack size to 0x100. Save the linker script, then recompile the program. for EDK 6.3i

Linker Script Execute the mb-objdump command in the Xygwin shell. for EDK 6.3i

Linker Script Change the linker script file to include a heap definition of 256 bytes near the top of the linker script as shown below. To do this, double click on the Linker Script under Project: MyProj as follows: Add the _HEAP_SIZE definition near the top as shown below: _HEAP_SIZE = 256; /* heap size definition */ for EDK 6.3i

Linker Script Add the three lines shown below to the .bss_stack section of the linker script as shown below. . += _HEAP_SIZE; . = ALIGN(16); _heap_end = .; Save the linker script, then recompile the program. for EDK 6.3i

Linker Script Execute the mb-objdump command in the Xygwin shell. for EDK 6.3i

Linker Script Edit the system.c file to define a local variable, k, initialized with a value of 0, and increment it by 1 inside the for loop. Change the system.c file to define a local variable and increment it in the for loop. The code should look like the following: int k=0; k = k + 1; Save the system.c file, then recompile the code. for EDK 6.3i

Linker Script Execute the mb-objdump command in the Xygwin shell. for EDK 6.3i

Linker Script Edit the system.c file to add a statement that will output the value of the variable k to the LEDs. Change the system.c file to add a statement that outputs the value of variable k to the LEDs. The code should look like the following: XGpio_DiscreteWrite (&gp_out, 1, k); Save the system.c file, then recompile the code. for EDK 6.3i

Linker Script Execute the mb-objdump command in the Xygwin shell. for EDK 6.3i

Verifying in Hardware In the source code file, comment out all lines which refer to variable k. Change i<10 to i<4000000 in the for loop and save the file. Recompile the source file. for EDK 6.3i

Verifying in Hardware Click Tools  Update Bitstream and implement and generate the BIT file. Download the generated bit file by clicking Tools  Download. After the board is programmed, you will see that the LEDs are turning ON and OFF in the desired sequence. for EDK 6.3i

Conclusion XPS can be used to define, develop, and integrate the software components of the embedded system. A device driver interface can be defined for each of the peripherals and the processor. XPS creates an MSS file that represents the software side of the processor system. for EDK 6.3i

Conclusion (cont’d) The peripheral-specific functional software can be developed and compiled. The executable file can be generated from the compiled object codes and libraries. The linker script can be edited to control placement of various code segments into target memory. for EDK 6.3i