Post Go back to editing

L1 scratchpad for stack and RSI issues: bug in example rsi.c for BF504 (and possibly others)


The example code to work with SD cards is using automatic variables (uint8_t buffer[8];) for DMA buffers. Of course, when the stack is in the scratchpad memory, that can't work.

Since the example code is very likely to be used as a basis for other applications, you might want to consider either making the buffer global or at least putting a big fat warning about the necessity to keep all DMA buffers out of automatic variables. I can also recommend adding a runtime assertion to ensure the address passed is in the right range.

It's likely that other drivers might suffer from similar problems so a more thorough investigation might be necessary.

Best regards.

  • Hi,

    Can you confirm that you are referring to the POST example for the BF506F EZ-KIT Lite? If this is the case, I can enter an enhancement request so it can be considered for the future.

    Note that it may be beyond the scope of the examples to reiterate limitations - such as performing DMA from scratchpad - that are documented elsewhere.



  • for example


    static uint32_t sd_mmc_get_sd_scr_register(void)


        uint32_t error = 0;

        uint8_t buffer[8];

        *pRSI_DATA_LGTH = 8;


        error = sd_mmc_send_command(SD_MMC_CMD_SEND_STATUS,<<16);



            error = sd_mmc_send_command(   SD_MMC_CMD_SELECT_DESELECT_CARD,



    // DMA call here

        SDBlockRead((void *)&buffer[0], 8);

  • We declared them global and make static like this

    static uint8_t          dma_buffer[64];

    then remove    

    uint8_t buffer[8];

    or uint8_t buffer[64];

    from functions static uint32_t sd_mmc_get_sd_scr_register(void), static uint32_t sd_mmc_get_sd_ssr_register(void) and so on

  • Thanks for the feedback. As I said, I'll log this as an enhancement request.

    Thanks again,