Showing posts with label 嵌入式相關. Show all posts
Showing posts with label 嵌入式相關. Show all posts

Apr 28, 2008

S3C2440, USB in Linux

他媽的USB似乎根本就沒啟動

帥哥的測試:
GPH10 控制小 port:0 是打開 1 是關掉
GPH8 控制大 port: 1 是打開 0 是關掉

送電之後就可以用了...他媽的白費兩個禮拜

05/23 :
之前請正哥寄信去要電路圖都不屌我們

COLOR 打電話去就要到了

更正
GPH8 : USB_HOST_EN

GPH10 : nUSB_PULL_UP_EN

USB_HOST_EN 控制 USB_H_5V --> USB HOST PORT 的供電 (大PORT)

nUSB_PULL_UP_EN 控制 USB_C_D+ --> MINI USB 的供電 (小PORT)

DEBUGFS Support

(host)# cd rootfs

(host)# pwd
/home2/fyodor/filesystem/rootfs

(busybox)# mkdir var/debug

(busybox)# vi etc/fstab
加一行:none  /var/debug    debugfs  ramfs 0  0

(busybox)# modprobe rt73usb
phy0 -> rt2x00_set_chip: Info - Chipset detected - rt: 1300, rf: 0002, rev: 000.
usbcore: registered new interface driver rt73usb

(busybox)# cd /var/debug

(busybox)# ls
drwxr-xr-x    3 0        0               0 Jan  1 00:32 ieee80211
drwxr-xr-x    3 0        0               0 Jan  1 00:00 ohci
drwxr-xr-x    2 0        0               0 Jan  1 00:00 usbmon

rt73的debugfs出來的資訊就在ieee80211裡面

Apr 22, 2008

NAND Flash ~ empty flash 問題

Openmoko - 惱人的 Empty flash 問題

# sumtool -e 0x20000 --no-cleanmarkers --littleendian -i output/rootfs.jffs2 -o output/newrootfs.jffs2

Apr 19, 2008

warning: `regparm' attribute directive ignored

交叉編譯rt73usb driver的時候,需要指定kernel source路徑

# cd RT73_Linux_STA_Drv1.0.4.0/Module

# make ARCH=arm CROSS_COMPILE=arm-linux-

\KERNDIR=/home2/fyodor/kernel/linux-2.6.25__from__2.6.24.3/

出現了這個警告

warning: `regparm' attribute directive ignored

網路上查到是說

kernel src directory裡面的 include/asm

他是一個link,應該要指向corss compile目標

(在我這個情況就是asm-arm)

如果沒把asm 指到 asm-arm,就會出現這個warning

http://osdir.com/ml/linux.gps/2006-02/msg00049.html

http://linux.chinaunix.net/bbs/archiver/?tid-916672.html

可是我有正確指過去啊....怎麼還是出現這個warning

Apr 11, 2008

Linux Driver - Platform Device

platform-driver


Driver裡面先定義出platform-driver的名稱

這個名稱是s3c2410-ohci

static struct platform_driver ohci_hcd_s3c2410_driver = {
.probe          = ohci_hcd_s3c2410_drv_probe,
.remove         = ohci_hcd_s3c2410_drv_remove,
.shutdown       = usb_hcd_platform_shutdown,
/*.suspend      = ohci_hcd_s3c2410_drv_suspend, */
/*.resume       = ohci_hcd_s3c2410_drv_resume, */
.driver         = {
.owner  = THIS_MODULE,
.name   = "s3c2410-ohci",
},
};

----

platform_driver的資料結構:

[include/linux/platform_device.h]

struct platform_driver {
int (*probe)(struct platform_device *);
int (*remove)(struct platform_device *);
void (*shutdown)(struct platform_device *);
int (*suspend)(struct platform_device *, pm_message_t state);
int (*suspend_late)(struct platform_device *, pm_message_t state);
int (*resume_early)(struct platform_device *);
int (*resume)(struct platform_device *);
struct device_driver driver;
};

resource


