Skip to content

Commit

Permalink
SKHynix25: initial support
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Oct 22, 2019
1 parent b2f3ba2 commit db87b5c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 26 deletions.
18 changes: 5 additions & 13 deletions FlashDetector/src/iTXTech/FlashDetector/Decoder/SKHynix.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class SKHynix extends Decoder{
"G" => [1, 2, self::LARGE_BLOCK],
"H" => [1, 4, self::LARGE_BLOCK],
"J" => [1, 8, self::LARGE_BLOCK],
"K" => [1, -1, self::LARGE_BLOCK],//Double Stack Package
"K" => [1, 2, self::LARGE_BLOCK],//Double Stack Package
"T" => [2, 1, self::LARGE_BLOCK],
"U" => [2, 2, self::LARGE_BLOCK],
"V" => [2, 4, self::LARGE_BLOCK],
"W" => [2, -1, self::LARGE_BLOCK],//Double Stack Package
"W" => [2, 2, self::LARGE_BLOCK],//Double Stack Package
"Y" => [2, 8, self::LARGE_BLOCK],
"R" => [2, 6, self::LARGE_BLOCK],
"Z" => [2, 12, self::LARGE_BLOCK],
Expand Down Expand Up @@ -106,14 +106,6 @@ class SKHynix extends Decoder{
"E" => [4, 4, true, 4],
"Q" => [4, 4, true, 4]
];
protected const GENERATION = [
"M" => 1,
"A" => 2,
"B" => 3,
"C" => 4,
"D" => 5,
"E" => 6
];
protected const PACKAGE = [
"T" => "TSOP1",
"V" => "WSOP",
Expand Down Expand Up @@ -156,7 +148,7 @@ public static function getName() : string{
}

public static function check(string $partNumber) : bool{
if(StringUtil::startsWith($partNumber, "H2")){//TODO: E2NAND
if(StringUtil::startsWith($partNumber, "H2")){
return true;
}
return false;
Expand All @@ -165,7 +157,7 @@ public static function check(string $partNumber) : bool{
public static function decode(string $partNumber) : FlashInfo{
$flashInfo = (new FlashInfo($partNumber))
->setVendor(self::getName());
if(in_array($level = self::shiftChars($partNumber, 3), ["H2J", "H2D"])){
if(in_array($level = self::shiftChars($partNumber, 3), ["H2J", "H2D", "H26"])){
//TODO: SKHynix E2NAND
return $flashInfo->setType(Constants::NAND_TYPE_CON)
->setExtraInfo([Constants::UNSUPPORTED_REASON => Constants::SKHYNIX_UNSUPPORTED]);
Expand All @@ -192,7 +184,7 @@ public static function decode(string $partNumber) : FlashInfo{
$flashInfo->setClassification(new Classification(
$mode[0], $mode[3], $mode[1], $classification[1]));
$flashInfo//->setInterface((new FlashInterface(false))->setAsync(true)->setSync(true))//Async default = true
->setGeneration(self::getOrDefault(self::shiftChars($partNumber, 1), self::GENERATION))
->setGeneration(self::getOrDefault(self::shiftChars($partNumber, 1), Samsung::GENERATION))
->setPackage(self::getOrDefault(self::shiftChars($partNumber, 1), self::PACKAGE));

$packageMaterial = self::shiftChars($partNumber, 1);
Expand Down
71 changes: 71 additions & 0 deletions FlashDetector/src/iTXTech/FlashDetector/Decoder/SKHynix25.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/*
* iTXTech FlashDetector
*
* Copyright (C) 2018-2019 iTX Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace iTXTech\FlashDetector\Decoder;


use iTXTech\FlashDetector\Constants;
use iTXTech\FlashDetector\FlashInfo;
use iTXTech\FlashDetector\Property\FlashInterface;
use iTXTech\SimpleFramework\Util\StringUtil;

class SKHynix25 extends SKHynix{
public static function check(string $partNumber) : bool{
if(StringUtil::startsWith($partNumber, "H25")){
return true;
}
return false;
}

public static function decode(string $partNumber) : FlashInfo{
$flashInfo = (new FlashInfo($partNumber))->setType(Constants::NAND_TYPE_NAND)
->setVendor(self::getName())->setInterface((new FlashInterface(true))->setToggle(true));
self::shiftChars($partNumber, 3);//remove H25
//B => ToggleDDR 4.0, Q => ToggleDDR 2.0 | maybe voltage
$flashInfo->setExtraInfo([
"toggle" => self::getOrDefault(self::shiftChars($partNumber, 1), ["B" => "4.0", "Q" => "2.0"])
])->setVoltage("Vcc: 3.3V, VccQ: 1.8V (UNOFFICIAL)");
self::shiftChars($partNumber, 1);//E, F ???
$flashInfo->setCellLevel($level = self::getOrDefault(self::shiftChars($partNumber, 1), [
"M" => 2,
"T" => 3
]))->setDeviceWidth(8);
self::shiftChars($partNumber, 1);//8, M
$density = self::shiftChars($partNumber, 1);
switch($level){
case 2:
$flashInfo->setDensity(self::getOrDefault($density, ["A" => 256 * Constants::DENSITY_GBITS], 0));
break;
case 3:
default:
$flashInfo->setDensity(self::getOrDefault($density, [
"A" => 512 * Constants::DENSITY_GBITS,
"B" => 1 * Constants::DENSITY_TBITS,
"D" => 2 * Constants::DENSITY_TBITS,
"F" => 4 * Constants::DENSITY_TBITS,
"G" => 8 * Constants::DENSITY_TBITS,
], 0));
}
self::shiftChars($partNumber, 1);//2, 3, 4 | maybe CE, Rb, Ch
$flashInfo->setGeneration(self::getOrDefault(self::shiftChars($partNumber, 1), Samsung::GENERATION));

return $flashInfo;
}
}
27 changes: 14 additions & 13 deletions FlashDetector/src/iTXTech/FlashDetector/Decoder/Samsung.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ class Samsung extends Decoder{
"VG" => 8 * Constants::DENSITY_TBITS,
"00" => 0
];
public const GENERATION = [
"M" => 1,
"A" => 2,
"B" => 3,
"C" => 4,
"D" => 5,
"E" => 6,
"F" => 7,
"G" => 8,
"H" => 9,
"Y" => 25,
"Z" => 26
];

public static function getName() : string{
return Constants::VENDOR_SAMSUNG;
Expand Down Expand Up @@ -154,19 +167,7 @@ public static function decode(string $partNumber) : FlashInfo{
"J" => [16, 4],
], [-1, -1]);
$flashInfo->setClassification(new Classification($mode[0], Classification::UNKNOWN_PROP, $mode[1], $c[1]))
->setGeneration(self::getOrDefault(self::shiftChars($partNumber, 1), [
"M" => 1,
"A" => 2,
"B" => 3,
"C" => 4,
"D" => 5,
"E" => 6,
"F" => 7,
"G" => 8,
"H" => 9,
"Y" => 25,
"Z" => 26
]));
->setGeneration(self::getOrDefault(self::shiftChars($partNumber, 1), self::GENERATION));

self::shiftChars($partNumber, 1);//remove -
$flashInfo->setPackage(self::getOrDefault($package = self::shiftChars($partNumber, 1), [
Expand Down
2 changes: 2 additions & 0 deletions FlashDetector/src/iTXTech/FlashDetector/FlashDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use iTXTech\FlashDetector\Decoder\SanDisk;
use iTXTech\FlashDetector\Decoder\SanDiskShortCode;
use iTXTech\FlashDetector\Decoder\SKHynix;
use iTXTech\FlashDetector\Decoder\SKHynix25;
use iTXTech\FlashDetector\Decoder\SKHynixLegacy;
use iTXTech\FlashDetector\Decoder\SpecTek;
use iTXTech\FlashDetector\Decoder\Toshiba;
Expand Down Expand Up @@ -97,6 +98,7 @@ public static function loadDatabase(){

public static function init(string $lang = "eng", string $fallbackLang = "eng"){
self::registerDecoder(Micron::class);
self::registerDecoder(SKHynix25::class);
self::registerDecoder(SKHynix::class);
self::registerDecoder(SKHynixLegacy::class);
self::registerDecoder(Toshiba::class);
Expand Down

0 comments on commit db87b5c

Please sign in to comment.