,

QQ2440V3 – 1- original boot message

Number of partitions: 5
name            :       offset          size            flag
------------------------------------------------------------
vivi            :       0x00000000      0x00020000      0
eboot           :       0x00020000      0x00020000      0
param           :       0x00040000      0x00010000      0
kernel          :       0x00050000      0x00200000      0
root            :       0x00250000      0x03dac000      0

##### Partition Menu #####
[r] Reset mtd parition table
[a] Add a mtd partition entry
[d] Delete a mtd partition entry
[v] View the mtd partition table
[w] Write the mtd partition table
[q] Quit
Enter your selection: q

##### FriendlyARM BIOS for 2440 #####
[x] bon part 0 320k 2368k
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[c] Download root_cramfs image
[n] Download Nboot
[e] Download Eboot
[i] Download WinCE NK.nb0
[w] Download WinCE NK.bin
[d] Download & Run
[f] Format the nand flash
[p] Partition for Linux
[b] Boot the system
[s] Set the boot parameters
[t] Print the TOC struct of wince
[q] Goto shell of vivi
Enter your selection: b
Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySA
C0"
MACH_TYPE = 782
NOW, Booting Linux......
Uncompressing Linux.............................................................
.............................................................. done, booting the
 kernel.
Linux version 2.6.32 (kozmers@kozmers-ThinkPad-X200) (gcc version 4.4.3 (ctng-1.
6.1) ) #11 Wed Aug 24 10:15:46 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60852KB available (3468K code, 311K data, 132K init, 0K highmem)
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing pending ext status 00000200
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
devtmpfs: initialized
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
ROMFS MTD (C) 2007 Red Hat, Inc.
yaffs Aug 18 2011 15:35:28 Installing.
msgmni has been set to 118
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 40x30
fb0: s3c2410fb frame buffer device
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND ECC disabled
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit
)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Creating 3 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x000000000000-0x000000030000 : "Bootloader"
0x000000050000-0x000000250000 : "kernel"
0x000000250000-0x000003ffc000 : "rootfs"
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)/n
eth0: CS8900A rev E at 0xe0000300 irq=53, addr: 00: 0:3E:26:0A: 0/n
usbmon: debugfs is not available
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.32 ohci_hcd
usb usb1: SerialNumber: s3c24xx
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mice: PS/2 mouse device common for all mice
Entering s3c2410ts_init
got and enabled clock
s3c2410 TouchScreen successfully loaded
input: s3c2410 TouchScreen as /class/input/input0
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
TCP cubic registered
NET: Registered protocol family 17
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:2.
devtmpfs: mounted
Freeing init memory: 132K
-----------Mount all------------
hwclock: can't open '/dev/misc/rtc': No such file or directory

*********************************************************
*   S3C2440 Rootfs by Kozmers @ Apr.15.2011
*   Busybox 1.18.3 which compiled by arm-linux-gcc-4.4.3
*********************************************************

Please press Enter to activate this console.
Processing /etc/profile...
Set search library in /etc/profile
Set user path in /etc/profile
All Done...

******************************************************
*                  Lockon Kozmers Technology
*                    http://www.kozmers.com
******************************************************
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LD_LIBRARY_PATH=/lib:/usr/lib
******************************************************
/ # uname -r
2.6.32
Posted in QQ2440V3 | Leave a comment
,

Startline – 2 – rootfs for arm linux kernel – 1

nfs – Net File System
1.
2.
3.
Over.

Posted in ARM | Leave a comment
,

Startline – 1 – linux kernel for arm – 3

1. Simple root file system — cramfs .

Download cramfs-1.1.tar.gz from

http://sourceforge.net/projects/cramfs

# tar -zxvf cramfs-1.1.tar.gz
# cd cramfs-1.1
# sudo apt-get install zlib1g-dev -y
# make
# sudo cp mkcramfs /usr/bin

Make a simple root file system

# mkdir /opt/rootfs
# cd /opt
/opt# mkcramfs rootfs rootfs.cramfs

2. Download rootfs and Run.

Download rootfs cramfs . Transfer /opt/rootfs.cramfs

Download & Run. Transfer last kernel zImage.

...

