Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/harmn1/iphonelinux
Browse files Browse the repository at this point in the history
Also, the NAND chip settings are now current for 2.2. If anyone else has problems, I'll look in an even newer iBoot.
  • Loading branch information
planetbeing committed Mar 9, 2010
2 parents bd639e4 + ddc88ea commit 13d3901
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 18 deletions.
2 changes: 1 addition & 1 deletion openiboot/ftl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ int ftl_read(void* buffer, uint64_t offset, int size) {
return FALSE;
}

int read = ((Data->bytesPerPage > toRead) ? toRead : Data->bytesPerPage);
int read = (((Data->bytesPerPage-pageOffset) > toRead) ? toRead : Data->bytesPerPage-pageOffset);
memcpy(curLoc, tBuffer + pageOffset, read);
curLoc += read;
toRead -= read;
Expand Down
10 changes: 5 additions & 5 deletions openiboot/hfs/rawfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int allocate(RawFile* rawFile, off_t size) {
}

/* zero out allocated block */
ASSERT(WRITE(volume->image, curBlock * volume->volumeHeader->blockSize, volume->volumeHeader->blockSize, zeros), "WRITE");
ASSERT(WRITE(volume->image, ((uint64_t)curBlock) * volume->volumeHeader->blockSize, volume->volumeHeader->blockSize, zeros), "WRITE");

