Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12606 Discussions

Byteblaster driver for Linux 2.6

Altera_Forum
Honored Contributor II
1,138 Views

Has anyone successfully ported the ByteblasterII device driver to the version 2.6 kernel ? 

 

Would appreciate any info on how this can be achieved.  

I have managed to generate the byteblaster.ko file but find that insmod fails with the following error: 

 

error inserting 'byteblaster.ko': -1 device or resource busy 

 

 

This error is returned by devfs_register_chrdev but I'm not sure why this would occur, no other devices are connected to the port. Any suggestions ? 

 

thanks
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
418 Views

Here is a patch for byteblaster on 2.6: 

 

diff -urN byteblaster.orig/byteblaster.c byteblaster/byteblaster.c 

--- byteblaster.orig/byteblaster.c 2004-11-30 12:11:14.000000000 +0100 

+++ byteblaster/byteblaster.c 2005-02-09 12:10:24.000000000 +0100 

@@ -66,6 +66,7 @@ 

# include <linux/module.h> 

# include <linux/kernel.h> 

# include <linux/devfs_fs_kernel.h> 

+#include <linux/fs.h> 

# include <linux/slab.h> 

# include <linux/smp_lock.h> 

# include <linux/sched.h> 

@@ -88,7 +89,7 @@ 

struct byteblaster_t { 

struct pardevice * dev; 

unsigned long flags; 

- devfs_handle_t devfs_handle; 

+ dev_t devfs_handle; 

struct semaphore port_mutex; 

 

char * read_fifo; 

@@ -419,10 +420,10 @@ 

return; 

 

sprintf (name, "byteblaster%d", i); 

- byteblaster.devfs_handle = devfs_register (null, name, 

- devfs_fl_default, byteblaster_major, i, 

- s_ifchr | s_irugo | s_iwugo, 

- &byteblaster_fops, null); 

+ byteblaster.devfs_handle = NULL; //devfs_register (NULL, name, 

+// DEVFS_FL_DEFAULT, byteblaster_major, i, 

+// S_IFCHR | S_IRUGO | S_IWUGO, 

+// &byteblaster_fops, NULL); 

 

printk(KERN_INFO "byteblaster%d: using %s.\n", i, port->name); 

 

@@ -441,7 +442,7 @@ 

if (byteblaster.dev != null && byteblaster.dev->port == port) { 

 

parport_unregister_device(byteblaster.dev); 

- devfs_unregister(byteblaster.devfs_handle); 

+ //devfs_unregister(byteblaster.devfs_handle); 

 

byteblaster.dev = NULL; 

byteblaster.devfs_handle = null; 

@@ -468,7 +469,7 @@ 

byteblaster.read_fifo = NULL; 

 

- err = devfs_register_chrdev(byteblaster_major, "byteblaster", &byteblaster_fops); 

+ err = register_chrdev(byteblaster_major, "byteblaster", &byteblaster_fops); 

if (err < 0) 

return err; 

 

@@ -488,12 +489,12 @@ 

 

parport_unregister_driver (&byteblaster_driver); 

 

- devfs_unregister_chrdev(byteblaster_major, "byteblaster"); 

+ unregister_chrdev(byteblaster_major, "byteblaster"); 

 

for (i = 0 ; i < BYTEBLASTER_MAX ; i++) 

if (byteblaster.dev != null) { 

parport_unregister_device(byteblaster.dev); 

- devfs_unregister(byteblaster.devfs_handle); 

+ //devfs_unregister(byteblaster.devfs_handle); 

 

diff -urN byteblaster.orig/Makefile byteblaster/Makefile 

--- byteblaster.orig/Makefile 2004-11-30 12:11:14.000000000 +0100 

+++ byteblaster/Makefile 2005-02-09 14:42:16.222653771 +0100 

@@ -15,25 +15,38 @@ 

# This is the default location of the  

# VER = $(shell uname -r) 

# INCLUDEDIR=/lib/modules/$(VER)/build/include 

-include .config.make 

+#include .config.make 

 

-CFLAGS= -D__KERNEL__ -DMODULE -D__SMP__ -O3 -Wall -I$(INCLUDEDIR) 

+#CFLAGS= -D__KERNEL__ -DMODULE -D__SMP__ -O3 -Wall -I$(INCLUDEDIR) 

 

# Comment out the next line if you don&#39;t want kernel symbol versioning. 

-CFLAGS += -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h 

+#CFLAGS += -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h 

 

-OBJS = byteblaster.o 

+#OBJS = byteblaster.o 

 

-byteblaster.o : byteblaster.c Makefile 

+ifneq ($(KERNELRELEASE),) 

+ obj-m := byteblaster.o 

 

-install: byteblaster.o jtagd-init 

+else 

+ VER := $(shell uname -r) 

+ KDIR := /lib/modules/$(VER)/build 

+ PWD := $(shell pwd) 

+default: 

+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules 

+endif 

+#byteblaster.o : byteblaster.c Makefile 

+install: byteblaster.ko jtagd-init 

install -d /lib/modules/$(VER)/kernel/misc/ 

- install -c byteblaster.o /lib/modules/$(VER)/kernel/misc/byteblaster.o 

+ install -c byteblaster.ko /lib/modules/$(VER)/kernel/misc/byteblaster.ko 

install -c jtagd-init /etc/rc.d/init.d/jtagd 

/sbin/chkconfig --add jtagd 

/sbin/depmod -aq 

/etc/rc.d/init.d/jtagd start 

 

clean: 

- rm *.o 

+ rm -f *.ko *.o .*.cmd byteblaster.mod.c 

+ rm -rf .tmp_versions
0 Kudos
Altera_Forum
Honored Contributor II
418 Views

Thanks, I will give it a try.

0 Kudos
Reply