Skip to content
This repository
Browse code

Merge branch 'master' of git://github.com/harmn1/iphonelinux

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...
commit 13d390104a5ca069ea5dfad86aef81cb869854d1 2 parents bd639e4 + ddc88ea
planetbeing authored March 08, 2010
2  openiboot/ftl.c
@@ -1021,7 +1021,7 @@ int ftl_read(void* buffer, uint64_t offset, int size) {
1021 1021
 			return FALSE;
1022 1022
 		}
1023 1023
 
1024  
-		int read = ((Data->bytesPerPage > toRead) ? toRead : Data->bytesPerPage);
  1024
+		int read = (((Data->bytesPerPage-pageOffset) > toRead) ? toRead : Data->bytesPerPage-pageOffset);
1025 1025
 		memcpy(curLoc, tBuffer + pageOffset, read);
1026 1026
 		curLoc += read;
1027 1027
 		toRead -= read;
10  openiboot/hfs/rawfile.c
@@ -86,7 +86,7 @@ int allocate(RawFile* rawFile, off_t size) {
86 86
 				}
87 87
 
88 88
 				/* zero out allocated block */
89  
-				ASSERT(WRITE(volume->image, curBlock * volume->volumeHeader->blockSize, volume->volumeHeader->blockSize, zeros), "WRITE");
  89
+				ASSERT(WRITE(volume->image, ((uint64_t)curBlock) * volume->volumeHeader->blockSize, volume->volumeHeader->blockSize, zeros), "WRITE");
90 90
 
91 91
 				setBlockUsed(volume, curBlock, TRUE);
92 92
 				volume->volumeHeader->freeBlocks--;
