Skip to contentSkip to conversation

DHCP updating environment???]

U-Boot-Users Steven Scholz 2 participants 11 messages Nov 5, 2002

lore
Share & tools
lore
#0 lore raw

Hi there,

I asked this quetsion before. But on the PPCBoot mailing list. So here again on the new list:

-------- Original Message --------
Subject: [PPCBoot-users] DHCP updating environment???
Date: Thu, 31 Oct 2002 16:46:47 +0100
From: Steven Scholz <[email protected]>
To: PPCBoot <[email protected]>

Hi folks,

is there a reason why BootpCopyNetParams() in bootp.c does _not_ setenv the ipaddr?

If I set autoload=n I want to use the dhcp command just to get the IP address from the server. But PPCBoot only sets the "bootfile" variable and nothing more!

Wouldn't it make sense to set all the params we got from the DHCP server? Well, at least the ones we're interessted in (see CONFIG_BOOTP_MASK).

Thanks,

Steven

#1 lore raw
Quoted 2 lines · In message <[email protected]> you wrote:

I asked this quetsion before. But on the PPCBoot mailing list.

I remember, and hoped somebody with a btter memory than mine would jump in.

Quoted 2 lines

is there a reason why BootpCopyNetParams() in bootp.c does _not_ setenv the ipaddr?

IIRC this was requested by one / some users with nobody else complaining about this. [But this discussion may have happned about 2 years ago, so I may be wrong.]

Quoted 2 lines

If I set autoload=n I want to use the dhcp command just to get the IP address from the server. But PPCBoot only sets the "bootfile" variable and nothing more!

No. With DHCP you cannot "just get the IP address"; you will always get what the DHCP server has to offer, and you default configuration will most certainly ask for more than just the IP address.

Quoted 1 line

Wouldn't it make sense to set all the params we got from the DHCP server?

Maybe, maybe not. This depends on a lot of things.

For example: assume I manually set a parameter (maybe ipaddr, maybe gatewayip); in this case I probably want to make sure that my pre-set
values take precedence over any DHCP supplied (additional)
information. But then, I cannot simply implement some code which sets the params gotten via DHCP if they are not present in the environment
- I think I remember there was an argument that in such a situation you would not be able to get rid of a faulty setting suppllied once by a misconfigured DHCP server.

Quoted 1 line

Well, at least the ones we're interessted in (see CONFIG_BOOTP_MASK).

I understand what you mean, but I would like to hear more feedback from others...

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
See us @ electronica 2002 in Munich, Nov 12-15, Hall A3, Booth A3.325 
#2 lore raw
Quoted 18 lines · Wolfgang Denk
Quoted 2 lines

is there a reason why BootpCopyNetParams() in bootp.c does _not_ setenv the ipaddr?

IIRC this was requested by one / some users with nobody else complaining about this. [But this discussion may have happned about 2 years ago, so I may be wrong.]

Quoted 2 lines

If I set autoload=n I want to use the dhcp command just to get the IP address from the server. But PPCBoot only sets the "bootfile" variable and nothing more!

No. With DHCP you cannot "just get the IP address"; you will always get what the DHCP server has to offer, and you default configuration will most certainly ask for more than just the IP address.

Quoted 1 line

Wouldn't it make sense to set all the params we got from the DHCP server?

Maybe, maybe not. This depends on a lot of things.

Quoted 8 lines

For example: assume I manually set a parameter (maybe ipaddr, maybe gatewayip); in this case I probably want to make sure that my pre-set
values take precedence over any DHCP supplied (additional)
information. But then, I cannot simply implement some code which sets the params gotten via DHCP if they are not present in the environment
- I think I remember there was an argument that in such a situation you would not be able to get rid of a faulty setting suppllied once by a misconfigured DHCP server.

Fair enough!
That's why I mentioned CONFIG_BOOTP_MASK. This could be use to decide/filter which setting supplied by a DHCP server to use.
If you have to deal with a faulty server and you don't want/can update PPCBoot, maybe we can introduce an environment variable like "dhcp_mask" ...

Quoted 4 lines
Quoted 1 line

Well, at least the ones we're interessted in (see CONFIG_BOOTP_MASK).

I understand what you mean, but I would like to hear more feedback from others...

Yes please! :o)

Again: What's the use of setting autoload to "n"?
I thought it's to get the settings from a DHCP server without immediately loading a file, so I can use the settings (IP, server ip etc) for something else, e.g. tftp'ing an FPGA file or ppcboot (ehm sorry U-Boot) image.

Thanks,

Steven

#3 lore raw
Quoted 2 lines · In message <[email protected]> you wrote:

Again: What's the use of setting autoload to "n"?

The doc says:

autoload

if set to "no" (any string beginning with 'n'), the rarpb, bootp or dhcp commands will just perform a configuration lookup from the BOOTP / DHCP server, but not try to load any image using TFTP.

Quoted 3 lines

I thought it's to get the settings from a DHCP server without immediately loading a file, so I can use the settings (IP, server ip etc) for something else, e.g. tftp'ing an FPGA file or ppcboot (ehm sorry U-Boot) image.

