This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Creating a Bootloader with C

I currently have 2 in system programming (also acting as bootloaders) designs done up in 8051 assembly but would like to recode them in C. I'm unsure how one goes about doing this based upon the runtime constraints placed on the user when using C.

Parents
  • What runtime constraints do you believe would be an impediment?

    Just the runtime setup... I'd need another startup file then I need to make sure all my code is in a location in code space that does not get ERASED. Last I tried using C, I recall having an issue with the tools finding ?CSTART label when I did SRC output and assembly.

    Everything is polled while the device is runing ISP code. And there are no interrupts as these are vectors are in the place I'm programming for normal operating code.

    What would be the benefit of re-coding in 'C'?

    I'd find it easier to come back to at a later date and make changes. Especially if I start doing other 8051 work.

    Is there some hard timing constraint that has to be met with regard to the code you have to generate?

    There are hard timing constraints but these should not be an impediment.

    "why even consider putting ANY effort into a "bootloader" ?"

    Okay, I'm refering more to ISP/IAP. I still use bootloaders (although one could also refer to them sort of as overlays) on other processors so that ram can be loaded with different firmware/data/cpld & fpga configurations depending on the modality needed.

    some rationale
    -So the end product is field upgradeable from a common user interface this also reduces depenencies I have no control over. Also, the system contains a total of 11 different processors (only 5 of which are '51 microcontrollers).
    -Communication bus used is not supported by the ISP for the device selected.
    -End user might not have access to a computer able of running the manufacture's ISP software.
    -There is limited access(to varying degrees) to the device which limit how I can use manufacturers' ISP/bootloader.
    -There are a limited number of pins I can access the device with through a particular connector.
    -I need to maintain a consistent protocol to the devices in the system. The manufacturers' ISP is not consistent with the protocol I use.
    -The time spent developing has saved development time and will save time if firmware changes are required.
    -There is extra hardware to program the device using manufactures' ISP.
    -The most important mark is my boss wants it.
    -And cause I like monkeying around.

Reply
  • What runtime constraints do you believe would be an impediment?

    Just the runtime setup... I'd need another startup file then I need to make sure all my code is in a location in code space that does not get ERASED. Last I tried using C, I recall having an issue with the tools finding ?CSTART label when I did SRC output and assembly.

    Everything is polled while the device is runing ISP code. And there are no interrupts as these are vectors are in the place I'm programming for normal operating code.

    What would be the benefit of re-coding in 'C'?

    I'd find it easier to come back to at a later date and make changes. Especially if I start doing other 8051 work.

    Is there some hard timing constraint that has to be met with regard to the code you have to generate?

    There are hard timing constraints but these should not be an impediment.

    "why even consider putting ANY effort into a "bootloader" ?"

    Okay, I'm refering more to ISP/IAP. I still use bootloaders (although one could also refer to them sort of as overlays) on other processors so that ram can be loaded with different firmware/data/cpld & fpga configurations depending on the modality needed.

    some rationale
    -So the end product is field upgradeable from a common user interface this also reduces depenencies I have no control over. Also, the system contains a total of 11 different processors (only 5 of which are '51 microcontrollers).
    -Communication bus used is not supported by the ISP for the device selected.
    -End user might not have access to a computer able of running the manufacture's ISP software.
    -There is limited access(to varying degrees) to the device which limit how I can use manufacturers' ISP/bootloader.
    -There are a limited number of pins I can access the device with through a particular connector.
    -I need to maintain a consistent protocol to the devices in the system. The manufacturers' ISP is not consistent with the protocol I use.
    -The time spent developing has saved development time and will save time if firmware changes are required.
    -There is extra hardware to program the device using manufactures' ISP.
    -The most important mark is my boss wants it.
    -And cause I like monkeying around.

Children
  • Tim,
    I think you, like Jay call IAP a "bootloader".
    That particular name (of PDP-8 origin, I believe) refer to getting a different program loaded into a computer so it will run a different task after the program is loaded. IAP, in contrast refer to loading something that will make the same task be performed better. Thus using a "bootloader" is for those that play with the '51, ISP/IAP is for updating code that actually serves a purpose.

    So, can we agree: a "bootloader" load into RAM, IAP load into flash. If we can, this discussion will be so much easier.

    Erik

  • Just the runtime setup... I'd need another startup file then I need to make sure all my code is in a location in code space that does not get ERASED. Last I tried using C, I recall having an issue with the tools finding ?CSTART label when I did SRC output and assembly.


    It's certainly easy enough to send a CODE() directive to Keil's linker to make it place a certain segment at a given location in code space. Just check the manual. The warning about C_START probably comes in if you monkey around with the startup sequence in assembly and something in Keil's STARTUP.A51 or INIT.A51 gets broken.

    As just a general note of encouragement, my last '51 project design implemented a bootloader (or IAP, whatever) in C that works quite well, so it's certainly doable.

  • We use "bootloaders" a lot. Usually it is because the systems being downloaded are in a multi-drop environment and the in-chip ISP code doesn't handle the enable on the transmitter.

    In addition, our users are not programmers ... often barely computer literate. Using programs like FlashMagic is much to dangerous (if you specify the wrong chip type it can destroy the micro).

    We generally have a simple download application run on a PC. The details of erasing memory, setting option bits, and restarting after download are left to the "bootloader".

  • Using programs like FlashMagic is much to dangerous (if you specify the wrong chip type it can destroy the micro).
    If you use FM in commandline mode you can create a 'push the button" application. Of course NoTouch will be needed as well.

    Erik