UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer dsatyamu
Observer
959 Views
Registered: ‎05-29-2018

base address on a linux project through Xilinx SDK

I created my own IP(Adder) on Xilinx Vivado and exported the hardware and created Boot.bin using Petalinux.

 

I exported bitstream onto Xilinx SDK and created an application to be run on Linux.

 

Now, I want to understand how to target the BaseAddress of my Adder IP?

I can see the base address information only on system.hdf file.

 

 

I know that if we create application to be run on Standalone OS, it generates the include files like xparameters.h which can then be used to target addresses using the functions XIL_IN32 and XIL_OUT32 and so on.

 

How to target specific address locations while we create applications(using Xilinx SDK) to be run on linux?

 

Your responses are highly valuable!

0 Kudos
4 Replies
Observer dsatyamu
Observer
907 Views
Registered: ‎05-29-2018

Re: base address on a linux project through Xilinx SDK

I created an adderIP.c simple project below but end up getting segementation fault.

Can you please let me know what is the issue and how I can fix it?

 

Adder Code:

/*

 * adder_ip.c

 *

 *  Created on: Jul 22, 2018

 *      Author: dsatyamu

 */

 

 

#include <stdio.h>

 

#include <stdlib.h>

#include <errno.h>

#include <fcntl.h>

#include <sys/mman.h>

#include <errno.h>

#include <stdint.h>

 

 

#define ADDER_IP_ADDR    0xa0000000

 

int adder;

 

static volatile uint32_t *adderIP;

 

static int fd = -1;

 

int mmap_init() {

 

        if(fd != -1) return 0;

 

        if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0) {

                printf("Unable to open /dev/mem: %s\n", (char *)strerror(errno));

                return -1;

        }

        return 0;

}

unsigned int *memory_map(int paddr) {

 

        unsigned int *vaddr;

        if(fd == -1) mmap_init();

 

        vaddr = (uint32_t *)mmap(0, 0x400, PROT_READ|PROT_WRITE, MAP_SHARED, fd, paddr);

        if (vaddr == MAP_FAILED){

                printf("Mmap failed on physical address %x: %s\n", paddr, (char *)strerror(errno));

                return ((unsigned int *)-1);

        }

 

        return vaddr;

}

 

int main(void) {

 

printf("In main function\n");

    mmap_init();

    adderIP = memory_map(ADDER_IP_ADDR); 

}

 

 

 

Segmentation fault:

 

root@xilinx-zcu102-2017_4:~/BOOT# ./adder_722_t2.elf
In main function
[ 75.458528] adder_722_t2.el[2328]: unhandled level 1 translation fault (11) at 0xffffffa27e2608, esr 0x92000005
[ 75.470023] pgd = ffffffc876ca6000
[ 75.473401] [ffffffa27e2608] *pgd=0000000877783003[ 75.478001] , *pud=0000000877783003
, *pmd=0000000877780003[ 75.483467] , *pte=0020000877926fd3
[ 75.486934]
[ 75.488415]
[ 75.489889] CPU: 2 PID: 2328 Comm: adder_722_t2.el Tainted: G O 4.9.0-xilinx-v2017.4 #1
[ 75.499006] Hardware name: ZynqMP ZCU102 Rev1.0 (DT)
[ 75.503954] task: ffffffc87af32480 task.stack: ffffffc877268000
[ 75.509861] PC is at 0x7fa2743090
[ 75.513155] LR is at 0x7fa2712658
[ 75.516456] pc : [<0000007fa2743090>] lr : [<0000007fa2712658>] pstate: 80000000
[ 75.523832] sp : 0000007ffe1a54c0
[ 75.527127] x29: 0000007ffe1a54e0 x28: 000000000000002a
[ 75.532422] x27: 0000007ffe1a5b90 x26: 00000000ffffffd0
[ 75.537717] x25: 0000007fa280c488 x24: 0000000000000001
[ 75.543012] x23: 0000000000000073 x22: 0000007fa27dc9b0
[ 75.548308] x21: 00000000ffffffd8 x20: 0000000000000000
[ 75.553603] x19: ffffffffa27e2608 x18: 0000000000040900
[ 75.558898] x17: 0000000000410c48 x16: 0000007fa2717bb0
[ 75.564194] x15: 0000000000000252 x14: 00000000000003f3
[ 75.569489] x13: 0000000000000000 x12: 0101010101010101
[ 75.574784] x11: 0000000000000020 x10: 0101010101010101
[ 75.580080] x9 : 0000007ffe1a5b90 x8 : 0101010101010101
[ 75.585375] x7 : 206c616369737968 x6 : 0000007ffe1a5a80
[ 75.590671] x5 : 00000000ffffffff x4 : 0000000000000608
[ 75.595966] x3 : 0000007ffe1a5b60 x2 : 0000000000000020
[ 75.601261] x1 : 000000000040099d x0 : ffffffffa27e2608
[ 75.606556]
Segmentation fault
root@xilinx-zcu102-2017_4:~/BOOT#

 

0 Kudos
Moderator
Moderator
896 Views
Registered: ‎09-12-2007

Re: base address on a linux project through Xilinx SDK

Can you debug this in the SDK debugger to see where this is failing?

http://www.wiki.xilinx.com/How+to+debug+Linux+Application+in+SDK+2017.4

 

There is also example code there to try

0 Kudos
Observer dsatyamu
Observer
859 Views
Registered: ‎05-29-2018

Re: base address on a linux project through Xilinx SDK

Not yet. Trying with SDK debugger today. I will update the post.
I was trying few other things.
0 Kudos
Highlighted
Observer anujvaishnav
Observer
378 Views
Registered: ‎11-06-2017

Re: base address on a linux project through Xilinx SDK

Based on my past experience 'address translation fault of level 1' takes place if an int* is converted to unsigned int and then back into int* as Vivado hls has 32 address hardcoded into driver. This should not affect our driver but it seems the petalinux compiler cannot handle this gracefully.
If you code has any such casts I would suggest try changing/removing them and see what happens.

0 Kudos