Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

How can i build a tftp server in u-boot?

I use the u-boot run my embedded system in nios2 platform.

In the first time,I must use the tftp download my imag file to the sdram,

but there are no tftp server in the u-boot.I must operate commands in the console of u-boot and download my kernel+romfs image file by tftp server in PC

if the u-boot have a tftp server, i can download image file more easily.

who can tell me How can i add a tftp server in the u-boot?

thank you for all help!

8 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi smalllight,

    > if the u-boot have a tftp server, i can download image file more easily.

    ...<snip>...

    > who can tell me How can i add a tftp server in the u-boot?

    This would be inappropriate -- u-boot is a bootp/dhcp/tftp client ... a bootloader, not a server.

    If you want to avoid manually entering the commands, setup the u-boot "autoboot" to

    automatically download (and execute) your image when your board boots.

    --Scott
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    thank you for you reply.

    In tha fact, I have update the u-boot sourse, my u-boot can choice the run model between tftp and run the kernel img in the flash.

    when the u-boot run in tftp model, I will set a default IP, and download a default file in the default server,eg. 192.168.168.100 image.rom

    so if i want to download the image file, i must change my PC&#39;s IP address to th default and change my image file name to default one. this is trouble.

    so I want to add a tftp server in u-boot. In the case,I can download my image file by tftp command in the PC.

    can you give some advise?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi smalllight,

    > so if i want to download the image file, i must change my PC&#39;s IP address to th

    > default and change my image file name to default one. this is trouble.

    > so I want to add a tftp server in u-boot. In the case,I can download my image

    > file by tftp command in the PC.

    You must be a glutton for punishment ;-)

    I don&#39;t understand why you have to change the IP address of your PC. Just update

    the u-boot environment variable &#39;serverip&#39;. Regardless, if you want to add a tftp

    server to u-boot, please feel free to do so.

    However, I would recommend you simply run a dhcp/bootp server and let

    u-boot download the image automatically (or via autoboot script). If you&#39;re using

    Linux, you can use the standard dhcpd/tftpd. If you&#39;re using windoze I

    recommend tftpd32:

    http://tftpd32.jounin.net (http://tftpd32.jounin.net)

    Regards,

    --Scott
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi smcnutt!

    thank you for you help.

    my english is very poor, I don&#39;t discribe my problem clearly.

    why do i must change my PC ip to download the image file? the reason as follon:

    first, i don&#39;t want to use the command line in u-boot.

    second,Maybe,I download the image file in diffrent PC

    for example,the ip of my embed board is 192.168.168.1

    I set the serverip=192.168.168.100

    now if the ip of my pc is 192.168.168.99

    in this case, if i want to download my image file, i must use the command line of u-boot to change the env serverip or i change the ip of my pc to 192.168.168.100

    ,or i will no way to download my image file.

    if i have a tftf server in u-boot. i can input the command "tftp -i 192.168.168.1 put image.rom" in the cmd in my pc.

    do you understand?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi smalllight,

    > my english is very poor, I don&#39;t discribe my problem clearly.

    Your english is fine ... and I understand your problem clearly -- I just don&#39;t

    agree with your proposed solution :-)

    > first, i don&#39;t want to use the command line in u-boot.

    You don&#39;t have to ... use the autoboot feature.

    > second,Maybe,I download the image file in diffrent PC

    And that is exactly the problem (plus others) that DHCP/BOOTP & TFTP successfully

    solved many years ago ... and continues to solve today. u-boot fully supports DHCP/BOOTP & TFTP.

    > in this case, if i want to download my image file, i must use the command line of

    > u-boot to change the env serverip or i change the ip of my pc to 192.168.168.100

    > ,or i will no way to download my image file.

    Again, I disagree. Regardless, you have at least two choices:

    1. get tftpd32: http://tftpd32.jounin.net (http://tftpd32.jounin.net)

    This is what I recommend.

    2. implement a tftp server in u-boot

    Feel free to implement the tftp server in u-boot -- but realize that you will be

    re-inventing the wheel ;-)

    Regards,

    --Scott
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,smcnutt

    thank you for your help, I change the tftp client of u-boot to a tftp server.

    I can download the image file in any PC.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by smalllight@May 10 2006, 06:54 AM

    hi,smcnutt

    thank you for your help, i change the tftp client of u-boot to a tftp server.

    i can download the image file in any pc.

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=15249)

    --- quote end ---

    --- Quote End ---

    Hi smalllight,

    could you please explain how you did so.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

    --- Quote Start ---

    Hi smalllight,

    could you please explain how you did so.

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=15253)

    --- Quote End ---

    [/b]

    --- Quote End ---

    Hi, MFM

    In the fact,the tftp server is very similar with a tftp client

    In the u-boot, there are no the code about WRQ.

    if a tftp client want transport a file to tftp server.

    it will send a WRQ to tftpserver,the tftp server will send a ACK to client when the receive the WRQ packet.

    then the client will transport the fill 512 bytes in once.

    when the server receive the data packey,it send a ACK packet to client.

    if the data length is smaller than 512 bytes, the file transport success.

    so I add some code to ask the WRQ packet in the function TftpHandle

    and change the TftpOurPort to WELL_KNOWN_PORT and you must Save the Client IP when you receive the ARP packet.

    Before your work,you should read the tftp protcol document.