NUC972-5寸电容屏-linux-drv-chrdevbase

32 篇文章 8 订阅
10 篇文章 0 订阅

NUC972-5寸电容屏-linux-drv-chrdevbase

drv_chrdevbase.c

#include <linux/types.h>
#include <linux/kernel.h>

#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/module.h>

#define CHRDEVBASE_MAJOR	200
#define CHRDEVBASE_NAME		"chrdevbase"

static char readbuf[100];
static char writebuf[100];
static char kerneldata[] = {"kernel data!"};

static int chrdevbase_open(struct inode *inode,struct file *filp)
{
	printk("chrdevbase open! \r\n");
	return 0;
}


static ssize_t chrdevbase_read(struct file *filp,char __user *buf,size_t cnt,loff_t *offt)
{
	int retvalue = 0;

	memcpy(readbuf, kerneldata, sizeof(kerneldata));
	retvalue = copy_to_user(buf, readbuf, cnt);
	if(retvalue == 0){
		printk("kernel senddata ok! \r\n");
	}else{
		printk("kernel senddata failed! \r\n");
	}
	printk("chrdevbase read! \r\n");
	return 0;
}

static ssize_t chrdevbase_write(struct file *filp,const char __user *buf,size_t cnt,loff_t *offt)
{
	int retvalue = 0;

	retvalue = copy_from_user(writebuf, buf, cnt);
	if(retvalue == 0){
		printk("kernel recevdata: %s \r\n",writebuf);
	}else {
		printk("kernel recevdata: failed \r\n");
	}
	printk("chrdevbase write ! \r\n");
	return 0;
}

static int chrdevbase_release(struct inode *inode, struct file *filp)
{
	printk("chrdevbase release ! \r\n");
	return 0;
}


static struct file_operations chrdevbase_fops = {
	.owner = THIS_MODULE,
	.open = chrdevbase_open,
	.read = chrdevbase_read,
	.write = chrdevbase_write,
	.release = chrdevbase_release,
};

static int __init chrdevbase_init(void)
{
	int retvalue = 0;

	retvalue = register_chrdev(CHRDEVBASE_MAJOR, CHRDEVBASE_NAME, &chrdevbase_fops);
	if(retvalue < 0){
		printk("chrdevbase driver register failed \r\n");
	}
	printk("chrdevbase_init() \r\n");
	return 0 ;
}

static void __exit chrdevbase_exit(void)
{
	unregister_chrdev(CHRDEVBASE_MAJOR,CHRDEVBASE_NAME);
	printk("chrdevbase_exit() \r\n");
}


module_init(chrdevbase_init);
module_exit(chrdevbase_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("HB");



Makefile

obj-m := drv_chrdevbase.o
PWD := $(shell pwd)

KDIR ?= /home/coidea/nuc972/sdk/kernel
all:
	$(MAKE) -C $(KDIR) M=$(PWD)
clean:
	rm -rf .*.cmd *.o *.mod.c *.ko 

app_chrdevbase.c

#include <stdio.h>
#include "unistd.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "stdlib.h"
#include "string.h"

static char usrdata[] = {"usr data!"};


int main(int argc, char *argv[])
{
	int fd,retvalue;
	char *filename;
	char readbuf[100], writebuf[100];

	if(argc != 3){
		printf("Error Usage! \r\n");
		return -1;
	}

	filename = argv[1];

	fd = open(filename, O_RDWR);
	if(fd < 0){
		printf("Can't open file %s \r\n",filename);
		return -1;
	}

	if(atoi(argv[2]) == 1){
		retvalue = read(fd, readbuf, 50);
		if(retvalue < 0){
			printf("read file %s failed ! \r\n",filename);
		}else{
			printf("read data:%s  \r\n",readbuf);
		}
	}

	if(atoi(argv[2]) == 2){
		memcpy(writebuf, usrdata, sizeof(usrdata));
		retvalue = write(fd, writebuf, 50);
		if(retvalue < 0){
			printf("write file %s failed ! \r\n",filename);
		}
	}

	retvalue = close(fd);
	if(retvalue < 0){
		printf("Can't close file %s \r\n",filename);
		return -1;
	}

	return 0;
}


编译驱动程序

coidea@pc:~/nuc972/sdk$ source env.sh 
coidea@pc:~/nuc972/DRV$ cd drv_chrdevbase/
coidea@pc:~/nuc972/DRV/drv_chrdevbase$ ls
drv_chrdevbase.c  Makefile
coidea@pc:~/nuc972/DRV/drv_chrdevbase$ make
make -C /home/coidea/nuc972/sdk/kernel M=/home/coidea/nuc972/DRV/drv_chrdevbase
make[1]: Entering directory '/home/coidea/nuc972/sdk/kernel'
  LD      /home/coidea/nuc972/DRV/drv_chrdevbase/built-in.o
  CC [M]  /home/coidea/nuc972/DRV/drv_chrdevbase/drv_chrdevbase.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/coidea/nuc972/DRV/drv_chrdevbase/drv_chrdevbase.mod.o
  LD [M]  /home/coidea/nuc972/DRV/drv_chrdevbase/drv_chrdevbase.ko
make[1]: Leaving directory '/home/coidea/nuc972/sdk/kernel'
coidea@pc:~/nuc972/DRV/drv_chrdevbase$ ls
built-in.o        drv_chrdevbase.ko     drv_chrdevbase.mod.o  Makefile       Module.symvers
drv_chrdevbase.c  drv_chrdevbase.mod.c  drv_chrdevbase.o      modules.order

编译app程序
arm-linux-gcc app_chrdevbase.c -o app_chrdevbase

用nfs方式把文件下载到开发板

Kernel command line: noinitrd root=/dev/mtdblock2 rootfstype=yaffs2 rootflags=inband-tags console=ttyS0,115200n8 rdinit=/sbin/init mem=64M
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: 59044k/59044k available, 6492k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc0511f1c   (5160 kB)
      .init : 0xc0512000 - 0xc0539074   ( 157 kB)
      .data : 0xc053a000 - 0xc05805c0   ( 282 kB)
       .bss : 0xc05805c0 - 0xc05ba928   ( 233 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
NR_IRQS:625
sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 4294967286ms
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 148.88 BogoMIPS (lpj=744448)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
Initializing cgroup subsys devices
Initializing cgroup subsys freezer
Initializing cgroup subsys perf_event
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0xc03fb0c8 - 0xc03fb104
devtmpfs: initialized
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
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
i2c_gpio_probe - pdev = i2c-gpio
platform i2c-gpio.2: Driver i2c-gpio requests probe deferral
i2c_gpio_probe - pdev = i2c-gpio
platform i2c-gpio.3: Driver i2c-gpio requests probe deferral
media: Linux media interface: v0.10
Linux video capture interface: v2.00
Advanced Linux Sound Architecture Driver Initialized.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
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 (double precision)
msgmni has been set to 115
NET: Registered protocol family 38
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
[nuc970fb_probe] 10
div    = 0x00000718
div    = 0x00000718
Console: switching to colour frame buffer device 100x30
fb0: nuc970fb frame buffer device
nuc970-uart.0: ttyS0 at I/O 0x0 (irq = 36) is a NUC970
nuc970-uart.1: ttyS1 at I/O 0x0 (irq = 37) is a NUC970
nuc970-uart.2: ttyS2 at I/O 0x0 (irq = 38) is a NUC970
nuc970-uart.3: ttyS3 at I/O 0x0 (irq = 43) is a NUC970
nuc970-uart.8: ttyS8 at I/O 0x0 (irq = 41) is a NUC970
brd: module loaded
SCSI Media Changer driver v0.25 
nuc970 mtd nand driver version: 20160331
NAND device: Manufacturer ID: 0xef, Chip ID: 0xda (Winbond NAND 256MiB 3,3V 8-bit), 256MiB, page size: 2048, OOB size: 64
nand: SMRA size 64, 32
Bad block table found at page 131008, version 0x01
Bad block table found at page 130944, version 0x01
Creating 3 MTD partitions on "nand0":
0x000000000000-0x000000200000 : "u-boot"
0x000000200000-0x000001600000 : "Kernel"
0x000001600000-0x000010000000 : "user"
fmi-sm: registered successfully! mtdid=nand0
CAN device driver interface
nuc970-can0 nuc970-can0: nuc970_can0_platform device registered (regs=f800b000, irq=58)
nuc970-can1 nuc970-can1: nuc970_can1_platform device registered (regs=f800b400, irq=59)
libphy: nuc970_rmii0: probed
PPP generic driver version 2.4.2
PPP BSD Compression module registered
PPP Deflate Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci_nuc970_probe() - name: nuc970-ehci
nuc970-ehci nuc970-ehci: Nuvoton NUC970/N9H30 EHCI Host Controller
nuc970-ehci nuc970-ehci: new USB bus registered, assigned bus number 1
nuc970-ehci nuc970-ehci: irq 23, io mem 0xb0005000
nuc970-ehci nuc970-ehci: USB 2.0 started, EHCI 0.95
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
nuc970-ohci nuc970-ohci: Nuvoton NUC970/N9H30 OHCI Host Controller
nuc970-ohci nuc970-ohci: new USB bus registered, assigned bus number 2
nuc970-ohci nuc970-ohci: irq 24, io mem 0xb0007000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
usbcore: registered new interface driver usb-storage
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver option
usbserial: USB Serial support registered for GSM modem (1-port)
mousedev: PS/2 mouse device common for all mice
nuc970adc_probe - pdev = nuc970-adc
input: NUC970/N9H30 TouchScreen(ADC) as /devices/platform/nuc970-adc/input/input0
input: NUC970/N9H30 Keypad(ADC) as /devices/platform/nuc970-adc/input/input1
nuc970-rtc nuc970-rtc: rtc core: registered nuc970-rtc as rtc0
i2c /dev entries driver
nuc970-i2c0 nuc970-i2c0: i2c-0: nuc970 I2C adapter
nuvoton_cap_device_probe - pdev = nuc970-videoin
nuvoton_cap_device_probe video0, main sensor registeration fail.
platform nuc970-videoin: Driver nuc970-cap requests probe deferral
usbcore: registered new interface driver uvcvideo
USB Video Class driver (1.1.1)
This is Version C 0x1230d008
ios->clock=400000
NUC970 Crypto engine enabled.
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
nuc970-audio nuc970-audio:  nau8822-hifi <-> nuc970-audio-i2s mapping ok
TCP: cubic registered
NET: Registered protocol family 17
NET: Registered protocol family 15
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
lib80211: common routines for IEEE802.11 drivers
i2c_gpio_probe - pdev = i2c-gpio
i2c-gpio i2c-gpio.2: using pins 33 (SDA) and 32 (SCL)
i2c_gpio_probe - pdev = i2c-gpio
i2c-gpio i2c-gpio.3: using pins 136 (SDA) and 137 (SCL)
nuvoton_cap_device_probe - pdev = nuc970-videoin
.....................................................................................................................................................................
Sensor Chip_Version_H = 0x14(0x14) Chip_Version_L = 0x10(0x10)

driver i2c initial done
nuvoton_cap_device_probe video0, main sensor registeration ok.
nuvoton_cap_device_probe video1, main sensor registeration ok.
<<-GTP-INFO->> GTP driver installing...
<<-GTP-INFO->> GTP Driver Version: V1.8<2013/06/08>
<<-GTP-INFO->> GTP Driver Built@09:02:36, Jun 30 2022
<<-GTP-INFO->> GTP I2C Address: 0x5d
input: Goodix Capacitive TouchScreen as /devices/virtual/input/input2
<<-GTP-INFO->> GTP works in interrupt mode.
<<-GTP-INFO->> IC Version: 911_1060
<<-GTP-INFO->> Applied memory size:2562.
<<-GTP-INFO->> Create proc entry success!
i2c_add_driver : 0 
nuc970-rtc nuc970-rtc: setting system clock to 2005-01-01 00:00:06 UTC (1104537606)
ALSA device list:
  #0: nuc970_IIS
yaffs: dev is 32505858 name is "mtdblock2" rw
yaffs: passed flags "inband-tags"
VFS: Mounted root (yaffs2 filesystem) on device 31:2.
devtmpfs: mounted
Freeing unused kernel memory: 156K
Starting logging: OK
Starting mdev...
modprobe: can't change directory to '/lib/modules': No such file or directory
Initializing random number generator... done.
Starting network: nuc970-emac0 nuc970-emac0: eth0 is OPENED
udhcpc: started, v1.25.1
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending select for 192.168.0.118
udhcpc: lease of 192.168.0.118 obtained, lease time 7200
deleting routers
adding dns 192.168.1.1
adding dns 192.168.0.1
OK
Starting ntpd: OK
Starting sshd: OK
# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:00:01:92  
          inet addr:192.168.0.118  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:40 errors:0 dropped:2 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6895 (6.7 KiB)  TX bytes:1542 (1.5 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# ping 192.168.0.115
PING 192.168.0.115 (192.168.0.115): 56 data bytes
64 bytes from 192.168.0.115: seq=0 ttl=64 time=0.000 ms
64 bytes from 192.168.0.115: seq=1 ttl=64 time=0.000 ms
64 bytes from 192.168.0.115: seq=2 ttl=64 time=0.000 ms
^C
--- 192.168.0.115 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.000/0.000/0.000 ms
# ls
bin         lib         lost+found  opt         run         tmp
dev         lib32       media       proc        sbin        usr
etc         linuxrc     mnt         root        sys         var
# cd mnt
# ls
# cd ..
# mount -t nfs -o nolock 192.168.0.115:/home/coidea/nuc972 /mnt
# ls /mnt
app         drv         mnt         sdk         sdk.tar.gz
# cd /lib
# ls
fonts                 libdl-2.23.so         libnss_files-2.23.so
ld-2.23.so            libdl.so.2            libnss_files.so.2
ld-linux.so.3         libgcc_s.so           libpthread-2.23.so
libatomic.so          libgcc_s.so.1         libpthread.so.0
libatomic.so.1        libm-2.23.so          libresolv-2.23.so
libatomic.so.1.0.0    libm.so.6             libresolv.so.2
libc-2.23.so          libnsl-2.23.so        librt-2.23.so
libc.so.6             libnsl.so.1           librt.so.1
libcrypt-2.23.so      libnss_dns-2.23.so    libutil-2.23.so
libcrypt.so.1         libnss_dns.so.2       libutil.so.1
# mkdir modules
# pwd
/lib
# ls
fonts                 libdl.so.2            libpthread-2.23.so
ld-2.23.so            libgcc_s.so           libpthread.so.0
ld-linux.so.3         libgcc_s.so.1         libresolv-2.23.so
libatomic.so          libm-2.23.so          libresolv.so.2
libatomic.so.1        libm.so.6             librt-2.23.so
libatomic.so.1.0.0    libnsl-2.23.so        librt.so.1
libc-2.23.so          libnsl.so.1           libutil-2.23.so
libc.so.6             libnss_dns-2.23.so    libutil.so.1
libcrypt-2.23.so      libnss_dns.so.2       modules
libcrypt.so.1         libnss_files-2.23.so
libdl-2.23.so         libnss_files.so.2
# cd /mnt
# ls
app         drv         mnt         sdk         sdk.tar.gz

# ls
drv_chrdevbase
# cd drv_chrdevbase/
# ls
Makefile              drv_chrdevbase.c      drv_chrdevbase.mod.o
Module.symvers        drv_chrdevbase.ko     drv_chrdevbase.o
built-in.o            drv_chrdevbase.mod.c  modules.order
# cp drv_chrdevbase.ko /lib/modules/
# insmod drv_chrdevbase.ko
chrdevbase_init() 
# cd /
# ls
bin         lib         lost+found  opt         run         tmp
dev         lib32       media       proc        sbin        usr
etc         linuxrc     mnt         root        sys         var
# mkdir app
# ls
app         lib         media       root        tmp
bin         lib32       mnt         run         usr
dev         linuxrc     opt         sbin        var
etc         lost+found  proc        sys
# ll
-/bin/sh: ll: not found
# ls -l app
total 0
# ls
app         lib         media       root        tmp
bin         lib32       mnt         run         usr
dev         linuxrc     opt         sbin        var
etc         lost+found  proc        sys
# rmmod drv_chrdevbase.ko
chrdevbase_exit() 
# modprobe drv_chrdevbase.ko
modprobe: can't change directory to '3.10.108': No such file or directory
# cd /lib
# ls
fonts                 libdl.so.2            libpthread-2.23.so
ld-2.23.so            libgcc_s.so           libpthread.so.0
ld-linux.so.3         libgcc_s.so.1         libresolv-2.23.so
libatomic.so          libm-2.23.so          libresolv.so.2
libatomic.so.1        libm.so.6             librt-2.23.so
libatomic.so.1.0.0    libnsl-2.23.so        librt.so.1
libc-2.23.so          libnsl.so.1           libutil-2.23.so
libc.so.6             libnss_dns-2.23.so    libutil.so.1
libcrypt-2.23.so      libnss_dns.so.2       modules
libcrypt.so.1         libnss_files-2.23.so
libdl-2.23.so         libnss_files.so.2
# cd modules/
# mkdir 3.10.108
# modprobe drv_chrdevbase.ko
modprobe: can't open 'modules.dep': No such file or directory
# ls
3.10.108           drv_chrdevbase.ko
# cd 3.10.108/
# depmpd
-/bin/sh: depmpd: not found
# pwd
/lib/modules/3.10.108
# cd ..
# cd /
# ls
app         lib         media       root        tmp
bin         lib32       mnt         run         usr
dev         linuxrc     opt         sbin        var
etc         lost+found  proc        sys
# can't open 'modules.dep'
# ls
app         lib         media       root        tmp
bin         lib32       mnt         run         usr
dev         linuxrc     opt         sbin        var
etc         lost+found  proc        sys
# cd /lib/modules/
# ls
3.10.108           drv_chrdevbase.ko
# insmod drv_chrdevbase.ko 
chrdevbase_init() 
# cd /
# cat /proc/devices
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  7 vcs
 10 misc
 13 input
 14 sound
 29 fb
 81 video4linux
 86 ch
 89 i2c
 90 mtd
108 ppp
116 alsa
128 ptm
136 pts
180 usb
188 ttyUSB
189 usb_device
200 chrdevbase
252 bsg
253 media
254 rtc

Block devices:
  1 ramdisk
259 blkext
  8 sd
 31 mtdblock
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
179 mmc
# cat /dev
cat: read error: Is a directory
# cd /dev
# ls
audio               ram2                tty39
bus                 ram3                tty4
console             ram4                tty40
cpu_dma_latency     ram5                tty41
dsp                 ram6                tty42
etimer0             ram7                tty43
etimer1             ram8                tty44
etimer2             ram9                tty45
etimer3             random              tty46
fb0                 root                tty47
full                rtc0                tty48
ge2d                shm                 tty49
i2c-0               snd                 tty5
i2c-2               tty                 tty50
i2c-3               tty0                tty51
input               tty1                tty52
kmem                tty10               tty53
kmsg                tty11               tty54
log                 tty12               tty55
mem                 tty13               tty56
mixer               tty14               tty57
mtd0                tty15               tty58
mtd0ro              tty16               tty59
mtd1                tty17               tty6
mtd1ro              tty18               tty60
mtd2                tty19               tty61
mtd2ro              tty2                tty62
mtdblock0           tty20               tty63
mtdblock1           tty21               tty7
mtdblock2           tty22               tty8
network_latency     tty23               tty9
network_throughput  tty24               ttyS0
null                tty25               ttyS1
nuvoton-aes         tty26               ttyS2
nuvoton-sha         tty27               ttyS3
ppp                 tty28               ttyS8
psaux               tty29               uhid
ptmx                tty3                urandom
pts                 tty30               vcs
ram0                tty31               vcs1
ram1                tty32               vcsa
ram10               tty33               vcsa1
ram11               tty34               video0
ram12               tty35               video1
ram13               tty36               video2
ram14               tty37               zero
ram15               tty38
# mknod /dev/chrdevbase c 200 0
# pwd
/dev
# ls
audio               ram15               tty38
bus                 ram2                tty39
chrdevbase          ram3                tty4
console             ram4                tty40
cpu_dma_latency     ram5                tty41
dsp                 ram6                tty42
etimer0             ram7                tty43
etimer1             ram8                tty44
etimer2             ram9                tty45
etimer3             random              tty46
fb0                 root                tty47
full                rtc0                tty48
ge2d                shm                 tty49
i2c-0               snd                 tty5
i2c-2               tty                 tty50
i2c-3               tty0                tty51
input               tty1                tty52
kmem                tty10               tty53
kmsg                tty11               tty54
log                 tty12               tty55
mem                 tty13               tty56
mixer               tty14               tty57
mtd0                tty15               tty58
mtd0ro              tty16               tty59
mtd1                tty17               tty6
mtd1ro              tty18               tty60
mtd2                tty19               tty61
mtd2ro              tty2                tty62
mtdblock0           tty20               tty63
mtdblock1           tty21               tty7
mtdblock2           tty22               tty8
network_latency     tty23               tty9
network_throughput  tty24               ttyS0
null                tty25               ttyS1
nuvoton-aes         tty26               ttyS2
nuvoton-sha         tty27               ttyS3
ppp                 tty28               ttyS8
psaux               tty29               uhid
ptmx                tty3                urandom
pts                 tty30               vcs
ram0                tty31               vcs1
ram1                tty32               vcsa
ram10               tty33               vcsa1
ram11               tty34               video0
ram12               tty35               video1
ram13               tty36               video2
ram14               tty37               zero
# ls -l chrdevbase 
crw-r--r--    1 root     root      200,   0 Jul  1 16:15 chrdevbase
# cd /
# ls
app         lib         media       root        tmp
bin         lib32       mnt         run         usr
dev         linuxrc     opt         sbin        var
etc         lost+found  proc        sys
# cd app
# ls
# cd /mnt
# ls
app         drv         mnt         sdk         sdk.tar.gz
# cd app
# ls
a.out             app_chrdevbase    app_chrdevbase.c
# cp app_chrdevbase /app
# cd /app
# ls
app_chrdevbase
# ./app_chrdevbase /dev/chrdevbase 1
chrdevbase open! 
kernel senddata ok! 
chrdevbase read! 
read data:kechrdevbase release ! 
rnel data!  
# ./app_chrdevbase /dev/chrdevbase 2
chrdevbase open! 
kernel recevdata: usr data! 
chrdevbase write ! 
chrdevbase release ! 
# ldmod
-/bin/sh: ldmod: not found
# lsmod
Module                  Size  Used by    Tainted: G  
drv_chrdevbase          1770  0 
# rmmod drv_chrdevbase
chrdevbase_exit() 
# lsmod
Module                  Size  Used by    Tainted: G  
# 

说明:
1.编译驱动或app前要先 source env.sh ,系统中没有设置默的交叉编译工具目录
2.在根文件系统中默认没有使用depmod这个功能,所以不能用modprobe这个命令来加载,要么重新配置busybox
用insmod加载也是可以的.
3.有的目录不能进入是没有给权限:chmod 777 dir



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值