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

Set PATH during uClinux kernel boot

Altera_Forum
Honored Contributor II
1,072 Views

I'm running uClinux on the DE2 board. I've added detail in my design to include an SD card. I mount the SD card in the rc file. This allows me to easily add user files the the uClinux file system. However, I currently have to copy the files to /bin in order to run them. How do I add the path to the SD card (/mnt/sd) to my $PATH at startup?

0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
371 Views

What is your shell? 

 

For bash, the files .bashrc or .bash_profile (something like that) get sourced at startup, so you can put  

 

export PATH=$PATH:/mnt/sd/bin 

 

in that file. Or you can first check if /mnt/sd/bin exists ... 

 

if [ -e /mnt/sd/bin ]; then 

export PATH=$PATH:/mnt/sd/bin 

fi; 

 

(No guarantees that this is valid bash code, you can Google for the correct syntax) 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
371 Views

I'm using the default uClinux w NIOS2 shell, sash. I tried to include bash via make menuconfig but it wouldn't make. I don't think it has been ported for use with NIOS??? Not sure if .sashrc and/or .sash_profile exist and if they do, where to find them.?? Any more help would be appreciated.

0 Kudos
Altera_Forum
Honored Contributor II
371 Views

Traditionally /etc/profile and $HOME/.profile are run (sourced) for login shells. 

Not sure of the pedigree oh 'sash', might be based on 'ash'. 

The scripts it runs at startup, and the order, are only likely to be obtainable from specifc documentation or reading the C source for the shell itself. 

 

The kernels default $PATH might also be settable - but again that is kernel/OS dependant.
0 Kudos
Altera_Forum
Honored Contributor II
371 Views

Thanks, dsl. 

I'll dig into the sash c code as I cannot locate any decent documentation regarding the shell. Do you have any more detail on how to set the kernels default path?
0 Kudos
Altera_Forum
Honored Contributor II
371 Views

Got it! 

 

- changed env[1] = "PATH=/bin:/usr/bin/etc/:..." in /uCliunx-dist/user/init/simpleinit.c 

 

Thanks again for you suggestions.
0 Kudos
Altera_Forum
Honored Contributor II
371 Views

Modifying standard programs certainly is not the recommended way, even if it of course does work. I am certain that any shell supports setting exported environment strings in the init script, and that it does support automatically calling an init script.  

 

I did try this with (AFAI remember) sash and mash on NIOS (and of course with bash on PC).  

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
371 Views

I agree, modifying standard code is generally a bad idea, which is why I didn't mess with sash.c (even though that works too!!)

0 Kudos
Reply