Skip to content

Commit

Permalink
[FL-2630] Wireless UART (#45)
Browse files Browse the repository at this point in the history
* HTTP: websocket mockup
* PSRAM: 2M, store some global objects there
* Web interface: UART console and refactoring
* Simple-UART: get config
* Network: websocket for web uart
* Web interface: UART history, receive indicator
* Build: artifacts
* Web interface: UART config
* Simple UART: proxy config
* Web interface: cleanup API and fix README
* software uart logs: more precise timings
* software uart logs: enlarge buffer
* uart: network socket
* app: network uart
* Web interface: UART send
* Web interface: update dependencies
* UART Rx: 1Mb stream buffer
* HTTP Server: cleanup websocket fns
* Web interface: smart nbsp in terminal
* Web interface: add keypress to non-interactive elements with on:click
* bundle
* Web interface: fix first nbsp on line
* Web interface: firmware version
* Attempts to fix build: 1
* Attempts to fix build: 2
* Attempts to fix build: 3
* Web interface: mobile friendly uart terminal
* Web interface: mobile friendly input
  • Loading branch information
DrZlo13 authored Sep 26, 2023
1 parent 41acbe3 commit 9447ee9
Show file tree
Hide file tree
Showing 41 changed files with 2,099 additions and 521 deletions.
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

0 comments on commit 9447ee9

Please sign in to comment.