linux模块 如何编译

qq_1104962332 2021-03-14 01:22:03
哪位大佬来帮我编译一个linux模块
...全文
3621 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
uuwu2000 2021-03-17
  • 打赏
  • 举报
回复
make zImage执行后生成的就是linux系统安装文件了啊
uuwu2000 2021-03-17
  • 打赏
  • 举报
回复
改啥呢?是我说要改的那几个文件么?
qq_1104962332 2021-03-17
  • 打赏
  • 举报
回复
引用 2 楼 uuwu2000的回复:
将tl2543.c复制到linux-2.6.38/drivers/char 修改Kconfig、Makefile文件,仿制其他的配置修改 回到linux-2.6.38目录下 1) make menuconfig.......(没有第一步,菜单看不见yc...) 2) linux-2.6.38/drivers/char/Makefile最后加上 obj-$(CONFIG_TLC2543) += tlc2543.o 3) make zImage
能帮忙改一下吗?
uuwu2000 2021-03-17
  • 打赏
  • 举报
回复
将tl2543.c复制到linux-2.6.38/drivers/char 修改Kconfig、Makefile文件,仿制其他的配置修改 回到linux-2.6.38目录下 1) make menuconfig.......(没有第一步,菜单看不见yc...) 2) linux-2.6.38/drivers/char/Makefile最后加上 obj-$(CONFIG_TLC2543) += tlc2543.o 3) make zImage
uuwu2000 2021-03-17
  • 打赏
  • 举报
