Skip to content

Commit 59f2507

Browse files
authored
Merge pull request #11 from tusker-tools/main
Improve compatibility for BMW remote page reading (support PCF7945, PCF7944 and 26A0700)
2 parents fefebc6 + d559285 commit 59f2507

4 files changed

Lines changed: 34 additions & 18 deletions

File tree

Arduino/hitaguino/hitaguino.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
/* 4MHz clock output for PCF7991 ABIC */
1313
#if defined(__AVR_ATmega328P__) // Setting for Arduino Nano and Pro Mini
1414
const int CLKOUT = 3;
15-
#elif(__AVR_ATmega2560__) // Setting for Arduino Nano and Pro Mini
15+
#elif(__AVR_ATmega2560__) // Setting for Arduino Mega 2560
1616
const int CLKOUT = 9;
1717
#endif
1818

1919
const int SCK_pin = 6;
2020
const int dout_pin = 7;
21-
//const int din_pin = 21; // Arduino Mega2560 original value 21 Mega2560 can also use 2
22-
const int din_pin = 2; //Use with Arduino Nano
23-
//Note: din_pin must have external interrupt feature!
21+
const int din_pin = 2; //Note: din_pin must have external interrupt feature!
2422
const int test_pin = 4;
2523

2624
const char hitagerVersion[] = {"211"}; // Major Version, Minor Version, Fix

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Additional infos can be found at the homepage of the project initiator's [websit
44

55
## Main Features:
66
- Supported Protocols:
7-
- Hitag2, Hitag2+EE, Hitag2 Extended, Hitag2 BMW Extention
7+
- Hitag2, Hitag2+EE, Hitag2 Extended, Hitag2 BMW EE Extention
88
- Hitag3
99
- Hitag AES
1010
- Hitag Pro
@@ -24,34 +24,36 @@ AESHitager PC <-------> Arduino <-------> PCF7991 IC <- - - - -> Key Transponder
2424

2525
1. **Arduino**
2626
- Download the latest Hitaguino release from the Github page
27-
- **Option 1:**
27+
- **Flash Arduino (Option 1):**
2828
Use Avrdudess (https://github.com/ZakKemble/AVRDUDESS, ~2MB) for uploading the .hex file only (Select "Arduino" as Programmer, Select proper COM Port, Baud Rate "115200", select .hex file in "Flash" section, click Go, wait until programming finished)
2929

30-
- **Option 2:**
30+
- **Flash Arduino (Option 2):**
3131
Open the .ino file in your arduino IDE, compile & upload it to the board
3232

3333
**Hint:** It might be necessary to press and release the reset button on the araduino board shortly before upload process starts.
3434

3535
2. **RFID Reader**
3636
It is possible to use any available PCB containing a PCF7991 base station IC (ABIC). The cheapest solution seems to be IPROG RFID Adapter (available for ~ 15$)
3737

38-
| Arduino Pin | PCF7991 Pin Nr. | ABIC Pin Name | IPROG D-SUB PIN |
38+
| Arduino Nano Pin | PCF7991 Pin Nr. | PCF7991 Pin Name | IPROG D-SUB PIN |
3939
| :------------: | :----------: | :-----------: | :-------------: |
4040
| D2 | 10 | DOUT | 5 |
4141
| D7 | 9 | DIN | 3 |
4242
| D6 | 8 | CLK | 4 |
43-
| D3 (optional) | 6 | XTAL1 | 20 |
43+
| D3 / D9* (optional) | 6 | XTAL1 | 20 |
4444
| GND (optional) | (see Hint) | (see Hint) | 36 |
4545
| VCC / +5V | - | - | 32 |
4646

47+
\* : For Arduino Mega 2560
48+
4749
<img src="/documentation/PCF7991_Footprint.JPG" width=30% height=30%>
4850

4951
**Hint 1:**
5052
Connecting D3 is only required if the ABIC is not supplied with clock source (e.g. Crystal Oscillator) on the PCB. In this case, Arduino's clock output can be used.
5153
**Hint 2:**
5254
Connecting GND is only required if not connected via USB. In this case connect Arduino GND to PCB GND (not directly at ABIC GND pin)
5355

54-
**Variants:**
56+
**Hardware Variants:**
5557
- **Hitag2 v3.1, ZedBull Mini** (and others boards with on-board crystal oscillator and µC):
5658
- Connect Arduino according to table
5759
- Do not connect D3, as clock source is already present at the PCB
@@ -60,5 +62,6 @@ AESHitager PC <-------> Arduino <-------> PCF7991 IC <- - - - -> Key Transponder
6062
- **IPROG RFID Adapter**
6163
- The adapter can be used without any modification on the PCB
6264
- Connect with arduino according to table column "IPROG D-Sub Pin" <br>
63-
<br>
64-
<img src="/documentation/D_SUB_44_IPROG_Connector.jpg" width=50% height=50%>
65+
- Below the schematic of the Iprog PCB:
66+
<img src="https://user-images.githubusercontent.com/82545992/183724661-752b45e0-bc28-4f21-9efb-90c9170f3230.png" width=30% height=30%>
67+

sources/Hitager/BmwHt2.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public string readBlocks(int blockAddressStart, int blockAddressEnd)
155155

156156
for (int j = blockAddressStart; j <= blockAddressEnd; j++)
157157
{
158+
bool LvSpclPrcdRead = false; // "Special procedure required"indicator
158159
/* Select the block */
159160
if (!(j == 0 || j == 31))
160161
{
@@ -178,18 +179,32 @@ public string readBlocks(int blockAddressStart, int blockAddressEnd)
178179
{
179180
String received = "00000000";
180181

182+
181183
if (((j == 14 && i == 7) || j == 31))
182184
{
183185
/* Not readable pages */
184186
received = "B1B1B1B1";
185187
}
186188
else if (j == 15 || j==0)
187189
{
188-
/* Special procedure for reading protected block PCF7944 5WK49121 */
189-
Thread.Sleep(10);
190-
sendCmdUntilResponse("i0540", "FFFFFFE8", 5);
191-
Thread.Sleep(10);
192-
received = ReadPage(i);
190+
if(LvSpclPrcdRead == false)
191+
{
192+
received = ReadPage(i);
193+
}
194+
195+
if (received.Equals("B1B1B1B1") || LvSpclPrcdRead==true)
196+
{
197+
/* Try Special procedure for reading protected block PCF7944 5WK49121 */
198+
Thread.Sleep(10);
199+
sendCmdUntilResponse("i0540", "FFFFFFE8", 5);
200+
Thread.Sleep(10);
201+
received = ReadPage(i);
202+
if (!received.Equals("B1B1B1B1"))
203+
{
204+
/* If special reading procedure was successful, remember this for next block */
205+
LvSpclPrcdRead = true;
206+
}
207+
}
193208
}
194209
else
195210
{

sources/Hitager/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
[assembly: AssemblyTrademark("")]
1818
[assembly: AssemblyCulture("")]
1919

20-
[assembly: AssemblyVersion("1.3.1.*")]
20+
[assembly: AssemblyVersion("1.3.2.*")]
2121

2222
[assembly: ComVisible(false)]
2323
[assembly: NeutralResourcesLanguage("en-US")]

0 commit comments

Comments
 (0)