mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge branch 'dev' of https://github.com/DarkFlippers/unleashed-firmware into xfw-dev
This commit is contained in:
12
.gitmodules
vendored
12
.gitmodules
vendored
@@ -1,9 +1,6 @@
|
||||
[submodule "lib/mlib"]
|
||||
path = lib/mlib
|
||||
url = https://github.com/P-p-H-d/mlib.git
|
||||
[submodule "lib/STM32CubeWB"]
|
||||
path = lib/STM32CubeWB
|
||||
url = https://github.com/Flipper-Zero/STM32CubeWB.git
|
||||
[submodule "lib/littlefs"]
|
||||
path = lib/littlefs
|
||||
url = https://github.com/littlefs-project/littlefs.git
|
||||
@@ -34,3 +31,12 @@
|
||||
[submodule "lib/heatshrink"]
|
||||
path = lib/heatshrink
|
||||
url = https://github.com/flipperdevices/heatshrink.git
|
||||
[submodule "lib/st_cmsis_device_wb"]
|
||||
path = lib/stm32wb_cmsis
|
||||
url = https://github.com/STMicroelectronics/cmsis_device_wb
|
||||
[submodule "lib/stm32wbxx_hal_driver"]
|
||||
path = lib/stm32wb_hal
|
||||
url = https://github.com/STMicroelectronics/stm32wbxx_hal_driver
|
||||
[submodule "lib/stm32wb_copro"]
|
||||
path = lib/stm32wb_copro
|
||||
url = https://github.com/flipperdevices/stm32wb_copro.git
|
||||
|
||||
@@ -1 +1 @@
|
||||
--ignore-ccache -C gccarm --rules-config .pvsconfig -e lib/fatfs -e lib/fnv1a-hash -e lib/FreeRTOS-Kernel -e lib/heatshrink -e lib/libusb_stm32 -e lib/littlefs -e lib/mbedtls -e lib/micro-ecc -e lib/microtar -e lib/mlib -e lib/qrcode -e lib/ST25RFAL002 -e lib/STM32CubeWB -e lib/u8g2 -e lib/xtreme -e lib/nanopb -e */arm-none-eabi/* -e applications/external/dap_link/lib/free-dap
|
||||
--ignore-ccache -C gccarm --rules-config .pvsconfig -e lib/cmsis_core -e lib/fatfs -e lib/fnv1a-hash -e lib/FreeRTOS-Kernel -e lib/heatshrink -e lib/libusb_stm32 -e lib/littlefs -e lib/mbedtls -e lib/micro-ecc -e lib/microtar -e lib/mlib -e lib/qrcode -e lib/ST25RFAL002 -e lib/stm32wb_cmsis -e lib/stm32wb_copro -e lib/stm32wb_hal -e lib/u8g2 -e lib/xtreme -e lib/nanopb -e */arm-none-eabi/* -e applications/external/dap_link/lib/free-dap
|
||||
|
||||
40
.vscode/example/launch.json
vendored
40
.vscode/example/launch.json
vendored
@@ -27,20 +27,21 @@
|
||||
"type": "cortex-debug",
|
||||
"servertype": "openocd",
|
||||
"device": "stlink",
|
||||
"svdFile": "./debug/STM32WB55_CM4.svd",
|
||||
"svdFile": "./scripts/debug/STM32WB55_CM4.svd",
|
||||
// If you're debugging early in the boot process, before OS scheduler is running,
|
||||
// you have to comment out the following line.
|
||||
"rtos": "FreeRTOS",
|
||||
"configFiles": [
|
||||
"interface/stlink.cfg",
|
||||
"./debug/stm32wbx.cfg",
|
||||
"./scripts/debug/stm32wbx.cfg",
|
||||
],
|
||||
"postAttachCommands": [
|
||||
"source scripts/debug/flipperversion.py",
|
||||
"fw-version",
|
||||
// "compare-sections",
|
||||
"source debug/flipperapps.py",
|
||||
"source scripts/debug/flipperapps.py",
|
||||
"fap-set-debug-elf-root build/latest/.extapps",
|
||||
// "source debug/FreeRTOS/FreeRTOS.py",
|
||||
// "svd_load debug/STM32WB55_CM4.svd"
|
||||
// "source scripts/debug/FreeRTOS/FreeRTOS.py",
|
||||
]
|
||||
// "showDevDebugOutput": "raw",
|
||||
},
|
||||
@@ -52,14 +53,16 @@
|
||||
"type": "cortex-debug",
|
||||
"servertype": "external",
|
||||
"gdbTarget": "${input:BLACKMAGIC}",
|
||||
"svdFile": "./debug/STM32WB55_CM4.svd",
|
||||
"svdFile": "./scripts/debug/STM32WB55_CM4.svd",
|
||||
"rtos": "FreeRTOS",
|
||||
"postAttachCommands": [
|
||||
"monitor swdp_scan",
|
||||
"attach 1",
|
||||
"set confirm off",
|
||||
"set mem inaccessible-by-default off",
|
||||
"source debug/flipperapps.py",
|
||||
"source scripts/debug/flipperversion.py",
|
||||
"fw-version",
|
||||
"source scripts/debug/flipperapps.py",
|
||||
"fap-set-debug-elf-root build/latest/.extapps",
|
||||
// "compare-sections",
|
||||
]
|
||||
@@ -74,10 +77,12 @@
|
||||
"servertype": "jlink",
|
||||
"interface": "swd",
|
||||
"device": "STM32WB55RG",
|
||||
"svdFile": "./debug/STM32WB55_CM4.svd",
|
||||
"svdFile": "./scripts/debug/STM32WB55_CM4.svd",
|
||||
"rtos": "FreeRTOS",
|
||||
"postAttachCommands": [
|
||||
"source debug/flipperapps.py",
|
||||
"source scripts/debug/flipperversion.py",
|
||||
"fw-version",
|
||||
"source scripts/debug/flipperapps.py",
|
||||
"fap-set-debug-elf-root build/latest/.extapps",
|
||||
]
|
||||
// "showDevDebugOutput": "raw",
|
||||
@@ -90,27 +95,20 @@
|
||||
"type": "cortex-debug",
|
||||
"servertype": "openocd",
|
||||
"device": "cmsis-dap",
|
||||
"svdFile": "./debug/STM32WB55_CM4.svd",
|
||||
"svdFile": "./scripts/debug/STM32WB55_CM4.svd",
|
||||
"rtos": "FreeRTOS",
|
||||
"configFiles": [
|
||||
"interface/cmsis-dap.cfg",
|
||||
"./debug/stm32wbx.cfg",
|
||||
"./scripts/debug/stm32wbx.cfg",
|
||||
],
|
||||
"postAttachCommands": [
|
||||
"source debug/flipperapps.py",
|
||||
"source scripts/debug/flipperversion.py",
|
||||
"fw-version",
|
||||
"source scripts/debug/flipperapps.py",
|
||||
"fap-set-debug-elf-root build/latest/.extapps",
|
||||
],
|
||||
// "showDevDebugOutput": "raw",
|
||||
},
|
||||
{
|
||||
"name": "fbt debug",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "./lib/scons/scripts/scons.py",
|
||||
"args": [
|
||||
"plugin_dist"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "python debug",
|
||||
"type": "python",
|
||||
|
||||
16
SConstruct
16
SConstruct
@@ -239,19 +239,31 @@ distenv.PhonyTarget(
|
||||
)
|
||||
|
||||
# Debug alien elf
|
||||
debug_other_opts = [
|
||||
"-ex",
|
||||
"source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py",
|
||||
# "-ex",
|
||||
# "source ${FBT_DEBUG_DIR}/FreeRTOS/FreeRTOS.py",
|
||||
"-ex",
|
||||
"source ${FBT_DEBUG_DIR}/flipperversion.py",
|
||||
"-ex",
|
||||
"fw-version",
|
||||
]
|
||||
|
||||
distenv.PhonyTarget(
|
||||
"debug_other",
|
||||
"${GDBPYCOM}",
|
||||
GDBOPTS="${GDBOPTS_BASE}",
|
||||
GDBREMOTE="${OPENOCD_GDB_PIPE}",
|
||||
GDBPYOPTS='-ex "source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py" ',
|
||||
GDBPYOPTS=debug_other_opts,
|
||||
)
|
||||
|
||||
distenv.PhonyTarget(
|
||||
"debug_other_blackmagic",
|
||||
"${GDBPYCOM}",
|
||||
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
|
||||
GDBREMOTE="$${BLACKMAGIC_ADDR}",
|
||||
GDBREMOTE="${BLACKMAGIC_ADDR}",
|
||||
GDBPYOPTS=debug_other_opts,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="mfkey32",
|
||||
name="Mfkey32",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
targets=["f7"],
|
||||
entry_point="mfkey32_main",
|
||||
requires=[
|
||||
"gui",
|
||||
|
||||
252
applications/external/mfkey32/mfkey32.c
vendored
252
applications/external/mfkey32/mfkey32.c
vendored
@@ -1,8 +1,9 @@
|
||||
#pragma GCC optimize("O3")
|
||||
#pragma GCC optimize("-funroll-all-loops")
|
||||
|
||||
// TODO: Handle back button correctly
|
||||
// TODO: Add keys to top of the user dictionary, not the bottom
|
||||
// TODO: More efficient dictionary bruteforce by scanning through hardcoded very common keys and previously found dictionary keys first?
|
||||
// (a cache for napi_key_already_found_for_nonce)
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
@@ -22,6 +23,7 @@
|
||||
#include <lib/toolbox/args.h>
|
||||
#include <lib/flipper_format/flipper_format.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
#define MF_CLASSIC_DICT_FLIPPER_PATH EXT_PATH("nfc/assets/mf_classic_dict.nfc")
|
||||
#define MF_CLASSIC_DICT_USER_PATH EXT_PATH("nfc/assets/mf_classic_dict_user.nfc")
|
||||
@@ -29,9 +31,7 @@
|
||||
#define TAG "Mfkey32"
|
||||
#define NFC_MF_CLASSIC_KEY_LEN (13)
|
||||
|
||||
// MSB_LIMIT: Chunk size (out of 256)
|
||||
#define MSB_LIMIT 16
|
||||
#define MIN_RAM 114500
|
||||
#define MIN_RAM 115632
|
||||
#define LF_POLY_ODD (0x29CE5C)
|
||||
#define LF_POLY_EVEN (0x870804)
|
||||
#define CONST_M1_1 (LF_POLY_EVEN << 1 | 1)
|
||||
@@ -40,9 +40,15 @@
|
||||
#define CONST_M2_2 (LF_POLY_EVEN << 1 | 1)
|
||||
#define BIT(x, n) ((x) >> (n)&1)
|
||||
#define BEBIT(x, n) BIT(x, (n) ^ 24)
|
||||
#define SWAPENDIAN(x) (x = (x >> 8 & 0xff00ff) | (x & 0xff00ff) << 8, x = x >> 16 | x << 16)
|
||||
#define SWAPENDIAN(x) \
|
||||
((x) = ((x) >> 8 & 0xff00ff) | ((x)&0xff00ff) << 8, (x) = (x) >> 16 | (x) << 16)
|
||||
//#define SIZEOF(arr) sizeof(arr) / sizeof(*arr)
|
||||
|
||||
static int eta_round_time = 56;
|
||||
static int eta_total_time = 900;
|
||||
// MSB_LIMIT: Chunk size (out of 256)
|
||||
static int MSB_LIMIT = 16;
|
||||
|
||||
struct Crypto1State {
|
||||
uint32_t odd, even;
|
||||
};
|
||||
@@ -68,7 +74,6 @@ typedef struct {
|
||||
typedef enum {
|
||||
MissingNonces,
|
||||
ZeroNonces,
|
||||
OutOfMemory,
|
||||
} MfkeyError;
|
||||
|
||||
typedef enum {
|
||||
@@ -81,15 +86,20 @@ typedef enum {
|
||||
Help,
|
||||
} MfkeyState;
|
||||
|
||||
// TODO: Can we eliminate any of the members of this struct?
|
||||
typedef struct {
|
||||
FuriMutex* mutex;
|
||||
MfkeyError err;
|
||||
MfkeyState mfkey_state;
|
||||
int cracked;
|
||||
int unique_cracked;
|
||||
int num_completed;
|
||||
int total;
|
||||
int dict_count;
|
||||
int search;
|
||||
int eta_timestamp;
|
||||
int eta_total;
|
||||
int eta_round;
|
||||
bool is_thread_running;
|
||||
bool close_thread_please;
|
||||
FuriThread* mfkeythread;
|
||||
@@ -194,7 +204,7 @@ static inline uint32_t crypt_word(struct Crypto1State* s) {
|
||||
uint32_t res_ret = 0;
|
||||
uint32_t feedin, t;
|
||||
for(int i = 0; i <= 31; i++) {
|
||||
res_ret |= (filter(s->odd) << (24 ^ i));
|
||||
res_ret |= (filter(s->odd) << (24 ^ i)); //-V629
|
||||
feedin = LF_POLY_EVEN & s->even;
|
||||
feedin ^= LF_POLY_ODD & s->odd;
|
||||
s->even = s->even << 1 | (evenparity32(feedin));
|
||||
@@ -431,6 +441,17 @@ int old_recover(
|
||||
return s;
|
||||
}
|
||||
|
||||
static inline int sync_state(ProgramState* program_state) {
|
||||
int ts = furi_hal_rtc_get_timestamp();
|
||||
program_state->eta_round = program_state->eta_round - (ts - program_state->eta_timestamp);
|
||||
program_state->eta_total = program_state->eta_total - (ts - program_state->eta_timestamp);
|
||||
program_state->eta_timestamp = ts;
|
||||
if(program_state->close_thread_please) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calculate_msb_tables(
|
||||
int oks,
|
||||
int eks,
|
||||
@@ -440,7 +461,8 @@ int calculate_msb_tables(
|
||||
struct Msb* odd_msbs,
|
||||
struct Msb* even_msbs,
|
||||
unsigned int* temp_states_odd,
|
||||
unsigned int* temp_states_even) {
|
||||
unsigned int* temp_states_even,
|
||||
ProgramState* program_state) {
|
||||
//FURI_LOG_I(TAG, "MSB GO %i", msb_iter); // DEBUG
|
||||
unsigned int msb_head = (MSB_LIMIT * msb_round); // msb_iter ranges from 0 to (256/MSB_LIMIT)-1
|
||||
unsigned int msb_tail = (MSB_LIMIT * (msb_round + 1));
|
||||
@@ -452,10 +474,13 @@ int calculate_msb_tables(
|
||||
memset(even_msbs, 0, MSB_LIMIT * sizeof(struct Msb));
|
||||
|
||||
for(semi_state = 1 << 20; semi_state >= 0; semi_state--) {
|
||||
//if (main_iter % 2048 == 0) {
|
||||
// FURI_LOG_I(TAG, "On main_iter %i", main_iter); // DEBUG
|
||||
//}
|
||||
if(filter(semi_state) == (oks & 1)) {
|
||||
if(semi_state % 32768 == 0) {
|
||||
if(sync_state(program_state) == 1) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(filter(semi_state) == (oks & 1)) { //-V547
|
||||
states_buffer[0] = semi_state;
|
||||
states_tail = state_loop(states_buffer, oks, CONST_M1_1, CONST_M2_1);
|
||||
|
||||
@@ -478,7 +503,7 @@ int calculate_msb_tables(
|
||||
}
|
||||
}
|
||||
|
||||
if(filter(semi_state) == (eks & 1)) {
|
||||
if(filter(semi_state) == (eks & 1)) { //-V547
|
||||
states_buffer[0] = semi_state;
|
||||
states_tail = state_loop(states_buffer, eks, CONST_M1_2, CONST_M2_2);
|
||||
|
||||
@@ -507,6 +532,12 @@ int calculate_msb_tables(
|
||||
eks >>= 12;
|
||||
|
||||
for(i = 0; i < MSB_LIMIT; i++) {
|
||||
if(sync_state(program_state) == 1) {
|
||||
return 0;
|
||||
}
|
||||
// TODO: Why is this necessary?
|
||||
memset(temp_states_even, 0, sizeof(unsigned int) * (1280));
|
||||
memset(temp_states_odd, 0, sizeof(unsigned int) * (1280));
|
||||
memcpy(temp_states_odd, odd_msbs[i].states, odd_msbs[i].tail * sizeof(unsigned int));
|
||||
memcpy(temp_states_even, even_msbs[i].states, even_msbs[i].tail * sizeof(unsigned int));
|
||||
int res = old_recover(
|
||||
@@ -532,7 +563,8 @@ int calculate_msb_tables(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int recover(struct Crypto1Params* p, int ks2, ProgramState* const program_state) {
|
||||
bool recover(struct Crypto1Params* p, int ks2, ProgramState* program_state) {
|
||||
bool found = false;
|
||||
unsigned int* states_buffer = malloc(sizeof(unsigned int) * (2 << 9));
|
||||
struct Msb* odd_msbs = (struct Msb*)malloc(MSB_LIMIT * sizeof(struct Msb));
|
||||
struct Msb* even_msbs = (struct Msb*)malloc(MSB_LIMIT * sizeof(struct Msb));
|
||||
@@ -547,9 +579,12 @@ int recover(struct Crypto1Params* p, int ks2, ProgramState* const program_state)
|
||||
eks = eks << 1 | BEBIT(ks2, i);
|
||||
}
|
||||
int bench_start = furi_hal_rtc_get_timestamp();
|
||||
program_state->eta_total = eta_total_time;
|
||||
program_state->eta_timestamp = bench_start;
|
||||
for(msb = 0; msb <= ((256 / MSB_LIMIT) - 1); msb++) {
|
||||
//printf("MSB: %i\n", msb);
|
||||
program_state->search = msb;
|
||||
program_state->eta_round = eta_round_time;
|
||||
program_state->eta_total = eta_total_time - (eta_round_time * msb);
|
||||
if(calculate_msb_tables(
|
||||
oks,
|
||||
eks,
|
||||
@@ -559,18 +594,23 @@ int recover(struct Crypto1Params* p, int ks2, ProgramState* const program_state)
|
||||
odd_msbs,
|
||||
even_msbs,
|
||||
temp_states_odd,
|
||||
temp_states_even)) {
|
||||
temp_states_even,
|
||||
program_state)) {
|
||||
int bench_stop = furi_hal_rtc_get_timestamp();
|
||||
FURI_LOG_I(TAG, "Cracked in %i seconds", bench_stop - bench_start);
|
||||
free(states_buffer);
|
||||
free(odd_msbs);
|
||||
free(even_msbs);
|
||||
free(temp_states_odd);
|
||||
free(temp_states_even);
|
||||
return 1;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if(program_state->close_thread_please) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
free(states_buffer);
|
||||
free(odd_msbs);
|
||||
free(even_msbs);
|
||||
free(temp_states_odd);
|
||||
free(temp_states_even);
|
||||
return found;
|
||||
}
|
||||
|
||||
bool napi_mf_classic_dict_check_presence(MfClassicDictType dict_type) {
|
||||
@@ -820,8 +860,7 @@ MfClassicNonceArray* napi_mf_classic_nonce_array_alloc(
|
||||
MfClassicDict* system_dict,
|
||||
bool system_dict_exists,
|
||||
MfClassicDict* user_dict,
|
||||
bool user_dict_exists,
|
||||
ProgramState* const program_state) {
|
||||
ProgramState* program_state) {
|
||||
MfClassicNonceArray* nonce_array = malloc(sizeof(MfClassicNonceArray));
|
||||
MfClassicNonce* remaining_nonce_array_init = malloc(sizeof(MfClassicNonce) * 1);
|
||||
nonce_array->remaining_nonce_array = remaining_nonce_array_init;
|
||||
@@ -853,7 +892,7 @@ MfClassicNonceArray* napi_mf_classic_nonce_array_alloc(
|
||||
// Read total amount of nonces
|
||||
FuriString* next_line;
|
||||
next_line = furi_string_alloc();
|
||||
while(true) {
|
||||
while(!(program_state->close_thread_please)) {
|
||||
if(!stream_read_line(nonce_array->stream, next_line)) {
|
||||
FURI_LOG_T(TAG, "No nonces left");
|
||||
break;
|
||||
@@ -866,56 +905,59 @@ MfClassicNonceArray* napi_mf_classic_nonce_array_alloc(
|
||||
if(!furi_string_start_with_str(next_line, "Sec")) continue;
|
||||
const char* next_line_cstr = furi_string_get_cstr(next_line);
|
||||
MfClassicNonce res = {0};
|
||||
char token[20];
|
||||
int i = 0;
|
||||
const char* ptr = next_line_cstr;
|
||||
while(sscanf(ptr, "%s", token) == 1) {
|
||||
char* endptr;
|
||||
for(i = 0; i <= 17; i++) {
|
||||
if(i != 0) {
|
||||
next_line_cstr = strchr(next_line_cstr, ' ');
|
||||
if(next_line_cstr) {
|
||||
next_line_cstr++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
unsigned long value = strtoul(next_line_cstr, &endptr, 16);
|
||||
switch(i) {
|
||||
case 5:
|
||||
sscanf(token, "%lx", &res.uid);
|
||||
res.uid = value;
|
||||
break;
|
||||
case 7:
|
||||
sscanf(token, "%lx", &res.nt0);
|
||||
res.nt0 = value;
|
||||
break;
|
||||
case 9:
|
||||
sscanf(token, "%lx", &res.nr0_enc);
|
||||
res.nr0_enc = value;
|
||||
break;
|
||||
case 11:
|
||||
sscanf(token, "%lx", &res.ar0_enc);
|
||||
res.ar0_enc = value;
|
||||
break;
|
||||
case 13:
|
||||
sscanf(token, "%lx", &res.nt1);
|
||||
res.nt1 = value;
|
||||
break;
|
||||
case 15:
|
||||
sscanf(token, "%lx", &res.nr1_enc);
|
||||
res.nr1_enc = value;
|
||||
break;
|
||||
case 17:
|
||||
sscanf(token, "%lx", &res.ar1_enc);
|
||||
res.ar1_enc = value;
|
||||
break;
|
||||
default:
|
||||
break; // Do nothing
|
||||
}
|
||||
i++;
|
||||
ptr = strchr(ptr, ' ');
|
||||
if(!ptr) {
|
||||
break;
|
||||
}
|
||||
ptr++;
|
||||
next_line_cstr = endptr;
|
||||
}
|
||||
(program_state->total)++;
|
||||
uint32_t p64b = prng_successor(res.nt1, 64);
|
||||
if((system_dict_exists &&
|
||||
napi_key_already_found_for_nonce(
|
||||
system_dict, res.uid ^ res.nt1, res.nr1_enc, p64b, res.ar1_enc)) ||
|
||||
(user_dict_exists &&
|
||||
napi_key_already_found_for_nonce(
|
||||
user_dict, res.uid ^ res.nt1, res.nr1_enc, p64b, res.ar1_enc))) {
|
||||
(napi_key_already_found_for_nonce(
|
||||
user_dict, res.uid ^ res.nt1, res.nr1_enc, p64b, res.ar1_enc))) {
|
||||
(program_state->cracked)++;
|
||||
(program_state->num_completed)++;
|
||||
continue;
|
||||
}
|
||||
FURI_LOG_I(TAG, "No key found for %lx %lx", res.uid, res.ar1_enc);
|
||||
FURI_LOG_I(TAG, "No key found for %8lx %8lx", res.uid, res.ar1_enc);
|
||||
// TODO: Refactor
|
||||
nonce_array->remaining_nonce_array = realloc(
|
||||
nonce_array->remaining_nonce_array = realloc( //-V701
|
||||
nonce_array->remaining_nonce_array,
|
||||
sizeof(MfClassicNonce) * ((nonce_array->remaining_nonces) + 1));
|
||||
nonce_array->remaining_nonces++;
|
||||
@@ -923,14 +965,13 @@ MfClassicNonceArray* napi_mf_classic_nonce_array_alloc(
|
||||
nonce_array->total_nonces++;
|
||||
}
|
||||
furi_string_free(next_line);
|
||||
stream_rewind(nonce_array->stream);
|
||||
buffered_file_stream_close(nonce_array->stream);
|
||||
|
||||
array_loaded = true;
|
||||
FURI_LOG_I(TAG, "Loaded %lu nonces", nonce_array->total_nonces);
|
||||
} while(false);
|
||||
|
||||
if(!array_loaded) {
|
||||
buffered_file_stream_close(nonce_array->stream);
|
||||
free(nonce_array);
|
||||
nonce_array = NULL;
|
||||
}
|
||||
@@ -948,26 +989,23 @@ void napi_mf_classic_nonce_array_free(MfClassicNonceArray* nonce_array) {
|
||||
}
|
||||
|
||||
static void finished_beep() {
|
||||
// Beep to indicate completion if the speaker is available
|
||||
if(furi_hal_speaker_acquire(1000)) { // Wait up to a second for the speaker
|
||||
float freq = 3000;
|
||||
float volume = 1.0f; // 100% volume
|
||||
furi_hal_speaker_start(freq, volume);
|
||||
furi_delay_ms(75);
|
||||
furi_hal_speaker_stop();
|
||||
furi_hal_speaker_release();
|
||||
}
|
||||
// Beep to indicate completion
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &sequence_audiovisual_alert);
|
||||
notification_message(notification, &sequence_display_backlight_on);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
|
||||
void mfkey32(ProgramState* const program_state) {
|
||||
void mfkey32(ProgramState* program_state) {
|
||||
uint64_t found_key; // recovered key
|
||||
size_t keyarray_size = 0;
|
||||
uint64_t* keyarray = malloc(sizeof(uint64_t) * 1);
|
||||
uint32_t i = 0;
|
||||
uint32_t i = 0, j = 0;
|
||||
// Check for nonces
|
||||
if(!napi_mf_classic_nonces_check_presence()) {
|
||||
program_state->err = MissingNonces;
|
||||
program_state->mfkey_state = Error;
|
||||
free(keyarray);
|
||||
return;
|
||||
}
|
||||
// Read dictionaries (optional)
|
||||
@@ -990,7 +1028,7 @@ void mfkey32(ProgramState* const program_state) {
|
||||
// Read nonces
|
||||
MfClassicNonceArray* nonce_arr;
|
||||
nonce_arr = napi_mf_classic_nonce_array_alloc(
|
||||
system_dict, system_dict_exists, user_dict, user_dict_exists, program_state);
|
||||
system_dict, system_dict_exists, user_dict, program_state);
|
||||
if(system_dict_exists) {
|
||||
napi_mf_classic_dict_free(system_dict);
|
||||
}
|
||||
@@ -1004,15 +1042,13 @@ void mfkey32(ProgramState* const program_state) {
|
||||
return;
|
||||
}
|
||||
if(memmgr_get_free_heap() < MIN_RAM) {
|
||||
// Insufficient RAM
|
||||
program_state->err = OutOfMemory;
|
||||
program_state->mfkey_state = Error;
|
||||
napi_mf_classic_nonce_array_free(nonce_arr);
|
||||
napi_mf_classic_dict_free(user_dict);
|
||||
free(keyarray);
|
||||
return;
|
||||
// System has less than the guaranteed amount of RAM (140 KB) - adjust some parameters to run anyway at half speed
|
||||
eta_round_time *= 2;
|
||||
eta_total_time *= 2;
|
||||
MSB_LIMIT /= 2;
|
||||
}
|
||||
program_state->mfkey_state = MfkeyAttack;
|
||||
// TODO: Work backwards on this array and free memory
|
||||
for(i = 0; i < nonce_arr->total_nonces; i++) {
|
||||
MfClassicNonce next_nonce = nonce_arr->remaining_nonce_array[i];
|
||||
uint32_t p64 = prng_successor(next_nonce.nt0, 64);
|
||||
@@ -1026,9 +1062,10 @@ void mfkey32(ProgramState* const program_state) {
|
||||
next_nonce.ar1_enc)) {
|
||||
nonce_arr->remaining_nonces--;
|
||||
(program_state->cracked)++;
|
||||
(program_state->num_completed)++;
|
||||
continue;
|
||||
}
|
||||
FURI_LOG_I(TAG, "Cracking %lx %lx", next_nonce.uid, next_nonce.ar1_enc);
|
||||
FURI_LOG_I(TAG, "Cracking %8lx %8lx", next_nonce.uid, next_nonce.ar1_enc);
|
||||
struct Crypto1Params p = {
|
||||
0,
|
||||
next_nonce.nr0_enc,
|
||||
@@ -1037,24 +1074,29 @@ void mfkey32(ProgramState* const program_state) {
|
||||
next_nonce.nr1_enc,
|
||||
p64b,
|
||||
next_nonce.ar1_enc};
|
||||
if(recover(&p, next_nonce.ar0_enc ^ p64, program_state) == 0) {
|
||||
if(!recover(&p, next_nonce.ar0_enc ^ p64, program_state)) {
|
||||
if(program_state->close_thread_please) {
|
||||
break;
|
||||
}
|
||||
// No key found in recover()
|
||||
(program_state->num_completed)++;
|
||||
continue;
|
||||
}
|
||||
(program_state->cracked)++;
|
||||
(program_state->num_completed)++;
|
||||
found_key = p.key;
|
||||
bool already_found = false;
|
||||
for(i = 0; i < keyarray_size; i++) {
|
||||
if(keyarray[i] == found_key) {
|
||||
for(j = 0; j < keyarray_size; j++) {
|
||||
if(keyarray[j] == found_key) {
|
||||
already_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(already_found == false) {
|
||||
// New key
|
||||
keyarray = realloc(keyarray, sizeof(uint64_t) * (keyarray_size + 1));
|
||||
keyarray = realloc(keyarray, sizeof(uint64_t) * (keyarray_size + 1)); //-V701
|
||||
keyarray_size += 1;
|
||||
keyarray[keyarray_size - 1] = found_key;
|
||||
(program_state->cracked)++;
|
||||
(program_state->unique_cracked)++;
|
||||
}
|
||||
}
|
||||
@@ -1068,23 +1110,28 @@ void mfkey32(ProgramState* const program_state) {
|
||||
napi_mf_classic_dict_add_key_str(user_dict, temp_key);
|
||||
furi_string_free(temp_key);
|
||||
}
|
||||
napi_mf_classic_nonce_array_free(nonce_arr);
|
||||
if(user_dict_exists) {
|
||||
napi_mf_classic_dict_free(user_dict);
|
||||
if(keyarray_size > 0) {
|
||||
// TODO: Should we use DolphinDeedNfcMfcAdd?
|
||||
DOLPHIN_DEED(DolphinDeedNfcMfcAdd);
|
||||
}
|
||||
napi_mf_classic_nonce_array_free(nonce_arr);
|
||||
napi_mf_classic_dict_free(user_dict);
|
||||
free(keyarray);
|
||||
//FURI_LOG_I(TAG, "mfkey32 function completed normally"); // DEBUG
|
||||
program_state->mfkey_state = Complete;
|
||||
finished_beep();
|
||||
// No need to alert the user if they asked it to stop
|
||||
if(!(program_state->close_thread_please)) {
|
||||
finished_beep();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Screen is 128x64 px
|
||||
static void render_callback(Canvas* const canvas, void* ctx) {
|
||||
furi_assert(ctx);
|
||||
const ProgramState* program_state = ctx;
|
||||
ProgramState* program_state = ctx;
|
||||
furi_mutex_acquire(program_state->mutex, FuriWaitForever);
|
||||
char draw_str[32] = {};
|
||||
char draw_str[44] = {};
|
||||
canvas_clear(canvas);
|
||||
canvas_draw_frame(canvas, 0, 0, 128, 64);
|
||||
canvas_draw_frame(canvas, 0, 15, 128, 64);
|
||||
@@ -1092,27 +1139,44 @@ static void render_callback(Canvas* const canvas, void* ctx) {
|
||||
canvas_draw_str_aligned(canvas, 5, 4, AlignLeft, AlignTop, "Mfkey32");
|
||||
canvas_draw_icon(canvas, 114, 4, &I_mfkey);
|
||||
if(program_state->is_thread_running && program_state->mfkey_state == MfkeyAttack) {
|
||||
float progress = (float)program_state->cracked / (float)program_state->total;
|
||||
elements_progress_bar_with_text(canvas, 5, 18, 118, progress, draw_str);
|
||||
float eta_round = (float)1 - ((float)program_state->eta_round / (float)eta_round_time);
|
||||
float eta_total = (float)1 - ((float)program_state->eta_total / (float)eta_total_time);
|
||||
float progress = (float)program_state->num_completed / (float)program_state->total;
|
||||
if(eta_round < 0) {
|
||||
// Round ETA miscalculated
|
||||
eta_round = 1;
|
||||
program_state->eta_round = 0;
|
||||
}
|
||||
if(eta_total < 0) {
|
||||
// Total ETA miscalculated
|
||||
eta_total = 1;
|
||||
program_state->eta_total = 0;
|
||||
}
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
snprintf(
|
||||
draw_str,
|
||||
sizeof(draw_str),
|
||||
"Keys found: %d/%d (in prog.)",
|
||||
program_state->cracked,
|
||||
"Cracking: %d/%d - in prog.",
|
||||
program_state->num_completed,
|
||||
program_state->total);
|
||||
canvas_draw_str_aligned(canvas, 5, 31, AlignLeft, AlignTop, draw_str);
|
||||
elements_progress_bar_with_text(canvas, 5, 18, 118, progress, draw_str);
|
||||
snprintf(
|
||||
draw_str, sizeof(draw_str), "Search: %d/%d", program_state->search, 256 / MSB_LIMIT);
|
||||
canvas_draw_str_aligned(canvas, 26, 41, AlignLeft, AlignTop, draw_str);
|
||||
draw_str,
|
||||
sizeof(draw_str),
|
||||
"Round: %d/%d - ETA %02d Sec",
|
||||
(program_state->search) + 1, // Zero indexed
|
||||
256 / MSB_LIMIT,
|
||||
program_state->eta_round);
|
||||
elements_progress_bar_with_text(canvas, 5, 31, 118, eta_round, draw_str);
|
||||
snprintf(draw_str, sizeof(draw_str), "Total ETA %03d Sec", program_state->eta_total);
|
||||
elements_progress_bar_with_text(canvas, 5, 44, 118, eta_total, draw_str);
|
||||
} else if(program_state->is_thread_running && program_state->mfkey_state == DictionaryAttack) {
|
||||
elements_progress_bar_with_text(canvas, 5, 18, 118, 0, draw_str);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
snprintf(
|
||||
draw_str, sizeof(draw_str), "Dict solves: %d (in progress)", program_state->cracked);
|
||||
canvas_draw_str_aligned(canvas, 10, 31, AlignLeft, AlignTop, draw_str);
|
||||
canvas_draw_str_aligned(canvas, 10, 18, AlignLeft, AlignTop, draw_str);
|
||||
snprintf(draw_str, sizeof(draw_str), "Keys in dict: %d", program_state->dict_count);
|
||||
canvas_draw_str_aligned(canvas, 26, 41, AlignLeft, AlignTop, draw_str);
|
||||
canvas_draw_str_aligned(canvas, 26, 28, AlignLeft, AlignTop, draw_str);
|
||||
} else if(program_state->mfkey_state == Complete) {
|
||||
// TODO: Scrollable list view to see cracked keys if user presses down
|
||||
elements_progress_bar_with_text(canvas, 5, 18, 118, 1, draw_str);
|
||||
@@ -1142,9 +1206,7 @@ static void render_callback(Canvas* const canvas, void* ctx) {
|
||||
if(program_state->err == MissingNonces) {
|
||||
canvas_draw_str_aligned(canvas, 25, 36, AlignLeft, AlignTop, "No nonces found");
|
||||
} else if(program_state->err == ZeroNonces) {
|
||||
canvas_draw_str_aligned(canvas, 25, 36, AlignLeft, AlignTop, "No nonces to crack");
|
||||
} else if(program_state->err == OutOfMemory) {
|
||||
canvas_draw_str_aligned(canvas, 25, 36, AlignLeft, AlignTop, "Insufficient memory");
|
||||
canvas_draw_str_aligned(canvas, 15, 36, AlignLeft, AlignTop, "Nonces already cracked");
|
||||
} else {
|
||||
// Unhandled error
|
||||
}
|
||||
@@ -1161,11 +1223,12 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void mfkey32_state_init(ProgramState* const program_state) {
|
||||
static void mfkey32_state_init(ProgramState* program_state) {
|
||||
program_state->is_thread_running = false;
|
||||
program_state->mfkey_state = Ready;
|
||||
program_state->cracked = 0;
|
||||
program_state->unique_cracked = 0;
|
||||
program_state->num_completed = 0;
|
||||
program_state->total = 0;
|
||||
program_state->dict_count = 0;
|
||||
}
|
||||
@@ -1190,7 +1253,6 @@ void start_mfkey32_thread(ProgramState* program_state) {
|
||||
int32_t mfkey32_main() {
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
|
||||
|
||||
DOLPHIN_DEED(DolphinDeedPluginStart);
|
||||
ProgramState* program_state = malloc(sizeof(ProgramState));
|
||||
|
||||
mfkey32_state_init(program_state);
|
||||
|
||||
@@ -18,7 +18,7 @@ void nfc_scene_mfkey_complete_on_enter(void* context) {
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
FontSecondary,
|
||||
"Now use mfkey32v2\nto extract keys");
|
||||
"Now use Mfkey32\nto extract keys");
|
||||
widget_add_button_element(
|
||||
nfc->widget, GuiButtonTypeCenter, "OK", nfc_scene_mfkey_complete_callback, nfc);
|
||||
|
||||
@@ -46,4 +46,4 @@ void nfc_scene_mfkey_complete_on_exit(void* context) {
|
||||
Nfc* nfc = context;
|
||||
|
||||
widget_reset(nfc->widget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
PyCortexMDebug
|
||||
==============
|
||||
|
||||
*A set of GDB/Python-based utilities to make life debugging ARM Cortex-M processors a bit easier*
|
||||
|
||||
It will consist of several modules which will hopefully become integrated as they evolve. Presently, there is only one:
|
||||
|
||||
## SVD
|
||||
ARM defines an SVD (System View Description) file format in its CMSIS
|
||||
standard as a means for Cortex-M-based chip manufacturers to provide a
|
||||
common description of peripherals, registers, and register fields. You
|
||||
can download SVD files for different manufacturers
|
||||
[here](http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php).
|
||||
|
||||
My implementation so far has only tested STM32 chips but should hold for others. If others are like those from ST,
|
||||
expect plenty of errors in the file. Like GPIOA having a register named GPIOB_OSPEEDR and lots of 16-bit registers
|
||||
that are listed as 32!
|
||||
|
||||
The implementation consists of two components -- An xml parser module (pysvd) and a GDB file (gdb_svd).
|
||||
I haven't yet worked out a perfect workflow for this, though it's quite easy to use when
|
||||
you already tend to have a GDB initialization file for starting up OpenOCD and the like.
|
||||
However your workflow works, just make sure to, in GDB:
|
||||
|
||||
source gdb_svd.py
|
||||
svd_load [your_svd_file].svd
|
||||
|
||||
These files can be huge so it might take a second or two. Anyways, after that, you can do
|
||||
|
||||
svd
|
||||
|
||||
to list available peripherals with descriptions. Or you can do
|
||||
|
||||
svd [some_peripheral_name]
|
||||
|
||||
to see all of the registers (with their values) for a given peripheral. For more details, run
|
||||
|
||||
svd [some_peripheral_name] [some_register_name]
|
||||
|
||||
to see all of the field values with descriptions.
|
||||
|
||||
You can add format modifiers like:
|
||||
|
||||
* `svd/x` will display values in hex
|
||||
* `svd/o` will display values in octal
|
||||
* `svd/t` or `svd/b` will display values in binary
|
||||
* `svd/a` will display values in hex and try to resolve symbols from the values
|
||||
|
||||
All field values are displayed at the correct lengths as provided by the SVD files.
|
||||
Also, tab completion exists for nearly everything! When in doubt, run `svd help`.
|
||||
|
||||
### TODO
|
||||
|
||||
Enable writing to registers and individual fields
|
||||
|
||||
### Bugs
|
||||
|
||||
There are probably a few. All planning, writing, and testing of this was done in an afternoon. There may be
|
||||
some oddities in working with non-STM32 parts. I'll play with this when I start working with other
|
||||
controllers again. If something's giving you trouble, describe the problem and it shall be fixed.
|
||||
|
||||
## DWT
|
||||
The ARM Data Watchpoint and Trace Unit (DWT) offers data watchpoints and a series of gated cycle counters. For now,
|
||||
I only support the raw cycle counter but facilities are in place to make use of others. As this is independent of the
|
||||
specific device under test, commands are simple and you can configure a clock speed to get real time values from
|
||||
counters.
|
||||
|
||||
dwt configclk 48000000
|
||||
|
||||
will set the current core clock speed. Then
|
||||
|
||||
dwt cyccnt reset
|
||||
dwt cyccnt enable
|
||||
|
||||
will reset and start the cycle counter. At any point
|
||||
|
||||
dwt cycnt
|
||||
|
||||
will then indicate the number of cycles and amount of time that has passed.
|
||||
|
||||
## ITM/ETM support
|
||||
|
||||
This is not implemented yet. I want to have more complete support for some of the nicer debug and trace features
|
||||
on Cortex-M processors. Parts of this will probably be dependent on OpenOCD and possibly on specific interfaces.
|
||||
I'll try to avoid this where possible but can't make any promises.
|
||||
@@ -1,160 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
This file is part of PyCortexMDebug
|
||||
|
||||
PyCortexMDebug is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
PyCortexMDebug is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with PyCortexMDebug. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import gdb
|
||||
import struct
|
||||
|
||||
DWT_CTRL = 0xE0001000
|
||||
DWT_CYCCNT = 0xE0001004
|
||||
DWT_CPICNT = 0xE0001008
|
||||
DWT_EXTCNT = 0xE000100C
|
||||
DWT_SLEEPCNT = 0xE0001010
|
||||
DWT_LSUCNT = 0xE0001014
|
||||
DWT_FOLDCNT = 0xE0001018
|
||||
DWT_PCSR = 0xE000101C
|
||||
|
||||
prefix = "dwt : "
|
||||
|
||||
|
||||
class DWT(gdb.Command):
|
||||
clk = None
|
||||
is_init = False
|
||||
|
||||
def __init__(self):
|
||||
gdb.Command.__init__(self, "dwt", gdb.COMMAND_DATA)
|
||||
|
||||
@staticmethod
|
||||
def read(address, bits=32):
|
||||
"""Read from memory (using print) and return an integer"""
|
||||
value = gdb.selected_inferior().read_memory(address, bits / 8)
|
||||
return struct.unpack_from("<i", value)[0]
|
||||
|
||||
@staticmethod
|
||||
def write(address, value, bits=32):
|
||||
"""Set a value in memory"""
|
||||
gdb.selected_inferior().write_memory(address, bytes(value), bits / 8)
|
||||
|
||||
def invoke(self, args, from_tty):
|
||||
if not self.is_init:
|
||||
self.write(0xE000EDFC, self.read(0xE000EDFC) | (1 << 24))
|
||||
self.write(DWT_CTRL, 0)
|
||||
self.is_init = True
|
||||
|
||||
s = list(map(lambda x: x.lower(), str(args).split(" ")))
|
||||
# Check for empty command
|
||||
if s[0] in ["", "help"]:
|
||||
self.print_help()
|
||||
return ()
|
||||
|
||||
if s[0] == "cyccnt":
|
||||
if len(s) > 1:
|
||||
if s[1][:2] == "en":
|
||||
self.cyccnt_en()
|
||||
elif s[1][0] == "r":
|
||||
self.cyccnt_reset()
|
||||
elif s[1][0] == "d":
|
||||
self.cyccnt_dis()
|
||||
gdb.write(
|
||||
prefix
|
||||
+ "CYCCNT ({}): ".format("ON" if (self.read(DWT_CTRL) & 1) else "OFF")
|
||||
+ self.cycles_str(self.read(DWT_CYCCNT))
|
||||
)
|
||||
elif s[0] == "reset":
|
||||
if len(s) > 1:
|
||||
if s[1] == "cyccnt":
|
||||
self.cyccnt_reset()
|
||||
gdb.write(prefix + "CYCCNT reset\n")
|
||||
if s[1] == "counters":
|
||||
self.cyccnt_reset()
|
||||
gdb.write(prefix + "CYCCNT reset\n")
|
||||
else:
|
||||
self.cyccnt_reset()
|
||||
gdb.write(prefix + "CYCCNT reset\n")
|
||||
else:
|
||||
# Reset everything
|
||||
self.cyccnt_reset()
|
||||
gdb.write(prefix + "CYCCNT reset\n")
|
||||
elif s[0] == "configclk":
|
||||
if len(s) == 2:
|
||||
try:
|
||||
self.clk = float(s[1])
|
||||
except:
|
||||
self.print_help()
|
||||
else:
|
||||
self.print_help()
|
||||
else:
|
||||
# Try to figure out what stupid went on here
|
||||
gdb.write(args)
|
||||
self.print_help()
|
||||
|
||||
@staticmethod
|
||||
def complete(text, word):
|
||||
text = str(text).lower()
|
||||
s = text.split(" ")
|
||||
|
||||
commands = ["configclk", "reset", "cyccnt"]
|
||||
reset_commands = ["counters", "cyccnt"]
|
||||
cyccnt_commands = ["enable", "reset", "disable"]
|
||||
|
||||
if len(s) == 1:
|
||||
return filter(lambda x: x.startswith(s[0]), commands)
|
||||
|
||||
if len(s) == 2:
|
||||
if s[0] == "reset":
|
||||
return filter(lambda x: x.startswith(s[1]), reset_commands)
|
||||
if s[0] == "cyccnt":
|
||||
return filter(lambda x: x.startswith(s[1]), cyccnt_commands)
|
||||
|
||||
def cycles_str(self, cycles):
|
||||
if self.clk:
|
||||
return "%d cycles, %.3es\n" % (cycles, cycles * 1.0 / self.clk)
|
||||
else:
|
||||
return "%d cycles"
|
||||
|
||||
def cyccnt_en(self):
|
||||
self.write(DWT_CTRL, self.read(DWT_CTRL) | 1)
|
||||
|
||||
def cyccnt_dis(self):
|
||||
self.write(DWT_CTRL, self.read(DWT_CTRL) & 0xFFFFFFFE)
|
||||
|
||||
def cyccnt_reset(self, value=0):
|
||||
self.write(DWT_CYCCNT, value)
|
||||
|
||||
def cpicnt_reset(self, value=0):
|
||||
self.write(DWT_CPICNT, value & 0xFF)
|
||||
|
||||
@staticmethod
|
||||
def print_help():
|
||||
gdb.write("Usage:\n")
|
||||
gdb.write("=========\n")
|
||||
gdb.write("dwt:\n")
|
||||
gdb.write("\tList available peripherals\n")
|
||||
gdb.write("dwt configclk [Hz]:\n")
|
||||
gdb.write("\tSet clock for rendering time values in seconds\n")
|
||||
gdb.write("dwt reset:\n")
|
||||
gdb.write("\tReset everything in DWT\n")
|
||||
gdb.write("dwt reset counters:\n")
|
||||
gdb.write("\tReset all DWT counters\n")
|
||||
gdb.write("dwt cyccnt\n")
|
||||
gdb.write("\tDisplay the cycle count\n")
|
||||
gdb.write("\td(default):decimal, x: hex, o: octal, b: binary\n")
|
||||
return
|
||||
|
||||
|
||||
# Registers our class to GDB when sourced:
|
||||
DWT()
|
||||
@@ -1,586 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"Makes working with XML feel like you are working with JSON"
|
||||
|
||||
try:
|
||||
from defusedexpat import pyexpat as expat
|
||||
except ImportError:
|
||||
from xml.parsers import expat
|
||||
|
||||
from xml.sax.saxutils import XMLGenerator
|
||||
from xml.sax.xmlreader import AttributesImpl
|
||||
|
||||
try: # pragma no cover
|
||||
from cStringIO import StringIO
|
||||
except ImportError: # pragma no cover
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
from inspect import isgenerator
|
||||
|
||||
|
||||
class ObjectDict(dict):
|
||||
def __getattr__(self, name):
|
||||
if name in self:
|
||||
return self[name]
|
||||
else:
|
||||
raise AttributeError("No such attribute: " + name)
|
||||
|
||||
|
||||
try: # pragma no cover
|
||||
_basestring = basestring
|
||||
except NameError: # pragma no cover
|
||||
_basestring = str
|
||||
try: # pragma no cover
|
||||
_unicode = unicode
|
||||
except NameError: # pragma no cover
|
||||
_unicode = str
|
||||
|
||||
__author__ = "Martin Blech"
|
||||
__version__ = "0.12.0"
|
||||
__license__ = "MIT"
|
||||
|
||||
|
||||
class ParsingInterrupted(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class _DictSAXHandler(object):
|
||||
def __init__(
|
||||
self,
|
||||
item_depth=0,
|
||||
item_callback=lambda *args: True,
|
||||
xml_attribs=True,
|
||||
attr_prefix="@",
|
||||
cdata_key="#text",
|
||||
force_cdata=False,
|
||||
cdata_separator="",
|
||||
postprocessor=None,
|
||||
dict_constructor=ObjectDict,
|
||||
strip_whitespace=True,
|
||||
namespace_separator=":",
|
||||
namespaces=None,
|
||||
force_list=None,
|
||||
comment_key="#comment",
|
||||
):
|
||||
self.path = []
|
||||
self.stack = []
|
||||
self.data = []
|
||||
self.item = None
|
||||
self.item_depth = item_depth
|
||||
self.xml_attribs = xml_attribs
|
||||
self.item_callback = item_callback
|
||||
self.attr_prefix = attr_prefix
|
||||
self.cdata_key = cdata_key
|
||||
self.force_cdata = force_cdata
|
||||
self.cdata_separator = cdata_separator
|
||||
self.postprocessor = postprocessor
|
||||
self.dict_constructor = dict_constructor
|
||||
self.strip_whitespace = strip_whitespace
|
||||
self.namespace_separator = namespace_separator
|
||||
self.namespaces = namespaces
|
||||
self.namespace_declarations = ObjectDict()
|
||||
self.force_list = force_list
|
||||
self.comment_key = comment_key
|
||||
|
||||
def _build_name(self, full_name):
|
||||
if self.namespaces is None:
|
||||
return full_name
|
||||
i = full_name.rfind(self.namespace_separator)
|
||||
if i == -1:
|
||||
return full_name
|
||||
namespace, name = full_name[:i], full_name[i + 1 :]
|
||||
try:
|
||||
short_namespace = self.namespaces[namespace]
|
||||
except KeyError:
|
||||
short_namespace = namespace
|
||||
if not short_namespace:
|
||||
return name
|
||||
else:
|
||||
return self.namespace_separator.join((short_namespace, name))
|
||||
|
||||
def _attrs_to_dict(self, attrs):
|
||||
if isinstance(attrs, dict):
|
||||
return attrs
|
||||
return self.dict_constructor(zip(attrs[0::2], attrs[1::2]))
|
||||
|
||||
def startNamespaceDecl(self, prefix, uri):
|
||||
self.namespace_declarations[prefix or ""] = uri
|
||||
|
||||
def startElement(self, full_name, attrs):
|
||||
name = self._build_name(full_name)
|
||||
attrs = self._attrs_to_dict(attrs)
|
||||
if attrs and self.namespace_declarations:
|
||||
attrs["xmlns"] = self.namespace_declarations
|
||||
self.namespace_declarations = ObjectDict()
|
||||
self.path.append((name, attrs or None))
|
||||
if len(self.path) > self.item_depth:
|
||||
self.stack.append((self.item, self.data))
|
||||
if self.xml_attribs:
|
||||
attr_entries = []
|
||||
for key, value in attrs.items():
|
||||
key = self.attr_prefix + self._build_name(key)
|
||||
if self.postprocessor:
|
||||
entry = self.postprocessor(self.path, key, value)
|
||||
else:
|
||||
entry = (key, value)
|
||||
if entry:
|
||||
attr_entries.append(entry)
|
||||
attrs = self.dict_constructor(attr_entries)
|
||||
else:
|
||||
attrs = None
|
||||
self.item = attrs or None
|
||||
self.data = []
|
||||
|
||||
def endElement(self, full_name):
|
||||
name = self._build_name(full_name)
|
||||
if len(self.path) == self.item_depth:
|
||||
item = self.item
|
||||
if item is None:
|
||||
item = None if not self.data else self.cdata_separator.join(self.data)
|
||||
|
||||
should_continue = self.item_callback(self.path, item)
|
||||
if not should_continue:
|
||||
raise ParsingInterrupted()
|
||||
if len(self.stack):
|
||||
data = None if not self.data else self.cdata_separator.join(self.data)
|
||||
item = self.item
|
||||
self.item, self.data = self.stack.pop()
|
||||
if self.strip_whitespace and data:
|
||||
data = data.strip() or None
|
||||
if data and self.force_cdata and item is None:
|
||||
item = self.dict_constructor()
|
||||
if item is not None:
|
||||
if data:
|
||||
self.push_data(item, self.cdata_key, data)
|
||||
self.item = self.push_data(self.item, name, item)
|
||||
else:
|
||||
self.item = self.push_data(self.item, name, data)
|
||||
else:
|
||||
self.item = None
|
||||
self.data = []
|
||||
self.path.pop()
|
||||
|
||||
def characters(self, data):
|
||||
if not self.data:
|
||||
self.data = [data]
|
||||
else:
|
||||
self.data.append(data)
|
||||
|
||||
def comments(self, data):
|
||||
if self.strip_whitespace:
|
||||
data = data.strip()
|
||||
self.item = self.push_data(self.item, self.comment_key, data)
|
||||
|
||||
def push_data(self, item, key, data):
|
||||
if self.postprocessor is not None:
|
||||
result = self.postprocessor(self.path, key, data)
|
||||
if result is None:
|
||||
return item
|
||||
key, data = result
|
||||
if item is None:
|
||||
item = self.dict_constructor()
|
||||
try:
|
||||
value = item[key]
|
||||
if isinstance(value, list):
|
||||
value.append(data)
|
||||
else:
|
||||
item[key] = [value, data]
|
||||
except KeyError:
|
||||
if self._should_force_list(key, data):
|
||||
item[key] = [data]
|
||||
else:
|
||||
item[key] = data
|
||||
return item
|
||||
|
||||
def _should_force_list(self, key, value):
|
||||
if not self.force_list:
|
||||
return False
|
||||
if isinstance(self.force_list, bool):
|
||||
return self.force_list
|
||||
try:
|
||||
return key in self.force_list
|
||||
except TypeError:
|
||||
return self.force_list(self.path[:-1], key, value)
|
||||
|
||||
|
||||
def parse(
|
||||
xml_input,
|
||||
encoding=None,
|
||||
expat=expat,
|
||||
process_namespaces=False,
|
||||
namespace_separator=":",
|
||||
disable_entities=True,
|
||||
process_comments=False,
|
||||
**kwargs
|
||||
):
|
||||
"""Parse the given XML input and convert it into a dictionary.
|
||||
|
||||
`xml_input` can either be a `string`, a file-like object, or a generator of strings.
|
||||
|
||||
If `xml_attribs` is `True`, element attributes are put in the dictionary
|
||||
among regular child elements, using `@` as a prefix to avoid collisions. If
|
||||
set to `False`, they are just ignored.
|
||||
|
||||
Simple example::
|
||||
|
||||
>>> import xmltodict
|
||||
>>> doc = xmltodict.parse(\"\"\"
|
||||
... <a prop="x">
|
||||
... <b>1</b>
|
||||
... <b>2</b>
|
||||
... </a>
|
||||
... \"\"\")
|
||||
>>> doc['a']['@prop']
|
||||
u'x'
|
||||
>>> doc['a']['b']
|
||||
[u'1', u'2']
|
||||
|
||||
If `item_depth` is `0`, the function returns a dictionary for the root
|
||||
element (default behavior). Otherwise, it calls `item_callback` every time
|
||||
an item at the specified depth is found and returns `None` in the end
|
||||
(streaming mode).
|
||||
|
||||
The callback function receives two parameters: the `path` from the document
|
||||
root to the item (name-attribs pairs), and the `item` (dict). If the
|
||||
callback's return value is false-ish, parsing will be stopped with the
|
||||
:class:`ParsingInterrupted` exception.
|
||||
|
||||
Streaming example::
|
||||
|
||||
>>> def handle(path, item):
|
||||
... print('path:%s item:%s' % (path, item))
|
||||
... return True
|
||||
...
|
||||
>>> xmltodict.parse(\"\"\"
|
||||
... <a prop="x">
|
||||
... <b>1</b>
|
||||
... <b>2</b>
|
||||
... </a>\"\"\", item_depth=2, item_callback=handle)
|
||||
path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:1
|
||||
path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:2
|
||||
|
||||
The optional argument `postprocessor` is a function that takes `path`,
|
||||
`key` and `value` as positional arguments and returns a new `(key, value)`
|
||||
pair where both `key` and `value` may have changed. Usage example::
|
||||
|
||||
>>> def postprocessor(path, key, value):
|
||||
... try:
|
||||
... return key + ':int', int(value)
|
||||
... except (ValueError, TypeError):
|
||||
... return key, value
|
||||
>>> xmltodict.parse('<a><b>1</b><b>2</b><b>x</b></a>',
|
||||
... postprocessor=postprocessor)
|
||||
ObjectDict([(u'a', ObjectDict([(u'b:int', [1, 2]), (u'b', u'x')]))])
|
||||
|
||||
You can pass an alternate version of `expat` (such as `defusedexpat`) by
|
||||
using the `expat` parameter. E.g:
|
||||
|
||||
>>> import defusedexpat
|
||||
>>> xmltodict.parse('<a>hello</a>', expat=defusedexpat.pyexpat)
|
||||
ObjectDict([(u'a', u'hello')])
|
||||
|
||||
You can use the force_list argument to force lists to be created even
|
||||
when there is only a single child of a given level of hierarchy. The
|
||||
force_list argument is a tuple of keys. If the key for a given level
|
||||
of hierarchy is in the force_list argument, that level of hierarchy
|
||||
will have a list as a child (even if there is only one sub-element).
|
||||
The index_keys operation takes precedence over this. This is applied
|
||||
after any user-supplied postprocessor has already run.
|
||||
|
||||
For example, given this input:
|
||||
<servers>
|
||||
<server>
|
||||
<name>host1</name>
|
||||
<os>Linux</os>
|
||||
<interfaces>
|
||||
<interface>
|
||||
<name>em0</name>
|
||||
<ip_address>10.0.0.1</ip_address>
|
||||
</interface>
|
||||
</interfaces>
|
||||
</server>
|
||||
</servers>
|
||||
|
||||
If called with force_list=('interface',), it will produce
|
||||
this dictionary:
|
||||
{'servers':
|
||||
{'server':
|
||||
{'name': 'host1',
|
||||
'os': 'Linux'},
|
||||
'interfaces':
|
||||
{'interface':
|
||||
[ {'name': 'em0', 'ip_address': '10.0.0.1' } ] } } }
|
||||
|
||||
`force_list` can also be a callable that receives `path`, `key` and
|
||||
`value`. This is helpful in cases where the logic that decides whether
|
||||
a list should be forced is more complex.
|
||||
|
||||
|
||||
If `process_comment` is `True` then comment will be added with comment_key
|
||||
(default=`'#comment'`) to then tag which contains comment
|
||||
|
||||
For example, given this input:
|
||||
<a>
|
||||
<b>
|
||||
<!-- b comment -->
|
||||
<c>
|
||||
<!-- c comment -->
|
||||
1
|
||||
</c>
|
||||
<d>2</d>
|
||||
</b>
|
||||
</a>
|
||||
|
||||
If called with process_comment=True, it will produce
|
||||
this dictionary:
|
||||
'a': {
|
||||
'b': {
|
||||
'#comment': 'b comment',
|
||||
'c': {
|
||||
|
||||
'#comment': 'c comment',
|
||||
'#text': '1',
|
||||
},
|
||||
'd': '2',
|
||||
},
|
||||
}
|
||||
"""
|
||||
handler = _DictSAXHandler(namespace_separator=namespace_separator, **kwargs)
|
||||
if isinstance(xml_input, _unicode):
|
||||
if not encoding:
|
||||
encoding = "utf-8"
|
||||
xml_input = xml_input.encode(encoding)
|
||||
if not process_namespaces:
|
||||
namespace_separator = None
|
||||
parser = expat.ParserCreate(encoding, namespace_separator)
|
||||
try:
|
||||
parser.ordered_attributes = True
|
||||
except AttributeError:
|
||||
# Jython's expat does not support ordered_attributes
|
||||
pass
|
||||
parser.StartNamespaceDeclHandler = handler.startNamespaceDecl
|
||||
parser.StartElementHandler = handler.startElement
|
||||
parser.EndElementHandler = handler.endElement
|
||||
parser.CharacterDataHandler = handler.characters
|
||||
if process_comments:
|
||||
parser.CommentHandler = handler.comments
|
||||
parser.buffer_text = True
|
||||
if disable_entities:
|
||||
try:
|
||||
# Attempt to disable DTD in Jython's expat parser (Xerces-J).
|
||||
feature = "http://apache.org/xml/features/disallow-doctype-decl"
|
||||
parser._reader.setFeature(feature, True)
|
||||
except AttributeError:
|
||||
# For CPython / expat parser.
|
||||
# Anything not handled ends up here and entities aren't expanded.
|
||||
parser.DefaultHandler = lambda x: None
|
||||
# Expects an integer return; zero means failure -> expat.ExpatError.
|
||||
parser.ExternalEntityRefHandler = lambda *x: 1
|
||||
if hasattr(xml_input, "read"):
|
||||
parser.ParseFile(xml_input)
|
||||
elif isgenerator(xml_input):
|
||||
for chunk in xml_input:
|
||||
parser.Parse(chunk, False)
|
||||
parser.Parse(b"", True)
|
||||
else:
|
||||
parser.Parse(xml_input, True)
|
||||
return handler.item
|
||||
|
||||
|
||||
def _process_namespace(name, namespaces, ns_sep=":", attr_prefix="@"):
|
||||
if not namespaces:
|
||||
return name
|
||||
try:
|
||||
ns, name = name.rsplit(ns_sep, 1)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
ns_res = namespaces.get(ns.strip(attr_prefix))
|
||||
name = (
|
||||
"{}{}{}{}".format(
|
||||
attr_prefix if ns.startswith(attr_prefix) else "", ns_res, ns_sep, name
|
||||
)
|
||||
if ns_res
|
||||
else name
|
||||
)
|
||||
return name
|
||||
|
||||
|
||||
def _emit(
|
||||
key,
|
||||
value,
|
||||
content_handler,
|
||||
attr_prefix="@",
|
||||
cdata_key="#text",
|
||||
depth=0,
|
||||
preprocessor=None,
|
||||
pretty=False,
|
||||
newl="\n",
|
||||
indent="\t",
|
||||
namespace_separator=":",
|
||||
namespaces=None,
|
||||
full_document=True,
|
||||
expand_iter=None,
|
||||
):
|
||||
key = _process_namespace(key, namespaces, namespace_separator, attr_prefix)
|
||||
if preprocessor is not None:
|
||||
result = preprocessor(key, value)
|
||||
if result is None:
|
||||
return
|
||||
key, value = result
|
||||
if (
|
||||
not hasattr(value, "__iter__")
|
||||
or isinstance(value, _basestring)
|
||||
or isinstance(value, dict)
|
||||
):
|
||||
value = [value]
|
||||
for index, v in enumerate(value):
|
||||
if full_document and depth == 0 and index > 0:
|
||||
raise ValueError("document with multiple roots")
|
||||
if v is None:
|
||||
v = ObjectDict()
|
||||
elif isinstance(v, bool):
|
||||
if v:
|
||||
v = _unicode("true")
|
||||
else:
|
||||
v = _unicode("false")
|
||||
elif not isinstance(v, dict):
|
||||
if (
|
||||
expand_iter
|
||||
and hasattr(v, "__iter__")
|
||||
and not isinstance(v, _basestring)
|
||||
):
|
||||
v = ObjectDict(((expand_iter, v),))
|
||||
else:
|
||||
v = _unicode(v)
|
||||
if isinstance(v, _basestring):
|
||||
v = ObjectDict(((cdata_key, v),))
|
||||
cdata = None
|
||||
attrs = ObjectDict()
|
||||
children = []
|
||||
for ik, iv in v.items():
|
||||
if ik == cdata_key:
|
||||
cdata = iv
|
||||
continue
|
||||
if ik.startswith(attr_prefix):
|
||||
ik = _process_namespace(
|
||||
ik, namespaces, namespace_separator, attr_prefix
|
||||
)
|
||||
if ik == "@xmlns" and isinstance(iv, dict):
|
||||
for k, v in iv.items():
|
||||
attr = "xmlns{}".format(":{}".format(k) if k else "")
|
||||
attrs[attr] = _unicode(v)
|
||||
continue
|
||||
if not isinstance(iv, _unicode):
|
||||
iv = _unicode(iv)
|
||||
attrs[ik[len(attr_prefix) :]] = iv
|
||||
continue
|
||||
children.append((ik, iv))
|
||||
if pretty:
|
||||
content_handler.ignorableWhitespace(depth * indent)
|
||||
content_handler.startElement(key, AttributesImpl(attrs))
|
||||
if pretty and children:
|
||||
content_handler.ignorableWhitespace(newl)
|
||||
for child_key, child_value in children:
|
||||
_emit(
|
||||
child_key,
|
||||
child_value,
|
||||
content_handler,
|
||||
attr_prefix,
|
||||
cdata_key,
|
||||
depth + 1,
|
||||
preprocessor,
|
||||
pretty,
|
||||
newl,
|
||||
indent,
|
||||
namespaces=namespaces,
|
||||
namespace_separator=namespace_separator,
|
||||
expand_iter=expand_iter,
|
||||
)
|
||||
if cdata is not None:
|
||||
content_handler.characters(cdata)
|
||||
if pretty and children:
|
||||
content_handler.ignorableWhitespace(depth * indent)
|
||||
content_handler.endElement(key)
|
||||
if pretty and depth:
|
||||
content_handler.ignorableWhitespace(newl)
|
||||
|
||||
|
||||
def unparse(
|
||||
input_dict,
|
||||
output=None,
|
||||
encoding="utf-8",
|
||||
full_document=True,
|
||||
short_empty_elements=False,
|
||||
**kwargs
|
||||
):
|
||||
"""Emit an XML document for the given `input_dict` (reverse of `parse`).
|
||||
|
||||
The resulting XML document is returned as a string, but if `output` (a
|
||||
file-like object) is specified, it is written there instead.
|
||||
|
||||
Dictionary keys prefixed with `attr_prefix` (default=`'@'`) are interpreted
|
||||
as XML node attributes, whereas keys equal to `cdata_key`
|
||||
(default=`'#text'`) are treated as character data.
|
||||
|
||||
The `pretty` parameter (default=`False`) enables pretty-printing. In this
|
||||
mode, lines are terminated with `'\n'` and indented with `'\t'`, but this
|
||||
can be customized with the `newl` and `indent` parameters.
|
||||
|
||||
"""
|
||||
if full_document and len(input_dict) != 1:
|
||||
raise ValueError("Document must have exactly one root.")
|
||||
must_return = False
|
||||
if output is None:
|
||||
output = StringIO()
|
||||
must_return = True
|
||||
if short_empty_elements:
|
||||
content_handler = XMLGenerator(output, encoding, True)
|
||||
else:
|
||||
content_handler = XMLGenerator(output, encoding)
|
||||
if full_document:
|
||||
content_handler.startDocument()
|
||||
for key, value in input_dict.items():
|
||||
_emit(key, value, content_handler, full_document=full_document, **kwargs)
|
||||
if full_document:
|
||||
content_handler.endDocument()
|
||||
if must_return:
|
||||
value = output.getvalue()
|
||||
try: # pragma no cover
|
||||
value = value.decode(encoding)
|
||||
except AttributeError: # pragma no cover
|
||||
pass
|
||||
return value
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
import sys
|
||||
import marshal
|
||||
|
||||
try:
|
||||
stdin = sys.stdin.buffer
|
||||
stdout = sys.stdout.buffer
|
||||
except AttributeError:
|
||||
stdin = sys.stdin
|
||||
stdout = sys.stdout
|
||||
|
||||
(item_depth,) = sys.argv[1:]
|
||||
item_depth = int(item_depth)
|
||||
|
||||
def handle_item(path, item):
|
||||
marshal.dump((path, item), stdout)
|
||||
return True
|
||||
|
||||
try:
|
||||
root = parse(
|
||||
stdin,
|
||||
item_depth=item_depth,
|
||||
item_callback=handle_item,
|
||||
dict_constructor=dict,
|
||||
)
|
||||
if item_depth == 0:
|
||||
handle_item([], root)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
3
fbt
3
fbt
@@ -5,6 +5,7 @@
|
||||
set -eu;
|
||||
|
||||
# private variables
|
||||
N_GIT_THREADS="$(getconf _NPROCESSORS_ONLN)";
|
||||
SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd -P)";
|
||||
SCONS_DEFAULT_FLAGS="--warn=target-not-built";
|
||||
SCONS_EP="python3 -m SCons";
|
||||
@@ -28,7 +29,7 @@ if [ -z "$FBT_NO_SYNC" ]; then
|
||||
echo "\".git\" directory not found, please clone repo via \"git clone\"";
|
||||
exit 1;
|
||||
fi
|
||||
git submodule update --init --depth 1;
|
||||
git submodule update --init --depth 1 --jobs "$N_GIT_THREADS";
|
||||
fi
|
||||
|
||||
$SCONS_EP $SCONS_DEFAULT_FLAGS "$@"
|
||||
|
||||
2
fbt.cmd
2
fbt.cmd
@@ -5,7 +5,7 @@ set SCONS_EP=python -m SCons
|
||||
|
||||
if [%FBT_NO_SYNC%] == [] (
|
||||
if exist ".git" (
|
||||
git submodule update --init --depth 1
|
||||
git submodule update --init --depth 1 --jobs %NUMBER_OF_PROCESSORS%
|
||||
) else (
|
||||
echo Not in a git repo, please clone with "git clone"
|
||||
exit /b 1
|
||||
|
||||
@@ -19,10 +19,10 @@ DIST_SUFFIX = "XFW-0046_06052023"
|
||||
# Coprocessor firmware
|
||||
COPRO_OB_DATA = "scripts/ob.data"
|
||||
|
||||
# Must match lib/STM32CubeWB version
|
||||
# Must match lib/stm32wb_copro version
|
||||
COPRO_CUBE_VERSION = "1.13.3"
|
||||
|
||||
COPRO_CUBE_DIR = "lib/STM32CubeWB"
|
||||
COPRO_CUBE_DIR = "lib/stm32wb_copro"
|
||||
|
||||
# Default radio stack
|
||||
COPRO_STACK_BIN = "stm32wb5x_BLE_Stack_light_fw.bin"
|
||||
@@ -32,13 +32,8 @@ COPRO_STACK_TYPE = "ble_light"
|
||||
# Leave 0 to let scripts automatically calculate it
|
||||
COPRO_STACK_ADDR = "0x0"
|
||||
|
||||
# If you override COPRO_CUBE_DIR on command-line, override this as well
|
||||
COPRO_STACK_BIN_DIR = posixpath.join(
|
||||
COPRO_CUBE_DIR,
|
||||
"Projects",
|
||||
"STM32WB_Copro_Wireless_Binaries",
|
||||
"STM32WB5x",
|
||||
)
|
||||
# If you override COPRO_CUBE_DIR on commandline, override this as well
|
||||
COPRO_STACK_BIN_DIR = posixpath.join(COPRO_CUBE_DIR, "firmware")
|
||||
|
||||
# Supported toolchain versions
|
||||
FBT_TOOLCHAIN_VERSIONS = (" 10.3.",)
|
||||
|
||||
@@ -7,7 +7,7 @@ env.Append(
|
||||
libenv = env.Clone(FW_LIB_NAME="flipper${TARGET_HW}")
|
||||
libenv.Append(
|
||||
CPPPATH=[
|
||||
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl",
|
||||
"#/lib/stm32wb_copro/wpan/interface/patterns/ble_thread/tl",
|
||||
]
|
||||
)
|
||||
libenv.ApplyLibFlags()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,26.0,,
|
||||
Version,+,26.2,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@@ -78,33 +78,6 @@ Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid_u2f.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_version.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_vibro.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_adc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_bus.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_comp.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_cortex.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crs.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dma.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dmamux.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_exti.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_gpio.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_hsem.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_i2c.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_ipcc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_iwdg.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lptim.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lpuart.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pka.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pwr.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rcc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rng.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rtc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_spi.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_system.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_tim.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_usart.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_utils.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_wwdg.h,,
|
||||
Header,+,lib/flipper_application/api_hashtable/api_hashtable.h,,
|
||||
Header,+,lib/flipper_application/api_hashtable/compilesort.hpp,,
|
||||
Header,+,lib/flipper_application/flipper_application.h,,
|
||||
@@ -156,6 +129,34 @@ Header,+,lib/one_wire/maxim_crc.h,,
|
||||
Header,+,lib/one_wire/one_wire_host.h,,
|
||||
Header,+,lib/one_wire/one_wire_slave.h,,
|
||||
Header,+,lib/print/wrappers.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_adc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_bus.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_comp.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_cortex.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_crc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_crs.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_dma.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_dmamux.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_exti.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_gpio.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_hsem.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_i2c.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_ipcc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_iwdg.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_lptim.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_lpuart.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_pka.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_pwr.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rcc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rng.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rtc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_spi.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_system.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_tim.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_usart.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_utils.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_wwdg.h,,
|
||||
Header,+,lib/pulse_reader/pulse_reader.h,,
|
||||
Header,+,lib/toolbox/args.h,,
|
||||
Header,+,lib/toolbox/crc32_calc.h,,
|
||||
Header,+,lib/toolbox/dir_walk.h,,
|
||||
@@ -201,8 +202,8 @@ Function,-,LL_EXTI_StructInit,void,LL_EXTI_InitTypeDef*
|
||||
Function,-,LL_GPIO_DeInit,ErrorStatus,GPIO_TypeDef*
|
||||
Function,+,LL_GPIO_Init,ErrorStatus,"GPIO_TypeDef*, LL_GPIO_InitTypeDef*"
|
||||
Function,-,LL_GPIO_StructInit,void,LL_GPIO_InitTypeDef*
|
||||
Function,-,LL_I2C_DeInit,ErrorStatus,I2C_TypeDef*
|
||||
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, LL_I2C_InitTypeDef*"
|
||||
Function,-,LL_I2C_DeInit,ErrorStatus,const I2C_TypeDef*
|
||||
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, const LL_I2C_InitTypeDef*"
|
||||
Function,-,LL_I2C_StructInit,void,LL_I2C_InitTypeDef*
|
||||
Function,-,LL_Init1msTick,void,uint32_t
|
||||
Function,+,LL_LPTIM_DeInit,ErrorStatus,LPTIM_TypeDef*
|
||||
@@ -823,6 +824,7 @@ Function,+,furi_hal_bt_change_app,_Bool,"FuriHalBtProfile, GapEventCallback, voi
|
||||
Function,+,furi_hal_bt_clear_white_list,_Bool,
|
||||
Function,+,furi_hal_bt_dump_state,void,FuriString*
|
||||
Function,+,furi_hal_bt_ensure_c2_mode,_Bool,BleGlueC2Mode
|
||||
Function,-,furi_hal_bt_get_hardfault_info,const FuriHalBtHardfaultInfo*,
|
||||
Function,+,furi_hal_bt_get_key_storage_buff,void,"uint8_t**, uint16_t*"
|
||||
Function,+,furi_hal_bt_get_radio_stack,FuriHalBtStack,
|
||||
Function,+,furi_hal_bt_get_rssi,float,
|
||||
@@ -1575,6 +1577,15 @@ Function,+,protocol_dict_render_brief_data,void,"ProtocolDict*, FuriString*, siz
|
||||
Function,+,protocol_dict_render_data,void,"ProtocolDict*, FuriString*, size_t"
|
||||
Function,+,protocol_dict_set_data,void,"ProtocolDict*, size_t, const uint8_t*, size_t"
|
||||
Function,-,pselect,int,"int, fd_set*, fd_set*, fd_set*, const timespec*, const sigset_t*"
|
||||
Function,-,pulse_reader_alloc,PulseReader*,"const GpioPin*, uint32_t"
|
||||
Function,-,pulse_reader_free,void,PulseReader*
|
||||
Function,-,pulse_reader_receive,uint32_t,"PulseReader*, int"
|
||||
Function,-,pulse_reader_samples,uint32_t,PulseReader*
|
||||
Function,-,pulse_reader_set_bittime,void,"PulseReader*, uint32_t"
|
||||
Function,-,pulse_reader_set_pull,void,"PulseReader*, GpioPull"
|
||||
Function,-,pulse_reader_set_timebase,void,"PulseReader*, PulseReaderUnit"
|
||||
Function,-,pulse_reader_start,void,PulseReader*
|
||||
Function,-,pulse_reader_stop,void,PulseReader*
|
||||
Function,-,putc,int,"int, FILE*"
|
||||
Function,-,putc_unlocked,int,"int, FILE*"
|
||||
Function,-,putchar,int,int
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
"flipper18",
|
||||
"furi",
|
||||
"freertos",
|
||||
"stm32cubewb",
|
||||
"stm32wb",
|
||||
"hwdrivers",
|
||||
"fatfs",
|
||||
"littlefs",
|
||||
@@ -54,4 +54,4 @@
|
||||
"infrared",
|
||||
"st25rfal002"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,26.0,,
|
||||
Version,+,26.2,,
|
||||
Header,+,applications/main/fap_loader/fap_loader_app.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
@@ -87,35 +87,6 @@ Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid_u2f.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_version.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_vibro.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_adc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_bus.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_comp.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_cortex.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crs.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dma.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dmamux.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_exti.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_gpio.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_hsem.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_i2c.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_ipcc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_iwdg.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lptim.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lpuart.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pka.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pwr.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rcc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rng.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rtc.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_spi.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_system.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_tim.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_usart.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_utils.h,,
|
||||
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_wwdg.h,,
|
||||
Header,-,lib/STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h,,
|
||||
Header,+,lib/STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h,,
|
||||
Header,+,lib/drivers/rgb_backlight.h,,
|
||||
Header,+,lib/flipper_application/api_hashtable/api_hashtable.h,,
|
||||
Header,+,lib/flipper_application/api_hashtable/compilesort.hpp,,
|
||||
@@ -182,6 +153,33 @@ Header,+,lib/one_wire/one_wire_host.h,,
|
||||
Header,+,lib/one_wire/one_wire_slave.h,,
|
||||
Header,+,lib/print/wrappers.h,,
|
||||
Header,+,lib/pulse_reader/pulse_reader.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_adc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_bus.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_comp.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_cortex.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_crc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_crs.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_dma.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_dmamux.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_exti.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_gpio.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_hsem.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_i2c.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_ipcc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_iwdg.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_lptim.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_lpuart.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_pka.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_pwr.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rcc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rng.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rtc.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_spi.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_system.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_tim.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_usart.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_utils.h,,
|
||||
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_wwdg.h,,
|
||||
Header,+,lib/subghz/blocks/const.h,,
|
||||
Header,+,lib/subghz/blocks/decoder.h,,
|
||||
Header,+,lib/subghz/blocks/encoder.h,,
|
||||
@@ -243,8 +241,8 @@ Function,-,LL_EXTI_StructInit,void,LL_EXTI_InitTypeDef*
|
||||
Function,-,LL_GPIO_DeInit,ErrorStatus,GPIO_TypeDef*
|
||||
Function,+,LL_GPIO_Init,ErrorStatus,"GPIO_TypeDef*, LL_GPIO_InitTypeDef*"
|
||||
Function,-,LL_GPIO_StructInit,void,LL_GPIO_InitTypeDef*
|
||||
Function,-,LL_I2C_DeInit,ErrorStatus,I2C_TypeDef*
|
||||
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, LL_I2C_InitTypeDef*"
|
||||
Function,-,LL_I2C_DeInit,ErrorStatus,const I2C_TypeDef*
|
||||
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, const LL_I2C_InitTypeDef*"
|
||||
Function,-,LL_I2C_StructInit,void,LL_I2C_InitTypeDef*
|
||||
Function,-,LL_Init1msTick,void,uint32_t
|
||||
Function,+,LL_LPTIM_DeInit,ErrorStatus,LPTIM_TypeDef*
|
||||
@@ -1093,6 +1091,7 @@ Function,+,furi_hal_bt_clear_white_list,_Bool,
|
||||
Function,+,furi_hal_bt_dump_state,void,FuriString*
|
||||
Function,+,furi_hal_bt_ensure_c2_mode,_Bool,BleGlueC2Mode
|
||||
Function,+,furi_hal_bt_get_conn_rssi,uint32_t,uint8_t*
|
||||
Function,-,furi_hal_bt_get_hardfault_info,const FuriHalBtHardfaultInfo*,
|
||||
Function,+,furi_hal_bt_get_key_storage_buff,void,"uint8_t**, uint16_t*"
|
||||
Function,+,furi_hal_bt_get_profile_adv_name,const char*,FuriHalBtProfile
|
||||
Function,+,furi_hal_bt_get_profile_mac_addr,const uint8_t*,FuriHalBtProfile
|
||||
@@ -4571,7 +4570,6 @@ Function,+,uECC_sign,int,"const uint8_t*, const uint8_t*, unsigned, uint8_t*, uE
|
||||
Function,-,uECC_sign_deterministic,int,"const uint8_t*, const uint8_t*, unsigned, const uECC_HashContext*, uint8_t*, uECC_Curve"
|
||||
Function,-,uECC_valid_public_key,int,"const uint8_t*, uECC_Curve"
|
||||
Function,-,uECC_verify,int,"const uint8_t*, const uint8_t*, unsigned, const uint8_t*, uECC_Curve"
|
||||
Function,-,ucStreamBufferGetStreamBufferType,uint8_t,StreamBufferHandle_t
|
||||
Function,+,uint8_to_hex_chars,void,"const uint8_t*, uint8_t*, int"
|
||||
Function,-,ulTaskGenericNotifyTake,uint32_t,"UBaseType_t, BaseType_t, TickType_t"
|
||||
Function,-,ulTaskGenericNotifyValueClear,uint32_t,"TaskHandle_t, UBaseType_t, uint32_t"
|
||||
@@ -4583,7 +4581,6 @@ Function,-,usbd_poll,void,usbd_device*
|
||||
Function,-,utf8_show,void,
|
||||
Function,-,utoa,char*,"unsigned, char*, int"
|
||||
Function,-,uxListRemove,UBaseType_t,ListItem_t*
|
||||
Function,-,uxStreamBufferGetStreamBufferNumber,UBaseType_t,StreamBufferHandle_t
|
||||
Function,-,uxTaskGetNumberOfTasks,UBaseType_t,
|
||||
Function,-,uxTaskGetStackHighWaterMark,UBaseType_t,TaskHandle_t
|
||||
Function,-,uxTaskGetStackHighWaterMark2,uint16_t,TaskHandle_t
|
||||
@@ -4608,8 +4605,6 @@ Function,-,vPortFree,void,void*
|
||||
Function,-,vPortGetHeapStats,void,HeapStats_t*
|
||||
Function,-,vPortInitialiseBlocks,void,
|
||||
Function,-,vPortSuppressTicksAndSleep,void,TickType_t
|
||||
Function,+,vStreamBufferDelete,void,StreamBufferHandle_t
|
||||
Function,-,vStreamBufferSetStreamBufferNumber,void,"StreamBufferHandle_t, UBaseType_t"
|
||||
Function,-,vTaskAllocateMPURegions,void,"TaskHandle_t, const MemoryRegion_t*"
|
||||
Function,-,vTaskDelay,void,const TickType_t
|
||||
Function,-,vTaskDelete,void,TaskHandle_t
|
||||
@@ -4755,21 +4750,6 @@ Function,+,widget_reset,void,Widget*
|
||||
Function,-,xPortGetFreeHeapSize,size_t,
|
||||
Function,-,xPortGetMinimumEverFreeHeapSize,size_t,
|
||||
Function,-,xPortStartScheduler,BaseType_t,
|
||||
Function,-,xStreamBufferBytesAvailable,size_t,StreamBufferHandle_t
|
||||
Function,+,xStreamBufferGenericCreate,StreamBufferHandle_t,"size_t, size_t, BaseType_t"
|
||||
Function,-,xStreamBufferGenericCreateStatic,StreamBufferHandle_t,"size_t, size_t, BaseType_t, uint8_t*, StaticStreamBuffer_t*"
|
||||
Function,-,xStreamBufferIsEmpty,BaseType_t,StreamBufferHandle_t
|
||||
Function,-,xStreamBufferIsFull,BaseType_t,StreamBufferHandle_t
|
||||
Function,-,xStreamBufferNextMessageLengthBytes,size_t,StreamBufferHandle_t
|
||||
Function,+,xStreamBufferReceive,size_t,"StreamBufferHandle_t, void*, size_t, TickType_t"
|
||||
Function,-,xStreamBufferReceiveCompletedFromISR,BaseType_t,"StreamBufferHandle_t, BaseType_t*"
|
||||
Function,-,xStreamBufferReceiveFromISR,size_t,"StreamBufferHandle_t, void*, size_t, BaseType_t*"
|
||||
Function,-,xStreamBufferReset,BaseType_t,StreamBufferHandle_t
|
||||
Function,-,xStreamBufferSend,size_t,"StreamBufferHandle_t, const void*, size_t, TickType_t"
|
||||
Function,-,xStreamBufferSendCompletedFromISR,BaseType_t,"StreamBufferHandle_t, BaseType_t*"
|
||||
Function,+,xStreamBufferSendFromISR,size_t,"StreamBufferHandle_t, const void*, size_t, BaseType_t*"
|
||||
Function,-,xStreamBufferSetTriggerLevel,BaseType_t,"StreamBufferHandle_t, size_t"
|
||||
Function,-,xStreamBufferSpacesAvailable,size_t,StreamBufferHandle_t
|
||||
Function,-,xTaskAbortDelay,BaseType_t,TaskHandle_t
|
||||
Function,-,xTaskCallApplicationTaskHook,BaseType_t,"TaskHandle_t, void*"
|
||||
Function,-,xTaskCatchUpTicks,BaseType_t,TickType_t
|
||||
|
||||
|
@@ -54,6 +54,26 @@ void ble_glue_set_key_storage_changed_callback(
|
||||
ble_glue->context = context;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* TL hook to catch hardfaults */
|
||||
|
||||
int32_t ble_glue_TL_SYS_SendCmd(uint8_t* buffer, uint16_t size) {
|
||||
if(furi_hal_bt_get_hardfault_info()) {
|
||||
furi_crash("ST(R) Copro(R) HardFault");
|
||||
}
|
||||
|
||||
return TL_SYS_SendCmd(buffer, size);
|
||||
}
|
||||
|
||||
void shci_register_io_bus(tSHciIO* fops) {
|
||||
/* Register IO bus services */
|
||||
fops->Init = TL_SYS_Init;
|
||||
fops->Send = ble_glue_TL_SYS_SendCmd;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ble_glue_init() {
|
||||
ble_glue = malloc(sizeof(BleGlue));
|
||||
ble_glue->status = BleGlueStatusStartup;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
/* Time, in ms, to wait for mode transition before crashing */
|
||||
#define C2_MODE_SWITCH_TIMEOUT 10000
|
||||
|
||||
#define FURI_HAL_BT_HARDFAULT_INFO_MAGIC 0x1170FD0F
|
||||
|
||||
FuriMutex* furi_hal_bt_core2_mtx = NULL;
|
||||
static FuriHalBtStack furi_hal_bt_stack = FuriHalBtStackUnknown;
|
||||
|
||||
@@ -469,6 +471,15 @@ bool furi_hal_bt_ensure_c2_mode(BleGlueC2Mode mode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const FuriHalBtHardfaultInfo* furi_hal_bt_get_hardfault_info() {
|
||||
/* AN5289, 4.8.2 */
|
||||
const FuriHalBtHardfaultInfo* info = (FuriHalBtHardfaultInfo*)(SRAM2A_BASE);
|
||||
if(info->magic != FURI_HAL_BT_HARDFAULT_INFO_MAGIC) {
|
||||
return NULL;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
void furi_hal_bt_set_profile_adv_name(
|
||||
FuriHalBtProfile profile,
|
||||
const char name[FURI_HAL_BT_ADV_NAME_LENGTH]) {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define FURI_HAL_FLASH_OPT_KEY2 0x4C5D6E7F
|
||||
#define FURI_HAL_FLASH_OB_TOTAL_WORDS (0x80 / (sizeof(uint32_t) * 2))
|
||||
|
||||
/* lib/STM32CubeWB/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_RfWithFlash/Core/Src/flash_driver.c
|
||||
/* STM32CubeWB/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_RfWithFlash/Core/Src/flash_driver.c
|
||||
* ProcessSingleFlashOperation, quote:
|
||||
> In most BLE application, the flash should not be blocked by the CPU2 longer than FLASH_TIMEOUT_VALUE (1000ms)
|
||||
> However, it could be that for some marginal application, this time is longer.
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"flipper7",
|
||||
"furi",
|
||||
"freertos",
|
||||
"stm32cubewb",
|
||||
"stm32wb",
|
||||
"hwdrivers",
|
||||
"fatfs",
|
||||
"littlefs",
|
||||
@@ -44,4 +44,4 @@
|
||||
"flipperformat",
|
||||
"toolbox"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -224,6 +224,19 @@ uint32_t furi_hal_bt_get_transmitted_packets();
|
||||
*/
|
||||
bool furi_hal_bt_ensure_c2_mode(BleGlueC2Mode mode);
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
uint32_t source_pc;
|
||||
uint32_t source_lr;
|
||||
uint32_t source_sp;
|
||||
} FuriHalBtHardfaultInfo;
|
||||
|
||||
/** Get hardfault info
|
||||
*
|
||||
* @return hardfault info. NULL if no hardfault
|
||||
*/
|
||||
const FuriHalBtHardfaultInfo* furi_hal_bt_get_hardfault_info();
|
||||
|
||||
/** Modify profile advertisement name and restart bluetooth
|
||||
* @param[in] profile profile type
|
||||
* @param[in] name new adv name
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <furi_hal_power.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <furi_hal_debug.h>
|
||||
#include <furi_hal_bt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
@@ -87,6 +88,20 @@ static void __furi_print_stack_info() {
|
||||
__furi_put_uint32_as_text(uxTaskGetStackHighWaterMark(NULL) * 4);
|
||||
}
|
||||
|
||||
static void __furi_print_bt_stack_info() {
|
||||
const FuriHalBtHardfaultInfo* fault_info = furi_hal_bt_get_hardfault_info();
|
||||
if(fault_info == NULL) {
|
||||
furi_hal_console_puts("\r\n\tcore2: not faulted");
|
||||
} else {
|
||||
furi_hal_console_puts("\r\n\tcore2: hardfaulted.\r\n\tPC: ");
|
||||
__furi_put_uint32_as_hex(fault_info->source_pc);
|
||||
furi_hal_console_puts("\r\n\tLR: ");
|
||||
__furi_put_uint32_as_hex(fault_info->source_lr);
|
||||
furi_hal_console_puts("\r\n\tSP: ");
|
||||
__furi_put_uint32_as_hex(fault_info->source_sp);
|
||||
}
|
||||
}
|
||||
|
||||
static void __furi_print_heap_info() {
|
||||
furi_hal_console_puts("\r\n\t heap total: ");
|
||||
__furi_put_uint32_as_text(xPortGetTotalHeapSize());
|
||||
@@ -136,6 +151,7 @@ FURI_NORETURN void __furi_crash() {
|
||||
__furi_print_stack_info();
|
||||
}
|
||||
__furi_print_heap_info();
|
||||
__furi_print_bt_stack_info();
|
||||
|
||||
#ifndef FURI_DEBUG
|
||||
// Check if debug enabled by DAP
|
||||
|
||||
@@ -1,25 +1,38 @@
|
||||
# Structure
|
||||
|
||||
- `app-scened-template` - Scened template app library
|
||||
- `app-template` - Template app library
|
||||
- `FreeRTOS-Kernel` - FreeRTOS kernel source code
|
||||
- `FreeRTOS-glue` - Extra glue to hold together FreeRTOS kernel and flipper firmware
|
||||
- `ST25RFAL002` - ST25R3916 Driver and protocol stack
|
||||
- `app-scened-template` - C++ app library
|
||||
- `callback-connector` - Callback connector library
|
||||
- `drivers` - Drivers that we wrote
|
||||
- `fatfs` - External storage file system
|
||||
- `cmsis_core` - CMSIS Core package, contain cortex-m core headers
|
||||
- `cxxheaderparser` - C++ headers parser, used by SDK bundler
|
||||
- `digital_signal` - Digital signal library: used by NFC for software implemented protocols
|
||||
- `drivers` - Various flipper drivers
|
||||
- `fatfs` - FatFS file system driver
|
||||
- `flipper_application` - Flipper application library, used for FAPs
|
||||
- `flipper_format` - Flipper File Format library
|
||||
- `fnv1a-hash` - Fnv1a hash library
|
||||
- `heatshrink` - Image compression library
|
||||
- `infrared` - Infrared library
|
||||
- `libusb_stm32` - STM32 USB library
|
||||
- `littlefs` - Internal storage file system
|
||||
- `micro-ecc` - Elliptic Curve Crytography library
|
||||
- `microtar` - TAR archive support library
|
||||
- `mlib` - Algorithms and containers
|
||||
- `nanopb` - Nano Protobuf library
|
||||
- `nfc` - Nfc library
|
||||
- `one_wire` - One wire library
|
||||
- `qrcode` - Qr code generator library
|
||||
- `ST25RFAL002` - ST253916 driver and NFC hal
|
||||
- `STM32CubeWB` - STM32WB series cube package
|
||||
- `subghz` - SubGhz library
|
||||
- `toolbox` - Toolbox of things that we are using but don't place in core
|
||||
- `u8g2` - Graphics library that we use to draw GUI
|
||||
- `fnv1a-hash` - FNV-1a hash library
|
||||
- `heatshrink` - Heatshrink compression library
|
||||
- `ibutton` - ibutton library, used by iButton application
|
||||
- `infrared` - Infrared library, used by Infrared application
|
||||
- `lfrfid` - LF-RFID library, used by LF RFID application
|
||||
- `libusb_stm32` - LibUSB for STM32 series MCU
|
||||
- `littlefs` - LittleFS file system driver, used by internal storage
|
||||
- `mbedtls` - MbedTLS cryptography library
|
||||
- `micro-ecc` - MicroECC cryptography library
|
||||
- `microtar` - MicroTAR library
|
||||
- `mlib` - M-Lib C containers library
|
||||
- `nanopb` - NanoPB library, protobuf implementation for MCU
|
||||
- `nfc` - NFC library, used by NFC application
|
||||
- `one_wire` - OneWire library, used by iButton application
|
||||
- `print` - Tiny printf implementation
|
||||
- `pulse_reader` - Pulse Reader library used by NFC for software implemented protocols
|
||||
- `qrcode` - QR-Code library
|
||||
- `stm32wb_cmsis` - STM32WB series CMSIS headers, extends CMSIS Core
|
||||
- `stm32wb_copro` - STM32WB Copro library: contains WPAN and radio co-processor firmware
|
||||
- `stm32wb_hal` - STM32WB HAL library, extends STM32WB CMSIS and provides HAL
|
||||
- `subghz` - Subghz library, used by SubGhz application
|
||||
- `toolbox` - Toolbox library, contains various things that is used by flipper firmware
|
||||
- `u8g2` - u8g2 graphics library, used by GUI subsystem
|
||||
- `update_util` - update utilities library, used by updater
|
||||
@@ -80,7 +80,7 @@ env.Append(
|
||||
|
||||
libs = env.BuildModules(
|
||||
[
|
||||
"STM32CubeWB",
|
||||
"stm32wb",
|
||||
"freertos",
|
||||
"print",
|
||||
"microtar",
|
||||
|
||||
Submodule lib/STM32CubeWB deleted from a9e29b431f
@@ -1,78 +0,0 @@
|
||||
Import("env")
|
||||
|
||||
env.Append(
|
||||
CPPPATH=[
|
||||
"#/lib/STM32CubeWB/Drivers/CMSIS/Device/ST/STM32WBxx/Include",
|
||||
"#/lib/STM32CubeWB/Drivers/CMSIS/Include",
|
||||
"#/lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc",
|
||||
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
"STM32WB",
|
||||
"STM32WB55xx",
|
||||
"USE_FULL_ASSERT",
|
||||
"USE_FULL_LL_DRIVER",
|
||||
],
|
||||
SDK_HEADERS=[
|
||||
*env.GlobRecursive(
|
||||
"*_ll_*.h",
|
||||
"#/lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/",
|
||||
exclude="*usb.h",
|
||||
),
|
||||
File("STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h"),
|
||||
File(
|
||||
"STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h"
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
if env["RAM_EXEC"]:
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
"VECT_TAB_SRAM",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
libenv = env.Clone(FW_LIB_NAME="stm32cubewb")
|
||||
libenv.Append(
|
||||
CPPPATH=[
|
||||
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/ble",
|
||||
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core",
|
||||
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread",
|
||||
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/shci",
|
||||
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl",
|
||||
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities",
|
||||
]
|
||||
)
|
||||
libenv.ApplyLibFlags()
|
||||
|
||||
sources = libenv.GlobRecursive(
|
||||
"*_ll_*.c", "STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Src/", exclude="*usb.c"
|
||||
)
|
||||
sources += Glob(
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/shci/*.c",
|
||||
source=True,
|
||||
)
|
||||
sources += Glob(
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl/*_tl*.c",
|
||||
source=True,
|
||||
)
|
||||
sources += [
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl/tl_mbox.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/svc/Src/svc_ctl.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_gap_aci.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_gatt_aci.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_hal_aci.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_hci_le.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_l2cap_aci.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/template/osal.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/dbg_trace.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/otp.c",
|
||||
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/stm_list.c",
|
||||
]
|
||||
|
||||
|
||||
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
|
||||
libenv.Install("${LIB_DIST_DIR}", lib)
|
||||
Return("lib")
|
||||
894
lib/cmsis_core/cmsis_armcc.h
Normal file
894
lib/cmsis_core/cmsis_armcc.h
Normal file
@@ -0,0 +1,894 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_armcc.h
|
||||
* @brief CMSIS compiler ARMCC (Arm Compiler 5) header file
|
||||
* @version V5.4.0
|
||||
* @date 20. January 2023
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2023 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CMSIS_ARMCC_H
|
||||
#define __CMSIS_ARMCC_H
|
||||
|
||||
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
|
||||
#error "Please use Arm Compiler Toolchain V4.0.677 or later!"
|
||||
#endif
|
||||
|
||||
/* CMSIS compiler control architecture macros */
|
||||
#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
|
||||
(defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
|
||||
#define __ARM_ARCH_6M__ 1
|
||||
#endif
|
||||
|
||||
#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
|
||||
#define __ARM_ARCH_7M__ 1
|
||||
#endif
|
||||
|
||||
#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
|
||||
#define __ARM_ARCH_7EM__ 1
|
||||
#endif
|
||||
|
||||
/* __ARM_ARCH_8M_BASE__ not applicable */
|
||||
/* __ARM_ARCH_8M_MAIN__ not applicable */
|
||||
/* __ARM_ARCH_8_1M_MAIN__ not applicable */
|
||||
|
||||
/* CMSIS compiler control DSP macros */
|
||||
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
#define __ARM_FEATURE_DSP 1
|
||||
#endif
|
||||
|
||||
/* CMSIS compiler specific defines */
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE __inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static __inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE static __forceinline
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __declspec(noreturn)
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT __packed struct
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION __packed union
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
#define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
#define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
#define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#define __RESTRICT __restrict
|
||||
#endif
|
||||
#ifndef __COMPILER_BARRIER
|
||||
#define __COMPILER_BARRIER() __memory_changed()
|
||||
#endif
|
||||
#ifndef __NO_INIT
|
||||
#define __NO_INIT __attribute__ ((section (".bss.noinit"), zero_init))
|
||||
#endif
|
||||
#ifndef __ALIAS
|
||||
#define __ALIAS(x) __attribute__ ((alias(x)))
|
||||
#endif
|
||||
|
||||
/* ######################### Startup and Lowlevel Init ######################## */
|
||||
|
||||
#ifndef __PROGRAM_START
|
||||
#define __PROGRAM_START __main
|
||||
#endif
|
||||
|
||||
#ifndef __INITIAL_SP
|
||||
#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
|
||||
#endif
|
||||
|
||||
#ifndef __STACK_LIMIT
|
||||
#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
|
||||
#endif
|
||||
|
||||
#ifndef __VECTOR_TABLE
|
||||
#define __VECTOR_TABLE __Vectors
|
||||
#endif
|
||||
|
||||
#ifndef __VECTOR_TABLE_ATTRIBUTE
|
||||
#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET")))
|
||||
#endif
|
||||
|
||||
/* ########################## Core Instruction Access ######################### */
|
||||
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
|
||||
Access to dedicated instructions
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief No Operation
|
||||
\details No Operation does nothing. This instruction can be used for code alignment purposes.
|
||||
*/
|
||||
#define __NOP __nop
|
||||
|
||||
|
||||
/**
|
||||
\brief Wait For Interrupt
|
||||
\details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
|
||||
*/
|
||||
#define __WFI __wfi
|
||||
|
||||
|
||||
/**
|
||||
\brief Wait For Event
|
||||
\details Wait For Event is a hint instruction that permits the processor to enter
|
||||
a low-power state until one of a number of events occurs.
|
||||
*/
|
||||
#define __WFE __wfe
|
||||
|
||||
|
||||
/**
|
||||
\brief Send Event
|
||||
\details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
|
||||
*/
|
||||
#define __SEV __sev
|
||||
|
||||
|
||||
/**
|
||||
\brief Instruction Synchronization Barrier
|
||||
\details Instruction Synchronization Barrier flushes the pipeline in the processor,
|
||||
so that all instructions following the ISB are fetched from cache or memory,
|
||||
after the instruction has been completed.
|
||||
*/
|
||||
#define __ISB() __isb(0xF)
|
||||
|
||||
/**
|
||||
\brief Data Synchronization Barrier
|
||||
\details Acts as a special kind of Data Memory Barrier.
|
||||
It completes when all explicit memory accesses before this instruction complete.
|
||||
*/
|
||||
#define __DSB() __dsb(0xF)
|
||||
|
||||
/**
|
||||
\brief Data Memory Barrier
|
||||
\details Ensures the apparent order of the explicit memory operations before
|
||||
and after the instruction, without ensuring their completion.
|
||||
*/
|
||||
#define __DMB() __dmb(0xF)
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (32 bit)
|
||||
\details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#define __REV __rev
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (16 bit)
|
||||
\details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
|
||||
{
|
||||
rev16 r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (16 bit)
|
||||
\details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
|
||||
{
|
||||
revsh r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Rotate Right in unsigned value (32 bit)
|
||||
\details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
|
||||
\param [in] op1 Value to rotate
|
||||
\param [in] op2 Number of Bits to rotate
|
||||
\return Rotated value
|
||||
*/
|
||||
#define __ROR __ror
|
||||
|
||||
|
||||
/**
|
||||
\brief Breakpoint
|
||||
\details Causes the processor to enter Debug state.
|
||||
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
|
||||
\param [in] value is ignored by the processor.
|
||||
If required, a debugger can use it to store additional information about the breakpoint.
|
||||
*/
|
||||
#define __BKPT(value) __breakpoint(value)
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse bit order of value
|
||||
\details Reverses the bit order of the given value.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
#define __RBIT __rbit
|
||||
#else
|
||||
__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
|
||||
|
||||
result = value; /* r will be reversed bits of v; first get LSB of v */
|
||||
for (value >>= 1U; value != 0U; value >>= 1U)
|
||||
{
|
||||
result <<= 1U;
|
||||
result |= value & 1U;
|
||||
s--;
|
||||
}
|
||||
result <<= s; /* shift when v's highest bits are zero */
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Count leading zeros
|
||||
\details Counts the number of leading zeros of a data value.
|
||||
\param [in] value Value to count the leading zeros
|
||||
\return number of leading zeros in value
|
||||
*/
|
||||
#define __CLZ __clz
|
||||
|
||||
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (8 bit)
|
||||
\details Executes a exclusive LDR instruction for 8 bit value.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint8_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (16 bit)
|
||||
\details Executes a exclusive LDR instruction for 16 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint16_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (32 bit)
|
||||
\details Executes a exclusive LDR instruction for 32 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint32_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (8 bit)
|
||||
\details Executes a exclusive STR instruction for 8 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXB(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (16 bit)
|
||||
\details Executes a exclusive STR instruction for 16 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXH(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (32 bit)
|
||||
\details Executes a exclusive STR instruction for 32 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXW(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Remove the exclusive lock
|
||||
\details Removes the exclusive lock which is created by LDREX.
|
||||
*/
|
||||
#define __CLREX __clrex
|
||||
|
||||
|
||||
/**
|
||||
\brief Signed Saturate
|
||||
\details Saturates a signed value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (1..32)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __SSAT __ssat
|
||||
|
||||
|
||||
/**
|
||||
\brief Unsigned Saturate
|
||||
\details Saturates an unsigned value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (0..31)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __USAT __usat
|
||||
|
||||
|
||||
/**
|
||||
\brief Rotate Right with Extend (32 bit)
|
||||
\details Moves each bit of a bitstring right by one bit.
|
||||
The carry input is shifted in at the left end of the bitstring.
|
||||
\param [in] value Value to rotate
|
||||
\return Rotated value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
|
||||
{
|
||||
rrx r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (8 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 8 bit value.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint8_t at (*ptr)
|
||||
*/
|
||||
#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (16 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 16 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint16_t at (*ptr)
|
||||
*/
|
||||
#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (32 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 32 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint32_t at (*ptr)
|
||||
*/
|
||||
#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (8 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 8 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRBT(value, ptr) __strt(value, ptr)
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (16 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 16 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRHT(value, ptr) __strt(value, ptr)
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (32 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 32 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRT(value, ptr) __strt(value, ptr)
|
||||
|
||||
#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
/**
|
||||
\brief Signed Saturate
|
||||
\details Saturates a signed value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (1..32)
|
||||
\return Saturated value
|
||||
*/
|
||||
__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if ((sat >= 1U) && (sat <= 32U))
|
||||
{
|
||||
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
|
||||
const int32_t min = -1 - max ;
|
||||
if (val > max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < min)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Unsigned Saturate
|
||||
\details Saturates an unsigned value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (0..31)
|
||||
\return Saturated value
|
||||
*/
|
||||
__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if (sat <= 31U)
|
||||
{
|
||||
const uint32_t max = ((1U << sat) - 1U);
|
||||
if (val > (int32_t)max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < 0)
|
||||
{
|
||||
return 0U;
|
||||
}
|
||||
}
|
||||
return (uint32_t)val;
|
||||
}
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
|
||||
|
||||
|
||||
/* ########################### Core Function Access ########################### */
|
||||
/** \ingroup CMSIS_Core_FunctionInterface
|
||||
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Enable IRQ Interrupts
|
||||
\details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
/* intrinsic void __enable_irq(); */
|
||||
|
||||
|
||||
/**
|
||||
\brief Disable IRQ Interrupts
|
||||
\details Disables IRQ interrupts by setting special-purpose register PRIMASK.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
/* intrinsic void __disable_irq(); */
|
||||
|
||||
/**
|
||||
\brief Get Control Register
|
||||
\details Returns the content of the Control Register.
|
||||
\return Control Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_CONTROL(void)
|
||||
{
|
||||
register uint32_t __regControl __ASM("control");
|
||||
return(__regControl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Control Register
|
||||
\details Writes the given value to the Control Register.
|
||||
\param [in] control Control Register value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_CONTROL(uint32_t control)
|
||||
{
|
||||
register uint32_t __regControl __ASM("control");
|
||||
__regControl = control;
|
||||
__ISB();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get IPSR Register
|
||||
\details Returns the content of the IPSR Register.
|
||||
\return IPSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_IPSR(void)
|
||||
{
|
||||
register uint32_t __regIPSR __ASM("ipsr");
|
||||
return(__regIPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get APSR Register
|
||||
\details Returns the content of the APSR Register.
|
||||
\return APSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_APSR(void)
|
||||
{
|
||||
register uint32_t __regAPSR __ASM("apsr");
|
||||
return(__regAPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get xPSR Register
|
||||
\details Returns the content of the xPSR Register.
|
||||
\return xPSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_xPSR(void)
|
||||
{
|
||||
register uint32_t __regXPSR __ASM("xpsr");
|
||||
return(__regXPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Process Stack Pointer
|
||||
\details Returns the current value of the Process Stack Pointer (PSP).
|
||||
\return PSP Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_PSP(void)
|
||||
{
|
||||
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||
return(__regProcessStackPointer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Process Stack Pointer
|
||||
\details Assigns the given value to the Process Stack Pointer (PSP).
|
||||
\param [in] topOfProcStack Process Stack Pointer value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
|
||||
{
|
||||
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||
__regProcessStackPointer = topOfProcStack;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Main Stack Pointer
|
||||
\details Returns the current value of the Main Stack Pointer (MSP).
|
||||
\return MSP Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_MSP(void)
|
||||
{
|
||||
register uint32_t __regMainStackPointer __ASM("msp");
|
||||
return(__regMainStackPointer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Main Stack Pointer
|
||||
\details Assigns the given value to the Main Stack Pointer (MSP).
|
||||
\param [in] topOfMainStack Main Stack Pointer value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
|
||||
{
|
||||
register uint32_t __regMainStackPointer __ASM("msp");
|
||||
__regMainStackPointer = topOfMainStack;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Priority Mask
|
||||
\details Returns the current state of the priority mask bit from the Priority Mask Register.
|
||||
\return Priority Mask value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_PRIMASK(void)
|
||||
{
|
||||
register uint32_t __regPriMask __ASM("primask");
|
||||
return(__regPriMask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Priority Mask
|
||||
\details Assigns the given value to the Priority Mask Register.
|
||||
\param [in] priMask Priority Mask
|
||||
*/
|
||||
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
|
||||
{
|
||||
register uint32_t __regPriMask __ASM("primask");
|
||||
__regPriMask = (priMask);
|
||||
}
|
||||
|
||||
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
/**
|
||||
\brief Enable FIQ
|
||||
\details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
#define __enable_fault_irq __enable_fiq
|
||||
|
||||
|
||||
/**
|
||||
\brief Disable FIQ
|
||||
\details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
#define __disable_fault_irq __disable_fiq
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Base Priority
|
||||
\details Returns the current value of the Base Priority register.
|
||||
\return Base Priority register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_BASEPRI(void)
|
||||
{
|
||||
register uint32_t __regBasePri __ASM("basepri");
|
||||
return(__regBasePri);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Base Priority
|
||||
\details Assigns the given value to the Base Priority register.
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
|
||||
{
|
||||
register uint32_t __regBasePri __ASM("basepri");
|
||||
__regBasePri = (basePri & 0xFFU);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Base Priority with condition
|
||||
\details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
|
||||
or the new value increases the BASEPRI priority level.
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
|
||||
{
|
||||
register uint32_t __regBasePriMax __ASM("basepri_max");
|
||||
__regBasePriMax = (basePri & 0xFFU);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Fault Mask
|
||||
\details Returns the current value of the Fault Mask register.
|
||||
\return Fault Mask register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
|
||||
{
|
||||
register uint32_t __regFaultMask __ASM("faultmask");
|
||||
return(__regFaultMask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Fault Mask
|
||||
\details Assigns the given value to the Fault Mask register.
|
||||
\param [in] faultMask Fault Mask value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
|
||||
{
|
||||
register uint32_t __regFaultMask __ASM("faultmask");
|
||||
__regFaultMask = (faultMask & (uint32_t)1U);
|
||||
}
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
|
||||
/**
|
||||
\brief Get FPSCR
|
||||
\details Returns the current value of the Floating Point Status/Control register.
|
||||
\return Floating Point Status/Control register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_FPSCR(void)
|
||||
{
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
register uint32_t __regfpscr __ASM("fpscr");
|
||||
return(__regfpscr);
|
||||
#else
|
||||
return(0U);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set FPSCR
|
||||
\details Assigns the given value to the Floating Point Status/Control register.
|
||||
\param [in] fpscr Floating Point Status/Control value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||
{
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
register uint32_t __regfpscr __ASM("fpscr");
|
||||
__regfpscr = (fpscr);
|
||||
#else
|
||||
(void)fpscr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*@} end of CMSIS_Core_RegAccFunctions */
|
||||
|
||||
|
||||
/* ################### Compiler specific Intrinsics ########################### */
|
||||
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
|
||||
Access to dedicated SIMD instructions
|
||||
@{
|
||||
*/
|
||||
|
||||
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
#define __SADD8 __sadd8
|
||||
#define __QADD8 __qadd8
|
||||
#define __SHADD8 __shadd8
|
||||
#define __UADD8 __uadd8
|
||||
#define __UQADD8 __uqadd8
|
||||
#define __UHADD8 __uhadd8
|
||||
#define __SSUB8 __ssub8
|
||||
#define __QSUB8 __qsub8
|
||||
#define __SHSUB8 __shsub8
|
||||
#define __USUB8 __usub8
|
||||
#define __UQSUB8 __uqsub8
|
||||
#define __UHSUB8 __uhsub8
|
||||
#define __SADD16 __sadd16
|
||||
#define __QADD16 __qadd16
|
||||
#define __SHADD16 __shadd16
|
||||
#define __UADD16 __uadd16
|
||||
#define __UQADD16 __uqadd16
|
||||
#define __UHADD16 __uhadd16
|
||||
#define __SSUB16 __ssub16
|
||||
#define __QSUB16 __qsub16
|
||||
#define __SHSUB16 __shsub16
|
||||
#define __USUB16 __usub16
|
||||
#define __UQSUB16 __uqsub16
|
||||
#define __UHSUB16 __uhsub16
|
||||
#define __SASX __sasx
|
||||
#define __QASX __qasx
|
||||
#define __SHASX __shasx
|
||||
#define __UASX __uasx
|
||||
#define __UQASX __uqasx
|
||||
#define __UHASX __uhasx
|
||||
#define __SSAX __ssax
|
||||
#define __QSAX __qsax
|
||||
#define __SHSAX __shsax
|
||||
#define __USAX __usax
|
||||
#define __UQSAX __uqsax
|
||||
#define __UHSAX __uhsax
|
||||
#define __USAD8 __usad8
|
||||
#define __USADA8 __usada8
|
||||
#define __SSAT16 __ssat16
|
||||
#define __USAT16 __usat16
|
||||
#define __UXTB16 __uxtb16
|
||||
#define __UXTAB16 __uxtab16
|
||||
#define __SXTB16 __sxtb16
|
||||
#define __SXTAB16 __sxtab16
|
||||
#define __SMUAD __smuad
|
||||
#define __SMUADX __smuadx
|
||||
#define __SMLAD __smlad
|
||||
#define __SMLADX __smladx
|
||||
#define __SMLALD __smlald
|
||||
#define __SMLALDX __smlaldx
|
||||
#define __SMUSD __smusd
|
||||
#define __SMUSDX __smusdx
|
||||
#define __SMLSD __smlsd
|
||||
#define __SMLSDX __smlsdx
|
||||
#define __SMLSLD __smlsld
|
||||
#define __SMLSLDX __smlsldx
|
||||
#define __SEL __sel
|
||||
#define __QADD __qadd
|
||||
#define __QSUB __qsub
|
||||
|
||||
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
|
||||
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
|
||||
|
||||
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
|
||||
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
|
||||
|
||||
#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
|
||||
((int64_t)(ARG3) << 32U) ) >> 32U))
|
||||
|
||||
#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
|
||||
|
||||
#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
/*@} end of group CMSIS_SIMD_intrinsics */
|
||||
|
||||
|
||||
#endif /* __CMSIS_ARMCC_H */
|
||||
1510
lib/cmsis_core/cmsis_armclang.h
Normal file
1510
lib/cmsis_core/cmsis_armclang.h
Normal file
File diff suppressed because it is too large
Load Diff
1934
lib/cmsis_core/cmsis_armclang_ltm.h
Normal file
1934
lib/cmsis_core/cmsis_armclang_ltm.h
Normal file
File diff suppressed because it is too large
Load Diff
303
lib/cmsis_core/cmsis_compiler.h
Normal file
303
lib/cmsis_core/cmsis_compiler.h
Normal file
@@ -0,0 +1,303 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_compiler.h
|
||||
* @brief CMSIS compiler generic header file
|
||||
* @version V5.3.0
|
||||
* @date 04. April 2023
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2023 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CMSIS_COMPILER_H
|
||||
#define __CMSIS_COMPILER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Arm Compiler 4/5
|
||||
*/
|
||||
#if defined ( __CC_ARM )
|
||||
#include "cmsis_armcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* Arm Compiler 6.6 LTM (armclang)
|
||||
*/
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
|
||||
#include "cmsis_armclang_ltm.h"
|
||||
|
||||
/*
|
||||
* Arm Compiler above 6.10.1 (armclang)
|
||||
*/
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
|
||||
#include "cmsis_armclang.h"
|
||||
|
||||
/*
|
||||
* TI Arm Clang Compiler (tiarmclang)
|
||||
*/
|
||||
#elif defined (__ti__)
|
||||
#include "cmsis_tiarmclang.h"
|
||||
|
||||
/*
|
||||
* GNU Compiler
|
||||
*/
|
||||
#elif defined ( __GNUC__ )
|
||||
#include "cmsis_gcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* IAR Compiler
|
||||
*/
|
||||
#elif defined ( __ICCARM__ )
|
||||
#include <cmsis_iccarm.h>
|
||||
|
||||
|
||||
/*
|
||||
* TI Arm Compiler (armcl)
|
||||
*/
|
||||
#elif defined ( __TI_ARM__ )
|
||||
#include <cmsis_ccs.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#define __RESTRICT __restrict
|
||||
#endif
|
||||
#ifndef __COMPILER_BARRIER
|
||||
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
|
||||
#define __COMPILER_BARRIER() (void)0
|
||||
#endif
|
||||
#ifndef __NO_INIT
|
||||
#define __NO_INIT __attribute__ ((section (".bss.noinit")))
|
||||
#endif
|
||||
#ifndef __ALIAS
|
||||
#define __ALIAS(x) __attribute__ ((alias(x)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TASKING Compiler
|
||||
*/
|
||||
#elif defined ( __TASKING__ )
|
||||
/*
|
||||
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||
* Including the CMSIS ones.
|
||||
*/
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __packed__
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __packed__ T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __align(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
#ifndef __COMPILER_BARRIER
|
||||
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
|
||||
#define __COMPILER_BARRIER() (void)0
|
||||
#endif
|
||||
#ifndef __NO_INIT
|
||||
#define __NO_INIT __attribute__ ((section (".bss.noinit")))
|
||||
#endif
|
||||
#ifndef __ALIAS
|
||||
#define __ALIAS(x) __attribute__ ((alias(x)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* COSMIC Compiler
|
||||
*/
|
||||
#elif defined ( __CSMC__ )
|
||||
#include <cmsis_csm.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM _asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
// NO RETURN is automatically detected hence no warning here
|
||||
#define __NO_RETURN
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#warning No compiler specific solution for __USED. __USED is ignored.
|
||||
#define __USED
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED @packed
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT @packed struct
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION @packed union
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
@packed struct T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
|
||||
#define __ALIGNED(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
#ifndef __COMPILER_BARRIER
|
||||
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
|
||||
#define __COMPILER_BARRIER() (void)0
|
||||
#endif
|
||||
#ifndef __NO_INIT
|
||||
#define __NO_INIT __attribute__ ((section (".bss.noinit")))
|
||||
#endif
|
||||
#ifndef __ALIAS
|
||||
#define __ALIAS(x) __attribute__ ((alias(x)))
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error Unknown compiler.
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __CMSIS_COMPILER_H */
|
||||
|
||||
2217
lib/cmsis_core/cmsis_gcc.h
Normal file
2217
lib/cmsis_core/cmsis_gcc.h
Normal file
File diff suppressed because it is too large
Load Diff
1008
lib/cmsis_core/cmsis_iccarm.h
Normal file
1008
lib/cmsis_core/cmsis_iccarm.h
Normal file
File diff suppressed because it is too large
Load Diff
1510
lib/cmsis_core/cmsis_tiarmclang.h
Normal file
1510
lib/cmsis_core/cmsis_tiarmclang.h
Normal file
File diff suppressed because it is too large
Load Diff
39
lib/cmsis_core/cmsis_version.h
Normal file
39
lib/cmsis_core/cmsis_version.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_version.h
|
||||
* @brief CMSIS Core(M) Version definitions
|
||||
* @version V5.0.5
|
||||
* @date 02. February 2022
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2022 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef __CMSIS_VERSION_H
|
||||
#define __CMSIS_VERSION_H
|
||||
|
||||
/* CMSIS Version definitions */
|
||||
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
|
||||
#define __CM_CMSIS_VERSION_SUB ( 6U) /*!< [15:0] CMSIS Core(M) sub version */
|
||||
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
|
||||
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
|
||||
#endif
|
||||
2170
lib/cmsis_core/core_cm4.h
Normal file
2170
lib/cmsis_core/core_cm4.h
Normal file
File diff suppressed because it is too large
Load Diff
275
lib/cmsis_core/mpu_armv7.h
Normal file
275
lib/cmsis_core/mpu_armv7.h
Normal file
@@ -0,0 +1,275 @@
|
||||
/******************************************************************************
|
||||
* @file mpu_armv7.h
|
||||
* @brief CMSIS MPU API for Armv7-M MPU
|
||||
* @version V5.1.2
|
||||
* @date 25. May 2020
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2017-2020 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef ARM_MPU_ARMV7_H
|
||||
#define ARM_MPU_ARMV7_H
|
||||
|
||||
#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes
|
||||
#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes
|
||||
#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes
|
||||
#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes
|
||||
#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes
|
||||
#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte
|
||||
#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes
|
||||
#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte
|
||||
#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes
|
||||
#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte
|
||||
#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes
|
||||
#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes
|
||||
|
||||
#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access
|
||||
#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only
|
||||
#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only
|
||||
#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access
|
||||
#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only
|
||||
#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access
|
||||
|
||||
/** MPU Region Base Address Register Value
|
||||
*
|
||||
* \param Region The region to be configured, number 0 to 15.
|
||||
* \param BaseAddress The base address for the region.
|
||||
*/
|
||||
#define ARM_MPU_RBAR(Region, BaseAddress) \
|
||||
(((BaseAddress) & MPU_RBAR_ADDR_Msk) | \
|
||||
((Region) & MPU_RBAR_REGION_Msk) | \
|
||||
(MPU_RBAR_VALID_Msk))
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attributes
|
||||
*
|
||||
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
||||
* \param IsShareable Region is shareable between multiple bus masters.
|
||||
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
|
||||
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
||||
*/
|
||||
#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \
|
||||
((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
|
||||
(((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
|
||||
(((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \
|
||||
(((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk))
|
||||
|
||||
/**
|
||||
* MPU Region Attribute and Size Register Value
|
||||
*
|
||||
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
||||
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
||||
* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_.
|
||||
* \param SubRegionDisable Sub-region disable field.
|
||||
* \param Size Region size of the region to be configured, for example 4K, 8K.
|
||||
*/
|
||||
#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \
|
||||
((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
|
||||
(((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
|
||||
(((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \
|
||||
(((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \
|
||||
(((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \
|
||||
(((MPU_RASR_ENABLE_Msk))))
|
||||
|
||||
/**
|
||||
* MPU Region Attribute and Size Register Value
|
||||
*
|
||||
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
||||
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
||||
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
||||
* \param IsShareable Region is shareable between multiple bus masters.
|
||||
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
|
||||
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
||||
* \param SubRegionDisable Sub-region disable field.
|
||||
* \param Size Region size of the region to be configured, for example 4K, 8K.
|
||||
*/
|
||||
#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
|
||||
ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size)
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attribute for strongly ordered memory.
|
||||
* - TEX: 000b
|
||||
* - Shareable
|
||||
* - Non-cacheable
|
||||
* - Non-bufferable
|
||||
*/
|
||||
#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U)
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attribute for device memory.
|
||||
* - TEX: 000b (if shareable) or 010b (if non-shareable)
|
||||
* - Shareable or non-shareable
|
||||
* - Non-cacheable
|
||||
* - Bufferable (if shareable) or non-bufferable (if non-shareable)
|
||||
*
|
||||
* \param IsShareable Configures the device memory as shareable or non-shareable.
|
||||
*/
|
||||
#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U))
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attribute for normal memory.
|
||||
* - TEX: 1BBb (reflecting outer cacheability rules)
|
||||
* - Shareable or non-shareable
|
||||
* - Cacheable or non-cacheable (reflecting inner cacheability rules)
|
||||
* - Bufferable or non-bufferable (reflecting inner cacheability rules)
|
||||
*
|
||||
* \param OuterCp Configures the outer cache policy.
|
||||
* \param InnerCp Configures the inner cache policy.
|
||||
* \param IsShareable Configures the memory as shareable or non-shareable.
|
||||
*/
|
||||
#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) >> 1U), ((InnerCp) & 1U))
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attribute non-cacheable policy.
|
||||
*/
|
||||
#define ARM_MPU_CACHEP_NOCACHE 0U
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attribute write-back, write and read allocate policy.
|
||||
*/
|
||||
#define ARM_MPU_CACHEP_WB_WRA 1U
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attribute write-through, no write allocate policy.
|
||||
*/
|
||||
#define ARM_MPU_CACHEP_WT_NWA 2U
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attribute write-back, no write allocate policy.
|
||||
*/
|
||||
#define ARM_MPU_CACHEP_WB_NWA 3U
|
||||
|
||||
|
||||
/**
|
||||
* Struct for a single MPU Region
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t RBAR; //!< The region base address register value (RBAR)
|
||||
uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
|
||||
} ARM_MPU_Region_t;
|
||||
|
||||
/** Enable the MPU.
|
||||
* \param MPU_Control Default access permissions for unconfigured regions.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
|
||||
{
|
||||
__DMB();
|
||||
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
__DSB();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
/** Disable the MPU.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Disable(void)
|
||||
{
|
||||
__DMB();
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
|
||||
__DSB();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
/** Clear and disable the given MPU region.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
|
||||
{
|
||||
MPU->RNR = rnr;
|
||||
MPU->RASR = 0U;
|
||||
}
|
||||
|
||||
/** Configure an MPU region.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rasr Value for RASR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
|
||||
{
|
||||
MPU->RBAR = rbar;
|
||||
MPU->RASR = rasr;
|
||||
}
|
||||
|
||||
/** Configure the given MPU region.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rasr Value for RASR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
|
||||
{
|
||||
MPU->RNR = rnr;
|
||||
MPU->RBAR = rbar;
|
||||
MPU->RASR = rasr;
|
||||
}
|
||||
|
||||
/** Memcpy with strictly ordered memory access, e.g. used by code in ARM_MPU_Load().
|
||||
* \param dst Destination data is copied to.
|
||||
* \param src Source data is copied from.
|
||||
* \param len Amount of data words to be copied.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0U; i < len; ++i)
|
||||
{
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** Load the given number of MPU regions from a table.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
|
||||
while (cnt > MPU_TYPE_RALIASES) {
|
||||
ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize);
|
||||
table += MPU_TYPE_RALIASES;
|
||||
cnt -= MPU_TYPE_RALIASES;
|
||||
}
|
||||
ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -51,6 +51,16 @@ struct DigitalSignalInternals {
|
||||
#define T_TIM 1562 /* 15.625 ns *100 */
|
||||
#define T_TIM_DIV2 781 /* 15.625 ns / 2 *100 */
|
||||
|
||||
/* maximum entry count of the sequence dma ring buffer */
|
||||
#define SEQUENCE_DMA_RINGBUFFER_SIZE 32
|
||||
/* maximum number of DigitalSignals in a sequence */
|
||||
#define SEQUENCE_SIGNALS_SIZE 32
|
||||
/*
|
||||
* if sequence size runs out from the initial value passed to digital_sequence_alloc
|
||||
* the size will be increased by this amount and reallocated
|
||||
*/
|
||||
#define SEQUENCE_SIZE_REALLOCATE_INCREMENT 256
|
||||
|
||||
DigitalSignal* digital_signal_alloc(uint32_t max_edges_cnt) {
|
||||
DigitalSignal* signal = malloc(sizeof(DigitalSignal));
|
||||
signal->start_level = true;
|
||||
@@ -90,10 +100,6 @@ DigitalSignal* digital_signal_alloc(uint32_t max_edges_cnt) {
|
||||
void digital_signal_free(DigitalSignal* signal) {
|
||||
furi_assert(signal);
|
||||
|
||||
if(!signal) {
|
||||
return;
|
||||
}
|
||||
|
||||
free(signal->edge_timings);
|
||||
free(signal->reload_reg_buff);
|
||||
free(signal->internals);
|
||||
@@ -293,8 +299,6 @@ void digital_signal_send(DigitalSignal* signal, const GpioPin* gpio) {
|
||||
furi_hal_gpio_init(
|
||||
signal->internals->gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
|
||||
/* single signal, add a temporary, terminating edge at the end */
|
||||
signal->edge_timings[signal->edge_cnt++] = 10;
|
||||
digital_signal_prepare_arr(signal);
|
||||
|
||||
digital_signal_setup_dma(signal);
|
||||
@@ -306,8 +310,6 @@ void digital_signal_send(DigitalSignal* signal, const GpioPin* gpio) {
|
||||
|
||||
digital_signal_stop_timer();
|
||||
digital_signal_stop_dma();
|
||||
|
||||
signal->edge_cnt--;
|
||||
}
|
||||
|
||||
static void digital_sequence_alloc_signals(DigitalSequence* sequence, uint32_t size) {
|
||||
@@ -332,7 +334,7 @@ DigitalSequence* digital_sequence_alloc(uint32_t size, const GpioPin* gpio) {
|
||||
sequence->bake = false;
|
||||
|
||||
sequence->dma_buffer = malloc(sizeof(struct ReloadBuffer));
|
||||
sequence->dma_buffer->size = 32;
|
||||
sequence->dma_buffer->size = SEQUENCE_DMA_RINGBUFFER_SIZE;
|
||||
sequence->dma_buffer->buffer = malloc(sequence->dma_buffer->size * sizeof(uint32_t));
|
||||
|
||||
sequence->dma_config_gpio.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
|
||||
@@ -357,7 +359,7 @@ DigitalSequence* digital_sequence_alloc(uint32_t size, const GpioPin* gpio) {
|
||||
sequence->dma_config_timer.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP;
|
||||
sequence->dma_config_timer.Priority = LL_DMA_PRIORITY_HIGH;
|
||||
|
||||
digital_sequence_alloc_signals(sequence, 32);
|
||||
digital_sequence_alloc_signals(sequence, SEQUENCE_SIGNALS_SIZE);
|
||||
digital_sequence_alloc_sequence(sequence, size);
|
||||
|
||||
return sequence;
|
||||
@@ -366,10 +368,6 @@ DigitalSequence* digital_sequence_alloc(uint32_t size, const GpioPin* gpio) {
|
||||
void digital_sequence_free(DigitalSequence* sequence) {
|
||||
furi_assert(sequence);
|
||||
|
||||
if(!sequence) {
|
||||
return;
|
||||
}
|
||||
|
||||
free(sequence->signals);
|
||||
free(sequence->sequence);
|
||||
free(sequence->dma_buffer->buffer);
|
||||
@@ -404,8 +402,9 @@ void digital_sequence_add(DigitalSequence* sequence, uint8_t signal_index) {
|
||||
furi_assert(signal_index < sequence->signals_size);
|
||||
|
||||
if(sequence->sequence_used >= sequence->sequence_size) {
|
||||
sequence->sequence_size += 256;
|
||||
sequence->sequence = realloc(sequence->sequence, sequence->sequence_size);
|
||||
sequence->sequence_size += SEQUENCE_SIZE_REALLOCATE_INCREMENT;
|
||||
sequence->sequence = realloc(sequence->sequence, sequence->sequence_size); //-V701
|
||||
furi_assert(sequence->sequence);
|
||||
}
|
||||
|
||||
sequence->sequence[sequence->sequence_used++] = signal_index;
|
||||
@@ -479,7 +478,7 @@ static void digital_sequence_finish(DigitalSequence* sequence) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(last_pos != dma_buffer->read_pos) {
|
||||
if(last_pos != dma_buffer->read_pos) { //-V547
|
||||
prev_timer = DWT->CYCCNT;
|
||||
}
|
||||
if(DWT->CYCCNT - prev_timer > wait_ticks) {
|
||||
@@ -513,7 +512,7 @@ static void digital_sequence_queue_pulse(DigitalSequence* sequence, uint32_t len
|
||||
break;
|
||||
}
|
||||
|
||||
if(last_pos != dma_buffer->read_pos) {
|
||||
if(last_pos != dma_buffer->read_pos) { //-V547
|
||||
prev_timer = DWT->CYCCNT;
|
||||
}
|
||||
if(DWT->CYCCNT - prev_timer > wait_ticks) {
|
||||
|
||||
@@ -11,10 +11,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* helper for easier signal generation */
|
||||
#define DIGITAL_SIGNAL_MS(x) (x * 100000000UL)
|
||||
#define DIGITAL_SIGNAL_US(x) (x * 100000UL)
|
||||
#define DIGITAL_SIGNAL_NS(x) (x * 100UL)
|
||||
#define DIGITAL_SIGNAL_PS(x) (x / 10UL)
|
||||
#define DIGITAL_SIGNAL_MS(x) ((x)*100000000UL)
|
||||
#define DIGITAL_SIGNAL_US(x) ((x)*100000UL)
|
||||
#define DIGITAL_SIGNAL_NS(x) ((x)*100UL)
|
||||
#define DIGITAL_SIGNAL_PS(x) ((x) / 10UL)
|
||||
|
||||
/* using an anonymous type for the internals */
|
||||
typedef struct DigitalSignalInternals DigitalSignalInternals;
|
||||
@@ -52,15 +52,22 @@ uint32_t digital_signal_get_edge(DigitalSignal* signal, uint32_t edge_num);
|
||||
void digital_signal_send(DigitalSignal* signal, const GpioPin* gpio);
|
||||
|
||||
DigitalSequence* digital_sequence_alloc(uint32_t size, const GpioPin* gpio);
|
||||
|
||||
void digital_sequence_free(DigitalSequence* sequence);
|
||||
|
||||
void digital_sequence_set_signal(
|
||||
DigitalSequence* sequence,
|
||||
uint8_t signal_index,
|
||||
DigitalSignal* signal);
|
||||
|
||||
void digital_sequence_set_sendtime(DigitalSequence* sequence, uint32_t send_time);
|
||||
|
||||
void digital_sequence_add(DigitalSequence* sequence, uint8_t signal_index);
|
||||
|
||||
bool digital_sequence_send(DigitalSequence* sequence);
|
||||
|
||||
void digital_sequence_clear(DigitalSequence* sequence);
|
||||
|
||||
void digital_sequence_timebase_correction(DigitalSequence* sequence, float factor);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -119,10 +119,6 @@ void pulse_reader_set_pull(PulseReader* signal, GpioPull pull) {
|
||||
void pulse_reader_free(PulseReader* signal) {
|
||||
furi_assert(signal);
|
||||
|
||||
if(!signal) {
|
||||
return;
|
||||
}
|
||||
|
||||
free(signal->timer_buffer);
|
||||
free(signal->gpio_buffer);
|
||||
free(signal);
|
||||
@@ -213,8 +209,8 @@ uint32_t pulse_reader_receive(PulseReader* signal, int timeout_us) {
|
||||
|
||||
/* probably larger values, so choose a wider data type */
|
||||
if(signal->unit_divider > 1) {
|
||||
delta_unit =
|
||||
(uint32_t)((uint64_t)delta * (uint64_t)signal->unit_multiplier / signal->unit_divider);
|
||||
delta_unit = (uint32_t)((uint64_t)delta * (uint64_t)signal->unit_multiplier /
|
||||
signal->unit_divider);
|
||||
} else {
|
||||
delta_unit = delta * signal->unit_multiplier;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PULSE_READER_NO_EDGE 0xFFFFFFFFUL
|
||||
#define PULSE_READER_LOST_EDGE 0xFFFFFFFEUL
|
||||
#define F_TIM2 64000000UL
|
||||
#define PULSE_READER_NO_EDGE (0xFFFFFFFFUL)
|
||||
#define PULSE_READER_LOST_EDGE (0xFFFFFFFEUL)
|
||||
#define F_TIM2 (64000000UL)
|
||||
|
||||
/**
|
||||
* unit of the edge durations to return
|
||||
|
||||
71
lib/stm32wb.scons
Normal file
71
lib/stm32wb.scons
Normal file
@@ -0,0 +1,71 @@
|
||||
Import("env")
|
||||
|
||||
env.Append(
|
||||
CPPPATH=[
|
||||
"#/lib/cmsis_core",
|
||||
"#/lib/stm32wb_cmsis/Include",
|
||||
"#/lib/stm32wb_hal/Inc",
|
||||
"#/lib/stm32wb_copro/wpan",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
"STM32WB",
|
||||
"STM32WB55xx",
|
||||
"USE_FULL_ASSERT",
|
||||
"USE_FULL_LL_DRIVER",
|
||||
],
|
||||
SDK_HEADERS=env.GlobRecursive(
|
||||
"*_ll_*.h",
|
||||
Dir("stm32wb_hal/Inc"),
|
||||
exclude="*usb.h",
|
||||
),
|
||||
)
|
||||
|
||||
if env["RAM_EXEC"]:
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
"VECT_TAB_SRAM",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
libenv = env.Clone(FW_LIB_NAME="stm32wb")
|
||||
libenv.Append(
|
||||
CPPPATH=[
|
||||
"#/lib/stm32wb_copro/wpan/ble",
|
||||
"#/lib/stm32wb_copro/wpan/ble/core",
|
||||
"#/lib/stm32wb_copro/wpan/interface/patterns/ble_thread",
|
||||
"#/lib/stm32wb_copro/wpan/interface/patterns/ble_thread/shci",
|
||||
"#/lib/stm32wb_copro/wpan/interface/patterns/ble_thread/tl",
|
||||
"#/lib/stm32wb_copro/wpan/utilities",
|
||||
]
|
||||
)
|
||||
libenv.ApplyLibFlags()
|
||||
|
||||
sources = libenv.GlobRecursive("*_ll_*.c", "stm32wb_hal/Src/", exclude="*usb.c")
|
||||
sources += Glob(
|
||||
"stm32wb_copro/wpan/interface/patterns/ble_thread/shci/*.c",
|
||||
source=True,
|
||||
)
|
||||
sources += Glob(
|
||||
"stm32wb_copro/wpan/interface/patterns/ble_thread/tl/*_tl*.c",
|
||||
exclude="stm32wb_copro/wpan/interface/patterns/ble_thread/tl/shci_tl_if.c",
|
||||
source=True,
|
||||
)
|
||||
sources += [
|
||||
"stm32wb_copro/wpan/interface/patterns/ble_thread/tl/tl_mbox.c",
|
||||
"stm32wb_copro/wpan/ble/svc/Src/svc_ctl.c",
|
||||
"stm32wb_copro/wpan/ble/core/auto/ble_gap_aci.c",
|
||||
"stm32wb_copro/wpan/ble/core/auto/ble_gatt_aci.c",
|
||||
"stm32wb_copro/wpan/ble/core/auto/ble_hal_aci.c",
|
||||
"stm32wb_copro/wpan/ble/core/auto/ble_hci_le.c",
|
||||
"stm32wb_copro/wpan/ble/core/auto/ble_l2cap_aci.c",
|
||||
"stm32wb_copro/wpan/ble/core/template/osal.c",
|
||||
"stm32wb_copro/wpan/utilities/dbg_trace.c",
|
||||
"stm32wb_copro/wpan/utilities/otp.c",
|
||||
"stm32wb_copro/wpan/utilities/stm_list.c",
|
||||
]
|
||||
|
||||
|
||||
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
|
||||
libenv.Install("${LIB_DIST_DIR}", lib)
|
||||
Return("lib")
|
||||
1
lib/stm32wb_cmsis
Submodule
1
lib/stm32wb_cmsis
Submodule
Submodule lib/stm32wb_cmsis added at d1b860584d
1
lib/stm32wb_copro
Submodule
1
lib/stm32wb_copro
Submodule
Submodule lib/stm32wb_copro added at 6c9c54f056
1
lib/stm32wb_hal
Submodule
1
lib/stm32wb_hal
Submodule
Submodule lib/stm32wb_hal added at cfd0dd258c
@@ -1,24 +1,35 @@
|
||||
#include "version.h"
|
||||
|
||||
#include <furi.h>
|
||||
/* This header is autogenerated by build system */
|
||||
#include "version.inc.h"
|
||||
|
||||
#define VERSION_MAGIC (0xBE40u)
|
||||
#define VERSION_MAJOR (0x1u)
|
||||
#define VERSION_MINOR (0x0u)
|
||||
|
||||
struct Version {
|
||||
// Header
|
||||
const uint16_t magic;
|
||||
const uint8_t major;
|
||||
const uint8_t minor;
|
||||
// Payload
|
||||
const char* git_hash;
|
||||
const char* git_branch;
|
||||
const char* git_branch_num;
|
||||
const char* build_date;
|
||||
const char* custom_flipper_name;
|
||||
const char* version;
|
||||
// Payload bits and pieces
|
||||
const uint8_t target;
|
||||
const bool build_is_dirty;
|
||||
};
|
||||
|
||||
/* version of current running firmware (bootloader/flipper) */
|
||||
static const Version version = {
|
||||
.magic = VERSION_MAGIC,
|
||||
.major = VERSION_MAJOR,
|
||||
.minor = VERSION_MINOR,
|
||||
.git_hash = GIT_COMMIT,
|
||||
.git_branch = GIT_BRANCH,
|
||||
.git_branch_num = GIT_BRANCH_NUM,
|
||||
.build_date = BUILD_DATE,
|
||||
#ifdef FURI_CUSTOM_FLIPPER_NAME
|
||||
.custom_flipper_name = FURI_CUSTOM_FLIPPER_NAME,
|
||||
@@ -47,7 +58,8 @@ const char* version_get_gitbranch(const Version* v) {
|
||||
}
|
||||
|
||||
const char* version_get_gitbranchnum(const Version* v) {
|
||||
return v ? v->git_branch_num : version.git_branch_num;
|
||||
UNUSED(v);
|
||||
return "0";
|
||||
}
|
||||
|
||||
const char* version_get_builddate(const Version* v) {
|
||||
|
||||
@@ -62,7 +62,6 @@ class Main(App):
|
||||
)
|
||||
self.parser_copro.add_argument("cube_dir", help="Path to Cube folder")
|
||||
self.parser_copro.add_argument("output_dir", help="Path to output folder")
|
||||
self.parser_copro.add_argument("mcu", help="MCU series as in copro folder")
|
||||
self.parser_copro.add_argument(
|
||||
"--cube_ver", dest="cube_ver", help="Cube version", required=True
|
||||
)
|
||||
@@ -264,16 +263,20 @@ class Main(App):
|
||||
from flipper.assets.copro import Copro
|
||||
|
||||
self.logger.info("Bundling coprocessor binaries")
|
||||
copro = Copro(self.args.mcu)
|
||||
self.logger.info("Loading CUBE info")
|
||||
copro.loadCubeInfo(self.args.cube_dir, self.args.cube_ver)
|
||||
self.logger.info("Bundling")
|
||||
copro.bundle(
|
||||
self.args.output_dir,
|
||||
self.args.stack_file,
|
||||
self.args.stack_type,
|
||||
self.args.stack_addr,
|
||||
)
|
||||
copro = Copro()
|
||||
try:
|
||||
self.logger.info("Loading CUBE info")
|
||||
copro.loadCubeInfo(self.args.cube_dir, self.args.cube_ver)
|
||||
self.logger.info("Bundling")
|
||||
copro.bundle(
|
||||
self.args.output_dir,
|
||||
self.args.stack_file,
|
||||
self.args.stack_type,
|
||||
self.args.stack_addr,
|
||||
)
|
||||
except Exception as e:
|
||||
self.logger.error(f"Failed to bundle: {e}")
|
||||
return 1
|
||||
self.logger.info("Complete")
|
||||
|
||||
return 0
|
||||
|
||||
@@ -29,7 +29,6 @@ from FreeRTOSgdb.GDBCommands import ShowQueueInfo
|
||||
|
||||
class Scheduler:
|
||||
def __init__(self):
|
||||
|
||||
self._blocked = ListInspector("xSuspendedTaskList")
|
||||
self._delayed1 = ListInspector("xDelayedTaskList1")
|
||||
self._delayed2 = ListInspector("xDelayedTaskList2")
|
||||
@@ -61,7 +61,6 @@ class ShowQueueInfo(gdb.Command):
|
||||
if maxCount == 0:
|
||||
print(outputFmt % (q.GetName(), q.GetQueueMessagesWaiting(), "", ""))
|
||||
else:
|
||||
|
||||
for i in range(0, maxCount):
|
||||
txName = ""
|
||||
if i < len(sendList):
|
||||
@@ -48,7 +48,6 @@ class HandleRegistry:
|
||||
print("%d: %3s %16s" % (i, h, name))
|
||||
|
||||
def FilterBy(self, qMode):
|
||||
|
||||
"""Retrieve a List of Mutex Queue Handles"""
|
||||
resp = []
|
||||
for i in range(self._minIndex, self._maxIndex):
|
||||
@@ -56,7 +56,6 @@ class ListInspector:
|
||||
of some of the TCB Task lists.
|
||||
"""
|
||||
if self._list != None:
|
||||
|
||||
CastType = None
|
||||
if CastTypeStr != None:
|
||||
if type(CastTypeStr) == str:
|
||||
@@ -73,7 +72,6 @@ class ListInspector:
|
||||
index = self._list["pxIndex"]
|
||||
|
||||
if numElems > 0 and numElems < 200:
|
||||
|
||||
if startElem == 0:
|
||||
curr = index
|
||||
else:
|
||||
@@ -47,7 +47,6 @@ QueueMode.Map = QueueMap
|
||||
|
||||
|
||||
class QueueInspector:
|
||||
|
||||
QueueType = gdb.lookup_type("Queue_t")
|
||||
|
||||
def __init__(self, handle):
|
||||
@@ -11,7 +11,6 @@ import gdb
|
||||
|
||||
|
||||
class TaskInspector:
|
||||
|
||||
TCBType = gdb.lookup_type("TCB_t")
|
||||
|
||||
def __init__(self, handle):
|
||||
@@ -28,7 +28,5 @@ directory = path.abspath(directory)
|
||||
sys.path.append(directory)
|
||||
|
||||
from cmdebug.svd_gdb import LoadSVD
|
||||
from cmdebug.dwt_gdb import DWT
|
||||
|
||||
DWT()
|
||||
LoadSVD()
|
||||
35
scripts/debug/PyCortexMDebug/README.md
Normal file
35
scripts/debug/PyCortexMDebug/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
PyCortexMDebug
|
||||
==============
|
||||
|
||||
## SVD
|
||||
|
||||
ARM defines an SVD (System View Description) file format in its CMSIS standard as a means for Cortex-M-based chip manufacturers to provide a common description of peripherals, registers, and register fields. You can download SVD files for different manufacturers [here](http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php).
|
||||
|
||||
The implementation consists of two components -- An lxml-based parser module (pysvd) and a GDB file (gdb_svd). I haven't yet worked out a perfect workflow for this, though it's quite easy to use when you already tend to have a GDB initialization file for starting up OpenOCD and the like. However your workflow works, just make sure to, in GDB:
|
||||
|
||||
source gdb_svd.py
|
||||
svd_load [your_svd_file].svd
|
||||
|
||||
These files can be huge so it might take a second or two. Anyways, after that, you can do
|
||||
|
||||
svd
|
||||
|
||||
to list available peripherals with descriptions. Or you can do
|
||||
|
||||
svd [some_peripheral_name]
|
||||
|
||||
to see all of the registers (with their values) for a given peripheral. For more details, run
|
||||
|
||||
svd [some_peripheral_name] [some_register_name]
|
||||
|
||||
to see all of the field values with descriptions.
|
||||
|
||||
You can add format modifiers like:
|
||||
|
||||
* `svd/x` will display values in hex
|
||||
* `svd/o` will display values in octal
|
||||
* `svd/t` or `svd/b` will display values in binary
|
||||
* `svd/a` will display values in hex and try to resolve symbols from the values
|
||||
|
||||
All field values are displayed at the correct lengths as provided by the SVD files.
|
||||
Also, tab completion exists for nearly everything! When in doubt, run `svd help`.
|
||||
@@ -16,15 +16,14 @@ You should have received a copy of the GNU General Public License
|
||||
along with PyCortexMDebug. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from collections import OrderedDict
|
||||
from . import x2d
|
||||
|
||||
import traceback
|
||||
import warnings
|
||||
import pickle
|
||||
import lxml.objectify as objectify
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
import os
|
||||
import pickle
|
||||
import traceback
|
||||
import re
|
||||
import warnings
|
||||
|
||||
|
||||
class SmartDict:
|
||||
@@ -127,31 +126,26 @@ class SVDFile:
|
||||
|
||||
def __init__(self, fname):
|
||||
"""
|
||||
|
||||
Args:
|
||||
fname: Filename for the SVD file
|
||||
"""
|
||||
f = objectify.parse(os.path.expanduser(fname))
|
||||
root = f.getroot()
|
||||
periph = root.peripherals.getchildren()
|
||||
self.peripherals = SmartDict()
|
||||
self.base_address = 0
|
||||
|
||||
xml_file_name = os.path.expanduser(fname)
|
||||
pickle_file_name = xml_file_name + ".pickle"
|
||||
root = None
|
||||
if os.path.exists(pickle_file_name):
|
||||
print("Loading pickled SVD")
|
||||
root = pickle.load(open(pickle_file_name, "rb"))
|
||||
else:
|
||||
print("Loading XML SVD and pickling it")
|
||||
root = x2d.parse(open(xml_file_name, "rb"))
|
||||
pickle.dump(root, open(pickle_file_name, "wb"), pickle.HIGHEST_PROTOCOL)
|
||||
print("Processing SVD tree")
|
||||
# XML elements
|
||||
for p in root["device"]["peripherals"]["peripheral"]:
|
||||
for p in periph:
|
||||
try:
|
||||
self.peripherals[p["name"]] = SVDPeripheral(p, self)
|
||||
if p.tag == "peripheral":
|
||||
self.peripherals[str(p.name)] = SVDPeripheral(p, self)
|
||||
else:
|
||||
# This is some other tag
|
||||
pass
|
||||
except SVDNonFatalError as e:
|
||||
# print(e)
|
||||
pass
|
||||
print("SVD Ready")
|
||||
print(e)
|
||||
|
||||
|
||||
def add_register(parent, node):
|
||||
@@ -271,11 +265,11 @@ class SVDPeripheral:
|
||||
self.parent_base_address = parent.base_address
|
||||
|
||||
# Look for a base address, as it is required
|
||||
if "baseAddress" not in svd_elem:
|
||||
if not hasattr(svd_elem, "baseAddress"):
|
||||
raise SVDNonFatalError("Periph without base address")
|
||||
self.base_address = int(str(svd_elem.baseAddress), 0)
|
||||
if "@derivedFrom" in svd_elem:
|
||||
derived_from = svd_elem["@derivedFrom"]
|
||||
if "derivedFrom" in svd_elem.attrib:
|
||||
derived_from = svd_elem.attrib["derivedFrom"]
|
||||
try:
|
||||
self.name = str(svd_elem.name)
|
||||
except AttributeError:
|
||||
@@ -301,14 +295,16 @@ class SVDPeripheral:
|
||||
self.clusters = SmartDict()
|
||||
|
||||
if hasattr(svd_elem, "registers"):
|
||||
if "register" in svd_elem.registers:
|
||||
for r in svd_elem.registers.register:
|
||||
if isinstance(r, x2d.ObjectDict):
|
||||
add_register(self, r)
|
||||
if "cluster" in svd_elem.registers:
|
||||
for c in svd_elem.registers.cluster:
|
||||
if isinstance(c, x2d.ObjectDict):
|
||||
add_cluster(self, c)
|
||||
registers = [
|
||||
r
|
||||
for r in svd_elem.registers.getchildren()
|
||||
if r.tag in ["cluster", "register"]
|
||||
]
|
||||
for r in registers:
|
||||
if r.tag == "cluster":
|
||||
add_cluster(self, r)
|
||||
elif r.tag == "register":
|
||||
add_register(self, r)
|
||||
|
||||
def refactor_parent(self, parent):
|
||||
self.parent_base_address = parent.base_address
|
||||
@@ -342,11 +338,11 @@ class SVDPeripheralRegister:
|
||||
else:
|
||||
self.size = 0x20
|
||||
self.fields = SmartDict()
|
||||
if "fields" in svd_elem:
|
||||
if hasattr(svd_elem, "fields"):
|
||||
# Filter fields to only consider those of tag "field"
|
||||
for f in svd_elem.fields.field:
|
||||
if isinstance(f, x2d.ObjectDict):
|
||||
self.fields[str(f.name)] = SVDPeripheralRegisterField(f, self)
|
||||
fields = [f for f in svd_elem.fields.getchildren() if f.tag == "field"]
|
||||
for f in fields:
|
||||
self.fields[str(f.name)] = SVDPeripheralRegisterField(f, self)
|
||||
|
||||
def refactor_parent(self, parent):
|
||||
self.parent_base_address = parent.base_address
|
||||
109
scripts/debug/flipperversion.py
Normal file
109
scripts/debug/flipperversion.py
Normal file
@@ -0,0 +1,109 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, Optional
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
# Must match FuriHalRtcRegisterVersion index in FuriHalRtcRegister enum
|
||||
RTC_BACKUP_VERSION_REGISTER_IDX = 0x2
|
||||
|
||||
RTC_BASE = 0x40002800
|
||||
RTC_BACKUP_BASE = RTC_BASE + 0x50
|
||||
|
||||
VERSION_REGISTER_ADDRESS = RTC_BACKUP_BASE + RTC_BACKUP_VERSION_REGISTER_IDX * 4
|
||||
|
||||
VERSION_STRUCT_MAGIC = 0xBE40
|
||||
|
||||
|
||||
@dataclass
|
||||
class VersionData:
|
||||
git_hash: str
|
||||
git_branch: str
|
||||
build_date: str
|
||||
version: str
|
||||
target: int
|
||||
build_is_dirty: bool
|
||||
extra: Optional[Dict[str, str]] = field(default_factory=dict)
|
||||
|
||||
|
||||
class VersionLoader:
|
||||
def __init__(self, version_ptr):
|
||||
self.version_ptr = version_ptr
|
||||
self._cstr_type = gdb.lookup_type("char").pointer()
|
||||
self._uint_type = gdb.lookup_type("unsigned int")
|
||||
|
||||
version_signature = version_ptr.dereference().cast(self._uint_type)
|
||||
is_versioned = (version_signature & (0xFFFF)) == VERSION_STRUCT_MAGIC
|
||||
if is_versioned:
|
||||
self._version_data = self.load_versioned(
|
||||
major=version_signature >> 16 & 0xFF,
|
||||
minor=version_signature >> 24 & 0xFF,
|
||||
)
|
||||
else:
|
||||
self._version_data = self.load_unversioned()
|
||||
|
||||
@property
|
||||
def version(self) -> VersionData:
|
||||
return self._version_data
|
||||
|
||||
def load_versioned(self, major, minor):
|
||||
if major != 1:
|
||||
raise ValueError("Unsupported version struct major version")
|
||||
|
||||
# Struct version 1.0
|
||||
extra_data = int(self.version_ptr[5].cast(self._uint_type))
|
||||
return VersionData(
|
||||
git_hash=self.version_ptr[1].cast(self._cstr_type).string(),
|
||||
git_branch=self.version_ptr[2].cast(self._cstr_type).string(),
|
||||
build_date=self.version_ptr[3].cast(self._cstr_type).string(),
|
||||
version=self.version_ptr[4].cast(self._cstr_type).string(),
|
||||
target=extra_data & 0xF,
|
||||
build_is_dirty=bool((extra_data >> 8) & 0xF),
|
||||
)
|
||||
|
||||
def load_unversioned(self):
|
||||
"""Parse an early version of the version struct."""
|
||||
extra_data = int(self.version_ptr[5].cast(self._uint_type))
|
||||
return VersionData(
|
||||
git_hash=self.version_ptr[0].cast(self._cstr_type).string(),
|
||||
git_branch=self.version_ptr[1].cast(self._cstr_type).string(),
|
||||
# branch number is #2, but we don't care about it
|
||||
build_date=self.version_ptr[3].cast(self._cstr_type).string(),
|
||||
version=self.version_ptr[4].cast(self._cstr_type).string(),
|
||||
target=extra_data & 0xF,
|
||||
build_is_dirty=bool((extra_data >> 8) & 0xF),
|
||||
)
|
||||
|
||||
|
||||
class FlipperFwVersion(gdb.Command):
|
||||
"""Print the version of Flipper's firmware."""
|
||||
|
||||
def __init__(self):
|
||||
super(FlipperFwVersion, self).__init__("fw-version", gdb.COMMAND_USER)
|
||||
|
||||
def invoke(self, arg, from_tty):
|
||||
void_ptr_type = gdb.lookup_type("void").pointer().pointer()
|
||||
version_ptr_ptr = gdb.Value(VERSION_REGISTER_ADDRESS).cast(void_ptr_type)
|
||||
|
||||
if not version_ptr_ptr:
|
||||
print("RTC version register is NULL")
|
||||
return
|
||||
|
||||
version_ptr = version_ptr_ptr.dereference()
|
||||
if not version_ptr:
|
||||
print("Pointer to version struct is NULL")
|
||||
return
|
||||
|
||||
version_struct = version_ptr.cast(void_ptr_type)
|
||||
|
||||
v = VersionLoader(version_struct)
|
||||
print("Firmware version on attached Flipper:")
|
||||
print(f"\tVersion: {v.version.version}")
|
||||
print(f"\tBuilt on: {v.version.build_date}")
|
||||
print(f"\tGit branch: {v.version.git_branch}")
|
||||
print(f"\tGit commit: {v.version.git_hash}")
|
||||
print(f"\tDirty: {v.version.build_is_dirty}")
|
||||
print(f"\tHW Target: {v.version.target}")
|
||||
|
||||
|
||||
FlipperFwVersion()
|
||||
@@ -18,7 +18,7 @@ def GetDevices(env):
|
||||
def generate(env, **kw):
|
||||
env.AddMethod(GetDevices)
|
||||
env.SetDefault(
|
||||
FBT_DEBUG_DIR="${ROOT_DIR}/debug",
|
||||
FBT_DEBUG_DIR="${FBT_SCRIPT_DIR}/debug",
|
||||
)
|
||||
|
||||
if (adapter_serial := env.subst("$OPENOCD_ADAPTER_SERIAL")) != "auto":
|
||||
@@ -39,10 +39,10 @@ def generate(env, **kw):
|
||||
"|openocd -c 'gdb_port pipe; log_output ${FBT_DEBUG_DIR}/openocd.log' ${[SINGLEQUOTEFUNC(OPENOCD_OPTS)]}"
|
||||
],
|
||||
GDBOPTS_BASE=[
|
||||
"-ex",
|
||||
"target extended-remote ${GDBREMOTE}",
|
||||
"-ex",
|
||||
"source ${FBT_DEBUG_DIR}/gdbinit",
|
||||
"-ex",
|
||||
"target extended-remote ${GDBREMOTE}",
|
||||
],
|
||||
GDBOPTS_BLACKMAGIC=[
|
||||
"-q",
|
||||
@@ -61,6 +61,8 @@ def generate(env, **kw):
|
||||
"-ex",
|
||||
"source ${FBT_DEBUG_DIR}/flipperapps.py",
|
||||
"-ex",
|
||||
"source ${FBT_DEBUG_DIR}/flipperversion.py",
|
||||
"-ex",
|
||||
"fap-set-debug-elf-root ${FBT_FAP_DEBUG_ELF_ROOT}",
|
||||
"-ex",
|
||||
"source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py",
|
||||
@@ -68,6 +70,8 @@ def generate(env, **kw):
|
||||
"svd_load ${SVD_FILE}",
|
||||
"-ex",
|
||||
"compare-sections",
|
||||
"-ex",
|
||||
"fw-version",
|
||||
],
|
||||
JFLASHPROJECT="${FBT_DEBUG_DIR}/fw.jflash",
|
||||
)
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import logging
|
||||
import json
|
||||
from io import BytesIO
|
||||
import tarfile
|
||||
import xml.etree.ElementTree as ET
|
||||
import posixpath
|
||||
import logging
|
||||
import os
|
||||
import posixpath
|
||||
import tarfile
|
||||
from io import BytesIO
|
||||
|
||||
from flipper.utils import file_sha256, timestamp
|
||||
from flipper.assets.coprobin import CoproBinary, get_stack_type
|
||||
from flipper.utils import file_sha256, timestamp
|
||||
|
||||
|
||||
CUBE_COPRO_PATH = "Projects/STM32WB_Copro_Wireless_Binaries"
|
||||
CUBE_COPRO_PATH = "firmware"
|
||||
|
||||
MANIFEST_TEMPLATE = {
|
||||
"manifest": {"version": 0, "timestamp": 0},
|
||||
@@ -27,8 +25,7 @@ MANIFEST_TEMPLATE = {
|
||||
class Copro:
|
||||
COPRO_TAR_DIR = "core2_firmware"
|
||||
|
||||
def __init__(self, mcu):
|
||||
self.mcu = mcu
|
||||
def __init__(self):
|
||||
self.version = None
|
||||
self.cube_dir = None
|
||||
self.mcu_copro = None
|
||||
@@ -38,20 +35,24 @@ class Copro:
|
||||
if not os.path.isdir(cube_dir):
|
||||
raise Exception(f'"{cube_dir}" doesn\'t exists')
|
||||
self.cube_dir = cube_dir
|
||||
self.mcu_copro = os.path.join(self.cube_dir, CUBE_COPRO_PATH, self.mcu)
|
||||
self.mcu_copro = os.path.join(self.cube_dir, CUBE_COPRO_PATH)
|
||||
if not os.path.isdir(self.mcu_copro):
|
||||
raise Exception(f'"{self.mcu_copro}" doesn\'t exists')
|
||||
cube_manifest_file = os.path.join(self.cube_dir, "package.xml")
|
||||
cube_manifest = ET.parse(cube_manifest_file)
|
||||
cube_package = cube_manifest.find("PackDescription")
|
||||
if not cube_package:
|
||||
raise Exception("Unknown Cube manifest format")
|
||||
cube_version = cube_package.get("Patch") or cube_package.get("Release")
|
||||
if not cube_version or not cube_version.startswith("FW.WB"):
|
||||
raise Exception("Incorrect Cube package or version info")
|
||||
cube_version = cube_version.replace("FW.WB.", "", 1)
|
||||
try:
|
||||
cube_manifest_file = os.path.join(self.cube_dir, "VERSION")
|
||||
with open(cube_manifest_file, "r") as cube_manifest:
|
||||
cube_version = cube_manifest.read().strip()
|
||||
except IOError:
|
||||
raise Exception(f"Failed to read version from {cube_manifest_file}")
|
||||
|
||||
if not cube_version.startswith("v"):
|
||||
raise Exception(f"Invalid cube version: {cube_version}")
|
||||
cube_version = cube_version[1:]
|
||||
|
||||
if cube_version != reference_cube_version:
|
||||
raise Exception("Unsupported cube version")
|
||||
raise Exception(
|
||||
f"Unsupported cube version: {cube_version}, expecting {reference_cube_version}"
|
||||
)
|
||||
self.version = cube_version
|
||||
|
||||
def _getFileName(self, name):
|
||||
|
||||
@@ -5,7 +5,7 @@ import os.path
|
||||
import sys
|
||||
|
||||
|
||||
# From STM32CubeWB\Middlewares\ST\STM32_WPAN\interface\patterns\ble_thread\shci\shci.h
|
||||
# From lib/stm32wb_copro/wpan/interface/patterns/ble_thread/shci/shci.h
|
||||
__STACK_TYPE_CODES = {
|
||||
"BLE_FULL": 0x01,
|
||||
"BLE_HCI": 0x02,
|
||||
|
||||
@@ -170,7 +170,6 @@ class Main(App):
|
||||
"update.dir",
|
||||
"sdk_headers.dir",
|
||||
"lib.dir",
|
||||
"debug.dir",
|
||||
"scripts.dir",
|
||||
)
|
||||
|
||||
|
||||
@@ -186,6 +186,33 @@ dist_env.PhonyTarget(
|
||||
FBT_FAP_DEBUG_ELF_ROOT=path_as_posix(dist_env.subst("$FBT_FAP_DEBUG_ELF_ROOT")),
|
||||
)
|
||||
|
||||
# Debug alien elf
|
||||
debug_other_opts = [
|
||||
"-ex",
|
||||
"source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py",
|
||||
"-ex",
|
||||
"source ${FBT_DEBUG_DIR}/flipperversion.py",
|
||||
"-ex",
|
||||
"fw-version",
|
||||
]
|
||||
|
||||
dist_env.PhonyTarget(
|
||||
"debug_other",
|
||||
"${GDBPYCOM}",
|
||||
GDBOPTS="${GDBOPTS_BASE}",
|
||||
GDBREMOTE="${OPENOCD_GDB_PIPE}",
|
||||
GDBPYOPTS=debug_other_opts,
|
||||
)
|
||||
|
||||
dist_env.PhonyTarget(
|
||||
"debug_other_blackmagic",
|
||||
"${GDBPYCOM}",
|
||||
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
|
||||
GDBREMOTE="${BLACKMAGIC_ADDR}",
|
||||
GDBPYOPTS=debug_other_opts,
|
||||
)
|
||||
|
||||
|
||||
dist_env.PhonyTarget(
|
||||
"flash_blackmagic",
|
||||
"$GDB $GDBOPTS $SOURCES $GDBFLASH",
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
"@UFBT_DEBUG_DIR@/stm32wbx.cfg"
|
||||
],
|
||||
"postAttachCommands": [
|
||||
"source @UFBT_DEBUG_DIR@/flipperversion.py",
|
||||
"fw-version",
|
||||
"source @UFBT_DEBUG_DIR@/flipperapps.py",
|
||||
"fap-set-debug-elf-root @UFBT_DEBUG_ELF_DIR@"
|
||||
],
|
||||
@@ -49,6 +51,8 @@
|
||||
"@UFBT_DEBUG_DIR@/stm32wbx.cfg"
|
||||
],
|
||||
"postAttachCommands": [
|
||||
"source @UFBT_DEBUG_DIR@/flipperversion.py",
|
||||
"fw-version",
|
||||
"source @UFBT_DEBUG_DIR@/flipperapps.py",
|
||||
"fap-set-debug-elf-root @UFBT_DEBUG_ELF_DIR@"
|
||||
],
|
||||
@@ -69,6 +73,8 @@
|
||||
"attach 1",
|
||||
"set confirm off",
|
||||
"set mem inaccessible-by-default off",
|
||||
"source @UFBT_DEBUG_DIR@/flipperversion.py",
|
||||
"fw-version",
|
||||
"source @UFBT_DEBUG_DIR@/flipperapps.py",
|
||||
"fap-set-debug-elf-root @UFBT_DEBUG_ELF_DIR@"
|
||||
]
|
||||
@@ -86,6 +92,8 @@
|
||||
"svdFile": "@UFBT_DEBUG_DIR@/STM32WB55_CM4.svd",
|
||||
"rtos": "FreeRTOS",
|
||||
"postAttachCommands": [
|
||||
"source @UFBT_DEBUG_DIR@/flipperversion.py",
|
||||
"fw-version",
|
||||
"source @UFBT_DEBUG_DIR@/flipperapps.py",
|
||||
"fap-set-debug-elf-root @UFBT_DEBUG_ELF_DIR@"
|
||||
]
|
||||
|
||||
@@ -78,10 +78,8 @@ def generate(env, **kw):
|
||||
env.SetDefault(
|
||||
# Paths
|
||||
SDK_DEFINITION=env.File(sdk_data["sdk_symbols"]),
|
||||
FBT_DEBUG_DIR=pathlib.Path(
|
||||
sdk_current_sdk_dir_node.Dir(sdk_components["debug.dir"]).abspath
|
||||
).as_posix(),
|
||||
FBT_SCRIPT_DIR=scripts_dir,
|
||||
FBT_DEBUG_DIR=scripts_dir.Dir("debug"),
|
||||
LIBPATH=sdk_current_sdk_dir_node.Dir(sdk_components["lib.dir"]),
|
||||
FW_ELF=sdk_current_sdk_dir_node.File(sdk_components["firmware.elf"]),
|
||||
FW_BIN=sdk_current_sdk_dir_node.File(sdk_components["full.bin"]),
|
||||
|
||||
@@ -56,7 +56,6 @@ class GitVersion:
|
||||
return {
|
||||
"GIT_COMMIT": commit,
|
||||
"GIT_BRANCH": branch,
|
||||
"GIT_BRANCH_NUM": branch_num,
|
||||
"FURI_CUSTOM_FLIPPER_NAME": custom_fz_name,
|
||||
"VERSION": version,
|
||||
"BUILD_DIRTY": dirty and 1 or 0,
|
||||
@@ -65,7 +64,6 @@ class GitVersion:
|
||||
return {
|
||||
"GIT_COMMIT": commit,
|
||||
"GIT_BRANCH": branch,
|
||||
"GIT_BRANCH_NUM": branch_num,
|
||||
"VERSION": version,
|
||||
"BUILD_DIRTY": dirty and 1 or 0,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user