[arch/arm/plat-s3c24xx/devs.c"]
/* USB Host Controller */

static struct resource s3c_usb_resource[] = {
[0] = {
.start = S3C24XX_PA_USBHOST,
.end   = S3C24XX_PA_USBHOST + S3C24XX_SZ_USBHOST - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_USBH,
.end   = IRQ_USBH,
.flags = IORESOURCE_IRQ,
}
};

platform-device (單一)


platporm裡要註冊device

使用的name對應到欲使用的driver

還有resource則是對應到上面

[arch/arm/plat-s3c24xx/devs.c"]
struct platform_device s3c_device_usb = {
.name             = "s3c2410-ohci",
.id               = -1,
.num_resources    = ARRAY_SIZE(s3c_usb_resource),
.resource         = s3c_usb_resource,
.dev              = {
.dma_mask = &s3c_device_usb_dmamask,
.coherent_dma_mask = 0xffffffffUL
}
};

EXPORT_SYMBOL(s3c_device_usb)

----

platform_device的資料結構:

[include/linux/platform_device.h]

struct platform_device {
const char      * name;
int             id;
struct device dev;
u32             num_resources;
struct resource * resource;
};

----

device的資料結構:

[include/linux/device.h]

struct device {
struct klist            klist_children;
struct klist_node       knode_parent;           /* node in sibling list */
struct klist_node       knode_driver;
struct klist_node       knode_bus;
struct device           *parent;

struct kobject kobj;
char    bus_id[BUS_ID_SIZE];    /* position on parent bus */
struct device_type      *type;
unsigned                is_registered:1;
unsigned                uevent_suppress:1;

struct semaphore        sem;    /* semaphore to synchronize calls to
* its driver.
*/

struct bus_type * bus;          /* type of bus device is on */
struct device_driver *driver;   /* which driver has allocated this
device */
void            *driver_data;   /* data private to the driver */
void            *platform_data; /* Platform specific data, device
core doesn't touch it */
struct dev_pm_info      power;

#ifdef CONFIG_NUMA
int             numa_node;      /* NUMA node this device is close to */
#endif
u64             *dma_mask;      /* dma mask (if dma'able device) */
u64             coherent_dma_mask;/* Like dma_mask, but for
alloc_coherent mappings as
not all hardware supports
64 bit addresses for consistent
allocations such descriptors. */

struct list_head        dma_pools;      /* dma pools (if dma'ble) */

struct dma_coherent_mem *dma_mem; /* internal for coherent mem
override */
/* arch specific additions */
struct dev_archdata     archdata;

spinlock_t              devres_lock;
struct list_head        devres_head;

/* class_device migration path */
struct list_head        node;
struct class            *class;
dev_t                   devt;           /* dev_t, creates the sysfs "dev" */
struct attribute_group  **groups;       /* optional groups */

void    (*release)(struct device * dev);
};

platform-device (全部)


最後把整個platform特有的device放在devices[]裡面

[arch/arm/mach-s3c2440/mach-smdk2440.c]

static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
};

machine init


在machine init的時候,把devices加進platform

[arch/arm/mach-s3c2440/mach-smdk2440.c]

static void __init smdk2440_machine_init(void)
{
s3c24xx_fb_set_platdata(&smdk2440_fb_info);

platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));

printk("smdk2440 machine init\n");
smdk_machine_init();
}

參考資料


帥哥安的 linux kernel 2.6.24.3 platform device driver

2.6.24 Kernel Document :
driver-model/Platform.txt

driver-model/Driver.txt

Apr 8, 2008

Wireless tools for ARM Linux

Wireless Tools is A collection of tools to configure IEEE 802.11 wireless LAN cards

目前最新版本 wireless_tools.29.tar.gz

抓下來之後修改Makefile

Apr 4, 2008

Linux Kernel modules in busybox

如果module沒有安裝到 target_rootfs裡面,在板子上就沒有module,也沒有modules.dep。
執行modprobe 會error : modprobe: cannot parse modules.dep

把modules放在busybox_rootfs裡


(~/kernel_src/linux-2.6.24.3) $ make clean

(~/kernel_src/linux-2.6.24.3) $ make

(2.6以上的kernel只要執行make就包含make zImage && make modules)

(~/kernel_src/linux-2.6.24.3) # make modules_install

// 把編譯出來的模組,複製到host機器的 /lib/modules/2.6.24.3/ (最好先把 /lib/modules 備份!)

# ls /lib/modules/2.6.24.3 -l


總計 44
lrwxrwxrwx 1 root root   35 2008-03-29 16:47 build -> /home2/fyodor/kernel/linux-2.6.24.3
drwxr-xr-x 4 root root   96 2008-03-29 16:47 kernel
-rw-r--r-- 1 root root  166 2008-03-29 16:47 modules.alias
-rw-r--r-- 1 root root   69 2008-03-29 16:47 modules.ccwmap
-rw-r--r-- 1 root root 2627 2008-03-29 16:47 modules.dep
-rw-r--r-- 1 root root   73 2008-03-29 16:47 modules.ieee1394map
-rw-r--r-- 1 root root  141 2008-03-29 16:47 modules.inputmap
-rw-r--r-- 1 root root   81 2008-03-29 16:47 modules.isapnpmap
-rw-r--r-- 1 root root   74 2008-03-29 16:47 modules.ofmap
-rw-r--r-- 1 root root   99 2008-03-29 16:47 modules.pcimap
-rw-r--r-- 1 root root   43 2008-03-29 16:47 modules.seriomap
-rw-r--r-- 1 root root 2660 2008-03-29 16:47 modules.symbols
-rw-r--r-- 1 root root  189 2008-03-29 16:47 modules.usbmap
lrwxrwxrwx 1 root root   35 2008-03-29 16:47 source -> /home2/fyodor/kernel/linux-2.6.24.3

除了build 和 source 不需要放到target檔案系統裡,其他全部複製過去

# sudo mkdir -p ~/FileSystem/rootfs/lib/modules/2.6.24.3

# sudo cp /lib/modules/2.6.24.3/* ~/FileSystem/rootfs/lib/modules/2.6.24.3

(如果有手動加 driver,還是要照對應路徑放到rootfs裡面)

Apr 2, 2008

Linux 裡 S3C2440 的initial 順序