setBlockUsed(volume, curBlock, TRUE);
volume->volumeHeader->freeBlocks--;
Expand Down Expand Up @@ -195,12 +195,12 @@ static int rawFileRead(io_func* io,off_t location, size_t size, void *buffer) {
possible = extent->blockCount * blockSize - locationInBlock;

if(size > possible) {
ASSERT(READ(volume->image, extent->startBlock * blockSize + locationInBlock, possible, buffer), "READ");
ASSERT(READ(volume->image, ((uint64_t)extent->startBlock) * blockSize + locationInBlock, possible, buffer), "READ");
size -= possible;
buffer = (void*)(((size_t)buffer) + possible);
extent = extent->next;
} else {
ASSERT(READ(volume->image, extent->startBlock * blockSize + locationInBlock, size, buffer), "READ");
ASSERT(READ(volume->image, ((uint64_t)extent->startBlock) * blockSize + locationInBlock, size, buffer), "READ");
break;
}

Expand Down Expand Up @@ -251,12 +251,12 @@ static int rawFileWrite(io_func* io,off_t location, size_t size, void *buffer) {
possible = extent->blockCount * blockSize - locationInBlock;

if(size > possible) {
ASSERT(WRITE(volume->image, extent->startBlock * blockSize + locationInBlock, possible, buffer), "WRITE");
ASSERT(WRITE(volume->image, ((uint64_t)extent->startBlock) * blockSize + locationInBlock, possible, buffer), "WRITE");
size -= possible;
buffer = (void*)(((size_t)buffer) + possible);
extent = extent->next;
} else {
ASSERT(WRITE(volume->image, extent->startBlock * blockSize + locationInBlock, size, buffer), "WRITE");
ASSERT(WRITE(volume->image, ((uint64_t)extent->startBlock) * blockSize + locationInBlock, size, buffer), "WRITE");
break;
}

Expand Down
26 changes: 14 additions & 12 deletions openiboot/nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ static uint8_t* aTemporarySBuf;
#define SECTOR_SIZE 512

static const NANDDeviceType SupportedDevices[] = {
{0x2555D5EC, 8192, 0x80, 4, 64, 4, 2, 4, 2, 7744, 4, 6},
{0xB614D5EC, 4096, 0x80, 8, 128, 4, 2, 4, 2, 3872, 4, 6},
{0xB655D7EC, 8192, 0x80, 8, 128, 4, 2, 4, 2, 7744, 4, 6},
{0xA514D3AD, 4096, 0x80, 4, 64, 4, 2, 4, 2, 3872, 4, 6},
{0xA555D5AD, 8192, 0x80, 4, 64, 4, 2, 4, 2, 7744, 4, 6},
{0xA585D598, 8320, 0x80, 4, 64, 6, 2, 4, 2, 7744, 4, 6},
{0xBA94D598, 4096, 0x80, 8, 216, 6, 2, 4, 2, 3872, 8, 8},
{0xBA95D798, 8192, 0x80, 8, 216, 6, 2, 4, 2, 7744, 8, 8},
{0x3ED5D789, 8192, 0x80, 8, 216, 4, 2, 4, 2, 7744, 8, 8},
{0x3E94D589, 4096, 0x80, 8, 216, 4, 2, 4, 2, 3872, 8, 8},
{0x3ED5D72C, 8192, 0x80, 8, 216, 4, 2, 4, 2, 7744, 8, 8},
{0x3E94D52C, 4096, 0x80, 8, 216, 4, 2, 4, 2, 3872, 8, 8},
{0x2555D5EC, 8192, 128, 4, 64, 4, 2, 4, 2, 7744, 4, 6},
{0xB614D5EC, 4096, 128, 8, 128, 4, 2, 4, 2, 3872, 4, 6},
{0xB655D7EC, 8192, 128, 8, 128, 4, 2, 4, 2, 7744, 4, 6},
{0xA514D3AD, 4096, 128, 4, 64, 4, 2, 4, 2, 3872, 4, 6},
{0xA555D5AD, 8192, 128, 4, 64, 4, 2, 4, 2, 7744, 4, 6},
{0xB614D5AD, 4096, 128, 8, 128, 4, 2, 4, 2, 3872, 4, 6},
{0xB655D7AD, 8192, 128, 8, 128, 4, 2, 4, 2, 7744, 4, 6},
{0xA585D598, 8320, 128, 4, 64, 6, 2, 4, 2, 7744, 4, 6},
{0xBA94D598, 4096, 128, 8, 216, 6, 2, 4, 2, 3872, 8, 8},
{0xBA95D798, 8192, 128, 8, 216, 6, 2, 4, 2, 7744, 8, 8},
{0x3ED5D789, 8192, 128, 8, 216, 4, 2, 4, 2, 7744, 8, 8},
{0x3E94D589, 4096, 128, 8, 216, 4, 2, 4, 2, 3872, 8, 8},
{0x3ED5D72C, 8192, 128, 8, 216, 4, 2, 4, 2, 7744, 8, 8},
{0x3E94D52C, 4096, 128, 8, 216, 4, 2, 4, 2, 3872, 8, 8},
{0}
};

Expand Down
50 changes: 50 additions & 0 deletions tools/dumpnandinfo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

typedef struct NANDDeviceType {
uint32_t id;
uint16_t blocksPerBank;
uint16_t pagesPerBlock;
uint16_t sectorsPerPage;
uint16_t bytesPerSpare;
uint8_t WPPulseTime;
uint8_t WEHighHoldTime;
uint8_t NANDSetting3;
uint8_t NANDSetting4;
uint32_t userSubBlksTotal;
uint32_t ecc1;
uint32_t ecc2;
} NANDDeviceType;

int main(int argc, char* argv[])
{
if(argc < 3)
{
printf("Spit out a struct openiboot can use to configure NAND parameters from the similar table in iBoot.\n\n");
printf("Usage: %s <decrypted iboot file> <offset>\n", argv[0]);
return 0;
}

printf("static const NANDDeviceType SupportedDevices[] = {\n");
uint32_t offset = strtol(argv[2], NULL, 0);
FILE* f = fopen(argv[1], "rb");

fseek(f, offset, SEEK_SET);
while(1)
{
NANDDeviceType entry;
fread(&entry, 1, sizeof(entry), f);
if(entry.id == 0)
break;

printf("\t{0x%X, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d},\n",
entry.id, entry.blocksPerBank, entry.pagesPerBlock, entry.sectorsPerPage, entry.bytesPerSpare,
entry.WPPulseTime, entry.WEHighHoldTime, entry.NANDSetting3, entry.NANDSetting4,
entry.userSubBlksTotal, entry.ecc1, entry.ecc2);
}

printf("\t{0}\n};\n");

fclose(f);
}

0 comments on commit 13d3901

Please sign in to comment.