WARP Project Forums - Wireless Open-Access Research Platform

You are not logged in.

#1 2007-Apr-30 20:42:26

terrysu
Member
Registered: 2007-Apr-26
Posts: 7

How to make custom driver work for OPB model

I create a simple counter and convert it to opb.
I wrote the basic driver for this IP core based on the xilinx built in opb timer driver, the xmctrc.c xmctrc.h and other associated files.

Then I add the IP core to InterruptRef_xps_8_2 design project, andI have CIRQctr.c CIRQctr_intc.c and CIRQctr.h in both "ppc405_0\libsrc\CIRQ_opbw" and "ppc405_0\lib\include" folder. But after I include the "CIRQctr.h" file in main interruptTest.c file, I cannot call functions that I have written in CIRQctr.c and defined in CIRQctr.h.

Error message is like these:

/cygdrive/c/DOCUME~1/PRETEN~1/LOCALS~1/Temp/cc0QiiGi.o(.text+0x2b8): In function `main':
: undefined reference to `CIRQCtr_Initialize'
/cygdrive/c/DOCUME~1/PRETEN~1/LOCALS~1/Temp/cc0QiiGi.o(.text+0x2c8): In function `main':
: undefined reference to `CIRQCtr_SetHandler'
collect2: ld returned 1 exit status
make: *** [interruptTestrBeta/executable.elf] Error 1

if I tried to use function CIRQCtr_Initialize and CIRQCtr_SetHandler in main code.

I had to copy the code for both function above into main code from the CIRQctr.c and CIRQctr_intc.c file to make it work.

Is this a problem due to EDK not recognizing the .c driver file for the module?
But it's strange as .h file is read correctly by the main code, but gets stuck as soon as I tried to call function defined in my driver files.

Offline

 

#2 2007-Apr-30 21:33:58

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: How to make custom driver work for OPB model

You don't want to put custom code in the ppc405_0 directory; the contents of this directory get re-created every time you rebuild software for a project.

Peripherals are composed of both hardware and software. The hardware component goes in /pcores; the software goes in /drivers. By default, XPS projects don't have a /drivers/ folder, since the tools find the necessary drivers in the EDK_User_Repository and C:/EDK/sw/. If you create a custom peripheral, you should create a /drivers/ folder and put your core's software there.

Peripheral drivers have a similar structure to pcores, including XPS-specific files which describe the code and peripherals which the driver supports. All of this is detailed in the EDK's Platform Specification Format Reference Manual (look at the MDD file entry).

If you generate a core with sysgen2opb, a driver is created automatically in the sysgen netlist folder (look for /drivers/ at the same level as the /pcores/ folder). Just copy this folder into your XPS project folder, so that you have:

<project_root>\
   pcores\<your_core>
   drivers\<your_core>

By default, sysgen2opb only creates a header file in the driver's /src/ directory. This file contains #define statements for the address offset of each register in the design, plus macros for reading and writing each register. If you want a more sophisticated driver, you need to add C/H files to the driver src folder.

If you add .c files, you will need to modify the Makefile to instruct the compiler to process these files when it builds libraries for your project. Look at the Makefile for our OFDM core for an example of how to include C and H files in a driver.

Also, XPS doesn't recognize changes to driver source code when you update the bitstream. If you change driver source code, you have to choose Software->Clean Libraries in XPS, then update the bitstream.

Offline

 

#3 2007-May-01 02:54:46

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: How to make custom driver work for OPB model

I forgot to add that after creating a driver for your core (or copying in the one from sysgen2opb), you need to associate the driver with the instance of the pcore in your project. You can do this via the Software Platform Settings dialog box (Software->Software Platform Settings, click on Drivers) or by editing the MSS file by hand.

Offline

 

#4 2007-May-02 16:35:31

terrysu
Member
Registered: 2007-Apr-26
Posts: 7

Re: How to make custom driver work for OPB model

Thanks Murph.

However, after I compile and verify some of the functions I wrote in the driver file.

I cannot see the Interrupt Handler in Software platform setting for my IPCore that I have created. I have modified the MPD file for the interrupt port, connect it to INTC as well as in my main test code. I re-generate the linker script and bit-stream, but still cannot see it.

Is there anything specific I should write in .MCC files. I check the OFDM model project. There is version 1.01 in the description and I can see that from the Software->Software Platform Settings->Drivers windows too. Would that make a different and how do I add that to my driver?

Offline

 

#5 2007-May-02 19:55:53

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: How to make custom driver work for OPB model

You can specify interrupt handler properties in a driver's MDD file. Admittedly, this is a feature we haven't used yet (it's not part of our OFDM or OFDM_timer drivers yet). But if you look at the gpio driver's MDD file (in <EDK_root>\sw\XilinxProcessorIPLib\drivers\gpio_v2_00_a\data\) as an example, you'll find a block like this:

Code:

 BEGIN ARRAY interrupt_handler
   PROPERTY desc = "Interrupt Handler Information";
   PROPERTY size = 1, permit = none;
   PARAM name = int_handler, default = XNullHandler, desc = "Name of Interrupt Handler", type = string;
   PARAM name = int_port, default = IP2INTC_Irpt, desc = "Interrupt pin associated with the interrupt handler", permit = none;
 END ARRAY

The syntax for this code and another example of the interrupt_handler array are in the EDK's Platform Specification Format Reference Manual (see pg 100 for the example).

If you add a block like this to your custom core's MDD file and re-scan the repository, I'd bet it shows up in the interrupt handlers section of the Software Platform Settings dialog.

Offline

 

Board footer