Hello, maybe someone can help me.
I am working with Flowcode 8.2.2.15 and am currently experimenting a bit with the file MFRC522_Read_Write.fcfx from the entry:
viewtopic.php?f=63&t=19788&p=86494&hili ... ite#p86494
Reading out the UID works, but I can't handle the authentication. I always get an error message.
I tried 6x 0xFF as key and also 6x 0xFF and 4x the UID, i.e. a total of 10 bytes, as stated in the reader description:
• Authentication command code (60h, 61h)
• Block address
• Sector key byte 0
• Sector key byte 1
• Sector key byte 2
• Sector key byte 3
• Sector key byte 4
• Sector key byte 5
• Card serial number byte 0
• Card serial number byte 1
• Card serial number byte 2
• Card serial number byte 3
I use the Mifare NFC card reader module.
Does anyone have some good tips or a working process? Of course, I would also like to save data to the Tag and then read it out again for verification.
thanks
Christina
MFRC522 authentication problem
Moderator: Benj
Re: MFRC522 authentication problem
No one here in the forum who can help me?
There is always an authentication error:
Error 3 if I use the 6 bytes 0xFF and an error 1 if I use 6x 0xFF and the 4 UID bytes.
Here the file, changes mainly in the display.
Christina
There is always an authentication error:
Error 3 if I use the 6 bytes 0xFF and an error 1 if I use 6x 0xFF and the 4 UID bytes.
Here the file, changes mainly in the display.
Christina
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: MFRC522 authentication problem
Hi Tiny,
Tried your code on an Arduino and it seems to run AOK (at least with software SPI - I'm getting more convinced there is a fault with the hardware SPI code here) - I get Auth OK, Write Ok, read Ok and read/write ok - sometimes select error, sometimes auth error - but usually works.
I didn't change anything (except to delete the out->e2 and change the pins for the attached reader and display. - I happened to have an Arduino set up with card reader and the same i2c display !
Where are you getting the problem?
I've little experience of writing to the cards - my one attempt resulted in locking the card after my attempt to change the code for a block?
Martin
Tried your code on an Arduino and it seems to run AOK (at least with software SPI - I'm getting more convinced there is a fault with the hardware SPI code here) - I get Auth OK, Write Ok, read Ok and read/write ok - sometimes select error, sometimes auth error - but usually works.
I didn't change anything (except to delete the out->e2 and change the pins for the attached reader and display. - I happened to have an Arduino set up with card reader and the same i2c display !
Where are you getting the problem?
I've little experience of writing to the cards - my one attempt resulted in locking the card after my attempt to change the code for a block?
Martin
Re: MFRC522 authentication problem
Hello Martin,
Thanks for the answer!
I can only test this routine on a PIC (ECIO40P16), I have no other platform.
SPI and I2C runs on software. Reading the UID and card type is no problem, but authentication always results in an error message. Of course, write and read do not work with this.
I looked at a few Arduino sketches on the Internet, there is always a select command before authentication. There is also the macro in FC, but what are ValidBits? Which value belongs here or is this command necessary?
I used a new and a used / formatted tag. With an NFC reader / writer on the smartphone, it also works without any problems, the day can be written and read.
Christina
Thanks for the answer!
I can only test this routine on a PIC (ECIO40P16), I have no other platform.
SPI and I2C runs on software. Reading the UID and card type is no problem, but authentication always results in an error message. Of course, write and read do not work with this.
I looked at a few Arduino sketches on the Internet, there is always a select command before authentication. There is also the macro in FC, but what are ValidBits? Which value belongs here or is this command necessary?
I used a new and a used / formatted tag. With an NFC reader / writer on the smartphone, it also works without any problems, the day can be written and read.
Christina
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: MFRC522 authentication problem
Hi Christina,
From the datasheet....
Martin
From the datasheet....
However - you seem to have hardcoded the serial number (3a,35,71,25) - is this is what you intended to do (one card to test) - or should this be set to the four UID bytes read?MFAuthent
This command manages MIFARE authentication to enable a secure communication to
any MIFARE Mini, MIFARE 1K and MIFARE 4K card. The following data is written to the
FIFO buffer before the command can be activated:
• Authentication command code (60h, 61h)
• Block address
• Sector key byte 0
• Sector key byte 1
• Sector key byte 2
• Sector key byte 3
• Sector key byte 4
• Sector key byte 5
• Card serial number byte 0
• Card serial number byte 1
• Card serial number byte 2
• Card serial number byte 3
In total 12 bytes are written to the FIFO.
Remark: When the MFAuthent command is active all access to the FIFO buffer is
blocked. However, if there is access to the FIFO buffer, the ErrorReg register’s WrErr bit is
set.
This command automatically terminates when the MIFARE card is authenticated and the
Status2Reg register’s MFCrypto1On bit is set to logic 1.
This command does not terminate automatically if the card does not answer, so the timer
must be initialized to automatic mode. In this case, in addition to the IdleIRq bit, the
TimerIRq bit can be used as the termination criteria. During authentication processing, the
RxIRq bit and TxIRq bit are blocked. The Crypto1On bit is only valid after termination of
the MFAuthent command, either after processing the protocol or writing Idle to the
CommandReg register.
If an error occurs during authentication, the ErrorReg register’s ProtocolErr bit is set to
logic 1 and the Status2Reg register’s Crypto1On bit is set to logic 0
Martin
Re: MFRC522 authentication problem
Hi Martin,
the UID is only hardcoded for the test, if it works, depending on the application, up to 10 UID are stored in an EEprom and already compared with the EEprom data during the UID query. This ensures that only registered tags can be used. Then I would like to write an 8-digit UID on the card and also verify it, but for the time being this is only for test purposes.
For the used / formatted card the authorization string is 6x 0x00, for the new card 6x 0xFF and before a test run I activate the corresponding entries in the program.
No matter which card, error 1 or 3.
Christina
the UID is only hardcoded for the test, if it works, depending on the application, up to 10 UID are stored in an EEprom and already compared with the EEprom data during the UID query. This ensures that only registered tags can be used. Then I would like to write an 8-digit UID on the card and also verify it, but for the time being this is only for test purposes.
For the used / formatted card the authorization string is 6x 0x00, for the new card 6x 0xFF and before a test run I activate the corresponding entries in the program.
No matter which card, error 1 or 3.
Christina