2013年9月30日 星期一

Android Board HAL Led control

Ref.
http://www.linuxforu.com/2010/12/writing-your-first-linux-driver
http://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html

http://bbs.witech.com.cn/forum.php?mod=viewthread&tid=46598&extra=page%3D1%26filter%3Dtypeid%26typeid%3D28%26typeid%3D28

1.
///set serial number on android
android2.3.4_32bit/system/core/init/init.c
//property_set("ro.serialno", serialno[0] ? serialno : "");
property_set("ro.serialno", "OK1ATV800006"); //by stone

2.
//find define mk
/xxxxxx/android2.3.4_32bit/build/core/core/envsetup.mk
TARGET_OUT := $(PRODUCT_OUT)/system
TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib

3.
//////////////HAL files reference///////////
C:\xxxxxx\android2.3.4_32bit\frameworks\base\services
C:\xxxxxx\android2.3.4_32bit\hardware\libhardware
C:\xxxxxx\android2.3_kernel_v1.01\arch\arm
C:\xxxxxx\android2.3_kernel_v1.01\drivers\char


OpenAL HRTF 3d sound on Linux & Android

source code download on 2016/06/25

https://github.com/kcat/openal-soft
also refer to
https://github.com/soundsrc/openal-soft

///////////////////////Ubuntu 14.04 linux system///////////////////////
1. preinstall
sudo apt-get install cmake
sudo apt-get install libsdl-sound1.2-dev

sudo add-apt-repository ppa:adrozdoff/ffmpeg-opti
sudo apt-get update
sudo apt-get install libavformat-ffmpeg-dev libavcodec-ffmpeg-dev libavutil-ffmpeg-dev libavfilter-ffmpeg-dev libswscale-ffmpeg-dev libswresample-ffmpeg-dev libpostproc-ffmpeg-dev

2013年9月29日 星期日

Build OK6041 environment

http://note.jhpeng.com/2013/01/sudo-apt-get-install-git-core-gnupg.html
http://e-xiao.blogspot.tw/2011/10/resolve-build-errors-for-android-234.html

1.
gedit /etc/init.d/rc.local
//add
mount /dev/sda3 /extdriver

add-apt-repository ppa:sun-java-community-team/sun-java6
apt-get update
apt-get install sun-java6-jdk

//remove ppa:sun-java-community-team/sun-java6 list, option
gedit /etc/apt/sources.list

arm gdb trace u-boot to start_kernel on i.mx6

1.
In Eclipse right click project
Debug As -> Debug Configurations -> GDB Hardware Debugging

2.
click Startup tab
uncheck the all items on startup page
add those lines under [Halt] box but do not check [Halt]
add-symbol-file /root/project_board/free_imx/out/matrix_io/uboot/u-boot 0x4FF04000
start debugging and trace code
(ps: in u-boot os keyin [bdinfo] show relocaddr = 0x4FF04000)

How to debug android linux kernel or driver by KGTP

Ref. http://code.google.com/p/kgtp/wiki/HOWTOCN

1. install pci serial port card (option install)

2. Vmware add hardware serial port (option install)

3. serial port assign com9 (option install)

Jtag Openocd Eclipse debug

OpenOCD debugging is the most efficient than KGDB.

1.
Seeedstudio Bus Blaster price is less than 40 US$ on Ebay. Very cheap.
bus blaster v3 or v3c or v4 or v4.1 connect to i.mx6dq jtag pings.(Vtg, Vcc disconnect)
Blaster      - I.Mx6dq
TRST         - TRSTn (Test access port reset)
TDI            - TDI
TMS          - TMS
TCK          - TCK
TDO          - TDO
TSRST      - nSRST (System reset)
GND         - GND

http://dangerousprototypes.com/docs/Bus_Blaster
http://www.mediafire.com/view/ozh1f11zx8s2g5s/BusBlaster_jtag.png#
http://www.mediafire.com/view/9tbesr2g5j1bp82/IMX6dq_jtag.png#

2. arm-eabi-gdb dependency lib
add-apt-repository ppa:fkrull/deadsnakes
apt-get update
apt-get install python2.6 python2.6-dev

3. openocd pre-install lib
apt-get update
apt-get install libftdi-dev
apt-get install libusb-1.0-0-dev
apt-get install texinfo
apt-get install automake autoconf libtool pkg-config

4.
http://sourceforge.net/projects/openocd/files/openocd/0.9.0
download file openocd-0.9.0.tar.gz
extract to
[~home]/openocd-0.9.0
or
open terminal window -> git clone git://git.code.sf.net/p/openocd/code

2013年9月28日 星期六

Bus Blaster flash to Swd mode in OpenOcd

Refer to
https://yeah.nah.nz/embedded/busblaster-kt-link
https://bgamari.github.io/posts/2014-08-23-swd-with-busblaster-and-openocd.html
http://bgamari.github.io/posts/2013-07-24-flashing-busblaster-cpld-with-openocd.html
https://discuss.96boards.org/t/sdw-debugging-carbon-stm32-using-bus-blaster-v3/958
https://gist.github.com/natevw/14d1f1fe669ec6e201c5

1.
~circuit
Bus Blaster SWD connect to Target
TCK ──────────────────────── SWCK
TMS ──────────────────────── SWDAT
GND ──────────────────────── GND

