I am trying to write a simple, stand-alone TCP bootloader for an AVR micro-controller.

Right now, I have got a collection of APN that weigh almost 14KB memory. The application code will establish a TCP connection with the server,using the network's APN that was stored in the program space and checks with the server for any updated application code. If server responds positively, the code will restart controller itself to enter into the bootloader program. The bootloader will fetch the application code and store it in the program space.

My question is, How can i make the stand-alone TCP bootloader without depending on the application code for establishing TCP connection. As bootloader is only limited to 8KB of flash memory, How can i store the 14KB of APN+4KB of bootloader code into this 8KB boot section?

Application code:

  initiate TCP connection using APN in pgmspace;
  check server for any updates;
  normal function;

Bootloader code:

  request server to send the updated application code;
  receive code and flash the application code;
  goto application code address;

EDIT: My main concern here is, if suppose, something went wrong while flashing the new application code, then bootloader cannot connect to the server and i fear there is no other go but program it with a programmer


1 Answer 1


How much memory is on the system?

If you have enough memory it should not be a problem to store the APN code in normal memory and call it from the bootloader (this is what normal OSs do anyway). You should be careful to never overwrite it using good memory management. (I would put it on one end of the system memory.) The point is if you want use more memory when you write applications you have to start writing memory with the bootloader above the APN code.

Further, you should be able to also use this code in your applications if you are careful enough.

  • 2
    \$\begingroup\$ There are some references to this here which links to this excellent video from Mike. \$\endgroup\$
    – David
    Jun 20, 2014 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.