IAR reset macro for configuring FlexBus

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

IAR reset macro for configuring FlexBus

3,371件の閲覧回数
ryanlush
Contributor IV

I would like to boot code that lives on an external parallel flash. Obviously the FlexBux is not configured yet but I know the debugger calls a few macros when it loads code and I'm pretty sure you can configure it in there.

I don't really know how to do that though... could someone share an example with me?

ラベル(1)
タグ(1)
0 件の賞賛
返信
5 返答(返信)

3,128件の閲覧回数
dereksnell
NXP Employee
NXP Employee

Hi ryanlush‌,

Yes, you can use an IAR macro file, which the debugger executes before running your application.  This can configure external memories and clocks, really any registers, before execution.

One example that comes to mind is for our RT1050 MCU.  The attached macro file initializes the SDRAM and clocks for code execution from SDRAM.  You can see the macro uses 32-bit addresses for all the register writes.  

For the full example, this comes from our SDK for the board evkbimxrt1050, v2.4.1.  You can download it from our MCUXpresso SDK Builder.     Then the IAR project example is found at \SDK_2.4.1\boards\evkbimxrt1050\demo_apps\hello_world\iar

Thanks

0 件の賞賛
返信

3,128件の閲覧回数
ryanlush
Contributor IV

Thank you Derek, here is what I came up with

init_flexbus () {
    __writeMemory32(0x02200000, 0x4000C060, "Memory");    // reg FB_CSPMCR   = 0x02200000
      
    __writeMemory32(0x80000000, 0x4000C000, "Memory");    // reg FB_CSAR0    = 0x80000000
      
    __writeMemory32(0x001115C0, 0x4000C008, "Memory");    // reg FB_CSCR0    = 0x001115C0
    __writeMemory32(0x03FF0001, 0x4000C004, "Memory");    // reg FB_CSMR0    = 0x03FF0001
      
    __writeMemory32(0x00310000, 0x40048044, "Memory");    // reg SIM_CLKDIV1 = 0x00310000
    __writeMemory32(0x00003E00, 0x40048038, "Memory");    // reg SIM_SCGC5   = 0x00003E00
      
    __writeMemory32(0x00000600, 0x40049070, "Memory");    // reg PORTA_PCR28 = 0x600
    __writeMemory32(0x00000600, 0x40049074, "Memory");    // reg PORTA_PCR29 = 0x600

    __writeMemory32(0x00000140, 0x4004A00C, "Memory");    // reg PORTB_PCR3  = 0x140
    __writeMemory32(0x00000100, 0x4004A010, "Memory");    // reg PORTB_PCR4  = 0x100
    __writeMemory32(0x00000500, 0x4004A018, "Memory");    // reg PORTB_PCR6  = 0x500
    __writeMemory32(0x00000500, 0x4004A01C, "Memory");    // reg PORTB_PCR7  = 0x500
    __writeMemory32(0x00000500, 0x4004A020, "Memory");    // reg PORTB_PCR8  = 0x500
    __writeMemory32(0x00000500, 0x4004A024, "Memory");    // reg PORTB_PCR9  = 0x500
    __writeMemory32(0x00000500, 0x4004A028, "Memory");    // reg PORTB_PCR10 = 0x500
    __writeMemory32(0x00000500, 0x4004A02C, "Memory");    // reg PORTB_PCR11 = 0x500
    __writeMemory32(0x00000500, 0x4004A040, "Memory");    // reg PORTB_PCR16 = 0x500
    __writeMemory32(0x00000500, 0x4004A044, "Memory");    // reg PORTB_PCR17 = 0x500
    __writeMemory32(0x00000500, 0x4004A048, "Memory");    // reg PORTB_PCR18 = 0x500
    __writeMemory32(0x00000500, 0x4004A04C, "Memory");    // reg PORTB_PCR19 = 0x500
    __writeMemory32(0x00000500, 0x4004A050, "Memory");    // reg PORTB_PCR20 = 0x500
    __writeMemory32(0x00000500, 0x4004A054, "Memory");    // reg PORTB_PCR21 = 0x500
    __writeMemory32(0x00000500, 0x4004A058, "Memory");    // reg PORTB_PCR22 = 0x500
    __writeMemory32(0x00000500, 0x4004A05C, "Memory");    // reg PORTB_PCR23 = 0x500

    __writeMemory32(0x00000500, 0x4004B000, "Memory");    // reg PORTC_PCR0  = 0x500
    __writeMemory32(0x00000500, 0x4004B004, "Memory");    // reg PORTC_PCR1  = 0x500
    __writeMemory32(0x00000500, 0x4004B008, "Memory");    // reg PORTC_PCR2  = 0x500
    __writeMemory32(0x00000500, 0x4004B010, "Memory");    // reg PORTC_PCR4  = 0x500
    __writeMemory32(0x00000500, 0x4004B014, "Memory");    // reg PORTC_PCR5  = 0x500
    __writeMemory32(0x00000500, 0x4004B018, "Memory");    // reg PORTC_PCR6  = 0x500
    __writeMemory32(0x00000500, 0x4004B01C, "Memory");    // reg PORTC_PCR7  = 0x500
    __writeMemory32(0x00000500, 0x4004B020, "Memory");    // reg PORTC_PCR8  = 0x500
    __writeMemory32(0x00000500, 0x4004B024, "Memory");    // reg PORTC_PCR9  = 0x500
    __writeMemory32(0x00000500, 0x4004B028, "Memory");    // reg PORTC_PCR10 = 0x500
    __writeMemory32(0x00000500, 0x4004B02C, "Memory");    // reg PORTC_PCR11 = 0x500
    __writeMemory32(0x00000500, 0x4004B030, "Memory");    // reg PORTC_PCR12 = 0x500
    __writeMemory32(0x00000500, 0x4004B034, "Memory");    // reg PORTC_PCR13 = 0x500
    __writeMemory32(0x00000500, 0x4004B038, "Memory");    // reg PORTC_PCR14 = 0x500
    __writeMemory32(0x00000500, 0x4004B03C, "Memory");    // reg PORTC_PCR15 = 0x500

    __writeMemory32(0x00000500, 0x4004C004, "Memory");    // reg PORTD_PCR1  = 0x500
    __writeMemory32(0x00000500, 0x4004C008, "Memory");    // reg PORTD_PCR2  = 0x500
    __writeMemory32(0x00000500, 0x4004C00C, "Memory");    // reg PORTD_PCR3  = 0x500
    __writeMemory32(0x00000500, 0x4004C010, "Memory");    // reg PORTD_PCR4  = 0x500
    __writeMemory32(0x00000500, 0x4004C014, "Memory");    // reg PORTD_PCR5  = 0x500
    __writeMemory32(0x00000500, 0x4004C018, "Memory");    // reg PORTD_PCR6  = 0x500
    __writeMemory32(0x00000600, 0x4004C020, "Memory");    // reg PORTD_PCR8  = 0x600
    __writeMemory32(0x00000600, 0x4004C024, "Memory");    // reg PORTD_PCR9  = 0x600
    __writeMemory32(0x00000600, 0x4004C028, "Memory");    // reg PORTD_PCR10 = 0x600
    __writeMemory32(0x00000600, 0x4004C02C, "Memory");    // reg PORTD_PCR11 = 0x600
    __writeMemory32(0x00000600, 0x4004C030, "Memory");    // reg PORTD_PCR12 = 0x600
    __writeMemory32(0x00000600, 0x4004C034, "Memory");    // reg PORTD_PCR13 = 0x600
    __writeMemory32(0x00000600, 0x4004C038, "Memory");    // reg PORTD_PCR14 = 0x600
    __writeMemory32(0x00000600, 0x4004C03C, "Memory");    // reg PORTD_PCR15 = 0x600

    __message "init_flexbus() done.\n";
}