Using Bus Blaster V3C or V4.1a
http://dangerousprototypes.com/docs/Bus_Blaster_v3_design_overview
http://dangerousprototypes.com/docs/Bus_Blaster_v4_design_overview

2.
~Preinstall openocd 
https://github.com/fatalfeel/openocd_integrated

GitServer GitWeb GitLab on Bitnami

1. download GitLab 7.2.1-1
https://bitnami.com/stack/gitlab/installer

2. install open ssh
apt-get install openssh-server
http://bojack.pixnet.net/blog/post/29040829-%E3%80%90linux%E3%80%91%E5%9C%A8-ubuntu-%E4%B8%8A%E5%AE%89%E8%A3%9D-ssh-server

2013年9月27日 星期五

Ubuntu 12.04/14.04/16.04 install looks like 10.04

1. update sabertooth z87 bios to latest version in boot setup menu

2. install ubuntu 12.04.5 or 14.04.2
http://releases.ubuntu.com/12.04/
http://old-releases.ubuntu.com/releases/14.04.2/

ubuntu 14.04.2 linux kernel version is 3.16.0-xxx

3. burn iso file in DVD

4. setting DVD first boot in motherboard bios

5. create primary partition assign mount / ([/] = root directory)
My PC: 1Tb Hard disk and 8gb real ram
size         : 496gb
type         : Primary
use as      : Ext4
Mount point : /

2013年9月26日 星期四

Vivante 3d gc2000 work flow

///////////////////////////create device node /dev/galcore/////////////////////////////
$home/myandroid/kernel_imx/drivers/mxc/gpu-viv/Kbuild
MODULE_NAME ?= galcore
/* define node name*/
$home/myandroid/kernel_imx/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_linux.h
define DEVICE_NAME "galcore"

$home/myandroid/kernel_imx/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_probe.c
drv_init call
ret = register_chrdev(major, DEVICE_NAME, &driver_fops);

boot.img to image (binary vmlinux)

1. download image unpack tools
http://www.mediafire.com/file/2zcwc74bzjxej4b/android_bootimg_tools.tar.gz

2.
mkdir ./zimage
./unpackbootimg -i boot.img -o ./zimage

2013年9月24日 星期二

BaudRate setting for u-boot and kernel on i.mx6

gedit /root/project_board/free_imx/myandroid/bootable/bootloader/uboot-imx/include/configs/mx6_matrix_common.h
//#define CONFIG_BAUDRATE               115200 //by stone
#define CONFIG_BAUDRATE                  460800

gedit /root/project_board/free_imx/myandroid/bootable/bootloader/uboot-imx/include/config_fallbacks.h
//#define CONFIG_SYS_BAUDRATE_TABLE    { 9600, 19200, 38400, 57600, 115200 } //by stone
#define CONFIG_SYS_BAUDRATE_TABLE    { 9600, 19200, 38400, 57600, 115200, 230400, 460800 }

2013年9月22日 星期日

Task queue and ini

1.
using pthread_mutex_t for lock
using pthread_cond_t for signal
using std::vector for queue
using singleton in class
static TaskQueue*   Get();
static void         Free();

2. task queue source clip
int TaskQueue::Process(int type, NODE_YUV* node_yuv)
{
    int ret; //each thread own it's local variable address
    pthread_mutex_lock(&m_process_lock);

    switch(type)
    {
        case 0: //read first node
            if ( ret = m_vqueue.size() > 0 )
            {
                memcpy(node_yuv, &(*m_vqueue.begin()), sizeof(NODE_YUV));
                m_vqueue.erase(m_vqueue.begin());
            }
            break;

        case 1: //save last node
            m_vqueue.push_back(*node_yuv);
            break;
    }

    pthread_mutex_unlock(&m_process_lock);

    return ret;
}

void TaskQueue::TaskThreadLoop()
{
    int         ret;
    NODE_YUV    node_yuv;

    while(m_thread_work)
    {
        ret = Process(0, &node_yuv);
        if( ret )
        {
            //ur work start

            //ur work end
           
            printf("free %p size=%d\n", node_yuv.buf, node_yuv.size);
            free(node_yuv.buf);
        }
        else
        {
            //wait signal when queue empty
            pthread_mutex_lock(&m_taskqueue_work_lock);
            pthread_cond_wait(&m_taskqueue_work_cond, &m_taskqueue_work_lock);
            pthread_mutex_unlock(&m_taskqueue_work_lock);
        }
    }
}

3.
using std::ifstream for reading
using std::ofstream for writing

4. ini source clip
std::ifstream   inifile;
inifile.open(m_filepath, std::ifstream::in);

std::ofstream   inifile;
inifile.open(m_filepath, std::ofstream::out | std::ofstream::trunc);

source download:
https://www.mediafire.com/file/pry0z0x8pdsnm29/taskqueueini.tar.gz

Arm MCR command explain

MCR p15,0,<Rd>,<CRn>,<CRm>,<Opcode_2>
<CRm>和<Opcode_2>兩者組合決定對協處理器寄存器進行所需要的操作,如果沒有指定則<CRm>為C0,<Opcode_2>為0, 否則導致不可預知的結果.

