Merge branch 'master' into master

This commit is contained in:
Iceman 2019-08-16 11:16:03 +02:00 committed by GitHub
commit a013c1dad3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 203 additions and 119 deletions

View file

@ -3,6 +3,7 @@ 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... 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] ## [unreleased][unreleased]
- Fix reveng integration for all platforms else than WIN32 (@doegox)
- Add cheat sheet for easy operations of the Proxmark3 (scund00r) - Add cheat sheet for easy operations of the Proxmark3 (scund00r)
- Chg commands are now in green in the helptext list (@iceman1001) - Chg commands are now in green in the helptext list (@iceman1001)
- Fix 'script run ndefdump' - better exit messages when failing (@iceman1001) - Fix 'script run ndefdump' - better exit messages when failing (@iceman1001)

View file

@ -164,11 +164,16 @@ style:
# Detecting weird codepages and tabs. # Detecting weird codepages and tabs.
checks: checks:
find . \( -name "*.[ch]" -or -name "*.cpp" -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" -or -name "*.v" \) \ @echo "Files with suspicious chars:"
@find . \( -name "*.[ch]" -or -name "*.cpp" -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" -or -name "*.v" \) \
-exec sh -c "cat {} |recode utf8.. >/dev/null || echo {}" \; -exec sh -c "cat {} |recode utf8.. >/dev/null || echo {}" \;
find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" \) \ @echo "Files with tabs:"
-exec grep -lP '\t' {} \;
# to remove tabs within lines, one can try with: vi $file -c ':set tabstop=4' -c ':set et|retab' -c ':wq' # to remove tabs within lines, one can try with: vi $file -c ':set tabstop=4' -c ':set et|retab' -c ':wq'
@find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" \) \
-exec grep -lP '\t' {} \;
# @echo "Files with printf \\\\t:"
# @find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" \) \
# -exec grep -lP '\\t' {} \;
# Dummy target to test for GNU make availability # Dummy target to test for GNU make availability
_test: _test:

View file

@ -1,7 +1,9 @@
# Proxmark3 RDV4.0 Dedicated Github # RRG / Iceman repo, dedicated to Proxmark3 RDV4.0
This repo is based on iceman fork for Proxmark3. It is dedicated to bringing the most out of the new features for Proxmark3 RDV4.0 new hardware and design. This repo is based on iceman fork for Proxmark3. It is dedicated to bringing the most out of the new features for Proxmark3 RDV4.0 new hardware and design.
Note that it also supports other Proxmark3 platforms as well!
_Note that it also supports other Proxmark3 platforms as well!_
| Releases | Linux & OSX CI | Windows CI | | Releases | Linux & OSX CI | Windows CI |
| ------------------- |:-------------------:| -------------------:| | ------------------- |:-------------------:| -------------------:|
@ -40,18 +42,21 @@ This fork now compiles just fine on
- Windows/mingw environment with Qt5.6.1 & GCC 4.8 - Windows/mingw environment with Qt5.6.1 & GCC 4.8
- Ubuntu 1404, 1510, 1604, 1804, 1904 - Ubuntu 1404, 1510, 1604, 1804, 1904
- Mac OS X / Homebrew - Mac OS X / Homebrew
- ParrotOS - ParrotOS, Gentoo, Pentoo
- WSL (Windows subsystem linux) on Windows 10 - WSL, WSL2 (Windows subsystem linux) on Windows 10
- Docker container - Docker container
If you intend to contribute to the code, please read the [coding style notes](HACKING.md) first. If you intend to contribute to the code, please read the [coding style notes](HACKING.md) first.
- Internal notes on [Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md). - Internal notes on [Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md).
- Internal notes on UART - Internal notes on [UART](/doc/uart_notes.md)
- Internal notes on Frame format - Internal notes on [Frame format](/doc/new_frame_format.md)
- Internal notes on standalone mode - Internal notes on [external flash](/doc/ext_flash_notes.md)
- Internal notes on [standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)
- Internal notes on [Termux / Android](/doc/termux_notes.md)
## Cheat sheet
Thanks to Alex Dibs, you can enjoy a [command cheat sheet](/doc/cheatsheet.md)
## Why didn't you base it on official Proxmark3 Master? ## Why didn't you base it on official Proxmark3 Master?

View file

@ -8,27 +8,24 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// main code for HF Mifare aka ColinRun by Colin Brigato // main code for HF Mifare aka ColinRun by Colin Brigato
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "standalone.h" // standalone definitions #include "standalone.h" // standalone definitions
#include <stdbool.h> // for bool
#include <stdio.h>
#include <inttypes.h>
#include "hf_colin.h" #include "hf_colin.h"
#include "proxmark3_arm.h"
#include "appmain.h" #include "appmain.h"
#include "fpgaloader.h" #include "fpgaloader.h"
#include "dbprint.h" #include "dbprint.h"
#include "ticks.h" #include "ticks.h"
#include "commonutil.h"
#include "crc16.h"
#include "BigBuf.h"
#include "frozen.h"
#include "proxmark3_arm.h"
#include "mifaresim.h" // mifare1ksim
#include "mifareutil.h"
#include "iso14443a.h"
#include "util.h" #include "util.h"
#include "commonutil.h"
#include "BigBuf.h"
#include "iso14443a.h"
#include "mifareutil.h"
#include "mifaresim.h"
#include "vtsend.h" #include "vtsend.h"
#include "spiffs.h" #include "spiffs.h"
#include "string.h" #include "frozen.h"
#define MF1KSZ 1024 #define MF1KSZ 1024
#define MF1KSZSIZE 64 #define MF1KSZSIZE 64
@ -720,8 +717,10 @@ readysim:
SpinOff(100); SpinOff(100);
LED_C_ON(); LED_C_ON();
uint16_t flags; DBGLEVEL = DBG_NONE;
switch (p_card.uidlen) {
//uint16_t flags=0;
/*switch (p_card.uidlen) {
case 10: case 10:
flags = FLAG_10B_UID_IN_DATA; flags = FLAG_10B_UID_IN_DATA;
break; break;
@ -734,13 +733,23 @@ readysim:
default: default:
flags = FLAG_UID_IN_EMUL; flags = FLAG_UID_IN_EMUL;
break; break;
} }*/
// Use UID, SAK, ATQA from EMUL, if uid not defined // Use UID, SAK, ATQA from EMUL, if uid not defined
// if ((flags & (FLAG_4B_UID_IN_DATA | FLAG_7B_UID_IN_DATA | FLAG_10B_UID_IN_DATA)) == 0) { // if ((flags & (FLAG_4B_UID_IN_DATA | FLAG_7B_UID_IN_DATA | FLAG_10B_UID_IN_DATA)) == 0) {
flags |= FLAG_UID_IN_EMUL; //flags |= FLAG_UID_IN_EMUL;
//} //}
Mifare1ksim(flags | FLAG_MF_1K, 0, cjuid, 0, 0); //flags |= FLAG_MF_1K;
//if ((flags & (FLAG_4B_UID_IN_DATA | FLAG_7B_UID_IN_DATA | FLAG_10B_UID_IN_DATA)) == 0) {
// flags |= FLAG_UID_IN_EMUL;
//}
//flags = 0x10;
uint16_t flags = 0;
flags = 16;
DbprintfEx(FLAG_NEWLINE, "\n\n\n\n\n\n\n\nn\n\nn\n\n\nflags: %d (0x%02x)", flags, flags);
cjSetCursLeft();
SpinOff(1000);
Mifare1ksim(flags, 0, cjuid, 0, 0);
LED_C_OFF(); LED_C_OFF();
SpinOff(50); SpinOff(50);
vtsend_cursor_position_restore(NULL); vtsend_cursor_position_restore(NULL);

View file

@ -9,6 +9,10 @@
// StandAlone Mod // StandAlone Mod
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif #endif

View file

@ -1518,6 +1518,10 @@ static void PacketReceived(PacketCommandNG *packet) {
test_spiffs(); test_spiffs();
break; break;
} }
case CMD_SPIFFS_CHECK: {
rdv40_spiffs_check();
break;
}
case CMD_SPIFFS_MOUNT: { case CMD_SPIFFS_MOUNT: {
rdv40_spiffs_lazy_mount(); rdv40_spiffs_lazy_mount();
break; break;
@ -1901,6 +1905,11 @@ void __attribute__((noreturn)) AppMain(void) {
#ifdef WITH_FLASH #ifdef WITH_FLASH
// If flash is not present, BUSY_TIMEOUT kicks in, let's do it after USB // If flash is not present, BUSY_TIMEOUT kicks in, let's do it after USB
loadT55xxConfig(); loadT55xxConfig();
//
// Enforce a spiffs check/garbage collection at boot so we are likely to never
// fall under the 2 contigous free blocks availables
rdv40_spiffs_check();
#endif #endif
for (;;) { for (;;) {

View file

@ -34,7 +34,6 @@ void __attribute__((noreturn)) AppMain(void);
uint16_t AvgAdc(int ch); uint16_t AvgAdc(int ch);
void print_result(char *name, uint8_t *buf, size_t len);
//void PrintToSendBuffer(void); //void PrintToSendBuffer(void);
void ToSendStuffBit(int b); void ToSendStuffBit(int b);
void ToSendReset(void); void ToSendReset(void);

View file

@ -16,6 +16,7 @@
#include "common.h" #include "common.h"
#include "mifare.h" // struct #include "mifare.h" // struct
#include "pm3_cmd.h" #include "pm3_cmd.h"
#include "crc16.h" // compute_crc
// When the PM acts as tag and is receiving it takes // When the PM acts as tag and is receiving it takes
// 2 ticks delay in the RF part (for the first falling edge), // 2 ticks delay in the RF part (for the first falling edge),

View file

@ -22,9 +22,11 @@
// case, will ensure a flush by rollbacking to previous Unmounted state // case, will ensure a flush by rollbacking to previous Unmounted state
#define RDV40_SPIFFS_CACHE_SZ ((LOG_PAGE_SIZE + 32) * 4) #define RDV40_SPIFFS_CACHE_SZ ((LOG_PAGE_SIZE + 32) * 4)
#define SPIFFS_FD_SIZE (32) #define SPIFFS_FD_SIZE (32)
#define RDV40_SPIFFS_MAX_FD (2) #define RDV40_SPIFFS_MAX_FD (3)
#define RDV40_SPIFFS_FDBUF_SZ (SPIFFS_FD_SIZE * RDV40_SPIFFS_MAX_FD) #define RDV40_SPIFFS_FDBUF_SZ (SPIFFS_FD_SIZE * RDV40_SPIFFS_MAX_FD)
#define RDV40_LLERASE_BLOCKSIZE (64*1024)
#define RDV40_SPIFFS_LAZY_HEADER \ #define RDV40_SPIFFS_LAZY_HEADER \
int changed = 0; \ int changed = 0; \
if ((level == RDV40_SPIFFS_SAFETY_LAZY) || (level == RDV40_SPIFFS_SAFETY_SAFE)) { \ if ((level == RDV40_SPIFFS_SAFETY_LAZY) || (level == RDV40_SPIFFS_SAFETY_SAFE)) { \
@ -43,12 +45,8 @@
RDV40_SPIFFS_SAFE_FOOTER RDV40_SPIFFS_SAFE_FOOTER
#include "spiffs.h" #include "spiffs.h"
#include "flashmem.h"
#include "dbprint.h"
#include "printf.h"
#include "common.h"
#include "string.h"
#include "BigBuf.h" #include "BigBuf.h"
#include "dbprint.h"
///// FLASH LEVEL R/W/E operations for feeding SPIFFS Driver///////////////// ///// FLASH LEVEL R/W/E operations for feeding SPIFFS Driver/////////////////
static s32_t rdv40_spiffs_llread(u32_t addr, u32_t size, u8_t *dst) { static s32_t rdv40_spiffs_llread(u32_t addr, u32_t size, u8_t *dst) {
@ -70,28 +68,29 @@ static s32_t rdv40_spiffs_llwrite(u32_t addr, u32_t size, u8_t *src) {
static s32_t rdv40_spiffs_llerase(u32_t addr, u32_t size) { static s32_t rdv40_spiffs_llerase(u32_t addr, u32_t size) {
uint8_t erased = 0;
if (!FlashInit()) { if (!FlashInit()) {
return 130; return 130;
} }
if (DBGLEVEL > 2) Dbprintf("LLERASEDBG : Orig addr : %d\n", addr);
uint32_t bytes_erased = 0, bytes_remaining = size; uint8_t block, sector = 0;
while (bytes_remaining > 0) { block = addr / RDV40_LLERASE_BLOCKSIZE;
if (block) {
addr += bytes_erased; addr = addr - (block * RDV40_LLERASE_BLOCKSIZE);
}
if (DBGLEVEL > 2) Dbprintf("LLERASEDBG : Result addr : %d\n", addr);
sector = addr / SPIFFS_CFG_LOG_BLOCK_SZ;
Flash_CheckBusy(BUSY_TIMEOUT); Flash_CheckBusy(BUSY_TIMEOUT);
Flash_WriteEnable(); Flash_WriteEnable();
FlashSendByte(SECTORERASE); if (DBGLEVEL > 2) Dbprintf("LLERASEDBG : block : %d, sector : %d \n", block, sector);
Flash_TransferAdresse(addr); erased = Flash_Erase4k(block, sector);
FlashSendLastByte(0);
bytes_remaining -= 4096;
bytes_erased += 4096;
}
Flash_CheckBusy(BUSY_TIMEOUT); Flash_CheckBusy(BUSY_TIMEOUT);
FlashStop(); FlashStop();
return SPIFFS_OK; return SPIFFS_OK == erased ;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -162,6 +161,15 @@ int rdv40_spiffs_unmount() {
} }
return ret; return ret;
} }
int rdv40_spiffs_check() {
rdv40_spiffs_lazy_mount();
SPIFFS_check(&fs);
SPIFFS_gc_quick(&fs, 0);
rdv40_spiffs_lazy_unmount();
rdv40_spiffs_lazy_mount();
return SPIFFS_gc(&fs, 8192) == SPIFFS_OK;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
///// Base RDV40_SPIFFS_SAFETY_NORMAL operations//////////////////////////////// ///// Base RDV40_SPIFFS_SAFETY_NORMAL operations////////////////////////////////
@ -533,21 +541,16 @@ void rdv40_spiffs_safe_print_fsinfo() {
rdv40_spiffs_fsinfo fsinfo; rdv40_spiffs_fsinfo fsinfo;
rdv40_spiffs_getfsinfo(&fsinfo, RDV40_SPIFFS_SAFETY_SAFE); rdv40_spiffs_getfsinfo(&fsinfo, RDV40_SPIFFS_SAFETY_SAFE);
DbpString(_BLUE_("Flash Memory FileSystem Info (SPIFFS)")); DbpString(_BLUE_("Flash Memory FileSystem Info (SPIFFS)"));
// Dbprintf("-------------------------------------"); Dbprintf("-------------------------------------");
Dbprintf(" Logical Block Size........." _YELLOW_("%d")"bytes", fsinfo.blockSize); Dbprintf("* Filesystem Logical Block Size.........%d bytes", fsinfo.blockSize);
Dbprintf(" Logical Page Size.........." _YELLOW_("%d")"bytes", fsinfo.pageSize); Dbprintf("* Filesystem Logical Page Size..........%d bytes", fsinfo.pageSize);
Dbprintf(""); Dbprintf("--");
Dbprintf(" Max Open Files............." _YELLOW_("%d")"file descriptors", fsinfo.maxOpenFiles); Dbprintf("* Filesystem Max Open Files.............%d file descriptors", fsinfo.maxOpenFiles);
Dbprintf(" Max Path Length............" _YELLOW_("%d")"chars", fsinfo.maxPathLength); Dbprintf("* Filesystem Max Path Length............%d chars", fsinfo.maxPathLength);
// DbpString(_BLUE_("Details")); Dbprintf("--");
DbpString(""); Dbprintf("Filesystem\tSize\tUsed\tAvailable\tUse%\tMounted on");
Dbprintf(" Filesystem\tSize\tUsed\tAvailable\tUse%\tMounted on"); Dbprintf("spiffs\t%dB\t%dB\t%dB\t\t%d%\t/", fsinfo.totalBytes, fsinfo.usedBytes, fsinfo.freeBytes,
Dbprintf(" spiffs \t%d B\t%d B\t%d B\t\t"_YELLOW_("%d%")"\t/" fsinfo.usedPercent);
, fsinfo.totalBytes
, fsinfo.usedBytes
, fsinfo.freeBytes
, fsinfo.usedPercent
);
} }
// this function is safe and WILL rollback since it is only a PRINTING function, // this function is safe and WILL rollback since it is only a PRINTING function,

View file

@ -7,8 +7,9 @@
#ifndef SPIFFS_H_ #ifndef SPIFFS_H_
#define SPIFFS_H_ #define SPIFFS_H_
#if defined(__cplusplus)
#include "common.h" extern "C" {
#endif
#include "spiffs_config.h" #include "spiffs_config.h"
@ -32,7 +33,7 @@ typedef struct rdv40_spiffs_fsinfo {
int rdv40_spiffs_read_as_filetype(char *filename, uint8_t *dst, uint32_t size, RDV40SpiFFSSafetyLevel level); int rdv40_spiffs_read_as_filetype(char *filename, uint8_t *dst, uint32_t size, RDV40SpiFFSSafetyLevel level);
int rdv40_spiffs_check();
int rdv40_spiffs_lazy_unmount(); int rdv40_spiffs_lazy_unmount();
int rdv40_spiffs_lazy_mount(); int rdv40_spiffs_lazy_mount();
int rdv40_spiffs_lazy_mount_rollback(int changed); int rdv40_spiffs_lazy_mount_rollback(int changed);
@ -853,5 +854,8 @@ u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages);
#if SPIFFS_CACHE #if SPIFFS_CACHE
#endif #endif
#if defined(__cplusplus)
}
#endif
#endif /* SPIFFS_H_ */ #endif /* SPIFFS_H_ */

View file

@ -39,17 +39,17 @@ static s32_t spiffs_cache_page_free(spiffs *fs, int ix, u8_t write_back) {
(cp->flags & SPIFFS_CACHE_FLAG_TYPE_WR) == 0 && (cp->flags & SPIFFS_CACHE_FLAG_TYPE_WR) == 0 &&
(cp->flags & SPIFFS_CACHE_FLAG_DIRTY)) { (cp->flags & SPIFFS_CACHE_FLAG_DIRTY)) {
u8_t *mem = spiffs_get_cache_page(fs, cache, ix); u8_t *mem = spiffs_get_cache_page(fs, cache, ix);
SPIFFS_CACHE_DBG("CACHE_FREE: write cache page "_SPIPRIi" pix "_SPIPRIpg"\n", ix, cp->pix); SPIFFS_CACHE_DBG("CACHE_FREE: write cache page "_SPIPRIi" pix "_SPIPRIpg"\n", ix, cp->ucache.spix.pix);
res = SPIFFS_HAL_WRITE(fs, SPIFFS_PAGE_TO_PADDR(fs, cp->ucache.spix.pix), SPIFFS_CFG_LOG_PAGE_SZ(fs), mem); res = SPIFFS_HAL_WRITE(fs, SPIFFS_PAGE_TO_PADDR(fs, cp->ucache.spix.pix), SPIFFS_CFG_LOG_PAGE_SZ(fs), mem);
} }
#if SPIFFS_CACHE_WR #if SPIFFS_CACHE_WR
if (cp->flags & SPIFFS_CACHE_FLAG_TYPE_WR) { if (cp->flags & SPIFFS_CACHE_FLAG_TYPE_WR) {
SPIFFS_CACHE_DBG("CACHE_FREE: free cache page "_SPIPRIi" objid "_SPIPRIid"\n", ix, cp->obj_id); SPIFFS_CACHE_DBG("CACHE_FREE: free cache page "_SPIPRIi" objid "_SPIPRIid"\n", ix, cp->ucache.swrc.obj_id);
} else } else
#endif #endif
{ {
SPIFFS_CACHE_DBG("CACHE_FREE: free cache page "_SPIPRIi" pix "_SPIPRIpg"\n", ix, cp->pix); SPIFFS_CACHE_DBG("CACHE_FREE: free cache page "_SPIPRIi" pix "_SPIPRIpg"\n", ix, cp->ucache.spix.pix);
} }
cache->cpage_use_map &= ~(1 << ix); cache->cpage_use_map &= ~(1 << ix);
cp->flags = 0; cp->flags = 0;
@ -156,7 +156,7 @@ s32_t spiffs_phys_rd(
if (cp) { if (cp) {
cp->flags = SPIFFS_CACHE_FLAG_WRTHRU; cp->flags = SPIFFS_CACHE_FLAG_WRTHRU;
cp->ucache.spix.pix = SPIFFS_PADDR_TO_PAGE(fs, addr); cp->ucache.spix.pix = SPIFFS_PADDR_TO_PAGE(fs, addr);
SPIFFS_CACHE_DBG("CACHE_ALLO: allocated cache page "_SPIPRIi" for pix "_SPIPRIpg "\n", cp->ix, cp->pix); SPIFFS_CACHE_DBG("CACHE_ALLO: allocated cache page "_SPIPRIi" for pix "_SPIPRIpg "\n", cp->ix, cp->ucache.spix.pix);
s32_t res2 = SPIFFS_HAL_READ(fs, s32_t res2 = SPIFFS_HAL_READ(fs,
addr - SPIFFS_PADDR_TO_PAGE_OFFSET(fs, addr), addr - SPIFFS_PADDR_TO_PAGE_OFFSET(fs, addr),

View file

@ -8,7 +8,22 @@
#ifndef SPIFFS_CONFIG_H_ #ifndef SPIFFS_CONFIG_H_
#define SPIFFS_CONFIG_H_ #define SPIFFS_CONFIG_H_
#include "common.h" // ----------- 8< ------------
// Following includes are for the linux test build of spiffs
// These may/should/must be removed/altered/replaced in your target
//#include <stdio.h>
//#include <stdlib.h>
//
#include "printf.h"
#include "string.h"
#include "flashmem.h"
void Dbprintf(const char *fmt, ...);
//#include <stddef.h>
//#include <unistd.h>
// ----------- >8 ------------
typedef int s32_t; typedef int s32_t;
typedef uint32_t u32_t; typedef uint32_t u32_t;
@ -26,7 +41,7 @@ typedef uint8_t u8_t;
#endif #endif
// Set spiffs debug output call for garbage collecting. // Set spiffs debug output call for garbage collecting.
#ifndef SPIFFS_GC_DBG #ifndef SPIFFS_GC_DBG
#define SPIFFS_GC_DBG(_f, ...) #define SPIFFS_GC_DBG(_f, ...) //Dbprintf(_f, ## __VA_ARGS__)
#define SPIFFS_GC_DBGF(str) SPIFFS_GC_DBG(str,NULL) #define SPIFFS_GC_DBGF(str) SPIFFS_GC_DBG(str,NULL)
#endif #endif
// Set spiffs debug output call for caching. // Set spiffs debug output call for caching.
@ -36,7 +51,7 @@ typedef uint8_t u8_t;
#endif #endif
// Set spiffs debug output call for system consistency checks. // Set spiffs debug output call for system consistency checks.
#ifndef SPIFFS_CHECK_DBG #ifndef SPIFFS_CHECK_DBG
#define SPIFFS_CHECK_DBG(_f, ...) //SPIFFS_CHECK_DBG(_f, ## __VA_ARGS__) #define SPIFFS_CHECK_DBG(_f, ...) //Dbprintf(_f, ## __VA_ARGS__)
#define SPIFFS_CHECK_DBGF(str) SPIFFS_CHECK_DBG(str,NULL) #define SPIFFS_CHECK_DBGF(str) SPIFFS_CHECK_DBG(str,NULL)
#endif #endif
// Set spiffs debug output call for all api invocations. // Set spiffs debug output call for all api invocations.

View file

@ -22,6 +22,8 @@ TAR = tar
TARFLAGS = -C .. --ignore-failed-read -rvf TARFLAGS = -C .. --ignore-failed-read -rvf
RM = rm -f RM = rm -f
MV = mv MV = mv
TOUCH = touch
FALSE = false
ENV_LDFLAGS := $(LDFLAGS) ENV_LDFLAGS := $(LDFLAGS)
ENV_CFLAGS := $(CFLAGS) ENV_CFLAGS := $(CFLAGS)
@ -52,11 +54,11 @@ MBEDTLSLIBPATH = ../common/mbedtls
MBEDTLSLIB = $(MBEDTLSLIBPATH)/libmbedtls.a MBEDTLSLIB = $(MBEDTLSLIBPATH)/libmbedtls.a
CBORLIBPATH = ./tinycbor CBORLIBPATH = ./tinycbor
CBORLIB = $(CBORLIBPATH)/tinycbor.a CBORLIB = $(CBORLIBPATH)/tinycbor.a
REVENGFLAGS = -DPRESETS
LIBS = -I../common/zlib -Iuart -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) LIBS = -I../common/zlib -Iuart -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH)
INCLUDES_CLIENT = -I. -I../include -I../common -I/opt/local/include $(LIBS) INCLUDES_CLIENT = -I. -I../include -I../common -I/opt/local/include $(LIBS)
LDFLAGS = $(ENV_LDFLAGS) LDFLAGS = $(ENV_LDFLAGS)
CFLAGS = $(ENV_CFLAGS) -std=c99 -D_ISOC99_SOURCE $(REVENGFLAGS) $(INCLUDES_CLIENT) -Wall -Werror -g -O3
CFLAGS = $(ENV_CFLAGS) -std=c99 -D_ISOC99_SOURCE -DPRESETS $(INCLUDES_CLIENT) -Wall -Werror -g -O3
ifneq (,$(findstring MINGW,$(platform))) ifneq (,$(findstring MINGW,$(platform)))
CFLAGS += -mno-ms-bitfields CFLAGS += -mno-ms-bitfields
endif endif
@ -239,12 +241,6 @@ CMDSRCS = crapto1/crapto1.c \
cmdscript.c \ cmdscript.c \
pm3_bitlib.c \ pm3_bitlib.c \
cmdcrc.c \ cmdcrc.c \
reveng/preset.c \
reveng/reveng.c \
reveng/cli.c \
reveng/bmpbit.c \
reveng/model.c \
reveng/poly.c \
bucketsort.c bucketsort.c
cpu_arch = $(shell uname -m) cpu_arch = $(shell uname -m)
@ -262,12 +258,20 @@ ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
#-DDEBUG -Dverbose=1 #-DDEBUG -Dverbose=1
REVENGSRCS = reveng/preset.c \
reveng/reveng.c \
reveng/cli.c \
reveng/bmpbit.c \
reveng/model.c \
reveng/poly.c
QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o) COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o) CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
OBJCOBJS = $(OBJCSRCS:%.m=$(OBJDIR)/%.o) OBJCOBJS = $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o) ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
REVENGOBJS = $(REVENGSRCS:%.c=$(OBJDIR)/%.o)
MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \ MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
$(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \ $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
$(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \ $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
@ -292,7 +296,7 @@ ifeq "$(SUPPORTS_AVX512)" "True"
endif endif
BINS = proxmark3 flasher BINS = proxmark3 flasher
CLEAN = $(BINS) $(DEPENDENCY_FILES) $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h lualibs/pm3_cmd.lua lualibs/mf_default_keys.lua CLEAN = $(BINS) $(DEPENDENCY_FILES) $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(ZLIBOBJS) $(REVENGOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h lualibs/pm3_cmd.lua lualibs/mf_default_keys.lua reveng/bmptst
# need to assign dependancies to build these first... # need to assign dependancies to build these first...
all: lua_build jansson_build mbedtls_build cbor_build $(BINS) all: lua_build jansson_build mbedtls_build cbor_build $(BINS)
@ -301,9 +305,9 @@ all-static: LDLIBS:=-static $(LDLIBS)
all-static: $(BINS) all-static: $(BINS)
proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(QTLDLIBS) proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(QTLDLIBS)
proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/pm3_cmd.lua lualibs/mf_default_keys.lua proxmark3: reveng/bmptst $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(REVENGOBJS) lualibs/pm3_cmd.lua lualibs/mf_default_keys.lua
$(info [=] LD $@) $(info [=] LD $@)
$(Q)$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@ $(Q)$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(REVENGOBJS) $(LDLIBS) -o $@
flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS) $(OBJCOBJS) flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS) $(OBJCOBJS)
$(info [=] LD $@) $(info [=] LD $@)
@ -354,6 +358,11 @@ cbor_build:
$(info [*] MAKE tinycbor) $(info [*] MAKE tinycbor)
$(Q)$(MAKE) --no-print-directory -C $(CBORLIBPATH) all $(Q)$(MAKE) --no-print-directory -C $(CBORLIBPATH) all
reveng/bmptst: reveng/bmpbit.c reveng/config.h reveng/reveng.h
$(CC) $(CFLAGS) $(REVENGFLAGS) -DBMPTST -o $@ $<
( ./$@ && $(TOUCH) $@ ) || ( $(RM) $@ && $(FALSE) )
.PHONY: all clean .PHONY: all clean
# easy printing of MAKE VARIABLES # easy printing of MAKE VARIABLES
@ -419,7 +428,7 @@ $(OBJDIR)/%.o : %.m $(OBJDIR)/%.d
# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $< # $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
# $(POSTCOMPILE) # $(POSTCOMPILE)
DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS)) \ DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(REVENGSRCS)) \
$(patsubst %.o, %.d, $(MULTIARCHOBJS)) \ $(patsubst %.o, %.d, $(MULTIARCHOBJS)) \
$(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \ $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
$(patsubst %.m, $(OBJDIR)/%.d, $(OBJCSRCS)) \ $(patsubst %.m, $(OBJDIR)/%.d, $(OBJCSRCS)) \

View file

@ -39,6 +39,13 @@ static int CmdFlashMemSpiFFSTest(const char *Cmd) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
static int CmdFlashMemSpiFFSCheck(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
SendCommandNG(CMD_SPIFFS_CHECK, NULL, 0);
return PM3_SUCCESS;
}
static int CmdFlashMemSpiFFSTree(const char *Cmd) { static int CmdFlashMemSpiFFSTree(const char *Cmd) {
(void)Cmd; // Cmd is not used so far (void)Cmd; // Cmd is not used so far
clearCommandBuffer(); clearCommandBuffer();
@ -439,6 +446,7 @@ static command_t CommandTable[] = {
"copy", CmdFlashMemSpiFFSCopy, IfPm3Flash, "copy", CmdFlashMemSpiFFSCopy, IfPm3Flash,
"Copy a file to another (destructively) in SPIFFS FileSystem in FlashMEM (spiffs)" "Copy a file to another (destructively) in SPIFFS FileSystem in FlashMEM (spiffs)"
}, },
{"check", CmdFlashMemSpiFFSCheck, IfPm3Flash, "Check/try to defrag faulty/fragmented Filesystem"},
{"dump", CmdFlashMemSpiFFSDump, IfPm3Flash, "Dump a file from SPIFFS FileSystem in FlashMEM (spiffs)"}, {"dump", CmdFlashMemSpiFFSDump, IfPm3Flash, "Dump a file from SPIFFS FileSystem in FlashMEM (spiffs)"},
{"info", CmdFlashMemSpiFFSInfo, IfPm3Flash, "Print filesystem info and usage statistics (spiffs)"}, {"info", CmdFlashMemSpiFFSInfo, IfPm3Flash, "Print filesystem info and usage statistics (spiffs)"},
{"load", CmdFlashMemSpiFFSLoad, IfPm3Flash, "Upload file into SPIFFS Filesystem (spiffs)"}, {"load", CmdFlashMemSpiFFSLoad, IfPm3Flash, "Upload file into SPIFFS Filesystem (spiffs)"},

View file

@ -453,7 +453,7 @@ int CmdLFRead(const char *Cmd) {
cmdp++; cmdp++;
break; break;
case 'd': case 'd':
samples = param_get32ex(Cmd, cmdp, 0, 10); samples = param_get32ex(Cmd, cmdp + 1, 0, 10);
cmdp += 2; cmdp += 2;
break; break;
default: default:

View file

@ -442,7 +442,7 @@ static int CmdEM410xDemod(const char *Cmd) {
// this read is the "normal" read, which download lf signal and tries to demod here. // this read is the "normal" read, which download lf signal and tries to demod here.
static int CmdEM410xRead(const char *Cmd) { static int CmdEM410xRead(const char *Cmd) {
lf_read(true, 8192); lf_read(true, 12288);
return CmdEM410xDemod(Cmd); return CmdEM410xDemod(Cmd);
} }
@ -599,7 +599,7 @@ static int CmdEM410xWatch(const char *Cmd) {
PrintAndLogEx(WARNING, "\naborted via keyboard!\n"); PrintAndLogEx(WARNING, "\naborted via keyboard!\n");
break; break;
} }
lf_read(true, 8201); lf_read(true, 12288);
} while (CmdEM410xRead("") != PM3_SUCCESS); } while (CmdEM410xRead("") != PM3_SUCCESS);
return PM3_SUCCESS; return PM3_SUCCESS;

View file

@ -67,7 +67,7 @@ main(int argc, char *argv[]) {
setbmp(); setbmp();
if (BMP_BIT != bmpbit || BMP_SUB != bmpsub) { if (BMP_BIT != bmpbit || BMP_SUB != bmpsub) {
fprintf(stderr, "reveng: configuration fault. Update " fprintf(stderr, "reveng: configuration fault. Update "
"config.h with these definitions and " "reveng/config.h with these definitions and "
"recompile:\n" "recompile:\n"
"\t#define BMP_BIT %d\n" "\t#define BMP_BIT %d\n"
"\t#define BMP_SUB %d\n", "\t#define BMP_SUB %d\n",

View file

@ -57,33 +57,44 @@
/* #define ALWPCK 1 */ /* #define ALWPCK 1 */
/* Define PRESETS to compile CRC RevEng with the preset models from the /* #define PRESETS 1
* Define PRESETS to compile CRC RevEng with the preset models from the
* CRC Catalogue. This implies BMPMACRO and so makes the code platform- * CRC Catalogue. This implies BMPMACRO and so makes the code platform-
* specific. * specific.
*/ */
#ifdef _WIN32 /* #define BMP_BIT 32
#define PRESETS 1 // * Macros defining the size of a bmp_t.
#endif
/* Macros defining the size of a bmp_t.
* Their values only matter if PRESETS and/or BMPMACRO are defined, in * Their values only matter if PRESETS and/or BMPMACRO are defined, in
* which case edit the macros below to suit your architecture. * which case edit the macros below to suit your architecture.
* Otherwise, BMP_BIT and BMP_SUB will be redefined as aliases of bmpbit * Otherwise, BMP_BIT and BMP_SUB will be redefined as aliases of bmpbit
* and bmpsub, global objects initialised at run time. * and bmpsub, global objects initialised at run time.
*/ */
/* Size in bits of a bmp_t. Not necessarily a power of two. */ /* #define BMP_SUB 16
* The highest power of two that is strictly less than BMP_BIT.
#define BMP_BIT 32
/* The highest power of two that is strictly less than BMP_BIT.
* Initialises the index of a binary search for set bits in a bmp_t. * Initialises the index of a binary search for set bits in a bmp_t.
*/ */
#include <stdint.h>
#include <limits.h>
#if ULONG_MAX == UINT64_MAX
// most 64-bit platforms
#define PRESETS 1
#define BMP_BIT 64
#define BMP_SUB 32
#elif ULONG_MAX == UINT32_MAX
// 32-bit platforms and Mingw64
#define PRESETS 1
#define BMP_BIT 32
#define BMP_SUB 16 #define BMP_SUB 16
#else
#error Cannot determine automatically REVENG PRESETS Macros for your platform, you need to set them manually
#endif
/***************************************** /*****************************************
* * * *
* End of user configuration options * * End of user configuration options *

View file

@ -299,6 +299,7 @@ typedef struct {
#define CMD_SPIFFS_PRINT_FSINFO 0x2133 #define CMD_SPIFFS_PRINT_FSINFO 0x2133
#define CMD_SPIFFS_DOWNLOAD 0x2134 #define CMD_SPIFFS_DOWNLOAD 0x2134
#define CMD_SPIFFS_DOWNLOADED 0x2135 #define CMD_SPIFFS_DOWNLOADED 0x2135
#define CMD_SPIFFS_CHECK 0x3000
// more ? // more ?