Skip to content

Commit 8899340

Browse files
committed
main: fix jtag/swd interface variable type
1 parent 017da2f commit 8899340

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

main/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void run_openocd(void)
9494
int argc = 3;
9595

9696
char iface[32] = {0};
97-
sprintf(iface, "interface/esp_gpio_%s.cfg", g_app_params.interface == 0 ? "jtag" : "swd");
97+
sprintf(iface, "interface/esp_gpio_%s.cfg", g_app_params.interface == '0' ? "jtag" : "swd");
9898
argv[argc++] = "-f";
9999
argv[argc++] = iface;
100100

@@ -139,9 +139,9 @@ void load_openocd_params(void)
139139

140140
err = storage_read(OOCD_INTERFACE_KEY, &g_app_params.interface, 1);
141141
if (err != ESP_OK) {
142-
g_app_params.interface = CONFIG_OPENOCD_INTERFACE;
142+
g_app_params.interface = CONFIG_OPENOCD_INTERFACE + '0';
143143
}
144-
ui_update_interface_dropdown(g_app_params.interface);
144+
ui_update_interface_dropdown(g_app_params.interface - '0');
145145

146146
read_param = NULL;
147147
err = storage_alloc_and_read(OOCD_RTOS_TYPE_KEY, &read_param);
@@ -196,7 +196,7 @@ void load_openocd_params(void)
196196
ESP_LOGI(TAG, "rtos type (%s)", g_app_params.rtos_type);
197197
ESP_LOGI(TAG, "flash size (%s)", g_app_params.flash_size);
198198
ESP_LOGI(TAG, "dual core (%c)", g_app_params.dual_core);
199-
ESP_LOGI(TAG, "interface (%s)", g_app_params.interface == 0 ? "jtag" : "swd");
199+
ESP_LOGI(TAG, "interface (%s)", g_app_params.interface == '0' ? "jtag" : "swd");
200200
ESP_LOGI(TAG, "command arg (%s)", g_app_params.command_arg);
201201
ESP_LOGI(TAG, "debug_level (%c)", g_app_params.debug_level);
202202
}

main/network/web_server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ esp_err_t set_openocd_config_handler(httpd_req_t *req)
124124

125125
// Print the values
126126
ESP_LOGI(TAG, "Target: %s", target->valuestring);
127-
ESP_LOGI(TAG, "Interface: %s", interface->valueint == 0 ? "jtag" : "swd");
127+
ESP_LOGI(TAG, "Interface: %s", interface->valuestring[0] == '0' ? "jtag" : "swd");
128128
ESP_LOGI(TAG, "RTOS: %s", rtos->valuestring);
129129
ESP_LOGI(TAG, "Debug: %s", debug->valuestring);
130130
ESP_LOGI(TAG, "Dual Core: %s", dualCore->type == cJSON_True ? "true" : "false");
@@ -134,7 +134,7 @@ esp_err_t set_openocd_config_handler(httpd_req_t *req)
134134
storage_write(OOCD_CFG_FILE_KEY, target->valuestring, strlen(target->valuestring));
135135
storage_write(OOCD_CMD_LINE_ARGS_KEY, cParam->valuestring, strlen(cParam->valuestring));
136136
storage_write(OOCD_RTOS_TYPE_KEY, rtos->valuestring, strlen(rtos->valuestring));
137-
storage_write(OOCD_INTERFACE_KEY, (const char *)&interface->valueint, 1);
137+
storage_write(OOCD_INTERFACE_KEY, interface->valuestring, 1);
138138
storage_write(OOCD_DBG_LEVEL_KEY, debug->valuestring, 1);
139139

140140
if (dualCore->type == cJSON_True) {

main/ui_events.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ void ui_event_run_button(lv_event_t *e)
6868
/* save Interface type */
6969
selected_index = lv_dropdown_get_selected(g_ui_interface_dropdown);
7070
ESP_LOGI(TAG, "save selected interface: %s", selected_index == 0 ? "jtag" : "swd");
71-
storage_write(OOCD_INTERFACE_KEY, (const char *)&selected_index, 1);
71+
char interface = selected_index + '0';
72+
storage_write(OOCD_INTERFACE_KEY, &interface, 1);
7273

7374
/* save Flash Support */
7475
const char *flash_size = lv_obj_get_state(g_ui_flash_checkbox) & LV_STATE_CHECKED ? "auto" : "0";

0 commit comments

Comments
 (0)