Build web site and get free server Firebase

1.
Download  web server Nginx
http://nginx.org

this local server is for html response

2.
Register Firebase remote server
https://firebase.google.com

Firebase can create chat and webrtc server free
Peer to peer authenticate through the Firebase remote server.

3.
Go to Firebase control panel
https://console.firebase.google.com

Uart to LinBus on Android

Ref.
1. https://rtime.felk.cvut.cz/can/lin-bus/
    for Uart to linbus

2. https://github.com/linux-can/can-utils
    for slcan_attach modify

3. https://github.com/karelzak/util-linux
    for ldattach

4. https://github.com/shemminger/iproute2
    for ip link set up in C code
  
///// Linux Kernel /////
1. Copy sllin.c to kernel_imx/drivers/net/can

2. gedit kernel_imx/include/uapi/linux/tty.h
//add
#define N_SLLIN            25

Client HID of Bluez for Bluetooth Qualification

Download client HID sample code
http://anselm.hoffmeister.be/computer/hidclient/hidclient-20120728.tar.bz2

HID report descriptor sample
http://www.instructables.com/id/USB-Wii-Classic-Controller/step13/Bonus-Keyboard-and-Mouse

Register record to SDP sample
http://blog.csdn.net/huipengzhao/article/details/18268201

2013年9月21日 星期六

Eclipse debug Android framework and service

To prepare Eclipse:
http://fatalfeel.blogspot.tw/2013/09/eclipse-setting-for-ubuntu-imx6-android.html

//////////////////////////////////////////////
////////Debug surfaceflinger////////
//////////////////////////////////////////////
1.
gedit ~/OK8MM-android-source/frameworks/native/services/surfaceflinger/Android.mk
//add
LOCAL_CFLAGS += -O0 -g
LOCAL_CPPFLAGS += -O0 -g
LOCAL_STRIP_MODULE := false

2013年9月20日 星期五

Python debug with Eclipse ide

ref. https://kodi.wiki/view/HOW-TO:Debug_Python_Scripts_with_Eclipse

1.
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk

2. (if you have another version hava do this)
update-alternatives --config java
update-alternatives --config javac
update-alternatives --config javadoc

java -version
javac -version
javadoc -J-version

Build Eclipse debug environment for Android on Ubuntu

//////////////Install OpenJdk 7.0
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-7-jdk

update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-6-oracle/jre/bin/java 1100
update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1101
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-6-oracle/bin/javac 1100
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1101
update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/java-6-oracle/bin/javadoc 1100
update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/java-7-openjdk-amd64/bin/javadoc 1101

update-alternatives --config java
update-alternatives --config javac
update-alternatives --config javadoc
or
update-alternatives --set java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
update-alternatives --set javac /usr/lib/jvm/java-7-openjdk-amd64/bin/javac
update-alternatives --set javadoc /usr/lib/jvm/java-7-openjdk-amd64/bin/javadoc

//check version
java -version
javac -version
javadoc -J-version

Using arm gdb to find crash line of source file

1.
Make sure in default config
#CONFIG_ARM_UNWIND is not set
CONFIG_DEBUG_INFO=y
CONFIG_FRAME_POINTER=y
CONFIG_FRAME_POINTER depend on follows
CONFIG_CC_OPTIMIZE_FOR_SIZE=n
CONFIG_HAVE_FUNCTION_TRACER=y
CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
CONFIG_HAVE_DYNAMIC_FTRACE=y
CONFIG_TRACING_SUPPORT=y
CONFIG_FTRACE=y
CONFIG_FUNCTION_TRACER=y
CONFIG_DYNAMIC_FTRACE=y

2.check structure~myandroid/kernel_imx/arch/arm/include/uapi/asm/ptrace.h
struct pt_regs
{
  long uregs[18];
};

#define ARM_pc uregs[15]
#define ARM_lr uregs[14]

Start another process independent in linux

Android startup app from init.rc

1. facerecognition.sh
#!/system/bin/sh /system/bin/am start -n com.luxand.facerecognition/com.luxand.facerecognition.MainActivity

2. topeet_6dq.mk
gedit /mnt/ssd/iTOP-iMX6_android4.4.2/device/fsl/imx6/topeet_6dq.mk
#add
PRODUCT_COPY_FILES += \
device/fsl/matrix_io/etc/facerecognition.sh:system/etc/facerecognition.sh

Git2 lib for Win32 and Linux

///////////Win32/////////////
1. git2 source
https://github.com/libgit2/libgit2
Revision: eb5f03461fbcaa3fef8e63d1b0f7c682708fadd2 / Date: 2014/7/11 下午 06:22:48
installed

2. download cmake
http://www.cmake.org/cmake/resources/software.html
installed

3. install zlib - Complete package, except sources
http://gnuwin32.sourceforge.net/packages/zlib.htm
installed

2013年9月19日 星期四

Selinux from user-space to kernel

//build in debug mode
modify $home/myandroid/system/core/init/property_service.h
int property_get(const char *name, char *value)
{
    /*size_t value_len = __builtin_object_size(value, 0);
    if (value_len != PROP_VALUE_MAX)
        __property_get_size_error();*/

    return __property_get(name, value);
}

