發表文章

Opensource SMTP client with TLS/SSL for Gmail SMTP server. (How to cross-compilation)

      需求:想要能利用Gmail的SMTP server來發信,所以一定要有支援TLS/SSL功能 順便筆記一下 a.我選了這個opensource的STMP Client。Thanks gosu~ http://cleancode.org/projects/email b. 先試試./configure --build= powerpc-linux -gnu --host= powerpc-linux  CC=powerpc-linux-gcc,可惜出現error。 直接./configure,再來改Makefile. c.查一下有哪些Makefile [root@new-host-1052 email-3.1.3]# find . -name "Makefile" ./dlib/Makefile ./src/Makefile ./Makefile 把三個Makefile裡面的CC = powerpc-linux-gcc d.執行./configure時checking for SSL_library_init in -lssl... no vim configure的script。 改check condition if test $ac_cv_lib_ssl_SSL_library_init = yes; then --> if test $ac_cv_lib_ssl_SSL_library_init = no; then   cat >>confdefs.h < #define HAVE_LIBSSL 1 或是 vim ./include/config.h 硬改成1 /* Define to 1 if you have the `ssl' library (-lssl). */ #define HAVE_LIBSSL 1 e.遇到email-3.1.3/src/progress_bar.c:137: undefined reference to `rpl_malloc' google說直接comment out這兩行就行了。 /* Define to rpl_malloc if the replacement functi...

C function pointer 指標函數

相當方便的指標函數,可以輕鬆的乎叫對應的function。 (C function pointer with array can make functions call easier.)  所有的function都有一個位址,例如 func1() ,呼叫時我們可以直接呼叫func1();  或是透過指標,如: int(*p)(); 先宣告一個指標,然後 p=func1; or p=&func1; 都可以,func1 與 &func1,都是func1的起始位置。  a.呼叫時 1. p(); 2. (*p)(); 都可以,此時p與*p都是func1的起始位置。  b.(*p)()不可以寫成*p(),()優先序高於*,這樣會出錯。  c. 對指標含數進行*(p+1) 之類的運算是沒意義的。 #include <stdio .h> #include<stdlib .h> typedef int (*MYFUNC)(); int func1() { printf("\n%s\n",__func__); } int func2() { printf("\n%s\n",__func__); } int func3() { printf("\n%s\n",__func__); } /* static (*funcs[3])() = { &func1, &func2, &func3}; * static (*funcs[3])() = { func1, func2, func3}; * 這三個寫法都一樣的效果,&可加可不加,都是指到同樣的位址。 */ static MYFUNC funcs[3] = { &func1, &func2, &func3}; int main(int argc, char *argv[]) { (*(funcs[atoi(argv[1])]))(); } 執行結果(result): [root@new-host-832 stanley]# ./a.out 0 func1 [root@new-host-832 stanl...

C語言 enum

這在篇blog中,我將介紹一些enum的用法。 (I will show some enum type examples in C.) enum的基本語法 enum identifier { enumerator-list }  1. enum裡的識別字,會以int的型態,從0開始排列,你也可以給于數值。  2. enum也可以不宣告identifier , 如第二個enum的宣告方法, 可以減少define的使用,enumerator可以是相同的值,如範例中off跟yes都是1。  (Different constants in an enumeration may have the same value, identifier is not necessary) #include <stdio.h> typedef enum {sun, mon, tue, wed, thu, fri, sat}week_type; enum{on=0, off=1, no=0, yes=1}; main() { week_type day; day=thu; printf("\nDay=%d\n",day); printf("%d %d %d %d\n", on, off, no, yes); } 執結果(result): Day=4 0 1 0 1

how to create a new fedora18 for develop embedded linux

1. Enable SSHd on Fedora18    service sshd start    chkconfig sshd on    reboot ref: http://fedora18tutorial.blogspot.tw/2012/11/how-to-start-ssh-service-on-fedora-18.html 2. install samba   yum install cups-libs samba samba-common samba-client   yum install  system-config-samba   vim /etc/samba/smb.conf  add below: [home]         path = /home         read only = no ;       browseable = yes         guest ok = yes   do not forget add users.  smbpasswd –a xxxxxx   ref: http://www.howtoforge.com/fedora-18-samba-standalone-server-with-tdbsam-backend 3./etc/selinux/config        SELINUX=disabled 4. chkconfig iptables off

vmware 新增硬碟

[root@new-host-832 home]# fdisk -l Disk /dev/sda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes    Device Boot      Start         End      Blocks   Id  System /dev/sda1   *           1        2544    20434648+  83  Linux /dev/sda2            2545        2610      530145   82  Linux swap / Solaris Disk /dev/sdb: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes    Device Boot      Start         End      Blocks   Id  System /dev/sdb1               1        2610    20964793+  83 ...

Beagleboard-XM kernel

圖片
有了x-loader,u-boot 接下來,剩下的就是kernel跟root file system。 這篇文章筆記了,怎麼製作kernel image。 首先先下載kernel source,我選了omap用的kernel source http://muru.com/linux/omap/ git clone git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git linux-omap cd linux-omap 接著去Build kernel make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- distclean make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- omap2plus_defconfig make menuconfig時也許會缺少這個套件( sudo apt-get install libncurses5-dev) make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage build好的uImage會在arch/arm/boot/uImage 下,把uImage放到SD中。 接著製作一個給U-boot用的uEnv.txt,內容如下。 vram=12MB defaultdisplay=dvi dvimode=1280x720MR-16@60 kernel_file=uImage boot=bootm console=ttyO2,115200n8 mmcroot=/dev/mmcblk0p2 ro mmcrootfstype=ext4 rootwait fixrtc xyz_load_image=fatload mmc 0:1 0x80000000 uImage mmcargs=setenv bootargs console=${console} ${optargs} vram=${vram} omapfb.mode=${de...

Beagleboard-XM 製作 x-loader and u-boot

圖片
Beagleboard-XM 只能靠MMC/SD card啟動,這篇文章,筆記如何製作能開機的SD卡。 可以參考這篇文章在Linux下分割SD卡,及建立開機磁區,開機磁區的檔案系統是FAT32。 http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat sudo mount -t ext3 /dev/sdb1/media/boot sudo mount -t ext3 /dev/sdb2 /media/rootfs 或是這在邊下載,HP USB Disk Storage Format Tool 2.0.6 for Windows. http://code.google.com/p/beagleboard/wiki/BeagleSourceCode 先設好CROSS_COMPILE的環境變數。 export CROSS_COMPILE=arm-none-linux-gnueabi- export PATH=/opt/arm-2012.03/bin/:$PATH U-boot 這邊我們使用 Mainline U-Boot : 一樣先抓下來最新的source接著再抓 omap3 branch。 git clone git://git.denx.de/u-boot.git u-boot-main cd u-boot-main git checkout --track -b omap3 origin/master 接著就是去build U-boot的image,這裡的toolchain,可以用我網誌所教的crosstool-NG自己做,或是抓現有的   Code Sourcery GCC 。 下面的範例是使用Code Sourcery GCC的,成功會產一個MLO跟u-boot.bin。 make CROSS_COMPILE=arm-none-linux-gnueabi- mrproper make CROSS_COMPILE=arm-none-linux-gnueabi- omap3_beagle_config make CROSS_COMPILE=arm-none-linux-gnueabi- 最後把MLO、U-boot.bin...