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

Boot code question

By boot code consists of two projects. Both are written in C using small memory model. One I call fixed boot which is contained in FLASH memory. The other I call flex boot and it is downloaded from a PC to internal RAM if a software update is required. Flex boot contains FLASH erase and programming algorithms for several devices. Fixed boot calls functions in flex boot via a function table located at a fixed address.

My fixed boot project reserves memory 0xC000 - 0xD7FF for flex boot. For this scheme to work correctly I beleive that I need to insure that both projects setup the following items the same way:

1. The system stack
2. The main registers
3. The users stack
4. DPP registers

The first three I can handle but I am unsure how to handle the DPP registers. I posed this question to Keil support and they suggested to initialize them in the startup.a66 file.

I am confused at how this would work and so far have not been successful in getting an explaination from them. The compiler uses the DPP registers to calculate addresses. If I change the contents of these registers in the startup code, won't the compiled code calculate the wrong address???

Would someone please explain this too me.

Also I would appriciate any comments on things I might be missing or need to be careful of in the fixed/flex boot scheme I described.

Thanks in advance,
Walt

Parents
  • You need to beware of several things;
    The NEAR DATA and NEAR CONST memory classes of the projects should be at different addresses (L166 Locate settings). The linker puts near stuff in these areas starting at the bottom of the address range so if they are the same address range, the two will be in conflict. In the flex boot the const class will actually be in RAM anyways, though the project will think it's ROM.

    Depending on what devices you are programming, you may find that function calls during code critical periods will corrupt the programming. This problem forced me to write our boot section in assembly so I could control all calls (C166 uses functions to perform some casts and other things.) This also goes for interrupts.

    In the ST10F167, many things can cause a failure while the Flash is open for programming. Reading and writing some internal locations and some code locations seem to cause problems. The failure may be obvious or a weakly programmed bit which toggles when in use.

    I ended up using the first sector in an external flash for the boot sector (AM29F100 - 800). The boot sector initializes everything, identifies the CPU and external flash and maps the memory by sector. The external flash is mapped behind the internal flash so after the last byte of the internal flash there is a byte of external. The external then runs to the top of it's addressing, then the boot sector mirror, then all the external sectors which were 'hidden' by the internal. Since the CPU may have 128K of flash (F167) or 256k (F268) and the external can have 128k - 1M the map can be quite varied. The boot section then performs a CRC check on the program and compares the result to the CRC stored in the highest available address. If there are any failures, the server is notified of a bad program. The boot sector then waits for a hex download, erases and programs the various types of memory by address. Finally it calculates the CRC and stores it at the highest external flash address. It then performs a software reboot. If the program is good, the internal flash is mapped to the 0 segment and a software reset starts the application. The handy part about this system is the boot sector does not allow it's own sector to be reprogrammed. A bootstrap reset is required to do this. This system has been used with no failures in the field.
    Best luck

Reply
  • You need to beware of several things;
    The NEAR DATA and NEAR CONST memory classes of the projects should be at different addresses (L166 Locate settings). The linker puts near stuff in these areas starting at the bottom of the address range so if they are the same address range, the two will be in conflict. In the flex boot the const class will actually be in RAM anyways, though the project will think it's ROM.

    Depending on what devices you are programming, you may find that function calls during code critical periods will corrupt the programming. This problem forced me to write our boot section in assembly so I could control all calls (C166 uses functions to perform some casts and other things.) This also goes for interrupts.

    In the ST10F167, many things can cause a failure while the Flash is open for programming. Reading and writing some internal locations and some code locations seem to cause problems. The failure may be obvious or a weakly programmed bit which toggles when in use.

    I ended up using the first sector in an external flash for the boot sector (AM29F100 - 800). The boot sector initializes everything, identifies the CPU and external flash and maps the memory by sector. The external flash is mapped behind the internal flash so after the last byte of the internal flash there is a byte of external. The external then runs to the top of it's addressing, then the boot sector mirror, then all the external sectors which were 'hidden' by the internal. Since the CPU may have 128K of flash (F167) or 256k (F268) and the external can have 128k - 1M the map can be quite varied. The boot section then performs a CRC check on the program and compares the result to the CRC stored in the highest available address. If there are any failures, the server is notified of a bad program. The boot sector then waits for a hex download, erases and programs the various types of memory by address. Finally it calculates the CRC and stores it at the highest external flash address. It then performs a software reboot. If the program is good, the internal flash is mapped to the 0 segment and a software reset starts the application. The handy part about this system is the boot sector does not allow it's own sector to be reprogrammed. A bootstrap reset is required to do this. This system has been used with no failures in the field.
    Best luck

Children