Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Sep 10, 2024
2 parents acdaf8c + f9f2938 commit 572cf1b
Show file tree
Hide file tree
Showing 205 changed files with 5,130 additions and 879 deletions.
69 changes: 37 additions & 32 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
## Main changes
- SubGHz:
- OFW: Added protocol for Dickert MAHS garage door remote control
- Fix rare crash when opening Read mode via Frequency analyzer
- Refactor frequency analyzer code for better readability (by @derskythe | PR #782)
- Add new protocols (by @xMasterX) (big thanks to @Skorpionm for help with GangQi and Hollarm protocols!):
- Marantec24 (static 24 bit) with add manually support
- GangQi (static 34 bit) with button parsing and add manually support (thanks to @mishamyte for captures and testing)
- Hollarm (static 42 bit) with button parsing and add manually support (thanks to @mishamyte for captures)
- Hay21 (dynamic 21 bit) with button parsing
- Princeton custom buttons support (0x1, 0x2, 0x4, 0x8, 0xF)
- 125kHz RFID:
- OFW: Add lfrfid GProxII support
- OFW: Fix detection of GProx II cards and false detection of other cards (by @Astrrra)
- OFW: Fix Guard GProxII False Positive and 36-bit Parsing (by @zinongli)
- OFW: GProxII Fix Writing and Rendering Conflict
- NFC:
- OFW: Fix plantain balance string
- OFW: Now fifo size in ST25 chip is calculated properly
* Docs: Remove not printable symbols and update docs (by @derskythe | PR #783)
* OFW: Fix cumulative error in infrared signals
* OFW: iButton ID writing (Enable ID writing for ds1971 and ds1996)
- Saflok parser improvements (by @zinongli & @xtruan & @zacharyweiss & @evilmog & @Arkwin)
- OFW: Fix crash on Ultralight unlock (by @Astrrra)
- OFW: FeliCa anti-collision fix
* OFW: Rename 'Detect Reader' to 'Extract MF Keys'
* OFW: Happy mode
* OFW: Infrared: Universal AC - Add Airwell AW-HKD012-N91
* OFW: Broken file interaction fixes
* OFW: Add the Procrastination animation
* OFW PR 3892: Fix USB-UART bridge exit screen stopping the bridge prematurely (by @portasynthinca3)
* Apps: **Check out more Apps updates and fixes by following** [this link](https://github.com/xMasterX/all-the-plugins/commits/dev)
## Other changes
* Archive: Fix BadUSB favourite path check
* Settings: Show free flash amount in internal storage info (by @Willy-JL)
* Misc: Fix typo in comment in QueueTools.py (by @eltociear | PR #785)
* OFW PR 3840: GUI: NumberInput small improvements (by @Willy-JL)
* OFW PR 3838: SubGhz: Fix RPC status for ButtonRelease event (by @Skorpionm)
* OFW: scripts: improved size validator for updater image
* OFW: Desktop: seaprate callbacks for dolphin and storage subscriptions
* OFW: Make file extensions case-insensitive
* OFW: Remove internal storage folder if corresponding flag set
* OFW: **Added a text input that only accepts full numbers (int)**
* OFW: FuriEventLoop Pt.2
* OFW: Images linting: ensure that all images conform specification
* OFW: **Storage: remove LFS**
* OFW: NFC: Change the plantain last number display from "?" to "X"
* OFW: CCID App: Refactor
* OFW: Refactor detected protocols list
* OFW: fix: Ensure proper closure of variadic function in `mjs_array`
* OFW: **Added** `-Wundef` **to compiler options**
* OFW: toolchain: v39
* OFW: Furi: update string documentation
* OFW: Fix typo in "charge me" screen.
* OFW: Reordered VS-Code Tasks to follow the `Release` > `Debug` schema
* OFW: Remove unused entries from .editorconfig
* Docs: Improved the description steps to create a new remote BFT Mitto with more detailed and accurate instructions (by @chrostino | PR #805)
* OFW: FuriTimer: Use an event instead of a volatile bool to wait for deletion
* OFW: Threading, Timers improvements
* OFW: Replace all calls to strncpy with strlcpy, use strdup more, expose strlcat
* OFW: feat: add linux/gnome badusb demo resource files
* OFW: Exposed `view_dispatcher_get_event_loop`
* OFW: Infrared button operation fails now shows more informative messages
* OFW: Loader: Warn about missing SD card for main apps
* OFW: Desktop: Sanity check PIN length for good measure
* OFW: DialogEx: Fix NULL ptr crash
* OFW: Debug: use proper hook for handle_exit in flipperapps
* OFW: Clean up of LFS traces
* OFW: Proper integer parsing
* OFW: SubGhz: Fix RPC status for ButtonRelease event
* OFW: CCID: App changes
* OFW: 5V on GPIO control for ext. modules
* OFW: Gui: Add up and down button drawing functions to GUI elements
* OFW: Gui: change dialog_ex text ownership model
* OFW: Publishing T5577 page 1 block count macro
<br><br>
#### Known NFC post-refactor regressions list:
- Mifare Mini clones reading is broken (original mini working fine) (OFW)
Expand Down
3 changes: 2 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,15 @@ firmware_debug = distenv.PhonyTarget(
)
distenv.Depends(firmware_debug, firmware_flash)

distenv.PhonyTarget(
firmware_blackmagic = distenv.PhonyTarget(
"blackmagic",
"${GDBPYCOM}",
source=firmware_env["FW_ELF"],
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
GDBREMOTE="${BLACKMAGIC_ADDR}",
FBT_FAP_DEBUG_ELF_ROOT=firmware_env["FBT_FAP_DEBUG_ELF_ROOT"],
)
distenv.Depends(firmware_blackmagic, firmware_flash)

# Debug alien elf
debug_other_opts = [
Expand Down
7 changes: 3 additions & 4 deletions applications/debug/ccid_test/ccid_test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void ccid_test_app_free(CcidTestApp* app) {
furi_record_close(RECORD_GUI);
app->gui = NULL;

free(app->iso7816_handler);
iso7816_handler_free(app->iso7816_handler);

// Free rest
free(app);
Expand All @@ -121,8 +121,7 @@ int32_t ccid_test_app(void* p) {
furi_hal_usb_unlock();

furi_check(furi_hal_usb_set_config(&usb_ccid, &app->ccid_cfg) == true);
furi_hal_usb_ccid_set_callbacks(
(CcidCallbacks*)&app->iso7816_handler->ccid_callbacks, app->iso7816_handler);
iso7816_handler_set_usb_ccid_callbacks();
furi_hal_usb_ccid_insert_smartcard();

//handle button events
Expand All @@ -142,7 +141,7 @@ int32_t ccid_test_app(void* p) {
}

//tear down USB
furi_hal_usb_ccid_set_callbacks(NULL, NULL);
iso7816_handler_reset_usb_ccid_callbacks();
furi_hal_usb_set_config(usb_mode_prev, NULL);

//teardown view
Expand Down
46 changes: 37 additions & 9 deletions applications/debug/ccid_test/iso7816/iso7816_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
#include <furi.h>
#include <furi_hal.h>

#include "iso7816_handler.h"

#include "iso7816_t0_apdu.h"
#include "iso7816_atr.h"
#include "iso7816_handler.h"
#include "iso7816_response.h"

static Iso7816Handler* iso7816_handler;
static CcidCallbacks* ccid_callbacks;
static uint8_t* command_apdu_buffer;
static uint8_t* response_apdu_buffer;

void iso7816_icc_power_on_callback(uint8_t* atr_data, uint32_t* atr_data_len, void* context) {
furi_check(context);

Expand Down Expand Up @@ -40,12 +46,11 @@ void iso7816_xfr_datablock_callback(

Iso7816Handler* handler = (Iso7816Handler*)context;

ISO7816_Response_APDU* response_apdu = (ISO7816_Response_APDU*)&handler->response_apdu_buffer;

ISO7816_Command_APDU* command_apdu = (ISO7816_Command_APDU*)&handler->command_apdu_buffer;
ISO7816_Response_APDU* response_apdu = (ISO7816_Response_APDU*)response_apdu_buffer;
ISO7816_Command_APDU* command_apdu = (ISO7816_Command_APDU*)command_apdu_buffer;

uint8_t result = iso7816_read_command_apdu(
command_apdu, pc_to_reader_datablock, pc_to_reader_datablock_len);
command_apdu, pc_to_reader_datablock, pc_to_reader_datablock_len, CCID_SHORT_APDU_SIZE);

if(result == ISO7816_READ_COMMAND_APDU_OK) {
handler->iso7816_process_command(command_apdu, response_apdu);
Expand All @@ -61,8 +66,31 @@ void iso7816_xfr_datablock_callback(
}

Iso7816Handler* iso7816_handler_alloc() {
Iso7816Handler* handler = malloc(sizeof(Iso7816Handler));
handler->ccid_callbacks.icc_power_on_callback = iso7816_icc_power_on_callback;
handler->ccid_callbacks.xfr_datablock_callback = iso7816_xfr_datablock_callback;
return handler;
iso7816_handler = malloc(sizeof(Iso7816Handler));

command_apdu_buffer = malloc(sizeof(ISO7816_Command_APDU) + CCID_SHORT_APDU_SIZE);
response_apdu_buffer = malloc(sizeof(ISO7816_Response_APDU) + CCID_SHORT_APDU_SIZE);

ccid_callbacks = malloc(sizeof(CcidCallbacks));
ccid_callbacks->icc_power_on_callback = iso7816_icc_power_on_callback;
ccid_callbacks->xfr_datablock_callback = iso7816_xfr_datablock_callback;

return iso7816_handler;
}

void iso7816_handler_set_usb_ccid_callbacks() {
furi_hal_usb_ccid_set_callbacks(ccid_callbacks, iso7816_handler);
}

void iso7816_handler_reset_usb_ccid_callbacks() {
furi_hal_usb_ccid_set_callbacks(NULL, NULL);
}

void iso7816_handler_free(Iso7816Handler* handler) {
free(ccid_callbacks);

free(command_apdu_buffer);
free(response_apdu_buffer);

free(handler);
}
8 changes: 4 additions & 4 deletions applications/debug/ccid_test/iso7816/iso7816_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include "iso7816_t0_apdu.h"

typedef struct {
CcidCallbacks ccid_callbacks;
void (*iso7816_answer_to_reset)(Iso7816Atr* atr);
void (*iso7816_process_command)(
const ISO7816_Command_APDU* command,
ISO7816_Response_APDU* response);

uint8_t command_apdu_buffer[sizeof(ISO7816_Command_APDU) + CCID_SHORT_APDU_SIZE];
uint8_t response_apdu_buffer[sizeof(ISO7816_Response_APDU) + CCID_SHORT_APDU_SIZE];
} Iso7816Handler;

Iso7816Handler* iso7816_handler_alloc();

void iso7816_handler_free(Iso7816Handler* handler);
void iso7816_handler_set_usb_ccid_callbacks();
void iso7816_handler_reset_usb_ccid_callbacks();
37 changes: 18 additions & 19 deletions applications/debug/ccid_test/iso7816/iso7816_t0_apdu.c
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
/* Implements rudimentary iso7816-3 support for APDU (T=0) */
#include <stdint.h>
#include <string.h>
#include <furi.h>
#include <furi_hal.h>
#include "iso7816_t0_apdu.h"

//reads dataBuffer with dataLen size, translate it into a ISO7816_Command_APDU type
//reads pc_to_reader_datablock_len with pc_to_reader_datablock_len size, translate it into a ISO7816_Command_APDU type
//extra data will be pointed to commandDataBuffer
uint8_t iso7816_read_command_apdu(
ISO7816_Command_APDU* command,
const uint8_t* dataBuffer,
uint32_t dataLen) {
command->CLA = dataBuffer[0];
command->INS = dataBuffer[1];
command->P1 = dataBuffer[2];
command->P2 = dataBuffer[3];
const uint8_t* pc_to_reader_datablock,
uint32_t pc_to_reader_datablock_len,
uint32_t max_apdu_size) {
command->CLA = pc_to_reader_datablock[0];
command->INS = pc_to_reader_datablock[1];
command->P1 = pc_to_reader_datablock[2];
command->P2 = pc_to_reader_datablock[3];

if(dataLen == 4) {
if(pc_to_reader_datablock_len == 4) {
command->Lc = 0;
command->Le = 0;
command->LePresent = false;

return ISO7816_READ_COMMAND_APDU_OK;
} else if(dataLen == 5) {
} else if(pc_to_reader_datablock_len == 5) {
//short le

command->Lc = 0;
command->Le = dataBuffer[4];
command->Le = pc_to_reader_datablock[4];
command->LePresent = true;

return ISO7816_READ_COMMAND_APDU_OK;
} else if(dataLen > 5 && dataBuffer[4] != 0x00) {
} else if(pc_to_reader_datablock_len > 5 && pc_to_reader_datablock[4] != 0x00) {
//short lc

command->Lc = dataBuffer[4];
if(command->Lc > 0 && command->Lc < CCID_SHORT_APDU_SIZE) { //-V560
memcpy(command->Data, &dataBuffer[5], command->Lc);
command->Lc = pc_to_reader_datablock[4];
if(command->Lc > 0 && command->Lc < max_apdu_size) { //-V560
memcpy(command->Data, &pc_to_reader_datablock[5], command->Lc);

//does it have a short le too?
if(dataLen == (uint32_t)(command->Lc + 5)) {
if(pc_to_reader_datablock_len == (uint32_t)(command->Lc + 5)) {
command->Le = 0;
command->LePresent = false;
return ISO7816_READ_COMMAND_APDU_OK;
} else if(dataLen == (uint32_t)(command->Lc + 6)) {
command->Le = dataBuffer[dataLen - 1];
} else if(pc_to_reader_datablock_len == (uint32_t)(command->Lc + 6)) {
command->Le = pc_to_reader_datablock[pc_to_reader_datablock_len - 1];
command->LePresent = true;

return ISO7816_READ_COMMAND_APDU_OK;
Expand Down
3 changes: 2 additions & 1 deletion applications/debug/ccid_test/iso7816/iso7816_t0_apdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ typedef struct {
uint8_t iso7816_read_command_apdu(
ISO7816_Command_APDU* command,
const uint8_t* pc_to_reader_datablock,
uint32_t pc_to_reader_datablock_len);
uint32_t pc_to_reader_datablock_len,
uint32_t max_apdu_size);
void iso7816_write_response_apdu(
const ISO7816_Response_APDU* response,
uint8_t* reader_to_pc_datablock,
Expand Down
59 changes: 55 additions & 4 deletions applications/debug/expansion_test/expansion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,27 @@
* 13 -> 16 (USART TX to LPUART RX)
* 14 -> 15 (USART RX to LPUART TX)
*
* Optional: Connect an LED with an appropriate series resistor
* between pins 1 and 8. It will always be on if the device is
* connected to USB power, so unplug it before running the app.
*
* What this application does:
*
* - Enables module support and emulates the module on a single device
* (hence the above connection),
* - Connects to the expansion module service, sets baud rate,
* - Enables OTG (5V) on GPIO via plain expansion protocol,
* - Waits 5 cycles of idle loop (1 second),
* - Starts the RPC session,
* - Disables OTG (5V) on GPIO via RPC messages,
* - Waits 5 cycles of idle loop (1 second),
* - Creates a directory at `/ext/ExpansionTest` and writes a file
* named `test.txt` under it,
* - Plays an audiovisual alert (sound and blinking display),
* - Waits 10 cycles of idle loop,
* - Enables OTG (5V) on GPIO via RPC messages,
* - Waits 5 cycles of idle loop (1 second),
* - Stops the RPC session,
* - Waits another 10 cycles of idle loop,
* - Disables OTG (5V) on GPIO via plain expansion protocol,
* - Exits (plays a sound if any of the above steps failed).
*/
#include <furi.h>
Expand Down Expand Up @@ -302,6 +311,22 @@ static bool expansion_test_app_handshake(ExpansionTestApp* instance) {
return success;
}

static bool expansion_test_app_enable_otg(ExpansionTestApp* instance, bool enable) {
bool success = false;

do {
const ExpansionFrameControlCommand command = enable ?
ExpansionFrameControlCommandEnableOtg :
ExpansionFrameControlCommandDisableOtg;
if(!expansion_test_app_send_control_request(instance, command)) break;
if(!expansion_test_app_receive_frame(instance, &instance->frame)) break;
if(!expansion_test_app_is_success_response(&instance->frame)) break;
success = true;
} while(false);

return success;
}

static bool expansion_test_app_start_rpc(ExpansionTestApp* instance) {
bool success = false;

Expand Down Expand Up @@ -396,6 +421,27 @@ static bool expansion_test_app_rpc_alert(ExpansionTestApp* instance) {
return success;
}

static bool expansion_test_app_rpc_enable_otg(ExpansionTestApp* instance, bool enable) {
bool success = false;

instance->msg.command_id++;
instance->msg.command_status = PB_CommandStatus_OK;
instance->msg.which_content = PB_Main_gpio_set_otg_mode_tag;
instance->msg.content.gpio_set_otg_mode.mode = enable ? PB_Gpio_GpioOtgMode_ON :
PB_Gpio_GpioOtgMode_OFF;
instance->msg.has_next = false;

do {
if(!expansion_test_app_send_rpc_request(instance, &instance->msg)) break;
if(!expansion_test_app_receive_rpc_request(instance, &instance->msg)) break;
if(instance->msg.which_content != PB_Main_empty_tag) break;
if(instance->msg.command_status != PB_CommandStatus_OK) break;
success = true;
} while(false);

return success;
}

static bool expansion_test_app_idle(ExpansionTestApp* instance, uint32_t num_cycles) {
uint32_t num_cycles_done;
for(num_cycles_done = 0; num_cycles_done < num_cycles; ++num_cycles_done) {
Expand Down Expand Up @@ -434,13 +480,18 @@ int32_t expansion_test_app(void* p) {
if(!expansion_test_app_send_presence(instance)) break;
if(!expansion_test_app_wait_ready(instance)) break;
if(!expansion_test_app_handshake(instance)) break;
if(!expansion_test_app_enable_otg(instance, true)) break;
if(!expansion_test_app_idle(instance, 5)) break;
if(!expansion_test_app_start_rpc(instance)) break;
if(!expansion_test_app_rpc_enable_otg(instance, false)) break;
if(!expansion_test_app_idle(instance, 5)) break;
if(!expansion_test_app_rpc_mkdir(instance)) break;
if(!expansion_test_app_rpc_write(instance)) break;
if(!expansion_test_app_rpc_alert(instance)) break;
if(!expansion_test_app_idle(instance, 10)) break;
if(!expansion_test_app_rpc_enable_otg(instance, true)) break;
if(!expansion_test_app_idle(instance, 5)) break;
if(!expansion_test_app_stop_rpc(instance)) break;
if(!expansion_test_app_idle(instance, 10)) break;
if(!expansion_test_app_enable_otg(instance, false)) break;
success = true;
} while(false);

Expand Down
Loading

0 comments on commit 572cf1b

Please sign in to comment.