2021-01-11 14:52:35 +00:00
|
|
|
#include "fatfs.h"
|
|
|
|
#include "filesystem-api.h"
|
|
|
|
#include "sd-filesystem.h"
|
|
|
|
#include "menu/menu.h"
|
|
|
|
#include "menu/menu_item.h"
|
2021-01-13 21:23:34 +00:00
|
|
|
#include "cli/cli.h"
|
2021-03-09 11:53:33 +00:00
|
|
|
#include "api-hal-sd.h"
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
FS_Api* fs_api_alloc() {
|
|
|
|
FS_Api* fs_api = furi_alloc(sizeof(FS_Api));
|
|
|
|
|
|
|
|
// fill file api
|
|
|
|
fs_api->file.open = fs_file_open;
|
|
|
|
fs_api->file.close = fs_file_close;
|
|
|
|
fs_api->file.read = fs_file_read;
|
|
|
|
fs_api->file.write = fs_file_write;
|
|
|
|
fs_api->file.seek = fs_file_seek;
|
|
|
|
fs_api->file.tell = fs_file_tell;
|
|
|
|
fs_api->file.truncate = fs_file_truncate;
|
|
|
|
fs_api->file.size = fs_file_size;
|
|
|
|
fs_api->file.sync = fs_file_sync;
|
|
|
|
fs_api->file.eof = fs_file_eof;
|
|
|
|
|
|
|
|
// fill dir api
|
|
|
|
fs_api->dir.open = fs_dir_open;
|
|
|
|
fs_api->dir.close = fs_dir_close;
|
|
|
|
fs_api->dir.read = fs_dir_read;
|
|
|
|
fs_api->dir.rewind = fs_dir_rewind;
|
|
|
|
|
|
|
|
// fill common api
|
|
|
|
fs_api->common.info = fs_common_info;
|
|
|
|
fs_api->common.remove = fs_common_remove;
|
|
|
|
fs_api->common.rename = fs_common_rename;
|
|
|
|
fs_api->common.set_attr = fs_common_set_attr;
|
|
|
|
fs_api->common.mkdir = fs_common_mkdir;
|
|
|
|
fs_api->common.set_time = fs_common_set_time;
|
|
|
|
fs_api->common.get_fs_info = fs_get_fs_info;
|
|
|
|
|
|
|
|
// fill errors api
|
|
|
|
fs_api->error.get_desc = fs_error_get_desc;
|
|
|
|
fs_api->error.get_internal_desc = fs_error_get_internal_desc;
|
|
|
|
|
|
|
|
return fs_api;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sd_set_lines(SdApp* sd_app, uint8_t count, ...) {
|
|
|
|
va_list argptr;
|
|
|
|
count = min(count, SD_STATE_LINES_COUNT);
|
|
|
|
|
|
|
|
for(uint8_t i = 0; i < SD_STATE_LINES_COUNT; i++) {
|
|
|
|
sd_app->line[i] = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
va_start(argptr, count);
|
|
|
|
|
|
|
|
for(uint8_t i = 0; i < count; i++) {
|
|
|
|
sd_app->line[i] = va_arg(argptr, char*);
|
|
|
|
}
|
|
|
|
|
|
|
|
va_end(argptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sd_icon_draw_callback(Canvas* canvas, void* context) {
|
|
|
|
furi_assert(canvas);
|
|
|
|
furi_assert(context);
|
|
|
|
SdApp* sd_app = context;
|
|
|
|
|
|
|
|
switch(sd_app->info.status) {
|
|
|
|
case SD_NO_CARD:
|
|
|
|
break;
|
|
|
|
case SD_OK:
|
|
|
|
canvas_draw_icon(canvas, 0, 0, sd_app->icon.mounted);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
canvas_draw_icon(canvas, 0, 0, sd_app->icon.fail);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sd_app_draw_callback(Canvas* canvas, void* context) {
|
|
|
|
furi_assert(canvas);
|
|
|
|
furi_assert(context);
|
|
|
|
SdApp* sd_app = context;
|
|
|
|
|
|
|
|
canvas_clear(canvas);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
|
|
|
for(uint8_t i = 0; i < SD_STATE_LINES_COUNT; i++) {
|
|
|
|
canvas_draw_str(canvas, 0, (i + 1) * 10, sd_app->line[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sd_app_input_callback(InputEvent* event, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SdApp* sd_app = context;
|
|
|
|
|
|
|
|
osMessageQueuePut(sd_app->event_queue, event, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
SdApp* sd_app_alloc() {
|
|
|
|
SdApp* sd_app = furi_alloc(sizeof(SdApp));
|
|
|
|
|
|
|
|
// init inner fs data
|
2021-02-12 17:24:34 +00:00
|
|
|
furi_check(_fs_init(&sd_app->info));
|
2021-01-11 14:52:35 +00:00
|
|
|
|
2021-02-10 08:56:05 +00:00
|
|
|
sd_app->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
// init view_port
|
|
|
|
sd_app->view_port = view_port_alloc();
|
|
|
|
view_port_draw_callback_set(sd_app->view_port, sd_app_draw_callback, sd_app);
|
|
|
|
view_port_input_callback_set(sd_app->view_port, sd_app_input_callback, sd_app);
|
|
|
|
view_port_enabled_set(sd_app->view_port, false);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
// init lines
|
|
|
|
sd_set_lines(sd_app, 0);
|
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
// init icon view_port
|
|
|
|
sd_app->icon.view_port = view_port_alloc();
|
2021-01-11 14:52:35 +00:00
|
|
|
sd_app->icon.mounted = assets_icons_get(I_SDcardMounted_11x8);
|
|
|
|
sd_app->icon.fail = assets_icons_get(I_SDcardFail_11x8);
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_set_width(sd_app->icon.view_port, icon_get_width(sd_app->icon.mounted));
|
|
|
|
view_port_draw_callback_set(sd_app->icon.view_port, sd_icon_draw_callback, sd_app);
|
|
|
|
view_port_enabled_set(sd_app->icon.view_port, false);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
return sd_app;
|
|
|
|
}
|
|
|
|
|
2021-02-10 08:56:05 +00:00
|
|
|
bool app_sd_ask(SdApp* sd_app, InputKey input_true, InputKey input_false) {
|
2021-01-11 14:52:35 +00:00
|
|
|
bool result;
|
|
|
|
|
|
|
|
InputEvent event;
|
|
|
|
while(1) {
|
|
|
|
osStatus_t event_status =
|
|
|
|
osMessageQueueGet(sd_app->event_queue, &event, NULL, osWaitForever);
|
|
|
|
|
|
|
|
if(event_status == osOK) {
|
2021-02-10 08:56:05 +00:00
|
|
|
if(event.type == InputTypeShort && event.key == input_true) {
|
2021-01-11 14:52:35 +00:00
|
|
|
result = true;
|
|
|
|
break;
|
|
|
|
}
|
2021-02-10 08:56:05 +00:00
|
|
|
if(event.type == InputTypeShort && event.key == InputKeyBack) {
|
2021-01-11 14:52:35 +00:00
|
|
|
result = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void app_sd_info_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SdApp* sd_app = context;
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->view_port, true);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
// dynamic strings
|
|
|
|
const uint8_t str_buffer_size = 26;
|
|
|
|
const uint8_t str_count = 6;
|
|
|
|
char* str_buffer[str_count];
|
|
|
|
bool memory_error = false;
|
|
|
|
|
|
|
|
// info vars
|
|
|
|
uint32_t serial_num;
|
|
|
|
SDError get_label_result, get_free_result;
|
|
|
|
FATFS* fs;
|
|
|
|
uint32_t free_clusters, free_sectors, total_sectors;
|
|
|
|
char volume_label[34];
|
|
|
|
|
|
|
|
// init strings
|
|
|
|
for(uint8_t i = 0; i < str_count; i++) {
|
|
|
|
str_buffer[i] = malloc(str_buffer_size + 1);
|
|
|
|
if(str_buffer[i] == NULL) {
|
|
|
|
memory_error = true;
|
|
|
|
} else {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
str_buffer[i][0] = 0;
|
2021-01-11 14:52:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(memory_error) {
|
|
|
|
sd_set_lines(sd_app, 1, "not enough memory");
|
|
|
|
} else {
|
|
|
|
// get fs info
|
|
|
|
_fs_lock(&sd_app->info);
|
|
|
|
get_label_result = f_getlabel(sd_app->info.path, volume_label, &serial_num);
|
|
|
|
get_free_result = f_getfree(sd_app->info.path, &free_clusters, &fs);
|
|
|
|
_fs_unlock(&sd_app->info);
|
|
|
|
|
|
|
|
// calculate size
|
|
|
|
total_sectors = (fs->n_fatent - 2) * fs->csize;
|
|
|
|
free_sectors = free_clusters * fs->csize;
|
|
|
|
uint16_t sector_size = _MAX_SS;
|
|
|
|
#if _MAX_SS != _MIN_SS
|
|
|
|
sector_size = fs->ssize;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// output info to dynamic strings
|
|
|
|
if(get_label_result == SD_OK && get_free_result == SD_OK) {
|
|
|
|
snprintf(str_buffer[0], str_buffer_size, "%s", volume_label);
|
|
|
|
|
|
|
|
const char* fs_type = "";
|
|
|
|
|
|
|
|
switch(fs->fs_type) {
|
|
|
|
case(FS_FAT12):
|
|
|
|
fs_type = "FAT12";
|
|
|
|
break;
|
|
|
|
case(FS_FAT16):
|
|
|
|
fs_type = "FAT16";
|
|
|
|
break;
|
|
|
|
case(FS_FAT32):
|
|
|
|
fs_type = "FAT32";
|
|
|
|
break;
|
|
|
|
case(FS_EXFAT):
|
|
|
|
fs_type = "EXFAT";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fs_type = "UNKNOWN";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(str_buffer[1], str_buffer_size, "%s, S/N: %lu", fs_type, serial_num);
|
|
|
|
|
|
|
|
snprintf(str_buffer[2], str_buffer_size, "Cluster: %d sectors", fs->csize);
|
|
|
|
snprintf(str_buffer[3], str_buffer_size, "Sector: %d bytes", sector_size);
|
|
|
|
snprintf(
|
|
|
|
str_buffer[4], str_buffer_size, "%lu KB total", total_sectors / 1024 * sector_size);
|
|
|
|
snprintf(
|
|
|
|
str_buffer[5], str_buffer_size, "%lu KB free", free_sectors / 1024 * sector_size);
|
|
|
|
} else {
|
|
|
|
snprintf(str_buffer[0], str_buffer_size, "SD status error:");
|
|
|
|
snprintf(
|
|
|
|
str_buffer[1],
|
|
|
|
str_buffer_size,
|
|
|
|
"%s",
|
|
|
|
fs_error_get_internal_desc(_fs_status(&sd_app->info)));
|
|
|
|
snprintf(str_buffer[2], str_buffer_size, "Label error:");
|
|
|
|
snprintf(
|
|
|
|
str_buffer[3], str_buffer_size, "%s", fs_error_get_internal_desc(get_label_result));
|
|
|
|
snprintf(str_buffer[4], str_buffer_size, "Get free error:");
|
|
|
|
snprintf(
|
|
|
|
str_buffer[5], str_buffer_size, "%s", fs_error_get_internal_desc(get_free_result));
|
|
|
|
}
|
|
|
|
|
|
|
|
// dynamic strings to screen
|
|
|
|
sd_set_lines(
|
|
|
|
sd_app,
|
|
|
|
6,
|
|
|
|
str_buffer[0],
|
|
|
|
str_buffer[1],
|
|
|
|
str_buffer[2],
|
|
|
|
str_buffer[3],
|
|
|
|
str_buffer[4],
|
|
|
|
str_buffer[5]);
|
|
|
|
}
|
|
|
|
|
2021-02-10 08:56:05 +00:00
|
|
|
app_sd_ask(sd_app, InputKeyBack, InputKeyBack);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
sd_set_lines(sd_app, 0);
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->view_port, false);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
for(uint8_t i = 0; i < str_count; i++) {
|
|
|
|
free(str_buffer[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-13 21:23:34 +00:00
|
|
|
void app_sd_format_internal(SdApp* sd_app) {
|
|
|
|
uint8_t* work_area;
|
|
|
|
|
|
|
|
_fs_lock(&sd_app->info);
|
|
|
|
work_area = malloc(_MAX_SS);
|
|
|
|
if(work_area == NULL) {
|
|
|
|
sd_app->info.status = SD_NOT_ENOUGH_CORE;
|
|
|
|
} else {
|
|
|
|
sd_app->info.status = f_mkfs(sd_app->info.path, FM_ANY, 0, work_area, _MAX_SS);
|
|
|
|
free(work_area);
|
|
|
|
|
|
|
|
if(sd_app->info.status == SD_OK) {
|
|
|
|
// set label and mount card
|
|
|
|
f_setlabel("Flipper SD");
|
|
|
|
sd_app->info.status = f_mount(&sd_app->info.fat_fs, sd_app->info.path, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_fs_unlock(&sd_app->info);
|
|
|
|
}
|
|
|
|
|
2021-01-11 14:52:35 +00:00
|
|
|
void app_sd_format_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SdApp* sd_app = context;
|
|
|
|
|
|
|
|
// ask to really format
|
|
|
|
sd_set_lines(sd_app, 2, "Press UP to format", "or BACK to exit");
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->view_port, true);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
// wait for input
|
2021-02-10 08:56:05 +00:00
|
|
|
if(!app_sd_ask(sd_app, InputKeyUp, InputKeyBack)) {
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->view_port, false);
|
2021-01-11 14:52:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// show warning
|
|
|
|
sd_set_lines(sd_app, 3, "formatting SD card", "procedure can be lengthy", "please wait");
|
|
|
|
|
|
|
|
// format card
|
2021-01-13 21:23:34 +00:00
|
|
|
app_sd_format_internal(sd_app);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
if(sd_app->info.status != SD_OK) {
|
|
|
|
sd_set_lines(
|
|
|
|
sd_app, 2, "SD card format error", fs_error_get_internal_desc(sd_app->info.status));
|
|
|
|
} else {
|
|
|
|
sd_set_lines(sd_app, 1, "SD card formatted");
|
|
|
|
}
|
|
|
|
|
|
|
|
// wait for BACK
|
2021-02-10 08:56:05 +00:00
|
|
|
app_sd_ask(sd_app, InputKeyBack, InputKeyBack);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->view_port, false);
|
2021-01-11 14:52:35 +00:00
|
|
|
}
|
|
|
|
|
2021-03-09 11:53:33 +00:00
|
|
|
void app_sd_notify_wait_on() {
|
|
|
|
api_hal_light_set(LightRed, 0xFF);
|
|
|
|
api_hal_light_set(LightBlue, 0xFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
void app_sd_notify_wait_off() {
|
|
|
|
api_hal_light_set(LightRed, 0x00);
|
|
|
|
api_hal_light_set(LightBlue, 0x00);
|
|
|
|
}
|
|
|
|
|
|
|
|
void app_sd_notify_success() {
|
|
|
|
for(uint8_t i = 0; i < 3; i++) {
|
|
|
|
delay(50);
|
|
|
|
api_hal_light_set(LightGreen, 0xFF);
|
|
|
|
delay(50);
|
|
|
|
api_hal_light_set(LightGreen, 0x00);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void app_sd_notify_eject() {
|
|
|
|
for(uint8_t i = 0; i < 3; i++) {
|
|
|
|
delay(50);
|
|
|
|
api_hal_light_set(LightBlue, 0xFF);
|
|
|
|
delay(50);
|
|
|
|
api_hal_light_set(LightBlue, 0x00);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void app_sd_notify_error() {
|
|
|
|
for(uint8_t i = 0; i < 3; i++) {
|
|
|
|
delay(50);
|
|
|
|
api_hal_light_set(LightRed, 0xFF);
|
|
|
|
delay(50);
|
|
|
|
api_hal_light_set(LightRed, 0x00);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool app_sd_mount_card(SdApp* sd_app) {
|
|
|
|
bool result = false;
|
|
|
|
const uint8_t max_init_counts = 10;
|
|
|
|
uint8_t counter = max_init_counts;
|
|
|
|
uint8_t bsp_result;
|
|
|
|
|
|
|
|
_fs_lock(&sd_app->info);
|
|
|
|
|
|
|
|
while(result == false && counter > 0 && hal_sd_detect()) {
|
|
|
|
app_sd_notify_wait_on();
|
|
|
|
|
|
|
|
if((counter % 10) == 0) {
|
|
|
|
// power reset sd card
|
|
|
|
bsp_result = BSP_SD_Init(true);
|
|
|
|
} else {
|
|
|
|
bsp_result = BSP_SD_Init(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bsp_result) {
|
|
|
|
// bsp error
|
|
|
|
sd_app->info.status = SD_LOW_LEVEL_ERR;
|
|
|
|
} else {
|
|
|
|
sd_app->info.status = f_mount(&sd_app->info.fat_fs, sd_app->info.path, 1);
|
|
|
|
|
|
|
|
if(sd_app->info.status == SD_OK || sd_app->info.status == SD_NO_FILESYSTEM) {
|
|
|
|
FATFS* fs;
|
|
|
|
uint32_t free_clusters;
|
|
|
|
|
|
|
|
sd_app->info.status = f_getfree(sd_app->info.path, &free_clusters, &fs);
|
|
|
|
|
|
|
|
if(sd_app->info.status == SD_OK || sd_app->info.status == SD_NO_FILESYSTEM) {
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
app_sd_notify_wait_off();
|
|
|
|
|
|
|
|
if(!result) {
|
|
|
|
delay(1000);
|
|
|
|
printf(
|
|
|
|
"[sd_filesystem] init(%d), error: %s\r\n",
|
|
|
|
counter,
|
|
|
|
fs_error_get_internal_desc(sd_app->info.status));
|
|
|
|
|
|
|
|
counter--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_fs_unlock(&sd_app->info);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-11 14:52:35 +00:00
|
|
|
void app_sd_unmount_card(SdApp* sd_app) {
|
|
|
|
_fs_lock(&sd_app->info);
|
|
|
|
|
|
|
|
// set status
|
|
|
|
sd_app->info.status = SD_NO_CARD;
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->icon.view_port, false);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
// close files
|
|
|
|
for(uint8_t index = 0; index < SD_FS_MAX_FILES; index++) {
|
|
|
|
FileData* filedata = &sd_app->info.files[index];
|
|
|
|
|
|
|
|
if(filedata->thread_id != NULL) {
|
|
|
|
if(filedata->is_dir) {
|
|
|
|
f_closedir(&filedata->data.dir);
|
|
|
|
} else {
|
|
|
|
f_close(&filedata->data.file);
|
|
|
|
}
|
|
|
|
filedata->thread_id = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// unmount volume
|
|
|
|
f_mount(0, sd_app->info.path, 0);
|
|
|
|
|
|
|
|
_fs_unlock(&sd_app->info);
|
|
|
|
}
|
|
|
|
|
|
|
|
void app_sd_eject_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SdApp* sd_app = context;
|
|
|
|
|
|
|
|
sd_set_lines(sd_app, 1, "ejecting SD card");
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->view_port, true);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
app_sd_unmount_card(sd_app);
|
|
|
|
|
|
|
|
sd_set_lines(sd_app, 1, "SD card can be pulled out");
|
|
|
|
|
|
|
|
// wait for BACK
|
2021-02-10 08:56:05 +00:00
|
|
|
app_sd_ask(sd_app, InputKeyBack, InputKeyBack);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->view_port, false);
|
2021-01-11 14:52:35 +00:00
|
|
|
}
|
|
|
|
|
2021-01-13 21:23:34 +00:00
|
|
|
static void cli_sd_status(string_t args, void* _ctx) {
|
|
|
|
SdApp* sd_app = (SdApp*)_ctx;
|
|
|
|
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("SD status: ");
|
|
|
|
printf(fs_error_get_internal_desc(sd_app->info.status));
|
|
|
|
printf("\r\n");
|
2021-01-13 21:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cli_sd_format(string_t args, void* _ctx) {
|
|
|
|
SdApp* sd_app = (SdApp*)_ctx;
|
|
|
|
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("formatting SD card, please wait\r\n");
|
2021-01-13 21:23:34 +00:00
|
|
|
|
|
|
|
// format card
|
|
|
|
app_sd_format_internal(sd_app);
|
|
|
|
|
|
|
|
if(sd_app->info.status != SD_OK) {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("SD card format error: ");
|
|
|
|
printf(fs_error_get_internal_desc(sd_app->info.status));
|
|
|
|
printf("\r\n");
|
2021-01-13 21:23:34 +00:00
|
|
|
} else {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("SD card formatted\r\n");
|
2021-01-13 21:23:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cli_sd_info(string_t args, void* _ctx) {
|
|
|
|
SdApp* sd_app = (SdApp*)_ctx;
|
|
|
|
|
|
|
|
const uint8_t str_buffer_size = 64;
|
|
|
|
char str_buffer[str_buffer_size];
|
|
|
|
|
|
|
|
// info vars
|
|
|
|
uint32_t serial_num;
|
|
|
|
SDError get_label_result, get_free_result;
|
|
|
|
FATFS* fs;
|
|
|
|
uint32_t free_clusters, free_sectors, total_sectors;
|
|
|
|
char volume_label[34];
|
|
|
|
|
|
|
|
// get fs info
|
|
|
|
_fs_lock(&sd_app->info);
|
|
|
|
get_label_result = f_getlabel(sd_app->info.path, volume_label, &serial_num);
|
|
|
|
get_free_result = f_getfree(sd_app->info.path, &free_clusters, &fs);
|
|
|
|
_fs_unlock(&sd_app->info);
|
|
|
|
|
|
|
|
// calculate size
|
|
|
|
total_sectors = (fs->n_fatent - 2) * fs->csize;
|
|
|
|
free_sectors = free_clusters * fs->csize;
|
|
|
|
uint16_t sector_size = _MAX_SS;
|
|
|
|
#if _MAX_SS != _MIN_SS
|
|
|
|
sector_size = fs->ssize;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// output info to dynamic strings
|
|
|
|
if(get_label_result == SD_OK && get_free_result == SD_OK) {
|
|
|
|
const char* fs_type = "";
|
|
|
|
|
|
|
|
switch(fs->fs_type) {
|
|
|
|
case(FS_FAT12):
|
|
|
|
fs_type = "FAT12";
|
|
|
|
break;
|
|
|
|
case(FS_FAT16):
|
|
|
|
fs_type = "FAT16";
|
|
|
|
break;
|
|
|
|
case(FS_FAT32):
|
|
|
|
fs_type = "FAT32";
|
|
|
|
break;
|
|
|
|
case(FS_EXFAT):
|
|
|
|
fs_type = "EXFAT";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fs_type = "UNKNOWN";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(str_buffer, str_buffer_size, "Label: %s\r\n", volume_label);
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
|
|
|
|
snprintf(str_buffer, str_buffer_size, "%s, S/N: %lu\r\n", fs_type, serial_num);
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
|
|
|
|
snprintf(str_buffer, str_buffer_size, "Cluster: %d sectors\r\n", fs->csize);
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
|
|
|
|
snprintf(str_buffer, str_buffer_size, "Sector: %d bytes\r\n", sector_size);
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
|
|
|
|
snprintf(
|
|
|
|
str_buffer, str_buffer_size, "%lu KB total\r\n", total_sectors / 1024 * sector_size);
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
|
|
|
|
snprintf(
|
|
|
|
str_buffer, str_buffer_size, "%lu KB free\r\n", free_sectors / 1024 * sector_size);
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
} else {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("SD status error: ");
|
2021-01-13 21:23:34 +00:00
|
|
|
snprintf(
|
|
|
|
str_buffer,
|
|
|
|
str_buffer_size,
|
|
|
|
"%s\r\n",
|
|
|
|
fs_error_get_internal_desc(_fs_status(&sd_app->info)));
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("Label error: ");
|
2021-01-13 21:23:34 +00:00
|
|
|
snprintf(
|
|
|
|
str_buffer, str_buffer_size, "%s\r\n", fs_error_get_internal_desc(get_label_result));
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("Get free error: ");
|
2021-01-13 21:23:34 +00:00
|
|
|
snprintf(
|
|
|
|
str_buffer, str_buffer_size, "%s\r\n", fs_error_get_internal_desc(get_free_result));
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(str_buffer);
|
2021-01-13 21:23:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-12 17:24:34 +00:00
|
|
|
int32_t sd_filesystem(void* p) {
|
2021-01-11 14:52:35 +00:00
|
|
|
SdApp* sd_app = sd_app_alloc();
|
|
|
|
FS_Api* fs_api = fs_api_alloc();
|
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
Gui* gui = furi_record_open("gui");
|
|
|
|
Cli* cli = furi_record_open("cli");
|
|
|
|
ValueMutex* menu_vm = furi_record_open("menu");
|
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
gui_add_view_port(gui, sd_app->view_port, GuiLayerFullscreen);
|
|
|
|
gui_add_view_port(gui, sd_app->icon.view_port, GuiLayerStatusBarLeft);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
cli_add_command(cli, "sd_status", cli_sd_status, sd_app);
|
|
|
|
cli_add_command(cli, "sd_format", cli_sd_format, sd_app);
|
|
|
|
cli_add_command(cli, "sd_info", cli_sd_info, sd_app);
|
2021-01-13 21:23:34 +00:00
|
|
|
|
2021-01-11 14:52:35 +00:00
|
|
|
// add api record
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
furi_record_create("sdcard", fs_api);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
|
|
|
// init menu
|
|
|
|
// TODO menu icon
|
|
|
|
MenuItem* menu_item;
|
|
|
|
menu_item = menu_item_alloc_menu("SD Card", assets_icons_get(I_SDcardMounted_11x8));
|
|
|
|
|
|
|
|
menu_item_subitem_add(
|
|
|
|
menu_item, menu_item_alloc_function("Info", NULL, app_sd_info_callback, sd_app));
|
|
|
|
menu_item_subitem_add(
|
|
|
|
menu_item, menu_item_alloc_function("Format", NULL, app_sd_format_callback, sd_app));
|
|
|
|
menu_item_subitem_add(
|
|
|
|
menu_item, menu_item_alloc_function("Eject", NULL, app_sd_eject_callback, sd_app));
|
|
|
|
|
|
|
|
// add item to menu
|
|
|
|
furi_check(menu_vm);
|
|
|
|
with_value_mutex(
|
|
|
|
menu_vm, (Menu * menu) { menu_item_add(menu, menu_item); });
|
|
|
|
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("[sd_filesystem] start\r\n");
|
2021-01-11 14:52:35 +00:00
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
// add api record
|
|
|
|
furi_record_create("sdcard", fs_api);
|
|
|
|
|
2021-01-11 14:52:35 +00:00
|
|
|
// sd card cycle
|
|
|
|
bool sd_was_present = true;
|
|
|
|
|
2021-03-09 11:53:33 +00:00
|
|
|
// init detect pins
|
|
|
|
hal_sd_detect_init();
|
|
|
|
|
2021-01-11 14:52:35 +00:00
|
|
|
while(true) {
|
|
|
|
if(sd_was_present) {
|
2021-03-09 11:53:33 +00:00
|
|
|
if(hal_sd_detect()) {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("[sd_filesystem] card detected\r\n");
|
2021-03-09 11:53:33 +00:00
|
|
|
app_sd_mount_card(sd_app);
|
2021-01-11 14:52:35 +00:00
|
|
|
|
2021-03-09 11:53:33 +00:00
|
|
|
if(sd_app->info.status != SD_OK) {
|
|
|
|
printf(
|
|
|
|
"[sd_filesystem] sd init error: %s\r\n",
|
|
|
|
fs_error_get_internal_desc(sd_app->info.status));
|
|
|
|
app_sd_notify_error();
|
2021-01-11 14:52:35 +00:00
|
|
|
} else {
|
2021-03-09 11:53:33 +00:00
|
|
|
printf("[sd_filesystem] sd init ok\r\n");
|
|
|
|
app_sd_notify_success();
|
2021-01-11 14:52:35 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->icon.view_port, true);
|
2021-01-11 14:52:35 +00:00
|
|
|
sd_was_present = false;
|
2021-03-09 11:53:33 +00:00
|
|
|
|
|
|
|
if(!hal_sd_detect()) {
|
|
|
|
printf("[sd_filesystem] card removed\r\n");
|
|
|
|
|
|
|
|
view_port_enabled_set(sd_app->icon.view_port, false);
|
|
|
|
app_sd_unmount_card(sd_app);
|
|
|
|
sd_was_present = true;
|
|
|
|
}
|
2021-01-11 14:52:35 +00:00
|
|
|
}
|
|
|
|
} else {
|
2021-03-09 11:53:33 +00:00
|
|
|
if(!hal_sd_detect()) {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("[sd_filesystem] card removed\r\n");
|
2021-01-11 14:52:35 +00:00
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_enabled_set(sd_app->icon.view_port, false);
|
2021-01-11 14:52:35 +00:00
|
|
|
app_sd_unmount_card(sd_app);
|
|
|
|
sd_was_present = true;
|
2021-03-09 11:53:33 +00:00
|
|
|
app_sd_notify_eject();
|
2021-01-11 14:52:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delay(1000);
|
|
|
|
}
|
2021-02-12 17:24:34 +00:00
|
|
|
|
|
|
|
return 0;
|
2021-01-11 14:52:35 +00:00
|
|
|
}
|