$home/myandroid/external/libselinux/src/avc.c
int avc_has_perm_noaudit(...)
{
...
...

Android App communication through binder to user-space (IPC)

Ref.
http://wangkuiwu.github.io/2014/09/03/Binder-ServiceManager-Daemon/

[The example is a system app send message through binder to mediaserver audio]
Target:
1.
external/sepolicy/system_app.te

type system_app, domain;
app_domain(system_app)
net_domain(system_app)
### begin issue: ###
binder_use(system_app)
binder_call(system_app, binderservicedomain)
binder_call(system_app, appdomain)
### end issue: ###
binder_service(system_app)

Install libgtk2 and libwxgtk3 in Ubuntu

1. install gtk
download libglib2.0-dev deb
https://ftp.nsysu.edu.tw/Ubuntu/ubuntu/pool/main/g/glib2.0

gdebi ./libglib2.0-dev_2.40.0-2_amd64.deb

2013年9月18日 星期三

Eclipse debug Android jni c/c++ of system app on Ubuntu

To prepare Eclipse:
https://fatalfeel.blogspot.tw/2013/09/build-eclipse-debug-environment-for.html
//////////////////////////////////////////////
Debug LinbusConfig App
//////////////////////////////////////////////
1.
~myandroid/frameworks/base/cmds/app_process/Android.mk
LOCAL_PATH:= $(call my-dir)
.
.
LOCAL_MODULE:= app_process
.
.
LOCAL_CFLAGS                := -O1 -g
LOCAL_CPPFLAGS             := -O1 -g
LOCAL_STRIP_MODULE    := false
include $(BUILD_EXECUTABLE)

Eclipse debug Android jni c/c++ of App on NDK R13

Include NDK R13 Method
////////////////eclipse setting//////////////////
http://www.eclipse.org/downloads/packages/release/Kepler/SR2
Eclipse Standard 4.3.2 -> linux 64bits
install eclipse-standard-kepler-SR2-linux-gtk-x86_64.tar.gz
extract to /opt/eclipse
chmod 755 -R /opt/eclipse

gedit /opt/eclipse.ini
-XX:PermSize=64m
-XX:MaxPermSize=256m
-Xms128m
-Xmx4096m

Solve Ubuntu 12.04/14.04 can not login to desktop

Reason why is lightdm or ubuntu-desktop damage

1. install gdm
after startup press ctrl+alt+F1 and login
apt-get -f install gdm
dpkg-reconfigure gdm  -> select gdm
reboot

2.
After startup
gdm simple mode login
open terminal
(If terminal all black or all white then setting forground color
Ternimal -> 編輯 -> 設定組合偏好設定 -> 顏色 -> 文字顏色 -> 白色)

Cross platform Secs/Gem open source

////////////////////////////////////////////////
///////////Project Download
////////////////////////////////////////////////
http://www.mediafire.com/file/khpjkq4fgssh3yp/GemHsms2018.zip

1.This project can build on VC++ on Win32 and Eclipse CDT on Linux.
2.Need preinstall ACE Wrappers and Xerces
3.Memory leak fixed
4.File secs.xsd grammar fixed

2013年9月16日 星期一

Openal 3D sound for tinyalsa android sound

Openal tinyalsa for android 6.0 fit for all android sound stream
It's for android low level sound stream. Processing After android Audioflinger.

1.
tinyalsa put in ~myandroid/external/tinyalsa

2.
OpenalConfig put in ~myandroid/packages/apps

3.
add this line in system_app.te
allow system_app default_prop:property_service set;

add this line in mediaserver.te
allow mediaserver default_prop:property_service set;

make sure remove this line in all *.te
neverallow { ... -system_app } default_prop:property_service set;

download:
http://www.mediafire.com/file/w8hh29ck0apnep2/tinyalsa_openal.tar.gz

Building 3d game Doom1 on Ubuntu 16.04

1.
apt-get install freedoom

2.
wget https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.0.18.tar.gz
#mirror site https://github.com/libsdl-org/SDL/tags
tar -xvf ./release-2.0.18.tar.gz
cd SDL-release-2.0.18
./configure --prefix=/usr
make -j8 && make install

3.
rm -f /usr/lib/x86_64-linux-gnu/libSDL2-*
cp -fP /usr/lib/libSDL2* /usr/lib/x86_64-linux-gnu

HelloWorld cross compile on Mingw64

#install mingw64
apt install gcc-mingw-w64

#install wine
ubuntu 18.04
apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
ubuntu 16.04
apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main'

apt update
apt install --install-recommends winehq-stable

2013年9月15日 星期日

KdeSvn (Gui Svn) in ubuntu 12.04/14.04

KdeSvn was written by C++ good and fast~~~

Download kdesvn-master.zip
https://github.com/KDE/kdesvn

apt-get install cmake
apt-get install kdelibs5-dev kdelibs5-plugins
apt-get install libapr1-dev libaprutil1-dev
apt-get install libsvn-dev
apt-get install oxygen-icon-theme

2013年9月14日 星期六

Android camera yuv to rgb rgba with arm neon

///
///n21 to rgb
///
static uint8x8_t const loaduv(unsigned char const* uv)
{
   return vld1_u8(uv);
}

static void store_pixel_block(unsigned char* dst, uint8x8x3_t& pblock, uint8x8_t const& r, uint8x8_t const& g, uint8x8_t const& b)
{
   pblock.val[0] = r;
   pblock.val[1] = g;
   pblock.val[2] = b;
   vst3_u8(dst, pblock);
}

2013年9月12日 星期四

Json to Xml and Xml to Json open source

Refer to:
1. https://github.com/DaveGamble/cJSON
2. https://github.com/aMonst/json_xml_transf

Dts Dtsi device tree setting and code

Device tree .dts parser, it's like Tinyxml

///////////////paser dts
gedit /root/project_board/free_imx/myandroid/kernel_imx/drivers/of/fdt.c
void __init unflatten_device_tree(void)
{
    //of_allnodes get full Tree
    __unflatten_device_tree(initial_boot_params, &of_allnodes, early_init_dt_alloc_memory_arch);
   
    of_alias_scan(early_init_dt_alloc_memory_arch); //start parser
}

2013年9月11日 星期三

Start a independent process in C

There are 3 id in you process
getpid(), getpgid(getpid()), getsid(getpid()).

1. caller side
#use posix_spawn get spawn id and wait until target independently

pid_t spawnid;
pid_t targetid;
char* args[] = {"targetname", "usb", "1", "2", NULL};

posix_spawn(&spawnid, "/root/hdapi/targetname/bin/targetname", NULL, NULL, args, environ);

targetid = 0;
while( targetid != spawnid ) //wait targetname totally independent    {
targetid = getsid(spawnid);
usleep(1000);
}

