Skip to main content
Visitor II
December 7, 2011
Question

STR912: problem writing boot code to Bank0

  • December 7, 2011
  • 15 replies
  • 2828 views
Posted on December 07, 2011 at 22:48

Okay, I've learned how to move code to Bank1, and it executes properly.

After having some problems getting bank1 booting to work, we decided to instead try copying our firmware into an external Flash chip and validate it, then switch to code which is entirely in Bank1, to write from the external flash back into bank0.

I first wrote and tested code to enable unused sectors in Bank1 and write/verify code; this works fine.

Now I'm trying to write code from Ext Flash to bank0:

//**************************************************************************************************

u8 *src = (u8 *) ALT_FEPROM ;

u8 *dest = (u8 *) (0) ; // Bank0 Sector 0

bytes_remaining = datum[0] ;

unsigned flags = disable_IRQ(); // make sure nothing tries to execute from bank0 !!

set_led_green_on() ;

while (LOOP_FOREVER) {

wlen = (bytes_remaining > SIZE_64K) ? SIZE_64K : bytes_remaining ;

// this function is executing successfully...

if (feprom_program_enable_bank0(dest, BANK0_FM) == FALSE) {

break;

}

set_led_red_on() ;

delay_250msec(4) ;

u32 u32SectorAddr;

// if the physical address does not belong to any of the internal flash sectors, fail.

if (!bank0_bGetBankSecAddrByPhyAddr((uint) dest, &u32SectorAddr, NULL)) {

break;

}

// 12/07/11 - here is the show-stopper...

// If I call this function, which writes to two registers in the internal flash-programming interface,

// the sector erase proceeds successfully, but the code never returns to here...

bank0_EraseSector(u32SectorAddr); // Erase the sector

//**************************************************************************************************

However, as the comments reflect, the sector-erase function never returns.

I used OpenOCD via the JTAG interface, to look at bank0 space after the crash, and it appears that the erase *did* occur, but the function never returns.

bank0_EraseSector() contains only two writes to the STR9 CUI interface:

//**************************************************************************************************

static void bank0_EraseSector(vu32 FMI_Sector)

{

/* Write an erase set-up command to the sector */

*(vu16 *)FMI_Sector = 0x20;

/* Write an erase confirm command to the sector */

*(vu16 *)FMI_Sector = 0xD0;

}

//**************************************************************************************************

So why does this crash? What else do I need to do to make this work?

I tried remapping bank1 to boot bank and bank0 to non-boot bank, using

// FMI_BankRemapConfig(0, 6, 0x80000, 0) ; // this crashes the board immediately!!

but that doesn't work either...

Our system: STR912 512K/32K
    This topic has been closed for replies.

    15 replies

    Visitor II
    June 19, 2012
    Posted on June 19, 2012 at 09:46

    can you verify sector protection disabled after you disable it?

    Visitor II
    June 21, 2012
    Posted on June 21, 2012 at 10:13

    Address 0x80000 and 0x82000 will lie in the same sector of BANK 0 ie. B0S1, I am disabling the sector protection for this sector in the beginning, if sector protection was not disabled how could i have been able to write ox80000 to 0x81fff.  

    Visitor II
    June 21, 2012
    Posted on June 21, 2012 at 13:30

    i got mixed up.  our memory map has bank1 at 80000.  and the sector size is 8k.

    but curiously it seems to behave like that for you?

    Visitor II
    June 22, 2012
    Visitor II
    June 25, 2012
    Posted on June 25, 2012 at 06:48

    just a clarification.  have you used caps or another tool (we also use rlink) to test writing to bank0/bank1 via jtag?  and successfully write to all sectors?  for example in caps there is a section to enable/disable sector protections.