From: iceman1001 Date: Fri, 24 Feb 2017 14:45:24 +0000 (+0100) Subject: CHG: @marshmellow42 's changes to lfops.c /lfsampling.c X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/17556415a96c983ce0894adc9af64a026878195c CHG: @marshmellow42 's changes to lfops.c /lfsampling.c CHG: updated CHANGELOG.md --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 364549c9..b66db046 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,19 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... -## [unreleased][unreleased] - - `lf em4x em4x50***` refactoring of em4x50 commands. (iceman) +## [unreleased][unreleased] + - correctly using stdtypes.h printf and scanf format string macros (PRIx64 et al) (pwpivi) + - fix linker warning re missing entry point when linking fullimage.elf (pwpivi) + - small changes to lf psk and fsk demods to improve results when the trace begins with noise or the chip isn't broadcasting yet (marshmellow) + - NOTE CHANGED ALL `lf em4x em*` cmds to simpler `lf em ` - example: `lf em4x em410xdemod` is now `lf em 410xdemod` + - Renamed and rebuilt `lf em readword` && readwordpwd to `lf em 4x05read` - it now demods and outputs the read block (marshmellow/iceman) + - Renamed and rebuilt `lf em writeword` && writewordpwd to `lf em 4x05write` - it now also reads validation output from the tag (marshmellow/iceman) + - Fixed bug in lf sim and continuous demods not turning off antenna when finished + - Added lua script path fixes (pwpivi) + - `lf search` - Added EM4x05/EM4x69 chip detection (marshmellow) + - Added lf em 4x05dump command to read and output all the blocks of the chip (marshmellow) + - Added lf em 4x05info command to read and display information about the chip (marshmellow) + - `lf em4x em4x50***` refactoring of em4x50 commands. (iceman) ## [1.6.9][icemanfork] [2017-02-06] - Serial speedup, if possible 408600baud otherwise default to 115200baud (iceman) @@ -113,11 +124,11 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Adjusted lf t55xx dump to allow overriding the safety check and warning text (marshmellow) - Adjusted lf t55xx write input variables (marshmellow) - Adjusted lf t55xx read with password safety check and warning text and adjusted the input variables (marshmellow & iceman) -- Adjusted LF FSK demod to account for cross threshold fluctuations (898 count waves will adjust the 9 to 8 now...) more accurate. +- Adjusted LF FSK demod to account for cross threshold fluctuations (898 count waves will adjust the 9 to 8 now...) more accurate. (marshmellow) - Adjusted timings for t55xx commands. more reliable now. (marshmellow & iceman) - `lf cmdread` adjusted input methods and added help text (marshmellow & iceman) - changed `lf config t ` to be 0 - 128 and will trigger on + or - threshold value (marshmellow) -- `hf iclass dump` cli options - can now dump AA1 and AA2 with different keys in one run (does not go to multiple pages for the larger tags yet) +- `hf iclass dump` cli options - can now dump AA1 and AA2 with different keys in one run (does not go to multiple pages for the larger tags yet) (marshmellow) - Revised workflow for StandAloneMode14a (Craig Young) - EPA functions (`hf epa`) now support both ISO 14443-A and 14443-B cards (frederikmoellers) - 'hw version' only talks to ARM at startup, after that the info is cached. (pwpiwi) diff --git a/armsrc/lfops.c b/armsrc/lfops.c index a7b8d819..20e4efd3 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -326,7 +326,6 @@ void AcquireTiType(void) // if not provided a valid crc will be computed from the data and written. void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc) { - StartTicks(); FpgaDownloadAndGo(FPGA_BITSTREAM_LF); if(crc == 0) { crc = update_crc16(crc, (idlo)&0xff); @@ -347,8 +346,10 @@ void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc) // whether we're modulating the antenna (high) // or listening to the antenna (low) FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_PASSTHRU); + StartTicks(); + LED_A_ON(); - + // steal this pin from the SSP and use it to control the modulation AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT; AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT; @@ -361,7 +362,7 @@ void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc) // then write 80 bits of data (or 64 bit data + 16 bit crc if you prefer) // finally end with 0x0300 (write frame) // all data is sent lsb first - // finish with 15ms programming time + // finish with 50ms programming time // modulate antenna HIGH(GPIO_SSC_DOUT); @@ -399,7 +400,8 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol) int i = 0; uint8_t *buf = BigBuf_get_addr(); - FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT); + FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_PASSTHRU); + //FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT); //FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_READER_FIELD); //FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_TOGGLE_MODE ); @@ -420,8 +422,9 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol) AT91C_BASE_PIOA->PIO_ODR = GPIO_SSC_CLK; // power on antenna - // OPEN_COIL(); - // SpinDelay(50); + OPEN_COIL(); + // charge time + WaitMS(50); for(;;) { WDT_HIT(); @@ -1699,7 +1702,6 @@ void EM4xLogin(uint32_t pwd) { void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd) { LED_A_ON(); - uint8_t len; //clear buffer now so it does not interfere with timing later @@ -1719,7 +1721,9 @@ void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd) { SendForward(len); - DoAcquisition_default(0, TRUE); + WaitUS(400); + // Now do the acquisition + DoPartialAcquisition(20, true, 6000); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); cmd_send(CMD_ACK,0,0,0,0,0); @@ -1753,10 +1757,10 @@ void EM4xWriteWord(uint32_t flag, uint32_t data, uint32_t pwd) { SendForward(len); //Wait 20ms for write to complete? - WaitMS(10); + WaitMS(6); //Capture response if one exists - DoAcquisition_default(20, TRUE); + DoPartialAcquisition(20, true, 6000); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); cmd_send(CMD_ACK,0,0,0,0,0); diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index def7431d..fe595bf2 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -116,10 +116,10 @@ void LFSetupFPGAForADC(int divisor, bool lf_field) { * @param silent - is true, now outputs are made. If false, dbprints the status * @return the number of bits occupied by the samples. */ -uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averaging, int trigger_threshold, bool silent) { +uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averaging, int trigger_threshold, bool silent, int bufsize) { //bigbuf, to hold the aquired raw data signal uint8_t *dest = BigBuf_get_addr(); - uint16_t bufsize = BigBuf_max_traceLen(); + bufsize = (bufsize > 0 && bufsize < BigBuf_max_traceLen()) ? bufsize : BigBuf_max_traceLen(); //BigBuf_Clear_ext(false); //creates issues with cmdread (marshmellow) @@ -208,14 +208,19 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag * @return number of bits sampled */ uint32_t DoAcquisition_default(int trigger_threshold, bool silent) { - return DoAcquisition(1,8,0,trigger_threshold,silent); + return DoAcquisition(1, 8, 0,trigger_threshold, silent, 0); } uint32_t DoAcquisition_config( bool silent) { return DoAcquisition(config.decimation ,config.bits_per_sample ,config.averaging ,config.trigger_threshold - ,silent); + ,silent + ,0); +} + +uint32_t DoPartialAcquisition(int trigger_threshold, bool silent, int sample_size) { + return DoAcquisition(1, 8, 0, trigger_threshold, silent, sample_size); } uint32_t ReadLF(bool activeField, bool silent) { @@ -252,9 +257,9 @@ uint32_t SnoopLF() { **/ void doT55x7Acquisition(size_t sample_size) { - #define T55xx_READ_UPPER_THRESHOLD 128+40 // 60 grph - #define T55xx_READ_LOWER_THRESHOLD 128-40 // -60 grph - #define T55xx_READ_TOL 2 + #define T55xx_READ_UPPER_THRESHOLD 128+60 // 60 grph + #define T55xx_READ_LOWER_THRESHOLD 128-60 // -60 grph + #define T55xx_READ_TOL 5 uint8_t *dest = BigBuf_get_addr(); uint16_t bufsize = BigBuf_max_traceLen(); @@ -319,6 +324,9 @@ void doT55x7Acquisition(size_t sample_size) { #define COTAG_T2 (COTAG_T1>>1) #define COTAG_ONE_THRESHOLD 128+30 #define COTAG_ZERO_THRESHOLD 128-30 +#ifndef COTAG_BITS +#define COTAG_BITS 264 +#endif void doCotagAcquisition(size_t sample_size) { uint8_t *dest = BigBuf_get_addr(); diff --git a/armsrc/lfsampling.h b/armsrc/lfsampling.h index a31e2dc5..b300ee73 100644 --- a/armsrc/lfsampling.h +++ b/armsrc/lfsampling.h @@ -36,6 +36,9 @@ uint32_t SampleLF(bool silent); uint32_t SnoopLF(); +// adds sample size to default options +uint32_t DoPartialAcquisition(int trigger_threshold, bool silent, int sample_size); + /** * @brief Does sample acquisition, ignoring the config values set in the sample_config. * This method is typically used by tag-specific readers who just wants to read the samples