Difficulties with the USB MSD bootloader

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Difficulties with the USB MSD bootloader

1,020件の閲覧回数
Pastrav
Contributor I

Hello,

 

I'm currently trying to make a project written for the MCF52259 Eval Board compatible with the USB Mass storage device bootloader supplied by Freescale. I have read the documentation for the bootloader as well as application note AN3927 ("Freescale S08 USB Mass Storage Device Bootloader") which describes the bootloader in detail and even gives step-by step guide to making a project compatible with it.

 There are 2 problems that prevent me from accomplishing this task:

 

   1. I don't have experience regarding the linker command file (LCF) and I have troubles adapting the current Linker file structure into what the application note recommends.

To make things clear: my project's memory structure is defined this way:

 

MEMORY {
vectorrom (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000020
code (RX) : ORIGIN = 0x00000500, LENGTH = 0x0007FB00
vectorram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
userram (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00005C00
} - just as described in application note AN4329 ("Relocating Code and Data Using the CodeWarrior Linker Command File (LCF) for ColdFire Architecture")

 

 and bootloader-compatible LCF's memory structure looks like this:

{
vectorflash(RX) : ORIGIN = 0x00000000, LENGTH = 0x00000418
bootcode (RX): ORIGIN = 0x00000420, LENGTH = 0x00003BE0
flash (RX) : ORIGIN = 0x00004010, LENGTH = 0x0007BFF0
vectorram(RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
sram (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00005A00
ipsbar (RWX) : ORIGIN = 0x40000000, LENGTH = 0x0
}

 And although some sections have similar structure and sizes, they aren't identical and I don't know which should I keep and what to do with the other sections.

 

2. The files in the Application note don't match the ones in the 'MCF5225x Bootloader_1.2' archive:

instead of having 'mcf5225x_vectors.s' i have 'exceptions.c' (which seems to be written for V1 MCFs, despite the lab being about '5225x') and 'V2_Bootloader.lib' is missing completely. Also the project I'm working on already has the file 'exceptions.c', which I've replaced with the new one - but I've got no idea if they're compatible.

 

 I know this issue might seem trivial but I'm treading new grounds and I can't get over this without some help. So if you have any thoughts on this please share them !

Thanks for reading :smileyhappy:

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

674件の閲覧回数
FridgeFreezer
Senior Contributor I

You'll find with the first one that the CFM protection bits are included in mcf5225x_vectors.s, mine looks like this:

 

/* * File: vectors.s * Purpose: MCF5225x vector table *  * License:     All software covered by license agreement in - *              docs/Freescale_Software_License.pdf */#ifdef __GNUC__ /* { */#define sr %sr#define _asm_exception_handler      irq_handler#define _timer_handler    timer_handler#endif /* } __GNUC__ */ .global VECTOR_TABLE .global _VECTOR_TABLE .global start .extern ___SP_INIT .extern _asm_startmeup .extern _asm_exception_handler// .extern __Entry .text/* * Exception Vector Table */VECTOR_TABLE:_VECTOR_TABLE:INITSP:  .long ___SP_INIT    /* Initial SP   */INITPC:  .long _asm_startmeup   /* Initial PC   *///INITPC:  .long __Entry     /* Initial PC   */vector02: .long _asm_exception_handler /* Access Error   */vector03: .long _asm_exception_handler /* Address Error  */vector04: .long _asm_exception_handler /* Illegal Instruction */vector05: .long _asm_exception_handler /* Reserved    */vector06: .long _asm_exception_handler /* Reserved    */vector07: .long _asm_exception_handler /* Reserved    */vector08: .long _asm_exception_handler /* Privilege Violation */vector09: .long _asm_exception_handler /* Trace    */vector0A: .long _asm_exception_handler /* Unimplemented A-Line */vector0B: .long _asm_exception_handler /* Unimplemented F-Line */vector0C: .long _asm_exception_handler /* Debug Interrupt  */vector0D: .long _asm_exception_handler /* Reserved    */vector0E: .long _asm_exception_handler /* Format Error   */vector0F: .long _asm_exception_handler /* Unitialized Int.  */vector10: .long _asm_exception_handler /* Reserved    */vector11: .long _asm_exception_handler /* Reserved    */vector12: .long _asm_exception_handler /* Reserved    */vector13: .long _asm_exception_handler /* Reserved    */vector14: .long _asm_exception_handler /* Reserved    */vector15: .long _asm_exception_handler /* Reserved    */vector16: .long _asm_exception_handler /* Reserved    */vector17: .long _asm_exception_handler /* Reserved    */vector18: .long _asm_exception_handler /* Spurious Interrupt */vector19: .long _asm_exception_handler /* Autovector Level 1 */vector1A: .long _asm_exception_handler /* Autovector Level 2 */vector1B: .long _asm_exception_handler /* Autovector Level 3 */vector1C: .long _asm_exception_handler /* Autovector Level 4 */vector1D: .long _asm_exception_handler /* Autovector Level 5 */vector1E: .long _asm_exception_handler /* Autovector Level 6 */vector1F: .long _asm_exception_handler /* Autovector Level 7 */vector20: .long _asm_exception_handler /* TRAP #0    */vector21: .long _asm_exception_handler /* TRAP #1    */vector22: .long _asm_exception_handler /* TRAP #2    */vector23: .long _asm_exception_handler /* TRAP #3    */vector24: .long _asm_exception_handler /* TRAP #4    */vector25: .long _asm_exception_handler /* TRAP #5    */vector26: .long _asm_exception_handler /* TRAP #6    */vector27: .long _asm_exception_handler /* TRAP #7    */vector28: .long _asm_exception_handler /* TRAP #8    */vector29: .long _asm_exception_handler /* TRAP #9    */vector2A: .long _asm_exception_handler /* TRAP #10    */vector2B: .long _asm_exception_handler /* TRAP #11    */vector2C: .long _asm_exception_handler /* TRAP #12    */vector2D: .long _asm_exception_handler /* TRAP #13    */vector2E: .long _asm_exception_handler /* TRAP #14    */vector2F: .long _asm_exception_handler /* TRAP #15    */vector30: .long _asm_exception_handler /* Reserved    */vector31: .long _asm_exception_handler /* Reserved    */vector32: .long _asm_exception_handler /* Reserved    */vector33: .long _asm_exception_handler /* Reserved    */vector34: .long _asm_exception_handler /* Reserved    */vector35: .long _asm_exception_handler /* Reserved    */vector36: .long _asm_exception_handler /* Reserved    */vector37: .long _asm_exception_handler /* Reserved    */vector38: .long _asm_exception_handler /* Reserved    */vector39: .long _asm_exception_handler /* Reserved    */vector3A: .long _asm_exception_handler /* Reserved    */vector3B: .long _asm_exception_handler /* Reserved    */vector3C: .long _asm_exception_handler /* Reserved    */vector3D: .long _asm_exception_handler /* Reserved    */vector3E: .long _asm_exception_handler /* Reserved    */vector3F: .long _asm_exception_handler /* Reserved    */vector40: .long _asm_exception_handler // User Interrupt 0vector41: .long _asm_exception_handler // ...vector42: .long _asm_exception_handlervector43: .long _asm_exception_handlervector44: .long _asm_exception_handlervector45: .long _asm_exception_handlervector46: .long _asm_exception_handlervector47: .long _asm_exception_handlervector48: .long _asm_exception_handlervector49: .long _asm_exception_handlervector4A: .long _asm_exception_handlervector4B: .long _asm_exception_handlervector4C: .long _asm_exception_handlervector4D: .long _asm_exception_handlervector4E: .long _asm_exception_handlervector4F: .long _asm_exception_handlervector50: .long _asm_exception_handlervector51: .long _asm_exception_handlervector52: .long _asm_exception_handlervector53: .long _asm_exception_handlervector54: .long _asm_exception_handlervector55: .long _asm_exception_handlervector56: .long _asm_exception_handlervector57: .long _asm_exception_handlervector58: .long _asm_exception_handlervector59: .long _asm_exception_handlervector5A: .long _asm_exception_handlervector5B: .long _asm_exception_handlervector5C: .long _asm_exception_handlervector5D: .long _asm_exception_handlervector5E: .long _asm_exception_handlervector5F: .long _asm_exception_handlervector60: .long _asm_exception_handlervector61: .long _asm_exception_handlervector62: .long _asm_exception_handlervector63: .long _asm_exception_handlervector64: .long _asm_exception_handlervector65: .long _asm_exception_handlervector66: .long _asm_exception_handlervector67: .long _asm_exception_handlervector68: .long _asm_exception_handlervector69: .long _asm_exception_handlervector6A: .long _asm_exception_handlervector6B: .long _asm_exception_handlervector6C: .long _asm_exception_handlervector6D: .long _asm_exception_handlervector6E: .long _asm_exception_handlervector6F: .long _asm_exception_handlervector70: .long _asm_exception_handlervector71: .long _asm_exception_handlervector72: .long _asm_exception_handlervector73: .long _asm_exception_handlervector74: .long _asm_exception_handlervector75: .long _asm_exception_handlervector76: .long _asm_exception_handlervector77: .long _asm_exception_handlervector78: .long _asm_exception_handlervector79: .long _asm_exception_handlervector7A: .long _asm_exception_handlervector7B: .long _asm_exception_handlervector7C: .long _asm_exception_handlervector7D: .long _asm_exception_handlervector7E: .long _asm_exception_handlervector7F: .long _asm_exception_handler vector80: .long _asm_exception_handlervector81: .long _asm_exception_handlervector82: .long _asm_exception_handlervector83: .long _asm_exception_handlervector84: .long _asm_exception_handlervector85: .long _asm_exception_handlervector86: .long _asm_exception_handlervector87: .long _asm_exception_handlervector88: .long _asm_exception_handlervector89: .long _asm_exception_handlervector8A: .long _asm_exception_handlervector8B: .long _asm_exception_handlervector8C: .long _asm_exception_handlervector8D: .long _asm_exception_handlervector8E: .long _asm_exception_handlervector8F: .long _asm_exception_handlervector90: .long _asm_exception_handlervector91: .long _asm_exception_handlervector92: .long _asm_exception_handlervector93: .long _asm_exception_handlervector94: .long _asm_exception_handlervector95: .long _asm_exception_handlervector96: .long _asm_exception_handlervector97: .long _asm_exception_handlervector98: .long _asm_exception_handlervector99: .long _asm_exception_handlervector9A: .long _asm_exception_handlervector9B: .long _asm_exception_handlervector9C: .long _asm_exception_handlervector9D: .long _asm_exception_handlervector9E: .long _asm_exception_handlervector9F: .long _asm_exception_handlervectorA0: .long _asm_exception_handlervectorA1: .long _asm_exception_handlervectorA2: .long _asm_exception_handlervectorA3: .long _asm_exception_handlervectorA4: .long _asm_exception_handlervectorA5: .long _asm_exception_handlervectorA6: .long _asm_exception_handlervectorA7: .long _asm_exception_handlervectorA8: .long _asm_exception_handlervectorA9: .long _asm_exception_handlervectorAA: .long _asm_exception_handlervectorAB: .long _asm_exception_handlervectorAC: .long _asm_exception_handlervectorAD: .long _asm_exception_handlervectorAE: .long _asm_exception_handlervectorAF: .long _asm_exception_handlervectorB0: .long _asm_exception_handlervectorB1: .long _asm_exception_handlervectorB2: .long _asm_exception_handlervectorB3: .long _asm_exception_handlervectorB4: .long _asm_exception_handlervectorB5: .long _asm_exception_handlervectorB6: .long _asm_exception_handlervectorB7: .long _asm_exception_handlervectorB8: .long _asm_exception_handlervectorB9: .long _asm_exception_handlervectorBA: .long _asm_exception_handlervectorBB: .long _asm_exception_handlervectorBC: .long _asm_exception_handlervectorBD: .long _asm_exception_handlervectorBE: .long _asm_exception_handlervectorBF: .long _asm_exception_handler    .org 0x400/*  * CFM Flash Configuration Field  */ /* * NOTE: This data controls the flash, including read/write protect * It must be left at the end of the vector table (0x400). */ KEY_UPPER:  .long   0x00000000KEY_LOWER:  .long   0x00000000//CFMPROT:    .long   0x00000001 // Was 0x00000000 (all unprotected), now bottom (boot) block is protectedCFMPROT:    .long   0xFFFFFFFF // Protect all flash (ah -ah!) by defaultCFMSACC:    .long   0x00000000CFMDACC:    .long   0x00000000CFMSEC:     .long   0x00000000/********************************************************************/ .end

 

That means the vectorflash section is 0x418 long and includes the cfmprotrom 0x20 bytes. A bit confusing, as with most of freescale's stuff they don't really document what's going on, where is the "correct" place to put this data, etc. and change their minds with every release of anything.

 

You'll notice a couple of changes there, we had some problems with the CFM & bootloader (here: https://community.freescale.com/message/85288#85288 with the processor doing things the data sheet says it shouldn't - to put it another way, make sure you protect all of the CFM anytime you're not flashing it otherwise you *will* lose data, regardless of what the manual says. There's also issues with the timings and executing code from RAM or not.

 

There is some info on the LCF format here:

https://community.freescale.com/message/96410#96410

 

Application note AN4329 ia quite useful too.

 

Hope this lot helps!

0 件の賞賛
返信

674件の閲覧回数
Pastrav
Contributor I

 

 Thank you very muh for the detailed answer.

I'll try out again and see what I can do :smileyhappy:

0 件の賞賛
返信

674件の閲覧回数
Leong
Contributor III

a few tips since i'm going through bootloader stuff too. 1. keep the map file and check against the lcf. 2. stop in the debugger and view memory. some time one line of misalignment screw things up....

0 件の賞賛
返信