From da94b6303ea75f2b7b8e0b08fb9a96c730c894a4 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Fri, 3 Jan 2014 23:55:39 +0100 Subject: Make fat test tool build again, and make its sector size configurable. Change-Id: Icfe7c4bb880c2f10918a7809f0f1f1c3838f6f48 --- firmware/test/fat/Makefile | 5 +++-- firmware/test/fat/ata-sim.c | 10 ++++------ firmware/test/fat/main.c | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/firmware/test/fat/Makefile b/firmware/test/fat/Makefile index 77c299dfca..38bce0bde1 100644 --- a/firmware/test/fat/Makefile +++ b/firmware/test/fat/Makefile @@ -1,3 +1,4 @@ +SECTOR_SIZE = 512 FIRMWARE = ../.. DRIVERS = ../../drivers @@ -7,8 +8,8 @@ BUILDDATE=$(shell date -u +'-DYEAR=%Y -DMONTH=%m -DDAY=%d') INCLUDE = -I$(EXPORT) -I$(FIRMWARE)/include -I$(FIRMWARE)/target/hosted -I$(FIRMWARE)/target/hosted/sdl DEFINES = -DTEST_FAT -DDEBUG -DDISK_WRITE -DHAVE_FAT16SUPPORT -D__PCTOOL__ -CFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) $(BUILDDATE) -I. $(INCLUDE) -I$(FIRMWARE)/libc/include -SIMFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE) +CFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) $(BUILDDATE) -I. $(INCLUDE) -I$(FIRMWARE)/libc/include -DROCKBOX_DIR='".rockbox"' -DSECTOR_SIZE=$(SECTOR_SIZE) +SIMFLAGS = -g -Wall -std=gnu99 -Wno-pointer-sign $(DEFINES) -I. $(INCLUDE) -DSECTOR_SIZE=$(SECTOR_SIZE) TARGET = fat diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c index 98fd5adc28..07b772f433 100644 --- a/firmware/test/fat/ata-sim.c +++ b/firmware/test/fat/ata-sim.c @@ -3,8 +3,6 @@ #include #include "debug.h" -#define BLOCK_SIZE 512 - static FILE* file; void panicf( const char *fmt, ... ); @@ -17,11 +15,11 @@ int storage_read_sectors(unsigned long start, int count, void* buf) else DEBUGF("[Reading block 0x%lx]\n", start); - if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { + if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) { perror("fseek"); return -1; } - if(!fread(buf,BLOCK_SIZE,count,file)) { + if(!fread(buf,SECTOR_SIZE,count,file)) { DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf ); perror("fread"); panicf("Disk error\n"); @@ -40,11 +38,11 @@ int storage_write_sectors(unsigned long start, int count, void* buf) if (start == 0) panicf("Writing on sector 0!\n"); - if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { + if(fseek(file,start*SECTOR_SIZE,SEEK_SET)) { perror("fseek"); return -1; } - if(!fwrite(buf,BLOCK_SIZE,count,file)) { + if(!fwrite(buf,SECTOR_SIZE,count,file)) { DEBUGF("ata_write_sectors(0x%lx, 0x%x, %p)\n", start, count, buf ); perror("fwrite"); panicf("Disk error\n"); diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c index 96a95a8b2a..e838682b0b 100644 --- a/firmware/test/fat/main.c +++ b/firmware/test/fat/main.c @@ -49,11 +49,11 @@ void ldebugf(const char* file, int line, const char *fmt, ...) void dbg_dump_sector(int sec) { - unsigned char buf[512]; + unsigned char buf[SECTOR_SIZE]; storage_read_sectors(sec,1,buf); DEBUGF("---< Sector %d >-----------------------------------------\n", sec); - dbg_dump_buffer(buf, 512, 0); + dbg_dump_buffer(buf, SECTOR_SIZE, 0); } void dbg_dump_buffer(unsigned char *buf, int len, int offset) @@ -427,7 +427,7 @@ void dbg_tail(char* name) return; DEBUGF("Got file descriptor %d\n",fd); - rc = lseek(fd,-512,SEEK_END); + rc = lseek(fd,-SECTOR_SIZE,SEEK_END); if ( rc >= 0 ) { rc = read(fd, buf, SECTOR_SIZE); if( rc > 0 ) -- cgit