Seems you think right. Ummmm... why are you asking? Any problems with it?

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
See us @ electronica 2002 in Munich, Nov 12-15, Hall A3, Booth A3.325 
#4 lore raw
Quoted 13 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

Again: What's the use of setting autoload to "n"?

The doc says:

autoload

if set to "no" (any string beginning with 'n'), the rarpb, bootp or dhcp commands will just perform a configuration lookup from the BOOTP / DHCP server, but not try to load any image using TFTP.

Quoted 6 lines
Quoted 3 lines

I thought it's to get the settings from a DHCP server without immediately loading a file, so I can use the settings (IP, server ip etc) for something else, e.g. tftp'ing an FPGA file or ppcboot (ehm sorry U-Boot) image.

Seems you think right. Ummmm... why are you asking? Any problems with it?

Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...

(Well not realy anoyed! Just curious why it is the way it is.)

I want to do something like "dhcp; tftp 100000 fpga.rbf".

Steven

#5 lore raw
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 3 lines

Seems you think right. Ummmm... why are you asking? Any problems with it?

Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...

(Well not realy anoyed! Just curious why it is the way it is.)

I want to do something like "dhcp; tftp 100000 fpga.rbf".

I don't get you. Do you mean that setting "autoload" to "no" does NOT work with DHCP? From the code I think it should work.

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
See us @ electronica 2002 in Munich, Nov 12-15, Hall A3, Booth A3.325 
#6 lore raw
Quoted 8 lines · Wolfgang Denk
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 3 lines

Seems you think right. Ummmm... why are you asking? Any problems with it?

Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...

Quoted 6 lines
Quoted 3 lines

(Well not realy anoyed! Just curious why it is the way it is.)

I want to do something like "dhcp; tftp 100000 fpga.rbf".

I don't get you. Do you mean that setting "autoload" to "no" does NOT work with DHCP? From the code I think it should work.

Ok. Example (from real life):

After power on I have

loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F

A bootp results in:
=> bootp
FEC ETHERNET configured
BOOTP broadcast 1
DHCP client bound to address 10.0.9.161
ARP broadcast 1
TFTP from server 10.0.2.9; our IP address is 10.0.9.161 Filename 'pImage.DAB4K2'.
Load address: 0x100000
Loading: #################################################################

         #################################################################
         ########

done
Bytes transferred = 702439 (ab7e7 hex)
=> printenv
loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F
bootfile=pImage.DAB4K2
filesize=ab7e7
netmask=255.255.0.0
hostname=dab4k2_69383
rootpath=/opt/ELDK/ppc_8xx
ipaddr=10.0.9.161
serverip=10.0.2.9

Fair enough! But let's do it again...

=> setenv autoload n
=> bootp
FEC ETHERNET configured
BOOTP broadcast 1
DHCP client bound to address 10.0.9.161
=> printenv
loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F
autoload=n
bootfile=pImage.DAB4K2

You see!?

Only "bootfile" gets set. So a following tftp brings

=> tftp 100000 pImage.DAB4K2
FEC ETHERNET configured
*** ERROR: `serverip' not set

So I think BootpCopyNetParams() should get called regardless of autoload!

Steven

#7 lore raw
Quoted 67 lines · Steven Scholz
Quoted 8 lines · Wolfgang Denk
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 3 lines

Seems you think right. Ummmm... why are you asking? Any problems with it?

Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...

Quoted 6 lines
Quoted 3 lines

(Well not realy anoyed! Just curious why it is the way it is.)

I want to do something like "dhcp; tftp 100000 fpga.rbf".

I don't get you. Do you mean that setting "autoload" to "no" does NOT work with DHCP? From the code I think it should work.

Ok. Example (from real life):

After power on I have

loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F

A bootp results in:
=> bootp
FEC ETHERNET configured
BOOTP broadcast 1
DHCP client bound to address 10.0.9.161
ARP broadcast 1
TFTP from server 10.0.2.9; our IP address is 10.0.9.161 Filename 'pImage.DAB4K2'.
Load address: 0x100000
Loading: #################################################################

         #################################################################
         ########

done
Bytes transferred = 702439 (ab7e7 hex)
=> printenv
loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F
bootfile=pImage.DAB4K2
filesize=ab7e7
netmask=255.255.0.0
hostname=dab4k2_69383
rootpath=/opt/ELDK/ppc_8xx
ipaddr=10.0.9.161
serverip=10.0.2.9

Fair enough! But let's do it again...

=> setenv autoload n
=> bootp
FEC ETHERNET configured
BOOTP broadcast 1
DHCP client bound to address 10.0.9.161
=> printenv
loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F
autoload=n
bootfile=pImage.DAB4K2

You see!?

Quoted 7 lines

Only "bootfile" gets set. So a following tftp brings

=> tftp 100000 pImage.DAB4K2
FEC ETHERNET configured
*** ERROR: `serverip' not set

So I think BootpCopyNetParams() should get called regardless of autoload!

Sorry!!!
BootpCopyNetParams() gets called regardless of autoload!

But

void BootpCopyNetParams(Bootp_t *bp)

{
        NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
        NetCopyIP(&NetServerIP, &bp->bp_siaddr);
        memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6);
        copy_filename (BootFile, bp->bp_file, sizeof(BootFile));

        debug ("Bootfile: %s\n", BootFile);

        /* Propagate to environment:
         * don't delete exising entry when BOOTP / DHCP reply does
         * not contain a new value
         */
        if (*BootFile) {
                setenv ("bootfile", BootFile);
        }
}

So setenv is called only for bootfile. So should we call setenv for OurIP, ServerIp etc or should tftp check NetOurIP or bp->bp_yiaddr!?

Steven

#8 lore raw
Quoted 100 lines · Steven Scholz
Quoted 67 lines · Steven Scholz
Quoted 8 lines · Wolfgang Denk
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 3 lines

Seems you think right. Ummmm... why are you asking? Any problems with it?

Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...

Quoted 6 lines
Quoted 3 lines

(Well not realy anoyed! Just curious why it is the way it is.)

I want to do something like "dhcp; tftp 100000 fpga.rbf".

I don't get you. Do you mean that setting "autoload" to "no" does NOT work with DHCP? From the code I think it should work.

Ok. Example (from real life):

After power on I have

loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F

A bootp results in:
=> bootp
FEC ETHERNET configured
BOOTP broadcast 1
DHCP client bound to address 10.0.9.161
ARP broadcast 1
TFTP from server 10.0.2.9; our IP address is 10.0.9.161 Filename 'pImage.DAB4K2'.
Load address: 0x100000
Loading: #################################################################

         #################################################################
         ########

done
Bytes transferred = 702439 (ab7e7 hex)
=> printenv
loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F
bootfile=pImage.DAB4K2
filesize=ab7e7
netmask=255.255.0.0
hostname=dab4k2_69383
rootpath=/opt/ELDK/ppc_8xx
ipaddr=10.0.9.161
serverip=10.0.2.9

Fair enough! But let's do it again...

=> setenv autoload n
=> bootp
FEC ETHERNET configured
BOOTP broadcast 1
DHCP client bound to address 10.0.9.161
=> printenv
loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F
autoload=n
bootfile=pImage.DAB4K2

You see!?

Quoted 7 lines

Only "bootfile" gets set. So a following tftp brings

=> tftp 100000 pImage.DAB4K2
FEC ETHERNET configured
*** ERROR: `serverip' not set

So I think BootpCopyNetParams() should get called regardless of autoload!

Sorry!!!
BootpCopyNetParams() gets called regardless of autoload!

But

void BootpCopyNetParams(Bootp_t *bp)

{
        NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
        NetCopyIP(&NetServerIP, &bp->bp_siaddr);
        memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6);
        copy_filename (BootFile, bp->bp_file, sizeof(BootFile));

        debug ("Bootfile: %s\n", BootFile);

        /* Propagate to environment:
         * don't delete exising entry when BOOTP / DHCP reply does
         * not contain a new value
         */
        if (*BootFile) {
                setenv ("bootfile", BootFile);
        }
}
Quoted 2 lines

So setenv is called only for bootfile. So should we call setenv for OurIP, ServerIp etc or should tftp check NetOurIP or bp->bp_yiaddr!?

I should realy read more before start writing! ;-)

netbootp_update_env() is what I need! When I call netbootp_update_env() from within the DHCPHandler when autoload == n then I get what I need...

=> setenv autoload n
=> dhcp
FEC ETHERNET configured
BOOTP broadcast 0
DHCP client bound to address 10.0.9.161
=> printenv
loadaddr=0x100000
serial#=69383
ethaddr=00:A0:33:01:07:0F
autoload=n
bootfile=pImage.DAB4K2
netmask=255.255.0.0
hostname=dab4k2_69383
rootpath=/opt/ELDK/ppc_8xx
ipaddr=10.0.9.161
serverip=10.0.2.9

What do you think?

Steven

#9 lore raw
Quoted 2 lines · In message <[email protected]> you wrote:

What do you think?

To _me_ this makes sense. Please send me a patch.

If there is no protest from anybody else it'll make it into CVS within a couple of hours.

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
See us @ electronica 2002 in Munich, Nov 12-15, Hall A3, Booth A3.325 
#10 lore raw
Quoted 9 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

What do you think?

To _me_ this makes sense. Please send me a patch.

If there is no protest from anybody else it'll make it into CVS within a couple of hours.

Dear Wolfgang,

1. I can't send patches for U-Boot yet.
2. All I have right now is a nasty hack that works for me (since my DHCP server is configured well)
3. Before we put something like that into CVS we (not just you and me) should discuss a way to deal with misconfigured dhcp servers because this changes the behaviour of boards that actually have autoload=n.
(There's only one board with #define CFG_AUTOLOAD "n" in the PPCBoot CVS -> GENIETV)

Is it enough to have a right CONFIG_BOOTP_MASK? So only the "interessting" NetOurXXX variables are effected!?

Steven