From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tolunay Orkun Date: Thu, 07 Dec 2006 10:42:39 -0600 Subject: [U-Boot-Users] possible ELDK4 gcc compiler bug In-Reply-To: <200612071721.10783.matthias.fuchs@esd-electronics.com> References: <200612071721.10783.matthias.fuchs@esd-electronics.com> Message-ID: <4578447F.30001@orkun.us> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Matthias Fuchs wrote: > Hi, > > I noticed some strange behavior when using the ELDK4 gcc for compiling > U-Boot for a (new) 405 target based on the current PMC405 board. > > The code needs to read-modify-write a memory mapped FPGA internal register. > But the FPGA access does not appear in the object and therefore it is never > done. > > Here are some code snippets: > > 1) my 'fifo' BSP command: > > int do_fifo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) > { > struct pmc405v2_fpga_s *fpga = (struct pmc405v2_fpga_s *)FPGA_BA; > int i; > int n = 0; The compiler is optimizing away your code. Check out the 'volatile' keyword. It is exactly this situation it was intended. A better way is to use in32() out32() etc. The I/O accessors make sure I/O operation is completed before next instruction is executed. Simply accessing the memory mapped registers might not archive the same. Best regards, Tolunay