[BUG] file system

Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

[BUG] file system

 · 
Posted: 01.10.2018 - 14:45  ·  #1
Das Lesen einer Datei über Blockread bricht bei mir nach 24477696 gelesenen Bytes ab.
Die Funktion liefert ein false zurück, obwohl die Datei noch nicht komplett gelesen wurde.
Kann das jemand bestätigen?

Gruß
Thomas

Ausgabe Terminalprogramm

Code

size of Alarm1.wav = 38400124<r><n>
calculate crc of Alarm1.wav<r><n>
file system io error while calculating CRC<r><n>
block count = 47808<r><n>
byte count old = 512<r><n>
byte count = 0<r><n>


Testcode

Code

program calcCRC;

Device = xmega128A4U, VCC = 3.3; // only USB version supports crc module

define_fuses
  Override_Fuses;
  NoteBook   = A;
  COMport    = USB;
  FuseBits1  = [WDPER0, WDPER2]; // watchdog = 8s
  FuseBits4  = [WDLOCK];
  FuseBits5  = [BODACT0, BODLEVEL0, BODLEVEL1, BODLEVEL2]; // BOD = 3V
  ProgFuses  = true;

Import SysTick, SerportE0, FAT16_32, XMega_CRC;
From SysTick Import SystemTime16;
From System Import longword;

define
  OSCtype         = extXTAL = 4096000, PLLmul = 15, prescA = 2, prescB = 1, prescC = 1;
  SysTick         = 10;
  StackSize       = 256, iData;
  FrameSize       = 384, iData;
  SerPortE0       = 115200, Stop1;  // debug connection
  FAT16           = SPI_D, PortD.4, iData; // SPI_X, SS-Port, SS-PIN, data area
  F16_FileHandles = 4;
  F16_DirLevels   = 2;
  F16_MMCspeed    = superfast; // standard, slow, fast, superfast  (fat32)
  F16_StrLen      = 80; // buffer for Writeln to files

uses UFAT16_32;

implementation

const
  BLOCKSIZE : word = 512;

type
  tFileBuffer = array[0..BLOCKSIZE-1] of byte;

var
  {$IDATA}
  fileforCRC              : file of byte;
  filebuffer              : tFileBuffer;

{------------------------------------------------------------------------------}
function calculateCRC : boolean;
var
  fname : TFileName;
  blockCount : longWord;
  fSize : longword;
  byteCount_old : word;
  byteCount : word;
  fsStatus : boolean;
begin
  fname := 'Alarm1.wav';

  if F16_FileSize('', fname, fSize) then
    Writeln(SeroutE0, 'size of ' + fname + ' = ' + LongToStr(fSize));
  else
    Writeln(SeroutE0, 'F16_fileSize failed');
  endif;
  
  Writeln(SeroutE0, 'calculate crc of ' + fname);

  if not F16_FileAssign(fileforCRC, '', fname) then
    Writeln(SeroutE0, 'open ' + fname + ' failed');
    return(false);
  endif;

  if not F16_FileReset(fileforCRC) then
    Writeln(SeroutE0, 'file reset failed');
    F16_FileClose(fileforCRC);
    return(false);
  endif;

  // calculate crc
  blockCount := 0;
  while not F16_EndOfFile(fileforCRC) do
    ASM: WDR;
    fsStatus := F16_BlockRead(fileforCRC, @filebuffer, Sizeof(filebuffer), byteCount); // long timeout
    if fsStatus = false then
      // file system io error
      F16_FileClose(fileforCRC);
      Writeln(SeroutE0, 'file system io error while calculating CRC');
      Writeln(SeroutE0, 'block count = ' + LongToStr(blockCount));
      Writeln(SeroutE0, 'byte count old = ' + IntToStr(byteCount_old));
      Writeln(SeroutE0, 'byte count = ' + IntToStr(byteCount));
      return(false);
    else
      inc(blockCount);
     // add bytes to crc calculation
    endif;
    byteCount_old := byteCount;
  endwhile;
  
  F16_FileClose(fileforCRC);
  return(true);
end;

//------------------------------------------------------------------------------
// main
begin
  loop
    ASM: WDR;
    while not F16_DiskInit do
      Writeln(SeroutE0, 'disk init failed');
      mDelay(1000);
    endwhile;
    if not F16_DiskReset then
      Writeln(SeroutE0, 'disk failed');
    else
      calculateCRC;
    endif;
  endloop;
end.

rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: [BUG] file system

 · 
Posted: 01.10.2018 - 15:23  ·  #2
Hallo Thomas,
das sieht irgendwie nach einer Grenze von 2^31 aus, longword.
Möglicherweise ein Limit im Filesystem?
rolf
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: [BUG] file system

 · 
Posted: 01.10.2018 - 16:16  ·  #3
Hallo Rolf
Die Testdatei ist 36,6 MB.
Das sollte für longword kein Problem sein
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: [BUG] file system

 · 
Posted: 01.10.2018 - 16:21  ·  #4
stimmt, ich habe mich da um ein paar stellen vertan :-(
Aber ich habe da momentan keine Idee
rolf
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: [BUG] file system

 · 
Posted: 12.10.2018 - 20:53  ·  #5
Quote

Blockread bricht bei mir nach 24477696 gelesenen Bytes ab


Nachtrag: Die genaue Position hängt vom Zustand des Dateisystems auf der SD Karte ab (Fragmentierung). Der Fehler tritt bei FAT16 sowie auch FAT32 formatierten Karten auf. Wenn der Fehler auftritt, dann immer an der selben Position.
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   96   110 · Page-Gen-Time: 0.021476s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI