由於目前的桌機是安裝 Linux,但又想要傳檔案到 iphone上,
windows上是有 ifunbox可以用,很方便,但 Linux的使用者就是該死…
所以透過 ssh來達到此功能!
前提是已 JB情況下且電腦跟 iphone是同時連上 wifi:
1. 在 iphone上透過 cydia下載 openssh
2. 裝完 iphone重開機
3. Linux上要有 scp跟 ssh的功能,沒有的話安裝一下吧
4. scp XXX.ipa root@ip_address:/private/var/mobile/Documents/Installous/Downloads/
(上述步驟是想把我下載的 .ipa檔傳到 installous的資料夾)
iphone上的預設帳號/密碼為 root/alpine
5. 傳完後,到 iphone的 installous裡的 download就會發現剛剛傳的檔案,安裝吧!!!!!
2011年10月19日 星期三
2011年10月15日 星期六
boot and run Linux from a USB flash memory stick
先插上 USB, 假設裝置節點為 /dev/sda
方法一:
how to install ubuntu to a USB stick
方法二:
boot debian from an USB device
中文版
$ sudo umount /dev/sda
$ wget ftp://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/hd-media/boot.img.gz
$ sudo zcat boot.img.gz > /dev/sda
$ sudo mount /dev/sda /mnt
只要留下
vmlinuz (核心二進位檔案),
initrd.gz (初始化記憶體映像檔) ,
syslinux.cfg (SYSLINUX 設定檔案),
這三個就好,其它可以刪掉,
當然也可以換成自己的核心、檔案系統,
也可以修改一下 syslinux.cfg,加些開機所需參數等。
方法一:
how to install ubuntu to a USB stick
- Download the Ubuntu 6.10 ISO and burn it to CD
- Restart your computer (booting from the Ubuntu Live CD)
- Insert a 1GB or larger USB flash drive
- Open a terminal window and type sudo su
- Now type fdisk -l to list available drives/partitions (note which device is your flash drive Example: /dev/sdb). Throughout this tutorial, replace all instances of x with your flash drive letter. For example, if your flash drive is sdb, replace x with b.
- Type umount /dev/sdx1
- Type fdisk /dev/sdx
- type p to show the existing partition and d to delete it
- type p again to show any remaining partitions (if partitions exist, repeat the previous step)
- type n to make a new partition
- type p for primary partition
- type 1 to make this the first partition
- hit enter to use the default 1st cylinder
- type +750M to set the partition size
- type a to make this partition active
- type 1 to select partition 1
- type t to change the partition filesystem
- type 6 to select the fat16 file system
- type n to make another new partition
- type p for primary partition
- type 2 to make this the second partition
- hit enter to use the default cylinder
- hit enter again to use the default last cylinder
- type w to write the new partition table
- Type umount /dev/sdx1 to unmount the partition
- Type mkfs.vfat -F 16 -n usb /dev/sdx1 to format the first partition
"Alternately you can try mkfs.vfat -F 32 -n usb /dev/sdx1 (doesn't always work)"
- Type umount /dev/sdx2 to ensure the partition is unmounted
- Type mkfs.ext2 -b 4096 -L casper-rw /dev/sdx2 to format the second partition
- Remove and Re-insert your flash drive
- Back at the terminal, type sudo apt-get install syslinux mtools
- Type syslinux -sf /dev/sdx1
- Restart your computer, remove the CD and boot back into Windows
方法二:
boot debian from an USB device
中文版
$ sudo umount /dev/sda
$ wget ftp://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/hd-media/boot.img.gz
$ sudo zcat boot.img.gz > /dev/sda
$ sudo mount /dev/sda /mnt
只要留下
vmlinuz (核心二進位檔案),
initrd.gz (初始化記憶體映像檔) ,
syslinux.cfg (SYSLINUX 設定檔案),
這三個就好,其它可以刪掉,
當然也可以換成自己的核心、檔案系統,
也可以修改一下 syslinux.cfg,加些開機所需參數等。
use buildroot to create your own root file system
這陣子,一直想做一個自己的 Linux distro,
最主要是想要練功,目前想到要有的功能有
1. Live USB
2. 小且快速
3. 硬體支援盡量好
4. 資料可以存下來
關於第一點,是想要帶著跑,身上只要有支 USB隨身碟,
插上電腦,馬上就可以使用。
第二點,目標想把整體大小壓在 100MB以內,且應用程式不用多,
現在想到要有的 AP有,file browser,web browser,x window,
及window mamager。
第三點,說穿了就是 kernel的選項看要怎麼選。
第四點,由於目前是做 Live USB,所有資料都是跑在記憶體中,
關機資料當然不見,因此這個功能想達成。
一個 Linux distro最基本架構對我來說有三層,
root file system
---------------------
kernel
---------------------
boot loader
---------------------
hardware
最底下 hardware不說,就是 boot loader、kernel及 rootfs這三層,
應用程式或是一堆文件雜要雜八的都屬 rootfs這層。
所以我第一步要先來建立我的 rootfs!
以前用 LFS去從頭到尾建立一個完整的 distro,
雖然花了很多時間,但卻很值得,
因為可以學到很深,很廣,
但它實際做出來的大小其實不小…
幾百 MB吧,
不可否認,toolchain一定會有影響,
gllibc跟 uclibc編一樣的包,大小當然就不同,
自己曾經也有過瘋狂的 porting過,但太花時間跟精力了…
所以就用 buildroot來取代 LFS,
來做我一版 distro的 rootfs吧!!
buildroot可以想像它就是 LFS的自動化腳本,
當選了想要的東西後,打個 make,
就會產生出來,這裡記錄一下我怎麼選的,
$ git clone git://git.buildroot.net/buildroot
$ cd buildroot && make menuconfig
Toolchain --->
Toolchain type (Crosstool-NG toolchain) --->
(X) Crosstool-NG toolchain
Crosstool-NG C library (glibc) --->
(X) glibc
[*] Enable C++ support
System configuration --->
/dev management (Static using device table) --->
(X) Dynamic using udev
Package Selection for the target --->
Graphic libraries and applications (graphic/text) --->
[*] X.org X Window System, X11R7, release 7.5 --->
X Window System server type (TinyX) --->
(X) Modular X.org
X11R7 Applications --->
[*] setxkbmap
[*] twm
[*] xclock
[*] xinit
[*] xinput
[*] xkbcomp
X11R7 Drivers --->
[*] xf86-input-evdev
[*] xf86-input-keyboard
[*] xf86-input-mouse
[*] xf86-video-cirrus
[*] xf86-video-fbdev
[*] xf86-video-vesa
[*] Liberation (Free fonts)
[*] xterm
Hardware handling --->
[*] dbus
[*] enable all extras
[*] usb_modeswitch
[*] usbmount
Libraries --->
Graphics --->
[*] libgtk2
[*] gtk engines
GTK Themes --->
[*] hicolor (default theme)
Text and terminal handling --->
[*] ncurses libpanel in target
[*] ncurses libform in target
[*] ncurses libmenu in target
Networking applications --->
[*] wireless tools
[*] Install shared library
[*] wpa_supplicant
Filesystem images --->
[*] cpio the root filesystem
$ make
這時就會開始 compile,需要一段時間…
這裡附上 config file
結束後,在 $ur_buildroot_location/output/images
會有已壓縮後 rootfs的 tar檔及 cpio檔,
而在 $ur_buildroot_location/output/target
是還沒壓縮後的。
最主要是想要練功,目前想到要有的功能有
1. Live USB
2. 小且快速
3. 硬體支援盡量好
4. 資料可以存下來
關於第一點,是想要帶著跑,身上只要有支 USB隨身碟,
插上電腦,馬上就可以使用。
第二點,目標想把整體大小壓在 100MB以內,且應用程式不用多,
現在想到要有的 AP有,file browser,web browser,x window,
及window mamager。
第三點,說穿了就是 kernel的選項看要怎麼選。
第四點,由於目前是做 Live USB,所有資料都是跑在記憶體中,
關機資料當然不見,因此這個功能想達成。
一個 Linux distro最基本架構對我來說有三層,
root file system
---------------------
kernel
---------------------
boot loader
---------------------
hardware
最底下 hardware不說,就是 boot loader、kernel及 rootfs這三層,
應用程式或是一堆文件雜要雜八的都屬 rootfs這層。
所以我第一步要先來建立我的 rootfs!
以前用 LFS去從頭到尾建立一個完整的 distro,
雖然花了很多時間,但卻很值得,
因為可以學到很深,很廣,
但它實際做出來的大小其實不小…
幾百 MB吧,
不可否認,toolchain一定會有影響,
gllibc跟 uclibc編一樣的包,大小當然就不同,
自己曾經也有過瘋狂的 porting過,但太花時間跟精力了…
所以就用 buildroot來取代 LFS,
來做我一版 distro的 rootfs吧!!
buildroot可以想像它就是 LFS的自動化腳本,
當選了想要的東西後,打個 make,
就會產生出來,這裡記錄一下我怎麼選的,
$ git clone git://git.buildroot.net/buildroot
$ cd buildroot && make menuconfig
Toolchain --->
Toolchain type (Crosstool-NG toolchain) --->
(X) Crosstool-NG toolchain
Crosstool-NG C library (glibc) --->
(X) glibc
[*] Enable C++ support
System configuration --->
/dev management (Static using device table) --->
(X) Dynamic using udev
Package Selection for the target --->
Graphic libraries and applications (graphic/text) --->
[*] X.org X Window System, X11R7, release 7.5 --->
X Window System server type (TinyX) --->
(X) Modular X.org
X11R7 Applications --->
[*] setxkbmap
[*] twm
[*] xclock
[*] xinit
[*] xinput
[*] xkbcomp
X11R7 Drivers --->
[*] xf86-input-evdev
[*] xf86-input-keyboard
[*] xf86-input-mouse
[*] xf86-video-cirrus
[*] xf86-video-fbdev
[*] xf86-video-vesa
[*] Liberation (Free fonts)
[*] xterm
Hardware handling --->
[*] dbus
[*] enable all extras
[*] usb_modeswitch
[*] usbmount
Libraries --->
Graphics --->
[*] libgtk2
[*] gtk engines
GTK Themes --->
[*] hicolor (default theme)
Text and terminal handling --->
[*] ncurses libpanel in target
[*] ncurses libform in target
[*] ncurses libmenu in target
Networking applications --->
[*] wireless tools
[*] Install shared library
[*] wpa_supplicant
Filesystem images --->
[*] cpio the root filesystem
$ make
這時就會開始 compile,需要一段時間…
這裡附上 config file
結束後,在 $ur_buildroot_location/output/images
會有已壓縮後 rootfs的 tar檔及 cpio檔,
而在 $ur_buildroot_location/output/target
是還沒壓縮後的。
2010年9月15日 星期三
建立自己的 Linux開機圖片
轉自這位大大的文章
在 Linux中,預設的開機圖片,在左上角有隻小企鵝,大小為 80x80 pixel,格式為 ppm,
現在我想要改成整個畫面都顯示自己的圖片:
1. 取得一張 png的圖片
2. 此時就會在本地資料夾產生一個名為 logo_linux_clut224.ppm的圖片,把它取代掉原本的小企鵝,
linux_source_tree/driver/video/logo/logo_linux_clut224.ppm
3. 重新編繹 kernel,產生 zImage
4. 完成
不要顯示開機訊息:
e -c "noinitrd console=/dev/null console=ttymxc0,115200 root=/dev/mmcblk0p1 rw wvga=mxcfb:800x480-16M@50"
http://sites.google.com/site/myembededlife/Home/s3c2440/add-linux-logo
在 Linux中,預設的開機圖片,在左上角有隻小企鵝,大小為 80x80 pixel,格式為 ppm,
現在我想要改成整個畫面都顯示自己的圖片:
1. 取得一張 png的圖片
# sudo apt-get install netpbm
# pngtopnm ur_picture.png | ppmquant -fs 223 | pnmtoplainpnm > logo_linux_clut224.ppm2. 此時就會在本地資料夾產生一個名為 logo_linux_clut224.ppm的圖片,把它取代掉原本的小企鵝,
linux_source_tree/driver/video/logo/logo_linux_clut224.ppm
3. 重新編繹 kernel,產生 zImage
4. 完成
不要顯示開機訊息:
e -c "noinitrd console=/dev/null console=ttymxc0,115200 root=/dev/mmcblk0p1 rw wvga=mxcfb:800x480-16M@50"
2010年6月25日 星期五
mini2440_buttons.c driver study
下面是 mini2440_buttons driver的完整程式。
下面用程式碼片段,拆開來一步一步學習。
首先,先說linux device driver的架構,大致上的linux device driver,都會長的像下面這樣,
#include < linux/module.h>
#include < linux/kernel.h>
#include < linux/fs.h>
#include < linux/init.h>
#include < linux/delay.h>
#include < linux/poll.h>
#include < linux/irq.h>
#include < asm/irq.h>
#include < linux/interrupt.h>
#include < asm/uaccess.h>
#include < mach/regs-gpio.h>
#include < mach/hardware.h>
#include < linux/platform_device.h>
#include < linux/cdev.h>
#include < linux/miscdevice.h>
#include < linux/sched.h>
#include < linux/gpio.h>
#define DEVICE_NAME "buttons"
struct button_irq_desc {
int irq;
int pin;
int pin_setting;
int number;
char *name;
};
static struct button_irq_desc button_irqs [] = {
{IRQ_EINT8 , S3C2410_GPG(0) , S3C2410_GPG0_EINT8 , 0, "KEY0"},
{IRQ_EINT11, S3C2410_GPG(3) , S3C2410_GPG3_EINT11 , 1, "KEY1"},
{IRQ_EINT13, S3C2410_GPG(5) , S3C2410_GPG5_EINT13 , 2, "KEY2"},
{IRQ_EINT14, S3C2410_GPG(6) , S3C2410_GPG6_EINT14 , 3, "KEY3"},
{IRQ_EINT15, S3C2410_GPG(7) , S3C2410_GPG7_EINT15 , 4, "KEY4"},
{IRQ_EINT19, S3C2410_GPG(11), S3C2410_GPG11_EINT19, 5, "KEY5"},
};
static volatile char key_values [] = {'0', '0', '0', '0', '0', '0'};
static DECLARE_WAIT_QUEUE_HEAD(button_waitq);
static volatile int ev_press = 0;
static irqreturn_t buttons_interrupt(int irq, void *dev_id)
{
struct button_irq_desc *button_irqs = (struct button_irq_desc *)dev_id;
int down;
// udelay(0);
down = !s3c2410_gpio_getpin(button_irqs->pin);
if (down != (key_values[button_irqs->number] & 1)) { // Changed
key_values[button_irqs->number] = '0' + down;
ev_press = 1;
wake_up_interruptible(&button_waitq);
}
return IRQ_RETVAL(IRQ_HANDLED);
}
static int s3c24xx_buttons_open(struct inode *inode, struct file *file)
{
int i;
int err = 0;
for (i = 0; i < sizeof(button_irqs)/sizeof(button_irqs[0]); i++) {
if (button_irqs[i].irq < 0) {
continue;
}
err = request_irq(button_irqs[i].irq, buttons_interrupt, IRQ_TYPE_EDGE_BOTH,
button_irqs[i].name, (void *)&button_irqs[i]);
if (err)
break;
}
if (err) {
i--;
for (; i >= 0; i--) {
if (button_irqs[i].irq < 0) {
continue;
}
disable_irq(button_irqs[i].irq);
free_irq(button_irqs[i].irq, (void *)&button_irqs[i]);
}
return -EBUSY;
}
ev_press = 1;
return 0;
}
static int s3c24xx_buttons_close(struct inode *inode, struct file *file)
{
int i;
for (i = 0; i < sizeof(button_irqs)/sizeof(button_irqs[0]); i++) {
if (button_irqs[i].irq < 0) {
continue;
}
free_irq(button_irqs[i].irq, (void *)&button_irqs[i]);
}
return 0;
}
static int s3c24xx_buttons_read(struct file *filp, char __user *buff, size_t count, loff_t *offp)
{
unsigned long err;
if (!ev_press) {
if (filp->f_flags & O_NONBLOCK)
return -EAGAIN;
else
wait_event_interruptible(button_waitq, ev_press);
}
ev_press = 0;
err = copy_to_user(buff, (const void *)key_values, min(sizeof(key_values), count));
return err ? -EFAULT : min(sizeof(key_values), count);
}
static unsigned int s3c24xx_buttons_poll( struct file *file, struct poll_table_struct *wait)
{
unsigned int mask = 0;
poll_wait(file, &button_waitq, wait);
if (ev_press)
mask |= POLLIN | POLLRDNORM;
return mask;
}
static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.open = s3c24xx_buttons_open,
.release = s3c24xx_buttons_close,
.read = s3c24xx_buttons_read,
.poll = s3c24xx_buttons_poll,
};
static struct miscdevice misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DEVICE_NAME,
.fops = &dev_fops,
};
static int __init dev_init(void)
{
int ret;
ret = misc_register(&misc);
printk (DEVICE_NAME"\tinitialized\n");
return ret;
}
static void __exit dev_exit(void)
{
misc_deregister(&misc);
}
module_init(dev_init);
module_exit(dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("FriendlyARM Inc.");下面用程式碼片段,拆開來一步一步學習。
首先,先說linux device driver的架構,大致上的linux device driver,都會長的像下面這樣,
#include < linux/module.h>
#include < linux/kernel.h>
#include < linux/fs.h>
#include < linux/init.h>
#include < linux/delay.h>
#include < linux/poll.h>
#include < linux/irq.h>
#include < asm/irq.h>
#include < linux/interrupt.h>
#include < asm/uaccess.h>
#include < mach/regs-gpio.h>
#include < mach/hardware.h>
#include < linux/platform_device.h>
#include < linux/cdev.h>
#include < linux/miscdevice.h>
#include < linux/sched.h>
#include < linux/gpio.h>
static int s3c24xx_buttons_open(struct inode *inode, struct file *file)
{
...
}
static int s3c24xx_buttons_close(struct inode *inode, struct file *file)
{
...
}
static int s3c24xx_buttons_read(struct file *filp, char __user *buff, size_t count, loff_t *offp)
{
...
}
static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.open = s3c24xx_buttons_open,
.release = s3c24xx_buttons_close,
.read = s3c24xx_buttons_read,
};
static struct miscdevice misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DEVICE_NAME,
.fops = &dev_fops,
};
static int __init dev_init(void)
{
int ret;
ret = misc_register(&misc);
printk (DEVICE_NAME"\tinitialized\n");
return ret;
}
static void __exit dev_exit(void)
{
misc_deregister(&misc);
}
module_init(dev_init);
module_exit(dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("FriendlyARM Inc.");
2010年2月14日 星期日
tty?? ttyn?? ttySn?? console??
之前對於/dev/下有關tty ttyn ttySn console搞混,
後來上網查了一些資料,有點感覺了....不過不知道對不對就是了XD
假設: 有一台主機,跟一台螢幕,而主機有2個com port
n=0.1.2.3.4.....等數字
/dev/console: 表示目前的螢幕,就是擺在桌上的那台螢幕
/dev/tty: 虛擬
後來上網查了一些資料,有點感覺了....不過不知道對不對就是了XD
假設: 有一台主機,跟一台螢幕,而主機有2個com port
n=0.1.2.3.4.....等數字
/dev/console: 表示目前的螢幕,就是擺在桌上的那台螢幕
/dev/tty: 虛擬
訂閱:
文章 (Atom)