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

MCB 2140 IAP Firmware Upgrade

Respected Colleagues,

can somebody help me and point me to a sample Keil ARM project (if exists) which explains how to configure Keil application running on the Keil MCB 2140 Evaluation Board, that can be upgraded to a new version which is on the some media, for example SD/MMC card, using IAP ?

So, goal is to upgrade firmware without PC, only with SD/MMC card. Can anybody explain how to build an application which runs normally when the card is not inserted, and which copy a new code from the card into internal FLASH using IAP, when the card is inserted, and start the new code with success.

Thanks in advance.

Dragan Kujovic

  • One way to do it:

    Split the flash in three sections:
    - boot loader
    - application
    - application scratch

    Boot loader checks if there is a new valid application in scratch area. If so, erase application and copy from scratch area. If you loose power or anything bad happens, the boot loader can retry again.

    If scratch area is empty, or broken or has same version as current application, let boot loader start application.

    Application can (whenever it feels like it) check for a SD card. If found, check for a firmware binary. Verify checksum and version. If ok, erase scratch area and copy from SD to scratch area. When full image copied to scratch, reboot and let boot loader reprogram.

    A cheaper (but more dangerous) solution is to let the application scan for an image on the memory card. If a valid image (of newer - or at least different - version) is found, run a function in RAM that retrieves the file and programs the flash. The problem is that you need access to your file system code until your last block of SD data has been read into RAM for programming. This makes it a bit harder to write the application, but if correctly done you have less vasted flash space. The huge disadvantage is that a power loss during reprogramming will kill your device - your partially reprogrammed flash will fail to boot...

  • > Split the flash in three sections:
    > - boot loader
    > - application
    > - application scratch

    Respected Per Westermark,

    thanks for your kind and prompt answer.

    I know how to erase some FLASH sectors and how to save some data in a FLASH at desired address, but I don't know how to make boot loader which will perform a task that you have described.

    Can you please give me some example how to do this.

    Thanks in advance.

    Dragan Kujovic

  • But the boot loader is trivial.

    Just a normal (but tiny) program that checks contents of the application scratch area (no need for file system support or other magic).

    Check if there is a difference between app and app area. Difference is caused by: scratch area empty, scratch area broken, scratch area having different app version than app area, or one of the two areas only partially programmed.

    If difference is found - check if scratch area is valid: Use Adler32, crc32, stupid 32-bit checksum, ...

    If difference is found and scratch image is valid, use your knowledge of erasing and programming single sectors and copy the scratch area to the app area. Then jump to the entry address of the app area to let the new application start.

    If no difference is found, or scratch area doesn't contain a valid image, jump directly to app area entry point.

    The boot loader can be miniscule, since it has so very little to do. It leaves it to the normal application to perform all file I/O to get a new application image from the memory card and into the scratch area. You might even let the application checksum the retrieved image and "sign" it as valid directly before rebooting the unit to have the bootloader perform the programming. Just require that the app writes a magic marker at a fixed address in the scratch area when the full image has been copied from the memory card and checksum-verified.

  • > Then jump to the entry address of the app area
    > to let the new application start.

    Respected Per Westermark,

    thanks very much again.

    I know how to check everything about new and old firmware, but I don't know how to in this program (which is doing checking) implement startup of main application at xxx address which I have previously stored at some address.

    Thanks in advance.

    Dragan Kujovic

  • Please study carefuly part of TNKernel, firmware upgrader:

    www.tnkernel.com/usb_fw_upgrader.html

    Georg

  • > Please study carefuly part of TNKernel,
    > firmware upgrader:
    > www.tnkernel.com/usb_fw_upgrader.html

    Respected Georg,

    thanks for your hint.

    I have studied it today, but project is too complicated for mine level of knowledge to extract just what I need. I have tried but with no success.

    I know how to erase and program LPC2148 internal FLASH sectors with IAP, etc. but I don't know how to make a startup code which will start existing application or reprogram existing application with the new one from external FLASH, if any.

    The bottom line is:

    1) How to configure and with what options to build startup application in Keil ARM Complier which will be at address XXXX, and which will start some other application in internal FLASH at address YYYY, if any ?

    2) How to configure and to build main application which will be in internal FLASH at address YYYY ?

    If I can make, for example, Keil project that will make startup application which will only printf "Hello World", and jump to another application at some address which will printf "APP_1", and which application I can replace with second application that printf "APP_2" I think that I can make the rest.

    Anybody can help with some sample "Hello World" project ? Maybe Keil stuff ? I think that many of Keil clients need this.

    With best regards,

    Dragan Kujovic