Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

a strange problem, pls help me out

first some descriptions of my board:

quartus: 5.1

nios2: 5.1

nios2 cpu: nios/f with data cache

uClinux: derived from nioswiki.jot.com

everthing of the uClinux seems to be ok because I have done many verifications on it and nothing is wrong.

But when I run a user application including the following codes, the uClinux automatically reboot:

#define writew(b,addr)    __builtin_sthio ((void*)addr,b)# define readw(addr)       __builtin_ldhuio ((void*)addr)
            for(i=0;i<100;i++)
    {
  daq_status0=readw(STATUS2_BASE)&1;    
        fselect_counter=readw(STATUS1_BASE);
  while( daq_status0==(readw(STATUS2_BASE)&1) )
  {
                                  ;
  }  
    }

/*

STATUS1_BASE and STATUS2_BASE are the address of the registers in my user logic outside the nios2 cpu and are mapped to a flash-like space of the nios2 cpu.

I have verified that it&#39;s the above codes that make the uClinux system automatically reboot when I run it.

I generate the cross compiler according to "http://nioswiki.jot.com/WikiHome/OperatingSystems/BinaryToolchain" and compile my user application by such gcc command:

nios2-linux-uclibc-gcc hello.c -o hello -elf2flt

*/

then i changed my codes to the following:

#define writew(b,addr)    __builtin_sthio ((void*)addr,b)# define readw(addr)       __builtin_ldhuio ((void*)addr)
  
    for(i=0;i<100;i++)
    {
  daq_status0=readw(STATUS2_BASE)&1;    
        delay(1,1);
  fselect_counter=readw(STATUS1_BASE);
  delay(1,1);
     while( daq_status0==(readw(STATUS2_BASE)&1) )
  {
      delay(1,1);
  }  
    }
void delay(int loop1, int loop2)
{
   int i,j,k;
   for(i=0;i<loop1;i++)
   {
     for(j=0;j<loop2;j++)
     {
       k=j;
     }
   }
}

Then my application can function correctly in most times, but there is still a small probability to let the system reboot automatically.

My have made a lot of effort to do with the problem, but I can&#39;t still get rid of it!

can someone give me some hint or suggestion about the problem?
No RepliesBe the first to reply