memory(), chassis() optimized for raspberry
This commit is contained in:
parent
0be9e22f4c
commit
daa8419057
409
lib/util.js
409
lib/util.js
@ -885,214 +885,213 @@ function decodePiCpuinfo(lines) {
|
|||||||
} else if (lines === null) {
|
} else if (lines === null) {
|
||||||
lines = _rpi_cpuinfo;
|
lines = _rpi_cpuinfo;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
|
// https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
|
||||||
|
|
||||||
const oldRevisionCodes = {
|
const oldRevisionCodes = {
|
||||||
'0002': {
|
'0002': {
|
||||||
type: 'B',
|
type: 'B',
|
||||||
revision: '1.0',
|
revision: '1.0',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Egoman',
|
manufacturer: 'Egoman',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0003': {
|
'0003': {
|
||||||
type: 'B',
|
type: 'B',
|
||||||
revision: '1.0',
|
revision: '1.0',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Egoman',
|
manufacturer: 'Egoman',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0004': {
|
'0004': {
|
||||||
type: 'B',
|
type: 'B',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Sony UK',
|
manufacturer: 'Sony UK',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0005': {
|
'0005': {
|
||||||
type: 'B',
|
type: 'B',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Qisda',
|
manufacturer: 'Qisda',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0006': {
|
'0006': {
|
||||||
type: 'B',
|
type: 'B',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Egoman',
|
manufacturer: 'Egoman',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0007': {
|
'0007': {
|
||||||
type: 'A',
|
type: 'A',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Egoman',
|
manufacturer: 'Egoman',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0008': {
|
'0008': {
|
||||||
type: 'A',
|
type: 'A',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Sony UK',
|
manufacturer: 'Sony UK',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0009': {
|
'0009': {
|
||||||
type: 'A',
|
type: 'A',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Qisda',
|
manufacturer: 'Qisda',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'000d': {
|
'000d': {
|
||||||
type: 'B',
|
type: 'B',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 512,
|
memory: 512,
|
||||||
manufacturer: 'Egoman',
|
manufacturer: 'Egoman',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'000e': {
|
'000e': {
|
||||||
type: 'B',
|
type: 'B',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 512,
|
memory: 512,
|
||||||
manufacturer: 'Sony UK',
|
manufacturer: 'Sony UK',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'000f': {
|
'000f': {
|
||||||
type: 'B',
|
type: 'B',
|
||||||
revision: '2.0',
|
revision: '2.0',
|
||||||
memory: 512,
|
memory: 512,
|
||||||
manufacturer: 'Egoman',
|
manufacturer: 'Egoman',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0010': {
|
'0010': {
|
||||||
type: 'B+',
|
type: 'B+',
|
||||||
revision: '1.2',
|
revision: '1.2',
|
||||||
memory: 512,
|
memory: 512,
|
||||||
manufacturer: 'Sony UK',
|
manufacturer: 'Sony UK',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0011': {
|
'0011': {
|
||||||
type: 'CM1',
|
type: 'CM1',
|
||||||
revision: '1.0',
|
revision: '1.0',
|
||||||
memory: 512,
|
memory: 512,
|
||||||
manufacturer: 'Sony UK',
|
manufacturer: 'Sony UK',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0012': {
|
'0012': {
|
||||||
type: 'A+',
|
type: 'A+',
|
||||||
revision: '1.1',
|
revision: '1.1',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: 'Sony UK',
|
manufacturer: 'Sony UK',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0013': {
|
'0013': {
|
||||||
type: 'B+',
|
type: 'B+',
|
||||||
revision: '1.2',
|
revision: '1.2',
|
||||||
memory: 512,
|
memory: 512,
|
||||||
manufacturer: 'Embest',
|
manufacturer: 'Embest',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0014': {
|
'0014': {
|
||||||
type: 'CM1',
|
type: 'CM1',
|
||||||
revision: '1.0',
|
revision: '1.0',
|
||||||
memory: 512,
|
memory: 512,
|
||||||
manufacturer: 'Embest',
|
manufacturer: 'Embest',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
},
|
},
|
||||||
'0015': {
|
'0015': {
|
||||||
type: 'A+',
|
type: 'A+',
|
||||||
revision: '1.1',
|
revision: '1.1',
|
||||||
memory: 256,
|
memory: 256,
|
||||||
manufacturer: '512MB Embest',
|
manufacturer: '512MB Embest',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const processorList = [
|
||||||
|
'BCM2835',
|
||||||
|
'BCM2836',
|
||||||
|
'BCM2837',
|
||||||
|
'BCM2711',
|
||||||
|
'BCM2712',
|
||||||
|
];
|
||||||
|
const manufacturerList = [
|
||||||
|
'Sony UK',
|
||||||
|
'Egoman',
|
||||||
|
'Embest',
|
||||||
|
'Sony Japan',
|
||||||
|
'Embest',
|
||||||
|
'Stadium'
|
||||||
|
];
|
||||||
|
const typeList = {
|
||||||
|
'00': 'A',
|
||||||
|
'01': 'B',
|
||||||
|
'02': 'A+',
|
||||||
|
'03': 'B+',
|
||||||
|
'04': '2B',
|
||||||
|
'05': 'Alpha (early prototype)',
|
||||||
|
'06': 'CM1',
|
||||||
|
'08': '3B',
|
||||||
|
'09': 'Zero',
|
||||||
|
'0a': 'CM3',
|
||||||
|
'0c': 'Zero W',
|
||||||
|
'0d': '3B+',
|
||||||
|
'0e': '3A+',
|
||||||
|
'0f': 'Internal use only',
|
||||||
|
'10': 'CM3+',
|
||||||
|
'11': '4B',
|
||||||
|
'12': 'Zero 2 W',
|
||||||
|
'13': '400',
|
||||||
|
'14': 'CM4',
|
||||||
|
'15': 'CM4S',
|
||||||
|
'16': 'Internal use only',
|
||||||
|
'17': '5',
|
||||||
|
'18': 'CM5',
|
||||||
|
'19': '500',
|
||||||
|
'1a': 'CM5 Lite',
|
||||||
|
};
|
||||||
|
|
||||||
|
const revisionCode = getValue(lines, 'revision', ':', true);
|
||||||
|
const model = getValue(lines, 'model:', ':', true);
|
||||||
|
const serial = getValue(lines, 'serial', ':', true);
|
||||||
|
|
||||||
|
let result = {};
|
||||||
|
if ({}.hasOwnProperty.call(oldRevisionCodes, revisionCode)) {
|
||||||
|
// old revision codes
|
||||||
|
result = {
|
||||||
|
model,
|
||||||
|
serial,
|
||||||
|
revisionCode,
|
||||||
|
memory: oldRevisionCodes[revisionCode].memory,
|
||||||
|
manufacturer: oldRevisionCodes[revisionCode].manufacturer,
|
||||||
|
processor: oldRevisionCodes[revisionCode].processor,
|
||||||
|
type: oldRevisionCodes[revisionCode].type,
|
||||||
|
revision: oldRevisionCodes[revisionCode].revision,
|
||||||
|
};
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// new revision code
|
||||||
|
const revision = ('00000000' + getValue(lines, 'revision', ':', true).toLowerCase()).substr(-8);
|
||||||
|
const memSizeCode = parseInt(hex2bin(revision.substr(2, 1)).substr(5, 3), 2) || 0;
|
||||||
|
const manufacturer = manufacturerList[parseInt(revision.substr(3, 1), 10)];
|
||||||
|
const processor = processorList[parseInt(revision.substr(4, 1), 10)];
|
||||||
|
const typeCode = revision.substr(5, 2);
|
||||||
|
|
||||||
|
|
||||||
|
result = {
|
||||||
|
model,
|
||||||
|
serial,
|
||||||
|
revisionCode,
|
||||||
|
memory: 256 * Math.pow(2, memSizeCode),
|
||||||
|
manufacturer,
|
||||||
|
processor,
|
||||||
|
type: {}.hasOwnProperty.call(typeList, typeCode) ? typeList[typeCode] : '',
|
||||||
|
revision: '1.' + revision.substr(7, 1),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
return result;
|
||||||
|
|
||||||
const processorList = [
|
|
||||||
'BCM2835',
|
|
||||||
'BCM2836',
|
|
||||||
'BCM2837',
|
|
||||||
'BCM2711',
|
|
||||||
'BCM2712',
|
|
||||||
];
|
|
||||||
const manufacturerList = [
|
|
||||||
'Sony UK',
|
|
||||||
'Egoman',
|
|
||||||
'Embest',
|
|
||||||
'Sony Japan',
|
|
||||||
'Embest',
|
|
||||||
'Stadium'
|
|
||||||
];
|
|
||||||
const typeList = {
|
|
||||||
'00': 'A',
|
|
||||||
'01': 'B',
|
|
||||||
'02': 'A+',
|
|
||||||
'03': 'B+',
|
|
||||||
'04': '2B',
|
|
||||||
'05': 'Alpha (early prototype)',
|
|
||||||
'06': 'CM1',
|
|
||||||
'08': '3B',
|
|
||||||
'09': 'Zero',
|
|
||||||
'0a': 'CM3',
|
|
||||||
'0c': 'Zero W',
|
|
||||||
'0d': '3B+',
|
|
||||||
'0e': '3A+',
|
|
||||||
'0f': 'Internal use only',
|
|
||||||
'10': 'CM3+',
|
|
||||||
'11': '4B',
|
|
||||||
'12': 'Zero 2 W',
|
|
||||||
'13': '400',
|
|
||||||
'14': 'CM4',
|
|
||||||
'15': 'CM4S',
|
|
||||||
'16': 'Internal use only',
|
|
||||||
'17': '5',
|
|
||||||
'18': 'CM5',
|
|
||||||
'19': '500',
|
|
||||||
'1a': 'CM5 Lite',
|
|
||||||
};
|
|
||||||
|
|
||||||
const revisionCode = getValue(lines, 'revision', ':', true);
|
|
||||||
const model = getValue(lines, 'model:', ':', true);
|
|
||||||
const serial = getValue(lines, 'serial', ':', true);
|
|
||||||
|
|
||||||
let result = {};
|
|
||||||
if ({}.hasOwnProperty.call(oldRevisionCodes, revisionCode)) {
|
|
||||||
// old revision codes
|
|
||||||
result = {
|
|
||||||
model,
|
|
||||||
serial,
|
|
||||||
revisionCode,
|
|
||||||
memory: oldRevisionCodes[revisionCode].memory,
|
|
||||||
manufacturer: oldRevisionCodes[revisionCode].manufacturer,
|
|
||||||
processor: oldRevisionCodes[revisionCode].processor,
|
|
||||||
type: oldRevisionCodes[revisionCode].type,
|
|
||||||
revision: oldRevisionCodes[revisionCode].revision,
|
|
||||||
};
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// new revision code
|
|
||||||
const revision = ('00000000' + getValue(lines, 'revision', ':', true).toLowerCase()).substr(-8);
|
|
||||||
const memSizeCode = parseInt(hex2bin(revision.substr(2, 1)).substr(5, 3), 2) || 0;
|
|
||||||
const manufacturer = manufacturerList[parseInt(revision.substr(3, 1), 10)];
|
|
||||||
const processor = processorList[parseInt(revision.substr(4, 1), 10)];
|
|
||||||
const typeCode = revision.substr(5, 2);
|
|
||||||
|
|
||||||
|
|
||||||
result = {
|
|
||||||
model,
|
|
||||||
serial,
|
|
||||||
revisionCode,
|
|
||||||
memory: 256 * Math.pow(2, memSizeCode),
|
|
||||||
manufacturer,
|
|
||||||
processor,
|
|
||||||
type: {}.hasOwnProperty.call(typeList, typeCode) ? typeList[typeCode] : '',
|
|
||||||
revision: '1.' + revision.substr(7, 1),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRpiGpu() {
|
function getRpiGpu() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user