-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LF Sim Timing issues #72
Comments
I investigated LF Sim a bit in depth a while ago, and my conclusion was the following... Could you elaborate on what you did to get the images above? Are you using two pm3:s ? |
my guess is we need to use a different clock calculation. (possibly instead of bit-bang, modulate or demodulate for x clock periods for each wave, where x is 1/2 the given wave length) unfortunately I'm very new to the clocks and their uses. |
i'm using 2 PM3's one to sim one to read. |
maybe I should snoop the sim to a real reader... I can look at that. |
Here's the forum thread where I looked into it |
I just re-read the info, and I do believe we need an internal clock, or I suppose fix the carrier clock detection. can we re-use some of the info used for hitag? |
We should use the carrier clock, as that one kind of per definition is correct - it's the clock the reader expects, whether it's correct according to NIST standards or not... |
i'm attempting to learn. ;) as I said above I can hack it and get ASK to work above RF/16 clocks. |
I can try to capture some traces, with a rfidler generating a 125khz wave, and measuring the ssp_clk from the FPGA debug output, with the pm3 in LF simulation-mode (but not modulating). If I use a DSO to measure the carrier wave and the FPGA output, it would be possible to see if the FPGA somehow misses a step in the carrier sometimes or if the error is somewhere else. |
I cannot prove it yet, but it appears to mainly happen during a modulation transition. When it switches high to low or low to high. So I'm not sure you will see something. But it is a very good test to verify it is working as it should when not modulating so we can rule that out. |
I think I may have fixed the bit transition issue noted in my first post. it appears a true tags wave begins low 00001111 and 0000011111, so I flipped them (in my fork). but we still have the timing issues. now maybe a 25V antenna works perfectly... ??? but too strong or too weak and your stuck? |
just thought I'd explain what I experimented with to get ask simulation working somewhat: to simulate EM41xx ask/man tags I built a new function SimulateTagLowFrequencyMM. the only change that really made a difference was to test if we just transitioned from a high to low or from low to high and then skip the "wait for reader carrier to go low" loop. it appears to me when we are transitioning, either the modulating of the coil takes too long and we miss the carrier low, or it interferes with reading the carrier low. (or it has nothing to do with that and it just effectively removes 2 samples per wave that we somehow picked up by mistake) this gets lf simask working above rf/16 clock rates. but this is a band-aide and does not really address the clock issue. |
http:https://www.proxmark.org/forum/viewtopic.php?pid=2670#p2670 does this still apply to our clock? |
based on this: http:https://www.proxmark.org/forum/viewtopic.php?pid=6021#p6021 |
it appears the issues where there prior to the break out of LF and HF fpga code, (and the wave cleaning). I loaded code from 6/17/2014 before the FPGA split,(fpga from 2/25/2014) and the "extra" samples per wave were there. |
It would be very simple now that we have unused modes... Address wise... |
Regarding my last comment, see here. |
I looked at the code now, the lo_simulate is still there. You can try to just use that mode instead, and see if it works better. lo_simulate was very similar to lf_edge_detect back then, the change just added support for both doing reader modulations OR lf sims, whereas earleir it was just lf sim. One other notable thing changed, as far as I can see. Before:
After:
See what happened there? The thresholds for determining the carrier state changed, from 64,200 into 70,190. I don't know the reasoning behind that. The current code, in lo_edge_detect is more complicated, based on izsh's algorithms. Anyway, just switching mode to use lo_simulate looks very simple, no fpga coding needed. |
Just looking at the code, I don't believe the problem is on the "output"-side, that is, our intended signals being corrupted. The ARM-signals go pretty much directly to the coils:
As you can see The Therefore, I'm leaning towards some problem in the carrier detection. |
Ah, I may be totally off. When we're doing sims, we're not looking at |
How do I try the lo_simulate mode? It doesn't seem to have a mode? |
Could it just be the time it takes to power up the coil? Would a larger antenna coil take longer to power up? Longer than a 1/2 a clock cycle? |
To answer myself, No, it should not be waiting for the coil to fully modulate when you call high or low. I don't think... |
The coil powering up could be the reason... But it is just the transition that will trigger 1 / 0 ? |
If there is a delay of some sort during modulation it would be during a transition from open to shorted or visa versa. And this would explain why my code now works with waves that have fewer transitions (ask RF/32 and above) but why would the code wait for the coil and not just set the bit to on or off and continue? |
Depends on how the lf_detect &pr lf_simulate modes works I guess. The file lo_simulate.v needs to be in the makefile for the fpga.. and hooked in with the FPGA_LF_SIMULATE (1<<2) in armsrc/apps.h |
Yeah, sorry, code is there but not addressable... And afaict, no delay, no logic, no clock... |
Sounds like it should be fairly easy to reuse lo_simulate. I'd like to try it and see if it functions any differently. Holiman do you have a FPGA build environment? Is that something we could test? |
Yes, I can enable it. May take a few days |
Understood, and thanks. It might not fix it but it will rule it out. I don't like not being able to see a problem in the code. :( in the mean time I will continue testing antennas to see their affects on this. |
Darn phone... Wrong button |
the assignments for pwr_oeX are a bit different between the lo_simulate.v and lo_edge_detect.
unfortunately I do not yet understand what each of these do or why pwr_oe3 and pwr_oe1 were flipped. |
During simulation the
If someone would try this in lo_edge_detect - unfortunately I can't test LF:
|
I would love to help out, but I don't have a working fpga development environment. |
@pwpiwi, great analysis, probably spot on. I can make a new fpga and send to marshmellow for testing |
And yes, we have a winner, marshmellow just confirmed. Well done! |
the waves look beautiful! I've confirmed good FSK (HID) simulating against 5 different valid readers. it is consistent and reliable. |
while we are on the subject of powering the lf antenna, I was looking at the NRZ/Direct modulation. it appears to normally stay half modulated and modulate full or off to indicate a bit. is there anyway we can support this? |
Where is all this information of the inner workings of the fpga and its use with the pm3? Can someone make a write-up? With technical details or system documentation? I don't read verilog, so this would help my understanding a lot. |
@iceman: depends what you mean with "inner workings". Its a programmable device and Its function is determined by the verilog sources. Together with the PM3 schematic this is the only documentation available. However, if you are interested in the FPGA inner structure then google for the datasheet (Xilinx DS001 Spartan II). @marshmellow42: Do you have a reference (link) to the NRZ/direct modulation you are looking for? |
@iceman ; I didn't have a clue about how Verilog functions a few months back. But it's fairly simple to read some tutorials and pick it up. The main concepts could be explained in a page or two, so it's pretty easy to reach the level of being able to comprehend written code - a bit more to write it yourself. But coming from a software background, I also have difficulties understanding the hardware portions, and the boundaries between hardware and software. I've not looked at the pm3 schematic. @pwpiwi - what free/opensource tools would you recommend to view and make sense of the schematics? |
oh, and perhaps you haven't notived. But after I fixed iclass full simulation, I tagged a version 2.0.0-rc1. With this fix in place, I tagged it as 2.0.0-rc2. Anything else we want included in 2.0.0-final? |
@holiman For me, the hardware connections into the software is just "automagic". I'm totally lost there. My idea was to start understanding it but it seems like I need dev environment for Verilog too.. regarding the rc2, I suggest you get the new stuff from @marshmellow42 into it. @pwpiwi Your extended knowledge over the software borders to the hardware side, gives you a more complete picture than I ever can get from just looking at the software side. |
I meant the schematics in doc/proxmark3_schema.pdf. I am recommending Adobe Reader to view and make sense of the schematics 😀. |
For verilog compilation, yes you need a dev env. I use an old win xp virtual machine setup for the purpose, but all I do withini it is copy the code from linux to windows, run go.bat, copy back (via shared folders). For experimentation with verilog, you can use some open source tools. Or just do it the hard way, modify via editors, generate an FPGA-image, flash, test. Works well for small things, like this one here. |
@holiman for tagging I'd like to finish my Sim commands and see if I can finish the patch to em410x Sim. I will test psk Sim later today. And might be ready for a pull after that. @piwi, for NRZ/Direct the best I have is the traces in the traces folder and my experimenting with the ata5577 chip. I know how to demod it, and have built a demod function for it. I've only ever seen one tag from an unknown system use it. |
I've finished the sim commands i can build (missing NRZ/Direct), as well as a few fixes - including for the em410xsim and lf sim. (as well as other fixes i've had in my fork for a while.) |
I have another FPGA bugfix in hi_iso14443.v in testing and will commit on Monday morning. Together with @marshmellow42's last fixes this should go into 2.0.0-final. And I might commit the fix for issue #73 on Monday evening... |
Couldn't continue with testing yesterday. @holiman: up to you to decide when you want to do the "final" tagging. I personally don't care if these fixes go to 2.0.0.-final or the next release. I am quite sure that these won't be the last fixes anyway... |
Pushed two commits. |
I've been testing the LF sim functions to see why they are so erratic as to their functionality.
I believe it comes down to the use of the clock in SimulateTagLowFrequency.
could someone explain what GPIO_SSC_CLK measures?
let me illustrate the issue:
a standard HID FSK2a tag should have waves 10 samples and 8 samples long depending on whether it is bit 1 or bit 0. so digitally it should be 1111100000 and 11110000.
if this is sent through the SimulateTagLowFrequncy the output has 2 errors.
so our clock is too slow
So going from 1111000011110000 to 1111100000 translates 11110000001111100000 (added 2 extra 0 bits)
img1: bad timing:
![fsk-sim-bad timing](https://cloud.githubusercontent.com/assets/9687156/6419550/2a65544a-be8c-11e4-82e8-b9ffa310a5d0.JPG)
img2: bad transition:
![fsk-sim-bad bit transition](https://cloud.githubusercontent.com/assets/9687156/6419557/357e32c0-be8c-11e4-96bd-1d9095f39548.JPG)
any thoughts?
I can get ASK clocks of 32 or greater to work fine but the lower the clock the worse this affects things.
The text was updated successfully, but these errors were encountered: