Linux freezes on access to lwhps2fpga bridge

Hello everybody,
Im trying to access peripherals behind lwhps2fpga bridge. I have the standard devicetree entry. The bridges are registered at boot up. In /sys/class... they seem to be enabled. Im using the following code:

#define HW_REGS_BASE ( 0xff200000 )
#define HW_REGS_SPAN ( 0x00040000 )
#define HW_REGS_MASK ( HW_REGS_SPAN - 1 )
#define LED_PIO_BASE ( 0x00010040 )

int main(void)
{
uint32_t *h2p_lw_led_addr=NULL;
void *virtual_base;
int fd;

printf("---g49-hps2fpga---\n");

// Open /dev/mem
if( ( fd = open( “/dev/mem”, ( O_RDWR | O_SYNC ) ) ) == -1 ) {
printf( “ERROR: could not open “/dev/mem”…\n” );
return( 1 );
}

printf("/dev/mem is open\n");

// get virtual addr that maps to physical
virtual_base = (uint32_t *)mmap( NULL, HW_REGS_SPAN, ( PROT_READ | PROT_WRITE ),MAP_SHARED, fd, HW_REGS_BASE );
if( virtual_base == MAP_FAILED ) {
printf( “ERROR: mmap() failed…\n” );
close( fd );
return(1);
}

printf("base is mapped\n");

// Get the address that maps to the LEDs
h2p_lw_led_addr=(uint32_t *)(virtual_base + LED_PIO_BASE);

printf("got address %08x\n",h2p_lw_led_addr);

// Add 1 to the PIO register

!!!When I uncomment one of the two following lines Linux freezes

// printf(“reading: %08x\n”,*h2p_lw_led_addr);

// *h2p_lw_led_addr = 0xf;

Has anybody had this problem and found a solution?

Thanks, Ulrich

Check your clocks, check your resets.
I just had this problem. I would recommend a clock counter connected to an LED at a human-noticable interval to turn it on and off to prove your clocking constraints are right.

Thanks, this solved my problem. One of four clock lines seems not to arrive at the FPGA pin. After connecting to a different pin its working:-)