@@ -195,12 +195,12 @@ static int rawFileRead(io_func* io,off_t location, size_t size, void *buffer) {
195 195
 		possible = extent->blockCount * blockSize - locationInBlock;
196 196
 
197 197
 		if(size > possible) {
198  
-			ASSERT(READ(volume->image, extent->startBlock * blockSize + locationInBlock, possible, buffer), "READ");
  198
+			ASSERT(READ(volume->image, ((uint64_t)extent->startBlock) * blockSize + locationInBlock, possible, buffer), "READ");
199 199
 			size -= possible;
200 200
 			buffer = (void*)(((size_t)buffer) + possible);
201 201
 			extent = extent->next;
202 202
 		} else {
203  
-			ASSERT(READ(volume->image, extent->startBlock * blockSize + locationInBlock, size, buffer), "READ");
  203
+			ASSERT(READ(volume->image, ((uint64_t)extent->startBlock) * blockSize + locationInBlock, size, buffer), "READ");
204 204
 			break;
205 205
 		}
206 206
 
@@ -251,12 +251,12 @@ static int rawFileWrite(io_func* io,off_t location, size_t size, void *buffer) {
251 251
 		possible = extent->blockCount * blockSize - locationInBlock;
252 252
 
253 253
 		if(size > possible) {
254  
-			ASSERT(WRITE(volume->image, extent->startBlock * blockSize + locationInBlock, possible, buffer), "WRITE");
  254
+			ASSERT(WRITE(volume->image, ((uint64_t)extent->startBlock) * blockSize + locationInBlock, possible, buffer), "WRITE");
255 255
 			size -= possible;
256 256
 			buffer = (void*)(((size_t)buffer) + possible);
257 257
 			extent = extent->next;
258 258
 		} else {
259  
-			ASSERT(WRITE(volume->image, extent->startBlock * blockSize + locationInBlock, size, buffer), "WRITE");
  259
+			ASSERT(WRITE(volume->image, ((uint64_t)extent->startBlock) * blockSize + locationInBlock, size, buffer), "WRITE");
260 260
 			break;
261 261
 		}
262 262
 
26  openiboot/nand.c
@@ -32,18 +32,20 @@ static uint8_t* aTemporarySBuf;
32 32
 #define SECTOR_SIZE 512
33 33
 
34 34
 static const NANDDeviceType SupportedDevices[] = {
35  
-	{0x2555D5EC, 8192, 0x80, 4, 64, 4, 2, 4, 2, 7744, 4, 6},
36  
-	{0xB614D5EC, 4096, 0x80, 8, 128, 4, 2, 4, 2, 3872, 4, 6},
37  
-	{0xB655D7EC, 8192, 0x80, 8, 128, 4, 2, 4, 2, 7744, 4, 6},
38  
-	{0xA514D3AD, 4096, 0x80, 4, 64, 4, 2, 4, 2, 3872, 4, 6},
39  
-	{0xA555D5AD, 8192, 0x80, 4, 64, 4, 2, 4, 2, 7744, 4, 6},
40  
-	{0xA585D598, 8320, 0x80, 4, 64, 6, 2, 4, 2, 7744, 4, 6},
41  
-	{0xBA94D598, 4096, 0x80, 8, 216, 6, 2, 4, 2, 3872, 8, 8},
42  
-	{0xBA95D798, 8192, 0x80, 8, 216, 6, 2, 4, 2, 7744, 8, 8},
43  
-	{0x3ED5D789, 8192, 0x80, 8, 216, 4, 2, 4, 2, 7744, 8, 8},
44  
-	{0x3E94D589, 4096, 0x80, 8, 216, 4, 2, 4, 2, 3872, 8, 8},
45  
-	{0x3ED5D72C, 8192, 0x80, 8, 216, 4, 2, 4, 2, 7744, 8, 8},
46  
-	{0x3E94D52C, 4096, 0x80, 8, 216, 4, 2, 4, 2, 3872, 8, 8},
  35
+	{0x2555D5EC, 8192, 128, 4, 64, 4, 2, 4, 2, 7744, 4, 6},
  36
+	{0xB614D5EC, 4096, 128, 8, 128, 4, 2, 4, 2, 3872, 4, 6},
  37
+	{0xB655D7EC, 8192, 128, 8, 128, 4, 2, 4, 2, 7744, 4, 6},
  38
+	{0xA514D3AD, 4096, 128, 4, 64, 4, 2, 4, 2, 3872, 4, 6},
  39
+	{0xA555D5AD, 8192, 128, 4, 64, 4, 2, 4, 2, 7744, 4, 6},
  40
+	{0xB614D5AD, 4096, 128, 8, 128, 4, 2, 4, 2, 3872, 4, 6},
  41
+	{0xB655D7AD, 8192, 128, 8, 128, 4, 2, 4, 2, 7744, 4, 6},
  42
+	{0xA585D598, 8320, 128, 4, 64, 6, 2, 4, 2, 7744, 4, 6},
  43
+	{0xBA94D598, 4096, 128, 8, 216, 6, 2, 4, 2, 3872, 8, 8},
  44
+	{0xBA95D798, 8192, 128, 8, 216, 6, 2, 4, 2, 7744, 8, 8},
  45
+	{0x3ED5D789, 8192, 128, 8, 216, 4, 2, 4, 2, 7744, 8, 8},
  46
+	{0x3E94D589, 4096, 128, 8, 216, 4, 2, 4, 2, 3872, 8, 8},
  47
+	{0x3ED5D72C, 8192, 128, 8, 216, 4, 2, 4, 2, 7744, 8, 8},
  48
+	{0x3E94D52C, 4096, 128, 8, 216, 4, 2, 4, 2, 3872, 8, 8},
47 49
 	{0}
48 50
 };
49 51
 
50  tools/dumpnandinfo.c
... ...
@@ -0,0 +1,50 @@
  1
+#include <stdio.h>
  2
+#include <stdlib.h>
  3
+#include <stdint.h>
  4
+
  5
+typedef struct NANDDeviceType {
  6
+	uint32_t id;
  7
+	uint16_t blocksPerBank;
  8
+	uint16_t pagesPerBlock;
  9
+	uint16_t sectorsPerPage;
  10
+	uint16_t bytesPerSpare;
  11
+	uint8_t WPPulseTime;
  12
+	uint8_t WEHighHoldTime;
  13
+	uint8_t NANDSetting3;
  14
+	uint8_t NANDSetting4;
  15
+	uint32_t userSubBlksTotal;
  16
+	uint32_t ecc1;
  17
+	uint32_t ecc2;
  18
+} NANDDeviceType;
  19
+
  20
+int main(int argc, char* argv[])
  21
+{
  22
+	if(argc < 3)
  23
+	{
  24
+		printf("Spit out a struct openiboot can use to configure NAND parameters from the similar table in iBoot.\n\n");
  25
+		printf("Usage: %s <decrypted iboot file> <offset>\n", argv[0]);
  26
+		return 0;
  27
+	}
  28
+
  29
+	printf("static const NANDDeviceType SupportedDevices[] = {\n");
  30
+	uint32_t offset = strtol(argv[2], NULL, 0);
  31
+	FILE* f = fopen(argv[1], "rb");
  32
+
  33
+	fseek(f, offset, SEEK_SET);
  34
+	while(1)
  35
+	{
  36
+		NANDDeviceType entry;
  37
+		fread(&entry, 1, sizeof(entry), f);
  38
+		if(entry.id == 0)
  39
+			break;
  40
+
  41
+		printf("\t{0x%X, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d},\n",
  42
+				entry.id, entry.blocksPerBank, entry.pagesPerBlock, entry.sectorsPerPage, entry.bytesPerSpare,
  43
+				entry.WPPulseTime, entry.WEHighHoldTime, entry.NANDSetting3, entry.NANDSetting4,
  44
+				entry.userSubBlksTotal, entry.ecc1, entry.ecc2);
  45
+	}
  46
+
  47
+	printf("\t{0}\n};\n");
  48
+
  49
+	fclose(f);
  50
+}

0 notes on commit 13d3901

Please sign in to comment.
Something went wrong with that request. Please try again.