- No this doesn't work
- The stock adafruit library needs to be rewritten
- When you read back the data page 0 will be unable to be read and pages 133 and 134 will be all zeros despite being able to be read
Last active
May 1, 2020 00:18
-
-
Save LindseyB/aa6391f77da9b6c31d552769c9f49f27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <SPI.h> | |
#include <Adafruit_PN532.h> // Note: This needs to be edited to exclude the bounds check, lines 1334-1351 should be commented out | |
#define PN532_IRQ (2) | |
#define PN532_RESET (3) // Not connected by default on the NFC Shield | |
// This is using the NFC shield, if you are using the breakout you will need to change these pins | |
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET); | |
int shift = 12; // so we skip the first few pages that will stay the same | |
byte data[] = {0, 0, 0, 0}; // buffer for writing the data | |
byte pages = 135; | |
// note: this dump is generated from https://games.kel.mn/amiibo/ | |
// with files from: https://nfc-bank.com/bins.php?categoryid=2 | |
// and by searching for "Use this to Encrypt your custom Amiibo NTag pastebin" to get the key file | |
byte dataBlock[] { | |
0x04, 0xe4, 0x39, 0x51, | |
0xe2, 0xd1, 0x64, 0x80, | |
0xd7, 0x48, 0x00, 0x00, | |
0xf1, 0x10, 0xff, 0xee, | |
0xa5, 0x00, 0x00, 0x00, | |
0xb5, 0xfe, 0xa9, 0x95, | |
0x11, 0x0c, 0x97, 0xa1, | |
0x41, 0x24, 0x95, 0x4f, | |
0xf7, 0xbe, 0x64, 0x03, | |
0x06, 0x5e, 0xf0, 0x1f, | |
0x0f, 0x00, 0x4d, 0x4e, | |
0xd9, 0x72, 0x8e, 0x4f, | |
0x39, 0xf9, 0x51, 0x57, | |
0x93, 0x13, 0x09, 0xaa, | |
0x29, 0xd7, 0xde, 0x13, | |
0x39, 0x39, 0xf2, 0x71, | |
0x3a, 0x49, 0xc0, 0xfa, | |
0x8c, 0x5f, 0x46, 0xc8, | |
0x21, 0x72, 0x94, 0x16, | |
0x08, 0x6e, 0x89, 0xda, | |
0xe3, 0x18, 0x10, 0x32, | |
0x02, 0x61, 0x00, 0x01, | |
0x00, 0x65, 0x05, 0x02, | |
0x30, 0x33, 0x34, 0x31, | |
0x50, 0x1b, 0x6f, 0x45, | |
0x7c, 0xbe, 0xa7, 0xec, | |
0xf2, 0x69, 0xfa, 0xee, | |
0x2f, 0x51, 0x06, 0xab, | |
0x97, 0x83, 0xb8, 0x51, | |
0x84, 0x04, 0x72, 0x11, | |
0x83, 0x1c, 0x83, 0x34, | |
0x50, 0x73, 0xb6, 0x77, | |
0x45, 0x99, 0x3c, 0x56, | |
0x2f, 0x5b, 0x25, 0xaf, | |
0xdb, 0xfc, 0x3c, 0x33, | |
0x2c, 0xb9, 0x29, 0xdc, | |
0xc8, 0x6c, 0xae, 0x1c, | |
0x2b, 0x44, 0x8a, 0x39, | |
0x1b, 0x65, 0xa4, 0x42, | |
0x89, 0x16, 0xf5, 0x20, | |
0x95, 0x3a, 0x0b, 0x79, | |
0x46, 0xa7, 0xd0, 0xd9, | |
0x08, 0x78, 0x0c, 0xa2, | |
0xc3, 0xc7, 0xe3, 0xbe, | |
0x05, 0x7d, 0x60, 0x46, | |
0xf3, 0x56, 0xac, 0x21, | |
0x85, 0xee, 0xb3, 0xd0, | |
0x4d, 0x68, 0x14, 0x9c, | |
0x38, 0xf6, 0x5e, 0x28, | |
0x8d, 0x4d, 0x0f, 0xc7, | |
0x16, 0x22, 0x46, 0xb2, | |
0x8e, 0x47, 0xe3, 0xf9, | |
0x75, 0x44, 0x9d, 0xfc, | |
0x91, 0xad, 0x1d, 0x69, | |
0x37, 0x66, 0x16, 0x88, | |
0x9b, 0x26, 0x06, 0x71, | |
0xdf, 0x21, 0x23, 0x2c, | |
0x9f, 0x75, 0x6e, 0x91, | |
0xd8, 0x11, 0x7b, 0xf7, | |
0x55, 0x6b, 0x3f, 0x8c, | |
0xcc, 0x0a, 0x37, 0xec, | |
0x68, 0x7b, 0x60, 0xb0, | |
0x3c, 0x6d, 0xfd, 0xe8, | |
0x11, 0x3d, 0xab, 0x08, | |
0x74, 0x01, 0x03, 0x2b, | |
0x00, 0x83, 0xc8, 0xbd, | |
0x32, 0x84, 0xb8, 0xa4, | |
0x46, 0x10, 0xf7, 0x72, | |
0x1e, 0xb7, 0xb5, 0x65, | |
0xc7, 0xb5, 0x03, 0xdc, | |
0x80, 0xd9, 0xd0, 0xad, | |
0x18, 0x1b, 0xe7, 0xae, | |
0xfa, 0x29, 0x65, 0x6c, | |
0x7e, 0x22, 0xf1, 0x12, | |
0xb7, 0xaf, 0x62, 0xc1, | |
0x2e, 0x0a, 0xff, 0x38, | |
0x84, 0x50, 0x9f, 0xbd, | |
0x4c, 0x66, 0x11, 0xee, | |
0xdf, 0xe2, 0x1f, 0xc2, | |
0x1b, 0xd8, 0x6e, 0x56, | |
0x54, 0x05, 0x94, 0x3c, | |
0x39, 0xd3, 0xac, 0x85, | |
0xd8, 0x60, 0xec, 0x48, | |
0xd8, 0x73, 0x9e, 0x2b, | |
0xe9, 0xd0, 0x51, 0xeb, | |
0xda, 0xc5, 0xd3, 0x6b, | |
0x59, 0x95, 0x33, 0x72, | |
0x77, 0xb3, 0x9d, 0xc6, | |
0x38, 0xff, 0x26, 0x1b, | |
0xd3, 0xce, 0xd6, 0xcf, | |
0xf7, 0x65, 0x97, 0x88, | |
0x40, 0x3c, 0x39, 0x89, | |
0xbf, 0x0c, 0x1e, 0x07, | |
0x2f, 0x36, 0xbf, 0xd8, | |
0xb9, 0x85, 0x16, 0x9e, | |
0x08, 0xec, 0x03, 0x2e, | |
0x3e, 0xa0, 0xac, 0x62, | |
0xdc, 0xa2, 0x0f, 0xdc, | |
0x15, 0xc9, 0x35, 0xb1, | |
0xff, 0xa8, 0xc4, 0xdc, | |
0xb8, 0x59, 0xdc, 0x28, | |
0x23, 0x3f, 0xa8, 0x96, | |
0x3d, 0x68, 0xce, 0x7c, | |
0x1b, 0x82, 0xe2, 0x56, | |
0xe5, 0x9b, 0x3d, 0xbb, | |
0xd8, 0x82, 0xc5, 0xd1, | |
0x23, 0xa6, 0x13, 0xff, | |
0x76, 0x88, 0xd5, 0xa9, | |
0xa3, 0x01, 0x80, 0x78, | |
0x21, 0x38, 0x9b, 0x1e, | |
0x10, 0x5e, 0x48, 0xa8, | |
0xe9, 0x99, 0x5a, 0x0a, | |
0x8b, 0xe1, 0xf2, 0xb8, | |
0x35, 0x19, 0x77, 0x25, | |
0x59, 0xfa, 0x14, 0xb4, | |
0x47, 0xce, 0x5d, 0xb2, | |
0xff, 0x94, 0x0d, 0xec, | |
0xbe, 0xa2, 0x8b, 0xcf, | |
0x48, 0x71, 0xfc, 0xfa, | |
0xbf, 0x8c, 0x8f, 0x8e, | |
0x6e, 0xe2, 0x60, 0xda, | |
0xe6, 0x45, 0xbc, 0x43, | |
0xad, 0xb4, 0x24, 0x4c, | |
0x53, 0xd4, 0xf2, 0xe7, | |
0xc1, 0x8a, 0x46, 0x37, | |
0xc6, 0x18, 0x42, 0x70, | |
0xb4, 0x8d, 0xcd, 0xe8, | |
0xb4, 0xe2, 0x68, 0x72, | |
0x19, 0xf1, 0x54, 0x39, | |
0x54, 0x8f, 0x51, 0xf1, | |
0x00, 0x00, 0x00, 0xbd, | |
0x00, 0x00, 0x00, 0x04, | |
0x5f, 0x00, 0x00, 0x00, | |
0xac, 0xbd, 0x2c, 0x04, | |
0x80, 0x80, 0x00, 0x00 | |
}; | |
void setup(void) { | |
Serial.begin(115200); | |
Serial.println("Hello!"); | |
nfc.begin(); | |
uint32_t versiondata = nfc.getFirmwareVersion(); | |
if (! versiondata) { | |
Serial.print("Didn't find PN53x board"); | |
while (1); // halt | |
} | |
// Got ok data, print it out! | |
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); | |
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); | |
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC); | |
Serial.print("Please feed me an NFC tag..."); | |
} | |
void loop(void){ | |
uint8_t success; | |
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID | |
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type) | |
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found | |
// 'uid' will be populated with the UID, and uidLength will indicate | |
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight) | |
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength); | |
if (success) { | |
// Display some basic information about the card | |
Serial.println("Found an ISO14443A card"); | |
Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes"); | |
Serial.print(" UID Value: "); | |
nfc.PrintHex(uid, uidLength); | |
Serial.println(""); | |
// Write main data – the function takes 4 bytes at a time | |
for (byte page = 3; page < pages; page++) { | |
// Write data to the page | |
for (byte i = 0; i < 4; i++) { | |
data[i] = dataBlock[shift + i]; | |
} | |
Serial.print("Writing page...");Serial.println(page, DEC); | |
nfc.PrintHexChar(data, 4); | |
success = nfc.ntag2xx_WritePage(page, data); | |
if(!success) { | |
Serial.println("ehhhh that didn't fucking work..."); | |
while(1); //halt | |
} | |
shift = shift + 4; | |
} | |
} | |
Serial.print("Done."); | |
while(1); // halt | |
} | |
Example output:
Hello!
Found chip PN532
Firmware ver. 1.6
Found an ISO14443A card
UID Length: 7 bytes
UID Value: 0x04 0xE4 0x39 0xE2 0xD1 0x64 0x80
Writing page...3
F1 10 FF EE ⸮.⸮⸮
Writing page...4
A5 00 00 00 ⸮...
Writing page...5
B5 FE A9 95 ⸮⸮⸮⸮
Writing page...6
11 0C 97 A1 ..⸮⸮
Writing page...7
41 24 95 4F A$⸮O
Writing page...8
F7 BE 64 03 ⸮⸮d.
Writing page...9
06 5E F0 1F .^⸮.
Writing page...10
0F 00 4D 4E ..MN
Writing page...11
D9 72 8E 4F ⸮r⸮O
Writing page...12
39 F9 51 57 9⸮QW
Writing page...13
93 13 09 AA ⸮..⸮
Writing page...14
29 D7 DE 13 )⸮⸮.
Writing page...15
39 39 F2 71 99⸮q
Writing page...16
3A 49 C0 FA :I⸮⸮
Writing page...17
8C 5F 46 C8 ⸮_F⸮
Writing page...18
21 72 94 16 !r⸮.
Writing page...19
08 6E 89 DA .n⸮⸮
Writing page...20
E3 18 10 32 ⸮..2
Writing page...21
02 61 00 01 .a..
Writing page...22
00 65 05 02 .e..
Writing page...23
30 33 34 31 0341
Writing page...24
50 1B 6F 45 P.oE
Writing page...25
7C BE A7 EC |⸮⸮⸮
Writing page...26
F2 69 FA EE ⸮i⸮⸮
Writing page...27
2F 51 06 AB /Q.⸮
Writing page...28
97 83 B8 51 ⸮⸮⸮Q
Writing page...29
84 04 72 11 ⸮.r.
Writing page...30
83 1C 83 34 ⸮.⸮4
Writing page...31
50 73 B6 77 Ps⸮w
Writing page...32
45 99 3C 56 E⸮<V
Writing page...33
2F 5B 25 AF /[%⸮
Writing page...34
DB FC 3C 33 ⸮⸮<3
Writing page...35
2C B9 29 DC ,⸮)⸮
Writing page...36
C8 6C AE 1C ⸮l⸮.
Writing page...37
2B 44 8A 39 +D⸮9
Writing page...38
1B 65 A4 42 .e⸮B
Writing page...39
89 16 F5 20 ⸮.⸮
Writing page...40
95 3A 0B 79 ⸮:.y
Writing page...41
46 A7 D0 D9 F⸮⸮⸮
Writing page...42
08 78 0C A2 .x.⸮
Writing page...43
C3 C7 E3 BE ⸮⸮⸮
Writing page...44
05 7D 60 46 .}`F
Writing page...45
F3 56 AC 21 ⸮V⸮!
Writing page...46
85 EE B3 D0 ⸮⸮⸮
Writing page...47
4D 68 14 9C Mh.⸮
Writing page...48
38 F6 5E 28 8⸮^(
Writing page...49
8D 4D 0F C7 ⸮M.⸮
Writing page...50
16 22 46 B2 ."F⸮
Writing page...51
8E 47 E3 F9 ⸮G⸮⸮
Writing page...52
75 44 9D FC uD⸮⸮
Writing page...53
91 AD 1D 69 ⸮⸮.i
Writing page...54
37 66 16 88 7f.⸮
Writing page...55
9B 26 06 71 ⸮&.q
Writing page...56
DF 21 23 2C ⸮!#,
Writing page...57
9F 75 6E 91 ⸮un⸮
Writing page...58
D8 11 7B F7 ⸮.{⸮
Writing page...59
55 6B 3F 8C Uk?⸮
Writing page...60
CC 0A 37 EC ⸮.7⸮
Writing page...61
68 7B 60 B0 h{`⸮
Writing page...62
3C 6D FD E8 <m⸮⸮
Writing page...63
11 3D AB 08 .=⸮.
Writing page...64
74 01 03 2B t..+
Writing page...65
00 83 C8 BD .⸮Ƚ
Writing page...66
32 84 B8 A4 2⸮⸮⸮
Writing page...67
46 10 F7 72 F.⸮r
Writing page...68
1E B7 B5 65 .⸮⸮e
Writing page...69
C7 B5 03 DC ǵ.⸮
Writing page...70
80 D9 D0 AD ⸮⸮Э
Writing page...71
18 1B E7 AE ..⸮
Writing page...72
FA 29 65 6C ⸮)el
Writing page...73
7E 22 F1 12 ~"⸮.
Writing page...74
B7 AF 62 C1 ⸮⸮b⸮
Writing page...75
2E 0A FF 38 ..⸮8
Writing page...76
84 50 9F BD ⸮P⸮⸮
Writing page...77
4C 66 11 EE Lf.⸮
Writing page...78
DF E2 1F C2 ⸮⸮.⸮
Writing page...79
1B D8 6E 56 .⸮nV
Writing page...80
54 05 94 3C T.⸮<
Writing page...81
39 D3 AC 85 9Ӭ⸮
Writing page...82
D8 60 EC 48 ⸮`⸮H
Writing page...83
D8 73 9E 2B ⸮s⸮+
Writing page...84
E9 D0 51 EB ⸮⸮Q⸮
Writing page...85
DA C5 D3 6B ⸮⸮⸮k
Writing page...86
59 95 33 72 Y⸮3r
Writing page...87
77 B3 9D C6 w⸮⸮⸮
Writing page...88
38 FF 26 1B 8⸮&.
Writing page...89
D3 CE D6 CF ⸮⸮⸮⸮
Writing page...90
F7 65 97 88 ⸮e⸮⸮
Writing page...91
40 3C 39 89 @<9⸮
Writing page...92
BF 0C 1E 07 ⸮...
Writing page...93
2F 36 BF D8 /6⸮⸮
Writing page...94
B9 85 16 9E ⸮⸮.⸮
Writing page...95
08 EC 03 2E .⸮..
Writing page...96
3E A0 AC 62 >⸮⸮b
Writing page...97
DC A2 0F DC ܢ.⸮
Writing page...98
15 C9 35 B1 .⸮5⸮
Writing page...99
FF A8 C4 DC ⸮⸮⸮⸮
Writing page...100
B8 59 DC 28 ⸮Y⸮(
Writing page...101
23 3F A8 96 #?⸮⸮
Writing page...102
3D 68 CE 7C =h⸮|
Writing page...103
1B 82 E2 56 .⸮⸮V
Writing page...104
E5 9B 3D BB ⸮=⸮
Writing page...105
D8 82 C5 D1 ⸮⸮
Writing page...106
23 A6 13 FF #⸮.⸮
Writing page...107
76 88 D5 A9 v⸮թ
Writing page...108
A3 01 80 78 ⸮.⸮x
Writing page...109
21 38 9B 1E !8⸮.
Writing page...110
10 5E 48 A8 .^H⸮
Writing page...111
E9 99 5A 0A ⸮Z.
Writing page...112
8B E1 F2 B8 ⸮⸮⸮
Writing page...113
35 19 77 25 5.w%
Writing page...114
59 FA 14 B4 Y⸮.⸮
Writing page...115
47 CE 5D B2 G⸮]⸮
Writing page...116
FF 94 0D EC ⸮⸮.⸮
Writing page...117
BE A2 8B CF ⸮⸮⸮⸮
Writing page...118
48 71 FC FA Hq⸮⸮
Writing page...119
BF 8C 8F 8E ⸮⸮⸮⸮
Writing page...120
6E E2 60 DA n⸮`⸮
Writing page...121
E6 45 BC 43 ⸮E⸮C
Writing page...122
AD B4 24 4C ⸮⸮$L
Writing page...123
53 D4 F2 E7 S⸮⸮⸮
Writing page...124
C1 8A 46 37 ⸮⸮F7
Writing page...125
C6 18 42 70 ⸮.Bp
Writing page...126
B4 8D CD E8 ⸮⸮⸮⸮
Writing page...127
B4 E2 68 72 ⸮⸮hr
Writing page...128
19 F1 54 39 .⸮T9
Writing page...129
54 8F 51 F1 T⸮Q⸮
Writing page...130
00 00 00 BD ...⸮
Writing page...131
00 00 00 04 ....
Writing page...132
5F 00 00 00 _...
Writing page...133
AC BD 2C 04 ⸮⸮,.
Writing page...134
80 80 00 00 ⸮⸮..
Done.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment