Falošné čipy: Rozdiel medzi revíziami
Zo stránky SensorWiki
Bez shrnutí editace |
Bez shrnutí editace |
||
Riadok 73: | Riadok 73: | ||
Y-coordinate [0x0016] | Y-coordinate [0x0016] | ||
* Tu su nejake zdroje k tym signature bytes | * Tu su nejake zdroje k tym signature bytes | ||
* Nas zaujima toto: Serial number - https://microchip.my.site.com/s/article/Serial-number-in-AVR---Mega-Tiny-devices | |||
** https://onlinedocs.microchip.com/pr/GUID-0EC909F9-8FB7-46B2-BF4B-05290662B5C3-en-US-12.1.1/index.html?GUID-1CA1F31E-B953-4F6F-8166-716E99FB56EC | ** https://onlinedocs.microchip.com/pr/GUID-0EC909F9-8FB7-46B2-BF4B-05290662B5C3-en-US-12.1.1/index.html?GUID-1CA1F31E-B953-4F6F-8166-716E99FB56EC | ||
** https://onlinedocs.microchip.com/pr/GUID-EC8D3BAB-0B5E-454F-AB6E-6A7C91C6F103-en-US-3/index.html?GUID-B7E112F3-FAB5-4460-A019-1CD3E929FA29 | |||
** https://arduino.stackexchange.com/questions/24859/how-do-i-read-the-fuse-bits-from-within-my-sketch | ** https://arduino.stackexchange.com/questions/24859/how-do-i-read-the-fuse-bits-from-within-my-sketch | ||
* | |||
<tabs> | |||
<tab name="Arduino"><source lang="c++"> | |||
/* pin0 - Red LED / 1 - Green / 4 - Blue */ | |||
void setup() | |||
{ | |||
pinMode(0, OUTPUT); | |||
} | |||
void loop() | |||
{ | |||
digitalWrite(0, LOW); // LED On (common Anode) | |||
delay(200); // Wait for 200 ms | |||
digitalWrite(0, HIGH); // LED Off | |||
delay(200); // Wait for 200 ms | |||
} | |||
</source></tab> | |||
<tab name="AVR C-code"><source lang="c++" style="background: LightYellow;"> | |||
// Source https://gist.github.com/speters/f889faec42b510052a6ab4be437d38ca | |||
// Purpose is to simply run a memory check on ATMEGA238P to test for counterfeit parts | |||
// Usually fake chip has only FF on the last line | |||
#include <avr/boot.h> | |||
#define SIGRD 5 | |||
void setup() | |||
{ | |||
Serial.begin(9600); | |||
Serial.println(""); | |||
Serial.println("boot sig dump"); | |||
int newLineIndex = 0; | |||
char buffer[40]; | |||
Serial.println("\n 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); | |||
sprintf(buffer, "00: "); | |||
Serial.print(buffer); | |||
for (uint8_t i = 0x00; i <= 0x0F; i += 1) | |||
{ | |||
sprintf(buffer, "%02X ",boot_signature_byte_get(i)); | |||
Serial.print(buffer); | |||
} | |||
Serial.println(); | |||
sprintf(buffer, "10: "); | |||
Serial.print(buffer); | |||
for (uint8_t i = 0x10; i <= 0x1F; i += 1) | |||
{ | |||
sprintf(buffer, "%02X ",boot_signature_byte_get(i)); | |||
Serial.print(buffer); | |||
} | |||
Serial.println(); | |||
Serial.println(); | |||
sprintf(buffer, "Signature: %02X %02X %02X ",boot_signature_byte_get(0x00),boot_signature_byte_get(0x02),boot_signature_byte_get(0x04)); | |||
Serial.print(buffer); | |||
if (boot_signature_byte_get(0x00) == 0x1E) | |||
if (boot_signature_byte_get(0x02) == 0x95) | |||
if (boot_signature_byte_get(0x04) == 0x0F) | |||
Serial.println(" (ATmega328P)"); | |||
else if (boot_signature_byte_get(0x04) == 0x16) | |||
Serial.println(" (ATmega328PB)"); | |||
else | |||
Serial.println(" (---)"); | |||
else | |||
Serial.println(" (---)"); | |||
else | |||
Serial.println(" (---)"); | |||
Serial.print(" Lot: "); | |||
Serial.write(boot_signature_byte_get(0x0F)); | |||
Serial.write(boot_signature_byte_get(0x0E)); | |||
Serial.write(boot_signature_byte_get(0x11)); | |||
Serial.write(boot_signature_byte_get(0x10)); | |||
Serial.write(boot_signature_byte_get(0x13)); | |||
Serial.write(boot_signature_byte_get(0x12)); | |||
Serial.print(" Wafer: "); | |||
Serial.print(boot_signature_byte_get(0x15),DEC); | |||
Serial.print(" X: "); | |||
Serial.print(boot_signature_byte_get(0x17),DEC); | |||
Serial.print(" Y: "); | |||
Serial.print(boot_signature_byte_get(0x16),DEC); | |||
Serial.println(" (Decimal)"); | |||
//Serial.println(); | |||
cli(); | |||
uint8_t lowBits = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS); | |||
uint8_t highBits = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); | |||
uint8_t extendedBits = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS); | |||
uint8_t lockBits = boot_lock_fuse_bits_get(GET_LOCK_BITS); | |||
sei(); | |||
Serial.print(" Fuses: Low: 0x"); | |||
Serial.print(lowBits, HEX); | |||
Serial.print(" High: 0x"); | |||
Serial.print(highBits, HEX); | |||
Serial.print(" Ext: 0x"); | |||
Serial.print(extendedBits, HEX); | |||
Serial.print(" Lock: 0x"); | |||
Serial.println(lockBits, HEX); | |||
} | |||
void loop() | |||
{ /* do nothing here */ } | |||
</source></tab> | |||
</tabs> |
Verzia z 20:07, 25. jún 2024
Falošné čipy sú celkom často diskutovanou témou a tak som sa k nej dostal napokon aj ja. Začalo to celkom nevinne, nedokázal som totiž na jednej doštičke s klonom Arduino Nano rozchodiť časovač T2. A ani na druhej, ale na Arduino UNO mi to išlo. To už som začal hľadať chybu všade inde len nie u seba a napokon som narazil na stránku, kde bola opísaná jedna z možností, ako detekovať pravé Atmel (resp. Microchip) čipy a ako odhaliť tie nepravé. Je to celkom zaujímavé a dostaneme sa tak až celkom na úroveň výroby jednotlivých čipov. Každý mikroprocesor ATmega328P je spočiatku len jedna časť kremíkovej platne z priemerom 8 palcov, na ktorej sa postupne vrstva po vrstve vyrába celá štruktúra procesora. Ako takáto platňa (wafer) vyzerá?
Kremíková platňa (wafer) s priemerom 8 palcov, ktorú drží v ruke Eric Weddington (Atmel)
v roku 2013 na Maker Faire New York. Jedna takáto platňa obsahuje približne 1500 mikroprocesorov ATmega328.
(Foto/Source: Lenore Edman, Evil Mad Scientist
Obvykle sa procesory (a iné obvody) nevyrábajú po jednom, ale v tzv. dávkach (batch, LOT) obsahujúcch niekoľko takýchto platní - od jednotiek až po niekoľko desiatok. No a firma Atmel po výrobe procesorov každý kus na platni otestuje a zapíše do pamäte jeho polohu a číslo platne, takže aj spätne sa dá zistiť, kedy, kde a ako procesor vyrobili. Každý procesor tak získa unikátne výrobné číslo (signature). Podrobnosti o tomto kóde sú zverejnené a tak nie je ťažko spraviť si jednoduchý program, ktorý tento kód dokáže prečítať.
Lokalizácia konkrétneho čipu na kremíkovej platni
Zdroj: https://www.artwork.com/package/wmapconvert/manual_v2/glossary_of_terms.html
No a aké sú výsledky?
Sem pride tabulka so 4-5 Arduino Nano, najprv fotka celej dosky, pod nou USB prevodnik a konektor a napokon aj vycitany Signature.
Celkom na konci bude program, ktory si kazdy moze spustit a vyskusat spolu s odkazom na popis toho signature od Atmelu (miCrochipu):
- https://onlinedocs.microchip.com/pr/GUID-CBDC1838-0100-4F26-A45A-134958193C3B-en-US-4/index.html?GUID-5A8FB4BC-BC6B-47F2-AACE-6B6B107D5E8A - tieto mi sedia vo vypise?
Device Signature Byte 1 [0x0000] - tu je kod vyrobcu 0x1E Microchip (Atmel) Device Signature Byte 2 [0x0002] - tu by mala byt velkost Flash pamate: 0x8F 512 0x90 1024 0x91 2048 0x92 4096 0x93 8192 0x94 16384 0x95 32768 0x96 65536 0x97 131072 Device Signature Byte 3 [0x0004] - toto je unikatne ID pre konkretny device Signature Bytes Device 0x1E 0x92 0x05 ATmega48 1E 92 07 ATtiny44 1E 93 05 ATmega8 1E 93 0A ATmega88 1E 93 0B ATtiny85 1E 94 03 ATmega16 1E 94 06 ATmega168 1E 95 02 ATmega32 1E 95 0F ATmega328P 1E 95 16 ATmega328PB (!) RC Oscillator Calibration Byte [0x0001] - kalibračný bajt pre RC oscilátor Lot Number 1st Char [0x000F] - označenie výrobnej série (batch, lot) Lot Number 2nd Char [0x000E] Lot Number 3rd Char [0x0011] Lot Number 4th Char [0x0010] Lot Number 5th Char [0x0013] Lot Number 6th Char [0x0012] Reserved [0x0014] Wafer Number [0x0015] - číslo waferu v rámci série X-coordinate [0x0017] - poloha čipu na waferi X a Y Y-coordinate [0x0016]
- Tu su nejake zdroje k tym signature bytes
- Nas zaujima toto: Serial number - https://microchip.my.site.com/s/article/Serial-number-in-AVR---Mega-Tiny-devices
- https://onlinedocs.microchip.com/pr/GUID-0EC909F9-8FB7-46B2-BF4B-05290662B5C3-en-US-12.1.1/index.html?GUID-1CA1F31E-B953-4F6F-8166-716E99FB56EC
- https://onlinedocs.microchip.com/pr/GUID-EC8D3BAB-0B5E-454F-AB6E-6A7C91C6F103-en-US-3/index.html?GUID-B7E112F3-FAB5-4460-A019-1CD3E929FA29
- https://arduino.stackexchange.com/questions/24859/how-do-i-read-the-fuse-bits-from-within-my-sketch
/* pin0 - Red LED / 1 - Green / 4 - Blue */
void setup()
{
pinMode(0, OUTPUT);
}
void loop()
{
digitalWrite(0, LOW); // LED On (common Anode)
delay(200); // Wait for 200 ms
digitalWrite(0, HIGH); // LED Off
delay(200); // Wait for 200 ms
}
// Source https://gist.github.com/speters/f889faec42b510052a6ab4be437d38ca
// Purpose is to simply run a memory check on ATMEGA238P to test for counterfeit parts
// Usually fake chip has only FF on the last line
#include <avr/boot.h>
#define SIGRD 5
void setup()
{
Serial.begin(9600);
Serial.println("");
Serial.println("boot sig dump");
int newLineIndex = 0;
char buffer[40];
Serial.println("\n 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
sprintf(buffer, "00: ");
Serial.print(buffer);
for (uint8_t i = 0x00; i <= 0x0F; i += 1)
{
sprintf(buffer, "%02X ",boot_signature_byte_get(i));
Serial.print(buffer);
}
Serial.println();
sprintf(buffer, "10: ");
Serial.print(buffer);
for (uint8_t i = 0x10; i <= 0x1F; i += 1)
{
sprintf(buffer, "%02X ",boot_signature_byte_get(i));
Serial.print(buffer);
}
Serial.println();
Serial.println();
sprintf(buffer, "Signature: %02X %02X %02X ",boot_signature_byte_get(0x00),boot_signature_byte_get(0x02),boot_signature_byte_get(0x04));
Serial.print(buffer);
if (boot_signature_byte_get(0x00) == 0x1E)
if (boot_signature_byte_get(0x02) == 0x95)
if (boot_signature_byte_get(0x04) == 0x0F)
Serial.println(" (ATmega328P)");
else if (boot_signature_byte_get(0x04) == 0x16)
Serial.println(" (ATmega328PB)");
else
Serial.println(" (---)");
else
Serial.println(" (---)");
else
Serial.println(" (---)");
Serial.print(" Lot: ");
Serial.write(boot_signature_byte_get(0x0F));
Serial.write(boot_signature_byte_get(0x0E));
Serial.write(boot_signature_byte_get(0x11));
Serial.write(boot_signature_byte_get(0x10));
Serial.write(boot_signature_byte_get(0x13));
Serial.write(boot_signature_byte_get(0x12));
Serial.print(" Wafer: ");
Serial.print(boot_signature_byte_get(0x15),DEC);
Serial.print(" X: ");
Serial.print(boot_signature_byte_get(0x17),DEC);
Serial.print(" Y: ");
Serial.print(boot_signature_byte_get(0x16),DEC);
Serial.println(" (Decimal)");
//Serial.println();
cli();
uint8_t lowBits = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
uint8_t highBits = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
uint8_t extendedBits = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
uint8_t lockBits = boot_lock_fuse_bits_get(GET_LOCK_BITS);
sei();
Serial.print(" Fuses: Low: 0x");
Serial.print(lowBits, HEX);
Serial.print(" High: 0x");
Serial.print(highBits, HEX);
Serial.print(" Ext: 0x");
Serial.print(extendedBits, HEX);
Serial.print(" Lock: 0x");
Serial.println(lockBits, HEX);
}
void loop()
{ /* do nothing here */ }