Thank you tremendously, I've finally gotten some time to sit down and try this and it seems your advice has helped me gain some progress.
So, with this code below, I am able to connect both my rx and tx lines together and then connect them into an active connection from jtag2updi and snoop it's updi commands being sent while it programs an attiny. This is a step up from only being able to connect the rx line without causing (what I assume was) line contention.
I am also able to send messages on my tx line and immediately read them back on my rx line, so I feel like everything should be working...
Alas, even when I send the same commands as jtag2updi I'm apparently still not getting any response from my attiny, and of course it's hard to tell whether the problem lay in the uart setup or some detail of the updi protocol.
Code: Select all
// UART configuration
uart_config_t uart_config = {
.baud_rate = UPDI_BAUD,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_EVEN,
.stop_bits = UART_STOP_BITS_2,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_APB,
};
// Configure UART parameters
uart_param_config(UPDI_UART_NUM, &uart_config);
// Set UART pins
uart_set_pin(UPDI_UART_NUM, UPDI_RX_PIN, UPDI_TX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
// Install UART driver
uart_driver_install(UPDI_UART_NUM, 1024 * 2, 0, 0, NULL, 0);
// Set UART read timeout
uart_set_rx_timeout(UPDI_UART_NUM, 50);
const gpio_config_t pin_cfg {
.pin_bit_mask = (1ul << GPIO_NUM_8) | (1ul << GPIO_NUM_2),
.mode = GPIO_MODE_INPUT_OUTPUT_OD, // Input and Output w/ open-drain!
.pull_up_en = GPIO_PULLUP_ENABLE, // Open-drain requires a pull-up.
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE
};
gpio_config(&pin_cfg);
esp_rom_gpio_connect_out_signal(UPDI_TX_PIN, UART_PERIPH_SIGNAL(UPDI_UART_NUM, SOC_UART_TX_PIN_IDX), false, false);
esp_rom_gpio_connect_in_signal(UPDI_RX_PIN, UART_PERIPH_SIGNAL(UPDI_UART_NUM, SOC_UART_RX_PIN_IDX), false);
I'm assuming that at this point there's probably not much more you can do to help me, and we are probably going outside the scope of this thread. But if you do happen to have any more insight it would be greatly appreciated.
I have another thread here discussing tx/rx on the same line, although what we're doing here is effectively good enough if I can just connect two lines together.
https://esp32.com/posting.php?mode=reply&f=13&t=40073