• AVR Freaks

Hot!How to save net config and other data into NVM and reload it on power up?

Author
skynet78
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2009/03/17 06:30:41
  • Location: 0
  • Status: offline
2015/10/15 14:12:53 (permalink)
0

How to save net config and other data into NVM and reload it on power up?

Hello everybody, i'm try to store the modified net config received from web page but on power on the net config is always the default values.
The harmony framework have a similar function of old tcp/ip stack called "saveappconfig" ?
It's possible to use the nvm driver with the nvm media of file system stored in ointernal flash working with web_server or snmp application?
post edited by skynet78 - 2015/11/05 08:42:52
#1

13 Replies Related Threads

    rainad
    Moderator
    • Total Posts : 1387
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: How to save net config into nvm and reload it on power up? 2015/10/19 08:09:34 (permalink)
    0
    An example of how to do that is in the tcpip_commands.c::_Command_NetworkOnOff() when the symbol TCPIP_STACK_COMMANDS_STORAGE_ENABLE is defined.
    It uses TCPIP_STACK_NetConfigGet() and TCPIP_STACK_NetConfigSet() API functions.
    The idea is that you supply a buffer where the network configuration is stored and later on you can restore the network configuration from that saved data.
    Eventually this functionality will be implemented by a service inside the Harmony framework but for now you could use this as a model.
     
    #2
    skynet78
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2009/03/17 06:30:41
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2015/11/05 04:58:30 (permalink)
    0
    Hi rainad,
    thank you for your reply.
    I seen the API function TCPIP_STACK_NetConfigGet() and TCPIP_STACK_NetConfigSet() in tcpip_commands.c source file.
    Now I am very confused !!! shock: [8D]
    How to use the command? are you an example code? where is the stored data location?
    The command list is only used in the "SYS_CMD_DESCRIPTOR    tcpipCmdTbl[]" initialized by "TCPIP_Commands_Initialize" on "TCPIP_STACK_MODULE_ENTRY_TBL[]" in the tcpip_manager.c
     
    #3
    freebsd
    Super Member
    • Total Posts : 163
    • Reward points : 0
    • Joined: 2011/03/07 04:15:29
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2015/11/05 05:24:42 (permalink)
    0
    Hi,
    It is not required to use command to use the TCPIP_STACK_NetConfigGet() and TCPIP_STACK_NetConfigSet() . To store the data in NVM location, you need to use a buffer and collect Netconfig data and store that data in a NVM location. TCPIP_STACK_NetConfigGet()  is use to get the net config data and those data need to be stored in a buffer. TCPIP_STACK_NetConfigSet()   is use to set the net config data.
     
    Hope this clears. 
    #4
    skynet78
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2009/03/17 06:30:41
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2015/11/05 07:54:06 (permalink)
    0
    Hi freebsd,
    thank for your reply.
    I tried to use the Command_NetworkOnOff() by SYSTEM_CONSOLE and it work using "if eth0 down" and "if eth0 up" command string but if power down and up the system the net config contains already the default value.
    My target is stored in NVM the netconfig, SNMP setting and other parameters in my application to reload it at system power up.
    In the final version i will add the bootloader.
    In the past I have worked with the microchip tcp/ip stack and I have saved more parameter on external EEPROM but now with the new harmony framework I have difficulties ...
    #5
    skynet78
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2009/03/17 06:30:41
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2015/11/05 08:25:37 (permalink)
    0
    My problem is similar to this:
    http://www.microchip.com/forums/m877734.aspx

    Someone can put an example code with NVM and MPFS at the same time?
    post edited by skynet78 - 2015/11/05 08:27:17
    #6
    freebsd
    Super Member
    • Total Posts : 163
    • Reward points : 0
    • Joined: 2011/03/07 04:15:29
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2015/11/05 22:40:42 (permalink)
    0
    Hi,
    You can take a look at the tcpip demo where both NVM and MPFS is used together.
     
    "apps\tcpip\web_server_nvm_mpfs\firmware\src\system_config\pic32mx_eth_sk"
     
    Please take a look
    #7
    skynet78
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2009/03/17 06:30:41
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2015/11/10 07:58:36 (permalink)
    0
    Hi everybody,
    my question now is: How to use NVM driver to manage different memory location about MPFS data and custom data buffer?
    In the pic32_eth_web_server example project the NVM driver is initialized with 
    #define DRV_NVM_INSTANCES_NUMBER 1
    #define DRV_NVM_CLIENTS_NUMBER 1
    #define DRV_NVM_BUFFER_OBJECT_NUMBER 5

    #define DRV_NVM_INTERRUPT_MODE true
    #define DRV_NVM_INTERRUPT_SOURCE INT_SOURCE_FLASH_CONTROL

    #define DRV_NVM_MEDIA_SIZE 64
    #define DRV_NVM_MEDIA_START_ADDRESS 0x9D000000

    #define DRV_NVM_ROW_SIZE 512
    #define DRV_NVM_PAGE_SIZE 4096
    #define DRV_NVM_PROGRAM_UNLOCK_KEY1 0xAA996655
    #define DRV_NVM_PROGRAM_UNLOCK_KEY2 0x556699AA

    #define DRV_NVM_ERASE_WRITE_ENABLE

    #define DRV_NVM_SYS_FS_REGISTER

     
    In the nvm_read_write example project the NVM driver is initialized with
    #define DRV_NVM_INSTANCES_NUMBER 1
    #define DRV_NVM_CLIENTS_NUMBER 1
    #define DRV_NVM_BUFFER_OBJECT_NUMBER 8

    #define DRV_NVM_INTERRUPT_MODE true
    #define DRV_NVM_INTERRUPT_SOURCE INT_SOURCE_FLASH_CONTROL

    #define DRV_NVM_MEDIA_SIZE 32
    #define DRV_NVM_MEDIA_START_ADDRESS 0x9D010000

    #define DRV_NVM_ROW_SIZE 512
    #define DRV_NVM_PAGE_SIZE 4096
    #define DRV_NVM_PROGRAM_UNLOCK_KEY1 0xAA996655
    #define DRV_NVM_PROGRAM_UNLOCK_KEY2 0x556699AA

    #define DRV_NVM_ERASE_WRITE_ENABLE

     
    If I try to change the harmony configuration (by tool -> embedded -> MPLAB Harmony Configurator) and set the Number of NVM Driver Client to 2 the init configuration change only one row:
    #define DRV_NVM_CLIENTS_NUMBER 2

    Now how to use the second client of NVM Driver?
    I tryed to insert a new app task with use the same code of nvm_read_write project app but the handle driver return an INVALID_HANDLE.
     
    Also, the NVM driver in web server project, is initialized by system_init.c with
    /* Initialize the NVM Driver */
        sysObj.drvNvm = DRV_NVM_Initialize(DRV_NVM_INDEX_0, (SYS_MODULE_INIT *)&drvNvmInit);

    It's possible to use the same handler to save custom data?
     
    The nvm_read_write project use the 
    const uint8_t gAppFlashReserveArea[APP_NVM_MEMORY_AREA_SIZE] __attribute__ ((keep)) __attribute__((address(DRV_NVM_MEDIA_START_ADDRESS))) = {0};
    to preserve the memory address used to read/write operation but in the web server the memory is used to MPFS files....
     
    Anybody help me?
    #8
    skynet78
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2009/03/17 06:30:41
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2015/11/12 06:59:14 (permalink)
    0
    Hi,
    I tryed to implement a merge of web_server_nvm and nvm_read_write example project....
    After more errors the changes are:
    system_config.h
    #define DRV_NVM_CUSTOM_START_ADDRESS 0x9D000000
    #define DRV_NVM_MEDIA_START_ADDRESS 0x9D000000 + 0x00002000

    Added a new app named "custom_nvm_app" with the same code of nvm_read_write example
    I set the APP_NVM_MEMORY_AREA_SIZE dimension at 8kB in the custom_nvm_app
    /* The size of the media used for this demo. */
    #define APP_NVM_MEMORY_AREA_SIZE (DRV_NVM_MEDIA_SIZE * 128)

    Added new items to NVMGeometryTable in the system_init.c
    /*** FLASH Driver Initialization Data ***/

    SYS_FS_MEDIA_REGION_GEOMETRY NVMGeometryTable[6] =
    {
        {
            .blockSize = 1,
            .numBlocks = (DRV_NVM_MEDIA_SIZE * 1024),
        },
        {
           .blockSize = DRV_NVM_ROW_SIZE,
           .numBlocks = ((DRV_NVM_MEDIA_SIZE * 1024)/DRV_NVM_ROW_SIZE)
        },
        {
           .blockSize = DRV_NVM_PAGE_SIZE,
           .numBlocks = ((DRV_NVM_MEDIA_SIZE * 1024)/DRV_NVM_PAGE_SIZE)
        },
        {
           .blockSize = 1,
           .numBlocks = (DRV_NVM_MEDIA_SIZE * 128)
        },
        {
           .blockSize = DRV_NVM_ROW_SIZE,
           .numBlocks = ((DRV_NVM_MEDIA_SIZE * 128)/DRV_NVM_ROW_SIZE)
        },
        {
           .blockSize = DRV_NVM_PAGE_SIZE,
           .numBlocks = ((DRV_NVM_MEDIA_SIZE * 128)/DRV_NVM_PAGE_SIZE)
        }
    };

    Change the index of APP_NVM_REGION_INDEX in the custom_nvm_app.h
    /* Enumeration of the Read, write and erase region geometry indices */
    typedef enum {

        /* Read region index */
        APP_NVM_READ_REGION_INDEX = 3,

        /* Write region index */
        APP_NVM_WRITE_REGION_INDEX = 4,

        /* Erase region index */
        APP_NVM_ERASE_REGION_INDEX = 5

    } APP_NVM_REGION_INDEX;

    Now the handle of second NVM client is correct, all the operation in the sample code (APP_EraseMemoryAndVerify, APP_SequentialReadWrite, APP_RandomReadWrite....) but the first NVM client driver
    (the MPFS file system) dont work !!!
    If I connect the web browser at the ip of the system the web page print the MPFS error message
    404: File not found
    Use MPFS Upload to program web pages

     
    Any suggestion?
    #9
    Rokx
    New Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2013/01/23 00:23:26
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2015/11/23 02:42:15 (permalink)
    0
    I'm facing the same problem at the moment.
    Have you found a solutuion for this problem? I really don't want to add external memory just to store the network config.
    #10
    mrpackethead
    packet mangler
    • Total Posts : 967
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2016/05/22 00:14:38 (permalink)
    0
    Did anyone solve this?  THis is nuts microchip.. 
     
    #11
    fhguarni
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2016/09/26 01:27:04
    • Location: Australia
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2016/10/26 17:12:46 (permalink)
    0
    Hello,
     
    I am facing the same problem.  I need to store web pages and other data, which is very important, and I do not want to store it in an external memory.  With MLA using PIC32MX I could use part of the flash memory of the micro to store this information, while web pages were stored somewhere else. However, I cannot see an easy way to do it using Harmony with PIC32MZ...
     
    Someone has found a solution for this?
    #12
    Tez
    Moderator
    • Total Posts : 480
    • Reward points : 0
    • Joined: 2006/10/04 11:09:05
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2016/10/28 09:30:14 (permalink)
    3.5 (2)
    Please look at the flash driver contained in the framework/driver/flash. This provides a direct address based API to access the flash. 
    #13
    glamprecht
    Starting Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2010/09/27 22:45:46
    • Location: 0
    • Status: offline
    Re: How to save net config into nvm and reload it on power up? 2020/06/29 11:38:57 (permalink)
    0
    I am not getting framework/driver/flash driver working together with the mpfs driver. They both work separately though. Still nobody with a solution to save settings to program flash?
    #14
    Jump to:
    © 2020 APG vNext Commercial Version 4.5