USB program upgrade and revert to earlier or latest versions

Discussion in 'Embedded Systems and Microcontrollers' started by ironhyde, May 12, 2015.

  1. ironhyde

    Thread Starter New Member

    May 12, 2015
    3
    0
    I had a cortex m0 USB mass storage project. I also have a PC app which makes sense out of the log and debug gibberish files inside the USB drive. This project has been dormant for a while:(. I wanted to add more functionality to it.
    Objective:
    Drag .bin or .hex file in the USB drive. The code reads the file and writes it into the on-chip flash. The on-chip flash should always have 2 codes on it but only the latest will be run. This will allow me to check if the code was written correctly on the on-chip flash. If not then I can revert to the earlier code. Will this work like a pointer or like grub which will allow to switch between 2 OS by checking a flag. How do i go about this? I'm looking for a simple approach:).
    P.S.
    Later I'd also like to add some encryption in the .hex or .bin file. This will ensure that the code does not write the on-chip flash with anybody's files but only :cool:mine!
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,138
    1,789
    Divide and conquer. One step at a time.
     
  3. ironhyde

    Thread Starter New Member

    May 12, 2015
    3
    0
    I'm back again yo:cool:! Thanks Papabravo. I did some reading on these firmware update and bootloader thing. SO now I have three firmware on the cortex M0:p. The first one is the multi-app bootloader. I'm using the Keil IDE and its default compiler. The application starts with bootloader.uvprojx and then switches to one of the two application namely: blue2000.uvprojx and red3000.uvprojx. So we have 3 binaries/executables on our controller at following addresses of the flash program/code memory space: bootloader at 0x0, blue2000 at 0x2000 and red3000 at 0x3000 .
    The code is able to switch firmwares correctly. But I had some problems with ISRs in the blue2000.uvprojx. The ISR does not execute as expected. After debugging, I found that after the interrupt in blue2000.uvprojx, the code still uses the vector table of the bootloader.uvprojx.
    So I currently implemented the vector table in RAM n it works fine:)!
    blue2000 and red3000 are the same code but these two app firmwares here are compiled using absolute ROM addresses to create fw2000.bin and fw3000.bin. This is done in Keil by setting the address in "Options for target"->"Target"->"IROM1:" -> "Start" address to respective start address .
     
  4. ironhyde

    Thread Starter New Member

    May 12, 2015
    3
    0
    Compiling n building firmware updates for a fixed address is a problem that I'm facing:(. I need a way to build a position independent firmware fwXXXX.
    Is there a way to compile a fwXXXX which can be relocatable at both the addresses? fwXXXX is compiled n built into .bin or .hex such that it can be executed at any address (in this case 0x2000 or 0x3000).

    Thanks;)
     
Loading...