| Index: embios/trunk/target/ipodnano2g/ls.x | 
| — | — | @@ -56,7 +56,7 @@ | 
| 57 | 57 | *(.initbss*) | 
| 58 | 58 | . = ALIGN(0x4); | 
| 59 | 59 | _initstackstart = .; | 
| 60 |  | -        . += 0x4000;
 | 
|  | 60 | +        . += 0x400; | 
| 61 | 61 | _initstackend = .; | 
| 62 | 62 | _initbssend = .; | 
| 63 | 63 | } > INIT | 
| Index: embios/trunk/target/ipodnano2g/config.h | 
| — | — | @@ -27,7 +27,9 @@ | 
| 28 | 28 |  | 
| 29 | 29 | //#define NAND_DEBUG | 
| 30 | 30 | //#define NAND_TRACE | 
|  | 31 | +//#define VFL_DEBUG | 
| 31 | 32 | //#define VFL_TRACE | 
|  | 33 | +//#define FTL_DEBUG | 
| 32 | 34 | //#define FTL_TRACE | 
| 33 | 35 |  | 
| 34 | 36 |  | 
| Index: embios/trunk/target/ipodnano2g/nand.c | 
| — | — | @@ -82,7 +82,7 @@ | 
| 83 | 83 | uint8_t nand_twp[4]; | 
| 84 | 84 | uint8_t nand_tunk2[4]; | 
| 85 | 85 | uint8_t nand_tunk3[4]; | 
| 86 |  | -uint32_t nand_type[4];
 | 
