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++
12652 Discussions

Device nodes: major, minor numbers

Altera_Forum
Honored Contributor II
1,089 Views

I have been using the Nios II IDE to rebuild and upload my romfs filesystem image to my uKit development board. 

 

I previously did not have a problem communicating via ttyS0. 

 

Now I am having a problem. It gives me an error saying that the device doesn't exist. 

Upon checking /dev/ttyS0 and /dev/ttyS1, I am able to see that the minor numbers are all 0 instead of what they should be. 

 

I double checked my filenames under the target directory and it appears that they are OK. 

Output from "ls -l dev/*ttyS0*" shown below. 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

-rwx------  1  user      mkpasswd      0  Dec  1  14:37 @ttyS0,c,4,64*[/b] 

--- Quote End ---  

 

 

I even loopback mounted the romfs.bin on a linux system as a romfs and the device files were created properly. 

Output from "ls -l dev/ttyS0" shown below. 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

crw-------  1  root      root      4,  64  Dec  31  1969  ttyS0[/b] 

--- Quote End ---  

 

 

The problem exists when I try to upload the filesystem to my board. Somehow the device nodes are not being created properly. 

Here is the ls -l /dev/ttyS0 output. I noticed that none of my /dev files have their minor number correct. They are all set to zero. 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

crw-------  1  root      root      4,  0  Jan  1  1970  ttyS0[/b] 

--- Quote End ---  

 

 

Has anyone else seen this? 

Does anyone have a suggestion?
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
397 Views

The "ls" command cannot display the minor number correctly. Please use the ls command from busybox, it will tell you the real number.

0 Kudos
Altera_Forum
Honored Contributor II
397 Views

To fix this bug, the application source ls.c has to be modified. It can be found in application source directory fileutils. The problematic codes start from line 307: 

    if (S_ISBLK(statbuf->st_mode) || S_ISCHR(statbuf->st_mode))                     sprintf(cp, "%3d, %3d ", statbuf->st_rdev >> 8,                              statbuf->st_rdev & 0xff); 

To fix this bug, please change them to 

    if (S_ISBLK(statbuf->st_mode) || S_ISCHR(statbuf->st_mode))                    sprintf(cp, "%3d, %3d ", (unsigned int)(statbuf->st_rdev >> 8),                             (unsigned int)(statbuf->st_rdev & 0xff));
0 Kudos
Altera_Forum
Honored Contributor II
397 Views

I will look at recompiling my ls command with the fix. 

 

I have resolved my problem. 

 

I was getting an error indicating that the device didn&#39;t exist, so when I did the ls and the minor number wasn&#39;t there I assumed that this was the problem. 

 

What I forgot was that I had recently started a new kernel project whereby my nios serial support was not enabled. OOPS. 

 

After recompiling the kernel with serial uart support, the serial port worked properly. 

 

Sadly, it was a dumb mistake with a little deception added in. 

 

Thanks for your help.
0 Kudos
Reply