Author Topic: Boot loader for MCF52223  (Read 9446 times)

Offline skyguy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Boot loader for MCF52223
« on: March 26, 2009, 05:11:35 PM »
I'm looking to add a serial port bootloader to a MCF52223 project.  Is uTasker a good choice for this, or would someone recommend alternatives?

Thanks,

Rick

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Boot loader for MCF52223
« Reply #1 on: March 26, 2009, 05:28:10 PM »
Hi Rick

There is something here which may be interesting for you: http://www.utasker.com/forum/index.php?topic=336.0

As you probably know, the project includes boot loader support via Ethernet and via USB. In fact USB is essentially a serial boot loaderd, but it does load binary since the USB protocol itself ensures that the data is not corrupted in any way which can not be guarantied via UART without a simple protocol (eg. using S-REC adds a simple check sum).

There are however 2 basic methods.

1) load the new SW using the original application, which is the method generally used by the project. The boot loader itself doesn't need to work with the interface and so can be small (2k on the Coldfire). The disadvantage is that it needs enough memory to store the new code. However many projects use SPI FLASH and so this is a minor issue since they offer large intermediate storage space. The boot loader includes support for various SPI FLASH types (the boot loader size increases to 4k in this case).

2) add a boot loader which enables loading of new code via UART (or other interfaces). This is essentially a small project of its own which runs if no application project is loaded. If an application is detected it simply jumps to that one instead.
This approach has also be used to allow uploads via webserver (in a simpler form can do it via UART) by booting to a mini uTasker project (under 20k is achievable for a web server based boot loader with NetBIOS and DHCP with this capability on an ARM processor). A mini-project with just UART via SREC will require probably around 8k but is easy to set up. The UART driver also supports message mode which is useful for SREC since it queues complete lines automatically, making the SREC interpreter interface very clean.

So you should find that your preferred method should be possible with out much effort.

Regards

Mark

Offline skyguy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Boot loader for MCF52223
« Reply #2 on: June 22, 2009, 02:12:48 AM »
I'm finally getting around to this project.

I haven't found specific instructions for using the provided configurations for the MCF52223 or M52223EVB.  I've found some posts that suggest I need to use the M52235EVB ROM target but also enable the definition for _M5222X in config.h.  It also looks like I need to disable KIRIN3.  Like this:

From config.h

#ifndef __CONFIG__
#define __CONFIG__

#define MY_PROJECT_NAME     "uTasker Bootloader"

#define BOOT_LOADER                                                      // {4} this ensures that no unnecessary simulation support is required

#define uDisable_Interrupt  __disable_interrupt
#define uEnable_Interrupt   __enable_interrupt

#define TARGET_HW           "Bare-Minimum Boot"

//#define SPI_SW_UPLOAD                                                  // new SW is situated in SPI FLASH {1}{2}
//#define SPI_FLASH_SST25                                                // {15} use SST SPI FLASH rather than ATMEL
//#define SPI_FLASH_ST                                                   // define that we are using ST FLASH rather than default ATMEL {9}
//#define SPI_DATA_FLASH                                                 // FLASH type is data FLASH supporting sub-sectors (relevant for ST types) {9}

//#define KIRIN3                                                           // M5225X family - otherwise remove!

// Specific project builds
#ifndef _BOOT_LOADER_ASSEMBLER
    #ifdef _CODE_WARRIOR_CF
        #pragma const_strings on                                         // ensure strings are of const type
    #endif

    #ifdef _M5223X
      //#define _M5221X                                                  // USB family {10}
        #define _M5222X                                                  // USB family {10}
      //#define _M5225X                                                  // Ethernet/USB family {14}

        #define _MALLOC_ALIGN                                            // support malloc with align option since LAN memory should be on specific boundary
        #define TICK_RESOLUTION        50                                // 50 ms system time period - max possible with M5223X at 60MHz (with prescaler) PIT would be about 70s!



Is that right?  If so, the logic below seems to define the memory for the MCF52221, not the MCF52223.


            #ifndef _M5225X
                #define _M52221                                          // M52221 rather than M52223
            #endif
            #define PLL_OUTPUT_FREQ_INT    48000000                      // run at crystal frequency with no PLL
            #define OSCCLK                 48000000                      // 48 MHz oscillator / crystal input
            #define POST_DIV               1
            #if defined _M5225X                                          // {14}
                #define SIZE_OF_FLASH      (512*1024)                    // M52259 has 512k
                #define SIZE_OF_RAM        (64*1024)
            #elif defined _M52221
                #define SIZE_OF_FLASH      (128*1024)                    // M52221 has 128k
                #define SIZE_OF_RAM        (16*1024)
            #else
                #define SIZE_OF_FLASH      (256*1024)                    // M52223 has 256k
                #define SIZE_OF_RAM        (32*1024)               
            #endif


Hints and guidance to documentation appreciated!

Thanks,

Rick

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Boot loader for MCF52223
« Reply #3 on: June 22, 2009, 01:07:13 PM »
Hi Rick

First I'll describe the configuration of the application project and then the boot project (the second is in fact very similar or even identical)

To configure the project for the MCF52223 the base define _M5223X is needed (this will already be on and it is used to distinguish the Coldfire V2 MCU from any other hardware - the name originates from the first device supported but is nevertheless still used for the basic family).

Then chose the specific device class

  //#define _M521X                                                       // basic CAN MCU
  //#define _M521XX                                                      // basic MCU
  //#define _M5221X                                                      // USB family
    #define _M5222X                                                      // USB family
  //#define _M5225X                                                      // Kirin3


Only one of the possibilities should be selected (note that there may be more possibilities here than in your version).

The next step is to select the board that the chip is on, plus possibly change heap settings:

        #define M52223EVB                                                // EVB Board for M52223
      //#define M52221DEMO                                               // DEMO Board for M52221

        #define OUR_HEAP_SIZE (HEAP_REQUIREMENTS)((6*1024)*MEM_FACTOR)
        #define DEVICE_WITHOUT_ETHERNET                                  // M5222X has USB but no Ethernet


You can select the DEMO or EVAL boards or add your own target define to control setups elsewhere in the project.


The boot loader set up is very similar, where you select _M5222X but don't need to select a board to go with it (unless you want to add one due to specific board related differences).

Your setup is thus basically correct but you need to remove the define _M52221 otherwise it will be for the M52221 - this is used to control this and will set for the larger memory when commented out.



Back to the serial loader itself:
Check out the new document here describing the SREC loader which has been developed in the meantime: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF
There is also a demo at http://www.utasker.com/SW_Demos.html (although not for the M52223 - I will try to add this shortly).
The SREC loader is also dicussed mor ehere: http://www.utasker.com/forum/index.php?topic=587.0
This will be included in the next SP or else contact me directly for a beta project.

Regards

Mark