[Armadeus-commitlog] armadeus branch, master, updated. latestrelease-168-g4d73dbf
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2009-11-25 09:57:19
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 4d73dbf067c315a28fab98e70bc4c88501fcc6d2 (commit)
via 648e2df5a2649129c513255b15eb653aba5fded2 (commit)
via c69d139ecfea0d0cd0ad03557aeb04d4388a0ad9 (commit)
via c957b401e6addf220eb5f285508b99ea3aea59c2 (commit)
via f5e13fc1e9fe2ee35f36130dec5b5f604d939819 (commit)
from 38af2b865f3026c40ac73cbfec56ae311ba1e9f6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4d73dbf067c315a28fab98e70bc4c88501fcc6d2
Author: Julien Boibessot <jul...@ar...>
Date: Wed Nov 25 10:48:42 2009 +0100
[LINUX] Cleanup fpgaloader, check indentation while we are at it...
commit 648e2df5a2649129c513255b15eb653aba5fded2
Author: Julien Boibessot <jul...@ar...>
Date: Wed Nov 25 10:41:51 2009 +0100
[LINUX] Cleanup some wishbone_example Makefiles
commit c69d139ecfea0d0cd0ad03557aeb04d4388a0ad9
Author: Julien Boibessot <jul...@ar...>
Date: Wed Nov 25 10:40:07 2009 +0100
[TEST] Cleanup and factorize test_fpga
commit c957b401e6addf220eb5f285508b99ea3aea59c2
Author: Julien Boibessot <jul...@ar...>
Date: Wed Nov 25 09:31:31 2009 +0100
Indentation...
commit f5e13fc1e9fe2ee35f36130dec5b5f604d939819
Author: Julien Boibessot <jul...@ar...>
Date: Tue Nov 24 23:24:42 2009 +0100
Indentation...
-----------------------------------------------------------------------
Summary of changes:
.../modules/fpga/dev_tools/loader/fpga-loader.c | 47 ++--
.../fpga/dev_tools/loader/xilinx-fpga-loader.c | 130 ++++++-----
.../fpga/dev_tools/loader/xilinx-fpga-loader.h | 13 +-
.../linux/modules/fpga/wishbone_example/Makefile | 10 -
.../fpga/wishbone_example/wb_button/Makefile | 13 +-
.../fpga/wishbone_example/wb_button/button.c | 269 ++++++++++----------
.../fpga/wishbone_example/wb_button/button.h | 32 +--
.../fpga/wishbone_example/wb_button/gbutton.c | 237 +++++++++---------
target/test/test_fpga.sh | 57 ++---
target/test/test_helpers.sh | 7 +-
10 files changed, 402 insertions(+), 413 deletions(-)
diff --git a/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c b/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c
index 05b5d6b..bb98a47 100644
--- a/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c
+++ b/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c
@@ -20,7 +20,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-// #define DEBUG
+/* #define DEBUG */
#include <linux/version.h>
#include <linux/module.h>
@@ -44,7 +44,7 @@ struct fpga_desc *g_current_desc = NULL;
struct semaphore fpga_sema;
static unsigned char fpga_descriptor = 0; /* use default target_fpga_desc */
-module_param( fpga_descriptor, byte, 0 );
+module_param(fpga_descriptor, byte, 0);
#define FPGA_BUFFER_SIZE 4096
static unsigned char g_buffer[FPGA_BUFFER_SIZE];
@@ -60,18 +60,18 @@ static ssize_t armadeus_fpga_write(struct file *file, const char* pData, size_t
if (down_interruptible(&fpga_sema))
return -ERESTARTSYS;
- if( count > FPGA_BUFFER_SIZE ) {
+ if (count > FPGA_BUFFER_SIZE) {
count = FPGA_BUFFER_SIZE;
}
/* Get value to write from user space */
- ret = __copy_from_user( g_buffer, pData, count);
+ ret = __copy_from_user(g_buffer, pData, count);
if (ret != 0) {
ret = -EFAULT;
goto out;
}
- ret = fpga_load( g_current_desc, g_buffer, count );
+ ret = fpga_load(g_current_desc, g_buffer, count);
out:
/* Release exclusive access */
@@ -89,17 +89,20 @@ static int armadeus_fpga_open(struct inode *inode, struct file *file)
return -ERESTARTSYS;
/* Only one access at a time is permitted */
- if( g_nb_users > 0 )
- return -EBUSY;
+ if (g_nb_users > 0) {
+ ret = -EBUSY;
+ goto out;
+ }
- ret = fpga_init_load( g_current_desc );
- if(!ret) {
+ ret = fpga_init_load(g_current_desc);
+ if (!ret) {
printk("Starting FPGA download\n");
g_nb_users++;
}
- pr_debug("Opening /dev/fpga/loader%d file, %d %d\n", MINOR(inode->i_rdev), fpga_descriptor, ret);
+ pr_debug("Opening /dev/fpga/loader, %d %d\n", fpga_descriptor, ret);
+out:
/* Release exclusive access */
up(&fpga_sema);
@@ -108,12 +111,12 @@ static int armadeus_fpga_open(struct inode *inode, struct file *file)
static int armadeus_fpga_release(struct inode *inode, struct file *file)
{
- if( fpga_finish_load(g_current_desc) )
+ if (fpga_finish_load(g_current_desc))
printk("Failed to load FPGA !\n");
- pr_debug("Closing access to /dev/fpga/loader%d\n", MINOR(inode->i_rdev));
+ pr_debug("Closing access to /dev/fpgaloader\n");
- if( g_nb_users > 0 )
+ if (g_nb_users > 0)
g_nb_users--;
return 0;
@@ -121,7 +124,7 @@ static int armadeus_fpga_release(struct inode *inode, struct file *file)
/* PROC file */
-static int procfile_fpga_read( char *buffer, __attribute__ ((unused)) char **start, off_t offset, int buffer_length, int *eof, __attribute__ ((unused)) void* data)
+static int procfile_fpga_read(char *buffer, __attribute__ ((unused)) char **start, off_t offset, int buffer_length, int *eof, __attribute__ ((unused)) void* data)
{
int ret;
@@ -131,11 +134,11 @@ static int procfile_fpga_read( char *buffer, __attribute__ ((unused)) char **sta
library would continue to issue the read system call until the
the kernel replies that it has no more information, or until
its buffer is filled */
- if( offset > 0 ) {
+ if (offset > 0) {
/* we have finished to read, return 0 */
ret = 0;
} else {
- ret = fpga_get_infos( g_current_desc, buffer );
+ ret = fpga_get_infos(g_current_desc, buffer);
}
return ret;
@@ -177,7 +180,7 @@ int armadeus_fpga_ioctl( struct inode *inode, struct file *filp, unsigned int cm
return -EFAULT;
}*/
- switch(cmd)
+ switch (cmd)
{
default:
return -ENOTTY;
@@ -198,8 +201,8 @@ static int create_proc_entries( void )
proc_mkdir(FPGA_PROC_DIRNAME, NULL);
/* Create proc file */
- fpga_Proc_File = create_proc_entry( FPGA_PROC_FILENAME, S_IWUSR |S_IRUSR | S_IRGRP | S_IROTH, NULL );
- if( fpga_Proc_File == NULL ) {
+ fpga_Proc_File = create_proc_entry(FPGA_PROC_FILENAME, S_IWUSR |S_IRUSR | S_IRGRP | S_IROTH, NULL);
+ if (fpga_Proc_File == NULL) {
printk(DRIVER_NAME ": Could not register a" FPGA_PROC_FILENAME ". Terminating\n");
goto error;
} else {
@@ -269,7 +272,7 @@ static int armadeus_fpga_probe(struct platform_device *pdev)
__func__, __LINE__, fpgaloader_misc.minor);
result = create_proc_entries();
- if( result < 0 )
+ if (result < 0)
goto err_misc;
sema_init(&fpga_sema, 1);
@@ -277,6 +280,8 @@ static int armadeus_fpga_probe(struct platform_device *pdev)
/* initialize the current fpga descriptor with the one by default */
g_current_desc = platform_info;
+ printk(DRIVER_NAME " v" DRIVER_VERSION " ready\n");
+
return 0;
err_misc:
@@ -306,8 +311,6 @@ static struct platform_driver armadeus_fpga_driver = {
static int __init armadeus_fpga_init(void)
{
- printk(DRIVER_NAME " v" DRIVER_VERSION "\n");
-
return platform_driver_register(&armadeus_fpga_driver);
}
diff --git a/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c b/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c
index 09c380f..4897f88 100644
--- a/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c
+++ b/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c
@@ -67,7 +67,7 @@ static int xilinx_dump_descriptor_info( struct fpga_desc *desc, char* buffer )
* program the FPGA (serial mode).
* return 0 if success, >0 while programming, <0 if error detected
*/
-static size_t spartan_serial_load (struct fpga_desc *desc, const char* buf, size_t bsize)
+static size_t spartan_serial_load(struct fpga_desc *desc, const char* buf, size_t bsize)
{
Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
@@ -101,7 +101,7 @@ static size_t spartan_serial_load (struct fpga_desc *desc, const char* buf, size
} while (i > 0);
}
- if(bytecount%4096 == 0)
+ if (bytecount % 4096 == 0)
printk(".");
return bsize;
@@ -110,17 +110,17 @@ static size_t spartan_serial_load (struct fpga_desc *desc, const char* buf, size
}
/**
- * initialize the FPGA programming interface.
+ * initialize the FPGA programming interface (serial).
* return 0 if success, <0 if error detected
*/
-static int spartan_serial_init (struct fpga_desc *desc)
+static int spartan_serial_init(struct fpga_desc *desc)
{
Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
if (fn) {
unsigned long timestamp;
- if(*fn->pre){
- (*fn->pre)(); //Run the pre configuration function if there is one.
+ if (*fn->pre){
+ (*fn->pre)(); /* Run the pre configuration function if there is one. */
}
/* Establish the initial state */
@@ -186,10 +186,10 @@ static int spartan_serial_finish(struct fpga_desc *desc)
/**
- * initialize the FPGA programming interface.
+ * initialize the FPGA programming interface (parallel).
* return 0 if success, <0 if error detected
*/
-static int spartan_parallel_init (struct fpga_desc *desc)
+static int spartan_parallel_init(struct fpga_desc *desc)
{
int res = 0;
Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns;
@@ -244,7 +244,7 @@ static int spartan_parallel_init (struct fpga_desc *desc)
* program the FPGA (parallel mode).
* return 0 if success, >0 while programming, <0 if error detected
*/
-static size_t spartan_parallel_load (struct fpga_desc *desc, const char* buf, size_t bsize)
+static size_t spartan_parallel_load(struct fpga_desc *desc, const char* buf, size_t bsize)
{
unsigned long flags;
Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns;
@@ -285,7 +285,7 @@ static int spartan_parallel_finish(struct fpga_desc *desc)
(*fn->clk) (1); /* Assert the clock pin */
if (get_timer(timestamp) > CFG_FPGA_WAIT) {
- printk("** Timeout waiting for DONE to clear. %d \n", bytecount);
+ printk("** Timeout waiting for DONE to clear. %d bytes\n", bytecount);
(*fn->abort) (); /* abort the burn */
return -ETIMEDOUT;
}
@@ -296,10 +296,9 @@ static int spartan_parallel_finish(struct fpga_desc *desc)
(*fn->abort) (); /* abort the burn */
return -ETIMEDOUT;
}
-
(*fn->cs) (0); /* Deassert the chip select */
(*fn->wr) (0); /* Deassert the write pin */
- (*fn->post) (); /* post init */
+ (*fn->post) (); /* release resources */
}
return 0;
@@ -310,23 +309,31 @@ size_t fpga_load( struct fpga_desc *desc, const char *buf, size_t bsize )
{
int ret = 0;
- if( desc ) {
- switch( desc->family ) /* check family */
- {
- case Xilinx_Spartan:
+ if (desc) {
+ switch (desc->family) /* check family */
{
- switch( desc->iface ) /* check download hardware interface */
+ case Xilinx_Spartan:
{
- case slave_serial: ret = spartan_serial_load( desc, buf, bsize ); break;
- case slave_parallel: ret = spartan_parallel_load (desc, buf, bsize); break;
- default: PRINTF("interface not supported!\n"); ret = -ENOSYS; break;
+ switch (desc->iface) /* check download hardware interface */
+ {
+ case slave_serial:
+ ret = spartan_serial_load(desc, buf, bsize);
+ break;
+ case slave_parallel:
+ ret = spartan_parallel_load (desc, buf, bsize);
+ break;
+ default:
+ PRINTF("interface not supported!\n");
+ ret = -ENOSYS;
+ break;
+ }
}
- }
- break;
- default:
- PRINTF("family not supported!\n");
- ret = -ENOSYS;
- break;
+ break;
+
+ default:
+ PRINTF("family not supported!\n");
+ ret = -ENOSYS;
+ break;
}
}
else {
@@ -340,23 +347,30 @@ int fpga_init_load( struct fpga_desc *desc )
{
int ret = 0;
- if( desc ) {
- switch( desc->family )
- {
- case Xilinx_Spartan:
+ if (desc) {
+ switch (desc->family)
{
- switch( desc->iface ) /* check donwload hardware interface */
+ case Xilinx_Spartan:
{
- case slave_serial: ret = spartan_serial_init( desc ); break;
- case slave_parallel: ret = spartan_parallel_init( desc ); break;
- default: pr_debug("interface not supported!\n"); ret = -ENOSYS; break;
+ switch (desc->iface) /* check donwload hardware interface */
+ {
+ case slave_serial:
+ ret = spartan_serial_init( desc );
+ break;
+ case slave_parallel:
+ ret = spartan_parallel_init( desc );
+ break;
+ default:
+ pr_debug("interface not supported!\n");
+ ret = -ENOSYS;
+ break;
+ }
}
- }
- break;
- default:
- pr_debug("family not supported!\n");
- ret = -ENOSYS;
- break;
+ break;
+ default:
+ pr_debug("family not supported!\n");
+ ret = -ENOSYS;
+ break;
}
}
else {
@@ -366,33 +380,33 @@ int fpga_init_load( struct fpga_desc *desc )
return ret;
}
-int fpga_finish_load( struct fpga_desc *desc )
+int fpga_finish_load(struct fpga_desc *desc)
{
int ret = 0;
- if( desc ) {
- switch( desc->family )
+ if (desc) {
+ switch (desc->family)
{
case Xilinx_Spartan:
{
- switch( desc->iface ) /* check donwload hardware interface */
+ switch (desc->iface) /* check hardware download interface */
{
- case slave_serial:
- ret = spartan_serial_finish( desc );
- break;
- case slave_parallel:
- ret = spartan_parallel_finish( desc );
- break;
- default:
- pr_debug("interface not supported!\n");
- ret = -ENOSYS;
- break;
+ case slave_serial:
+ ret = spartan_serial_finish(desc);
+ break;
+ case slave_parallel:
+ ret = spartan_parallel_finish(desc);
+ break;
+ default:
+ pr_debug("interface not supported!\n");
+ ret = -ENOSYS;
+ break;
}
}
break;
- default:
- pr_debug("family not supported!\n");
- ret = -ENOSYS;
+ default:
+ pr_debug("family not supported!\n");
+ ret = -ENOSYS;
break;
}
} else {
@@ -407,7 +421,7 @@ int fpga_get_infos( struct fpga_desc *desc, char* buffer )
{
int len = 0;
- if( desc ) {
+ if (desc) {
len = xilinx_dump_descriptor_info( desc, buffer );
}
diff --git a/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.h b/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.h
index 5d88aa6..8666010 100644
--- a/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.h
+++ b/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.h
@@ -117,20 +117,21 @@ typedef struct {
* program the FPGA.
* return 0 if success, >0 while programming, <0 if error detected
*/
-size_t fpga_load( struct fpga_desc *desc, const char *buf, size_t bsize );
+size_t fpga_load(struct fpga_desc *desc, const char *buf, size_t bsize);
/**
* initialize the FPGA programming interface
* return 0 if success, <0 if error detected
*/
-int fpga_init_load( struct fpga_desc *desc );
+int fpga_init_load(struct fpga_desc *desc);
-/* terminate FGPA loading */
-int fpga_finish_load( struct fpga_desc *desc );
+/* terminate FPGA loading */
+int fpga_finish_load(struct fpga_desc *desc);
/**
- * get some infos about FPGA download, return the number of char placed in the buffer
+ * get some infos about FPGA download.
+ * return the number of char placed in the buffer
*/
-int fpga_get_infos( struct fpga_desc *desc, char* buffer);
+int fpga_get_infos(struct fpga_desc *desc, char* buffer);
#endif // __XILINX_FPGA_H__
diff --git a/target/linux/modules/fpga/wishbone_example/Makefile b/target/linux/modules/fpga/wishbone_example/Makefile
index 5a8c9be..e007089 100644
--- a/target/linux/modules/fpga/wishbone_example/Makefile
+++ b/target/linux/modules/fpga/wishbone_example/Makefile
@@ -24,15 +24,5 @@ install:
echo "Installing Armadeus drivers..."
$(MAKE) -C $(LINUX_DIR) SUBDIRS=$(PWD) INSTALL_MOD_PATH=$(TARGET_DIR) modules_install
-clean:
- rm -f *.*o \
- rm -f *.mod.c \
- rm -f *.cmd \
- rm -f *.o.d \
- rm -f *.order \
- rm -f .*.cmd \
- rm -rf .tmp_versions \
- rm -f Module.symvers
-
endif
diff --git a/target/linux/modules/fpga/wishbone_example/wb_button/Makefile b/target/linux/modules/fpga/wishbone_example/wb_button/Makefile
index ba40ab7..0328a81 100755
--- a/target/linux/modules/fpga/wishbone_example/wb_button/Makefile
+++ b/target/linux/modules/fpga/wishbone_example/wb_button/Makefile
@@ -8,7 +8,6 @@ obj-$(CONFIG_ARMADEUS_WISHBONE_EXAMPLE_BUTTON_DRIVER) += board_buttons.o gbutton
else
-
ARMADEUS_BASE_DIR=../../../../../..
include $(ARMADEUS_BASE_DIR)/Makefile.in
@@ -22,15 +21,9 @@ test:
$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc testbutton.c -o testbutton
clean:
- rm -f *.*o \
- rm -f *.mod.c \
- rm -f *.cmd \
- rm -f *.o.d \
- rm -f *.order \
- rm -f .*.cmd \
- rm -rf .tmp_versions \
- rm -f Module.symvers \
- rm -f testbutton
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
+ rm -f Module.markers \
+ rm -f modules.order
endif
diff --git a/target/linux/modules/fpga/wishbone_example/wb_button/button.c b/target/linux/modules/fpga/wishbone_example/wb_button/button.c
index bdeb936..f998516 100644
--- a/target/linux/modules/fpga/wishbone_example/wb_button/button.c
+++ b/target/linux/modules/fpga/wishbone_example/wb_button/button.c
@@ -27,40 +27,40 @@
static ssize_t button_fpga_read(void * addr, u16 *data, struct button_dev *dev)
{
- *data = ioread16(addr); /* read the button value */
+ *data = ioread16(addr); /* read the button value */
- return 2;
+ return 2;
}
static ssize_t button_fpga_write(void * addr, u16 *data, struct button_dev *dev)
{
- ssize_t retval;
+ ssize_t retval;
- iowrite16(*data, addr); /* write the button value */
- retval = 2;
+ iowrite16(*data, addr); /* write the button value */
+ retval = 2;
- return retval;
+ return retval;
}
/* irq management; awake read process */
static irqreturn_t fpga_interrupt(int irq, void *dev_id, struct pt_regs *reg)
{
- struct button_dev *ldev = dev_id;
- u16 data;
-
- button_fpga_read(ldev->fpga_virtual_base_address + FPGA_IRQ_PEND, &data, ldev);
- PDEBUG("Interrupt raised %x\n", data);
-
- if (data & WB_BUTTON_IRQ) {
- /* wake up reading process */
- if (ldev->reading)
- up(&ldev->sem);
- /* acknowledge irq_mngr */
- button_fpga_write(ldev->fpga_virtual_base_address + FPGA_IRQ_ACK, &data, ldev);
- return IRQ_HANDLED;
- } else {
- return IRQ_NONE;
- }
+ struct button_dev *ldev = dev_id;
+ u16 data;
+
+ button_fpga_read(ldev->fpga_virtual_base_address + FPGA_IRQ_PEND, &data, ldev);
+ PDEBUG("Interrupt raised %x\n", data);
+
+ if (data & WB_BUTTON_IRQ) {
+ /* wake up reading process */
+ if (ldev->reading)
+ up(&ldev->sem);
+ /* acknowledge irq_mngr */
+ button_fpga_write(ldev->fpga_virtual_base_address + FPGA_IRQ_ACK, &data, ldev);
+ return IRQ_HANDLED;
+ } else {
+ return IRQ_NONE;
+ }
}
/***********************************
@@ -68,53 +68,53 @@ static irqreturn_t fpga_interrupt(int irq, void *dev_id, struct pt_regs *reg)
* *********************************/
ssize_t button_read(struct file *fildes, char __user *buff, size_t count, loff_t *offp)
{
- struct button_dev *ldev = fildes->private_data;
- u16 data = 0;
- ssize_t retval = 0;
- DEFINE_WAIT(wait);
+ struct button_dev *ldev = fildes->private_data;
+ u16 data = 0;
+ ssize_t retval = 0;
+ DEFINE_WAIT(wait);
- ldev->reading = 1;
+ ldev->reading = 1;
- if (*offp + count >= 1) /* Only one word can be read */
- count = 1 - *offp;
+ if (*offp + count >= 1) /* Only one word can be read */
+ count = 1 - *offp;
- if ((retval=down_interruptible(&ldev->sem)) < 0)
- goto out;
+ if ((retval=down_interruptible(&ldev->sem)) < 0)
+ goto out;
- if ((retval = button_fpga_read(ldev->fpga_virtual_base_address + FPGA_BUTTON, &data, ldev)) < 0)
- goto out;
+ if ((retval = button_fpga_read(ldev->fpga_virtual_base_address + FPGA_BUTTON, &data, ldev)) < 0)
+ goto out;
- /* return data for user */
- if (copy_to_user(buff, &data, 2)) {
- printk(KERN_WARNING "read : copy to user data error\n");
- retval = -EFAULT;
- goto out;
- }
+ /* return data for user */
+ if (copy_to_user(buff, &data, 2)) {
+ printk(KERN_WARNING "read : copy to user data error\n");
+ retval = -EFAULT;
+ goto out;
+ }
- *offp = *offp + count;
- retval = 1;
+ *offp = *offp + count;
+ retval = 1;
out:
- PDEBUG("read : Return value %d\n", (int)retval);
- ldev->reading = 0;
+ PDEBUG("read : Return value %d\n", (int)retval);
+ ldev->reading = 0;
- return retval;
+ return retval;
}
int button_open(struct inode *inode, struct file *filp)
{
- /* Allocate and fill any data structure to be put in filp->private_data */
- filp->private_data = container_of(inode->i_cdev, struct button_dev, cdev);
- PDEBUG( "file opened\n");
+ /* Allocate and fill any data structure to be put in filp->private_data */
+ filp->private_data = container_of(inode->i_cdev, struct button_dev, cdev);
+ PDEBUG("file opened\n");
- return 0;
+ return 0;
}
int button_release(struct inode *inode, struct file *filp)
{
- PDEBUG( "released\n");
+ PDEBUG("released\n");
- return 0;
+ return 0;
}
/**********************************
@@ -122,107 +122,106 @@ int button_release(struct inode *inode, struct file *filp)
**********************************/
static int __init button_init(void)
{
- int result;
- int button_major, button_minor;
- u16 data;
- struct button_dev *sdev;
-
- button_major = 252;
- button_minor = 0;
-
- /* Allocate a private structure and reference it as driver's data */
- sdev = (struct button_dev *)kmalloc(sizeof(struct button_dev), GFP_KERNEL);
- if (sdev == NULL) {
- printk(KERN_WARNING "button: unable to allocate private structure\n");
- return -ENOMEM;
- }
-
- /* initiate mutex locked */
- sdev->reading = 0;
- init_MUTEX_LOCKED(&sdev->sem);
-
- /* Get the major and minor device numbers */
- PDEBUG("Get the major and minor device numbers\n");
- if (button_major) {
- devno = MKDEV(button_major, button_minor);
- result = register_chrdev_region(devno, N_DEV,BUTTON_NAME);
- } else {
- result = alloc_chrdev_region(&devno, button_minor, N_DEV, BUTTON_NAME);
- button_major = MAJOR(devno);
- }
- printk(KERN_INFO "button: MAJOR: %d MINOR: %d\n", MAJOR(devno), MINOR(devno));
- if (result < 0) {
- printk(KERN_WARNING "button: can't get major %d\n", button_major);
- }
-
- /* Init the cdev structure */
- PDEBUG("Init the cdev structure\n");
- cdev_init(&sdev->cdev, &button_fops);
- sdev->cdev.owner = THIS_MODULE;
-
- /* Add the device to the kernel, connecting cdev to major/minor number */
- PDEBUG("Add the device to the kernel, connecting cdev to major/minor number\n");
- result = cdev_add(&sdev->cdev, devno, 1);
- if (result < 0)
- printk(KERN_WARNING "button: can't add cdev\n");
-
- /* Requested I/O memory */
- sdev->fpga_virtual_base_address = (void*)IMX_CS1_VIRT;
-
- /* irq unmask */
- data = 1 | ioread16(sdev->fpga_virtual_base_address + FPGA_IRQ_MASK);
- if ((result=button_fpga_write(sdev->fpga_virtual_base_address + FPGA_IRQ_MASK, &data, sdev))<0)
- goto error;
-
- /* irq acknowledge */
- data = 1;
- if ((result=button_fpga_write(sdev->fpga_virtual_base_address + FPGA_IRQ_ACK, &data, sdev))<0)
- goto error;
-
- /* irq registering */
- printk(KERN_INFO "button: fpga irq shared gpioa 1\n");
- if (request_irq(IRQ_GPIOA(1), (irq_handler_t)fpga_interrupt, IRQF_SHARED,BUTTON_IRQ_NAME, sdev)<0) {
- printk(KERN_ERR "Can't request fpga irq\n");
- goto error;
- }
-
-
- /* OK module inserted ! */
- buttondev = sdev;
- printk(KERN_INFO "button module inserted\n");
- return 0;
+ int result;
+ int button_major, button_minor;
+ u16 data;
+ struct button_dev *sdev;
+
+ button_major = 252;
+ button_minor = 0;
+
+ /* Allocate a private structure and reference it as driver's data */
+ sdev = (struct button_dev *)kmalloc(sizeof(struct button_dev), GFP_KERNEL);
+ if (sdev == NULL) {
+ printk(KERN_WARNING "button: unable to allocate private structure\n");
+ return -ENOMEM;
+ }
+
+ /* initiate mutex locked */
+ sdev->reading = 0;
+ init_MUTEX_LOCKED(&sdev->sem);
+
+ /* Get the major and minor device numbers */
+ PDEBUG("Get the major and minor device numbers\n");
+ if (button_major) {
+ devno = MKDEV(button_major, button_minor);
+ result = register_chrdev_region(devno, N_DEV,BUTTON_NAME);
+ } else {
+ result = alloc_chrdev_region(&devno, button_minor, N_DEV, BUTTON_NAME);
+ button_major = MAJOR(devno);
+ }
+ printk(KERN_INFO "button: MAJOR: %d MINOR: %d\n", MAJOR(devno), MINOR(devno));
+ if (result < 0) {
+ printk(KERN_WARNING "button: can't get major %d\n", button_major);
+ }
+
+ /* Init the cdev structure */
+ PDEBUG("Init the cdev structure\n");
+ cdev_init(&sdev->cdev, &button_fops);
+ sdev->cdev.owner = THIS_MODULE;
+
+ /* Add the device to the kernel, connecting cdev to major/minor number */
+ PDEBUG("Add the device to the kernel, connecting cdev to major/minor number\n");
+ result = cdev_add(&sdev->cdev, devno, 1);
+ if (result < 0)
+ printk(KERN_WARNING "button: can't add cdev\n");
+
+ /* Requested I/O memory */
+ sdev->fpga_virtual_base_address = (void*)IMX_CS1_VIRT;
+
+ /* irq unmask */
+ data = 1 | ioread16(sdev->fpga_virtual_base_address + FPGA_IRQ_MASK);
+ if ((result=button_fpga_write(sdev->fpga_virtual_base_address + FPGA_IRQ_MASK, &data, sdev)) < 0)
+ goto error;
+
+ /* irq acknowledge */
+ data = 1;
+ if ((result=button_fpga_write(sdev->fpga_virtual_base_address + FPGA_IRQ_ACK, &data, sdev)) < 0)
+ goto error;
+
+ /* irq registering */
+ printk(KERN_INFO "button: fpga irq shared gpioa 1\n");
+ if (request_irq(IRQ_GPIOA(1), (irq_handler_t)fpga_interrupt, IRQF_SHARED,BUTTON_IRQ_NAME, sdev) < 0) {
+ printk(KERN_ERR "Can't request fpga irq\n");
+ goto error;
+ }
+
+ /* OK driver ready ! */
+ buttondev = sdev;
+ printk(KERN_INFO "button module loaded\n");
+ return 0;
error:
- printk(KERN_ERR "%s: not inserted\n", BUTTON_NAME);
- free_all();
+ printk(KERN_ERR "%s: not loaded\n", BUTTON_NAME);
+ free_all();
- return result;
+ return result;
}
static void __exit button_exit(void)
{
- free_all();
+ free_all();
}
static void free_all(void)
{
- struct button_dev *sdev = buttondev;
+ struct button_dev *sdev = buttondev;
- /* free irq*/
- free_irq(IRQ_GPIOA(1), sdev);
+ /* free irq*/
+ free_irq(IRQ_GPIOA(1), sdev);
- /* delete the cdev structure */
- cdev_del(&sdev->cdev);
+ /* delete the cdev structure */
+ cdev_del(&sdev->cdev);
- /* Free the allocated memory */
- kfree(sdev);
+ /* Free the allocated memory */
+ kfree(sdev);
- /* Release I/O memories */
- release_mem_region(FPGA_BASE_ADDR, FPGA_MEM_SIZE);
+ /* Release I/O memories */
+ release_mem_region(FPGA_BASE_ADDR, FPGA_MEM_SIZE);
- /* free major and minor number */
- unregister_chrdev_region(devno, N_DEV);
- printk(KERN_INFO "button module unloaded\n");
+ /* free major and minor number */
+ unregister_chrdev_region(devno, N_DEV);
+ printk(KERN_INFO "button module unloaded\n");
}
module_init(button_init);
diff --git a/target/linux/modules/fpga/wishbone_example/wb_button/button.h b/target/linux/modules/fpga/wishbone_example/wb_button/button.h
index 5676816..36e03f8 100644
--- a/target/linux/modules/fpga/wishbone_example/wb_button/button.h
+++ b/target/linux/modules/fpga/wishbone_example/wb_button/button.h
@@ -30,22 +30,14 @@
#include <linux/config.h>
#endif
-/* form module/drivers */
#include <linux/init.h>
#include <linux/module.h>
-
-/* for file operations */
+/* for file operations */
#include <linux/fs.h>
#include <linux/cdev.h>
-
-/* copy_to_user function */
-#include <asm/uaccess.h>
-
-/* request_mem_region */
-#include <linux/ioport.h>
-
-/* readw() writew() */
-#include <asm/io.h>
+#include <asm/uaccess.h> /* copy_to_user function */
+#include <linux/ioport.h> /* request_mem_region */
+#include <asm/io.h> /* readw() writew() */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
/* hardware addresses */
@@ -78,7 +70,7 @@
# define PDEBUG(fmt,args...) printk(stderr, fmt, ##args)
# endif
#else
-# define PDEBUG(fmt,args...) /* no debbuging message */
+# define PDEBUG(fmt,args...) /* no debugging message */
#endif
#define BUTTON_NUMBER 1
@@ -88,12 +80,12 @@
/* platform device */
struct plat_button_port{
- const char *name; /*instance name */
- int interrupt_number; /* interrupt_number */
- int num; /* instance number */
- void * membase; /* ioremap base address */
- int idnum; /* identity number */
- int idoffset; /* identity relative address */
- struct button_dev *sdev; /* struct for main device structure*/
+ const char *name; /*instance name */
+ int interrupt_number; /* interrupt_number */
+ int num; /* instance number */
+ void *membase; /* ioremap base address */
+ int idnum; /* identity number */
+ int idoffset; /* identity relative address */
+ struct button_dev *sdev;/* struct for main device structure*/
};
diff --git a/target/linux/modules/fpga/wishbone_example/wb_button/gbutton.c b/target/linux/modules/fpga/wishbone_example/wb_button/gbutton.c
index aadb94d..5ec1e8b 100644
--- a/target/linux/modules/fpga/wishbone_example/wb_button/gbutton.c
+++ b/target/linux/modules/fpga/wishbone_example/wb_button/gbutton.c
@@ -26,22 +26,13 @@
#include <linux/config.h>
#endif
-/* form module/drivers */
#include <linux/init.h>
#include <linux/module.h>
-
-/* for file operations */
-#include <linux/fs.h>
+#include <linux/fs.h> /* for file operations */
#include <linux/cdev.h>
-
-/* copy_to_user function */
-#include <asm/uaccess.h>
-
-/* request_mem_region */
-#include <linux/ioport.h>
-
-/* readw() writew() */
-#include <asm/io.h>
+#include <asm/uaccess.h> /* copy_to_user function */
+#include <linux/ioport.h> /* request_mem_region */
+#include <asm/io.h> /* readw() writew() */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
/* hardware addresses */
@@ -50,7 +41,6 @@
# include <mach/hardware.h>
#endif
-
/* for platform device */
#include <linux/platform_device.h>
@@ -77,13 +67,13 @@
/********************************
* main device structure
* ******************************/
-struct button_dev{
- char *name; /* name of the instance */
- struct cdev cdev; /* char device structure */
- struct semaphore sem; /* mutex */
+struct button_dev {
+ char *name; /* name of the instance */
+ struct cdev cdev; /* char device structure */
+ struct semaphore sem; /* mutex */
void * membase; /* base address for instance */
- dev_t devno; /* to store Major and minor numbers */
- u8 read_in_wait; /* user is waiting for value to read */
+ dev_t devno; /* to store Major and minor numbers */
+ u8 read_in_wait; /* user is waiting for value to read */
};
/***********************************
@@ -92,61 +82,62 @@ struct button_dev{
ssize_t button_read(struct file *fildes, char __user *buff,
size_t count, loff_t *offp)
{
- struct button_dev *ldev = fildes->private_data;
- u16 data=0;
- ssize_t retval = 0;
+ struct button_dev *ldev = fildes->private_data;
+ u16 data=0;
+ ssize_t retval = 0;
- ldev->read_in_wait = 1;
+ ldev->read_in_wait = 1;
- if(*offp + count >= 1) /* Only one word can be read */
- count = 1 - *offp;
+ if (*offp + count >= 1) /* Only one word can be read */
+ count = 1 - *offp;
- if((retval=down_interruptible(&ldev->sem))<0)
- {
- goto out;
- }
+ if ((retval=down_interruptible(&ldev->sem)) < 0) {
+ goto out;
+ }
- data=ioread16(ldev->membase+BUTTON_REG_OFFSET);
- PDEBUG("Read %d at 0x%x\n",data,(unsigned int)ldev->membase+BUTTON_REG_OFFSET);
+ data=ioread16(ldev->membase+BUTTON_REG_OFFSET);
+ PDEBUG("Read %d at 0x%x\n",data,(unsigned int)ldev->membase+BUTTON_REG_OFFSET);
- /* return data for user */
- if(copy_to_user(buff,&data,2)){
- printk(KERN_WARNING "read : copy to user data error\n");
- retval = -EFAULT;
- goto out;
- }
+ /* return data for user */
+ if (copy_to_user(buff, &data, 2)) {
+ printk(KERN_WARNING "read : copy to user data error\n");
+ retval = -EFAULT;
+ goto out;
+ }
- *offp = *offp + count;
- retval = 1;
+ *offp = *offp + count;
+ retval = 1;
out:
- ldev->read_in_wait = 0;
- return retval;
+ ldev->read_in_wait = 0;
+ return retval;
}
-int button_open(struct inode *inode, struct file *filp){
- /* Allocate and fill any data structure to be put in filp->private_data */
- filp->private_data = container_of(inode->i_cdev,struct button_dev, cdev);
- return 0;
+int button_open(struct inode *inode, struct file *filp)
+{
+ /* Allocate and fill any data structure to be put in filp->private_data */
+ filp->private_data = container_of(inode->i_cdev,struct button_dev, cdev);
+
+ return 0;
}
int button_release(struct inode *inode, struct file *filp)
{
- struct button_dev *dev;
+ struct button_dev *dev;
- dev = container_of(inode->i_cdev,struct button_dev,cdev);
- filp->private_data=NULL;
+ dev = container_of(inode->i_cdev, struct button_dev, cdev);
+ filp->private_data=NULL;
- return 0;
+ return 0;
}
static struct file_operations button_fops = {
- .owner = THIS_MODULE,
- .read = button_read,
- .open = button_open,
- .release = button_release,
+ .owner = THIS_MODULE,
+ .read = button_read,
+ .open = button_open,
+ .release = button_release,
};
/**********************************
@@ -154,12 +145,15 @@ static struct file_operations button_fops = {
* awake read process
* ********************************/
-static irqreturn_t button_interrupt(int irq,void *dev_id){
- struct button_dev *ldev = dev_id;
- /* wake up reading process */
- if(ldev->read_in_wait)up(&ldev->sem);
- /* acknowledge irq_mngr */
- return IRQ_HANDLED;
+static irqreturn_t button_interrupt(int irq, void *dev_id)
+{
+ struct button_dev *ldev = dev_id;
+
+ /* wake up reading process */
+ if (ldev->read_in_wait)
+ up(&ldev->sem);
+
+ return IRQ_HANDLED;
}
/**********************************
@@ -169,19 +163,19 @@ static int button_probe(struct platform_device *pdev)
{
struct plat_button_port *dev = pdev->dev.platform_data;
- int result = 0; /* error return */
- int button_major,button_minor;
+ int result = 0; /* error return */
+ int button_major,button_minor;
u16 data;
struct button_dev *sdev;
PDEBUG("Button probing\n");
- PDEBUG("Register %s num %d\n",dev->name,dev->num);
+ PDEBUG("Register %s num %d\n",dev->name,dev->num);
/**************************/
/* check if ID is correct */
/**************************/
data = ioread16(dev->membase+BUTTON_ID_OFFSET);
- if(data != dev->idnum){
+ if (data != dev->idnum) {
result = -1;
printk(KERN_WARNING "For %s id:%d doesn't match "
"with id read %d,\n is device present ?\n",
@@ -193,7 +187,7 @@ static int button_probe(struct platform_device *pdev)
/* allocate memory for sdev structure */
/********************************************/
sdev = kmalloc(sizeof(struct button_dev),GFP_KERNEL);
- if(!sdev){
+ if (!sdev) {
result = -ENOMEM;
goto error_sdev_alloc;
}
@@ -214,11 +208,11 @@ static int button_probe(struct platform_device *pdev)
/* Get the major and minor device numbers */
/******************************************/
- button_major = 251;
- button_minor = dev->num;
+ button_major = 251;
+ button_minor = dev->num;
sdev->devno = MKDEV(button_major, button_minor);
- result = alloc_chrdev_region(&(sdev->devno),button_minor, 1,dev->name);
+ result = alloc_chrdev_region(&(sdev->devno), button_minor, 1,dev->name);
if (result < 0) {
printk(KERN_WARNING "%s: can't get major %d\n",
dev->name,button_major);
@@ -229,64 +223,64 @@ static int button_probe(struct platform_device *pdev)
MAJOR(sdev->devno),
MINOR(sdev->devno));
- /* initiate mutex locked */
- sdev->read_in_wait = 0;
- init_MUTEX_LOCKED(&sdev->sem);
+ /* initiate mutex locked */
+ sdev->read_in_wait = 0;
+ init_MUTEX_LOCKED(&sdev->sem);
/****************************/
- /* Init the cdev structure */
+ /* Init the cdev structure */
/****************************/
- PDEBUG("Init the cdev structure\n");
- cdev_init(&sdev->cdev,&button_fops);
- sdev->cdev.owner = THIS_MODULE;
- sdev->cdev.ops = &button_fops;
+ PDEBUG("Init the cdev structure\n");
+ cdev_init(&sdev->cdev,&button_fops);
+ sdev->cdev.owner = THIS_MODULE;
+ sdev->cdev.ops = &button_fops;
- PDEBUG("%s: Add the device to the kernel, "
+ PDEBUG("%s: Add the device to the kernel, "
"connecting cdev to major/minor number \n",dev->name);
- result = cdev_add(&sdev->cdev,sdev->devno,1);
- if(result < 0){
- printk(KERN_WARNING "%s: can't add cdev\n",dev->name);
- goto error_cdev_add;
- }
-
- /* irq registering */
- result = request_irq(dev->interrupt_number,
- button_interrupt,
- IRQF_SAMPLE_RANDOM,
- sdev->name,
- sdev);
- if(result < 0){
+ result = cdev_add(&sdev->cdev, sdev->devno, 1);
+ if (result < 0) {
+ printk(KERN_WARNING "%s: can't add cdev\n", dev->name);
+ goto error_cdev_add;
+ }
+
+ /* irq registering */
+ result = request_irq(dev->interrupt_number,
+ button_interrupt,
+ IRQF_SAMPLE_RANDOM,
+ sdev->name,
+ sdev);
+ if (result < 0) {
printk(KERN_ERR "Can't register irq %d\n",
dev->interrupt_number);
goto request_irq_error;
}
- printk(KERN_INFO "button: irq registered : %d\n",
- dev->interrupt_number);
+ printk(KERN_INFO "button: irq registered : %d\n",
+ dev->interrupt_number);
- /* OK module inserted ! */
- printk(KERN_INFO "%s insered\n",dev->name);
- return 0;
+ /* OK driver ready ! */
+ printk(KERN_INFO "%s loaded\n", dev->name);
+ return 0;
/*********************/
/* Errors management */
/*********************/
/* freeing irq */
- free_irq(dev->interrupt_number,sdev);
+ free_irq(dev->interrupt_number, sdev);
request_irq_error:
/* delete the cdev structure */
cdev_del(&sdev->cdev);
- PDEBUG("%s:cdev deleted\n",dev->name);
+ PDEBUG("%s:cdev deleted\n", dev->name);
error_cdev_add:
/* free major and minor number */
- unregister_chrdev_region(sdev->devno,1);
- printk(KERN_INFO "%s: Led deleted\n",dev->name);
+ unregister_chrdev_region(sdev->devno, 1);
+ printk(KERN_INFO "%s: Led deleted\n", dev->name);
error_devno:
error_name_copy:
kfree(sdev->name);
error_name_alloc:
kfree(sdev);
error_sdev_alloc:
- printk(KERN_ERR "%s: not inserted\n", dev->name);
+ printk(KERN_ERR "%s: not loaded\n", dev->name);
error_id:
return result;
}
@@ -295,16 +289,17 @@ static int __devexit button_remove(struct platform_device *pdev)
{
struct plat_button_port *dev = pdev->dev.platform_data;
struct button_dev *sdev = (*dev).sdev;
+
/* freeing irq */
- free_irq(dev->interrupt_number,sdev);
+ free_irq(dev->interrupt_number, sdev);
//request_irq_error:
/* delete the cdev structure */
cdev_del(&sdev->cdev);
PDEBUG("%s:cdev deleted\n",dev->name);
//error_cdev_add:
/* free major and minor number */
- unregister_chrdev_region(sdev->devno,1);
- printk(KERN_INFO "%s: Led deleted\n",dev->name);
+ unregister_chrdev_region(sdev->devno, 1);
+ printk(KERN_INFO "%s: Led deleted\n", dev->name);
//error_devno:
//error_name_copy:
kfree(sdev->name);
@@ -319,13 +314,13 @@ static int __devexit button_remove(struct platform_device *pdev)
static struct platform_driver plat_button_driver =
{
- .probe = button_probe,
- .remove = __devexit_p(button_remove),
- .driver =
- {
- .name = "button",
- .owner = THIS_MODULE,
- },
+ .probe = button_probe,
+ .remove = __devexit_p(button_remove),
+ .driver =
+ {
+ .name = "button",
+ .owner = THIS_MODULE,
+ },
};
/**********************************
@@ -333,20 +328,21 @@ static struct platform_driver plat_button_driver =
**********************************/
static int __init button_init(void)
{
- int ret;
-
- PDEBUG("Platform driver name %s",plat_button_driver.driver.name);
- ret = platform_driver_register(&plat_button_driver);
- if (ret) {
- printk(KERN_ERR "Platform driver register error\n");
- return ret;
- }
- return 0;
+ int ret;
+
+ PDEBUG("Platform driver name %s", plat_button_driver.driver.name);
+ ret = platform_driver_register(&plat_button_driver);
+ if (ret) {
+ printk(KERN_ERR "Platform driver register error\n");
+ return ret;
+ }
+
+ return 0;
}
static void __exit button_exit(void)
{
- platform_driver_unregister(&plat_button_driver);
+ platform_driver_unregister(&plat_button_driver);
}
module_init(button_init);
@@ -357,4 +353,3 @@ MODULE_AUTHOR("Fabien Marteau <fab...@ar...> "
"- ARMadeus Systems");
MODULE_DESCRIPTION("button device generic driver");
-
diff --git a/target/test/test_fpga.sh b/target/test/test_fpga.sh
index bf2bcaf..3a7dc1f 100755
--- a/target/test/test_fpga.sh
+++ b/target/test/test_fpga.sh
@@ -14,29 +14,31 @@
source ./test_helpers.sh
source ./test_env.sh
-FPGA_LOAD_DEV="/dev/fpgaloader"
-
load_led_apf9328()
{
- dd if=./data/fpga/blinking_led_apf9328_200k.bit of=$FPGA_LOAD_DEV
+ load_fpga ./data/fpga/blinking_led_apf9328_200k.bit
+ RES=$?
}
load_led_apf27()
{
- echo "I hope you have connected Pins 1 & 39 of J20 (power)"
- dd if=./data/fpga/blinking_led_apf27_200k.bit of=$FPGA_LOAD_DEV
+ ask_user "Please connect pins 1 & 39 of J20 connector (3,3V supply for FPGA bank)\nThen press enter"
+ load_fpga ./data/fpga/blinking_led_apf27_200k.bit
+ RES=$?
}
load_button_apf9328()
{
- dd if=./data/fpga/wishbone_example_apf9328_200k.bit of=$FPGA_LOAD_DEV
+ load_fpga ./data/fpga/wishbone_example_apf9328_200k.bit
+ RES=$?
}
load_button_apf27()
{
- echo "I hope you have connected Pins 1 & 39 of J20 (power)"
- dd if=./data/fpga/wishbone_example_apf27_200k.bit of=$FPGA_LOAD_DEV
+ echo "I hope you have connected pins 1 & 39 of J20"
+ load_fpga ./data/fpga/wishbone_example_apf27_200k.bit
+ RES=$?
}
@@ -44,25 +46,16 @@ test_fpga_load()
{
show_test_banner "FPGA loading"
- modprobe fpgaloader
- RES=$?
- sleep 1
- if [ "$RES" != 0 ] || [ ! -c "$FPGA_LOAD_DEV" ] ; then
- echo "Module failed to load"
- exit_failed
- fi
-
- cat /proc/driver/fpga/loader
-
execute_for_target load_led_apf9328 load_led_apf27
- if [ "$?" == 0 ]; then
- ask_user "Did you see the FPGA's LED blinking ? (y/n)"
+ if [ "$RES" == 0 ]; then
+ ask_user "Did you see the FPGA's LED blinking ? (y/N)"
if [ "$response" == "y" ]; then
echo_test_ok
+ else
+ echo_test_failed
fi
fi
- rm -f $TEST_BITFILE
}
test_fpga_it()
@@ -70,28 +63,32 @@ test_fpga_it()
show_test_banner "FPGA interrupts"
execute_for_target load_button_apf9328 load_button_apf27
- modprobe irq_ocore
- modprobe gbutton
- modprobe board_buttons
+ if [ "$RES" != 0 ]; then
+ exit_failed
+ fi
- if [ "$?" != 0 ] ; then
- echo "Some Modules failed to load"
+ modprobe irq_ocore && modprobe gbutton && modprobe board_buttons
+ DEVICE_NODE=`cat /proc/devices | grep BUTTON | cut -d " " -f 1`
+ if [ "$?" != 0 ] || [ "$DEVICE_NODE" == "" ]; then
+ echo "Some modules failed to load"
exit_failed
fi
- DEVICE_NODE=`cat /proc/devices | grep BUTTON | cut -d " " -f 1`
- mknod /dev/button0 c $DEVICE_NODE 0
+ if [ ! -c /dev/button0 ]; then
+ mknod /dev/button0 c $DEVICE_NODE 0
+ fi
/usr/bin/testsuite/testbutton /dev/button0 &
PID=$!
if [ "$?" == 0 ]; then
- ask_user "Please press FPGA button. Did you see something on the console ? (y/n)"
+ ask_user "Please press FPGA button. Did you see something on the console ? (y/N)"
if [ "$response" == "y" ]; then
echo_test_ok
+ else
+ echo_test_failed
fi
fi
kill $PID
- rm -f $TEST_BITFILE
}
test_fpga_load
diff --git a/target/test/test_helpers.sh b/target/test/test_helpers.sh
index 27e67e4..c5133e5 100644
--- a/target/test/test_helpers.sh
+++ b/target/test/test_helpers.sh
@@ -68,9 +68,14 @@ echo_test_ok()
echo "Test OK !"
}
-exit_failed()
+echo_test_failed()
{
echo "Test FAILED !"
+}
+
+exit_failed()
+{
+ echo_test_failed
exit 1
}
hooks/post-receive
--
armadeus
|