Index: trunk/kernel/vfs/fatfs.c
===================================================================
--- trunk/kernel/vfs/fatfs.c	(revision 23)
+++ trunk/kernel/vfs/fatfs.c	(revision 50)
@@ -36,11 +36,12 @@
 #include <fatfs.h>
 
+
 //////////////////////////////////////////////////////////////////////////////////////////
 //          Extern  variables         
 //////////////////////////////////////////////////////////////////////////////////////////
 
-extern vfs_ctx_t        fs_context[FS_TYPES_NR];   // allocated in vfs.c file
-
-extern remote_barrier_t global_barrier;            // allocated dans kernel_init.c
+extern vfs_ctx_t          fs_context[FS_TYPES_NR];   // allocated in vfs.c file
+
+extern remote_barrier_t   global_barrier;            // allocated in kernel_init.c
  
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -297,36 +298,75 @@
                         xptr_t        root_inode_xp )
 {
-    error_t  error;
-    uint8_t  buffer[512];    // buffer for boot record
-
-    // make a synchronous access to IOC device to read the boot record from device
+    error_t     error;
+    uint8_t   * buffer;
+    kmem_req_t  req;
+
+    // allocate a 512 bytes buffer to store the boot record
+	req.type    = KMEM_512_BYTES;
+    req.flags   = AF_KERNEL | AF_ZERO;
+	buffer      = (uint8_t *)kmem_alloc( &req );
+     
+    fatfs_dmsg("\n[INFO] %s : enters with buffer = %x\n", 
+               __FUNCTION__ , (intptr_t)buffer );
+
+    // load the boot record from device
+    // using a synchronous access to IOC device  
     error = dev_ioc_sync_read( buffer , 0 , 1 );
-    assert( (error == 0) , __FUNCTION__ , "cannot access FAT boot record" );
+
+    assert( (error == 0) , __FUNCTION__ , "cannot access boot record" );
+
+#if CONFIG_FAT_DEBUG
+    uint32_t   line;
+    uint32_t   byte = 0;
+    printk("\n*** boot record at cycle %d ***\n", hal_time_stamp() );
+    for ( line = 0 ; line < 32 ; line++ )
+    {
+        printk(" %X | %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x |\n",
+               byte,
+               buffer[byte+ 0],buffer[byte+ 1],buffer[byte+ 2],buffer[byte+ 3],
+               buffer[byte+ 4],buffer[byte+ 5],buffer[byte+ 6],buffer[byte+ 7],
+               buffer[byte+ 8],buffer[byte+ 9],buffer[byte+10],buffer[byte+11],
+               buffer[byte+12],buffer[byte+13],buffer[byte+14],buffer[byte+15] );
+
+         byte += 16;
+    }
+#endif
 
     // check sector size from boot record
     uint32_t sector_size = get_record_from_buffer( BPB_BYTSPERSEC , buffer , 1 );
+
     assert( (sector_size == 512) , __FUNCTION__ , "sector size must be 512 bytes" );
 
     // check cluster size from boot record
     uint32_t nb_sectors = get_record_from_buffer( BPB_SECPERCLUS , buffer , 1 );
+
     assert( (nb_sectors == 8) , __FUNCTION__ , "cluster size must be 8 sectors" );
 
     // check number of FAT copies from boot record
     uint32_t nb_fats = get_record_from_buffer( BPB_NUMFATS , buffer , 1 );
+
     assert( (nb_fats == 1) , __FUNCTION__ , "number of FAT copies must be 1" );
 
     // get & check number of sectors in FAT from boot record
     uint32_t fat_sectors = get_record_from_buffer( BPB_FAT32_FATSZ32 , buffer , 1 );
+
     assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ , "FAT not multiple of 16 sectors");
 
     // get and check root cluster from boot record
     uint32_t root_cluster = get_record_from_buffer( BPB_FAT32_ROOTCLUS , buffer , 1 );
+
     assert( (root_cluster == 2) , __FUNCTION__ , "Root cluster index must be  2");
 
     // get FAT lba from boot record
     uint32_t fat_lba = get_record_from_buffer( BPB_RSVDSECCNT , buffer , 1 );
-    
+
+    // release the 512 bytes buffer
+    req.type = KMEM_512_BYTES;
+    req.ptr  = buffer;
+    kmem_free( &req );
+
     // allocate a mapper for the FAT itself
     mapper_t * fat_mapper = mapper_create();
+
     assert( (fat_mapper != NULL) , __FUNCTION__ , "no memory for FAT mapper" );
 
@@ -342,4 +382,18 @@
     fatfs_ctx->fat_mapper_xp         = XPTR( local_cxy , fat_mapper );
 
+    fatfs_dmsg("\n*** FAT context ***\n" 
+               "- fat_sectors     = %d\n"
+               "- sector size     = %d\n"
+               "- cluster size    = %d\n"
+               "- fat_first_lba   = %d\n"
+               "- data_first_lba  = %d\n"
+               "- mapper          = %l\n",
+               fatfs_ctx->fat_sectors_count,
+               fatfs_ctx->bytes_per_sector,
+               fatfs_ctx->bytes_per_cluster,
+               fatfs_ctx->fat_begin_lba,
+               fatfs_ctx->cluster_begin_lba,
+               fatfs_ctx->fat_mapper_xp );
+
     // initialize the VFS context
     vfs_ctx->type    = FS_TYPE_FATFS;
