2010-01-30 06:42:50     Running mysqlclient on uClinux for the blackfin processor

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2010-01-30 06:42:50     Running mysqlclient on uClinux for the blackfin processor

Li Yuqian (CHINA)

Message: 85358   

 

Hi all,

 

we just make some testing on our IPPBX using mysql client library, that IPPBX based 2.6.22.19-ADI-2008R1.5 version uClinux, running on a BF533/BF537 CPU, till now it working good :), following is our testing step, hope this can give you some clue for mysql client using on uClinux

 

--------------------

 

1. first we need compiling mysqlclient library, going to uClinux-dist, running:

 

[root@edgepbx uClinux-dist-2008R1.5-RC3]# make config_menuconfig

 

select Miscellaneous Applications --> [*] mysql and [*]   client library

 

[root@edgepbx uClinux-dist-2008R1.5-RC3]# make

 

when finished, you will got a libmysqlclient.a file at uClinux-dist-2008R1.5-RC3/user/mysql/libmysql/.libs directory,

 

[root@edgepbx .libs]# mkdir -p /root/nanoast/uClinux-dist-2008R1.5-RC3/staging/lib/mysql/

 

[root@edgepbx .libs]# cp libmysqlclient.a ../libmysqlclient.la /root/nanoast/uClinux-dist-2008R1.5-RC3/staging/lib/mysql/

 

[root@edgepbx .libs]# cd ../../include/

 

[root@edgepbx include]# mkdir -p /root/nanoast/build_fx08/uClinux-dist-2008R1.5-RC3/staging/include/mysql/

[root@edgepbx include]# cp *.h /root/nanoast/build_fx08/uClinux-dist-2008R1.5-RC3/staging/include/mysql/

 

2. now we got all mysqlclient .h file and library, and put it to uClinux-dist-2008R1.5-RC3/staging directory, we need testing is it working, copy following demo code to your PC and setting up bfin-linux-uclibc-gcc to your PATH, then create a testing DB on your PC, we used edgepbx_cn for our testing DB, DB table is products and insert some testing data as following

 

------------

 

mysql> select * from products;

+------+------+-----------------------------------+

| id   | name | description                       |

+------+------+-----------------------------------+

|    1 | ED1  | A single port digital E1/T1 IPPBX |

|    2 | FX08 | A 8 ports analog IPPBX            |

+------+------+-----------------------------------+

2 rows in set (0.00 sec)

 

------------

 

-------------

 

/* a demo mysql client program from based blackfin CPU's FX08/ED1 IPPBX */

#include <mysql.h>

#include <stdio.h>

 

int main() {

   MYSQL *conn;

   MYSQL_RES *res;

   MYSQL_ROW row;

 

   char *server = "192.168.0.1";

   char *user = "liyuqian";

   char *password = "****";

   char *database = "edgepbx_cn";

 

   conn = mysql_init(NULL);

 

   /* Connect to database */

   if (!mysql_real_connect(conn, server,

         user, password, database, 0, NULL, 0)) {

      fprintf(stderr, "When try connecting to DB got a error: %s\n", mysql_error(conn));

      return(0);

   }

 

   /* send SQL query */

   if (mysql_query(conn, "SELECT * FROM edgepbx WHERE product = ED1")) {

      fprintf(stderr, "When try query to DB got a error: %s\n", mysql_error(conn));

      return(0);

   }

 

   res = mysql_use_result(conn);

 

   /* output fields 1 and 2 of each row */

   while ((row = mysql_fetch_row(res)) != NULL)

      printf("%s %s\n", row[1], row[2]);

 

   /* Release memory used to store results and close connection */

   mysql_free_result(res);

   mysql_close(conn);

}

--------------------

 

[root@edgepbx mysql]# bfin-linux-uclibc-gcc -g -Wall -fPIC -I/root/nanoast/uClinux-dist-2008R1.5-RC3/staging/include/mysql mysql.c -L/root/nanoast/uClinux-dist-2008R1.5-RC3/staging/lib/mysql -L/root/nanoast/uClinux-dist-2008R1.5-RC3/staging/usr/lib -lmysqlclient   -lnsl -lm

 

3. we got a a.out excuable file, put this file to your emebbed board, now we put it to our IPPBX FX08

 

root:/persistent> uname -a

Linux fx08 2.6.22.19-ADI-2008R1.5nanoast-svn #15 Thu Nov 26 04:12:32 EST 2009 blackfin unknown

root:/persistent> cat /proc/cpuinfo

processor       : 0

vendor_id       : Analog Devices

cpu family      : 0x27a5000

model name      : ADSP-BF533 600(MHz CCLK) 120(MHz SCLK)

stepping        : 5

cpu MHz         : 600.000/120.000

bogomips        : 1196.03

Calibration     : 598016000 loops

cache size      : 16 KB(L1 icache) 32 KB(L1 dcache-wb) 0 KB(L2 cache)

dbank-A/B       : cache/cache

icache setup    : 4 Sub-banks/4 Ways, 32 Lines/Way

dcache setup    : 2 Super-banks/4 Sub-banks/2 Ways, 64 Lines/Way

board name      : FX08

board memory    : 131072 kB (0x00000000 -> 0x08000000)

kernel memory   : 114684 kB (0x00001000 -> 0x07000000)

root:/persistent> ./a.out

ED1 A single port digital E1/T1 IPPBX

FX08 A 8 ports analog IPPBX

 

 

Wow, it is working

 

now we has been ported that to our IPPBX, that used Asterisk, and using mysqlclient for cdr maintenance,  working perfect for us, you can try it, any question, just post your message here

 

Li Yuqian

QuoteReplyEditDelete

 

 

2010-02-01 00:47:39     Re: Running mysqlclient on uClinux for the blackfin processor

Yi Li (CHINA)

Message: 85386   

 

Yuqian Li,

 

Thanks for sharing. You may know that we have a wiki for document. So if you like,  you can write a wiki on docs.blackfin.uclinux.org.

 

-Yi

QuoteReplyEditDelete

 

 

2010-02-01 19:32:13     Re: Running mysqlclient on uClinux for the blackfin processor

Li Yuqian (CHINA)

Message: 85428   

 

Hi LI Yi,

 

I know that wiki, but i don't know how i can put this to there :(, can you give me some help for that? thank you.

 

Li Yuqian

QuoteReplyEditDelete

 

 

2010-02-01 20:58:49     Re: Running mysqlclient on uClinux for the blackfin processor

Yi Li (CHINA)

Message: 85429   

 

You can simply login and create a new page. If you are not familar with wiki, you can read dokuwiki manual:   www.dokuwiki.org/FAQ.

 

-Yi

QuoteReplyEditDelete

 

 

2010-02-02 19:15:49     Re: Running mysqlclient on uClinux for the blackfin processor

Mike Frysinger (UNITED STATES)

Message: 85489   

 

our wiki isnt set up for anyone to create pages in all namespaces ...

Attachments

    Outcomes