execUserPreload()
{
  init_flexbus();   

  __message "execUserReset() done.\n";
}

It appears to run the script and I don't see any errors but it's not writing to my parallel flash either. I did a spot check on SIM_CLKDIV1 and the value I wrote in the script didn't take. Any idea what I'm doing wrong?

0 件の賞賛
返信

3,128件の閲覧回数
dereksnell
NXP Employee
NXP Employee

Hi Ryan,

The macro only initializes the FlexBus and registers. If you want to write to external flash, you need a flash programming algorithm. It is code that executes on the MCU, takes data written by debugger, and writes to external flash using FlexBus. Similar to how the internal flash is programmed.

IAR has examples and details for creating flash programming algorithms. But I'll have to look later to point you to something specific.

0 件の賞賛
返信

3,128件の閲覧回数
ryanlush
Contributor IV

Well shucks, I assumed it would be the same algorithm it uses for internal flash. With CodeWarrior you only need to configure the FlexBus.

I wasn’t able to find anything for parallel flash in the IAR directory so I would appreciate you looking when you have time.

Thank you,

Ryan

(sent from mobile device)

0 件の賞賛
返信

3,128件の閲覧回数
dereksnell
NXP Employee
NXP Employee

Hi Ryan,

Since the code needed to program the internal flash is different than the code to program external flash on FlexBus, even CodeWarrior uses different flash programming algorithms.

For IAR, I found the attached document for using and creating a flash loader. This is installed with IAR at C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.22.2\arm\doc\FlashLoaderGuide.ENU.pdf

Best regards

0 件の賞賛
返信