AnsweredAssumed Answered

BF514 bfrom_SpiBoot fails to boot Firmware from SPI Flash

Question asked by dro on Nov 14, 2014
Latest reply on Jan 14, 2016 by robart23

Hi,

 

I have a strange problem the Boot mechanism of the BF514 DSP.

I use a custom bootloader to update my firmware. The bootloader loads the firmware

into the external SDRam checks the CRC and then writes the Firmware into the Flash (Spansion S25FL116K).

After that I read the firmware that it was just written and compare it, to make sure that writing in flash was correct.

If it is correct that I boot the application from Flash by calling bfrom_SpiBoot. The problem is that this worked until now.

I have to make some changes i the Firmware and when I do this changes and flash the firmware into the BF, the device

is not booting anymore and it stuck in the bfrom_SpiBoot function. If I revert this changes it works again .

 

I already debugged throw the bfrom_SpiBoot function and I saw that the at a moment, the DMA is configured to receive data from SPI and

after that the SPI controller set the bit RBSY. After that nothing work anymore.

 

#define SPI0_BAUDRATE                 5000

 

Spi0_Init(SPI0_BAUDRATE);

 

bfrom_SpiBoot( 0x1A000,

      BFLAG_PERIPHERAL | BFLAG_TYPE | BFLAG_NOAUTO | BFLAG_FASTREAD | 0x04,

      0,

      NULL);

 

 

void Spi0_Init(unsigned long const baudrate)

{

  // SCK frequency = (peripheral clock frequency SCLK)/(2 × SPI_BAUD)

  unsigned short baudDiv = (SCLK_MHZ*500000)/baudrate;  // 40 ... f_spi = 1MHz bei SCLK = 80MHz

 

  *pSPI0_CTL    = 0x00;

 

  // Enable peripheral function

  *pPORTG_FER   |= (SPI0_SCK|SPI0_MISO|SPI0_MOSI);//|SPI0_SSEL2);

 

  *pSPI0_BAUD = baudDiv;

 

  *pPORTFIO_DIR |= SPI0_SSEL1;

  *pPORTGIO_DIR |= SPI0_SSEL2;

  *pPORTHIO_DIR |= SPI0_SSEL3;

  Spi0_DisableSlave();

 

  *pSPI0_STAT |= TXE | RBSY; // clear spi error flags

  *pSPI0_CTL = 0;

  *pSPI0_STAT &= ~MODF; // reset mode fault flag

  // enable spi in master mode and set transfer initiation to rdbr read

  *pSPI0_CTL = (SPE | MSTR | 0x01);

  ssync();

}

Outcomes