1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to change default config before compiling?

Discussion in 'Tomato Firmware' started by augustynr, Jul 17, 2007.

  1. augustynr

    augustynr Network Guru Member

    Hi,
    I finally got to the point that I am able to compile Tomato.
    Now, I would like to make few changes before I create firmware for my router.
    Since I will be playing around with it I do not want to do the all changes by hand every time I upload the firmware.
    So I need to be able to assign basic and advanced network configuration, QoS, port forwarding, init scripts, before compilation.
    I admit that I have no idea how it is done, or where to start looking.
    I have tried to look through the source but could not find any pointers there.
    I hope that all these values are stored in some sort of the config file though which I can change and go on and create my firmware.
    Any pointers would be greatly appreciated.
    robert
     
  2. azeari

    azeari LI Guru Member

    currently these settings are stored in the nvram, which is not included in the firmware. it is possible to write a script to enter all your values into the nvram upon first boot though
     
  3. augustynr

    augustynr Network Guru Member

    azeari,
    Thanks,
    Any pointers on how to write a script like that and how to execute it on the first boot and what nvram values are responsible for what functionality?
    Thank you.
     
  4. mstombs

    mstombs Network Guru Member

    A script would be easiest, but if you are compiling anyway the nvram defaults look to be in here...

    tomato.tar\tomato\release\src\router\nvram\defaults.c
     
  5. augustynr

    augustynr Network Guru Member

    Great!
    If I decide to write a script where would I have to add it to source tree and how would I execute it?
    Thanks
     
  6. azeari

    azeari LI Guru Member

    i think what mstombs meant is u can modify the default nvram settings at that path (=
     
  7. augustynr

    augustynr Network Guru Member

    Azeari,
    That is understood :)
    The question about the script still stands though ...
    robert
     
  8. mstombs

    mstombs Network Guru Member

    With all due respect - if you need to ask about scripts - you shouldn't be attempting to re-compile yet, the bash shell is pretty powerful...

    The Tomato gui allows startup, firewall and wanup scripts to be entered - you don't need to know where they are stored, but if you want to do your own...

    the /var directory on the router is a ram disk, you can safely play there - rebooting will clear. Files saved on the jfffs flash partition should survive reboots. From windows I recommend WinSCP with notepad2 or Notepad++ as an editor/ file transferer, notepad and other editors tend to get the line ends wrong.

    Any Linux command you can enter with telnet or ssh can be put into a script file, the file made executable with chmod and run

    To write nvram variables you need the commands

    nvram set variable_name="value"

    followed by a

    nvram commit
    [this may not be needed other processes may do it for you!]

    It would be easy to corrupt important nvram variables resulting in the router failing to boot. Most times a reset to factory defaults with the reset button will reset the nvram variables...

    Hope that helps - and you know how to debrick!
     
  9. augustynr

    augustynr Network Guru Member

    mstombs,
    Thanks for your reply, I guess my question was not clear.
    I know how to write scripts, add and modify, what I do not know is once I have it, how do I add it to the sources to be compiled into the firmware so it is a part of it and then executed on the router once the firmware gets loaded.
     
  10. mstombs

    mstombs Network Guru Member

    Many apologies, sounds as though you do need to modify the code to include such a script. How you do it depends on whether you want to lock down the router to reset on every reboot or once only on the reset to defaults. Not yet tried this - but code is pretty easy to read, have a look in rc/init.c there's an interesting line with "run_nvscript"...
     
  11. GeeTek

    GeeTek Guest

    Excuse my complete absence of Linux knowldge, but is this not to imply that the dafault values can be modifed directly to be the desired values, thus negating the need for a script to change them ?
     
  12. mstombs

    mstombs Network Guru Member

    I think so, but a shell script easy to develop and test. A full recompile & re-flash etc takes longer, so one solution would be to put a hook to a file in the code, then drop the file into the filesystem before it is squashed. There's still a timing issue (different if auto vs manual running of script), and the possibility of adding custom flags to ensure the custom defaults applied on first reboot.
     
  13. augustynr

    augustynr Network Guru Member

    GeekTek,
    You are probably correct, the problem is that I want the script to do more then just set the nvram values.
     
  14. augustynr

    augustynr Network Guru Member

    mstombs,
    This sounds like the best solution for a lot of reasons. Any idea where I start? :)
     

Share This Page