Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FL-2630] Wireless UART #45

Merged
merged 29 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1a6d904
HTTP: websocket mockup
DrZlo13 Jul 23, 2023
ae62315
PSRAM: 2M, store some global objects there
DrZlo13 Jul 23, 2023
4e3760e
Web interface: UART console and refactoring
DrZlo13 Aug 9, 2023
69b622f
Simple-UART: get config
DrZlo13 Aug 9, 2023
ab10f0b
Network: websocket for web uart
DrZlo13 Aug 9, 2023
deba0ed
Web interface: UART history, receive indicator
DrZlo13 Aug 10, 2023
8861ae4
Build: artifacts
DrZlo13 Aug 10, 2023
e640b27
Web interface: UART config
DrZlo13 Aug 14, 2023
559a35c
Simple UART: proxy config
DrZlo13 Sep 18, 2023
df9146e
Web interface: cleanup API and fix README
DrZlo13 Sep 18, 2023
106887d
software uart logs: more precise timings
DrZlo13 Sep 22, 2023
81f11dd
software uart logs: enlarge buffer
DrZlo13 Sep 22, 2023
cdc8234
uart: network socket
DrZlo13 Sep 22, 2023
871e770
app: network uart
DrZlo13 Sep 22, 2023
9a92f81
Web interface: UART send
DrZlo13 Sep 22, 2023
c82d0ac
Web interface: update dependencies
DrZlo13 Sep 22, 2023
e9ed890
UART Rx: 1Mb stream buffer
DrZlo13 Sep 22, 2023
fee376b
HTTP Server: cleanup websocket fns
DrZlo13 Sep 22, 2023
d0b0031
Web interface: smart nbsp in terminal
DrZlo13 Sep 22, 2023
ab94351
Web interface: add keypress to non-interactive elements with on:click
DrZlo13 Sep 22, 2023
9402883
bundle
DrZlo13 Sep 22, 2023
03b806d
Web interface: fix first nbsp on line
DrZlo13 Sep 22, 2023
f7bf907
Web interface: firmware version
DrZlo13 Sep 22, 2023
cd345b8
Attempts to fix build: 1
DrZlo13 Sep 22, 2023
bd0da7b
Merge branch 'dev' into zlo/2630-logs-over-wifi
DrZlo13 Sep 25, 2023
f0e67c1
Attempts to fix build: 2
DrZlo13 Sep 25, 2023
bb15c54
Attempts to fix build: 3
DrZlo13 Sep 25, 2023
1691aca
Web interface: mobile friendly uart terminal
DrZlo13 Sep 25, 2023
15c25c0
Web interface: mobile friendly input
DrZlo13 Sep 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Black Magic Probe for ESP32-S2
# Black Magic Probe / DapLink for ESP32-S2

WiFi/USB capable version of the famous Black Magic Probe debugger.
WiFi/USB capable version of the famous BlackMagicProbe (or DapLink) debugger.

# Clone the Repository

Expand Down Expand Up @@ -32,22 +32,26 @@ Run:
idf.py -p <port> flash
```

## Test with ESP-IDF

Connect to the dev board with:
```shell
idf.py -p <port> monitor
```

You should not see errors in the logs if the firmware is installed and running correctly.

## Web interface development

Web interface is located in `components/svelte-portal` and written in Svelte. To build it, you need to install Node.js and run `npm install` in `components/svelte-portal` directory. Then you can run `npm run dev` to start development server or `npm run build` to build production version.

Typical workflow is to fix the board's IP address in `components/svelte-portal/src/App.svelte` and then run `npm run dev`. After that, you can open `http://localhost:5000` in your browser and see changes in the web interface in real time with live reload.
Typical workflow is to fix the board's IP address in `components/svelte-portal/src/lib/Api.svelte` and then run `npm run dev`. After that, you can open `http://localhost:5000` in your browser and see changes in the web interface in real time with live reload.

If you want to change local ip or port, you need to run `export HOST={ip} PORT={port}` before `npm run dev`.

```shell
export HOST=127.0.0.1 PORT=3000
npm run dev
```

When you're done, you need to run `npm run build`, `idf.py build` and then `idf.py -p <port> flash`. You can then open `http://blackmagic.local` in your browser and see the changes in the web interface.
```shell
npm run build
idf.py build
idf.py -p <port> flash
```


## Schematic

Expand Down
32 changes: 32 additions & 0 deletions components/simple-uart/simple-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ typedef struct {
uart_isr rx_isr;
} uart_context_t;

typedef struct {
uint32_t baud_rate;
uart_stop_bits_t stop_bits;
uart_parity_t parity;
uart_word_length_t data_bits;
} UartInnerConfig;

#define UART_CONTEX_INIT_DEF(uart_num) \
{ \
.hal.dev = UART_LL_GET_HW(uart_num), .uart_index = uart_num, .isr_context = NULL, \
Expand All @@ -31,6 +38,11 @@ static uart_context_t uart_context[UART_NUM_MAX] = {
#endif
};

static UartInnerConfig uart_config[UART_NUM_MAX] = {
{0},
{0},
};

#define UART_HAL(uart_num) &(uart_context[uart_num].hal)

/***********************************************/
Expand Down Expand Up @@ -173,17 +185,37 @@ static void simple_uart_isr(void* arg) {
}

void simple_uart_set_baud_rate(uint8_t uart_num, uint32_t baud_rate) {
uart_config[uart_num].baud_rate = baud_rate;
uart_hal_set_baudrate(UART_HAL(uart_num), baud_rate);
}

void simple_uart_set_stop_bits(uint8_t uart_num, uart_stop_bits_t stop_bits) {
uart_config[uart_num].stop_bits = stop_bits;
uart_hal_set_stop_bits(UART_HAL(uart_num), stop_bits);
}

void simple_uart_set_parity(uint8_t uart_num, uart_parity_t parity) {
uart_config[uart_num].parity = parity;
uart_hal_set_parity(UART_HAL(uart_num), parity);
}

void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits) {
uart_config[uart_num].data_bits = data_bits;
uart_hal_set_data_bit_num(UART_HAL(uart_num), data_bits);
}

uint32_t simple_uart_get_baud_rate(uint8_t uart_num) {
return uart_config[uart_num].baud_rate;
}

uart_stop_bits_t simple_uart_get_stop_bits(uint8_t uart_num) {
return uart_config[uart_num].stop_bits;
}

uart_parity_t simple_uart_get_parity(uint8_t uart_num) {
return uart_config[uart_num].parity;
}

uart_word_length_t simple_uart_get_data_bits(uint8_t uart_num) {
return uart_config[uart_num].data_bits;
}
34 changes: 33 additions & 1 deletion components/simple-uart/simple-uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,36 @@ void simple_uart_set_parity(uint8_t uart_num, uart_parity_t parity);
* @param uart_num
* @param data_bits
*/
void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits);
void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits);

/**
* @brief Get the UART baud rate
*
* @param uart_num
* @return uint32_t
*/
uint32_t simple_uart_get_baud_rate(uint8_t uart_num);

/**
* @brief Get the UART stop bits
*
* @param uart_num
* @return uart_stop_bits_t
*/
uart_stop_bits_t simple_uart_get_stop_bits(uint8_t uart_num);

/**
* @brief Get the UART parity
*
* @param uart_num
* @return uart_parity_t
*/
uart_parity_t simple_uart_get_parity(uint8_t uart_num);

/**
* @brief Get the UART data bits
*
* @param uart_num
* @return uart_word_length_t
*/
uart_word_length_t simple_uart_get_data_bits(uint8_t uart_num);
2 changes: 1 addition & 1 deletion components/soft-uart/soft-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct SoftUart {
#define wait_cycles(cycles) \
for(uint32_t start = cycle_count_get(); cycle_count_get() - start < cycles;)

static uint32_t cycle_count_get() {
static inline uint32_t __attribute__((always_inline)) cycle_count_get() {
uint32_t ccount;
__asm__ __volatile__("esync; rsr %0,ccount" : "=a"(ccount));
return ccount;
Expand Down
Loading