發表文章

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...

建立cross compiler tool-chain 使用 crosstool-ng 給Beagleboard-XM

圖片
      平常公司拿到的BSP都有提供prebuild的toolchain,網路上也很容易找到現成的,不過今天來 自己弄一個試試看吧。        本文使用crosstool-ng 1.15.2,選用crosstool-ng原因是,它一直更新,且有kernel-like menuconfig  configuration interface。 crosstool-ng官網: http://crosstool-ng.org/ 1.先抓下來,然後解開。  wget -c http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.15.2.tar.bz2  tar -xvf  http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.15.2.tar.bz2 2.先看看README ./cofigure --help 有些configure參數的說明。 ./doc 有詳細有關crosstool-ng的文件,有空可以看看。 3.先configure把安裝路徑指定在/home/ctng下 ./configure --prefix=/home/ctng 4.發現我缺少了不少library‧ sudo apt-get install bison sudo apt-get install flex sudo apt-get install build-essential sudo apt-get install texinfo sudo apt-get install libtool 5. make sudo make install ps. 可以把path加到env中,export PATH=$PATH:/home/ctng 6. 看有什麼現成的config: a.ct-ng list-samples 我選用這個: b.ct-ng arm - unknown - linux - uclibcgnueabi c.執行ct-ng menuconfig,沒啥要改的就儲存後...

Beagle Board-xM安裝ubuntu 方法一使用pre-build image

圖片
上露天買到一片便宜的Beagle Board,這篇是安裝ubuntu的筆記,有興趣的可以一起交流。 需要的工具: 一個5V 2A 2.1mm的變壓器。 5pin的USB OTG線。(也可以直接由這個供電) USB轉RS323的線,要看console debug message用的。 HDMI線,輸出到LCD。 USB滑鼠、鍵盤。 主要參考是這篇教學,若您習慣看英文的話,可以直接閱讀這篇,預計每種方法我都會試試。 reference: http://elinux.org/BeagleBoardUbuntu 首先,你需要台跑能Linux的電腦,我是用vmware裝了ubuntu。 方法一,使用Pre-build的image,這個方法比較簡單,不過對學習幫助不大,我會再試其它的方法。 a.先把image抓下來    wget http://rcn-ee.net/deb/rootfs/precise/ubuntu-12.04-r1-minimal-armhf.tar.xz c.如果你不知道你的SD卡被mount到那邊去了,你可以用以下的指令。 sudo ./setup_sdcard.sh --probe-mmc d.可以看到/dev/sdb就是SD卡囉(多餘的訊息被我省略了)。 Are you sure? I Don't see [/dev/idontknow], here is what I do see... fdisk -l: Disk /dev/sdb: 3957 MB, 3957325824 bytes <- MMC/SD card e.接下來就是把image安裝到記憶卡中,這需要一段時間大約十分鐘,這邊"beagle_xm",照不同的版子有不同的參數,參考一下print出來的指示修改就行了。 ps.在這個步驟前,script有提示我缺少某些library,照著指令下載安裝即可。 ./setup_sdcard.sh --mmc /dev/sdX --uboot "beagle_xm" f.最後把SD卡插上板子,接上鍵盤、滑鼠、HDMI。 預設的帳號、密碼。 Default user: ubuntu pass: temppwd

struct 初始化筆記

 最近在看kernel的code, 裡面常有個好用的struct初始化方式, 可以只設定自己需要的值,相當彈性。 範例如下:建立一個 struct std,在main中初始化,再利用指標函數呼叫showme,把值印出來。 (這簡單例子不考慮buffer overflow問題) struct std{ int number; char name[128]; int (*get)(struct std *p); }; void showme(struct std *p) { printf("My number is:%d name:%s \n",p->number,p->name); } int main() { struct std mystd={ .number = 39, .name = "LuLu", .get = &showme, }; //* equals struct std mystd={39,"lulu",&showme}; (*mystd.get)(&mystd); //*call showme function with mystd parameter } 執行結果: My number is:39 name:LuLu

Blog重新開張

最近又開始想寫些東西,這個blog會記錄我的遊記、一些關於嵌入系統的文章、自行車運動、 就這樣...