Jivin b2112 lays it down ...
> I am using the 2.4 kernel with the Coldfire MCF5275 and I've found an
> issue using the netflash application with programming files above 4meg.  At
> 4megs the following segfault error occurs.

I am guessing you have 128K sectors (* 32 = 4MB),  and you are overflowing
the bitmap (with is only 32 bits).

Try the attached patch (completely untested ;-)

Cheers,
Davidm


> -----------------------------------------------------------------------------------
> Write of 58388 bytes at pos 4194304 (data at 00540000)
> bad frame format: 00000000
> PC: [<040f5e00>]
> SR: 2014  SP: 005a3f4c  a2: f30ba003
> d0: 00000000    d1: 00000061    d2: 000006ff    d3: ffffe703
> d4: 00000004    d5: 00000000    a0: 00448010    a1: 005a2000
> Process netflash (pid: 54, stackpage=005a3000)
> Frame format=5
> Stack from 005a3f80:
>         005745e0 03f30ba0 00000006 03e23dfc 005a3fc4 00047326 005745e0
> 03f30ba0
>         00000006 03e23dfc 00000036 00047128 00000001 00400000 03e20e14
> 03e214f8
>         03e23f14 03e23f14 00023af6 00000004 00000006 03e23dfc 00000001
> 00000000
>         00000006 00000004 00400000 ffffffda 00000036 00000000 40800000
> 003a0e94
> Call Trace:
>         [<00047326>] [<00047128>] [<00023af6>]
> Code: bad frame format: 00000000
> PC: [<00022234>]
> SR: 2714  SP: 005a3ec4  a2: 005a4000
> d0: 00000000    d1: 00000f58    d2: 00000000    d3: 003a0e94
> d4: 005a4000    d5: 00000000    a0: 040f5e00    a1: 00109178
> Process netflash (pid: 54, stackpage=005a3000)
> Frame format=4 Stack from 005a3f00:
>         00000004 00028730 005a3f2c 0002260c 005a3f4c 000e7fd5 005a223c
> 00000036
>         005a3000 f30ba003 e23dfc00 005a3f40 00021f42 000e7d1c 005a3f4c
> 00000000
>         5a3f9000 00023a30 005a3f4c 00000061 000006ff ffffe703 00000004
> 00000000
>         00448010 005a2000 f30ba003 00000000 ffffffff 00000000 54082014
> 040f5e00
>         005745e0 03f30ba0 00000006 03e23dfc 005a3fc4 00047326 005745e0
> 03f30ba0
>         00000006 03e23dfc 00000036 00047128 00000001 00400000 03e20e14
> 03e214f8
> Call Trace:
>         [<00028730>] [<0002260c>] [<000e7fd5>] [<00021f42>]
>         [<000e7d1c>] [<00023a30>] [<00047326>] [<00047128>]
>         [<00023af6>]
> Code: 3030 2a00 2f00 4879 000e 7eb6 4eb9 0002 8730 508f
> SIGSEGV
> ---------------------------------------------------------------------------------------------
> 
> 
> I was able to narrow down the exact function causing the problem in
> /linux-2.4.x/drivers/block/blkmem.c  In general_program_func(), the function
> call to set_bit() is causing the segfault.
> 
> When the function is commented out, the application works fine.  I'm still
> working on the work around for this problem, but if anyone is aware of a
> solution if you could let me know so I can update it.
> 
> int general_program_func(struct inode * inode, struct file * file, struct
> arena_t * a, struct blkmem_program_t * prog)
> {
>   unsigned long i,block;
>   unsigned long erased = 0;
> 
>   /* Mandatory flush of all dirty buffers */
>   fsync_dev(inode->i_rdev);
>   invalidate_buffers(inode->i_rdev);
> 
>   for(i=0;i<prog->blocks;i++) {
>     int min= prog->block[i].pos / a->blksize;
>     int max = (prog->block[i].pos + prog->block[i].length - 1) / a->blksize;
>     for(block=min; block <= max; block++) {
>       if (!test_bit(block, &erased)) {
>                     printk("Erase of sector at pos %lx of arena %d (address
> %p)\n", block * a->blksize, MINOR(inode->i_rdev),
> (void*)(a->address+block*a->blksize));
> 
>         /* Invoke erase function */
>         a->erase_func(a, block * a->blksize);
>         *//set_bit(block, &erased);
> *      }
>     }
> 
>     printk("Write of %lu bytes at pos %lu (data at %p)\n",
> prog->block[i].length, prog->block[i].pos, prog->block[i].data);
> 
>     a->write_func(a, prog->block[i].pos, prog->block[i].length,
> prog->block[i].data);
> 
>     schedule();
>   }
> 
> #ifdef CONFIG_UCLINUX
>   if (prog->reset)
>                 HARD_RESET_NOW();
> #endif
>   return 0;
> }
> 
> Thanks
> Bruce

> _______________________________________________
> uClinux-dev mailing list
> uClinux-dev@uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-dev@uclinux.org
> To unsubscribe see:
> http://mailman.uclinux.org/mailman/options/uclinux-dev

-- 
David McCullough,  david_mccullo...@securecomputing.com,  Ph:+61 734352815
McAfee - SnapGear  http://www.snapgear.com                http://www.uCdot.org
Index: linux-2.4.x/drivers/block/blkmem.c
===================================================================
RCS file: /cvs/sw/linux-2.4.x/drivers/block/blkmem.c,v
retrieving revision 1.61
diff -u -r1.61 blkmem.c
--- linux-2.4.x/drivers/block/blkmem.c	1 Oct 2008 13:16:33 -0000	1.61
+++ linux-2.4.x/drivers/block/blkmem.c	28 May 2009 22:51:18 -0000
@@ -2623,7 +2623,9 @@
 int general_program_func(struct inode * inode, struct file * file, struct arena_t * a, struct blkmem_program_t * prog)
 {
   int i,block;
-  unsigned int erased = 0;
+  unsigned int erased[8]; /* enough for 32MBs of flash */
+
+  memset(erased, 0, sizeof(erased));
 
   /* Mandatory flush of all dirty buffers */
   fsync_dev(inode->i_rdev);
@@ -2633,6 +2635,11 @@
     int min= prog->block[i].pos / a->blksize;
     int max = (prog->block[i].pos + prog->block[i].length - 1) / a->blksize;
     for(block=min; block <= max; block++) {
+      if (block >= sizeof(erased) * 8) {
+        printk("%s,%d: bitmap is too small for this flash (%s blocks)\n"
+            __FILE__, __LINE__, __FUNCTION__, blocks);
+        continue;
+      }
       if (!test_bit(block, &erased)) {
 	printk("Erase of sector at pos %lx of arena %d (address %p)\n", block * a->blksize, MINOR(inode->i_rdev), (void*)(a->address+block*a->blksize));
     
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to