2009-01-22 06:30 AM
Fix: Bug in mass storage demo source code
2011-05-17 04:00 AM
Just want to point out a bug + fix in the mass storage demo source code:
* File Name : um0424\USBLib\demos\Mass_Storage\source\memory.c * Version : V2.2.1 * Date : 09/22/2008 @line 35: WORKS FOR 512 ONLY:u32 Data_Buffer[BULK_MAX_PACKET_SIZE *2]; /* 512 bytes*/
BETTER:u32 Data_Buffer[__MAX_BLOCK_SIZE_OF_ALL_LUNS__/4];
(you should define ''__MAX_BLOCK_SIZE_OF_ALL_LUNS__'' in your ''hw_config.h'') BEST: ... buffer size should be maximum of ''Mass_Block_Size'' of all LUNs---- Explanation: In ''memory.c'' @line 72 you can see that ''MAL_Read'' is called with ''Mass_Block_Size[lun]'' as parameter which is in most cases 512 bytes (OK) BUT if it is bigger (4096 in case of CDROM) then there would be a buffer overrun...MAL_Read( lun ,Offset ,Data_Buffer, Mass_Block_Size[lun] );
Cheers, Maik [ This message was edited by: maik on 22-01-2009 20:16 ] [ This message was edited by: maik on 22-01-2009 20:18 ]