CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Wed Aug 23, 2017 10:10 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 33 posts ]  Go to page 1 2 3 Next
Author Message
PostPosted: Tue Sep 23, 2014 8:45 am 
Offline

Joined: Thu Sep 18, 2014 12:10 am
Posts: 87
Is there any tutorial of how we can use Codesys Control on Raspberry with read only SD card?
Maybe with use of "ramfs".
Can any one tell us witch folders we have to mount as "tmpfs"?

Regards


Top
   
PostPosted: Tue Sep 23, 2014 3:36 pm 
Offline

Joined: Mon Jun 25, 2012 7:33 am
Posts: 20
Hallo Isislsis,

du kannst einfach Lib SysLibFile verwenden und mit File Open eine Datei im Read modus öffnen. Wenn es die Datei gibt, dann erhältst du ein gültiges Handle zurück. Mit diesem Handle kannst du dann mit der Funktion Read das File lesen.


Gesendet von iPhone mit Tapatalk


Top
   
PostPosted: Tue Sep 23, 2014 4:03 pm 
Offline

Joined: Thu Sep 18, 2014 12:10 am
Posts: 87
Hi.

Sorry maybe I'm wrong and you have misunderstood.
I ask how can work the CodesysControl runtime in a system with read only
sd card.
Because we take errors at boot time of Linux where not builded
some folders that needed from Codesys runtime.

Regards


Top
   
PostPosted: Tue Sep 23, 2014 4:25 pm 
Offline

Joined: Mon Jun 25, 2012 7:33 am
Posts: 20
Hi,

sorry I'm wrong i misunderstood your question


Gesendet von iPhone mit Tapatalk


Top
   
PostPosted: Tue Sep 23, 2014 5:58 pm 
Offline

Joined: Fri Feb 07, 2014 7:21 am
Posts: 60
Hello,

I would search the forum on the Raspberry Pi organisation for that,
or ask this question there.
http://www.raspberrypi.org/forums/

Best Regards
plcmax


Top
   
PostPosted: Tue Sep 23, 2014 6:13 pm 
Offline

Joined: Thu Sep 18, 2014 12:10 am
Posts: 87
I need specific information of Codesys runtime needs.
The rest of Linux functionality works fine after setup for
read only working mode of sd card.
The fail messages at boot up coming from Codesys runtime where
try to build some folders and files I thing at boot up time.

Regards


Top
   
PostPosted: Tue Sep 23, 2014 6:50 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2061
Hi,

could you share the information how you set this up as readonly?
Could you paste the message where you see that part of the runtime fails... screenshot

BR
Edwin


Top
   
PostPosted: Tue Sep 23, 2014 10:17 pm 
Offline

Joined: Thu Sep 18, 2014 12:10 am
Posts: 87
http://blog.pi3g.com/2014/04/make-raspbian-system-read-only/
http://nutcom.hu/ipe-r1/


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Wed Sep 24, 2014 6:55 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2061
Hi,
I've done a quick test for read-only SD configurations, this will work, maybe we need some tuning on some directories according the licensing
... need some more time to do this in detail and write a how to then.

BR
Edwin


Top
   
PostPosted: Fri Sep 26, 2014 8:34 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2061
Hello all,
this might really a good possibility to make it more 'robust'... -> to be proved

In my case I use the following procedure including licensing the pi. (sure this is optional)
1. start point is: Image from store or from raspberrypi.org and the installed codesys debian package
2. Optional: install the license
3. In my case I use a USB-Key which is read/writeable, where later the plc boot application and all needed files which CODESYS create are stored ( visu files /trend files license) etc
4. mount the USB-Key (sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/)
to /media and copy the content of /root to /media (this include the license to if the Pi is licensed)

5. change the runtime application directory to /media
sudo nano /etc/init.d/codesyscontrol
see screenshot
and change the location of PlcConfigFile
export PlcConfigFile=/media/CODESYSControl.cfg
and
cd /media/

save the changed codesyscontrol

6.add/change to /etc/CODESYSControl.cfg

[SysFile]
FilePath.1=/etc/, 3S.dat
FilePath.2=/media/, *.app, *.crc

move CODESYSControl.cfg and 3S.dat to your new location - in my case /media/

7. from that link: http://blog.pi3g.com/2014/04/make-raspb ... read-only/

Step by step how from the link above slightly changed to have an addition USB Stick for application data, license
Disable swap
dphys-swapfile swapoff
dphys-swapfile uninstall
update-rc.d dphys-swapfile disable

Install UnionFS
aptitude install unionfs-fuse

