Author Topic: TFTP Bootloader  (Read 11196 times)

Offline paulk

  • Newbie
  • *
  • Posts: 45
    • View Profile
TFTP Bootloader
« on: May 17, 2010, 08:53:25 PM »
The Bootloader document states that TFTP may be added in the future.  I'm wondering if there is any progress on this?  I realize that there may be a code penalty, and some other disadvantages.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: TFTP Bootloader
« Reply #1 on: May 17, 2010, 09:40:40 PM »
Hi Paul

There hasn't been any real demand for TFTP bootloading and personally I think that a small HTTP server does the job quite well - it doesn't need a TFTP server operating (asking someone with only limited PC and network knowledge to install one to load new SW is not easy when a simple Browser will do it).

Of course there may be circumstances when it needs to be automated, where it may indeed be of use. For this there is some demo code in application.c

// Test TFTP transfer
//
static void fnTransferTFTP()
{
    //fnStartTFTP_client(tftp_listener, ucTFTP_server_ip, TFTP_GET, "test.txt", '0'); // get a file (text.txt) from TFTP server and save it locally (to file '0')
    //fnStartTFTP_client(tftp_listener, ucTFTP_server_ip, TFTP_GET_COMPARE, "test.txt", '0'); // get a file (text.txt) from TFTP server and compare it to local file ('0')
    fnStartTFTP_client(tftp_listener, ucTFTP_server_ip, TFTP_PUT, "test1.txt", '0');  // transfer local file ('0') to TFTP server and save it there as (test1.txt)
}


he idea is that it can get a file from a TFTP server, upload it and compare the content against an already loaded version (not actually saving it though). If the version is different it can repeat with the save step and reboot to program it, as the 'bare-minimum' loader does it. By commenting in and out the three test lines the three cases can be tested.

Regards

Mark
« Last Edit: May 18, 2010, 09:47:48 PM by mark »

Offline paulk

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: TFTP Bootloader
« Reply #2 on: May 18, 2010, 04:30:48 PM »
Thanks Mark,

I agree that TFTP can be a hassle, most systems don't even have a client.  Interestingly the Luminary (TI) StellarisWare provided software includes a bootloader with BOOTP/TFTP support, but this requires their special software running on the host PC.  I agree that HTTP Post is a better method.  I might need to utilize an external Flash to maximize the code space for the firmware....

What do you think the smallest basic implementation of bootloader with HTTP server only would cost in terms of code size.  Again, a larger bootloader may be a good compromise so that we can utilize more flash space, and not worry about having to leave room for the uploaded image. 

That is: in this implementation, the bootloader could program the flash on the fly (while it is being downloaded).  If the download fails, the bootloader (with HTTP server) is always there, and a retry can occur.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: TFTP Bootloader
« Reply #3 on: May 18, 2010, 05:18:38 PM »
Hi Paul

A project configured to be just a web server with post capability to upload new code directly to FLASH (just after the "web server boot loader") requires about 16k of FLASH on a Cortex M3. This includes a single, simple, integrated web page with the upload form and a check of whether it should start or jump to the application that is already present. This corresponds approximately to the "serial loader" but over Ethernet rather than serial.
The only thing that needs to be agreed on between loader and application is where the boot code gets it Ethernet/IP settings from - often this is solved by keeping them in a space which is known by both.

I have used this technique a few times and its advantage compared to the "Bare-Minimum" loader method is that it doesn't need the memory to save the new code before it is copied (however often an SPI FLASH chip solves this quite simply).

Regards

Mark
« Last Edit: May 18, 2010, 09:48:07 PM by mark »

Offline paulk

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: TFTP Bootloader
« Reply #4 on: May 18, 2010, 06:27:33 PM »
Do you have this type of bootloader already written, and could share it?

Regards,
Paul

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: TFTP Bootloader
« Reply #5 on: May 18, 2010, 06:38:11 PM »
Hi Paul

Simply take the standard project and comment out everything that is not required in config.h and app_hw_xxxx.h.
Use a single user file with a simple form to post the code to the start of the file system and define the file system so that it occupies the rest of the FLASH space.

That is about it...

Regards

Mark

Offline paulk

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: TFTP Bootloader
« Reply #6 on: May 18, 2010, 07:58:00 PM »
OK, but won't the bootloader functionality change, because it won't be looking at the upper half of the memory space, but rather re-writing the flash as it gets accepted via POST?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: TFTP Bootloader
« Reply #7 on: May 18, 2010, 09:53:03 PM »
Hi Paul

Yes it is correct that the SW upload is written directly to FLASH where it can be executed. When the upload is successful it should mark the fact that the new code is ready (the serial loader does this be writing the first addresses, which it had saved during download) so that these can be recognised as valid program. There is nothing to stop a check sum and code length being integrated in the SW download so that it can also check this to be absolutely sure and stay in the boot loader if it is not good.

It means that the stripped-down project is acting as an independent boot loader and doesn't need anything else (no copying the code to its final location and no intermediate space required).

Regards

Mark