This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UCD3138A: Custom Bootloader code example

Part Number: UCD3138A
Other Parts Discussed in Thread: UCD3138

hi, can you provide custom bootloader project example for UCD3138? I mean of course both bootloader and main program. The main role of the BL will be to program / erase main program using custom serial interface

My assumption so far are:

  1. for good code practice the software interrupt used to write/erase flash should be part of custom BL project, the data flash write/erase in main program should be done thru SW interrupt placed in bootloader code
  2. since Fast and Standard Interrupts are used in main program, they shouldn't be used in BL and their jumping vectors should be forwarded to the main program address
  3. the BL load asm file has to be modified, so .vectors section points to right fast and standard interrupts, for example to second "virtual" vector fable at address 0x800
  4. the main program asm file has to be modified, so .vectors section points to right software interrupt location in BL
  5. the linker cmd in BL project sets PFLASH (RX) : org = 0x00000020, len = 0x000007DC keeping the interrupt vectors and place for checksum
  6. the linker cmd in main program project sets new "virtual" vector table VECS : org = 0x00000800, len = 0x00000020, but only fast and standard interrupt will be used here
  7. the linker cmd in main program project sets the PFLASH    (RX) : org = 0x00000820, len = 0x0000xxxx

I'm not sure should I keep rest of the default load asm file in main program? the load asm in the bootloader will set the stacks and ram, but it may be useful to "clean up" everything after exiting the BL so main program gets full resources and clean ram. Also this would allow to have different stack sizes for BL and main program.

Am I missing something more? The example projects would be great reference, since there are of things to take care of.

  • Here are some answers to your questions:

    1. We try to fit the boot flash into the 2K space, and all it does is to erase and write flash, so we just leave it in system mode.  This way it can access things directly without an SWI.  

    2,3, 4, 5, 6, 7 yup  

    The load.asm file in the bootloader is very minimal.  It does minimal initialization.  The little magic touch at the beginning to initialize the hardware, then initializing the stack for system mode, and then executing the code.  There is no RAM clearing and no handling of autoinitialization tables.  

    The one key feature you don't mention, and many customers don't get is that if the bootloader gets bigger than 2K, there has to be a program that fits entirely within the 2K that can verify a checksum for the rest of the bootflash and clear the 2K checksum if the extra checksum doesn't pass.  

    I actually have an old click-wrapped bootflash code that I can send you.  If you send me a friend request here with your email in it, I should be able to send you a box link to a clickwrapped simple bootloader.