2013年9月10日 星期二

Device node building

/* Given the minor device number and name,
     Tell Linux how many device numbers to apply for,
     Linux system help you find the major device number*/
if((alloc_chrdev_region(&devno, 0, 1, "hello_driver")) <0){
    pr_err("Cannot allocate major number\n");
    return -1;
}

Psychology of programming - How to place the left brace

After read Allman Style, K&R style, GNU style
https://en.wikipedia.org/wiki/Indentation_style

ISO C99, ISO C++ 2011, ISO C++ 2014, ISO C++ 2020
https://www.mediafire.com/file/3xy4u72o4g9uft2/ISO_C_and_C%252B%252B__International_Standard.zip

Hungarian notation & its history
https://idleloop.com/hungarian/
https://en.wikipedia.org/wiki/Talk%3AHungarian_notation
https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/general-naming-conventions

The Psychology of Computer Programming & An Introduction to General Systems Thinking by Weinberg
https://en.wikipedia.org/wiki/Gerald_Weinberg

Also wrote in many system:
Linux kernel, Zephyr, C#, Inline assembly, Android framework & App, IOS Object-C App, Python3 for AI, Scala for Risc-V, Buildroot, Bash, Makefile and trace GNU gcc source. Then post this topic.

2013年9月6日 星期五

TCP nonblock socket server and client