end_request: I/O error, dev mtdblock2, sector 0
Buffer I/O error on device mtdblock2, logical block 0
end_request: I/O error, dev mtdblock2, sector 0
Buffer I/O error on device mtdblock2, logical block 0
end_request: I/O error, dev mtdblock2, sector 0
FAT-fs (mtdblock2): unable to read boot sector
VFS: Cannot open root device "mtdblock2" or unknown-block(31,2)
Please append a correct "root=" boot option; here are the available partitions:
1f00             192 mtdblock0  (driver?)
1f01            2048 mtdblock1  (driver?)
1f02           63152 mtdblock2  (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
...

3. Fit the “I/O error of dev mtdblock2″

Close kernel NAND ECC check, because bootloader(vivi) itself check it , and both checking results were not the same. Only keep the vivi ECC checking, no kernel checking.

linux-3.0.4# vi drivers/mtd/nand/s3c2410.c 

s3c2410_nand_init_chip(){
...
chip->ecc.mode      = /*NAND_ECC_SOFT*/ NAND_ECC_NONE
...
}

make zImage and Download&Run

Uncompressing Linux... done, booting the kernel.
Linux version 3.0.4 (kozmers@dau-desktop) (gcc version 4.4.3 (ctng-1.6.1) ) #121
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 4064
Kernel command line: noinitrd console=ttySAC0 init=/linuxrc root=/dev/mtdblock2
PID hash table entries: 64 (order: -4, 256 bytes)
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 16MB = 16MB total
Memory: 11716k/11716k available, 4668k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc1800000 - 0xf6000000   ( 840 MB)
    lowmem  : 0xc0000000 - 0xc1000000   (  16 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0028000   ( 128 kB)
      .text : 0xc0028000 - 0xc040c6e4   (3986 kB)
      .data : 0xc040e000 - 0xc0432ea0   ( 148 kB)
       .bss : 0xc0432ec4 - 0xc045b204   ( 161 kB)
NR_IRQS:85
irq: clearing pending ext status 00000200
irq: clearing subpending status 00000007
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Version 1.0.24.
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 512 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 512 bind 512)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
JFFS2 version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 22
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 30x40
fb0: s3c2410fb frame buffer device
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
Uniform Multi-Platform E-IDE driver
ide-gd driver 1.18
ide-cd driver 5.00
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND ECC disabled
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bi)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Creating 3 MTD partitions on "NAND":
0x000000000000-0x000000030000 : "bootloader"
0x000000050000-0x000000250000 : "kernel"
0x000000250000-0x000003ffc000 : "rootfs"
dm9000 Ethernet Driver, V1.31
usbmon: debugfs is not available
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
VFS: Mounted root (cramfs filesystem) readonly on device 31:2.
Freeing init memory: 128K
Failed to execute /linuxrc.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel..
[<c0039fb8>] (unwind_backtrace+0x0/0xf4) from [<c0314a84>] (panic+0x58/0x188)
[<c0314a84>] (panic+0x58/0x188) from [<c002855c>] (init_post+0x7c/0xcc)
[<c002855c>] (init_post+0x7c/0xcc) from [<c000842c>] (kernel_init+0xe0/0x110)
[<c000842c>] (kernel_init+0xe0/0x110) from [<c0035ab8>] (kernel_thread_exit+0x0)

Note this:

NAND_ECC_NONE selected by board driver. This is not recommended !!

Show that the kernel ECC was off.

4. Now cramfs is OK with kernel. Only has this error

Failed to execute /linuxrc.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel

Because the cramfs was empty, there was no /linuxrc file.
Over.

Posted in ARM | Leave a comment
,

Startline – 1 – linux kernel for arm – 2

1. Change the driver about smdk’s clock, download and run again

$vi arch/arm/mach-s3c2440/mach-smdk2440.c 

// LINE 160
static void __init smdk2440_map_io(void)
{
s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
//s3c24xx_init_clocks(16934400);
s3c24xx_init_clocks(12000000);  // 12MHz clock
s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
}

