Building PtolemyII on Oracle Linux-6 VM on VBox
When Red Hat decides they've had enough of Microsoft and can afford to go on the offensive, what do they do? They get rid of the gcc -mno-cygwin switch. All applications that do not rely on the cygwin1.dll runtime executable cease to function. This is what monopolies do. They exert inertia. The path of least resistance is to immediately quit cygwin on Windows and immediately embrace Linux on a VM.
As of gcc-4, the -mno-cygwin build option has been deprecated. As a result it is still possible to build PtolemyII on Cygwin, however the EmbeddedCFileActor class functionality which depends on the -mno-cygvin switch, will not compile. The EmbeddedCFileActor class is important for providing convenient access to the incorporation of native C functionality in simulations. For any serious DSP developers, access to C functionality is mandatory. The only option is to build Ptolemy on Linux. This tutorial will describe the building of PtolemyII8.0.1 on a Oracle Linux Virtual Machine on Vbox.
Oracle Linux Release 6 Update 4 Media Pack for x86_64 (64 bit)
https://edelivery.oracle.com/EPD/Download/get_form?egroup_aru_number=16064752
Import your VM: File > Import Appliance to launch Appliance Import Wizard. Click Choose... to browse to the directory where you downloaded the file in and select the file OracleLinux64.ova then click Next to begin importing the virtual machine. It will prompt you to agree to the appropriate licenses while importing. You will see 'Oracle Virtual Sysadmin Days (Powered Off)' when it is finished importing. Please create a snapshot of the VM at this point, so you can always revert back to the pristine state in case something goes wrong or you want to repeat an exercise without manually reverting all the changes.
Increasing logical volumes and file systems
Cloned the .vmdk VM disk image into an .iso format with the VBoxManage “clonehd” command.
“C:\Program Files\Oracle\VirtualBox\VBoxManage.exe” clonehd –format VDI “C:\SPB_Data\VirtualBox VMs\Oracle Virtual Sysadmin Days\OracleLinux64-disk1.vmdk” “C:\SPB_Data\VirtualBox VMs\Oracle Virtual Sysadmin Days\OracleLinux64-disk1.vdi”
Re-sized the .vdi image with the VBoxManage “modifyhd” command.
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd "C:\SPB_Data\VirtualBox VMs\Oracle Virtual Sysadmin Days\OracleLinux64-disk1.vdi" --resize 14000
Use Gparted to increase the volume group vg_oraclelinux6 partition size to its full capacity.
Booted into Oracle-linux6 and extended the vg_oraclelinux6 volume group with the Linux “lvextend” command.
$ sudo lvextend -v -l +900 -r vg_oraclelinux6/lv_root
Determine the file system type (Linux how to determine the file system type)
$ df -T
The Oracle Linux distribution uses the btrfs filesystem for volume groug vg_oraclelinux6. This file system can be extended online.
[oracle@oraclelinux6 ~]$ sudo btrfs filesystem show
Label: none uuid: 89810a0a-7ed4-4756-a1df-c159ddd14dcd
Total devices 1 FS bytes used 4.50GB
devid 1 size 7.53GB used 7.53GB path /dev/dm-0
The file system volume can easily be grown with the following command (BTRFS Fun)
$ sudo btrfs filesystem resize +3g /
[oracle@oraclelinux6 ~]$ sudo btrfs filesystem show
Label: none uuid: 89810a0a-7ed4-4756-a1df-c159ddd14dcd
Total devices 1 FS bytes used 4.50GB
devid 1 size 10.53GB used 7.53GB path /dev/dm-0
[oracle@oraclelinux6 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_oraclelinux6-lv_root
11G 4.5G 4.7G 50% /
tmpfs 1004M 272K 1004M 1% /dev/shm
/dev/sda1 485M 56M 405M 12% /boot
/dev/sr1 57M 57M 0 100% /media/VBOXADDITIONS_4.2.18_88780
Note that df -h now shows that the file system volume has indeed been increased by the specified amount.
Reference
Storage management with LVM2 (mounting Virtual Hard Disk (VHD) for PtolemyII)
https://wikis.oracle.com/display/oraclelinux/Hands-on+lab+-+Storage+Management
YUM install java-1.6.0-openjdk-devel on Oracle VM Linux-6 VM on VBox
The Java JDK is necessary to run PtolemyII so we do the following
http://openjdk.java.net/install/
$ su -c "yum install java-1.6.0-openjdk-devel"
Guest Additions Not Loaded in VM Error
https://forums.virtualbox.org/viewtopic.php?f=6&t=47022
This error occurs when the ISO was mounted, but removed from the virtual drive while the VM was paused or for other various reasons.
Simply unmounted the ISO and Guest Additions will auto re-mount asking for permission to reinstall.
Failed Vbox Guest Additions Install
https://forums.virtualbox.org/viewtopic.php?f=6&t=47022
Compile PtolemyII from source
Download the sources
http://ptolemy.eecs.berkeley.edu/ptolemyII/ptII8.0/index.htm
PtolemyII Installation instructions are here http://ptolemy.eecs.berkeley.edu/ptolemyII/ptII8.0/ptII8.0.1/doc/install_index.htm
Move the source archive to /orion
$ sudo mv ~/Downloads/ptII8.0.1.src.tar.gz /orion
Change ownership on /orion
$ chown oracle /orion
Decompress the archive
$ cd $PTII
$ tar -zxvf ptII8.0.1.src.tar.gz
Edit the JARCS (Java actors compile list) in the $PTII/ptolemy/actor/lib/makefile
http://chess.eecs.berkeley.edu/ptexternal/src/ptII/doc/coding/addinganactor.htm#CreatingAnActor
If you are using make to build Ptolemy II, then the makefiles need to be updated.
Edit the $PTII/ptolemy/actor/lib/makefile and add the actors found in
CodegenActor.java$PTII/ptolemy/actor/lib/jni
These actors are:
CodegenActor.java
CompiledCompositeActor.java
EmbeddedCActor.java
EmbeddedCFileActor.java
PointerToken.java
Ramp2.java to the value of JSRCS. A good place for this is just after the Ramp.java \ line:
Quantizer.java \ Ramp.java \ RandomSource.java \ Quantizer.java \ Ramp.java \ Ramp2.java \ RandomSource.java \
Note that there is a TAB character before Ramp2.java.
This step is not strictly necessary, but it is good programming practice to put all source files in the makefile. Another reason we add it to the makefile is so that our new actor will be included in the lib.jar file.
make users: Run make in the $PTII/ptolemy/actor/lib directory (which is where you should already be). make will descend into the subdirectories and compile any needed files and eventually run
rm -f `basename Ramp2.java .java`.class CLASSPATH="../../.." "/cygdrive/c/j2sdk1.4.2_06/bin/javac" -g -O Ramp2.java
and Ramp2.class will be produced.
ant users: Run
cd $PTII ant
At this point, a class file at $PTII/ptolemy/actor/lib/*.class will have been created.
Note: The preceding step was not absolutely necessary as it appears that on Linux the actor EmbeddedCFileActor and its associated actors are automatically built with make, as on Linux, gcc's -mno-cygwin switch is clearly not required.
Instantiate Entity
To instantiate an entity, follow these steps
Quick:
Graph → Instantiate Entity → ptolemy.actor.lib.jni.EmbeddedCFileActor
Double Left Click on the imported CCompiledCompositeActor Symbol
Click on Preferences
Change the embeddedCCode field to Text
Check the expert mode box
Click OK
In the codeBlockFile field, enter <c_code_file_name.c> or Browse to the c file.
Example: For the example C:\Share\PID\codegen\agc_fsm.c, Browse to the windows /mnt/Share/PID/codegen directory and select the file agc_fsm.c
Alternatively, enter the c code text in embeddedCCode text box
Example Project:
/orion$PTII/ptolemy/actor/lib/jni/demo/Scale/Scale.xml
Detailed directions:
Start up Vergil and do File -> New -> Graph Editor
In Vergil, select Graph -> Instantiate Entity
In the Instantiate Entity window, edit the Class name field and replace its contents with ptolemy.actor.lib.Ramp2
Leave the Location (URL) field blank
Hit OK
The Ramp2 icon will appear.
To test the Ramp2 actor:
Click on Actors -> sinks -> GenericSinks and drag a Display actor over to the main canvas.
Connect the two actors by left clicking on the output of the ramp2 actor and dragging over to the input of the Display actor.
Select Directors -> SDF and drag the SDF director over to the right window.
Select View -> Run and change the number of iterations from 0 to 10, then hit the Run button.
You should see the numbers from 0 to 18 in the display.
Pros: Easy. Instantiate an actor and use it in the model. When the model is saved, the reference to the class is saved in the model.
Cons: Each time the modeler wants to use the actor, they must instantiate the actor, which means they need to know the name. The .class or .xml file must be present in the CLASSPATH of the JVM when the model is opened.
A few notes about Instantiate Entity:
Composite Actors can also be instantiated in this way. For example ptolemy.actor.lib.Sinewave is an Actor Oriented Class definition of a composite actor.
The Graph -> Instantiate Attribute menu choice is used to instantiate Ptolemy Attributes such as parameters or Directors.
Installing PtolemyII
As we have previously performed the installation of OpenJDK-6 on Ubuntu Vbox, step 1. below can be skipped.
Install JDK1.5 or later, add the jdk bin directory to your path so that javac and java are available, and have the make command available. http://www.troubleshooters.com/linux/prepostpath.htm
PATH=$PATH:/data/myscripts
export PATH
Set the PTII environment variable to the top level installed Ptolemy source directory. If the Ptolemy sources were installed to /opt/ptII8.0.1, then in a bash shell type:
Change ownership of the Ptolemy install directory
$ sudo su
# chown -R usysinc /opt/ptII8.0.1
# exit
Export the PTII environment variable
$ export PTII=/orion/ptII8.0.1
OR
add “export PTII=/orion/ptII8.0.1” to the file /root/.bash_profile
If autoconf has not already been installed then install it like
$ apt-get install autoconf
OR
$ sudo su
# yum install autoconf
# exit
Run configure.
$ cd "$PTII"
$ rm -f config.*
$ autoconf
$ ./configureOR$ cd "$PTII"; rm config.*; autoconf; ./configure
The safest thing to do is to run make fast install on the entire tree:
$ make fast install
Start Virgil
$ $PTII/bin/vergil
Note: The PtolemyII directory after make is 621MB, which is why we have installed the application to a separate VHD mounted as /orion.
Errors:
http://stackoverflow.com/questions/10382929/unsupported-major-minor-version-51-0
Subpages (1): PtolemyII on Linux VBox VM
Mount a Shared Folder on the Host
Reference
https://forums.virtualbox.org/viewtopic.php?t=15868
1. Open the VBox VM Settings and go to Shared Folders.
2. Click on the Add button and browse for a folder you want to share.
3. In the VBox Settings window, an entry per-appended with the name of the selected folder will appear. This will be the name of the Linux share. For instance if the name of the Windows host folder was "E:\Design\RESEARCH\PID" then the name of the Linux share folder would be "PID".
4. Open a Terminal window in the Linux guest and create a mount point such as below.
$ mkdir /mnt/Share
Note: You may have to delete and recreate the mount point if you closed and reopened the VBox VM.
$ su
Password: ******
$ rm -r /mnt/Share
$ mkdir /mnt/Share
5. In the same Terminal window in the Linux guest, mount the share as follows.
$ sudo mount -t vboxsf PID ~/mnt/Share
6. Now boot up Vergil
$ $PTII/bin/vergil &