Create mount script
nano /usr/local/bin/mount_unionfs

#!/bin/sh
[ -z "$1" ] && exit 1 || DIR=$1
ROOT_MOUNT=$(grep -v "^#" /etc/fstab | awk '$2=="/" {print substr($4,1,2)}')
if [ "$ROOT_MOUNT" != "ro" ]; then
/bin/mount --bind ${DIR}_org ${DIR}
else
/bin/mount -t tmpfs ramdisk ${DIR}_rw
/usr/bin/unionfs-fuse -o cow,allow_other,suid,dev,nonempty ${DIR}_rw=RW:${DIR}_org=RO ${DIR}
fi

make it executable:
chmod +x /usr/local/bin/mount_unionfs

nano /etc/fstab
(D01F-8E5A is what you need to adapt to your stick - you get this ID by sudo blkid /dev/sdb1 or sudo blkid /dev/sda1)

cat /etc_org/fstab
Code:
proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    ro                0       2
/dev/mmcblk0p2  /               ext4    ro,noatime        0       1
mount_unionfs   /etc            fuse    defaults          0       0
mount_unionfs   /var            fuse    defaults          0       0
none            /tmp            tmpfs   defaults          0       0
UUID=[b]D01F-8E5A[/b] /media/ vfat defaults,auto,umask=000,users,rw 0


Prepare the directories
cp -al /etc /etc_org
mv /var /var_org
mkdir /etc_rw
mkdir /var /var_rw
reboot

check if everything is readonly by
mount

you get:
/dev/root on / type ext4 (ro,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=219764k,nr_inodes=54941,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=44788k,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=89560k)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
ramdisk on /etc_rw type tmpfs (rw,relatime)
unionfs-fuse on /etc type fuse.unionfs-fuse (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
ramdisk on /var_rw type tmpfs (rw,relatime)
unionfs-fuse on /var type fuse.unionfs-fuse (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
none on /tmp type tmpfs (rw,relatime)
/dev/sdb1 on /media type vfat (rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)



Connect with CODESYS Developmentsystem - download Webvisu example and check
1. if license is ok
2. all applications files are redirected to /media (Usb stick)
you should see Application.app, Application.crc visu directory etc on the USB Stick /media

Let me know if this work for you.
If anyone find the time a long term test like for example 1000 times switch on and randomly switch off the pi should prove if this is a real
robust solution for have a large SD card life cycle.

BR
Edwin


You do not have the required permissions to view the files attached to this post.


Last edited by Edwin Schwellinger on Fri Nov 14, 2014 6:26 am, edited 11 times in total.

Top
   
PostPosted: Mon Sep 29, 2014 8:57 am 
Offline

Joined: Thu Sep 18, 2014 12:10 am
Posts: 87
Hi.

I try your method with some difference to use a third partition on sd card but after reboot of application download i take the message "Application 'Application' does not exist on device 'Device'. Do you want to create it and proceed with download?".

Did you check your method?

I found that need more changes in "sudo nano /etc/init.d/codesyscontrol" because we have licence errors at boot.

Any help?


Top
   
PostPosted: Mon Sep 29, 2014 10:20 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2061
Hi,

you need to add your new location / redirection path to the CODESYSControl.cfg
in my case this was:

FilePath.2=/media/, *.app, *.crc
I've added this to the description above.

Not sure if a redirection to an separate partition on the same SD Card will prevent the SD card corruption.

BR
Edwin


Top
   
PostPosted: Mon Sep 29, 2014 2:35 pm 
Offline

Joined: Thu Sep 18, 2014 12:10 am
Posts: 87
Hi.

I made the changes in CODESYSControl.cfg.
Sorry it doesn't works after rebbot.
All look ok, the application exist in new folder but not running and the CodesysV3 not finding with refresh list of applications.

Any idea?


Top
   
PostPosted: Mon Sep 29, 2014 4:19 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2061
Hi,
sure missing in CODESYSControl.cfg
the FilePath.1 to set on your new location, because here CDS store the name of the Bootproject to load.

[SysFile]
FilePath.1=/media/, 3S.dat
FilePath.2=/media/, *.app, *.crc

additional you need to change the path in the config file in
/etc/init.d/codesyscontrol

export PlcConfigFile=/media/CODESYSControl.cfg



BR
Edwin


Top
   
PostPosted: Mon Sep 29, 2014 7:52 pm 
Offline

Joined: Thu Sep 18, 2014 12:10 am
Posts: 87
Nothing has changed.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 33 posts ]  Go to page 1 2 3 Next

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited