This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Another problem with JFFS2


Hi
I have a problem with JFFS2. If I mount an empty filesystem I got this messages:


<5>jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x2003
instead
<5>jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000004: 0x000c
instead
<5>jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000008: 0xdc6d
instead
...


I found that the JFFS2 filesystem writes wrong erased block markers to the flash. I think it is a compiler problem in erase.c. The values (JFFS2_MAGIC_BITMASK, JFFS2_NODETYPE_CLEANMARKER,..) will not be copied to the marker structure. In the assembly you can see that the marker structure starts at fp-54 but the magic bitmask will be written to fp-68.

I use the gcc 3.2.2 ( xscale platform).


static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{
...
jeb->free_size = c->sector_size;
jeb->used_size = 0;
jeb->dirty_size = 0;
jeb->wasted_size = 0;
} else {
struct jffs2_unknown_node marker = {
.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),


404: e3a03a02 mov r3, #8192 ; 0x2000
408: e2833003 add r3, r3, #3 ; 0x3
40c: e3a00000 mov r0, #0 ; 0x0
410: e50b0040 str r0, [fp, -#64]
414: e14b33be strh r3, [fp, -#62]
418: e14b34b0 strh r3, [fp, -#64]
.totlen = cpu_to_je32(c->cleanmarker_size)
41c: e51b3040 ldr r3, [fp, -#64]
420: e597203c ldr r2, [r7, #60]
424: e24b4034 sub r4, fp, #52 ; 0x34 <- Address of 'marker'in r4 (fp - 54)
428: e50b3034 str r3, [fp, -#52]
42c: e3a03d66 mov r3, #6528 ; 0x1980
430: e2833005 add r3, r3, #5 ; 0x5
434: e50b202c str r2, [fp, -#44]
438: e50b2030 str r2, [fp, -#48]
43c: e50b2038 str r2, [fp, -#56]
440: e50b203c str r2, [fp, -#60]
};


marker.hdr_crc = cpu_to_je32(crc32(0, &marker, je32_to_cpu(marker.totlen) - 4));
444: e1a01004 mov r1, r4 <- Address of 'marker' in r1
448: e2422004 sub r2, r2, #4 ; 0x4
44c: e14b34b4 strh r3, [fp, -#68] <- JFFS2_MAGIC_BITMASK to 'marker' (fp - 68)
450: ebfffffe bl 0 <jffs2_erase_block>


ret = jffs2_flash_write(c, jeb->offset, je32_to_cpu(marker.totlen), &retlen, (char *)&marker);
454: e598100c ldr r1, [r8, #12]
458: e1a0c000 mov ip, r0
45c: e24b3048 sub r3, fp, #72 ; 0x48
460: e51b2030 ldr r2, [fp, -#48]
464: e1a00007 mov r0, r7
468: e50bc02c str ip, [fp, -#44]
46c: e58d4000 str r4, [sp]
470: e50bc03c str ip, [fp, -#60]
474: e50bc038 str ip, [fp, -#56]
478: ebfffffe bl 0 <jffs2_erase_block>
if (ret) {


...
}

If I change

       struct jffs2_unknown_node marker = {
           .magic =    cpu_to_je16(JFFS2_MAGIC_BITMASK),
           .nodetype =    cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
           .totlen =    cpu_to_je32(c->cleanmarker_size)
       };

to

       struct jffs2_unknown_node marker;
       marker.magic =    cpu_to_je16(JFFS2_MAGIC_BITMASK);
       marker.nodetype =    cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
       marker.totlen =    cpu_to_je32(c->cleanmarker_size);

all is works fine.

static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{
...
struct jffs2_unknown_node marker;
marker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
marker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
marker.totlen = cpu_to_je32(c->cleanmarker_size);
404: e597303c ldr r3, [r7, #60]


//
marker.hdr_crc = cpu_to_je32(crc32(0, &marker, je32_to_cpu(marker.totlen) - 4));
408: e24b4034 sub r4, fp, #52 ; 0x34 <- Address of 'marker'in r4 (fp -52)
40c: e3a0cd66 mov ip, #6528 ; 0x1980
410: e50b3030 str r3, [fp, -#48]
414: e51b2030 ldr r2, [fp, -#48]
418: e50b3040 str r3, [fp, -#64]
41c: e50b303c str r3, [fp, -#60]
420: e3a03a02 mov r3, #8192 ; 0x2000
424: e2833003 add r3, r3, #3 ; 0x3
428: e28cc005 add ip, ip, #5 ; 0x5
42c: e2422004 sub r2, r2, #4 ; 0x4
430: e1a01004 mov r1, r4
434: e3a00000 mov r0, #0 ; 0x0
438: e14bc3b4 strh ip, [fp, -#52] <- JFFS2_MAGIC_BITMASK (fp - 52)
43c: e14b33b2 strh r3, [fp, -#50]
440: e14b33b8 strh r3, [fp, -#56]
444: ebfffffe bl 0 <jffs2_erase_block>


ret = jffs2_flash_write(c, jeb->offset, je32_to_cpu(marker.totlen), &retlen, (char *)&marker);
448: e598100c ldr r1, [r8, #12]
44c: e1a0c000 mov ip, r0
450: e24b3044 sub r3, fp, #68 ; 0x44
454: e51b2030 ldr r2, [fp, -#48]
458: e1a00007 mov r0, r7
45c: e50bc02c str ip, [fp, -#44]
460: e58d4000 str r4, [sp]
464: e50bc03c str ip, [fp, -#60]
468: e50bc040 str ip, [fp, -#64]
46c: ebfffffe bl 0 <jffs2_erase_block>
...
}



Regards, Knud Wöhler




-- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]