Run result:

Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttyS"
MACH_TYPE = 782
NOW, Booting Linux......
Uncompressing Linux... done, booting the kernel.
s3c24xx_serial_initconsole
s3c24xx_serial_init_ports: initialising ports...
s3c24xx_serial_init_port: port=c02131d0, platdev=c0218848
s3c24xx_serial_init_port: c02131d0 (hw 0)...
resource c0207708 (50000000..50003fff)
port: map=50000000, mem=f7000000, irq=70 (70,71), clock=1
s3c2440_serial_resetport: port=c02131d0 (50000000), cfg=c02187c4
s3c24xx_serial_init_port: port=c0213290, platdev=c0208f98
s3c24xx_serial_init_port: c0213290 (hw 1)...
resource c0207740 (50004000..50007fff)
port: map=50004000, mem=f7004000, irq=73 (73,74), clock=1
s3c2440_serial_resetport: port=c0213290 (50004000), cfg=c02187e4
s3c24xx_serial_init_port: port=c0213350, platdev=c0209078
s3c24xx_serial_init_port: c0213350 (hw 2)...
resource c0207778 (50008000..5000bfff)
port: map=50008000, mem=f7008000, irq=76 (76,77), clock=1
s3c2440_serial_resetport: port=c0213350 (50008000), cfg=c0218804
s3c24xx_serial_console_setup: co=c02133ec (0), (null)
s3c24xx_serial_console_setup: port=c02131d0 (0)
s3c24xx_serial_get_options: port=c02131d0
registers: ulcon=00000003, ucon=000003c5, ubdriv=0000001a
calculated baud 117187
s3c24xx_serial_console_setup: baud 117187
selecting clock c02089f0
config: 8bits/char
setting ulcon to 00000003, brddiv to 26, udivslot 00000000
uart: ulcon = 0x00000003, ucon = 0x000003c5, ufcon = 0x00000051
Linux version 3.0.4 (dau@dau-desktop) (gcc version 4.4.3 (ctng-1.6.1) ) #5 Fri 1
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 4064
Kernel command line: root=/dev/hda1 ro init=/bin/bash console=ttySAC0
PID hash table entries: 64 (order: -4, 256 bytes)
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 16MB = 16MB total
Memory: 13912k/13912k available, 2472k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc1800000 - 0xf6000000   ( 840 MB)
    lowmem  : 0xc0000000 - 0xc1000000   (  16 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc001e000   (  88 kB)
      .text : 0xc001e000 - 0xc020125c   (1933 kB)
      .data : 0xc0202000 - 0xc0218540   (  90 kB)
       .bss : 0xc0218564 - 0xc0236a7e   ( 122 kB)
NR_IRQS:85
irq: clearing pending ext status 00000200
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c1804000, irq 33
DMA channel 1 at c1804040, irq 34
DMA channel 2 at c1804080, irq 35
DMA channel 3 at c18040c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
NetWinder Floating Point Emulator V0.97 (extended precision)
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 27
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
s3c24xx_serial_init(c02134c0,c021348c)
s3c2440_serial_probe: dev=c0218848
s3c24xx_serial_probe(c0218848, c021348c) 0
s3c24xx_serial_probe: initialising port c02131ac...
s3c24xx_serial_init_port: port=c02131d0, platdev=c0218848
s3c24xx_serial_probe: adding port
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440_serial_probe: dev=c0208f98
s3c24xx_serial_probe(c0208f98, c021348c) 1
s3c24xx_serial_probe: initialising port c021326c...
s3c24xx_serial_init_port: port=c0213290, platdev=c0208f98
s3c24xx_serial_probe: adding port
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440_serial_probe: dev=c0209078
s3c24xx_serial_probe(c0209078, c021348c) 2
s3c24xx_serial_probe: initialising port c021332c...
s3c24xx_serial_init_port: port=c0213350, platdev=c0209078
s3c24xx_serial_probe: adding port
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bi)
Scanning device for bad blocks
Creating 8 MTD partitions on "NAND":
0x000000000000-0x000000004000 : "Boot Agent"
0x000000000000-0x000000200000 : "S3C2410 flash partition 1"
0x000000400000-0x000000800000 : "S3C2410 flash partition 2"
0x000000800000-0x000000a00000 : "S3C2410 flash partition 3"
0x000000a00000-0x000000e00000 : "S3C2410 flash partition 4"
0x000000e00000-0x000001800000 : "S3C2410 flash partition 5"
0x000001800000-0x000003000000 : "S3C2410 flash partition 6"
0x000003000000-0x000004000000 : "S3C2410 flash partition 7"
mousedev: PS/2 mouse device common for all mice
s3c24xx_serial_startup: port=50000000 (f7000000,c0213434)
requesting tx irq...
s3c24xx_serial_startup ok
config: 8bits/char
setting ulcon to 00000003, brddiv to 26, udivslot 00000000
uart: ulcon = 0x00000003, ucon = 0x000003c5, ufcon = 0x00000051
VFS: Cannot open root device "hda1" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00              16 mtdblock0  (driver?)
1f01            2048 mtdblock1  (driver?)
1f02            4096 mtdblock2  (driver?)
1f03            2048 mtdblock3  (driver?)
1f04            4096 mtdblock4  (driver?)
1f05           10240 mtdblock5  (driver?)
1f06           24576 mtdblock6  (driver?)
1f07           16384 mtdblock7  (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[<c0030098>] (unwind_backtrace+0x0/0xf4) from [<c016e680>] (panic+0x58/0x188)
[<c016e680>] (panic+0x58/0x188) from [<c0008cfc>] (mount_block_root+0x1f0/0x2b4)
[<c0008cfc>] (mount_block_root+0x1f0/0x2b4) from [<c0008f50>] (prepare_namespac)
[<c0008f50>] (prepare_namespace+0x12c/0x184) from [<c0008428>] (kernel_init+0xd)
[<c0008428>] (kernel_init+0xdc/0x110) from [<c002bad8>] (kernel_thread_exit+0x0)

 

2. Fit error and boot string about partitions .

Error infomation is:

Scanning device for bad blocks
Creating 8 MTD partitions on "NAND":
0x000000000000-0x000000004000 : "Boot Agent"
0x000000000000-0x000000200000 : "S3C2410 flash partition 1"
0x000000400000-0x000000800000 : "S3C2410 flash partition 2"
0x000000800000-0x000000a00000 : "S3C2410 flash partition 3"
0x000000a00000-0x000000e00000 : "S3C2410 flash partition 4"
0x000000e00000-0x000001800000 : "S3C2410 flash partition 5"
0x000001800000-0x000003000000 : "S3C2410 flash partition 6"
0x000003000000-0x000004000000 : "S3C2410 flash partition 7"
mousedev: PS/2 mouse device common for all mice
s3c24xx_serial_startup: port=50000000 (f7000000,c0213434)
requesting tx irq...
s3c24xx_serial_startup ok
config: 8bits/char
setting ulcon to 00000003, brddiv to 26, udivslot 00000000
uart: ulcon = 0x00000003, ucon = 0x000003c5, ufcon = 0x00000051
VFS: Cannot open root device "hda1" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00              16 mtdblock0  (driver?)
1f01            2048 mtdblock1  (driver?)
1f02            4096 mtdblock2  (driver?)
1f03            2048 mtdblock3  (driver?)
1f04            4096 mtdblock4  (driver?)
1f05           10240 mtdblock5  (driver?)
1f06           24576 mtdblock6  (driver?)
1f07           16384 mtdblock7  (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

vivi linux partition dump infomation is:

Number of partitions: 5
name            :       offset          size            flag
------------------------------------------------------------
vivi            :       0x00000000      0x00028000      0
eboot           :       0x00028000      0x00018000      0
param           :       0x00040000      0x00010000      0
kernel          :       0x00050000      0x00200000      0
root            :       0x00250000      0x03dac000      0

Set boot string as:

 

$make menuconfig 

Boot options  --->
 (root=/dev/hda1 ro init=/bin/bash console=ttySAC0) Default kernel

noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0

 

Modify MTD tables in kernel source

$vi arch/arm/plat-s3c24xx/common-smdk.c
// LINE 111
static struct mtd_partition smdk_default_nand_part[] = {
        [0] = {
                .name   = "bootloader",
                .size   = 0x00030000,
                .offset = 0,
        },
        [1] = {
                .name   = "kernel",
                .offset = 0x00050000,
                .size   = 0x00200000,
        },
        [2] = {
                .name   = "rootfs",
                .offset = 0x00250000,
                .size   = 0x03dac000,
        }
};

$make zImage

Download & Run

Now, Downloading [ADDRESS:32000000h,TOTAL:2251826]
RECEIVED FILE SIZE: 2251826 (169KB/S, 13S)
Downloaded file at 0x30000000, size = 2251816 bytes
..                                                                              

  Uncompressing Linux... done, booting the kernel.
Linux version 3.0.4 (kozmers@dau-desktop) (gcc version 4.4.3 (ctng-1.6.1) ) #111
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 4064
Kernel command line: noinitrd console=ttySAC0 init=/linuxrc root=/dev/mtdblock2
PID hash table entries: 64 (order: -4, 256 bytes)
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 16MB = 16MB total
Memory: 11684k/11684k available, 4700k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc1800000 - 0xf6000000   ( 840 MB)
    lowmem  : 0xc0000000 - 0xc1000000   (  16 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0028000   ( 128 kB)
      .text : 0xc0028000 - 0xc0415960   (4023 kB)
      .data : 0xc0416000 - 0xc043b200   ( 149 kB)
       .bss : 0xc043b224 - 0xc04638a4   ( 162 kB)
NR_IRQS:85
irq: clearing pending ext status 00000200
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Version 1.0.24.
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 512 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 512 bind 512)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
JFFS2 version 2.2. (NAND) (SUMMARY)  �© 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 22
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 30x40
fb0: s3c2410fb frame buffer device
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
brd: module loaded
loop: module loaded
Uniform Multi-Platform E-IDE driver
ide-gd driver 1.18
ide-cd driver 5.00
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bi)
Scanning device for bad blocks
Creating 3 MTD partitions on "NAND":
0x000000000000-0x000000030000 : "bootloader"
0x000000050000-0x000000250000 : "kernel"
0x000000250000-0x000003ffc000 : "rootfs"
dm9000 Ethernet Driver, V1.31
usbmon: debugfs is not available
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
end_request: I/O error, dev mtdblock2, sector 0
Buffer I/O error on device mtdblock2, logical block 0
end_request: I/O error, dev mtdblock2, sector 0
Buffer I/O error on device mtdblock2, logical block 0
end_request: I/O error, dev mtdblock2, sector 0
FAT-fs (mtdblock2): unable to read boot sector
VFS: Cannot open root device "mtdblock2" or unknown-block(31,2)
Please append a correct "root=" boot option; here are the available partitions:
1f00             192 mtdblock0  (driver?)
1f01            2048 mtdblock1  (driver?)
1f02           63152 mtdblock2  (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
[<c0039fb8>] (unwind_backtrace+0x0/0xf4) from [<c031c314>] (panic+0x58/0x188)
[<c031c314>] (panic+0x58/0x188) from [<c0008e30>] (mount_block_root+0x16c/0x220)
[<c0008e30>] (mount_block_root+0x16c/0x220) from [<c0008f88>] (mount_root+0xa4/)
[<c0008f88>] (mount_root+0xa4/0xc8) from [<c0009110>] (prepare_namespace+0x164/)
[<c0009110>] (prepare_namespace+0x164/0x1bc) from [<c0008428>] (kernel_init+0xd)
[<c0008428>] (kernel_init+0xdc/0x110) from [<c0035ab8>] (kernel_thread_exit+0x0)

Over.

Posted in ARM | Leave a comment
,

DNW for LINUX

Linux下的DNW
1. 下载Linux下DNW的PC端USB驱动和写入工具

dnw_linux.tar
2. 编译PC端USB驱动和写入工具
2.1 解压缩
$ tar xzvf /path/to/dnw_linux.tgz
dnw_linux/
dnw_linux/secbulk/
dnw_linux/secbulk/Makefile
dnw_linux/secbulk/secbulk.c
dnw_linux/dnw/
dnw_linux/dnw/dnw.c

其中secbulk.c是PC端USB驱动, dnw.c是写入工具

2.2 编译并加载secbulk.c内核模块
$cd secbulk
$make -C /lib/modules/`uname -r`/build M=`pwd` modules

编译成功后在当前目录下可以看到secbulk.ko

用insmod命令加载模块,这需要root权限
$sudo insmod ./secbulk.ko
注:本指令因定要在dnw_linux/secbulk/目录下执行,在dnw_linux/目录下执行会出错!

2.3 编译dnw写入工具
$gcc -o dnw dnw.c
编译成功后生成可执行dnw(这一步在虚拟机下编译时出现了许多警告)

3 使用DNW下载
3.1 启动开发板,进入minicom,并将开发板和PC用USB电缆连接,此时用dmesg命令可以看到secbulk驱动加载:
[ 283.677772] usb 1-1: new full speed USB device using uhci_hcd and address 2
[ 284.084835] usb 1-1: configuration #1 chosen from 1 choice
[ 284.140430] secbulk:secbulk probing…
[ 284.140482] secbulk:bulk out endpoint found!
3.2 当出现“USB host is connected. Waiting a download.”时,在PC端Linux上用dnw工具写入要下载的文件
切换到root权限,执行dnw下载.
$./dnw /path/to/what/you/want/download

写入完成后提示成功
100% xxxxxxx bytes OK
4 提高下载速度
将secbulk.c中的
#define BULKOUT_BUFFER_SIZE 32
改为
#define BULKOUT_BUFFER_SIZE 512
可发现速度快了很多。

Posted in ARM | Leave a comment
,

Startline – 1 – linux kernel for arm – 1

arm : s3c2440
board : micro2440 by FriendlyARM
kernel : linux-3.0.4.tar.gz
cross-compiler: arm-linux-gcc-4.4.3-20100728.tar.gz
rootfs : cramfs / nfs / yaffs2

1. Prepare kernel source file.

Download linux kernel from http://www.kernel.org

linux-3.0.4.tar.gz

~$sudo chmod a+rw /opt
~$mkdir /opt/board
~$tar jxf linux-3.0.4.tar.gz -C /opt/board

 

2. Prepare cross-compile toolschain.

Download linux kernel from http://www.arm9.net

arm-linux-gcc-4.4.3-20100728.tar.gz

~$sudo tar zxf arm-linux-gcc-4.4.3-20100728.tar.gz -C /
~$ls /opt/FriendlyARM/toolschain/4.4.3/
arm-none-linux-gnueabi  bin  include  lib  libexec  share

 

3. Make default configuration file for arm s3c2440 kernel compiling.

$cd /opt/board/linux-3.0.4/
/opt/board/linux-3.0.4$cp arch/arm/configs/s3c2410_defconfig .config

4. Configure kernel options

/opt/board/linux-3.0.4$vi Makefile
:/?= $(SUBARCH)
#ARCH           ?= $(SUBARCH)
#CROSS_COMPILE  ?= $(CONFIG_CROSS_COMPILE:"%"=%)

ARCH            ?= arm
CROSS_COMPILE   ?= /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-

:wq

/opt/board/linux-3.0.4$make menuconfig

make: *** /opt/board/linux-3.0.4/arch/arm: Is a directory.  Stop.
ARCH            ?= arm'SPACE'

delete the 'space'.
$make menuconfig
*** Unable to find the ncurses libraries
$sudo apt-get install ncurses-dev -y
$make menuconfig
Kernel Features  --->
[*] Use the ARM EABI to compile the kernel
[*]   Allow old ABI binaries to run with this kernel (EXPERIMENTAL)

Quit and save config .

5. Compile kernel

/opt/board/linux-3.0.4$make -j4 zImage

file name : zImage
file size : 2345612 bytes

In partition table kernel file must less than 2MB.

Cut option function by $make menuconfig .

6. Download and run.

vivi menu

##### FriendlyARM BIOS for 2440 #####
[x] bon part 0 320k 2368k
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[c] Download root_cramfs image
[a] Absolute User Application
[n] Download Nboot
[e] Download Eboot
[i] Download WinCE NK.nb0
[w] Download WinCE NK.bin
[d] Download & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the nand flash
[p] Partition for Linux
[b] Boot the system
[s] Set the boot parameters
[t] Print the TOC struct of wince
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
Enter your selection:

file name : arch/arm/boot/zImage
file size : 1128484 bytes

Download & Run[d]

Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttyS"
MACH_TYPE = 782
NOW, Booting Linux......
Uncompressing Linux... done, booting the kernel.
s3c24xx_serial_initconsole
s3c24xx_serial_init_ports: initialising ports...
s3c24xx_serial_init_port: port=c02131d0, platdev=c0218848
s3c24xx_serial_init_port: c02131d0 (hw 0)...
resource c0207708 (50000000..50003fff)
port: map=50000000, mem=f7000000, irq=70 (70,71), clock=1
s3c2440_serial_resetport: port=c02131d0 (50000000), cfg=c02187c4
s3c24xx_serial_init_port: port=c0213290, platdev=c0208f98
s3c24xx_serial_init_port: c0213290 (hw 1)...
resource c0207740 (50004000..50007fff)
port: map=50004000, mem=f7004000, irq=73 (73,74), clock=1
s3c2440_serial_resetport: port=c0213290 (50004000), cfg=c02187e4
s3c24xx_serial_init_port: port=c0213350, platdev=c0209078
s3c24xx_serial_init_port: c0213350 (hw 2)...
resource c0207778 (50008000..5000bfff)
port: map=50008000, mem=f7008000, irq=76 (76,77), clock=1
s3c2440_serial_resetport: port=c0213350 (50008000), cfg=c0218804
s3c24xx_serial_console_setup: co=c02133ec (0), (null)
s3c24xx_serial_console_setup: port=c02131d0 (0)
s3c24xx_serial_get_options: port=c02131d0
registers: ulcon=00000003, ucon=000003c5, ubdriv=0000001a
calculated baud 165375
s3c24xx_serial_console_setup: baud 165375
selecting clock c02089f0
config: 8bits/char
3;7v��۷��[3[�4tٜ3�Gt�FDD���7���0��;��������#�����30�7x��C#��G��DGpF@

Over.

Posted in ARM | Leave a comment
,

LINUX driver – UART

uart_driver

struct uart_driver {
	struct module		*owner;
	const char		*driver_name;
	const char		*dev_name;
	int			 major;
	int			 minor;
	int			 nr;
	struct console		*cons;

	/*
	 * these are private; the low level driver should not
	 * touch these; they should be initialised to NULL
	 */
	struct uart_state	*state;
	struct tty_driver	*tty_driver;
};

uart_port

struct uart_port {
	spinlock_t		lock;			/* port lock */
	unsigned long		iobase;			/* in/out[bwl] */
	unsigned char __iomem	*membase;		/* read/write[bwl] */
	unsigned int		irq;			/* irq number */
	unsigned int		uartclk;		/* base uart clock */
	unsigned int		fifosize;		/* tx fifo size */
	unsigned char		x_char;			/* xon/xoff char */
	unsigned char		regshift;		/* reg offset shift */
	unsigned char		iotype;			/* io access style */
	unsigned char		unused1;

#define UPIO_PORT		(0)
#define UPIO_HUB6		(1)
#define UPIO_MEM		(2)
#define UPIO_MEM32		(3)
#define UPIO_AU			(4)			/* Au1x00 type IO */
#define UPIO_TSI		(5)			/* Tsi108/109 type IO */
#define UPIO_DWAPB		(6)			/* DesignWare APB UART */
#define UPIO_RM9000		(7)			/* RM9000 type IO */

	unsigned int		read_status_mask;	/* driver specific */
	unsigned int		ignore_status_mask;	/* driver specific */
	struct uart_info	*info;			/* pointer to parent info */
	struct uart_icount	icount;			/* statistics */

	struct console		*cons;			/* struct console, if any */
#ifdef CONFIG_SERIAL_CORE_CONSOLE
	unsigned long		sysrq;			/* sysrq timeout */
#endif

	upf_t			flags;

#define UPF_FOURPORT		((__force upf_t) (1 << 1))
#define UPF_SAK			((__force upf_t) (1 << 2))
#define UPF_SPD_MASK		((__force upf_t) (0x1030))
#define UPF_SPD_HI		((__force upf_t) (0x0010))
#define UPF_SPD_VHI		((__force upf_t) (0x0020))
#define UPF_SPD_CUST		((__force upf_t) (0x0030))
#define UPF_SPD_SHI		((__force upf_t) (0x1000))
#define UPF_SPD_WARP		((__force upf_t) (0x1010))
#define UPF_SKIP_TEST		((__force upf_t) (1 << 6))
#define UPF_AUTO_IRQ		((__force upf_t) (1 << 7))
#define UPF_HARDPPS_CD		((__force upf_t) (1 << 11))
#define UPF_LOW_LATENCY		((__force upf_t) (1 << 13))
#define UPF_BUGGY_UART		((__force upf_t) (1 << 14))
#define UPF_MAGIC_MULTIPLIER	((__force upf_t) (1 << 16))
#define UPF_CONS_FLOW		((__force upf_t) (1 << 23))
#define UPF_SHARE_IRQ		((__force upf_t) (1 << 24))
#define UPF_BOOT_AUTOCONF	((__force upf_t) (1 << 28))
#define UPF_FIXED_PORT		((__force upf_t) (1 << 29))
#define UPF_DEAD		((__force upf_t) (1 << 30))
#define UPF_IOREMAP		((__force upf_t) (1 << 31))

#define UPF_CHANGE_MASK		((__force upf_t) (0x17fff))
#define UPF_USR_MASK		((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))

	unsigned int		mctrl;			/* current modem ctrl settings */
	unsigned int		timeout;		/* character-based timeout */
	unsigned int		type;			/* port type */
	const struct uart_ops	*ops;
	unsigned int		custom_divisor;
	unsigned int		line;			/* port index */
	resource_size_t		mapbase;		/* for ioremap */
	struct device		*dev;			/* parent device */
	unsigned char		hub6;			/* this should be in the 8250 driver */
	unsigned char		suspended;
	unsigned char		unused[2];
	void			*private_data;		/* generic platform data pointer */
};

uart_ops

/*
 * This structure describes all the operations that can be
 * done on the physical hardware.
 */
struct uart_ops {
	unsigned int	(*tx_empty)(struct uart_port *);
	void		(*set_mctrl)(struct uart_port *, unsigned int mctrl);
	unsigned int	(*get_mctrl)(struct uart_port *);
	void		(*stop_tx)(struct uart_port *);
	void		(*start_tx)(struct uart_port *);
	void		(*send_xchar)(struct uart_port *, char ch);
	void		(*stop_rx)(struct uart_port *);
	void		(*enable_ms)(struct uart_port *);
	void		(*break_ctl)(struct uart_port *, int ctl);
	int		(*startup)(struct uart_port *);
	void		(*shutdown)(struct uart_port *);
	void		(*flush_buffer)(struct uart_port *);
	void		(*set_termios)(struct uart_port *, struct ktermios *new,
				       struct ktermios *old);
	void		(*set_ldisc)(struct uart_port *);
	void		(*pm)(struct uart_port *, unsigned int state,
			      unsigned int oldstate);
	int		(*set_wake)(struct uart_port *, unsigned int state);

	/*
	 * Return a string describing the type of the port
	 */
	const char *(*type)(struct uart_port *);

	/*
	 * Release IO and memory resources used by the port.
	 * This includes iounmap if necessary.
	 */
	void		(*release_port)(struct uart_port *);

	/*
	 * Request IO and memory resources used by the port.
	 * This includes iomapping the port if necessary.
	 */
	int		(*request_port)(struct uart_port *);
	void		(*config_port)(struct uart_port *, int);
	int		(*verify_port)(struct uart_port *, struct serial_struct *);
	int		(*ioctl)(struct uart_port *, unsigned int, unsigned long);
#ifdef CONFIG_CONSOLE_POLL
	void	(*poll_put_char)(struct uart_port *, unsigned char);
	int		(*poll_get_char)(struct uart_port *);
#endif
};

uart_state

/*
 * This is the state information which is persistent across opens.
 * The low level driver must not to touch any elements contained
 * within.
 */
struct uart_state {
	unsigned int		close_delay;		/* msec */
	unsigned int		closing_wait;		/* msec */

#define USF_CLOSING_WAIT_INF	(0)
#define USF_CLOSING_WAIT_NONE	(~0U)

	int			count;
	int			pm_state;
	struct uart_info	*info;
	struct uart_port	*port;

	struct mutex		mutex;
};

uart_info

Posted in ARM, EMBEDDED-LINUX | Comments Off
,

LINUX driver – base

1. 用户态与内核态

用户态对应ARM的usr模式,内核态对应ARM的svc模式。

驱动程序作为linux内核的一部分,工作在内核态。而应用程序工作在用户态,不能直接通过指针(整型直接数可以),把用户空间的数据地址传递给内核。若想传递指针必须经过转换。把用户态看到的空间地址转换成内核态可访问的地址。

Linux提供get_user , put_user , copy_from_user , copy_to_user等方法。它们自己负责访问权限的检查,使用时候不需关系更多问题。

2. 驱动程序类型

字符设备,块设备,网络设备。

字符设备:顺序读写,最小单位1个字节。

块设备:可随机读写,最小单位为一个块(一般为512字节,1024,4096等)。

网络设备:非常特殊。

3. 设备文件与设备文件系统

3.1 访问设备文件

Linux中字符设备和块设备是通过文件节点访问的。可以在文件系统中找到设备对应的文件名,这种文件就是设备文件。习惯上这些文件在/dev下。

ls -l /dev

可以列出。

3.2 主/次设备号

主设备号是linux唯一的联系驱动程序和设备文件节点途径(并不是通过设备文件名字)。系统共有0~255的一个字节个主设备。

cat /proc/devices

列出主设备号。

次设备号是区分同一设备类型(同一主设备号)的不同设备个体。只在驱动程序内部使用,内核直接把次设备号传给驱动程序,由驱动程序管理。

3.3 设备文件管理

目前有两种方式:devfs文件系统 和 sysfs文件系统+udev脚本。

在2.6.15以前用devfs来管理设备文件,在2.6.15以后抛弃了它,使用sysfs来管理,但都是维护/dev下的设备文件,这点没有变。它们都是动态创建设备文件节点,不需要mknod并麻烦的找主设备号。

3.3.1 sysfs+udev

sysfs系统文件系统为每个系统的硬件树进行了分级管理,提供设备的基本信息。

udev脚本是用户态下的动态维护/dev目录工具。它从sysfs获取信息可提供特定设备的固定设备名。这对于热拔插设备很重要,比如同一个U盘换插在两个USB控制器中,以前会产生两个设备名和设备号。而udev是在用户控件运行的脚本,这很容易被编辑和修改。

3.3.2 devfs

必须在编译内核的文件系统配置中选择支持devfs选项。

这样系统启动时会把设备文件挂载在/dev目录下。插入USB设备也会动态创建对应的设备文件节点在/dev下。

devfs在2.6新内核中被舍弃了,它的缺点是设备文件节点的名字是在内核态建立的,用户无法对其名字定义更改,内核加载了设备驱动,名字就随之生成。

Posted in ARM, EMBEDDED-LINUX | Leave a comment
,

linux millisleep

#include <time.h>

/* POSIX mlillisleep by nanosleep */
int
os_millisleep(int ms)
{
        struct timespec rqst, resp;

        while (ms)
        {
                if (ms > 2)
                {
                        rqst.tv_nsec = 2000000;
                        ms -= 2;
                }
                else
                {
                        rqst.tv_nsec = ms*1000000;
                        ms = 0;
                }
                rqst.tv_sec = 0;
                while (nanosleep(&rqst, &resp) != 0)
                {
                        if(errno == EINTR)
                        {
                /* Interrupted, continue */
                                memcpy(&rqst, &resp, sizeof(resp));
                        }
                        else
                        {
                                return(-1);
                        }
                }
        }
        return(0);
}
Posted in EMBEDDED-LINUX | Leave a comment
,

linux non-standard baud rate

#include <ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{

 int ser_dev = open ("/dev/ttyUSB0", F_RDWR);
 if (-1 == ser_dev) {
   perror("open");
   return -1;
 }

 struct serial_struct ser_info;
 if (ioctl(ser_dev, TIOCGSERIAL, &ser_info) < 0) {
  perror ("TIOCGSERIAL");
  return -1;
 }
 ser_info.flags = ASYNC_SPD_CUST | ASYNC_LOW_LATENCY;
 ser_info.custom_divisor = ser_info.baud_base / CUST_BAUD_RATE;
 if (ioctl(ser_dev, TIOCSSERIAL, &ser_info) < 0) {
  perror ("TIOCSSERIAL");
  return -1;
 }

 close (ser_dev);
 return 0;
}
Posted in EMBEDDED-LINUX | Leave a comment