Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Adding real NVRAM retain persistent memory

2015-09-21
2015-09-23
  • jfernandez88 - 2015-09-21

    Hi,

    I want use this additional NVRAM card on the raspberry pi 2 and use the 56kB of NVRAM on Codesys :

    http://www.cjemicros.co.uk/micros/indiv ... eClock-RTC

    1st : is it possible ?

    2nd : How ???

    I think we need to tell Codesys about where is referenced the NVRAM on the system.

    As you can see the chip is well reconize by raspbian :

    [ 4.281346] bcm2708_i2c_init_pinmode(1,2)
    [ 4.288983] bcm2708_i2c_init_pinmode(1,3)
    [ 4.381423] rtc-ds1307 1-0068: rtc core: registered ds1307 as rtc0
    [ 4.399365] rtc-ds1307 1-0068: 56 bytes nvram
    [ 4.429732] bcm2708_i2c 3f804000.i2c: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000)

    and the NVRAM is well affected by raspbian :

    root@raspberrycodesys:/home/pi# find /sys -name nvram
    /sys/devices/soc/3f804000.i2c/i2c-1/1-0068/nvram

    So, how can I say to the runtime "Please, use this kind of memory here for the retain data /sys/devices/soc/3f804000.i2c/i2c-1/1-0068/nvram"

    We can say on the CODESYSControl.cfg file something like this :

    [CmpApp]
    RetainType.Applications=InSRAM

    [CmpRetain]
    Retain.SRAM.Address=0x10000000 (but it's bullshit on my situation....)
    Retain.SRAM.Size........
    etc...

    I think the only way to tell the runtime about the NVRAM's location is when 3S compile it... but maybe not.

    One solution would be that 3S add a new parameter for CODESYSControl.cfg like :

    Retain.SRAM.SysLocation= /sys/devices/soc/3f804000.i2c/i2c-1/1-0068/nvram
    Retain.SRAM.Size=56K

    And here we go !!!!!

    Other idea ? Advice ?

    What is the 3S's position on the kind of feature request ?

    BR,

    Julien

    IMG: IMG_0331.JPG

     
  • eschwellinger

    eschwellinger - 2015-09-22

    Hi,
    where in these links do we find the NVRAM descripton?
    It is a RTC module and some I2C sensors... but NVRAM?

    Guess, even if a setting like would be possible
    it will not work.
    Because on retain in Sram setting we need a mapped memory area which will be accesses cyclic for the retain area
    in your iec task where you use the retain vars.
    If this is connected via I2C guess this will increase the plc cycle dramatically.

    In case of an unexpected poweroff, the write access should lead to a succesul write into the I2C connected NVRAM ... does this work
    via I2C??

    BR
    Edwin

     
  • jfernandez88 - 2015-09-23

    Hello Edwin !

    Yes, this link don't sept about the NVRAM but the chip DS1338 include 56KB of NVRAM :

    http://datasheets.maximintegrated.com/e ... S1338Z.pdf

    This work because I see the NVRAM on raspbian and I can write it with od command.

    So, you say that the problem would be the speed of access for this kind of memory ? Because of I2C ?

    If we don't need hi-speed, is it possible ? I try to find a method to map my 56KB I2C NVRAM to user space memory in linux... Any idea ? is it possible ?
    How you doing that with bigger PLC ? How do you affect NVRAM memory in linux ? Is it in place by hardware conception ? Or by a linux driver setup ?

    BR,

    Julien

     

Log in to post a comment.