Server:
static void Init_Server(int port)
{
  int                             err, flags;
  struct sockaddr_in    server_addr;

  s_server_fd = socket(AF_INET, SOCK_STREAM, 0);
  if (s_server_fd < 0)
      on_error("Could not create server_addr socket: %s\n", strerror(errno))

  server_addr.sin_family = AF_INET;
  server_addr.sin_port = htons(port);
  server_addr.sin_addr.s_addr = htonl(INADDR_ANY);

2013年9月3日 星期二

simple Httpd server Mongoose

ref http://code.google.com/p/mongoose/downloads/list

1. search all download find mongoose-2.8

2. here I build all sample in vs2008, download it
http://www.mediafire.com/?0k3vrk6tvz104v9

Android Horizon Scroll TAB extends Activity only

/////////////in main.xml
xml version="1.0" encoding="utf-8"
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#C0000000"
android:cacheColorHint="#00000000"

TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">


Cross platform inter thread communication

//////////////function pointer//////////////
template class IEventFunctorBase
{
public:
virtual void Call(ParamType& event) = 0;
virtual void* GetThis() = 0;
};

Proton 3d engine open source on android, ios, win32, macos

Ref:
http://www.rtsoft.com/wiki/doku.php?id=proton:android_projects#v2_styles
http://www.rtsoft.com/wiki/doku.php?id=proton:linux_setup

/////////////////////////////Android win32/////////////////////
1.Install Cygwin
http://www.cygwin.com/
switch item Devel [Default] to [Install]

H264 high profile decoder in VC9 include sse3 asm

H264 decode in VC9 include sse3 asm codec

1. download file high_profile_h264.zip from
http://www.mediafire.com/?932mmcx6lb79lyb

2. install MinGW

3. set executable files path for VC9 EX. C:\Program Files\MinGW\bin

4. build path name only in ascii code, can not unicode EX. c:\hi_ff264 or d:\hi_ff264 is good

5. Choice register in config.h #define HAVE_MMX 1 #define HAVE_MMX2 1 #define HAVE_SSE 1 #define HAVE_SSSE3 1

6. this code extract from ffmpeg-r26400-swscale-r32676 can decode h.264 high profile format

7. output use YUV420_TO_RGBA32_MMX() for opengl format you can modify this function for directx

8. GBRA32 MMX code reference
http://www.mediafire.com/?8u2gam3jfecgdb7

Motodev Studio 5.0 in linux(help you debug native c++)

ref. http://fatalfeel.blogspot.tw/2013/09/debug-cocos2d-in-c-android-ndk-eclipse.html
ref. http://www.motorola.com/sites/motodev/library/motodev_core_plugins.html
ref. http://developer.android.com/tools/devices/emulator.html#acceleration


1. Download Android-Sdk, Sdk Platform-tools, Ndk
http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
http://dl.google.com/android/repository/platform-tools_r12-linux.zip
extract to /usr/local/android-sdk-linux

http://www.crystax.net/en/download
download android-ndk-r7-crystax-5.beta3-linux-x86.tar.bz2
extract to /usr/local/android-ndk-r7-crystax-5.beta3

gtk 2.17.2+dfb drag and drop function fixed

gdkdnd-directfb.c

//refer to _gdk_windowing_window_get_pointer in gdkwindow-directfb.c
//and gdk_directfb_child_at in gdkevents-directfb.c
GdkWindow*
dnd_windowing_window_get_child (GdkWindow* node, GdkWindow* dragwin, gint x, gint y)
{
GdkWindowObject *win;
GdkWindowObject *private;
GList *list;

private = GDK_WINDOW_OBJECT (node);

Fixed iOS Simulator trouble from Xcode 3.X to 4.X

!!Notice do not use "root" login

#Xcode 3 ver in Xcode 4 project modify
cd into the PROJECT_NAME.xcodeproj directory
delete all previous [LoginUserName] files and directories
Reopen Xcode4 and build

#solve simulator-> error: failed to attach to process ID 0
Basically it means Xcode is not able to attach a build of your app to the simulator.
To solve this problem, simply do the following:

1.Click on Simulator and reset the simulator by going to the > OS Simulator > main menu choose > Reset Content and Settings

2."Product" > "Edit Scheme". On the left menu panel, click on "Run Project_Name.app".
The info display on the right should have the "Debug Process As" radio button picked as "Me (user-name)".
If not, make sure you do not login as "root".

3.Xcode, go to the menu "Window" > "Organizer". On the top menu, click on "Projects". Go ahead and delete "Derived Data".

4.delete "~/Library/Application Support/iPhone Simulator/6.0/Applications"

Poco with cocos2d in Android and Ios

//////////////build poco-1.4.4-all with Android NDK in Linux

root@ubuntu:~# /usr/local/android-ndk-r7-crystax-5.beta2/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/usr/local/android-toolchain

//Poco build command line
#Need full path configure, Otherwise you'll get an error saying "Current working directory not under $PROJECT_BASE."

export PATH=$PATH:/usr/local/android-toolchain/bin
/root/poco-1.4.4-alllinux/configure --prefix=/usr/local/poco-1.4.4 --config=Android --no-samples --no-tests --omit=NetSSL_OpenSSL,Crypto,Data/ODBC,Data/MySQL,PageCompiler

make

make install


Server and clients MultiPlayer Ryzom Source code

1. Download source code in c:\ or d:\
http://www.mediafire.com/?ikbz8l233wy7wj2

2. Download
http://sourceforge.net/projects/ryzom/files/ryzom_client.7z
then extract ryzom_client.7z to
C:\Documents and Settings\JesseStone\Application Data\Ryzom

Server and clients MultiPlayer ManaWorld Source code

Ref:
https://github.com/mana/manaserv
https://github.com/themanaworld/tmwa
https://github.com/tales/sourceoftales/wiki/How-to-setup-a-local-server

1. Preinstall codeblocks
https://sourceforge.net/projects/codeblocks/files/Binaries/13.12

2. codeblocks->Settings->Environment->General Settings,
uncheck "Allow only one running instance",
uncheck "Use an already running instance", and restart.
For debug 3 projects simultaniously.

Debug Cocos2d in C + Android NDK + Eclipse in Ubuntu

Ubuntu Linux Version

//////////////////////////////////////////////////////
Ref.
http://blog.plicatibu.com/how-to-debug-cocos2d-x-and-java-code-using-eclipse
http://ibeyond.blog.51cto.com/1988404/1109559
http://developer.android.com/guide/developing/device.html
http://blog.csdn.net/luoshengyang/article/details/6768304
////////////////////////////////////////////////////////

Concept:
begin break point in java debug first
then start ndk-gdb-eclipse server
use MOTODEV C++ debug > arm-linux-androideabi-gdb connect it
and continue java debug

Cocos2d + Android NDK + Eclipse in Win32

Ref.
http://www.eoeandroid.com/thread-156516-1-1.html
http://www.eoeandroid.com/thread-93743-1-1.html
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_run_test_cases_on_android-ndk

1.JDK 6
jdk-6u16-windows-i586.exe

2.Eclipse
eclipse-java-helios-SR2-win32.zip
http://www.eclipse.org/downloads/packages/release/helios/sr2

Linux inline asm and Macro expansion

Macro expansion:
vc:
cl /P panic.c

linux:
C:\Progra~1\MinGW\bin\mingw32-g++ -E -P panic.c -o panic.i

prototype generate:
vc:
cl /Zg panic.c

linux:
C:\Progra~1\MinGW\bin\mingw32-g++ -c -P panic.c -aux-info panic.i

Ubuntu + OpenAl-static

//refer to http://hi.baidu.com/%CF%B5%B4%C7%CF%C2%B4%CE/blog/item/f14cb71d375ae36adab4bd11.html

//put openal-soft-1.12.854.tbz2 in home

apt-get install cmake


How ot make .a and .so and use it

//refer to http://blog.yam.com/ytha/article/16636287

Generally, gcc is used to compile C language programs under Linux. By default, the compiler will only search for the standard C99 library.
Such as stdio.h, math.h, etc., while standard Linux system functions are usually stored in /lib and /usr/lib, So it is necessary to tell the compiler (linker) which function library to search, and the name of the function library under Linux always starts with lib,
Subsequent names are determined according to the library (m stands for math library), and the extension .a refers to the static library, and .so refers to the shared library.

Vmware+Ubuntu+wxWidgets-2.8.11+sqlite3-3.6.22+wxsqlite3+openGl

ref. http://converse-2008.blogspot.com/2010/09/how-to-building-opengl-in-ubuntu.html

apt-get install build-essential
apt-get install libgl1-mesa-dev
apt-get install libglu1-mesa-dev
apt-get install freeglut3-dev

In example.c


Gtk 2.17.2 drag and drop background bug fixed part 2

gdkdrawable-directfb.c

static void
gdk_directfb_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height)
{

gint i;
gint pitch;
GdkRegion clip;
GdkDrawableImplDirectFB *impl;
GdkGCDirectFB *gc_private = NULL;
IDirectFBSurface *surface = NULL;
guchar* ucbits;
//GdkWindowImplDirectFB* wimpl;
//GdkWindowObject* private;
GdkDrawableImplDirectFB* bgimpl;


Gtk 2.17.2 drag and drop background bug fixed part 1

gdkpixbuf-render.c

void
gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf,
GdkBitmap *bitmap,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height,
int alpha_threshold)
{
GdkGC *gc;
GdkColor color;
int x, y;
guchar *p;
int start, start_status;
int status;


Gtk+-2.17.2 + dfb words wrong update fixed

Modify as follows

static void gdk_window_impl_directfb_end_paint (GdkPaintable *paintable)
{
gint i;
GdkDrawableImplDirectFB *impl;

impl = GDK_DRAWABLE_IMPL_DIRECTFB (paintable);

D_DEBUG_AT( GDKDFB_Window, "%s( %p )\n", __FUNCTION__, paintable );


static gtk+-2.17.2 your single file make Part 3

4.gedit /gtk+-2.17.2/dndtest/Makefile

FBDEV_OBJS = /usr/ubuntufb/lib/directfb-1.3-0/wm/libdirectfbwm_default.o\
/usr/ubuntufb/lib/directfb-1.3-0/systems/libdirectfb_fbdev.o\
/usr/ubuntufb/lib/directfb-1.3-0/inputdrivers/libdirectfb_linux_input.o\
/usr/ubuntufb/lib/directfb-1.3-0/inputdrivers/libdirectfb_keyboard.o\
/usr/ubuntufb/lib/directfb-1.3-0/inputdrivers/libdirectfb_ps2mouse.o

srcdir = .
top_srcdir = ..

pkgdatadir = $(datadir)/gtk+
pkglibdir = $(libdir)/gtk+
pkgincludedir = $(includedir)/gtk+
top_builddir = ..


static gtk+-2.17.2 your single file make Part 2

3.gedit /gtk+-2.17.2/dndtest/dndtest.Po

dndtest.o: dndtest.c /usr/include/stdio.h /usr/include/features.h \
/usr/include/bits/predefs.h /usr/include/sys/cdefs.h \
/usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
/usr/include/gnu/stubs-32.h \
/usr/lib/gcc/i486-linux-gnu/4.4.3/include/stddef.h \
/usr/include/bits/types.h /usr/include/bits/typesizes.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i486-linux-gnu/4.4.3/include/stdarg.h \
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
/usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \
/usr/include/endian.h /usr/include/bits/endian.h \
/usr/include/bits/byteswap.h /usr/include/sys/select.h \
/usr/include/bits/select.h /usr/include/bits/sigset.h \
/usr/include/bits/time.h /usr/include/sys/sysmacros.h \
/usr/include/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/unistd.h /usr/include/bits/posix_opt.h \
/usr/include/bits/confname.h /usr/include/getopt.h /usr/include/string.h \
/usr/include/xlocale.h ../config.h ../gtk/gtk.h ../gdk/gdk.h \
../gdk/gdkapplaunchcontext.h /usr/ubuntufb/include/glib-2.0/gio/gio.h \

static gtk+-2.17.2 your single file make Part 1

Target is make a dndtest execute file

1.make directory in /gtk+-2.17.2/dndtest

///////////////////////////////////////////////////////////

2.gedit /gtk+-2.17.2/dndtest/dndtest.c

#include
#include
#include
#include
#include "config.h"
#include "gtk/gtk.h"


Gtk+-2.17.2 + directfb Scroll black area bug fixed

Modify gdkgeometry-directfb.c will fixed

/*if (gdk_rectangle_intersect (&rect, &clip_rect, &rect) &&
(!private->update_area ||
!gdk_region_rect_in (private->update_area, &rect)))
{
GdkRegion *region;

region = gdk_region_rectangle (&rect);
gdk_region_subtract (invalidate_region, region);
gdk_region_destroy (region);

if (impl->surface)
{
DFBRegion update = { rect.x, rect.y,
rect.x + rect.width - 1,
rect.y + rect.height - 1 };

impl->surface->SetClip (impl->surface, &update);
impl->surface->Blit (impl->surface, impl->surface, NULL, dx, dy);
impl->surface->SetClip (impl->surface, NULL);
impl->surface->Flip(impl->surface,&update,0);
}
}*/

Set eclipse to debug Gtk+directfb in Ubuntu

Refer to:
1. http://www.eit.name/blog/read.php?447
2. http://hi.baidu.com/googlekongjianddd/blog/item/09ea538bcc38d818c9fc7a4a.html

1.
apt-get install eclipse
To use only  jdk and jre packages for eclipse-c/c+
so go to synaptic remove contain name that include eclipse
or
add-apt-repository ppa:sun-java-community-team/sun-java6
apt-get update
apt-get install sun-java6-jdk

If meet "ca-certificates-java depends on openjdk-6-jre-headless"
then
sudo dpkg --purge bleachbit ca-certificates-java icedtea-6-plugin icedtea-netx
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer


2. Remove sun server (option).
gedit /etc/apt/sources.list
remove ppa:sun-java-community-team/sun-java6

Static gtk+-2.17.2 + Directfb cross compile on Ubuntu

In Ubuntu 10.4 Desktop and "root" login

apt-get install build-essential libncurses5-dev

apt-get install autoconf

apt-get install libtool

apt-get install gettext

apt-get install libglib2.0-dev

apt-get install libgtk2.0-dev

cd zlib-1.2.3

//zlib-1.2.3


Enable Framebuffer mode in Ubuntu 12.04/14.04 of Vmware

Check fb type
dmesg | grep vesa

//ver 12.04
gedit /boot/grub/grub.cfg
//ver 14.04
gedit /etc/default/grub

quiet splash
change to
quiet splash vga=792

Static build in VC9 GtK+-2.90.0 / GtK+-2.21.1

Refer to http://xullicious.com/gtk-win32.php

1.Need Gnuwin32 by fatalfeel
http://www.pudn.com/downloads264/sourcecode/windows/control/detail1213704.html

2.fatalfeel's all GTK package
http://www.pudn.com/downloads264/sourcecode/windows/control/detail1212874.html

Static cross compile gtk-2.16.6+gtk-directfb+arm-linux (arm-linux-gcc-3.4.3+uClibc-0.9.28)

Refer to zsfly.cublog.cn GTK+/DirectFB

Donwload address:
1. libiconv-1.9.2 http://ftp.gnu.org/pub/gnu/libiconv/

2. gettext-0.14.6 http://ftp.gnu.org/pub/gnu/gettext/

In Ubuntu 10.4 Desktop and "root" login

mkdir usr/local/armlinux, extract arm-linux-gcc-3.4.4-glib-2.3.5-static.tar.gz to usr/local/armlinux
edit /etc environment document file add /usr/local/armlinux/bin

Static cross compile gtk-2.16.6+gtk-directfb+arm-linux (arm-linux-gcc-3.4.4+glib-2.3.5)

Refer to zsfly.cublog.cn GTK+/DirectFB

In Ubuntu 10.4 Desktop and "root" login

apt-get install build-essential libncurses5-dev

apt-get install autoconf

apt-get install libtool

apt-get install gettext

apt-get install libglib2.0-dev

apt-get install libgtk2.0-dev

Arm Linux Debug IDE Eclipse

////////////////////// All unbuntu fourm ////////////////////////////////////
http://wiki.ubuntu-tw.org/

//////////install Vmware7.1 + Ubuntu 10.4 install Guide ////////////////////////////////////////////
http://www.vcbeta.net/read.php/424.htm
http://releases.ubuntu.com/

http://os.51cto.com/art/200901/104983.htm
http://www.cnitblog.com/aimilo2008/archive/2009/07/22/60286.html (reference red hat install)

///////// Gcc install recommand use root to work ////////////////////////////////////////////
sudo passwd root
then logout and login with root
apt-get install build-essential

cross compile gtk+gtk-directfb+arm-linux (arm-linux-gcc-3.4.4+glib-2.3.5)

Refer to 一生逍遙
2010年7月1日 by Jesse Stone Taiwan fatalfeel@hotmail.com

參考文獻1:http://blog.csdn.net/kendych/archive/2008/09/18/2947638.aspx
參考文獻2:https://wiki.mozilla.org/Mobile/DFBPorting
參考文獻3:http://blog.csdn.net/absurd/category/228434.aspx
參考文獻4:http://hi.baidu.com/chinalmy/blog/item/da814a5450a9e352574e0046.html
參考文獻5:http://www.docin.com/p-44613303.html
address1:http://hi.baidu.com/wstone_h/blog/item/e415151f82a45564f724e46d.html
address2:http://hi.baidu.com/wstone_h/blog/item/9cd8a010061bf6fbc3ce7901.html