From 0b2894e2eceb2ffa7def33f0912a588b2ac1c195 Mon Sep 17 00:00:00 2001 From: Michael Hohmuth Date: Thu, 24 Mar 2011 16:59:18 +0000 Subject: [PATCH] SD AMSv2: Restore access to the last 0xF000 sectors of internal drive Fixes FS#11965 and FS#12001. Backports r29625, r29637, r29638. Repairs r29169. Thanks to saratoga and funman! git-svn-id: svn://svn.rockbox.org/rockbox/branches/v3_8@29641 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/sd-as3525v2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c index 70d7c8fda1..d7a7d0178e 100644 --- a/firmware/target/arm/as3525/sd-as3525v2.c +++ b/firmware/target/arm/as3525/sd-as3525v2.c @@ -826,6 +826,7 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, int retry_all = 0; int const retry_data_max = 100; /* Generous, methinks */ int retry_data; + unsigned int real_numblocks; mutex_lock(&sd_mtx); #ifndef BOOTLOADER @@ -855,7 +856,13 @@ sd_transfer_retry_with_reinit: goto sd_transfer_error_no_dma; } - if((start+count) > card_info[drive].numblocks) + /* Check the real block size after the card has been initialized */ + real_numblocks = card_info[drive].numblocks; + /* 'start' represents the real (physical) starting sector + * so we must compare it to the real (physical) number of sectors */ + if (drive == INTERNAL_AS3525) + real_numblocks += AMS_OF_SIZE; + if ((start+count) > real_numblocks) { ret = -19; goto sd_transfer_error_no_dma;