first working user servo with makefile that downloads it

This commit is contained in:
2017-01-09 13:28:07 +01:00
parent 9756485f5a
commit 3519c559a1
21 changed files with 173 additions and 473 deletions

168
src/Readme.md Normal file
View File

@@ -0,0 +1,168 @@
Helpfull Deltatau lines
-----------------------
cat /opt/ppmac/projpp/projpp_help.txt
root@:/# projpp -l
$$$***
!common()
!mx-stage()
#4$
#4j/
#4k
Start IDE
New Project, PowerBrick_LV
makefile and output at:
C:\Documents and Settings\user\Desktop\scratch\PowerBrick_LVUserServoLoop\PowerBrick_LVUserServoLoop\C Language\Realtime Routines
Update Firmware
---------------
we are using: 2.0.2.14, IDE wants newer, probably 2.1.1.3 (http://forums.deltatau.com/filedepot/)
With IDE the new firmware can be installed (tools->...->download firmware)
User Servo Loop
---------------
build usralgo.ko (or copy from IDE after build)
rmmod usralgo
insmod /mypath/usralgo.ko (e.g. insmod /opt/ppmac/usrflash/Project/Bin/Debug/usralgo.ko)
cat /proc/kallsyms | grep MyUserAlgoFunctionName (e.g. cat /proc/kallsyms | grep user_pid_ctrl)
a47e448b r __kstrtab_user_pid_ctrl [usralgo]
a47e4458 r __ksymtab_user_pid_ctrl [usralgo]
a47e4068 T user_pid_ctrl [usralgo]
UserAlgo.ServoCtrlAddr[4] = $a47e4068
Motor[4].Ctrl =UserAlgo.ServoCtrlAddr[4].a
Sample Kernel Module
--------------------
http://www.thegeekstuff.com/2013/07/write-linux-kernel-module/
https://linux.die.net/lkmpg/x121.html
cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/usrServo/sampleKernelModule
Do a module on Ubuntu works.
ln -sfT Makefile.Ubuntu Makefile
make clean
make
dmesg
insmod /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/usrServo/sampleKernelModule/hello.ko
rmmod hello.ko
dmesg
Do a module for PowerBrick:
uncompress powerpc-465-rootfs.tar.gz (from PMAC IDE) to /opt -> /opt/powerpc-465-rootfs/usr/include/ etc.
compile fixdep, modpost
cd /opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/scripts/basic
gcc fixdep.c -o fixdep
cd /opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/scripts/mod
gcc modpost.c file2alias.c sumversion.c -o modpost
ln -sfT Makefile.Deltatau Makefile
make clean
make
scp hello.ko root@SAROP11-CPPM-MOT6871:/tmp
dmesg
insmod /tmp/hello.ko
rmmod hello.ko
dmesg
Build test the user Servo kernel module
---------------------------------------
The sources are from C:\Documents and Settings\user\Desktop\scratch\PowerBrick_LVUserServoLoop\PowerBrick_LVUserServoLoop\C Language\Realtime Routines
The Makefile calls the Lernel Makefile in /opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/Makefile
it generates files as .usralgo.o.cmd etc.
rootfs files are on the powerbrick or in C:\DeltaTau\Power PMAC IDE\compilers\opt -> powerpc-465-rootfs.tar.gz
On the powerbrick the kernel sources are not installed -> therefore the rootfs from the IDE is needed (uncompressed to /opt/powerpc-465-rootfs)
cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/usrServo
make clean
make
scp usralgo.ko root@SAROP11-CPPM-MOT6871:/tmp
rmmod usralgo
insmod /tmp/usralgo.ko
cat /proc/kallsyms | grep user_pid_ctrl
>>>> a35e812c T user_pid_ctrl [usralgo]
UserAlgo.ServoCtrlAddr[4] = $a35e812c
Motor[4].Ctrl =UserAlgo.ServoCtrlAddr[4].a
286 dmesg
287 rmmod hello.ko
288 dmesg
289 cat /proc/kallsyms | grep user_pid_ctrl
290 rmmod usralgo
291 cat /proc/kallsyms | grep user_pid_ctrl
292 insmod /opt/ppmac/usrflash/Project/Bin/Debug/usralgo.ko
293 cat /proc/kallsyms | grep user_pid_ctrl
294 rmmod usralgo
295 insmod /tmp/usralgo.ko
296 cat /proc/kallsyms | grep user_pid_ctrl
297 history
THIS ALSO WORKED !!!
rmmod usralgo
insmod /mypath/usralgo.ko (e.g. insmod /opt/ppmac/usrflash/Project/Bin/Debug/usralgo.ko)
cat /proc/kallsyms | grep MyUserAlgoFunctionName (e.g. cat /proc/kallsyms | grep user_pid_ctrl)
SCRATCH
-------
scp -r root@SAROP11-CPPM-MOT6871:/opt/ppmac .
scp -r root@SAROP11-CPPM-MOT6871:/usr/local/xenomai/lib xenomai
scp -r root@SAROP11-CPPM-MOT6871:/usr/lib .
LIB='-L ppmac/libppmac/ -Lxenomai -lppmac -lxenomai -lpthread_rt -lpthread -lrt -ldl'
LIB='-L/opt/eldk-4.2/PPMAC_rootfs-7-wheezy/opt/ppmac/libppmac -lppmac -L/opt/eldk-4.2/PPMAC_rootfs-7-wheezy/usr/local/xenomai-2.6.2.1/lib -lxenomai -lpthread_rt -lpthread -lrt -ldl'
INC='-I/opt/eldk-4.2/PPMAC_rootfs-7-wheezy/opt/ppmac/libppmac -I/opt/eldk-4.2/PPMAC_rootfs-7-wheezy/opt/ppmac/rtpmac'
/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc -g $INC -c main.c -o main.o
/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc -g main.o $LIB -o main
scp main root@SAROP11-CPPM-MOT6871:/tmp
export LD_LIBRARY_PATH=/opt/ppmac/libppmac/
./main
Motor[4].Ctrl=Sys.ServoCtrl
Motor[4].Ctrl=UserAlgo.ServoCtrlAddr[0]
UserAlgo.ServoCtrlAddr[0]=$....
Motor[4].IpbGain=2.9192927
UserAlgo.ServoCtrlAddr[4]=$a1108068
usrflash/Project/Bin/Debug/usralgo.so
usrflash/Project/Bin/Debug/usralgo.ko