回复
// TLC2543 SPICS1-C7 SPICLK1-C5 SPIMOSI1-C6 SPIMISO1-C4 #include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/input.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/sched.h> #include <linux/cdev.h> #include <linux/miscdevice.h> #include <asm/io.h> #include <asm/uaccess.h> #include <mach/map.h> #include <mach/regs-gpio.h> #include <plat/regs-timer.h> #define SPI_NAME "spi1_2543" static int major = 0; static struct class* yc_drv_poll_class; #define SPI_MISO 4 #define SPI_MOSI 6 #define SPI_CLK 5 /* #define SPI_CS1 "C7" #define SPI_CS2 "N9" #define SPI_CS3 "L8" */ #define S3C64XX_GPCCON (S3C64XX_GPC_BASE + 0x00) #define S3C6410_GPCCON_PA (0x7F008040) #define S3C6410_GPCDAT_PA (0x7F008044) #define S3C6410_GPCPUD_PA (0x7F008048) #define S3C6410_GPLCON1_PA (0x7F008814) #define S3C6410_GPLDAT_PA (0x7F008818) #define S3C6410_GPLPUD_PA (0x7F00881C) #define S3C6410_GPNCON_PA (0x7F008830) #define S3C6410_GPNDAT_PA (0x7F008834) #define S3C6410_GPNPUD_PA (0x7F008838) static volatile unsigned long* gpccon = NULL; static volatile unsigned long* gpcdat = NULL; static volatile unsigned long* gpcpud = NULL; static volatile unsigned long* gplcon = NULL; static volatile unsigned long* gpldat = NULL; static volatile unsigned long* gplpud = NULL; static volatile unsigned long* gpncon = NULL; static volatile unsigned long* gpndat = NULL; static volatile unsigned long* gpnpud = NULL; static int ycval[33]; static struct timer_list poll_timer; static bool entimer; static inline void set_cs1(int v){ // C7 unsigned long tmp; tmp = *gpcdat; if (v!=0) { tmp |= (1<<7); } else { tmp &= ~(1<<7); } *gpcdat = tmp; } static inline void set_cs2(int v){ // N9 unsigned long tmp; tmp = *gpndat; if (v!=0) { tmp |= (1<<9); } else { tmp &= ~(1<<9); } *gpndat = tmp; } static inline void set_cs3(int v){ // L8 unsigned long tmp; tmp = *gpldat; if (v!=0) { tmp |= (1<<8); } else { tmp &= ~(1<<8); } *gpldat = tmp; } static inline void set_gpcx_value(int pinx ,int v){ unsigned long tmp; tmp = *gpcdat; if (v!=0) { tmp |= (1<<pinx); } else { tmp &= ~(1<<pinx); } *gpcdat = tmp; } static inline int get_gpcx_value(int pinx){ int v; unsigned long tmp; tmp = *gpcdat; v = tmp & (1<<pinx); if(v!=0) return 1; return 0; } static int tlc2543_convert(int chip, int chn){ int i,result; set_gpcx_value(SPI_CLK, 0); set_cs1(1); set_cs2(1); set_cs3(1); udelay(1); // 10 result = 0; chn = chn % 11; chn <<=8; // followed bit need 0 if(chip==0) set_cs1(0); if(chip==1) set_cs2(0); if(chip==2) set_cs3(0); udelay(2); // 5 // >1.425us for(i=0;i<12;i++){ if(get_gpcx_value(SPI_MISO) != 0) result |= 0x01; if((chn & 0x800)!=0) set_gpcx_value(SPI_MOSI, 1); else set_gpcx_value(SPI_MOSI, 0); set_gpcx_value(SPI_CLK, 1); // frequenc < 4.1MHz udelay(1); // 5 if(i==11) udelay(10); set_gpcx_value(SPI_CLK, 0); udelay(1); // 5 // sugest above 1us, for wait out-data chn <<= 1; result <<= 1; } if(chip==0) set_cs1(1); if(chip==1) set_cs2(1); if(chip==2) set_cs3(1); udelay(5); // new add result >>= 1; return (result); } ///////////////////poll timer 500ms///////////////////////////////// static void timer_func(unsigned long data){ int chip, chn, tmp, i, k, val[6]; for(chip=0; chip<3; chip++){ tlc2543_convert(chip, 0); for(chn=0; chn<11; chn++){ for(i=0; i<5; i++) val[i] = tlc2543_convert(chip, chn); if(chn<10) val[5] = tlc2543_convert(chip, chn+1); else val[5] = tlc2543_convert(chip, chn); for(i=0; i<6; i++){ for(k=0; k<5-i; k++){ if(val[k]>val[k+1]){ tmp = val[k]; val[k] = val[k+1]; val[k+1] = tmp; } } } tmp = val[1] + val[2]; ycval[chip*11+chn] = tmp>>1; } } mod_timer(&poll_timer,jiffies+30); } ////////////////////////////////////////////////////////////////////// static int spi_open(struct inode *inode,struct file *filp) { set_cs1(1); set_cs2(1); set_cs3(1); set_gpcx_value(SPI_CLK, 0); init_timer(&poll_timer); poll_timer.expires = jiffies + 30; // Linux tickets:100Hz, so:50*10ms=>500ms poll_timer.function = timer_func; add_timer(&poll_timer); entimer = 1; return 0; } static int spi_release(struct inode *inode,struct file *filp) { if(entimer) { del_timer(&poll_timer); entimer = 0; } return 0; } static ssize_t spi_read(struct file *filp,char __user *buf,size_t count) { return(ssize_t)(copy_to_user(buf,ycval,count)); } static const struct file_operations spi_fops = { .owner = THIS_MODULE, .open = spi_open, .read = spi_read, .release = spi_release, }; static int __init spi_init(void) { major = register_chrdev(0, SPI_NAME, &spi_fops); if(major < 0) return -1; yc_drv_poll_class= class_create(THIS_MODULE, SPI_NAME); device_create(yc_drv_poll_class, NULL, MKDEV(major, 0), NULL, SPI_NAME); entimer = 0; gpccon = ioremap(S3C6410_GPCCON_PA, 4); gpcdat = ioremap(S3C6410_GPCDAT_PA, 4); gpcpud = ioremap(S3C6410_GPCPUD_PA, 4); *gpccon &= ~((0xF<<16)|(0xF<<20)|(0xF<<24)|(0xF<<28)); // 4BIT Control *gpccon |= ((0x0<<16)|(0x1<<20)|(0x1<<24)|(0x1<<28)); // 0000=input 0001=output *gpcpud &= ~((0x3<<8)|(0x3<<10)|(0x3<<12)|(0x3<<14)); // 2BIT Control *gpcpud |= ((0x2<<8)|(0x2<<10)|(0x2<<12)|(0x2<<14)); // 10=pull-up 01=pull-down 00-tri gplcon = ioremap(S3C6410_GPLCON1_PA, 4); gpldat = ioremap(S3C6410_GPLDAT_PA, 4); gplpud = ioremap(S3C6410_GPLPUD_PA, 4); *gplcon &= ~(0xF<<0); // 4BIT Control CS3:L8 *gplcon |= (0x1<<0); // 0000=input 0001=output *gplpud &= ~(0x3<<0); // 2BIT Control *gplpud |= (0x2<<0); // 10=pull-up 01=pull-down 00-tri gpncon = ioremap(S3C6410_GPNCON_PA, 4); gpndat = ioremap(S3C6410_GPNDAT_PA, 4); gpnpud = ioremap(S3C6410_GPNPUD_PA, 4); *gpncon &= ~(0x000c0000); // 2BIT Control CS2:N9 *gpncon |= (0x00040000); // 00=input 01=output *gpnpud &= ~(0x3<<18); // 2BIT Control *gpnpud |= (0x2<<18); // 10=pull-up 01=pull-down 00-tri return 0; } static void __exit spi_exit(void) { device_destroy(yc_drv_poll_class, MKDEV(major, 0)); class_destroy(yc_drv_poll_class); unregister_chrdev(major, SPI_NAME); iounmap(gpccon); iounmap(gpcdat); iounmap(gpcpud); iounmap(gplcon); iounmap(gpldat); iounmap(gplpud); iounmap(gpncon); iounmap(gpndat); iounmap(gpnpud); } module_init(spi_init); module_exit(spi_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("WUYONGMING"); MODULE_DESCRIPTION("SPI_TLC2543_DRIVRE");
qq_1104962332 2021-03-17
  • 打赏
  • 举报
回复
引用 5 楼 uuwu2000的回复:
make zImage执行后生成的就是linux系统安装文件了啊
嗯嗯,就是你说的

1,318

社区成员

发帖
与我相关
我的任务
社区描述
主要是开发驱动技术
社区管理员
  • 驱动程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