[uClinux-dev] problem with netflash

2009-05-28 Thread b2112
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.
---
Write of 58388 bytes at pos 4194304 (data at 0054)
bad frame format: 
PC: [040f5e00]
SR: 2014  SP: 005a3f4c  a2: f30ba003
d0: d1: 0061d2: 06ffd3: e703
d4: 0004d5: a0: 00448010a1: 005a2000
Process netflash (pid: 54, stackpage=005a3000)
Frame format=5
Stack from 005a3f80:
005745e0 03f30ba0 0006 03e23dfc 005a3fc4 00047326 005745e0
03f30ba0
0006 03e23dfc 0036 00047128 0001 0040 03e20e14
03e214f8
03e23f14 03e23f14 00023af6 0004 0006 03e23dfc 0001

0006 0004 0040 ffda 0036  4080
003a0e94
Call Trace:
[00047326] [00047128] [00023af6]
Code: bad frame format: 
PC: [00022234]
SR: 2714  SP: 005a3ec4  a2: 005a4000
d0: d1: 0f58d2: d3: 003a0e94
d4: 005a4000d5: a0: 040f5e00a1: 00109178
Process netflash (pid: 54, stackpage=005a3000)
Frame format=4 Stack from 005a3f00:
0004 00028730 005a3f2c 0002260c 005a3f4c 000e7fd5 005a223c
0036
005a3000 f30ba003 e23dfc00 005a3f40 00021f42 000e7d1c 005a3f4c

5a3f9000 00023a30 005a3f4c 0061 06ff e703 0004

00448010 005a2000 f30ba003    54082014
040f5e00
005745e0 03f30ba0 0006 03e23dfc 005a3fc4 00047326 005745e0
03f30ba0
0006 03e23dfc 0036 00047128 0001 0040 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;iprog-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

Re: [uClinux-dev] problem with netflash

2009-05-28 Thread David McCullough

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 0054)
 bad frame format: 
 PC: [040f5e00]
 SR: 2014  SP: 005a3f4c  a2: f30ba003
 d0: d1: 0061d2: 06ffd3: e703
 d4: 0004d5: a0: 00448010a1: 005a2000
 Process netflash (pid: 54, stackpage=005a3000)
 Frame format=5
 Stack from 005a3f80:
 005745e0 03f30ba0 0006 03e23dfc 005a3fc4 00047326 005745e0
 03f30ba0
 0006 03e23dfc 0036 00047128 0001 0040 03e20e14
 03e214f8
 03e23f14 03e23f14 00023af6 0004 0006 03e23dfc 0001
 
 0006 0004 0040 ffda 0036  4080
 003a0e94
 Call Trace:
 [00047326] [00047128] [00023af6]
 Code: bad frame format: 
 PC: [00022234]
 SR: 2714  SP: 005a3ec4  a2: 005a4000
 d0: d1: 0f58d2: d3: 003a0e94
 d4: 005a4000d5: a0: 040f5e00a1: 00109178
 Process netflash (pid: 54, stackpage=005a3000)
 Frame format=4 Stack from 005a3f00:
 0004 00028730 005a3f2c 0002260c 005a3f4c 000e7fd5 005a223c
 0036
 005a3000 f30ba003 e23dfc00 005a3f40 00021f42 000e7d1c 005a3f4c
 
 5a3f9000 00023a30 005a3f4c 0061 06ff e703 0004
 
 00448010 005a2000 f30ba003    54082014
 040f5e00
 005745e0 03f30ba0 0006 03e23dfc 005a3fc4 00047326 005745e0
 03f30ba0
 0006 03e23dfc 0036 00047128 0001 0040 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;iprog-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.comhttp://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 -	1.61
+++ linux-2.4.x/drivers/block/blkmem.c	28 May 2009 22:51:18 -
@@ -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