• AVR Freaks

Hot!Many bugs Harmony V3 SST26 (SQI) and MPFS file system

Author
boatbodger
Starting Member
  • Total Posts : 53
  • Reward points : 0
  • Joined: 2011/03/27 15:39:07
  • Location: 0
  • Status: offline
2019/10/24 17:35:24 (permalink)
0

Many bugs Harmony V3 SST26 (SQI) and MPFS file system

Bug 1: Upload does not complete:
I am finding that the MPFS Upload stalls because after the first call to SYS_FS_MEDIA_MANAGER_SectorWrite() subsequent calls to SYS_FS_MEDIA_MANAGER_CommandStatusGet() never return with SYS_FS_MEDIA_COMMAND_COMPLETED.
They always return 0xFFFF
I believe this is because the means of the DMA notifying completion "up the stack" may be broken.
I notice that the Harmony Configuration tool has set the following:
    .isMemDevInterruptEnabled = false,

which would seem to me to be wrong, as whilst the memory chip itself does not have an interrupt line, the DMA driving it *can* interrupt to say "done it, boss".
Does anybody know whether I should alter this setting?
The symptoms may look slightly similar to another post with a similar title, but Luciano's post appears to derive from problems with cache issues - I don't think that's the case for this particular problem - although I guess I may run into that later.
 
post edited by boatbodger - 2019/11/05 10:44:29
#1

