Sunday, May 24, 2020

How To Install an Old Version of Python on CentOS 7 without messing the default Python 2.7.x version installed

Ok this is how i install old Python 2.6.4 on a specific folder in my CentOS 7 without messing the Python 2.7.5 (default) that was installed in it.

What i want to do:
1. I am trying to run the UPG python script but somehow its binary strictly want to use python 2.6.4 or else it won't run
2. CentOS 7 comes with Python 2.7.x with it and i believe CentOS requires this version to be able to run its python scripts
3. So i need to be able to install Python 2.6.4 on a separate folder without messing with the default python version installed which is 2.7.x

What to do:


  1. 1. download python 2.6.4 source code package: https://www.python.org/downloads/release/python-264/
  2. download the tar file of course.
  3. unpack in any folder in your CentOS system but of course, you install it in preferred location /opt/ltx because UPG script refers to #!/opt/ltx/Python-2.6.4/bin/python 
  4. make sure you login as root
  5. Assuming you unpack it in /opt/ltx, cd to /opt/ltx/Python-2.6.4
  6. run configure like this >./configure --prefix=/opt/ltx/Python-2.6.4/.
    • this make install script to install the binaries and include files to /opt/ltx/Python-2.6.4/
  7. then finally >make install
  8. you can now see  /opt/ltx/Python-2.6.4/bin/python
  9. within this folder, you can do >python --version and the version will be 2.6.4
  10. however, doing >python --version on any other folder will show 2.7.x which means the default is still 2.7.x unless your script such as UPG strictly points to  /opt/ltx/Python-2.6.4/bin/ folder



Wednesday, April 10, 2019

How to Enable WIR, WCR, WRR records on STDF in Unison



Unison doesn't automatically add WIR, WCR, and WRR records into STDF file. To enable it, you need to add Wafer Descriptor object in the test program. To do this, follow the instructions below:


  1. In Optool menu, go to Tools > Wafer Map, the WaferMapTool will open.
  2. In the WaferMapTool, create Wafer Descriptor object. In my example below, I named the object “PutWaferDescriptorObjectNameHere”



  1. In the WaferMapTool menu, go to Edit > Edit Wafer Description…, the Edit Wafer Description Tool will open
  2. Put all the necessary values in the fields as shown below. Click OK


  1. Now that you have the Wafer Descriptor object. Let’s make it active.  In OpTool menu, go to Setup > Active Object > Wafer…, select the Wafer Descriptor you created. In my case it’s the “PutWaferDescriptorObjectNameHere”.
  2. Don’t forget to SAVE your program!!!
  3. Now from here on, as long as you use CURI driver that is for prober/wafer testing, you should generate WIR, WCR, and WRR in your STDF file.


Thursday, October 25, 2018

Compiling C++ Codes into shared Library and Linking Them


Compiling C++ Codes into shared library and linking them

Let's say you have files print.h and print.cpp, shown below that contains C++ codes you wish to compile as .so (shared object) file and they are stored in ~/demo/lib folder.

#ifndef __PRINT__
#define __PRINT__

#include <iostream>
#include <stdio.h>
void print(const char* p, bool endl = true);

#endif
#include <print.h>

void print(const char* p, bool endl)
{
std::cout << "print: " << p;
if (endl) std::cout << std::endl;
}

You can compile the above code into .o (static library) file with the command

~/demo/g++ -o lib.o -c ./lib/print.cpp

But we want to compile it as .so (shared library) file so we use the command instead

~/demo/g++ -o ./lib/liblib.so -shared -fpic ./lib/print.cpp

Note that with the above commands, liblib.so and lib.o is created in ~/demo/lib folder upon successful compilation.

Now let's say you have another set of C++ files loop.cpp and loop.h, shown below and you wish to compile them together with another C++ file into an .so file...

#ifndef __LOOP__
#define __LOOP__

#include <iostream>
#include <unistd.h>

class loop
{
public:
loop()
{
std::cout << "loop constructor"<< std::endl;
}
virtual ~loop()
{
std::cout << "loop destructor"<< std::endl;
}

void run(int i, int r);
};

#endif

#include <loop.h>

void loop::run(int i, int r)
{
while(r)
{
sleep(i);
std::cout << "loop..." << std::endl;
r--;
}
}

