Skip to content

Commit

Permalink
Add initial 96/97 V6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
antus committed Aug 19, 2023
1 parent fb0c10b commit e2364db
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 63 deletions.
8 changes: 0 additions & 8 deletions Apps/PcmHammer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,14 +1516,6 @@ private async void write_BackgroundThread(WriteType writeType, string path = nul
}
}

if (writeType != WriteType.Compare && (pcmInfo.HardwareType == PcmType.P04))
{
string msg = $"PCMHammer currently does not support writing to the {pcmInfo.HardwareType.ToString()}";
this.AddUserMessage(msg);
MessageBox.Show(msg);
return;
}

if (pcmInfo.HardwareType == PcmType.P04 || pcmInfo.HardwareType == PcmType.E54)
{
string msg = $"WARNING: {pcmInfo.HardwareType.ToString()} Support is still in development.";
Expand Down
3 changes: 2 additions & 1 deletion Apps/PcmLibrary/Devices/OBDXProDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public OBDXProDevice(IPort port, ILogger logger) : base(port, logger)
{
this.MaxSendSize = 4096 + 10 + 2; // packets up to 4112 but we want 4096 byte data blocks
this.MaxReceiveSize = 4096 + 10 + 2; // with 10 byte header and 2 byte block checksum

this.Supports4X = true;
this.SupportsSingleDpidLogging = true;
this.SupportsStreamLogging = true;
Expand Down Expand Up @@ -200,7 +201,7 @@ async private Task<bool> WaitForSerial(ushort NumBytes, int timeout = 0)
{
if (timeout == 0)
{
timeout = 500;
timeout = 1000;
}

int TempCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion Apps/PcmLibrary/Misc/FileValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public uint GetOsidFromImage()
{
int osid = 0;

if (image.Length == 512 * 1024 || image.Length == 1024 * 1024 || image.Length == 2048 * 1024) // bin valid sizes
if (image.Length == 256 * 1024 || image.Length == 512 * 1024 || image.Length == 1024 * 1024 || image.Length == 2048 * 1024) // bin valid sizes
{
PcmType type = this.ValidateSignatures();
switch (type)
Expand Down
113 changes: 63 additions & 50 deletions Apps/PcmLibrary/Misc/FlashChip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public static FlashChip Create(UInt32 chipId, ILogger logger)
// These numbers and descriptions are straight from the intel 28F400B data sheet.
// Notice that if you convert the 16 bit word sizes to decimal, they're all
// half as big as the description here, in bytes, indicates.
new MemoryRange(0x30000, 0x10000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x20000, 0x10000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x10000, 0x10000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x04000, 0x0C000, BlockType.Calibration), // 96kb main block
new MemoryRange(0x03000, 0x01000, BlockType.Parameter), // 8kb parameter block
Expand All @@ -75,14 +73,13 @@ public static FlashChip Create(UInt32 chipId, ILogger logger)
};
throw new InvalidOperationException("This flash chip ID was not supposed to exist in the wild.");

// This is not a real chip, its used as a default value, then overwritten with real data if the kernel supprot flashchipid.
case 0x12345678:
// P04 is too small to have chip ID code (at this stage). So, we use this hard coded ID to satisfy PCMHammer's need for a chip structure.
// 12345678 should not exist in the wild and is less likely to trigger accidentally than using 00000000 or FFFFFFFF.
size = 512 * 1024;
description = "Hardcoded Intel Specification 512kb";
description = "Default 512Kb";
memoryRanges = new MemoryRange[]
{
// These addresses are for a bottom fill chip (B) in byte mode (not word)
// Used by CKernelReader to initialise FlashChip default value
new MemoryRange(0x60000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x40000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x20000, 0x20000, BlockType.OperatingSystem), // 128kb main block
Expand All @@ -93,19 +90,14 @@ public static FlashChip Create(UInt32 chipId, ILogger logger)
};
break;

// Intel 28F800B
case 0x0089889D:
size = 1024 * 1024;
description = "Intel 28F800B, 1mb";
// Intel 28F200BX
case 0x00892274:
case 0x00892275:
size = 512 * 1024;
description = "Intel 28F200BX, 256kb";
memoryRanges = new MemoryRange[]
{
// These addresses are for a bottom fill chip (B) in byte mode (not word)
new MemoryRange(0xE0000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0xC0000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0xA0000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x80000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x60000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x40000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x20000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x08000, 0x18000, BlockType.Calibration), // 96kb main block
new MemoryRange(0x06000, 0x02000, BlockType.Parameter), // 8kb parameter block
Expand All @@ -131,23 +123,44 @@ public static FlashChip Create(UInt32 chipId, ILogger logger)
};
break;

// AM29BL162C
case 0x00012203:
size = 2048 * 1024;
description = "AMD AM29BL162C, 2mb";
// Intel 28F800B
case 0x0089889D:
size = 1024 * 1024;
description = "Intel 28F800B, 1mb";
memoryRanges = new MemoryRange[]
{ // Start address, Size in Bytes
new MemoryRange(0x1C0000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange(0x180000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange(0x140000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange(0x100000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange( 0xC0000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange( 0x80000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange( 0x40000, 0x40000, BlockType.Calibration), // 256kb calibration block
new MemoryRange( 0x08000, 0x38000, BlockType.Calibration), // 229kb calibration block
new MemoryRange( 0x06000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange( 0x04000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange( 0x00000, 0x04000, BlockType.Boot), // 16kb boot block
{
// These addresses are for a bottom fill chip (B) in byte mode (not word)
new MemoryRange(0xE0000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0xC0000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0xA0000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x80000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x60000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x40000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x20000, 0x20000, BlockType.OperatingSystem), // 128kb main block
new MemoryRange(0x08000, 0x18000, BlockType.Calibration), // 96kb main block
new MemoryRange(0x06000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange(0x04000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange(0x00000, 0x04000, BlockType.Boot), // 16kb boot block
};
break;

// AM29F400BB
case 0x000122AB:
size = 512 * 1024;
description = "AMD AM29F400BB, 512kb";
memoryRanges = new MemoryRange[]
{
new MemoryRange(0x70000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x60000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x50000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x40000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x30000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x20000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x10000, 0x10000, BlockType.Calibration), // 64kb calibration block
new MemoryRange(0x08000, 0x08000, BlockType.Calibration), // 32kb calibration block
new MemoryRange(0x06000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange(0x04000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange(0x00000, 0x04000, BlockType.Boot), // 16kb boot block
};
break;

Expand Down Expand Up @@ -197,23 +210,23 @@ public static FlashChip Create(UInt32 chipId, ILogger logger)
};
break;

// AM29F400BB
case 0x000122AB:
size = 512 * 1024;
description = "AMD AM29F400BB, 512kb";
// AM29BL162C
case 0x00012203:
size = 2048 * 1024;
description = "AMD AM29BL162C, 2mb";
memoryRanges = new MemoryRange[]
{
new MemoryRange(0x70000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x60000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x50000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x40000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x30000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x20000, 0x10000, BlockType.OperatingSystem), // 64kb main block
new MemoryRange(0x10000, 0x10000, BlockType.Calibration), // 64kb calibration block
new MemoryRange(0x08000, 0x08000, BlockType.Calibration), // 32kb calibration block
new MemoryRange(0x06000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange(0x04000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange(0x00000, 0x04000, BlockType.Boot), // 16kb boot block
{ // Start address, Size in Bytes
new MemoryRange(0x1C0000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange(0x180000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange(0x140000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange(0x100000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange( 0xC0000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange( 0x80000, 0x40000, BlockType.OperatingSystem), // 256kb main block
new MemoryRange( 0x40000, 0x40000, BlockType.Calibration), // 256kb calibration block
new MemoryRange( 0x08000, 0x38000, BlockType.Calibration), // 229kb calibration block
new MemoryRange( 0x06000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange( 0x04000, 0x02000, BlockType.Parameter), // 8kb parameter block
new MemoryRange( 0x00000, 0x04000, BlockType.Boot), // 16kb boot block
};
break;

Expand Down Expand Up @@ -257,9 +270,9 @@ public static FlashChip Create(UInt32 chipId, ILogger logger)
if (index == 0)
{
UInt32 top = memoryRanges[index].Address + memoryRanges[index].Size;
if ((top != 512 * 1024) && (top != 1024 * 1024) && (top != 2048 * 1024))
if ((top != 256 * 1024) && (top != 512 * 1024) && (top != 1024 * 1024) && (top != 2048 * 1024))
{
throw new InvalidOperationException(chipIdString + " - Upper end of memory range must be 512k or 1024k, is " + top.ToString("X8"));
throw new InvalidOperationException(chipIdString + " - Upper end of memory range must be 256, 512k, 1024k or 2048k, is " + (top / 1024).ToString() + "k");
}

if (size != top)
Expand Down
123 changes: 123 additions & 0 deletions Apps/PcmLibrary/Misc/PcmInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,129 @@ public PcmInfo(uint osid)
this.HardwareType = PcmType.BLACKBOX;
break;

// V6 Car Service number 16207326 1996/1997 256kb
case 9352140:
case 9352142:
case 9352143:
case 9352146:
case 9352149:
case 9352150:
case 9352340:
case 9352342:
case 9352346:
case 9352347:
case 9352553:
case 9354241:
case 9354242:
case 9355430:
case 9355433:
case 9355435:
case 9365005:
case 9365007:
case 9365012:
case 9365017:
case 9365650:
case 9365651:
case 9365652:
case 9365655:
case 9367092:
case 16210002:
case 16210010:
case 16219361:
case 16219368:
case 16226502:
case 16227925:
case 16230131:
case 16230375:
case 16230378:
case 16230380:
case 16230383:
case 16230385:
case 16231872:
case 16231877:
case 16231889:
case 16231890:
case 16231940:
case 16231941:
case 16232010:
case 16232466:
case 16232477:
case 16233470:
case 16233471:
case 16233472:
case 16233478:
case 16234097:
case 16234124:
case 16234438:
case 16234440:
case 16234441:
case 16234751:
case 16235667:
case 16238373:
case 16238443:
case 16238446:
case 16238447:
case 16238448:
case 16238450:
case 16238452:
case 16238453:
case 16238456:
case 16238457:
case 16238458:
case 16238517:
case 16238518:
case 16238519:
case 16238520:
case 16238523:
case 16238525:
case 16238532:
case 16238533:
case 16240637:
case 16241229:
case 16245321:
case 16246063:
case 16246066:
case 16249992:
case 16249995:
case 16251203:
case 16251205:
case 16251975:
case 16257917:
case 16257918:
case 16257922:
case 16257926:
case 16257935:
case 16257936:
case 16257937:
case 16257938:
case 16257940:
case 16257942:
case 16257947:
case 16257950:
case 16257952:
case 16257953:
case 16257955:
case 16257956:
this.Description = "1996/1997 256Kb V6";
this.IsSupported = true;
this.LoaderRequired = true;
this.ValidationMethod = PcmType.P04;
this.HardwareType = PcmType.P04;
this.KernelFileName = "Kernel-P04.bin";
this.KernelBaseAddress = 0xFF8000;
this.LoaderFileName = "Loader-P04.bin";
this.LoaderBaseAddress = 0xFF9800;
//this.ImageBaseAddress = 0x0;
this.ImageSize = 256 * 1024;
//this.RAMSize = 0x0;
this.KeyAlgorithm = 6;
this.ChecksumSupport = true;
this.FlashCRCSupport = true;
this.FlashIDSupport = true;
this.KernelVersionSupport = true;
//this.KernelMaxBlockSize = 4096;
break;

// P04 V6 Service number 9374997
case 9355672:
case 9356706:
Expand Down
Loading

0 comments on commit e2364db

Please sign in to comment.