Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
744 Views

Set PATH during uClinux kernel boot

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 I
43 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
Altera_Forum
Honored Contributor I
43 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.

Altera_Forum
Honored Contributor I
43 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.
Altera_Forum
Honored Contributor I
43 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?
Altera_Forum
Honored Contributor I
43 Views

Got it! 

 

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

 

Thanks again for you suggestions.
Altera_Forum
Honored Contributor I
43 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
Altera_Forum
Honored Contributor I
43 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!!)

Reply