Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 authored Aug 16, 2019
2 parents d99911a + d12b3c3 commit a013c1d
Show file tree
Hide file tree
Showing 21 changed files with 202 additions and 118 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...

## [unreleased][unreleased]
- Fix reveng integration for all platforms else than WIN32 (@doegox)
- Add cheat sheet for easy operations of the Proxmark3 (scund00r)
- Chg commands are now in green in the helptext list (@iceman1001)
- Fix 'script run ndefdump' - better exit messages when failing (@iceman1001)
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,16 @@ style:

# Detecting weird codepages and tabs.
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 {}" \;
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 tabs:"
# 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
_test:
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
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 |
| ------------------- |:-------------------:| -------------------:|
Expand Down Expand Up @@ -40,18 +42,21 @@ This fork now compiles just fine on
- Windows/mingw environment with Qt5.6.1 & GCC 4.8
- Ubuntu 1404, 1510, 1604, 1804, 1904
- Mac OS X / Homebrew
- ParrotOS
- WSL (Windows subsystem linux) on Windows 10
- ParrotOS, Gentoo, Pentoo
- WSL, WSL2 (Windows subsystem linux) on Windows 10
- Docker container

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 UART
- Internal notes on Frame format
- Internal notes on standalone mode


- Internal notes on [UART](/doc/uart_notes.md)
- Internal notes on [Frame format](/doc/new_frame_format.md)
- 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?

Expand Down
39 changes: 24 additions & 15 deletions armsrc/Standalone/hf_colin.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,24 @@
//-----------------------------------------------------------------------------
// main code for HF Mifare aka ColinRun by Colin Brigato
//-----------------------------------------------------------------------------

#include "standalone.h" // standalone definitions
#include <stdbool.h> // for bool
#include <stdio.h>
#include <inttypes.h>

#include "hf_colin.h"
#include "proxmark3_arm.h"
#include "appmain.h"
#include "fpgaloader.h"
#include "dbprint.h"
#include "ticks.h"
#include "util.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 "mifareutil.h"
#include "mifaresim.h"
#include "vtsend.h"
#include "spiffs.h"
#include "string.h"
#include "frozen.h"

#define MF1KSZ 1024
#define MF1KSZSIZE 64
Expand Down Expand Up @@ -720,8 +717,10 @@ void RunMod() {
SpinOff(100);
LED_C_ON();

uint16_t flags;
switch (p_card.uidlen) {
DBGLEVEL = DBG_NONE;

//uint16_t flags=0;
/*switch (p_card.uidlen) {
case 10:
flags = FLAG_10B_UID_IN_DATA;
break;
Expand All @@ -734,13 +733,23 @@ void RunMod() {
default:
flags = FLAG_UID_IN_EMUL;
break;
}
}*/

// 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) {
flags |= FLAG_UID_IN_EMUL;
//flags |= FLAG_UID_IN_EMUL;
//}
//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;
//}
Mifare1ksim(flags | FLAG_MF_1K, 0, cjuid, 0, 0);
//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();
SpinOff(50);
vtsend_cursor_position_restore(NULL);
Expand Down
4 changes: 4 additions & 0 deletions armsrc/Standalone/hf_colin.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
// StandAlone Mod
//-----------------------------------------------------------------------------

#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>

#ifndef FALSE
#define FALSE 0
#endif
Expand Down
9 changes: 9 additions & 0 deletions armsrc/appmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,10 @@ static void PacketReceived(PacketCommandNG *packet) {
test_spiffs();
break;
}
case CMD_SPIFFS_CHECK: {
rdv40_spiffs_check();
break;
}
case CMD_SPIFFS_MOUNT: {
rdv40_spiffs_lazy_mount();
break;
Expand Down Expand Up @@ -1901,6 +1905,11 @@ void __attribute__((noreturn)) AppMain(void) {
#ifdef WITH_FLASH
// If flash is not present, BUSY_TIMEOUT kicks in, let's do it after USB
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

for (;;) {
Expand Down
1 change: 0 additions & 1 deletion armsrc/appmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void __attribute__((noreturn)) AppMain(void);

uint16_t AvgAdc(int ch);

void print_result(char *name, uint8_t *buf, size_t len);
//void PrintToSendBuffer(void);
void ToSendStuffBit(int b);
void ToSendReset(void);
Expand Down
1 change: 1 addition & 0 deletions armsrc/iso14443a.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "common.h"
#include "mifare.h" // struct
#include "pm3_cmd.h"
#include "crc16.h" // compute_crc

// When the PM acts as tag and is receiving it takes
// 2 ticks delay in the RF part (for the first falling edge),
Expand Down
73 changes: 38 additions & 35 deletions armsrc/spiffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
// case, will ensure a flush by rollbacking to previous Unmounted state
#define RDV40_SPIFFS_CACHE_SZ ((LOG_PAGE_SIZE + 32) * 4)
#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_LLERASE_BLOCKSIZE (64*1024)

#define RDV40_SPIFFS_LAZY_HEADER \
int changed = 0; \
if ((level == RDV40_SPIFFS_SAFETY_LAZY) || (level == RDV40_SPIFFS_SAFETY_SAFE)) { \
Expand All @@ -43,12 +45,8 @@
RDV40_SPIFFS_SAFE_FOOTER

#include "spiffs.h"
#include "flashmem.h"
#include "dbprint.h"
#include "printf.h"
#include "common.h"
#include "string.h"
#include "BigBuf.h"
#include "dbprint.h"

///// 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) {
Expand All @@ -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) {


uint8_t erased = 0;

if (!FlashInit()) {
return 130;
}

uint32_t bytes_erased = 0, bytes_remaining = size;
while (bytes_remaining > 0) {

addr += bytes_erased;
Flash_CheckBusy(BUSY_TIMEOUT);
Flash_WriteEnable();
FlashSendByte(SECTORERASE);
Flash_TransferAdresse(addr);
FlashSendLastByte(0);

bytes_remaining -= 4096;
bytes_erased += 4096;
if (DBGLEVEL > 2) Dbprintf("LLERASEDBG : Orig addr : %d\n", addr);
uint8_t block, sector = 0;
block = addr / RDV40_LLERASE_BLOCKSIZE;
if (block) {
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_WriteEnable();
if (DBGLEVEL > 2) Dbprintf("LLERASEDBG : block : %d, sector : %d \n", block, sector);
erased = Flash_Erase4k(block, sector);

Flash_CheckBusy(BUSY_TIMEOUT);
FlashStop();

return SPIFFS_OK;
return SPIFFS_OK == erased ;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -162,6 +161,15 @@ int rdv40_spiffs_unmount() {
}
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////////////////////////////////
Expand Down Expand Up @@ -533,21 +541,16 @@ void rdv40_spiffs_safe_print_fsinfo() {
rdv40_spiffs_fsinfo fsinfo;
rdv40_spiffs_getfsinfo(&fsinfo, RDV40_SPIFFS_SAFETY_SAFE);
DbpString(_BLUE_("Flash Memory FileSystem Info (SPIFFS)"));
// Dbprintf("-------------------------------------");
Dbprintf(" Logical Block Size........." _YELLOW_("%d")"bytes", fsinfo.blockSize);
Dbprintf(" Logical Page Size.........." _YELLOW_("%d")"bytes", fsinfo.pageSize);
Dbprintf("");
Dbprintf(" Max Open Files............." _YELLOW_("%d")"file descriptors", fsinfo.maxOpenFiles);
Dbprintf(" Max Path Length............" _YELLOW_("%d")"chars", fsinfo.maxPathLength);
// DbpString(_BLUE_("Details"));
DbpString("");
Dbprintf(" Filesystem\tSize\tUsed\tAvailable\tUse%\tMounted on");
Dbprintf(" spiffs \t%d B\t%d B\t%d B\t\t"_YELLOW_("%d%")"\t/"
, fsinfo.totalBytes
, fsinfo.usedBytes
, fsinfo.freeBytes
, fsinfo.usedPercent
);
Dbprintf("-------------------------------------");
Dbprintf("* Filesystem Logical Block Size.........%d bytes", fsinfo.blockSize);
Dbprintf("* Filesystem Logical Page Size..........%d bytes", fsinfo.pageSize);
Dbprintf("--");
Dbprintf("* Filesystem Max Open Files.............%d file descriptors", fsinfo.maxOpenFiles);
Dbprintf("* Filesystem Max Path Length............%d chars", fsinfo.maxPathLength);
Dbprintf("--");
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,
fsinfo.usedPercent);
}

// this function is safe and WILL rollback since it is only a PRINTING function,
Expand Down
10 changes: 7 additions & 3 deletions armsrc/spiffs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

#ifndef SPIFFS_H_
#define SPIFFS_H_

#include "common.h"
#if defined(__cplusplus)
extern "C" {
#endif

#include "spiffs_config.h"

Expand All @@ -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_check();
int rdv40_spiffs_lazy_unmount();
int rdv40_spiffs_lazy_mount();
int rdv40_spiffs_lazy_mount_rollback(int changed);
Expand Down Expand Up @@ -853,5 +854,8 @@ u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages);

#if SPIFFS_CACHE
#endif
#if defined(__cplusplus)
}
#endif

#endif /* SPIFFS_H_ */
8 changes: 4 additions & 4 deletions armsrc/spiffs_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_DIRTY)) {
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);
}

#if SPIFFS_CACHE_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
#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);
cp->flags = 0;
Expand Down Expand Up @@ -156,7 +156,7 @@ s32_t spiffs_phys_rd(
if (cp) {
cp->flags = SPIFFS_CACHE_FLAG_WRTHRU;
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,
addr - SPIFFS_PADDR_TO_PAGE_OFFSET(fs, addr),
Expand Down
Loading

0 comments on commit a013c1d

Please sign in to comment.