Skip to content
Snippets Groups Projects
Commit ccee4481 authored by q3k's avatar q3k
Browse files

sdkconfig: use UART/JTAG console instead of USB OTG, document

parent d277de88
No related branches found
No related tags found
No related merge requests found
...@@ -84,22 +84,72 @@ $ make clean ...@@ -84,22 +84,72 @@ $ make clean
``` ```
3. access micropython repl: 3. access micropython repl:
``` ```
$ picocom -b 115200 /dev/ttyACM0 $ picocom -b 115200 /dev/ttyACM0
$ # OR
# screen /dev/ttyACM0
``` ```
## how to modify ## how to modify
### general info ### general info
global + micropython entry point: app_main() in micropython/ports/esp32/main.c (includes badge23/espan.h) global + micropython entry point: app_main() in micropython/ports/esp32/main.c (includes badge23/espan.h)
c entry point, called by^: os_app_main() in badge23/espan.c c entry point, called by^: os_app_main() in badge23/espan.c
register new c files for compilation: add to set(BADGE23_LIB) in micropython/ports/esp32/main/CMakelists.txt register new c files for compilation: add to set(BADGE23_LIB) in micropython/ports/esp32/main/CMakelists.txt
change output volume in the set_global_vol_dB(int8_t) call; -90 for mute change output volume in the set_global_vol_dB(int8_t) call; -90 for mute
to debug c files: printf broken atm, instead use: ### Debugging
#include "../../py/mphal.h"
mp_hal_stdout_tx_str("debug output: string literal here\n\r"); The badge is currently configured to run in HW USB UART/JTAG mode (vs. using TinyUSB and 'software' CDC/whatever using the generic OTG peripheral).
What this means:
1. You can use the MicroPython REPL over a USB console,
2. The MicroPython REPL will also print ESP-IDF logs, including panics,
3. You can use OpenOCD/GDB.
#### printf() debugging and logging in C-land
Given the above, you can do the following to get a log. This is part of ESP-IDF's standard logging functionality.
```
static const char *TAG = "misery";
// ...
ESP_LOGI(TAG, "i love C");
```
However, this will **only work** if you modify `micropython/ports/esp32/boards/sdkconfig.base` to set `CONFIG_LOG_DEFAULT_LEVEL_INFO=y` (which will likely break programs interacting with micropython REPL as many components of the ESP-IDF will suddenly become very chatty). But that's fine for troubleshooting some C-land bugs.
If you want to only log errors or just add temporary logs, use `ESP_LOGE` instead, which will always print to the USB console.
`printf()` also just works. But it should only be used for development debugging, for long-term logging statements please use `ESP_LOG*` instead.
#### Running OpenOCD+GDB
don't expect esp component registry or idf.py menuconfig to work. First, make sure your badge is running in application mode (not bootloader mode! that will stay in bootloader mode).
tried adding config items manually to micropython/ports/esp32/boards/sdkconfig.badge23, doesn't work :/
just put them into header files manually ig;; ```
$ make -C micropython/ports/esp32 openocd
```
Then, in another terminal:
```
$ make -C micropython/ports/esp32 gdb
```
Good luck.
### ESP-IDF functionality
Micropython splits up sdkconfig into a bunch of small files. Unfortunately, that doesn't work well with ESP-IDFs menuconfig.
If you want to permanently toggle options, you'll have to do that by modifying `micropython/ports/esp32/boards/sdkconfig.badge23`, or another file referenced by `micropython/ports/esp32/GENERIC_S3_BADGE/mpconfigboard.cmake`. Keep in mind the usual Kconfig shenanigants: disabling an options requires removing its line (not setting it to 'n'!), and that some options might be enabled automatically by other options. After modifying files, you must `make clean` in micropython/ports/esp32. Bummer.
To verify whether your configuration is what you expect it to be, you can still run menuconfig on the effective/calculated sdkconfig that micropython assembles. You can even modify the settings which will affect the build, but will be lost on `make clean` (and on git push, of course). To do so, run:
```
$ make -C micropython/ports/esp32 menuconfig
```
\ No newline at end of file
...@@ -60,6 +60,18 @@ all: ...@@ -60,6 +60,18 @@ all:
$(BUILD)/bootloader/bootloader.bin $(BUILD)/partition_table/partition-table.bin $(BUILD)/micropython.bin: FORCE $(BUILD)/bootloader/bootloader.bin $(BUILD)/partition_table/partition-table.bin $(BUILD)/micropython.bin: FORCE
openocd:
OPENOCD_COMMANDS='-f board/esp32s3-builtin.cfg' idf.py $(IDFPY_FLAGS) -p $(PORT) -b $(BAUD) openocd
gdb:
OPENOCD_COMMANDS='-f board/esp32s3-builtin.cfg' idf.py $(IDFPY_FLAGS) -p $(PORT) -b $(BAUD) gdb
monitor:
idf.py $(IDFPY_FLAGS) -p $(PORT) -b $(BAUD) monitor
menuconfig:
idf.py $(IDFPY_FLAGS) menuconfig
clean: clean:
idf.py $(IDFPY_FLAGS) fullclean idf.py $(IDFPY_FLAGS) fullclean
......
...@@ -3,7 +3,6 @@ set(IDF_TARGET esp32s3) ...@@ -3,7 +3,6 @@ set(IDF_TARGET esp32s3)
set(SDKCONFIG_DEFAULTS set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base boards/sdkconfig.base
boards/sdkconfig.badge23 boards/sdkconfig.badge23
boards/sdkconfig.usb
boards/sdkconfig.ble boards/sdkconfig.ble
boards/GENERIC_S3/sdkconfig.board boards/GENERIC_S3/sdkconfig.board
) )
...@@ -75,3 +75,4 @@ CONFIG_SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER=3 ...@@ -75,3 +75,4 @@ CONFIG_SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER=3
CONFIG_SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP=3 CONFIG_SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP=3
CONFIG_SOC_MCPWM_SWSYNC_CAN_PROPAGATE=y CONFIG_SOC_MCPWM_SWSYNC_CAN_PROPAGATE=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment