Changeset a67aab6 in rtems


Ignore:
Timestamp:
05/19/23 17:47:32 (7 months ago)
Author:
Kinsey Moore <kinsey.moore@…>
Branches:
master
Children:
4ca43110
Parents:
b296708
git-author:
Kinsey Moore <kinsey.moore@…> (05/19/23 17:47:32)
git-committer:
Joel Sherrill <joel@…> (06/08/23 14:48:44)
Message:

bsps/xqspipsu: Ensure NOR writes align

This change causes NOR writes to be broken according to page boundaries.
Writes across page boundaries cause the writes beyond the boundary to
fail silently. This also introduces a new function that will explicitly
write pages.

Location:
bsps
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bsps/include/dev/spi/xqspipsu-flash-helper.h

    rb296708 ra67aab6  
    5050 *
    5151 ******************************************************************************/
     52int QspiPsu_NOR_Write_Page(
     53  XQspiPsu *QspiPsuPtr,
     54  u32 Address,
     55  u32 ByteCount,
     56  u8 *WriteBfrPtr
     57);
     58
     59/*****************************************************************************/
     60/**
     61 *
     62 * This function writes to the serial Flash connected to the QSPIPSU interface.
     63 * Writes will be broken into device page sized and aligned writes as necessary.
     64 *
     65 * @param       QspiPsuPtr is a pointer to the QSPIPSU driver component to use.
     66 * @param       Address contains the address to write data to in the Flash.
     67 * @param       ByteCount contains the number of bytes to write.
     68 * @param       WriteBfrPtr is pointer to the write buffer (which is to be transmitted)
     69 *
     70 * @return      XST_SUCCESS if successful, else XST_FAILURE.
     71 *
     72 * @note        None.
     73 *
     74 ******************************************************************************/
    5275int QspiPsu_NOR_Write(
    5376  XQspiPsu *QspiPsuPtr,
    5477  u32 Address,
    5578  u32 ByteCount,
    56         u8 *WriteBfrPtr
     79  u8 *WriteBfrPtr
    5780);
    5881
  • bsps/shared/dev/spi/xqspipsu-flash-helper.c

    rb296708 ra67aab6  
    334334}
    335335
    336 int QspiPsu_NOR_Write(
     336int QspiPsu_NOR_Write_Page(
    337337  XQspiPsu *QspiPsuPtr,
    338338  u32 Address,
     
    474474
    475475  return 0;
     476}
     477
     478int QspiPsu_NOR_Write(
     479  XQspiPsu *QspiPsuPtr,
     480  u32 Address,
     481  u32 ByteCount,
     482  u8 *WriteBfrPtr
     483)
     484{
     485  int Status;
     486  size_t ByteCountRemaining = ByteCount;
     487  unsigned char *WriteBfrPartial = WriteBfrPtr;
     488  uint32_t AddressPartial = Address;
     489  uint32_t PageSize = Flash_Config_Table[FCTIndex].PageSize;
     490  if(QspiPsuPtr->Config.ConnectionMode == XQSPIPSU_CONNECTION_MODE_PARALLEL) {
     491    PageSize *= 2;
     492  }
     493
     494  while (ByteCountRemaining > 0) {
     495    /* Get write boundary */
     496    size_t WriteChunkLen = RTEMS_ALIGN_UP(AddressPartial + 1, PageSize);
     497
     498    /* Get offset to write boundary */
     499    WriteChunkLen -= (size_t)AddressPartial;
     500
     501    /* Cap short writes */
     502    if (WriteChunkLen > ByteCountRemaining) {
     503      WriteChunkLen = ByteCountRemaining;
     504    }
     505
     506    Status = QspiPsu_NOR_Write_Page(
     507      QspiPsuPtr,
     508      AddressPartial,
     509      WriteChunkLen,
     510      WriteBfrPartial
     511    );
     512    if ( Status != XST_SUCCESS ) {
     513      return Status;
     514    }
     515
     516    ByteCountRemaining -= WriteChunkLen;
     517    AddressPartial += WriteChunkLen;
     518    WriteBfrPartial += WriteChunkLen;
     519  }
     520  return Status;
    476521}
    477522
Note: See TracChangeset for help on using the changeset viewer.