|  | 86 | +int nand_type[4]; | 
| 87 | 87 | int nand_powered = 0; | 
| 88 | 88 | int nand_interleaved = 0; | 
| 89 | 89 | int nand_cached = 0; | 
| — | — | @@ -299,15 +299,15 @@ | 
| 300 | 300 | { | 
| 301 | 301 | mutex_lock(&nand_mtx, TIMEOUT_BLOCK); | 
| 302 | 302 | uint32_t result; | 
| 303 |  | -    if (nand_reset(bank)) return nand_unlock(0xFFFFFFFF);
 | 
| 304 |  | -    if (nand_send_cmd(0x90)) return nand_unlock(0xFFFFFFFF);
 | 
|  | 303 | +    if (nand_reset(bank)) return nand_unlock(0xFFFFFFFE); | 
|  | 304 | +    if (nand_send_cmd(0x90)) return nand_unlock(0xFFFFFFFD); | 
| 305 | 305 | FMANUM = 0; | 
| 306 | 306 | FMADDR0 = 0; | 
| 307 | 307 | FMCTRL1 = FMCTRL1_DOTRANSADDR; | 
| 308 |  | -    if (nand_wait_cmddone()) return nand_unlock(0xFFFFFFFF);
 | 
|  | 308 | +    if (nand_wait_cmddone()) return nand_unlock(0xFFFFFFFC); | 
| 309 | 309 | FMDNUM = 4; | 
| 310 | 310 | FMCTRL1 = FMCTRL1_DOREADDATA; | 
| 311 |  | -    if (nand_wait_addrdone()) return nand_unlock(0xFFFFFFFF);
 | 
|  | 311 | +    if (nand_wait_addrdone()) return nand_unlock(0xFFFFFFFB); | 
| 312 | 312 | result = FMFIFO; | 
| 313 | 313 | FMCTRL1 = FMCTRL1_CLEARRFIFO; | 
| 314 | 314 | return nand_unlock(result); | 
| — | — | @@ -343,14 +343,9 @@ | 
| 344 | 344 | sleep(50000); | 
| 345 | 345 | nand_last_activity_value = USEC_TIMER; | 
| 346 | 346 | for (i = 0; i < 4; i++) | 
| 347 |  | -    {
 | 
| 348 |  | -        if(nand_type[i] != 0xFFFFFFFF)
 | 
| 349 |  | -        {
 | 
| 350 |  | -            if(nand_reset(i))
 | 
| 351 |  | -                
 | 
|  | 347 | +        if (nand_type[i] >= 0) | 
|  | 348 | +            if (nand_reset(i)) | 
| 352 | 349 | panicf(PANIC_FATAL, "nand_power_up: nand_reset(bank=%d) failed.", (unsigned int)i); | 
| 353 |  | -        }
 | 
| 354 |  | -    }
 | 
| 355 | 350 | nand_powered = 1; | 
| 356 | 351 | nand_last_activity_value = USEC_TIMER; | 
| 357 | 352 | mutex_unlock(&nand_mtx); | 
| — | — | @@ -505,7 +500,7 @@ | 
| 506 | 501 | { | 
| 507 | 502 | for (i = 0; i < 4; i++) | 
| 508 | 503 | { | 
| 509 |  | -            if (nand_type[i] == 0xFFFFFFFF) continue;
 | 
|  | 504 | +            if (nand_type[i] < 0) continue; | 
| 510 | 505 | void* databuf = (void*)0; | 
| 511 | 506 | void* sparebuf = (void*)0; | 
| 512 | 507 | if (databuffer) databuf = (void*)((uint32_t)databuffer + 0x800 * i); | 
| — | — | @@ -522,7 +517,7 @@ | 
| 523 | 518 | nand_last_activity_value = USEC_TIMER; | 
| 524 | 519 | if (!nand_powered) nand_power_up(); | 
| 525 | 520 | uint8_t status[4]; | 
| 526 |  | -    for (i = 0; i < 4; i++) status[i] = (nand_type[i] == 0xFFFFFFFF);
 | 
|  | 521 | +    for (i = 0; i < 4; i++) status[i] = (nand_type[i] < 0); | 
| 527 | 522 | for (i = 0; i < 4; i++) | 
| 528 | 523 | { | 
| 529 | 524 | if (!status[i]) | 
| — | — | @@ -616,7 +611,7 @@ | 
| 617 | 612 | + 0x40 * (i - 1))) << 1; | 
| 618 | 613 | } | 
| 619 | 614 | for (i = 0; i < 4; i++) | 
| 620 |  | -        if (nand_type[i] != 0xFFFFFFFF)
 | 
|  | 615 | +        if (nand_type[i] < 0) | 
| 621 | 616 | rc |= status[i] << (i << 2); | 
| 622 | 617 | return nand_unlock(rc); | 
| 623 | 618 | } | 
| — | — | @@ -671,7 +666,7 @@ | 
| 672 | 667 | if (!nand_powered) nand_power_up(); | 
| 673 | 668 | for (i = 0; i < 4; i++) | 
| 674 | 669 | { | 
| 675 |  | -        if (nand_type[i] == 0xFFFFFFFF) continue;
 | 
|  | 670 | +        if (nand_type[i] < 0) continue; | 
| 676 | 671 | nand_set_fmctrl0(i, 0); | 
| 677 | 672 | if (nand_send_cmd(NAND_CMD_BLOCKERASE)) | 
| 678 | 673 | { | 
| — | — | @@ -690,7 +685,7 @@ | 
| 691 | 686 | } | 
| 692 | 687 | for (i = 0; i < 4; i++) | 
| 693 | 688 | { | 
| 694 |  | -        if (nand_type[i] == 0xFFFFFFFF) continue;
 | 
|  | 689 | +        if (nand_type[i] < 0) continue; | 
| 695 | 690 | if (rc & (1 << i)) continue; | 
| 696 | 691 | if (nand_wait_status_ready(i)) rc |= 1 << i; | 
| 697 | 692 | } | 
| — | — | @@ -699,7 +694,7 @@ | 
| 700 | 695 |  | 
| 701 | 696 | const struct nand_device_info_type* nand_get_device_type(uint32_t bank) | 
| 702 | 697 | { | 
| 703 |  | -    if (nand_type[bank] == 0xFFFFFFFF)
 | 
|  | 698 | +    if (nand_type[bank] < 0) | 
| 704 | 699 | return (struct nand_device_info_type*)0; | 
| 705 | 700 | return &nand_deviceinfotable[nand_type[bank]]; | 
| 706 | 701 | } | 
| — | — | @@ -714,7 +709,7 @@ | 
| 715 | 710 | } | 
| 716 | 711 | } | 
| 717 | 712 |  | 
| 718 |  | -uint32_t nand_device_init(void)
 | 
