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

integration of firmware bootloader

Hi,

I've several questions about writing my own small bootloader for firmware updates.

The whole programm is stored in a nor flash device. The user should be able to start a firmware update via the webserver (http post msg).

Is it the right / correct solution to generate two sections in the nor flash device (one for the basic programm (memory location 0x0 - 0x2000) including the http webserver, and another part for all the other stuff)?
Moreover, the webserver itself includes a lot of information for the user. So would it be better to write two webservers - one small webserver for the basic programm, only to start an update, and a second webserver for all the other stuff? I mean it's very difficult to find a clear break between the basic code and the other code.

Basic programm
- small webserver (or only tftp)

Extended programm
- huge webserver (stack including snmp...)

How is it possible to generate / build an update code for the user including only the code starting from memory location 0x2000? Because at the moment the whole code is generated using one keil project.

Maybe someone of you could give me some hints to develop such a system.

best regards
Harwald

  • I don't know about the "right / correct" solution, but that's the way I did it. I'm using an LPC2468 and the firmware updates are performed with a USB memory stick. The boot loader and the application are two different projects. When the BL boots it calculates a check sum on the main application. If the sum is invalid it continues on. It also checks a place in RAM for a magic value that tells it that the main application has caused the reboot so it can be reprogrammed. If everything is good it jumps to address 0x20000, which is the main applications reset vector address.

    I reuse the OHCI host controller code and the memory stick driver code. If you have enough flash I suggest that you reuse code, too -- it's easier to maintain.

    Use the

    -entry=0x...
    

    flag to specify the start address of the main application. See here: www.keil.com/.../armlinkref_chdfiejd.htm

    You'll also have to modify your startup.s file. I made quite a few changes to mine, though I'm not sure if they're all necessary. One change that I'm pretty sure is required is relocating the vector interrupts to RAM for the main application. Look up interrupt vector redirection (I can't find the page right now).

    I don't know if the way I did it is the best/correct way (it was more of a guess and check thing), but it works so I'm sticking with it.

  • I would like to implement ARM libraries into the boot loader and allow the application to access ARM libraries. For this reason I would like to keep just one application instead of two.

    do you have any suggestion ?

  • Why not just include the libraries in both projects?

    But to answer your question: I once worked on a (single) project that had five sections that could be individually reprogrammed and all sections interacted with each other. So in each section, I created a function table that referenced each shared routine. The tables were assigned specific locations in flash, so after an update its location wouldn't change.

    struct funcList {
            void (*func1) (void);
            int (*func2) (int, int);
    };
    
    
    void myFunc1(void)
    {
            // ...
    }
    
    int myFunc2(int a, int b)
    {
            return a+b;
    }
    
    
    // Use whatever pragma is necessary to specify its flash location
    const struct funcList funcList = {
            myFunc1,
            myFunc2,
    };
    

    Then for functions that access a shared routine, it would do so using the function table:

    int x;
    x = funcList.myFunc2(1, 2);
    

    Hope that helps,

    Jon

  • This is a nice idea I already implemented. My problem now is that each downloadable section (I have 2 in my case) needs to share some functions with the other and the boot loader, in addition it should be Position Independent (for downloading process I don't want to copy downloaded code from one flash area to another, so I need to move the two downloadable sections).

    Finally I succeeded to perform the whole integration except that I have a table like this:

    TableMapping const Tab0Addr[] = {

    {0x02, 1, 1, READ_CMD|NO_VALIDATION, ALLMETER,(u8*) (GetTariffContract1)},
    {0x10, 1, 2, READ_CMD|NO_VALIDATION, ALLMETER, &MeasureIcOut.measureIcRead.Vrms},
    {0x28, 1, 1, READ_CMD|WRITE_CMD|TARIFF, ALLMETER,(u32*)(MULTIPLE|ROW_81)}

    }

    With GetTariffContract1 being a function pointer that the linker refuses to include in my PI section since it is an absolute value. I don't need this address to be absolute (I would accept a relative jump) but I don't know how to tell the compiler in C. I made the same in MASM and it works.