初始化順序在 <kernel src>/arch/arm/plat-s3c24xx/cpu.c

static struct cpu_table cpu_ids[] __initdata{....}
.idcode         = 0x32440000,
.idmask         = 0xffffffff,
.map_io         = s3c244x_map_io,
.init_clocks    = s3c244x_init_clocks,
.init_uarts     = s3c244x_init_uarts,
.init           = s3c2440_init,
.name           = name_s3c2440

這幾個function的原始碼位置:

s3c244x_map_io      --->  arch/arm/plat-s3c24xx/s3c244x.c
s3c244x_init_clocks  --->  arch/arm/plat-s3c24xx/s3c244x.c
s3c244x_init_uarts   --->   arch/arm/plat-s3c24xx/s3c244x.c
s3c2440_init            --->  arch/arm/mach-s3c2440/s3c2440.c

Mar 19, 2008

設定暫存器位置的語法

暫存器的Addrewss Uint如果是....

Word:
#define Word_Reg     (*(volatile unsigned long *)0x12345678)

Half-Word:
#define HW_Reg       (*(volatile unsigned int *)0x876543219)

Char:
#define C_Reg           (*(volatile unsigned char *)0xabcd1234)

Dec 28, 2007

arm-linux-gcc: unrecognized option `-MQ'

this problem appears when I trying to make my own u-boot

the cause of this error is the version of arm-linux-gcc does not support the argument "MQ"

my gcc version is 2.95.3...

3.4.1 will be ok !

download arm-linux-gcc... handhelds.org

build GNU/Linux ARM Toolchain from scratch

Sep 23, 2007

[轉錄] Embedded Linux 的系統管理...from jollen

本文出處: www.jollen.org
已取得原作者授權使用

(1) (2) (3) (4) (5)


轉貼方便自己閱讀


[轉錄] Linux 的應用-- Video Streaming 探討...from jollen

本文出處: www.jollen.org
已取得原作者授權使用

(1) (2) (3) (4) (5) (6)


轉貼方便自己閱讀


May 16, 2007

[轉錄] ELF 之 Dynamic Linking 觀念教學 ~ from www.jollen.org

本文出處: www.jollen.org
已取得原作者授權使用

#1: 前言與簡介


接續前些時日的「Program Loading」專欄,本系列日 記將會介紹「dynamic linking」的核心觀念。首先,我們由 dynamic segment,即 .dynamic section 切入;如果您還不清楚為何以此做切入,建議先行閱讀 'Program Loading' 專欄,以建立基礎概念。

[轉錄] ELF 之 Program Loading 教學文件 ~ from www.jollen.org

本文出處: www.jollen.org
已取得原作者授權使用

#1: Segment 的觀念


「Program Loading」的議題在討論「如何將程式載入記憶體」,以便後續的「執行」。在「ELF(Executable and Linking Format)格式教學文件」第 1~8 篇文章裡,我們了解基本的 ELF 觀念,並建立所謂的「節區」知識。

本系列日記「ELF 之 Program Loading 教學文件」將會介紹有關程式載入(program loading)的核心主題,在此之前,請先閱讀 Jollen 的「Executable and Linking Format」專欄,以基本基礎的先備知識。

May 10, 2007

arm-elf-tools VS. arm-linux-tools

LinuxSir的討論可以看到~

luoyong的說法:
arm-elf-tools 生成的文件是FLAT格式的,连接时需要选项-elf2flt,编译得到的文件可以直接在裸机上跑,uClinux和ARM7可能只能运行这种格式的程序。

arm-linux-tools编译生成的文件是Linux内使用的可执行文件的格式(比如a.out)。

LYOO的說法:
从新版本看两者间的区别应该已经没有了,是面向同一目标的不同产品。
特地看了一下arm-linux-tools站上的文档,也没提之间的差别,新版的arm-linux-tools也支持ELF格式,而且强调生成的目标代码与操作系统无关,并建议不要使用旧的a.out格式。
我曾分别用arm-elf-tools和arm-linux-tool(u-boot官方提供的编译环境ELDK)编译过u-boot,都可以正常运行。

arm-elf-tools的主頁

May 8, 2007

Gnome也加入Embedded System陣營囉

jollen學長那邊看到Gnome即將加入Mobile & Embedded 的領域

恩~又多一套工具可選擇了

Nov 6, 2006

在ubuntu上建立arm toolchain

arm-linux-tools

YUANFENG光碟裡面的YUANFENG.tar.gz解開之後,裡面有cross-2.95.3.tar.bz2....

就是arm-linux-toos
$ sudo mkdir /usr/local/arm

$ sudo mv cross-2.95.3.tar.bz2 /usr/local/arm

$ sudo tar jxvf /usr/local/arm/cross-2.95.3.tar.bz2

$ sudo echo "export PATH=$PATH:/usr/local/arm/2.95.3/bin" >> ~/.bashrc

$ sudo echo "export PATH=$PATH:/usr/local/arm/2.95.3/bin" >> /etc/profile

$ sudo echo "export$ PATH=$PATH:/usr/local/arm/2.95.3/bin" >> /etc/bashrc