7 Replies Related Threads

    boatbodger
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2011/03/27 15:39:07
    • Location: 0
    • Status: offline
    Re: Bug 1 Harmony SST26 (SQI) and MPFS file system - upload writes never complete 2019/11/04 11:12:37 (permalink)
    5 (1)
    I eventually traced this to a bug in drv_memory.c.
    There needs to be a 'break' at line 579 to prevent fall-through to the READ_SECTOR label, as a) reading is un-necessary (because we're at page erase boundaries) and b) there is not enough read buffer declared (by default) to hold a whole erase chunk - 4096 bytes.  So if you *do* fall through to READ_SECTOR the next thing that happens is that HandleRead fails.
    post edited by boatbodger - 2019/11/05 10:45:45
    #2
    boatbodger
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2011/03/27 15:39:07
    • Location: 0
    • Status: offline
    Re: Many bugs Harmony V3 SST26 (SQI) and MPFS file system - Bug 2 2019/11/05 10:47:47 (permalink)
    0
    Bug 2: File system not recognised on mount
    This is because by default Harmony uses a different volume name for an external SQI volume and for an Program Flash volume.  Modify configuration.h to use the volume name "mtda1" for the web server volume to fix this.
    post edited by boatbodger - 2019/11/05 10:51:09
    #3
    boatbodger
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2011/03/27 15:39:07
    • Location: 0
    • Status: offline
    Re: Many bugs Harmony V3 SST26 (SQI) and MPFS file system - Bug 3 2019/11/05 10:49:53 (permalink)
    0
    Bug 3: Problems within the MPFS.c module on mounting (previous one was in sys_fs)
    For some reason, when MPFS calls SYS_FS_MEDIA_MANAGER_Read(), the buffer address it gives does not receive the data from the DMA-driven SST26.
    This turns out to be because - by default - variables are located in cached memory (which - on the PIC32MZ - starts at virtual address 0x8000_000).  The DMA does not have write-access to the CPU cache, so it all goes horribly wrong.
    Using the macro CACHE_ALIGN (which is defined in toolchain_specifics.h) pulls in the __attribute__(( coherence )) to the variable, and then the DMA reads work correctly.
    so change:
    static MPFS_FILE_OBJ gSysMpfsFileObj[SYS_FS_MAX_FILES];

    to read
    static MPFS_FILE_OBJ CACHE_ALIGN gSysMpfsFileObj[SYS_FS_MAX_FILES];

    and similarly treat gSysMpfsFileRecord and gSysMpfsObj
    Then things start to work...
     
    post edited by boatbodger - 2019/11/06 04:51:44
    #4
    boatbodger
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2011/03/27 15:39:07
    • Location: 0
    • Status: offline
    Re: Many bugs Harmony V3 SST26 (SQI) and MPFS file system 2019/11/05 10:58:15 (permalink)
    0
    Bug 4 (or Feature 1):
    You need to use the right mpfs generator.  Version 3.3.5 seems to generate files of a format acceptable to the mpfs2 system.  Version 3.3.0 does not, as far as I can tell.  Both are in the same folder, and 3.3.5 has an earlier date than 3.3.0.
    Version 3.3.0 has more buttons (includes dsPic24 and MDD, whatever that is).
      Go figure.
    #5
    boatbodger
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2011/03/27 15:39:07
    • Location: 0
    • Status: offline
    Re: Many bugs Harmony V3 SST26 (SQI) and MPFS file system - Bug 3 2019/11/20 01:38:53 (permalink)
    0
    I continued to have problems with the MPFS accessing SQU when not reading multiples of 4 bytes and/or not wanting the result to turn up on an aligned boundary.
    As I didn't have time to dig deep into the DMA operation I used brute force and ignorance by changing the function MPFSDiskRead in the source file mpfst.c so that it checks for these mis-aligned conditions, and if it detects them, reads to a local aligned buffer from an aligned byte then copies the relevant area from that buffer to the caller's buffer. 
    I also added a "stumble on if the DMA interrupt fails to arrive" facility (see loopcounter below), as the original of mpfs2 has an infinite wait loop for that - and I really really don't like it when microcontrollers hang forever...
     
    Code now reads:
    static bool MPFSDiskRead
    (
        uint16_t diskNum,
        uint8_t *destination,
        uint8_t *source, //Note: This is cast into an "address" (for possible use as an NVM address) in the fsmedia managr)
        const uint32_t nBytes
    )
    {
        uint32_t loopcounter;
        uint8_t *tempdest;
        uint32_t templength;
        SYS_FS_MEDIA_BLOCK_COMMAND_HANDLE commandHandle = SYS_FS_MEDIA_BLOCK_COMMAND_HANDLE_INVALID;
        SYS_FS_MEDIA_COMMAND_STATUS commandStatus = SYS_FS_MEDIA_COMMAND_UNKNOWN;

        source += FILE_SYSTEM_START;
        if (((uint32_t)destination & 0x1) || (nBytes & 0x3)){

            tempdest = aligned_buffer;
            templength = (nBytes+3) & 0xFFFC;
     
        }
        else {
            tempdest = destination;
            templength = nBytes;

        }
        commandHandle = SYS_FS_MEDIA_MANAGER_Read (diskNum, tempdest, source, templength);

        if (commandHandle == SYS_FS_MEDIA_BLOCK_COMMAND_HANDLE_INVALID)
        {
            return false;
        }
        loopcounter = 0;
        commandStatus = SYS_FS_MEDIA_MANAGER_CommandStatusGet(diskNum, commandHandle);

        while ( (commandStatus == SYS_FS_MEDIA_COMMAND_IN_PROGRESS) ||
                (commandStatus == SYS_FS_MEDIA_COMMAND_QUEUED))
        {
            SYS_FS_MEDIA_MANAGER_TransferTask (diskNum); //Ensure disk tasks can "clear"
            commandStatus = SYS_FS_MEDIA_MANAGER_CommandStatusGet(diskNum, commandHandle);
            if (++loopcounter == 1000000){
                UDP_PRINT("NO INT!\n\r");
                return true; //Which is a foul and contemptible lie
            }
        }
        if (((uint32_t)destination & 0x1) || (nBytes & 3)){
            memcpy((void *)destination, aligned_buffer,nBytes);
        }
        return (commandStatus == SYS_FS_MEDIA_COMMAND_COMPLETED) ? true : false;
    }

    post edited by boatbodger - 2019/11/20 01:41:30
    #6
    friesen
    Super Member
    • Total Posts : 2085
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    Re: Many bugs Harmony V3 SST26 (SQI) and MPFS file system - Bug 3 2019/11/20 14:51:39 (permalink)
    0
    I think the 4 byte thing is really a different bug.  Its a bit foggy, but I did a bunch of work to the sqi and etc driver on v 2.04 to get it to do what I needed.  I think perhaps it was partially related to caching, and something else as well.
     
    Also, it really needs to be polled properly if you are using an rtos, as 2.04 stands it checks for finish every tick, which isn't very fast.
     
    https://bitbucket.org/erikfriesen/harmony-2.04/src/master/
     
    https://bitbucket.org/erikfriesen/harmony-2.04/history-node/43d8be86155bff9070fc2230c0c4dd4ce5f93054/driver/sqi_flash/sst26/src/dynamic/drv_sst26.c?at=master
     
     

    Erik Friesen
    #7
    boatbodger
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2011/03/27 15:39:07
    • Location: 0
    • Status: offline
    Re: Many bugs Harmony V3 SST26 (SQI) and MPFS file system 2019/11/21 03:08:10 (permalink)
    0
    Thanks for that, Erik. As it happens, I'm not using RTOS - just the old school round robin series of calls to tasks
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5