To compile print.cpp and loop.cpp files into a single .so file, do the command as shown below

~/demo/g++ -o ./lib/liblib.so -shared -fpic ./lib/print.cpp ./lib/loop.cpp

Now that we have .so file already, let's create a C++ program that will use this shared library and use the function and class it contains.
The C++ file below will be our C++ program. It is stored as main.cpp in ~/demo folder.
It uses print() from print.cpp to print "hello world" and uses loop class to perform a loop of 5 intervals.

#include <iostream>
#include <print.h>
#include <loop.h>

int main()
{
print("hello world");
loop p;
p.run(1,5);
return 0;
}

Let's compile this code and link the shared library with it. The command below shows how to compile it into "run".

g++ -o run main.cpp -L/lib -llib -I./lib -I./

If compile is successful, and executable named 'run' should appear in ~/demo folder. If you execute it, you might encounter an error as shown below. This is because when executing a program that has dependency on a shared library, it needs to know where the library is.

run: error while loading shared libraries: liblib.so: cannot open shared object file: No such file or directory

To fix this, you can do either of the two possible solutions

1. Copy the liblib.so into any folder listed in the system's LD_LIBRARY_PATH environment variable. This is a more consistent solution because you only do this once.

2. add ~/demo/lib folder into LD_LIBRARY_PATH environment variable. You have to keep setting this every time you try to execute your program in a new terminal. To do this, follow the command below:

~/setenv LD_LIBRARY_PATH ~/demo/lib:${LD_LIBRARY_PATH}

Now try to run the program again.

Using Makefile 

You can create a makefile to simplify this process. Copy the code below into ~/demo/makefile

all: so main

so : ./lib/print.cpp ./lib/loop.cpp
g++ -o ./lib/liblib.so -shared -fpic ./lib/print.cpp ./lib/loop.cpp -I./lib

main : ./lib/liblib.so
g++ -o run main.cpp -L./lib -llib -I./lib -I ./

Then just call 'make' and the whole compiling process will be done.


Linking the Shared Library (.so) in Unison

In this guide, we will link a share library (.so) in a Unison test program and use the functions and classes defined in the shared library.

1. Optional: copy the .so file as well as its .h header files into test program folder

2. After loading test program, open TestTool



3. In the TestTool, select the application library you want to link the .so file. double-click it to open its settings. Below shows that I selected ST_DLOG application library from my test program.



4.  Click on "Compiler and Linker" tab. Click the "Add Path.." button and select the path where the .so file is located.



5. Once done, you will see the path in the "Linker Paths" list box.



6. In the "Linker Flags" list box, click an empty row. then type -L<.so path> -l<.so name w/o lib prefix>. The -l flag lets me specify the filename of the .so file I want to use, but I without the 'lib' prefix and .so extension. My .so file's filename is liblib.so so removing the prefix and extension, it becomes -llib.



7. Click "Include Paths" tab.



8. Click the "Add Path.." button and select the path where the .h file is selected. Once done, you will see the path in the "Include Paths" list box.



9. Add the include file in the application library's source code. Below shows I declared the include on ST_Datalog.cpp. I included the 2 header files from my shared library - loop.h and print.h



10. Somewhere in ST_Datalog.cpp, i called mydemo::print() function which is defined in the shared library.


11. Finally, compile your application library.










Wednesday, July 4, 2018

How to Create Periodic and One-shot Timer in EIM

**Note that this also works on EIM @ solaris**


Assuming you want to create a periodic timer that starts with program or EIM loading, add the these codes to the following EIM entry points:

void myEIM::ExtIntfInit( ProgramControl *program, const int head )
{
// ------------------------------------------------------------------
// create periodic timer that fires every x amount of seconds
// ------------------------------------------------------------------
StopTimer(0xFF); // stop this timer first in case there's already one running with this id
unsigned int nSec = 60;
if (!CreateTimer(0xFF, 1, nSec, 0, true))
{
program->writeln(STDOUT, "ERROR! Failed to create periodic timer of %d seconds!\n", nSec);
}
else
{
time_t tTime;
  struct tm * localTime;
time ( &tTime );
  localTime = localtime ( &tTime );
program->writeln(STDOUT, "SUCCESS! Created periodic timer of %d seconds Starting at %s", nSec, asctime (localTime));
}
}

