ESP-Prog sdcard issues

dizcza
Posts: 55
Joined: Tue Sep 07, 2021 6:59 pm

ESP-Prog sdcard issues

Postby dizcza » Mon Nov 14, 2022 2:23 pm

I have an ESP-Prog attached to a TTGO T8 ESP32 board (JTAG interface only). As soon as I initialize the sd card, I cannot debug the app.

Here are the logs that works (NO SD CARD):

Code: Select all

$ openocd -f interface/ftdi/esp32_devkitj_v1.cfg -f target/esp32.cfg
Open On-Chip Debugger v0.11.0-esp32-20221026 (2022-10-26-14:47)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x4008C192, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (1) - (Power on reset)
Info : [esp32.cpu1] Target halted, PC=0x4008C192, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
I also tried

Code: Select all

$ openocd -f board/esp32-wrover-kit-3.3v.cfg
- same story.

Then I add

Code: Select all

sdcard_mount_mmc();
in the main function, recompile and flash via USB, and see the following openocd logs:

Code: Select all

Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x4000942F, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (1) - (Power on reset)
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x40064AE0, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (1) - (Power on reset)
Error: [esp32.cpu1] Unexpected OCD_ID = 00000000
Error: [esp32.cpu1] Unexpected OCD_ID = 00000000
Error: [esp32.cpu1] Unexpected OCD_ID = 00000000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0x40008547, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Error: [esp32.cpu0] DSR (FFFFFFFF) indicates target still busy!
Error: [esp32.cpu0] DSR (FFFFFFFF) indicates DIR instruction generated an exception!
Error: [esp32.cpu0] DSR (FFFFFFFF) indicates DIR instruction generated an overrun!
Info : [esp32.cpu0] Target halted, PC=0xFFFFFFFF, debug_reason=00000000
Error: [esp32.cpu1] Unexpected OCD_ID = ffffffff
Info : Set GDB target to 'esp32.cpu0'
Info : [esp32.cpu0] Disabling LDDR32.P/SDDR32.P
Info : [esp32.cpu0] Disabling LDDR32.P/SDDR32.P
Warn : [esp32.cpu0] Failed writing 4 bytes at address 0x3ff5f048
Error: Failed to write ESP32_TIMG0WDT_CFG0 (-4)!
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x00000000, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (63) - (Unknown reset cause)
Error: [esp32.cpu1] Unexpected OCD_ID = 00000000
Info : [esp32.cpu0] Disabling LDDR32.P/SDDR32.P
Warn : [esp32.cpu0] Failed writing 4 bytes at address 0x3ff5f048
Error: Failed to write ESP32_TIMG0WDT_CFG0 (-4)!
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Error: [esp32.cpu0] Timed out waiting for CPU to be reset, target state=0
Error: [esp32.cpu0] Failed to wait for target halt to read reset cause (0)!
Polling target esp32.cpu0 failed, trying to reexamine
Error: [esp32.cpu0] Unexpected OCD_ID = 00000000
Examination failed, GDB will be halted. Polling again in 100ms
Polling target esp32.cpu0 failed, trying to reexamine
Error: [esp32.cpu0] Unexpected OCD_ID = 00000000
Examination failed, GDB will be halted. Polling again in 100ms
Polling target esp32.cpu0 failed, trying to reexamine
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Error: [esp32.cpu0] Timed out waiting for CPU to be reset, target state=1
Error: [esp32.cpu0] Failed to wait for target halt to read reset cause (0)!
Polling target esp32.cpu0 failed, trying to reexamine
Restarting the openocd does not help:

Code: Select all

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi tdo_sample_edge falling"
Info : clock speed 20000 kHz
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: esp32.cpu0: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: [esp32.cpu0] Unexpected OCD_ID = 00000000
Warn : target esp32.cpu0 examination failed
Error: [esp32.cpu1] Unexpected OCD_ID = 00000000
Warn : target esp32.cpu1 examination failed
Info : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
I noticed an interesting behavior: when I do sdcard listing and try launching the openocd server at the same time, openocd logs are:

Code: Select all