|  | 713 | +int nand_device_init(void) | 
| 719 | 714 | { | 
| 720 | 715 | mutex_init(&nand_mtx); | 
| 721 | 716 | wakeup_init(&nand_wakeup); | 
| — | — | @@ -726,7 +721,7 @@ | 
| 727 | 722 |  | 
| 728 | 723 | /* Assume there are 0 banks, to prevent | 
| 729 | 724 | nand_power_up from talking with them yet. */ | 
| 730 |  | -    for(i = 0; i < 4; i++) nand_type[i] = 0xFFFFFFFF;
 | 
|  | 725 | +    for (i = 0; i < 4; i++) nand_type[i] = -1; | 
| 731 | 726 | nand_power_up(); | 
| 732 | 727 |  | 
| 733 | 728 | /* Now that the flash is powered on, detect how | 
| — | — | @@ -738,7 +733,11 @@ | 
| 739 | 734 | nand_tunk2[i] = 7; | 
| 740 | 735 | nand_tunk3[i] = 7; | 
| 741 | 736 | type = nand_get_chip_type(i); | 
| 742 |  | -        if (type == 0xFFFFFFFF) continue;
 | 
|  | 737 | +        if (type >= 0xFFFFFFF0) | 
|  | 738 | +        { | 
|  | 739 | +            nand_type[i] = (int)type; | 
|  | 740 | +            continue; | 
|  | 741 | +        } | 
| 743 | 742 | for (j = 0; ; j++) | 
| 744 | 743 | { | 
| 745 | 744 | if (j == ARRAYLEN(nand_deviceinfotable)) break; | 
| — | — | @@ -753,7 +752,7 @@ | 
| 754 | 753 | nand_tunk2[i] = nand_deviceinfotable[nand_type[i]].tunk2; | 
| 755 | 754 | nand_tunk3[i] = nand_deviceinfotable[nand_type[i]].tunk3; | 
| 756 | 755 | } | 
| 757 |  | -    if (nand_type[0] == 0xFFFFFFFF) return 1;
 | 
|  | 756 | +    if (nand_type[0] < 0) return nand_type[0]; | 
| 758 | 757 | nand_interleaved = ((nand_type[0] >> 22) & 1); | 
| 759 | 758 | nand_cached = ((nand_type[0] >> 23) & 1); | 
| 760 | 759 |  | 
| Index: embios/trunk/target/ipodnano2g/ftl.c | 
| — | — | @@ -576,7 +576,7 @@ | 
| 577 | 577 | retries until it works or all available pages have been tried */ | 
| 578 | 578 | uint32_t ftl_vfl_commit_cxt(uint32_t bank) | 
| 579 | 579 | { | 
| 580 |  | -    DEBUGF("FTL: VFL: Committing context on bank %d\n", bank);
 | 
|  | 580 | +    DEBUGF("FTL: VFL: Committing context on bank %d", bank); | 
| 581 | 581 | if (ftl_vfl_cxt[bank].nextcxtpage + 8 <= ftl_nand_type->pagesperblock) | 
| 582 | 582 | if (ftl_vfl_store_cxt(bank) == 0) return 0; | 
| 583 | 583 | uint32_t current = ftl_vfl_cxt[bank].activecxtblock; | 
| — | — | @@ -595,7 +595,7 @@ | 
| 596 | 596 | ftl_vfl_cxt[bank].nextcxtpage = 0; | 
| 597 | 597 | if (ftl_vfl_store_cxt(bank) == 0) return 0; | 
| 598 | 598 | } | 
| 599 |  | -    panicf(PANIC_FATAL, "VFL: Failed to commit VFL CXT!\n");
 | 
|  | 599 | +    panicf(PANIC_FATAL, "VFL: Failed to commit VFL CXT!"); | 
| 600 | 600 | return 1; | 
| 601 | 601 | } | 
| 602 | 602 | #endif | 
| — | — | @@ -679,7 +679,7 @@ | 
| 680 | 680 | for (spareindex = 0; spareindex < spareused; spareindex++) | 
| 681 | 681 | if (ftl_vfl_cxt[bank].remaptable[spareindex] == block) | 
| 682 | 682 | { | 
| 683 |  | -            DEBUGF("FTL: VFL: Following remapped block: %d => %d\n",
 | 
|  | 683 | +            DEBUGF("FTL: VFL: Following remapped block: %d => %d", | 
| 684 | 684 | block, ftl_vfl_cxt[bank].firstspare + spareindex); | 
| 685 | 685 | return ftl_vfl_cxt[bank].firstspare + spareindex; | 
| 686 | 686 | } | 
| — | — | @@ -822,7 +822,7 @@ | 
| 823 | 823 | uint32_t checkempty, uint32_t remaponfail) | 
| 824 | 824 | { | 
| 825 | 825 | #ifdef VFL_TRACE | 
| 826 |  | -    DEBUGF("FTL: VFL: Reading page %d\n", vpage);
 | 
|  | 826 | +    DEBUGF("FTL: VFL: Reading page %d", vpage); | 
| 827 | 827 | #endif | 
| 828 | 828 |  | 
| 829 | 829 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | 
| — | — | @@ -854,7 +854,7 @@ | 
| 855 | 855 | #else | 
| 856 | 856 | if (remaponfail == 1 &&(ret & 0x11D) != 0 && (ret & 2) == 0) | 
| 857 | 857 | { | 
| 858 |  | -            DEBUGF("FTL: VFL: Scheduling vBlock %d for remapping!\n", block);
 | 
|  | 858 | +            DEBUGF("FTL: VFL: Scheduling vBlock %d for remapping!", block); | 
| 859 | 859 | ftl_vfl_schedule_block_for_remap(bank, block); | 
| 860 | 860 | } | 
| 861 | 861 | #endif | 
| — | — | @@ -870,7 +870,7 @@ | 
| 871 | 871 | uint32_t checkempty, uint32_t remaponfail) | 
| 872 | 872 | { | 
| 873 | 873 | #ifdef VFL_TRACE | 
| 874 |  | -    DEBUGF("FTL: VFL: Fast reading page %d on all banks\n", vpage);
 | 
|  | 874 | +    DEBUGF("FTL: VFL: Fast reading page %d on all banks", vpage); | 
| 875 | 875 | #endif | 
| 876 | 876 |  | 
| 877 | 877 | uint32_t i, rc = 0; | 
| — | — | @@ -947,7 +947,7 @@ | 
| 948 | 948 | { | 
| 949 | 949 | uint32_t i, j; | 
| 950 | 950 | #ifdef VFL_TRACE | 
| 951 |  | -    DEBUGF("FTL: VFL: Writing page %d\n", vpage);
 | 
|  | 951 | +    DEBUGF("FTL: VFL: Writing page %d", vpage); | 
| 952 | 952 | #endif | 
| 953 | 953 |  | 
| 954 | 954 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | 
| — | — | @@ -1139,7 +1139,7 @@ | 
| 1140 | 1140 | return 1; | 
| 1141 | 1141 | } | 
| 1142 | 1142 |  | 
| 1143 |  | -    DEBUGF("FTL: Found FTL context block: vBlock %d\n", ftlcxtblock);
 | 
|  | 1143 | +    DEBUGF("FTL: Found FTL context block: vBlock %d", ftlcxtblock); | 
| 1144 | 1144 | uint32_t ftlcxtfound = 0; | 
| 1145 | 1145 | for (i = ftl_nand_type->pagesperblock * ftl_banks - 1; i > 0; i--) | 
| 1146 | 1146 | { | 
| — | — | @@ -1155,9 +1155,9 @@ | 
| 1156 | 1156 | else | 
| 1157 | 1157 | { | 
| 1158 | 1158 | /* This will trip if there was an unclean unmount before. */ | 
| 1159 |  | -            DEBUGF("FTL: Unclean shutdown before!\n");
 | 
|  | 1159 | +            DEBUGF("FTL: Unclean shutdown before!"); | 
| 1160 | 1160 | #ifdef FTL_FORCEMOUNT | 
| 1161 |  | -            DEBUGF("FTL: Forcing mount nevertheless...\n");
 | 
|  | 1161 | +            DEBUGF("FTL: Forcing mount nevertheless..."); | 
| 1162 | 1162 | #else | 
| 1163 | 1163 | break; | 
| 1164 | 1164 | #endif | 
| — | — | @@ -1170,7 +1170,7 @@ | 
| 1171 | 1171 | return 1; | 
| 1172 | 1172 | } | 
| 1173 | 1173 |  | 
| 1174 |  | -    DEBUGF("FTL: Successfully read FTL context block\n");
 | 
|  | 1174 | +    DEBUGF("FTL: Successfully read FTL context block"); | 
| 1175 | 1175 | uint32_t pagestoread = ftl_nand_type->userblocks >> 10; | 
| 1176 | 1176 | if ((ftl_nand_type->userblocks & 0x1FF) != 0) pagestoread++; | 
| 1177 | 1177 |  | 
| — | — | @@ -1232,28 +1232,28 @@ | 
| 1233 | 1233 | uint8_t bbtentry = ftl_bbt[i][j]; | 
| 1234 | 1234 | for (k = 0; k < 8; k++) if ((bbtentry & (1 << k)) == 0) badblocks++; | 
| 1235 | 1235 | } | 
| 1236 |  | -        DEBUGF("FTL: BBT for bank %d: %d bad blocks\n", i, badblocks);
 | 
|  | 1236 | +        DEBUGF("FTL: BBT for bank %d: %d bad blocks", i, badblocks); | 
| 1237 | 1237 | badblocks = 0; | 
| 1238 | 1238 | #endif | 
| 1239 | 1239 | for (j = 0; j < ftl_vfl_cxt[i].sparecount; j++) | 
| 1240 | 1240 | if (ftl_vfl_cxt[i].remaptable[j] == 0xFFFF) badblocks++; | 
| 1241 |  | -        DEBUGF("FTL: VFL: Bank %d: %d of %d spare blocks are bad\n",
 | 
|  | 1241 | +        DEBUGF("FTL: VFL: Bank %d: %d of %d spare blocks are bad", | 
| 1242 | 1242 | i, badblocks, ftl_vfl_cxt[i].sparecount); | 
| 1243 |  | -        DEBUGF("FTL: VFL: Bank %d: %d blocks remapped\n",
 | 
|  | 1243 | +        DEBUGF("FTL: VFL: Bank %d: %d blocks remapped", | 
| 1244 | 1244 | i, ftl_vfl_cxt[i].spareused); | 
| 1245 |  | -        DEBUGF("FTL: VFL: Bank %d: %d blocks scheduled for remapping\n",
 | 
|  | 1245 | +        DEBUGF("FTL: VFL: Bank %d: %d blocks scheduled for remapping", | 
| 1246 | 1246 | i, 0x334 - ftl_vfl_cxt[i].scheduledstart); | 
| 1247 | 1247 | } | 
| 1248 | 1248 | #ifndef FTL_READONLY | 
| 1249 | 1249 | uint32_t min = 0xFFFFFFFF, max = 0, total = 0; | 
| 1250 |  | -    for (i = 0; i < (*ftl_nand_type).userBlocks + 23; i++)
 | 
|  | 1250 | +    for (i = 0; i < (*ftl_nand_type).userblocks + 23; i++) | 
| 1251 | 1251 | { | 
| 1252 | 1252 | if (ftl_erasectr[i] > max) max = ftl_erasectr[i]; | 
| 1253 | 1253 | if (ftl_erasectr[i] < min) min = ftl_erasectr[i]; | 
| 1254 | 1254 | total += ftl_erasectr[i]; | 
| 1255 | 1255 | } | 
| 1256 |  | -    DEBUGF("FTL: Erase counters: Minimum: %d, maximum %d, average: %d, total: %d\n",
 | 
| 1257 |  | -           min, max, total / ((*ftl_nand_type).userBlocks + 23), total);
 | 
|  | 1256 | +    DEBUGF("FTL: Erase counters: Minimum: %d, maximum %d, average: %d, total: %d", | 
|  | 1257 | +           min, max, total / ((*ftl_nand_type).userblocks + 23), total); | 
| 1258 | 1258 | #endif | 
| 1259 | 1259 | #endif | 
| 1260 | 1260 |  | 
| — | — | @@ -1284,12 +1284,12 @@ | 
| 1285 | 1285 | uint32_t error = 0; | 
| 1286 | 1286 |  | 
| 1287 | 1287 | #ifdef FTL_TRACE | 
| 1288 |  | -    DEBUGF("FTL: Reading %d sectors starting at %d\n", count, sector);
 | 
|  | 1288 | +    DEBUGF("FTL: Reading %d sectors starting at %d", count, sector); | 
| 1289 | 1289 | #endif | 
| 1290 | 1290 |  | 
| 1291 | 1291 | if (sector + count > ftl_nand_type->userblocks * ppb) | 
| 1292 | 1292 | { | 
| 1293 |  | -        DEBUGF("FTL: Sector %d is out of range!\n", sector + count - 1);
 | 
|  | 1293 | +        DEBUGF("FTL: Sector %d is out of range!", sector + count - 1); | 
| 1294 | 1294 | return 1; | 
| 1295 | 1295 | } | 
| 1296 | 1296 | if (count == 0) return 0; | 
| — | — | @@ -1307,13 +1307,13 @@ | 
| 1308 | 1308 | if (logentry != (struct ftl_log_type*)0) | 
| 1309 | 1309 | { | 
| 1310 | 1310 | #ifdef FTL_TRACE | 
| 1311 |  | -	        DEBUGF("FTL: Block %d has a log entry\n", block);
 | 
|  | 1311 | +	        DEBUGF("FTL: Block %d has a log entry", block); | 
| 1312 | 1312 | #endif | 
| 1313 | 1313 | if (logentry->scatteredvblock != 0xFFFF | 
| 1314 | 1314 | && logentry->pageoffsets[page] != 0xFFFF) | 
| 1315 | 1315 | { | 
| 1316 | 1316 | #ifdef FTL_TRACE | 
| 1317 |  | -   		     DEBUGF("FTL: Found page %d at block %d, page %d\n", page,
 | 
|  | 1317 | +   		     DEBUGF("FTL: Found page %d at block %d, page %d", page, | 
| 1318 | 1318 | (*logentry).scatteredvblock, (*logentry).pageoffsets[page]); | 
| 1319 | 1319 | #endif | 
| 1320 | 1320 | abspage = logentry->scatteredvblock * ppb | 
| — | — | @@ -1336,7 +1336,7 @@ | 
| 1337 | 1337 | memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800); | 
| 1338 | 1338 | else if ((ret & (0xd << (j << 2))) || ftl_sparebuffer[j].user.eccmark != 0xFF) | 
| 1339 | 1339 | { | 
| 1340 |  | -		            DEBUGF("FTL: Error while reading sector %d!\n", (sector + i));
 | 
|  | 1340 | +		            DEBUGF("FTL: Error while reading sector %d!", (sector + i)); | 
| 1341 | 1341 | error = 1; | 
| 1342 | 1342 | memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800); | 
| 1343 | 1343 | } | 
| — | — | @@ -1349,7 +1349,7 @@ | 
| 1350 | 1350 | if (ret & 2) memset(&((uint8_t*)buffer)[i << 11], 0, 0x800); | 
| 1351 | 1351 | else if ((ret & 0x11D) != 0 || ftl_sparebuffer[0].user.eccmark != 0xFF) | 
| 1352 | 1352 | { | 
| 1353 |  | -	            DEBUGF("FTL: Error while reading sector %d!\n", (sector + i));
 | 
|  | 1353 | +	            DEBUGF("FTL: Error while reading sector %d!", (sector + i)); | 
| 1354 | 1354 | error = 1; | 
| 1355 | 1355 | memset(&((uint8_t*)buffer)[i << 11], 0, 0x800); | 
| 1356 | 1356 | } | 
| — | — | @@ -1523,7 +1523,7 @@ | 
| 1524 | 1524 | if (newblock == 0xFFFFFFFF) return 1; | 
| 1525 | 1525 | ftl_cxt.ftlctrlblocks[i] = newblock; | 
| 1526 | 1526 | ftl_cxt.ftlctrlpage = newblock * ppb; | 
| 1527 |  | -    DEBUGF("Starting new FTL control block at %d\n", ftl_cxt.ftlctrlpage);
 | 
|  | 1527 | +    DEBUGF("Starting new FTL control block at %d", ftl_cxt.ftlctrlpage); | 
| 1528 | 1528 | uint32_t pagestoread = (ftl_nand_type->userblocks + 23) >> 10; | 
| 1529 | 1529 | if (((ftl_nand_type->userblocks + 23) & 0x1FF) != 0) pagestoread++; | 
| 1530 | 1530 | for (i = 0; i < pagestoread; i++) | 
| — | — | @@ -1855,7 +1855,7 @@ | 
| 1856 | 1856 | uint32_t mappages = (ftl_nand_type->userblocks + 0x3ff) >> 10; | 
| 1857 | 1857 | uint32_t ctrpages = (ftl_nand_type->userblocks + 23 + 0x3ff) >> 10; | 
| 1858 | 1858 | uint32_t endpage = ftl_cxt.ftlctrlpage + mappages + ctrpages + 1; | 
| 1859 |  | -    DEBUGF("FTL: Committing context\n");
 | 
|  | 1859 | +    DEBUGF("FTL: Committing context"); | 
| 1860 | 1860 | if (endpage >= (ftl_cxt.ftlctrlpage / ppb + 1) * ppb) | 
| 1861 | 1861 | ftl_cxt.ftlctrlpage |= ppb - 1; | 
| 1862 | 1862 | for (i = 0; i < ctrpages; i++) | 
| — | — | @@ -1882,7 +1882,7 @@ | 
| 1883 | 1883 | ftl_sparebuffer[0].meta.type = 0x43; | 
| 1884 | 1884 | if (ftl_vfl_write(ftl_cxt.ftlctrlpage, 1, &ftl_cxt, &ftl_sparebuffer[0]) != 0) | 
| 1885 | 1885 | return 1; | 
| 1886 |  | -    DEBUGF("FTL: Wrote context to page %d\n", ftl_cxt.ftlctrlpage);
 | 
|  | 1886 | +    DEBUGF("FTL: Wrote context to page %d", ftl_cxt.ftlctrlpage); | 
| 1887 | 1887 | return 0; | 
| 1888 | 1888 | } | 
| 1889 | 1889 | #endif | 
| — | — | @@ -1939,12 +1939,12 @@ | 
| 1940 | 1940 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | 
| 1941 | 1941 |  | 
| 1942 | 1942 | #ifdef FTL_TRACE | 
| 1943 |  | -    DEBUGF("FTL: Writing %d sectors starting at %d\n", count, sector);
 | 
|  | 1943 | +    DEBUGF("FTL: Writing %d sectors starting at %d", count, sector); | 
| 1944 | 1944 | #endif | 
| 1945 | 1945 |  | 
| 1946 | 1946 | if (sector + count > ftl_nand_type->userblocks * ppb) | 
| 1947 | 1947 | { | 
| 1948 |  | -        DEBUGF("FTL: Sector %d is out of range!\n", sector + count - 1);
 | 
|  | 1948 | +        DEBUGF("FTL: Sector %d is out of range!", sector + count - 1); | 
| 1949 | 1949 | return 1; | 
| 1950 | 1950 | } | 
| 1951 | 1951 | if (count == 0) return 0; | 
| — | — | @@ -1955,7 +1955,7 @@ | 
| 1956 | 1956 | { | 
| 1957 | 1957 | for (i = 0; i < 3; i++) | 
| 1958 | 1958 | { | 
| 1959 |  | -		    DEBUGF("FTL: Marking dirty, try %d\n", i);
 | 
|  | 1959 | +		    DEBUGF("FTL: Marking dirty, try %d", i); | 
| 1960 | 1960 | if (ftl_next_ctrl_pool_page() != 0) | 
| 1961 | 1961 | { | 
| 1962 | 1962 | mutex_unlock(&ftl_mtx); | 
| — | — | @@ -1974,7 +1974,7 @@ | 
| 1975 | 1975 | mutex_unlock(&ftl_mtx); | 
| 1976 | 1976 | return 1; | 
| 1977 | 1977 | } | 
| 1978 |  | -    	DEBUGF("FTL: Wrote dirty mark to %d\n", ftl_cxt.ftlctrlpage);
 | 
|  | 1978 | +    	DEBUGF("FTL: Wrote dirty mark to %d", ftl_cxt.ftlctrlpage); | 
| 1979 | 1979 | ftl_cxt.clean_flag = 0; | 
| 1980 | 1980 | } | 
| 1981 | 1981 |  | 
| — | — | @@ -1992,7 +1992,7 @@ | 
| 1993 | 1993 | if (page == 0 && count - i >= ppb) | 
| 1994 | 1994 | { | 
| 1995 | 1995 | #ifdef FTL_TRACE | 
| 1996 |  | -		    DEBUGF("FTL: Going to write a full hyperblock in one shot\n");
 | 
|  | 1996 | +		    DEBUGF("FTL: Going to write a full hyperblock in one shot"); | 
| 1997 | 1997 | #endif | 
| 1998 | 1998 | uint32_t vblock = logentry->scatteredvblock; | 
| 1999 | 1999 | logentry->scatteredvblock = 0xFFFF; | 
| — | — | @@ -1999,7 +1999,7 @@ | 
| 2000 | 2000 | if (logentry->pagesused != 0) | 
| 2001 | 2001 | { | 
| 2002 | 2002 | #ifdef FTL_TRACE | 
| 2003 |  | -    			DEBUGF("FTL: Scattered block had some pages already used, committing\n");
 | 
|  | 2003 | +    			DEBUGF("FTL: Scattered block had some pages already used, committing"); | 
| 2004 | 2004 | #endif | 
| 2005 | 2005 | ftl_release_pool_block(vblock); | 
| 2006 | 2006 | vblock = ftl_allocate_pool_block(); | 
| — | — | @@ -2041,7 +2041,7 @@ | 
| 2042 | 2042 | if (logentry->pagesused == ppb) | 
| 2043 | 2043 | { | 
| 2044 | 2044 | #ifdef FTL_TRACE | 
| 2045 |  | -    			DEBUGF("FTL: Scattered block is full, committing\n");
 | 
|  | 2045 | +    			DEBUGF("FTL: Scattered block is full, committing"); | 
| 2046 | 2046 | #endif | 
| 2047 | 2047 | ftl_remove_scattered_block(logentry); | 
| 2048 | 2048 | logentry = ftl_allocate_log_entry(block); | 
| — | — | @@ -2119,7 +2119,7 @@ | 
| 2120 | 2120 | if (ftl_cxt.clean_flag == 1) return 0; | 
| 2121 | 2121 |  | 
| 2122 | 2122 | #ifdef FTL_TRACE | 
| 2123 |  | -    DEBUGF("FTL: Syncing\n");
 | 
|  | 2123 | +    DEBUGF("FTL: Syncing"); | 
| 2124 | 2124 | #endif | 
| 2125 | 2125 |  | 
| 2126 | 2126 | if (ftl_cxt.swapcounter >= 20) | 
| — | — | @@ -2165,8 +2165,9 @@ | 
| 2166 | 2166 | uint32_t i; | 
| 2167 | 2167 | uint32_t result = 0; | 
| 2168 | 2168 | uint32_t foundsignature, founddevinfo, blockwiped, repaired, skip; | 
| 2169 |  | -    if (nand_device_init() != 0) //return 1;
 | 
| 2170 |  | -        panicf(PANIC_FATAL, "FTL: Lowlevel NAND driver init failed!");
 | 
|  | 2169 | +    int rc; | 
|  | 2170 | +    if ((rc = nand_device_init()) != 0) //return 1; | 
|  | 2171 | +        panicf(PANIC_FATAL, "FTL: Lowlevel NAND driver init failed: %d", rc); | 
| 2171 | 2172 | ftl_banks = 0; | 
| 2172 | 2173 | for (i = 0; i < 4; i++) | 
| 2173 | 2174 | if (nand_get_device_type(i) != 0) ftl_banks = i + 1; | 
| Index: embios/trunk/target/ipodnano2g/nand.h | 
| — | — | @@ -56,7 +56,7 @@ | 
| 57 | 57 |  | 
| 58 | 58 | const struct nand_device_info_type* nand_get_device_type(uint32_t bank); | 
| 59 | 59 | uint32_t nand_reset(uint32_t bank); | 
| 60 |  | -uint32_t nand_device_init(void);
 | 
|  | 60 | +int nand_device_init(void); | 
| 61 | 61 | void nand_set_active(void); | 
| 62 | 62 | long nand_last_activity(void); | 
| 63 | 63 | void nand_power_up(void); |