- myEIM is the external interface' name
- timer id for this code is 0xFF; you can set any unique integer you want
- the above code creates a periodic timer that immediately starts its countdown when CreateTimer() call is successful
- the timer is set to periodically trigger every 60 seconds

How to Increase Root Partition of CentOS 7 VMware

Part 1: Add a vmdk

1. Shutdown your CentOS 7 VMware and re-launch VMware player

2. Select your CentOS 7 VMware and click "Edit Virtual Machine Settings"


3. In the Hardware tab, click "Add.." button. "Add Hardware Wizard" dialog box will open


4. In the "Add hardware Wizard", select "Hard Disk". click "Next >"

5. Select "SCSI" as disk type. click "Next >"


6. Select "Create a new virtual disk". click "Next >"


7. Specify disk size in GB and select "Split virtual disk into multiple files." click "Next >"


8. Specify file name of the disk file. recommended to leave it as default. click "Finish".


9. In the "Virtual Machine Settings", you will now see "New Hard Disk" in the "Hardware" tab



Part 2: Configure LVM

1. Scan the host
find /sys -type f -iname "scan" -print

2. You will see the following list as shown below
[root@centos7vm localuser]# find /sys -type f -iname "scan" -print
/sys/devices/pci0000:00/0000:00:07.1/ata1/host1/scsi_host/host1/scan
/sys/devices/pci0000:00/0000:00:07.1/ata2/host2/scsi_host/host2/scan
/sys/devices/pci0000:00/0000:00:10.0/host0/scsi_host/host0/scan

3. Rescan the SCSI bus by passing to each host the "- - -".
# echo "- - -" > /sys/devices/pci0000:00/0000:00:07.1/ata1/host0/scsi_host/host0/scan
# echo "- - -" > /sys/devices/pci0000:00/0000:00:07.1/ata2/host1/scsi_host/host1/scan
# echo "- - -" > /sys/devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2/scan

4. create new pv for the new disk
pvcreate /dev/sdb

5. Now check if the new disk is now available
ls -ltr /dev/disk/by-id/

6. You will see the following list from above command
[root@centos7vm localuser]# ls -lrt /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Jul  4 15:36 lvm-pv-uuid-eN9yt9-jzpC-7Md5-9N1a-4bdP-i9Dn-jFZ1N4 -> ../../sdb
lrwxrwxrwx 1 root root  9 Jul  5  2018 ata-VMware_Virtual_IDE_CDROM_Drive_10000000000000000001 -> ../../sr0
lrwxrwxrwx 1 root root 10 Jul  5  2018 lvm-pv-uuid-GEwd0z-EDrV-hdB6-0o8M-S8eL-RzqU-gnSCIh -> ../../sda2
lrwxrwxrwx 1 root root 10 Jul  5  2018 dm-uuid-LVM-VhqLdEZRC9TbJfAu3v0q3aUREkRKgZbQl7dtNtoPOoI8yhrsKP3RFs70WdmfTP4o -> ../../dm-0
lrwxrwxrwx 1 root root 10 Jul  5  2018 dm-name-centos_centos7vm-root -> ../../dm-0
lrwxrwxrwx 1 root root 10 Jul  5  2018 dm-uuid-LVM-VhqLdEZRC9TbJfAu3v0q3aUREkRKgZbQL9essrhuujmOBF6M9VcK2LK0BUEeWlMR -> ../../dm-1
lrwxrwxrwx 1 root root 10 Jul  5  2018 dm-name-centos_centos7vm-swap -> ../../dm-1

7. One of the disk listed above points to our new disk /dev/sdb. in our above list, it's 
lvm-pv-uuid-eN9yt9-jzpC-7Md5-9N1a-4bdP-i9Dn-jFZ1N4 -> ../../sdb

8. Get your volume group of the root partition that we wish to expand
vgdisplay | grep 'VG Name'

    the output will be as shown below where "centos_centos7vm" is the volume group
[root@centos7vm localuser]# vgdisplay | grep 'VG Name'
  VG Name               centos_centos7vm

9. Let's now extend the root partition with the new disk
vgextend centos_centos7vm /dev/disk/by-id/lvm-pv-uuid-eN9yt9-jzpC-7Md5-9N1a-4bdP-i9Dn-jFZ1N4 -> ../../sdb