Info : TAP esp32.cpu0 does not have valid IDCODE (idcode=0xf8000000)
Info : TAP esp32.cpu1 does not have valid IDCODE (idcode=0xfc000000)
Info : TAP auto0.tap does not have valid IDCODE (idcode=0xfe000000)
Info : TAP auto1.tap does not have valid IDCODE (idcode=0xff000000)
Info : TAP auto2.tap does not have valid IDCODE (idcode=0xff800000)
Info : TAP auto3.tap does not have valid IDCODE (idcode=0xffc00000)
Info : TAP auto4.tap does not have valid IDCODE (idcode=0xffe00000)
Info : TAP auto5.tap does not have valid IDCODE (idcode=0xfff00000)
Info : TAP auto6.tap does not have valid IDCODE (idcode=0xfff80000)
Info : TAP auto7.tap does not have valid IDCODE (idcode=0xfffc0000)
Info : TAP auto8.tap does not have valid IDCODE (idcode=0xfffe0000)
Info : TAP auto9.tap does not have valid IDCODE (idcode=0x7fff0000)
Info : TAP auto10.tap does not have valid IDCODE (idcode=0x3fff8000)
Info : TAP auto11.tap does not have valid IDCODE (idcode=0x1fffc000)
Info : TAP auto12.tap does not have valid IDCODE (idcode=0xfffe000)
Info : TAP auto13.tap does not have valid IDCODE (idcode=0x7fff000)
Info : TAP auto14.tap does not have valid IDCODE (idcode=0x3fff800)
Info : TAP auto15.tap does not have valid IDCODE (idcode=0x1fffc00)
Info : TAP auto16.tap does not have valid IDCODE (idcode=0xfffe00)
Info : TAP auto17.tap does not have valid IDCODE (idcode=0x7fff00)
Info : TAP auto18.tap does not have valid IDCODE (idcode=0x3fff80)
Warn : Unexpected idcode after end of chain: 21 0x001fffc0
Warn : Unexpected idcode after end of chain: 53 0x00000000
Warn : Unexpected idcode after end of chain: 85 0x00000000
Warn : Unexpected idcode after end of chain: 117 0x00000000
Warn : Unexpected idcode after end of chain: 149 0x00000000
Warn : Unexpected idcode after end of chain: 181 0x07fff800
Warn : Unexpected idcode after end of chain: 213 0x00000000
Warn : Unexpected idcode after end of chain: 245 0x00000000
Warn : Unexpected idcode after end of chain: 277 0x00000000
Warn : Unexpected idcode after end of chain: 309 0x00000000
Warn : Unexpected idcode after end of chain: 341 0xffff0000
Warn : Unexpected idcode after end of chain: 373 0x00000000
Warn : Unexpected idcode after end of chain: 405 0x00000000
Warn : Unexpected idcode after end of chain: 437 0x00000000
Warn : Unexpected idcode after end of chain: 469 0x00000000
Warn : Unexpected idcode after end of chain: 501 0xffe00000
Warn : Unexpected idcode after end of chain: 533 0x0000001f
Warn : Unexpected idcode after end of chain: 565 0x00000000
Warn : Unexpected idcode after end of chain: 597 0x00000000
Warn : Unexpected idcode after end of chain: 629 0x00000000
Tried both SD MMC and SPI interfaces. Same story. The function "sdcard_mount_mmc" itself:

Code: Select all


static void sdcard_mount_finish(esp_err_t err) {
    if (err == ESP_OK) {
        ESP_LOGI(TAG, "SD card mounted at %s", sdcard_mount_point);
        sdmmc_card_print_info(stdout, m_card);

        /* Print free memory size info */
        printf("Free: %lluMB\n", sdcard_get_free_bytes() / (1 << 20));
    } else {
        ESP_LOGW(TAG, "sdcard_mount failed (%s)",
                esp_err_to_name(err));
    }
}


/**
 * Initialize and mount the SD card with MMC interface
 *
 * @return err code
 */
esp_err_t sdcard_mount_mmc() {
    ESP_LOGI(TAG, "Mounting SD MMC...");

	esp_vfs_fat_sdmmc_mount_config_t mount_config = SDCARD_MOUNT_CONFIG_DEFAULT();

    sdmmc_host_t host = SDMMC_HOST_DEFAULT();
    host.max_freq_khz = SDMMC_FREQ_HIGHSPEED;

    // This initializes the slot without card detect (CD) and write protect (WP) signals.
    // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
    sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();

    // Use 1-line SD mode
    slot_config.width = 1;

    // Enable internal pullups on enabled pins. The internal pullups
    // are insufficient however, please make sure 10k external pullups are
    // connected on the bus. This is for debug / example purpose only.
    slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;

    esp_err_t err = esp_vfs_fat_sdmmc_mount(sdcard_mount_point, &host,
            &slot_config, &mount_config, &m_card);

    sdcard_mount_finish(err);

	return err;
}
Adding other blocks of code, I2C stuff, WiFI, etc. seem to have no effect on openocd (it does not get broken). Only SD card matters.

Any clues?

---------------

TTGO T8's internal SD card slot I'm using:

Image

dizcza
Posts: 55
Joined: Tue Sep 07, 2021 6:59 pm

Re: ESP-Prog sdcard issues

Postby dizcza » Mon Nov 14, 2022 3:03 pm

I should have looked at the schematics better. SD card pins reuse JTAG, that's the culprit.

And I think it's impossible to reuse JTAG pins in the app, is it?

Who is online

Users browsing this forum: Baidu [Spider] and 152 guests