This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] AM2632:当有两个任务运行 Flash_nandGpmcRead () 时、我们如何成功读取 nand 闪存

Guru**** 2695575 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1596022/am2632-how-can-we-read-nand-flash-successfully-when-there-are-two-tasks-run-flash_nandgpmcread

器件型号: AM2632

我们有两个任务都需要运行 Flash_nandGpmcRead ()。

有一个系统无法成功运行的场景。 第一个任务需要运行 Flash_nandGpmcRead () 一秒钟、同时第二个任务需要运行 Flash_nandGpmcRead ()。

那么、我们如何解决这个问题呢?

 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Wei:

    GPMC(通用存储器控制器)硬件接口为 共享资源 一次只能处理一个事务。 当两个任务尝试同时从 NAND 闪存读取时:

    • GPMC 控制器状态机可能损坏

    其他参数类型 互斥 (互斥量)或 基于信标的保护 NAND 闪存访问操作。 以下是解决此问题的方法:

    其他参数类型 互斥 (互斥量)或 基于信标的保护 NAND 闪存访问操作。 以下是解决此问题的方法:

    /* Create a mutex for NAND flash access */
    SemaphoreP_Object gNandFlashMutex;
    
    /* Initialize the mutex during system initialization */
    void initNandFlashProtection(void)
    {
        SemaphoreP_Params semParams;
        
        SemaphoreP_Params_init(&semParams);
        semParams.mode = SemaphoreP_Mode_BINARY;  /* Binary semaphore acts as mutex */
        
        SemaphoreP_construct(&gNandFlashMutex, 1, &semParams);  /* Initial count = 1 */
    }
    
    /* Wrapper function for protected NAND read */
    int32_t protectedNandFlashRead(uint32_t offset, uint8_t *buf, uint32_t len)
    {
        int32_t status;
        
        /* Acquire mutex before accessing flash */
        SemaphoreP_pend(&gNandFlashMutex, SystemP_WAIT_FOREVER);
        
        /* Perform the actual flash read operation */
        status = Flash_nandGpmcRead(offset, buf, len);
        
        /* Release mutex after operation completes */
        SemaphoreP_post(&gNandFlashMutex);
        
        return status;
    }

    --
    此致、
    Jagadish。