10. Do this command to finalize extending the root partition with the new disk. Note that the command says +20GiB but you can set the value to the size you set your new disk.
lvextend -r -L +20GiB /dev/centos_centos7vm/root

   

11. Finally, verify the change
[root@centos7vm localuser]# df -k
Filesystem                        1K-blocks     Used Available Use% Mounted on
/dev/mapper/centos_centos7vm-root  41141472 18793492  20444880  48% /
devtmpfs                            2006452        0   2006452   0% /dev
tmpfs                               2021876      156   2021720   1% /dev/shm
tmpfs                               2021876     9180   2012696   1% /run
tmpfs                               2021876        0   2021876   0% /sys/fs/cgroup
/dev/sda1                            999320   121212    809296  14% /boot
tmpfs                                404376        0    404376   0% /run/user/0
tmpfs                                404376       12    404364   1% /run/user/1001







Tuesday, June 19, 2018

How To Compile CURI FAmodule in CentOS 7.2 with U1709 64-Bit OS and CURI 1.21

Note that this instruction is tested only with the following system and software versions:

OS: CentOS 7.2
Unison: U1709
Curi: CURI_1.12_2.121.x86_64

1. edit your project.makefile to look like this:

TARGET_MINOR_VERSION = 1

SO_TARGET = fademo_hooks.so

# -- Start of project files --
PROJECT_SOURCES = fademo_attach.cpp \
fademo_hooks.cpp  \

PROJECT_HEADERS   = fademo_hooks.h \

NO_PTHREAD=true
MBITS=64
PROJECT_INCLUDE_PATHS = -DLINUX_TARGET -DLINUX -DUNISON -I. -I/ltx/include 
PROJECT_LIBRARIES=-Wl,-rpath,/ltx/lib$(MBITS) -L/ltx/lib$(MBITS) -levxa

ifeq ("$(BUILD_OS)", "Linux")
CFLAGS:=-DLINUX_TARGET
endif

LDFLAGS:=

prepare:

Note the "MBITS=64" added

2. update all "long" arguments in fademo_hooks.h, fademo_attach.cpp, fademo_hooks.cpp to FA_LONG and "unsigned long" to FA_ULONG if any

3. use this command to compile > gmake CFG=Release MBITS=64 MBITS_CURI=64

4. after compiling as above, the .so files are stored in ~Release/ folder. rename Release to Release64 

5. update CURI config file /opt/ateTools/curi/unison/config/curi_conf.xml to point to this FAmodule:

<CURI_CONF>
    <Config Configuration_ID="DefaultConfiguration">
        <ConfigEnv Equipment_Path="/opt/ateTools/curi/unison/lib" Communications_Path="/opt/ateTools/curi/unison/lib" User_Path="/home/localuser/Desktop/famodule/Release"/>
        <CommunicationsList>
            <GPIB_IF>
                <Settings>
                    <stringSetting token="IbcAUTOPOLL" value="0"/>
                </Settings>
            </GPIB_IF>
            <RS232_IF/>
            <TTL_IF/>
            <TTL_IF DriverID="ASL PCI PORT" AccessName="ASL_XP_TTL" Library="curi_asl_ttl" />
            <TTL_IF DriverID="ASL AT PORT" AccessName="ASL_NT_TTL" Library="curi_asl_ttl" />
            <TCPIP_IF Port="65000"/>
            <USB_IF/>
        </CommunicationsList>
    </Config>

    <UserLibrary AccessName="Demo famodule" Library="fademo_hooks">
        <Settings>
    <stringSetting token="Module Type" value="FAPROC Module"/>
    <stringSetting token="Priority" value="50"/>
        </Settings>
    </UserLibrary>

Where /home/localuser/Desktop/famodule/Release is the path (without the '64' suffix) where your Famodule .so file is located and fademo_hooks is the name of the .so file

6. make sure to relaunch Unison

Monday, June 18, 2018

READ THIS if you are trying to use Fademo (GEM Host Simulator) on any platform

CentOS7

  • must create a symbolic link libexpat.so.0 -> /usr/lib/libexpat.so.1.6.0 as fademo references to libexpat.so.0. Note that in previous versions of CentOS, this link may point out to an older version of libexpat (e.g libexpat.so.1.5.0 in CentOS 6.2) libexpat but that's fine. it works.