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!

AR# 55779

v2013.04 - PetaLinux -UIO work for Accessing Registers does not work with Compiler Optimizations Enabled?

Description

I am attempting to use UIO to access registers, but this does not work as expected when utilizing compiler optimizations.  Why?

Solution

The following example code snippet does not work when compiler optimizations are allowed to run. 

{{{
void *ptr;

ptr = mmap(NULL, GPIO_MAP_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
*((unsigned *)(ptr +GPIO_TRI_OFFSET)) = 0;
*((unsigned *)(ptr +GPIO_DATA_OFFSET)) = value;
}}}

To work around this, the "volatile" keyword is used to disable compiler optimizations within this block. In addition, users can disable compiler optimizations with the -Os compiler flag at the global level.

AR# 55779
Date Created 04/29/2013
Last Updated 04/30/2013
Status Active
Type General Article
Devices
  • SoC
  • XA Zynq-7000
  • Zynq-7000
  • FPGA Device Families
Tools
  • EDK
  • PetaLinux SDK
  • PetaLinux SDK - 2012.12
  • PetaLinux SDK - 2013.04