• AVR Freaks

Hot!Save configuration in PIC32: NVM or File System?

Page: 12 > Showing page 1 of 2
Author
lelsteph
Super Member
  • Total Posts : 405
  • Reward points : 0
  • Joined: 2008/09/17 05:10:00
  • Location: 0
  • Status: offline
2016/06/26 09:35:01 (permalink)
0

Save configuration in PIC32: NVM or File System?

Hello
 
I need to save the configuration of my system (plenty of settings). I am thinking I should store it in the PIC32 Memory Flash.
I was first thinking to use the NVM Driver but it is used by the TCP IP Stack and it seems I cannot have kind of 2 instances (one for TCP and one for my configuration).
Then I though about using the File System, why not having a file on the media which will be the configuration. The File System is configured in MPFS2 for the Web pages, no FAT.
 
1]What would be your recommendation?
 
2]I tried to open in Write mode a file (ex: test.cfg), I get error SYS_FS_ERROR_DENIED.
Why? Because MPFS2 cannot be written?
How should I do?
 
Thanks for any help and recommendation.
 
Best Regards, Stephane.
#1

27 Replies Related Threads

    lelsteph
    Super Member
    • Total Posts : 405
    • Reward points : 0
    • Joined: 2008/09/17 05:10:00
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 07:42:32 (permalink)
    0
    Hello
     
    How do you save your configurations usually?
     
    Steph.
    #2
    malaugh
    Super Member
    • Total Posts : 412
    • Reward points : 0
    • Joined: 2011/03/31 14:04:42
    • Location: San Diego
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 08:11:41 (permalink)
    0
    If you are going to store the values in internal flash memory its probably easiest to just store the data as a structure.  the only problem is you will need to read the whole structure into RAM and write it back if you need to make configuration changes.
     
    As you have found out, MPFS is a read only file system.  The file system is made at compile time, and there is no provision for writing.
     
    If you need file system.  a FAT file system is available at http://elm-chan.org/fsw/ff/00index_e.html The Microchip library also has a FAT file system library.  You need to supply the low level driver.  We use this on an SD card with the supplied driver, or on a SPI flash with our own custom driver.
    #3
    lelsteph
    Super Member
    • Total Posts : 405
    • Reward points : 0
    • Joined: 2008/09/17 05:10:00
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 09:05:40 (permalink)
    0
    Hello

    Thank you for your response!
     
    Yes I have been using a mega ;) structure with all parameters.
    I also use a signature to detect in case of changes in the structure of the structure ;)
    Then I write in Bytes the structure into a Serial EEPROM or here I really want to use the internal flash.
     
    1. So you also confirm I cannot use the NVM driver having the TCP File System already on it?
    2. Can I activate the file system at the same time the MPFS2 is activated?
    3. I think Harmony already has everything including drivers if we use the FAT system?
     
    Thanks Steph.
     
    #4
    Paul PortSol
    Super Member
    • Total Posts : 630
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 09:21:41 (permalink)
    0
    One of the Harmony Tutorials includes read/write to a USB Stick (Thumbdrive).
    - its an extra piece of hardware
    + You can detact and examine/modify settings on a PC
    + You can save huge log files during development or even runtime if you got a big stick
     
    see Lab2a in:  http://microchip.wikidot....dable-harmony-training
    post edited by Paul PortSol - 2016/06/28 10:02:37
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 18848
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 09:48:22 (permalink)
    0
    malaugh
    If you are going to store the values in internal flash memory its probably easiest to just store the data as a structure.  the only problem is you will need to read the whole structure into RAM and write it back if you need to make configuration changes.
     
    As you have found out, MPFS is a read only file system.  The file system is made at compile time, and there is no provision for writing.
     
    If you need file system.  a FAT file system is available at http://elm-chan.org/fsw/ff/00index_e.html The Microchip library also has a FAT file system library.  You need to supply the low level driver.  We use this on an SD card with the supplied driver, or on a SPI flash with our own custom driver.


    Harmony Also has a FAT File System.
    #6
    lelsteph
    Super Member
    • Total Posts : 405
    • Reward points : 0
    • Joined: 2008/09/17 05:10:00
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 11:26:41 (permalink)
    0
    Hello
     
    Harmony Also has a FAT File System.

     
    Ok but can i use it with MPFS2 at the same time and the TCP stack?
     
    Thanks Steph.
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 18848
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 12:20:55 (permalink)
    0
    FAT is Not MPFS2.
    So no you can not use FAT to access MPFS2 drives.
     
    You can try setting up a FAT  partiion in the flash but it is over complicated for 1 file.
     
    Assuming you data does not change often enough to burn out the flash you are better off  creating a const array  that is flash page aligned and the size of the full page.
     
    #8
    mrpackethead
    packet mangler
    • Total Posts : 967
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 12:35:02 (permalink)
    0
    It would be great if there was a harmony example for nvm copy erase write to nvm
    #9
    mrpackethead
    packet mangler
    • Total Posts : 967
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 12:35:03 (permalink)
    0
    It would be great if there was a harmony example for nvm copy erase write to nvm
    #10
    NorthGuy
    Super Member
    • Total Posts : 6214
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 12:59:19 (permalink)
    0
    Internal flash can only be erased in pages and it takes noticeable amount of time to erase  (may be 20 ms or so). While erases/writes are done, your CPU will most likely stall. File system or not file system, it doesn't change the way how the internal flash works.
     
    Copying a block of data into internal flash. How hard this could be? Do you really think you need special drivers or anything of that sort to accomplish that?
    #11
    NKurzman
    A Guy on the Net
    • Total Posts : 18848
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 13:12:47 (permalink)
    0
    Note for the pic32mz if the flash is in the other page the pic will not stall.
    This can either help or confuse you.
    #12
    lelsteph
    Super Member
    • Total Posts : 405
    • Reward points : 0
    • Joined: 2008/09/17 05:10:00
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 14:14:43 (permalink)
    0
    Hello
     
    Assuming you data does not change often enough to burn out the flash you are better off  creating a const array  that is flash page aligned and the size of the full page.

    Not sure I get it, the configuration will be updated with the Web server.
    Looks like it would be better to save it in a Serial EEPROM.
     
    Thanks Stephane.
    #13
    NKurzman
    A Guy on the Net
    • Total Posts : 18848
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Save configuration in PIC32: NVM or File System? 2016/06/28 14:35:46 (permalink)
    0
    EEPROMs also have a maximum number of times they can be erased.
    The Number of cycles for Flash is lower.
     
    "the configuration will be updated with the Web server."
    Does that work out to a number of cycles for the life of the product?
    #14
    lelsteph
    Super Member
    • Total Posts : 405
    • Reward points : 0
    • Joined: 2008/09/17 05:10:00
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/06/30 04:29:28 (permalink)
    0
    Hello
     
    I pay a lot of attention to the memory life I can tell you ;) I designed special mechanisms in some projects to manage this.
     
    There won't be many updates of the configuration. The project has many settings that are user programmable. To set them up I will design web pages. Once the user has completed the changes, he can save, at this time only the new configuration will be saved in the EEPROM (this is what I meant with "the configuration will be updated with the Web server."). The number of times the user will save will be very small compared to the number of cycles supported by a Serial EEPROM for example.
     
    In the past I was always using Serial EEPROM to save settings, with the PIC32 I was thinking to use its memory but it looks like it will more efficient to still store in a Serial EEPROM.
     
    Thank you very much for your help!
     
    Steph.
     
    #15
    NKurzman
    A Guy on the Net
    • Total Posts : 18848
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Save configuration in PIC32: NVM or File System? 2016/06/30 06:17:37 (permalink)
    0
    It is possible to store the information in either place. The most efficent is your call.
    #16
    luca84
    New Member
    • Total Posts : 22
    • Reward points : 0
    • Joined: 2016/03/24 15:53:47
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/07/08 14:36:00 (permalink)
    0
    I have the same issue and I tried to solve by using only the internal flash memory in my pic32mx. You can see my solution in my post: 
     
    Now I would like to use a different solution to solve a problem with my system composed by a master board (pic32 ethernet starter kit 2) and some slave boards (pic32 usb starter kit 2). Every slave is identified by an ID number and is connected with the master board by an XBEE communication module based on my protocol. So for the master board I need to enter and store several informations and for every slave board only the ID number for the communication. So for the master board I can enter informations by web server and for storing I was thinking to a SPI external SDcard + FAT file system or a SPI external EEPROM, what do you suggest? For slaves I don't know how to assign an ID number to the board at runtime and how to store this information, external EEPROM or internal flash. With a file on external SDcard and FAT could be easy edit on windows and read at runtime but I think it's too much for only an ID number. Do you have some suggestions?
     
    Thank you!
     
    Luca
    #17
    NorthGuy
    Super Member
    • Total Posts : 6214
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/07/08 17:15:56 (permalink)
    0
    luca84Do you have some suggestions?



    If a slave needs an ID to establish communications then it must have the ID before communications are established. So, you either need to pre-program the IDs (some PICs may already have the IDs), or let the slaves get an ID as a part of network negotiation process. In either case, there's no need to store the ID.
     
    #18
    luca84
    New Member
    • Total Posts : 22
    • Reward points : 0
    • Joined: 2016/03/24 15:53:47
    • Location: 0
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/07/09 16:20:10 (permalink)
    0
    For now the user can start a scanning action of slaves by web page on master board, so every slave answer with its ID number setted before the compiling. But I don't want to change the ID for every slave device during compiling. I would like something like a unique signature for the board, for example like a MAC address for the master board. Does it exist something inside the pic like a unique identifier? Without this it's very difficult also to create a negotiation process because when the master ask for a device more than one can answer in the same time but without an IDentifier.
    #19
    NorthGuy
    Super Member
    • Total Posts : 6214
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Save configuration in PIC32: NVM or File System? 2016/07/10 06:29:33 (permalink)
    0
    luca84
    Does it exist something inside the pic like a unique identifier?

     
    Some of the PICs have unique ids. For others, you can use SQTP programming to implant them.
     
    luca84
    Without this it's very difficult also to create a negotiation process because when the master ask for a device more than one can answer in the same time but without an IDentifier.



    It's not that difficult. You can start from random ids, then let the master sort out the clashes.
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5