Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Problem in alt_find_dev

Altera_Forum
Honored Contributor II
2,118 Views

I've got a DMA component in my system named "/dev/dma". I copied code from the Memtest template so it should work. However, calling alt_dma_txchan_open("/dev/dma") fails. I traced down into the library code and found that alt_find_dev was performing a memcmp on the name. If I manually change the number of bytes to compare, then memcmp will pass otherwise it fails. Any ideas if I'm doing something wrong? 

 

alt_dev* alt_find_dev(const char* name, alt_llist* llist) { alt_dev* next = (alt_dev*) llist->next; alt_32 len; // change this line to pass len = strlen(name) + 1; // fails len = strlen(name); // passes while (next != (alt_dev*) llist) { if (!memcmp (next->name, name, len)) { /* match found */ return next; } next = (alt_dev*) next->llist.next; } return NULL; }
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
883 Views

Are you sure that your component device name is really "/dev/dma" and not something like "/dev/dma_0" or something else? 

To be sure you can include system.h in your source file and use the constant defined there instead of hard coding "/dev/dma". The constant should have a name like DMA_NAME or something close.
0 Kudos
Altera_Forum
Honored Contributor II
883 Views

I was actually using the defined name from system.h, but I modified my post to make it clear what I was doing.

0 Kudos
Altera_Forum
Honored Contributor II
883 Views

The only reason I can see for the failure is that the two strings (the one that you provide as device name and tho one declared in the system) are equal on the first 8 characters but differ on the ninth: yours has a 0 indicating an end of string, and the one in the system has something else, indicating that the string is longer.

0 Kudos
Altera_Forum
Honored Contributor II
883 Views

A recompile of the hardware and software solved the problem, with no indication of what the problem might have been.

0 Kudos
Altera_Forum
Honored Contributor II
883 Views

 

--- Quote Start ---  

A recompile of the hardware and software solved the problem, with no indication of what the problem might have been. 

--- Quote End ---  

 

 

 

i had the same pb, 

 

i simply add a counter to limit the cycle, when the counter reaches max times, return 

null. and pb solved. dont need to recompile the system. 

 

if you look carefully,i'ts the llist.next who block the program. .next remains always the same address, that's why it turns into a infinity cycle.
0 Kudos
Reply