mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 20:54:32 +02:00
Merge branch 'bugfix/clang_compatibility' into 'master'
clang compatibility fixes See merge request idf/esp-idf!3912
This commit is contained in:
@@ -31,6 +31,13 @@ typedef enum {
|
|||||||
SS_QUOTED_ARG_ESCAPED = SS_QUOTED_ARG | SS_FLAG_ESCAPE,
|
SS_QUOTED_ARG_ESCAPED = SS_QUOTED_ARG | SS_FLAG_ESCAPE,
|
||||||
} split_state_t;
|
} split_state_t;
|
||||||
|
|
||||||
|
/* helper macro, called when done with an argument */
|
||||||
|
#define END_ARG() do { \
|
||||||
|
char_out = 0; \
|
||||||
|
argv[argc++] = next_arg_start; \
|
||||||
|
state = SS_SPACE; \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
||||||
{
|
{
|
||||||
const int QUOTE = '"';
|
const int QUOTE = '"';
|
||||||
@@ -47,13 +54,6 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
|||||||
}
|
}
|
||||||
int char_out = -1;
|
int char_out = -1;
|
||||||
|
|
||||||
/* helper function, called when done with an argument */
|
|
||||||
void end_arg() {
|
|
||||||
char_out = 0;
|
|
||||||
argv[argc++] = next_arg_start;
|
|
||||||
state = SS_SPACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SS_SPACE:
|
case SS_SPACE:
|
||||||
if (char_in == SPACE) {
|
if (char_in == SPACE) {
|
||||||
@@ -73,7 +73,7 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
|||||||
|
|
||||||
case SS_QUOTED_ARG:
|
case SS_QUOTED_ARG:
|
||||||
if (char_in == QUOTE) {
|
if (char_in == QUOTE) {
|
||||||
end_arg();
|
END_ARG();
|
||||||
} else if (char_in == ESCAPE) {
|
} else if (char_in == ESCAPE) {
|
||||||
state = SS_QUOTED_ARG_ESCAPED;
|
state = SS_QUOTED_ARG_ESCAPED;
|
||||||
} else {
|
} else {
|
||||||
@@ -93,7 +93,7 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
|||||||
|
|
||||||
case SS_ARG:
|
case SS_ARG:
|
||||||
if (char_in == SPACE) {
|
if (char_in == SPACE) {
|
||||||
end_arg();
|
END_ARG();
|
||||||
} else if (char_in == ESCAPE) {
|
} else if (char_in == ESCAPE) {
|
||||||
state = SS_ARG_ESCAPED;
|
state = SS_ARG_ESCAPED;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -271,11 +271,14 @@ inline static uint32_t get_ccount(void)
|
|||||||
return ccount;
|
return ccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Caller is 2 stack frames deeper than we care about
|
||||||
|
#define STACK_OFFSET 2
|
||||||
|
|
||||||
#define TEST_STACK(N) do { \
|
#define TEST_STACK(N) do { \
|
||||||
if (STACK_DEPTH == N) { \
|
if (STACK_DEPTH == N) { \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
callers[N] = __builtin_return_address(N+offset); \
|
callers[N] = __builtin_return_address(N+STACK_OFFSET); \
|
||||||
if (!esp_ptr_executable(callers[N])) { \
|
if (!esp_ptr_executable(callers[N])) { \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
@@ -288,7 +291,6 @@ inline static uint32_t get_ccount(void)
|
|||||||
*/
|
*/
|
||||||
static IRAM_ATTR __attribute__((noinline)) void get_call_stack(void **callers)
|
static IRAM_ATTR __attribute__((noinline)) void get_call_stack(void **callers)
|
||||||
{
|
{
|
||||||
const int offset = 2; // Caller is 2 stack frames deeper than we care about
|
|
||||||
bzero(callers, sizeof(void *) * STACK_DEPTH);
|
bzero(callers, sizeof(void *) * STACK_DEPTH);
|
||||||
TEST_STACK(0);
|
TEST_STACK(0);
|
||||||
TEST_STACK(1);
|
TEST_STACK(1);
|
||||||
|
@@ -58,6 +58,27 @@ typedef struct {
|
|||||||
.unused = 0, \
|
.unused = 0, \
|
||||||
.type = RELOC_TYPE_BRANCH }
|
.type = RELOC_TYPE_BRANCH }
|
||||||
|
|
||||||
|
/* Comparison function used to sort the relocations array */
|
||||||
|
static int reloc_sort_func(const void* p_lhs, const void* p_rhs)
|
||||||
|
{
|
||||||
|
const reloc_info_t lhs = *(const reloc_info_t*) p_lhs;
|
||||||
|
const reloc_info_t rhs = *(const reloc_info_t*) p_rhs;
|
||||||
|
if (lhs.label < rhs.label) {
|
||||||
|
return -1;
|
||||||
|
} else if (lhs.label > rhs.label) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
// label numbers are equal
|
||||||
|
if (lhs.type < rhs.type) {
|
||||||
|
return -1;
|
||||||
|
} else if (lhs.type > rhs.type) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// both label number and type are equal
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Processing branch and label macros involves four steps:
|
/* Processing branch and label macros involves four steps:
|
||||||
*
|
*
|
||||||
@@ -203,24 +224,6 @@ esp_err_t ulp_process_macros_and_load(uint32_t load_addr, const ulp_insn_t* prog
|
|||||||
}
|
}
|
||||||
|
|
||||||
// step 3: sort relocations array
|
// step 3: sort relocations array
|
||||||
int reloc_sort_func(const void* p_lhs, const void* p_rhs) {
|
|
||||||
const reloc_info_t lhs = *(const reloc_info_t*) p_lhs;
|
|
||||||
const reloc_info_t rhs = *(const reloc_info_t*) p_rhs;
|
|
||||||
if (lhs.label < rhs.label) {
|
|
||||||
return -1;
|
|
||||||
} else if (lhs.label > rhs.label) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
// label numbers are equal
|
|
||||||
if (lhs.type < rhs.type) {
|
|
||||||
return -1;
|
|
||||||
} else if (lhs.type > rhs.type) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// both label number and type are equal
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
qsort(reloc_info, macro_count, sizeof(reloc_info_t),
|
qsort(reloc_info, macro_count, sizeof(reloc_info_t),
|
||||||
reloc_sort_func);
|
reloc_sort_func);
|
||||||
|
|
||||||
|
@@ -37,7 +37,6 @@ static void register_version();
|
|||||||
static void register_restart();
|
static void register_restart();
|
||||||
static void register_deep_sleep();
|
static void register_deep_sleep();
|
||||||
static void register_light_sleep();
|
static void register_light_sleep();
|
||||||
static void register_make();
|
|
||||||
#if WITH_TASKS_INFO
|
#if WITH_TASKS_INFO
|
||||||
static void register_tasks();
|
static void register_tasks();
|
||||||
#endif
|
#endif
|
||||||
@@ -50,7 +49,6 @@ void register_system()
|
|||||||
register_restart();
|
register_restart();
|
||||||
register_deep_sleep();
|
register_deep_sleep();
|
||||||
register_light_sleep();
|
register_light_sleep();
|
||||||
register_make();
|
|
||||||
#if WITH_TASKS_INFO
|
#if WITH_TASKS_INFO
|
||||||
register_tasks();
|
register_tasks();
|
||||||
#endif
|
#endif
|
||||||
@@ -342,108 +340,3 @@ static void register_light_sleep()
|
|||||||
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
|
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This command helps maintain sanity when testing console example from a console */
|
|
||||||
|
|
||||||
static int make(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int count = REG_READ(RTC_CNTL_STORE0_REG);
|
|
||||||
if (++count >= 3) {
|
|
||||||
printf("This is not the console you are looking for.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
REG_WRITE(RTC_CNTL_STORE0_REG, count);
|
|
||||||
|
|
||||||
const char *make_output =
|
|
||||||
R"(LD build/console.elf
|
|
||||||
esptool.py v2.1-beta1
|
|
||||||
)";
|
|
||||||
|
|
||||||
const char* flash_output[] = {
|
|
||||||
R"(Flashing binaries to serial port (*) (app at offset 0x10000)...
|
|
||||||
esptool.py v2.1-beta1
|
|
||||||
Connecting....
|
|
||||||
)",
|
|
||||||
R"(Chip is ESP32D0WDQ6 (revision 0)
|
|
||||||
Uploading stub...
|
|
||||||
Running stub...
|
|
||||||
Stub running...
|
|
||||||
Changing baud rate to 921600
|
|
||||||
Changed.
|
|
||||||
Configuring flash size...
|
|
||||||
Auto-detected Flash size: 4MB
|
|
||||||
Flash params set to 0x0220
|
|
||||||
Compressed 15712 bytes to 9345...
|
|
||||||
)",
|
|
||||||
R"(Wrote 15712 bytes (9345 compressed) at 0x00001000 in 0.1 seconds (effective 1126.9 kbit/s)...
|
|
||||||
Hash of data verified.
|
|
||||||
Compressed 333776 bytes to 197830...
|
|
||||||
)",
|
|
||||||
R"(Wrote 333776 bytes (197830 compressed) at 0x00010000 in 3.3 seconds (effective 810.3 kbit/s)...
|
|
||||||
Hash of data verified.
|
|
||||||
Compressed 3072 bytes to 82...
|
|
||||||
)",
|
|
||||||
R"(Wrote 3072 bytes (82 compressed) at 0x00008000 in 0.0 seconds (effective 1588.4 kbit/s)...
|
|
||||||
Hash of data verified.
|
|
||||||
Leaving...
|
|
||||||
Hard resetting...
|
|
||||||
)"
|
|
||||||
};
|
|
||||||
|
|
||||||
const char* monitor_output =
|
|
||||||
R"(MONITOR
|
|
||||||
)" LOG_COLOR_W R"(--- idf_monitor on (*) 115200 ---
|
|
||||||
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --
|
|
||||||
)" LOG_RESET_COLOR;
|
|
||||||
|
|
||||||
bool need_make = false;
|
|
||||||
bool need_flash = false;
|
|
||||||
bool need_monitor = false;
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
|
||||||
if (strcmp(argv[i], "all") == 0) {
|
|
||||||
need_make = true;
|
|
||||||
} else if (strcmp(argv[i], "flash") == 0) {
|
|
||||||
need_make = true;
|
|
||||||
need_flash = true;
|
|
||||||
} else if (strcmp(argv[i], "monitor") == 0) {
|
|
||||||
need_monitor = true;
|
|
||||||
} else if (argv[i][0] == '-') {
|
|
||||||
/* probably -j option */
|
|
||||||
} else if (isdigit((int) argv[i][0])) {
|
|
||||||
/* might be an argument to -j */
|
|
||||||
} else {
|
|
||||||
printf("make: *** No rule to make target `%s'. Stop.\n", argv[i]);
|
|
||||||
/* Technically this is an error, but let's not spoil the output */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (argc == 1) {
|
|
||||||
need_make = true;
|
|
||||||
}
|
|
||||||
if (need_make) {
|
|
||||||
printf("%s", make_output);
|
|
||||||
}
|
|
||||||
if (need_flash) {
|
|
||||||
size_t n_items = sizeof(flash_output) / sizeof(flash_output[0]);
|
|
||||||
for (int i = 0; i < n_items; ++i) {
|
|
||||||
printf("%s", flash_output[i]);
|
|
||||||
vTaskDelay(200/portTICK_PERIOD_MS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (need_monitor) {
|
|
||||||
printf("%s", monitor_output);
|
|
||||||
esp_restart();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void register_make()
|
|
||||||
{
|
|
||||||
const esp_console_cmd_t cmd = {
|
|
||||||
.command = "make",
|
|
||||||
.help = NULL, /* hide from 'help' output */
|
|
||||||
.hint = "all | flash | monitor",
|
|
||||||
.func = &make,
|
|
||||||
};
|
|
||||||
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user