-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsummary.php
More file actions
96 lines (79 loc) · 3.37 KB
/
summary.php
File metadata and controls
96 lines (79 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/*
* iTXTech FlashDetector
*
* Copyright (C) 2018-2023 iTX Technologies
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
//Originally customized for Fangli Technology Ltd.
require_once "env.php";
use iTXTech\FlashDetector\Constants;
use iTXTech\FlashDetector\FlashDetector;
use iTXTech\FlashDetector\Property\Classification;
$fdb = FlashDetector::getFdb();
$csv = "Part Number,Vendor,Density,Cell Level,Process Node,Package,CE Pins,Flash IDs" . PHP_EOL;
foreach ($fdb->getVendors() as $vendor) {
foreach ($vendor->getPartNumbers() as $pn) {
$i = FlashDetector::detect($pn->getPartNumber(), true);
$ids = $i->getFlashId();
if ($ids != null and $i->getDensity() > 0) {
$cell = $i->getCellLevel();
$ce = ($i->getClassification() ?? new Classification())->getCe();
$ce = ($ce < 0) ? "Unknown" : $ce;
if (($i->getExtraInfo()[Constants::ENTERPRISE] ?? false) === true) {
$cell = "e" . $cell;
}
$csv .= $pn->getPartNumber() . "," . strtoupper($i->getVendor()) . "," .
FlashDetector::getHumanReadableDensity($i->getDensity(), true) . "," .
$cell . "," . $i->getProcessNode() . "," . str_replace(",", " ", $i->getPackage()) .
"," . $ce . "," . implode(" ", $ids) . PHP_EOL;
}
}
}
file_put_contents("summary.csv", $csv);
$csv = "Micron FBGA Code,Part Number,Density,Cell Level,Process Node,Package,CE Pins,Flash IDs" . PHP_EOL;
$mdb = FlashDetector::getMdb();
foreach ($mdb as $vendor) {
foreach ($vendor as $code => $pns) {
if (!is_array($pns)) {
$pns = [$pns];
}
$info = FlashDetector::detect($pns[0]);
$ce = ($info->getClassification() ?? new Classification())->getCe();
$ids = $info->getFlashId() ?? [];
$d = $info->getDensity() ?? 0;
$cell = $info->getCellLevel();
if (($info->getExtraInfo()[Constants::ENTERPRISE] ?? false) === true) {
$cell = "e" . $cell;
}
$csv .= $code . "," . implode(" ", $pns) . "," .
FlashDetector::getHumanReadableDensity($d, true) . "," . $cell .
"," . $info->getProcessNode() . "," . str_replace(",", " ", $info->getPackage()) .
"," . $ce . "," . implode(" ", $ids) . PHP_EOL;
}
}
file_put_contents("micron_summary.csv", $csv);
$csv = "Flash IDs,Part Numbers,Controllers" . PHP_EOL;
$iddb = $fdb->getIddb();
foreach ($iddb->getFlashIds() as $flashId) {
$pns = $flashId->getPartNumbers();
$npn = [];
foreach ($pns as $pn) {
$npn[] = explode(" ", $pn)[1];
}
$csv .= $flashId->getFlashId() . "," . implode(" ", $npn) . "," . implode(" ", $flashId->getControllers()) . PHP_EOL;
}
file_put_contents("id_summary.csv", $csv);