lab2-4_single_msg_queue_interrupt
This commit is contained in:
parent
49d8d4269d
commit
7ddfd4a1aa
10
part3_freertos/lab2-1_single_msg_queue/.gitignore
vendored
Normal file
10
part3_freertos/lab2-1_single_msg_queue/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
# Configuration files
|
||||||
|
sdkconfig
|
||||||
|
sdkconfig.old
|
||||||
|
|
||||||
|
# Production folder
|
||||||
|
build/
|
||||||
|
|
||||||
|
# HTML documentation
|
||||||
|
html_doc/
|
||||||
6
part3_freertos/lab2-1_single_msg_queue/CMakeLists.txt
Normal file
6
part3_freertos/lab2-1_single_msg_queue/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# The following lines of boilerplate have to be in your project's
|
||||||
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(main)
|
||||||
2494
part3_freertos/lab2-1_single_msg_queue/Doxyfile
Normal file
2494
part3_freertos/lab2-1_single_msg_queue/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
3
part3_freertos/lab2-1_single_msg_queue/Makefile
Normal file
3
part3_freertos/lab2-1_single_msg_queue/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PROJECT_NAME := main
|
||||||
|
|
||||||
|
include $(IDF_PATH)/make/project.mk
|
||||||
22
part3_freertos/lab2-1_single_msg_queue/ftdi_ft2232.cfg
Normal file
22
part3_freertos/lab2-1_single_msg_queue/ftdi_ft2232.cfg
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
interface ftdi
|
||||||
|
ftdi_vid_pid 0x0403 0x6010
|
||||||
|
ftdi_layout_init 0x0038 0x003b
|
||||||
|
|
||||||
|
# The ESP32 only supports JTAG.
|
||||||
|
transport select jtag
|
||||||
|
|
||||||
|
# This can go as high as 20MHz if CPU frequency is 80MHz, or 26MHz
|
||||||
|
# if CPU frequency is 160MHz or 240MHz.
|
||||||
|
adapter_khz 20000
|
||||||
|
|
||||||
|
# If single core debugging is required, uncomment the following line
|
||||||
|
#set ESP32_ONLYCPU 1
|
||||||
|
|
||||||
|
# To disable RTOS support, uncomment the following line
|
||||||
|
# set ESP32_RTOS none
|
||||||
|
|
||||||
|
# This option defaults to 3.3v
|
||||||
|
set ESP32_FLASH_VOLTAGE 3.3
|
||||||
|
|
||||||
|
# Source the ESP32 configuration file
|
||||||
|
source [find target/esp32.cfg]
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(
|
||||||
|
SRC_DIRS "."
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
2
part3_freertos/lab2-1_single_msg_queue/main/component.mk
Normal file
2
part3_freertos/lab2-1_single_msg_queue/main/component.mk
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
COMPONENT_SRCDIRS := .
|
||||||
|
COMPONENT_ADD_INCLUDEDIRS := .
|
||||||
170
part3_freertos/lab2-1_single_msg_queue/main/main.c
Normal file
170
part3_freertos/lab2-1_single_msg_queue/main/main.c
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2020 by Fabrice Muller *
|
||||||
|
* *
|
||||||
|
* This file is useful for ESP32 Design course. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file lab1-2_main.c
|
||||||
|
* @author Fabrice Muller
|
||||||
|
* @date 12 Oct. 2020
|
||||||
|
* @brief File containing the lab1-2 of Part 3.
|
||||||
|
*
|
||||||
|
* @see https://github.com/fmuller-pns/esp32-vscode-project-template
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "soc/rtc_wdt.h"
|
||||||
|
|
||||||
|
/* FreeRTOS.org includes. */
|
||||||
|
#include "freertos/FreeRTOSConfig.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
#include "esp_freertos_hooks.h"
|
||||||
|
|
||||||
|
#include "my_helper_fct.h"
|
||||||
|
QueueHandle_t xQueue1;
|
||||||
|
|
||||||
|
/**************************************/
|
||||||
|
/**************************************/
|
||||||
|
/* Scenarios */
|
||||||
|
|
||||||
|
#define DIFF_PRIORITY
|
||||||
|
|
||||||
|
#define PINNED_TO_CORE 0x00
|
||||||
|
// 0x00: Task 1: Core 0, Task 2: Core 0
|
||||||
|
// 0x01: Task 1: Core 0, Task 2: Core 1
|
||||||
|
// 0x10: Task 1: Core 1, Task 2: Core 0
|
||||||
|
// 0x11: Task 1: Core 1, Task 2: Core 1
|
||||||
|
|
||||||
|
//#define IDLE_HOOKS
|
||||||
|
|
||||||
|
//#define TASK_DELAY
|
||||||
|
|
||||||
|
//#define PERIODIC_TASK_DELAY
|
||||||
|
|
||||||
|
/**************************************/
|
||||||
|
/**************************************/
|
||||||
|
|
||||||
|
/* Default stack size for tasks */
|
||||||
|
static const uint32_t STACK_SIZE = 4000;
|
||||||
|
|
||||||
|
#ifdef DIFF_PRIORITY
|
||||||
|
|
||||||
|
static const uint32_t T1_PRIO = 2;
|
||||||
|
static const uint32_t T2_PRIO = 2;
|
||||||
|
static const uint32_t T3_PRIO = 3;
|
||||||
|
#else
|
||||||
|
|
||||||
|
static const uint32_t T1_PRIO = 5;
|
||||||
|
static const uint32_t T2_PRIO = 5;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef IDLE_HOOKS
|
||||||
|
|
||||||
|
volatile uint32_t countIdle0 = 0;
|
||||||
|
volatile uint32_t countIdle1 = 0;
|
||||||
|
|
||||||
|
bool vApplicationIdleHook_0 ( void ){
|
||||||
|
countIdle0++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool vApplicationIdleHook_1 ( void ){
|
||||||
|
countIdle1++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef PERIODIC_TASK_DELAY
|
||||||
|
/* Buffer to extract trace information */
|
||||||
|
static char buffer[40*12];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Used as a loop counter to create a very crude delay. */
|
||||||
|
#define mainDELAY_LOOP_COUNT (0x1FFFFF)
|
||||||
|
|
||||||
|
/* The task function. */
|
||||||
|
void vTaskFunction1(void *pvParameters);
|
||||||
|
void vTaskFunction2(void *pvParameters);
|
||||||
|
void vTaskFunction3(void *pvParameters);
|
||||||
|
|
||||||
|
|
||||||
|
void app_main(void) {
|
||||||
|
|
||||||
|
xQueue1 = xQueueCreate(5, sizeof(uint32_t));
|
||||||
|
DISPLAY("Start of app_main task, priority = %d",uxTaskPriorityGet(NULL));
|
||||||
|
vTaskSuspendAll();
|
||||||
|
|
||||||
|
xTaskCreatePinnedToCore(vTaskFunction1, "Task 1", STACK_SIZE, (void*)"Task 1", T1_PRIO, NULL,CORE_1);
|
||||||
|
xTaskCreatePinnedToCore(vTaskFunction2, "Task 2", STACK_SIZE, (void*)"Task 2", T2_PRIO, NULL,CORE_0);
|
||||||
|
xTaskCreatePinnedToCore(vTaskFunction3, "Task 3", STACK_SIZE, (void*)"Task 3", T3_PRIO, NULL,CORE_0);
|
||||||
|
|
||||||
|
xTaskResumeAll();
|
||||||
|
|
||||||
|
/*for (;;) {
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS); // 100 ms
|
||||||
|
DISPLAY("Hello app_main task!");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/* to ensure its exit is clean */
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vTaskFunction1(void *pvParameters) {
|
||||||
|
int32_t lSentValue;
|
||||||
|
TickType_t xLastWakeTime;
|
||||||
|
xLastWakeTime= xTaskGetTickCount();
|
||||||
|
const TickType_t xDelay500ms = pdMS_TO_TICKS(500UL);
|
||||||
|
for(;;){
|
||||||
|
DISPLAY("Task 1 started , sending message");
|
||||||
|
lSentValue= 50;
|
||||||
|
xQueueSend(xQueue1, &lSentValue, 0);
|
||||||
|
// Compute time : 40 ms
|
||||||
|
COMPUTE_IN_TIME_MS(40) ;
|
||||||
|
// block periodically : 500 ms
|
||||||
|
vTaskDelayUntil(&xLastWakeTime, xDelay500ms);
|
||||||
|
DISPLAY("Task 1 done");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void vTaskFunction2(void *pvParameters) {
|
||||||
|
// Wait for message
|
||||||
|
int32_t lReceivedValue;
|
||||||
|
|
||||||
|
for(;;){
|
||||||
|
DISPLAY("Task 2 started, wait for message");
|
||||||
|
if(xQueueReceive(xQueue1,&lReceivedValue,portMAX_DELAY==pdTRUE)){
|
||||||
|
// display task number and message
|
||||||
|
DISPLAY("Task 2 : Received value : %d", lReceivedValue);
|
||||||
|
}
|
||||||
|
// Compute time : 30 ms
|
||||||
|
COMPUTE_IN_TIME_MS(30) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void vTaskFunction3(void *pvParameters) {
|
||||||
|
for(;;){
|
||||||
|
// Task blocked during 100 ms
|
||||||
|
DISPLAY("Task 3 started");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
// Compute time : 20 ms
|
||||||
|
COMPUTE_IN_TIME_MS(20);
|
||||||
|
DISPLAY ("Task 3 done");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
47
part3_freertos/lab2-1_single_msg_queue/main/my_helper_fct.h
Normal file
47
part3_freertos/lab2-1_single_msg_queue/main/my_helper_fct.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef _MY_HELPER_FCT_
|
||||||
|
#define _MY_HELPER_FCT_
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Core constants fot xTaskCreatePinnedToCore() function */
|
||||||
|
const uint32_t CORE_0 = 0;
|
||||||
|
const uint32_t CORE_1 = 1;
|
||||||
|
const uint32_t PRO_CPU = 0;
|
||||||
|
const uint32_t APP_CPU = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to display the buffer with arguments. msg is a formatted string as printf() function.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define DISPLAY(msg, ...) printf("%d:%d>\t"msg"\r\n", xTaskGetTickCount(), xPortGetCoreID(), ##__VA_ARGS__);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to display error/warning/info for the buffer with arguments. msg is a formatted string as printf() function.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define DISPLAYE(tag, msg, ...) ESP_LOGE(tag, "%d:%d>\t"msg"", xTaskGetTickCount(), xPortGetCoreID(), ##__VA_ARGS__);
|
||||||
|
|
||||||
|
#define DISPLAYW(tag, msg, ...) ESP_LOGW(tag, "%d:%d>\t"msg"", xTaskGetTickCount(), xPortGetCoreID(), ##__VA_ARGS__);
|
||||||
|
|
||||||
|
#define DISPLAYI(tag, msg, ...) ESP_LOGI(tag, "%d:%d>\t"msg"", xTaskGetTickCount(), xPortGetCoreID(), ##__VA_ARGS__);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to display the buffer without argument
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define DISPLAYB(msg) printf("%d:%d>\t", xTaskGetTickCount(), xPortGetCoreID());\
|
||||||
|
printf(msg);\
|
||||||
|
printf("\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
/* Consume CPU cycles. Time parameter is for the default frequency: 160MHz (ESP32_DEFAULT_CPU_FREQ_MHZ=160) */
|
||||||
|
#define COMPUTE_IN_TIME_US(time_us) {register uint32_t i=(uint32_t)time_us*5.02*100/22; while (i-- > 0) {asm(" nop");}}
|
||||||
|
|
||||||
|
#define COMPUTE_IN_TIME_MS(time_ms) {register uint32_t i=(uint32_t)time_ms*1000*5.02*100/22; while (i-- > 0) {asm(" nop");}}
|
||||||
|
|
||||||
|
#define COMPUTE_IN_TICK(tick) {register uint32_t i=(uint32_t)(tick*1000/configTICK_RATE_HZ)*1000*5.02*100/22; while (i-- > 0) {asm(" nop");}}
|
||||||
|
|
||||||
|
#endif
|
||||||
294
part3_freertos/lab2-1_single_msg_queue/readme.md
Normal file
294
part3_freertos/lab2-1_single_msg_queue/readme.md
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
# Visual Studio Code Template for ESP32
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
We consider that the Espressif IoT Development Framework (ESP-IDF), version 4.4.1, and Visual Studio Code environment is installed on the computer.
|
||||||
|
For more details, see:
|
||||||
|
- https://docs.espressif.com/projects/esp-idf/en/v4.4.1/esp32/get-started/index.html#installation-step-by-step
|
||||||
|
- https://code.visualstudio.com/
|
||||||
|
|
||||||
|
As of VS-code v1.56.1 integrated terminals require additional configuration to work correctly. see https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations to edit the `setting.json` file and add the following entry:
|
||||||
|
```bash
|
||||||
|
"terminal.integrated.allowWorkspaceConfiguration":true
|
||||||
|
```
|
||||||
|
|
||||||
|
In Linux (from Ubuntu 20.x), on connecting an ESP32 board with a CP210x USB to serial converter, there is a problem of connection. Add the following entries below that disable both parts of the brltty service and allowed the ESP32 development boards to properly connect.
|
||||||
|
```bash
|
||||||
|
sudo systemctl stop brltty-udev.service
|
||||||
|
sudo systemctl mask brltty-udev.service
|
||||||
|
sudo systemctl stop brltty.service
|
||||||
|
sudo systemctl disable brltty.service
|
||||||
|
```
|
||||||
|
Another solution is to uninstall brltty as below:
|
||||||
|
```bash
|
||||||
|
sudo apt remove brltty
|
||||||
|
```
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
Firstly, you have to clone the `esp32-vscode-project-template` project and follow the next steps.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/fmuller-pns/esp32-vscode-project-template.git
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 1. Rename the `vscode_project_template` folder
|
||||||
|
```bash
|
||||||
|
mv esp32-vscode-project-template <my_project_name>
|
||||||
|
```
|
||||||
|
#### 2. Go to the project directory
|
||||||
|
```bash
|
||||||
|
cd <my_project_name>
|
||||||
|
```
|
||||||
|
#### 3. Remove the GIT directory
|
||||||
|
```bash
|
||||||
|
rm -fR .git
|
||||||
|
```
|
||||||
|
#### 4. Open visual studio code for the new project
|
||||||
|
```bash
|
||||||
|
code .
|
||||||
|
```
|
||||||
|
#### 5. Verify paths in the `c_cpp_properties.json` file and change them if wrong.
|
||||||
|
```json
|
||||||
|
"IDF_TOOLS": "~/.espressif/tools",
|
||||||
|
"IDF_PATH": "~/esp/esp-idf"
|
||||||
|
```
|
||||||
|
#### 6. [Not required] Change the default project name called `main` in files.
|
||||||
|
This step renames the executable file. By default, the executable file is `main.elf`.
|
||||||
|
1. Open `CMakeLists.txt` and replace `main` by <my_project_name>
|
||||||
|
2. Open `Makefile` and replace `main` by <my_project_name>
|
||||||
|
3. Open `.vscode/launch.json` and replace `main` by <my_project_name> (lines 11 and 19)
|
||||||
|
|
||||||
|
#### 7. Open a terminal from Visual Studio Code to perform commands
|
||||||
|
Choose an external or internal terminal.
|
||||||
|
|
||||||
|
##### Open integrated terminal from Visual Studio Code
|
||||||
|
|
||||||
|
* using keyboard shortcut: `Ctrl+Shift+`<sup>2</sup>
|
||||||
|
* or pressing `F1` key and typing `integrated`
|
||||||
|
|
||||||
|
##### Open external terminal from Visual Studio Code
|
||||||
|
|
||||||
|
* using keyboard shortcut: `Ctrl+Shift+C`
|
||||||
|
* or pressing `F1` key and typing `external`
|
||||||
|
|
||||||
|
#### 8. Identify the USB serial port (usually `/dev/ttyUSB0`)
|
||||||
|
```bash
|
||||||
|
ls /dev/ttyUSB*
|
||||||
|
```
|
||||||
|
<span style="color:yellow">/dev/ttyUSB0</span>
|
||||||
|
|
||||||
|
#### 9. Building, flashing and running project
|
||||||
|
The serial port is `/dev/ttyUSB0` identified above.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash monitor
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Push the button on the ESP32 board when connecting
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Serial port /dev/ttyUSB0
|
||||||
|
Connecting........_____....._
|
||||||
|
Detecting chip type... ESP32
|
||||||
|
Chip is ESP32-PICO-D4 (revision 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Flashing and monitoring
|
||||||
|
The message "`Hello ESP32 !`" appears.
|
||||||
|
```bash
|
||||||
|
...
|
||||||
|
W (290) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
|
||||||
|
I (300) cpu_start: Starting scheduler on PRO CPU.
|
||||||
|
I (0) cpu_start: Starting scheduler on APP CPU.
|
||||||
|
Hello ESP32 !
|
||||||
|
```
|
||||||
|
|
||||||
|
To exit monitoring, typing `Ctrl+AltGr+]`
|
||||||
|
|
||||||
|
## Useful Commands
|
||||||
|
|
||||||
|
#### Open external terminal from vscode to perform commands
|
||||||
|
|
||||||
|
* using keyboard shortcut: `Ctrl+Shift+C`
|
||||||
|
* or pressing `F1` key and typing `external`
|
||||||
|
|
||||||
|
#### Open integrated terminal from vscode to perform commands
|
||||||
|
|
||||||
|
* using keyboard shortcut: `Ctrl+Shift+`<sup>2</sup>
|
||||||
|
* or pressing `F1` key and typing `integrated`
|
||||||
|
|
||||||
|
#### Clean project
|
||||||
|
```bash
|
||||||
|
idf.py fullclean
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Configuration of the ESP32 board (only in external terminal)
|
||||||
|
```bash
|
||||||
|
idf.py menuconfig
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Compile and build the executable file (`.elf` extension)
|
||||||
|
```bash
|
||||||
|
idf.py build
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Identify the USB serial port (usually `/dev/ttyUSB0`)
|
||||||
|
```bash
|
||||||
|
ls /dev/ttyUSB*
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Compile, build, flash
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Compile, build, flash and monitor
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash monitor
|
||||||
|
```
|
||||||
|
To exit monitoring, typing `Ctrl+AltGr+]`
|
||||||
|
|
||||||
|
## Using Tasks for ESP32 to run, debug Project and so on
|
||||||
|
|
||||||
|
1. In the menu, select `Run Task...`
|
||||||
|
2. Select the task you want to launch:
|
||||||
|
- `ESP32 - Build only`: just build the project
|
||||||
|
- `ESP32 - Flash and Monitor`: build (when modifications of code), flash and monitor
|
||||||
|
- `ESP32 - Clean Project`: Clean project (Full clean)
|
||||||
|
- `ESP32 - OpenOCD with FT2232`: Run in dedicated terminal the openOCD command to debug the project
|
||||||
|
- `ESP32 - Doxygen - HTML doc.`: Generate HTML documentation with Doxygen
|
||||||
|
|
||||||
|
## Configure GIT for your new project
|
||||||
|
|
||||||
|
#### Go to your new project folder
|
||||||
|
```bash
|
||||||
|
cd <project_name>
|
||||||
|
```
|
||||||
|
#### Configure name and email address
|
||||||
|
```bash
|
||||||
|
git config --global user.name "your name"
|
||||||
|
git config --global user.email "your email address"
|
||||||
|
```
|
||||||
|
#### Avoid typing your username and personal access token in vscode each time
|
||||||
|
This is useful when connecting your GIT to GitHub.
|
||||||
|
```bash
|
||||||
|
git config credential.helper store
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using GITHUB with visual studio code
|
||||||
|
|
||||||
|
We consider you have followed the sections above:
|
||||||
|
* Getting Started
|
||||||
|
* Configure GIT for your new project
|
||||||
|
|
||||||
|
Now, how to communicate with GitHub ?
|
||||||
|
|
||||||
|
1. Open visual studio code.
|
||||||
|
2. Click on the `Source Control` icon on your left side or use `Ctrl+Shift+G` shortcut.
|
||||||
|
3. For the first time, click on `Initialize Repository` button
|
||||||
|
4. Enter a message for your first commit (ex: first commit) and click on Commit icon
|
||||||
|
5. Press `F1` and typing `git add remote` and entering :
|
||||||
|
* *remote name* : your github repository previously created
|
||||||
|
* *remote url* : https://github.com/xxx/your_project.git
|
||||||
|
* *username* and *password*
|
||||||
|
6. Push to the GitHub server (master branch)
|
||||||
|
|
||||||
|
See https://code.visualstudio.com/docs/editor/versioncontrol for more details.
|
||||||
|
|
||||||
|
## Debugging with JTAG FT2232
|
||||||
|
|
||||||
|
You must install FTDI FT2232 driver.
|
||||||
|
### Quick Driver installation for Linux:
|
||||||
|
|
||||||
|
1. Install USB Driver
|
||||||
|
```bash
|
||||||
|
sudo apt-get install libusb-1.0
|
||||||
|
$ lsusb
|
||||||
|
Bus 001 Device 002: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
|
||||||
|
```
|
||||||
|
2. Install OpenOCD rules. The path for rule copy can be different and depend on your ESP-IDF installation.
|
||||||
|
```bash
|
||||||
|
$ sudo usermod -a -G dialout $USER
|
||||||
|
$ sudo usermod -a -G plugdev $USER
|
||||||
|
$ sudo cp ~/.espressif/tools/openocd-esp32/v0.10.0-esp32-20210401/openocd-esp32/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d/
|
||||||
|
$ sudo reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 1: From external terminals
|
||||||
|
|
||||||
|
1. Connect the ESP32 board (USB)
|
||||||
|
2. Open an external terminal for building, flashing and running project
|
||||||
|
The serial port is `/dev/ttyUSB0` identified above.
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash monitor
|
||||||
|
```
|
||||||
|
3. Connect the JTAG FT2232 (USB)
|
||||||
|
4. Open another external terminal for running `openocd` with configuration file (`ftdi_ft2232.cfg`) located in the project root.
|
||||||
|
```bash
|
||||||
|
openocd -f ftdi_ft2232.cfg
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Result on openocd terminal
|
||||||
|
```bash
|
||||||
|
Open On-Chip Debugger v0.10.0-esp32-20190313 (2019-03-13-09:52)
|
||||||
|
Licensed under GNU GPL v2
|
||||||
|
adapter speed: 20000 kHz
|
||||||
|
Info : Configured 2 cores
|
||||||
|
esp32 interrupt mask on
|
||||||
|
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 : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
|
||||||
|
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
|
||||||
|
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
|
||||||
|
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
|
||||||
|
Info : Detected debug stubs @ 3ffb2950 on core0 of target 'esp32'
|
||||||
|
Info : Listening on port 3333 for gdb connections
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 2: From Visual Studio Code
|
||||||
|
1. Click on the left on the line you want to set a breakpoint. A red bullet appears.
|
||||||
|
|
||||||
|
2. Click on debug Icon
|
||||||
|
|
||||||
|
3. Click on RUN `ESP32 OpenOCD`. If an error arises, click again.
|
||||||
|
|
||||||
|
4. The program stops at the breakpoint and you can see variables and more
|
||||||
|
|
||||||
|
### Step 3: When you modify the code
|
||||||
|
|
||||||
|
Do not touch the terminal with `openocd` command.
|
||||||
|
|
||||||
|
1. Stop the program into the terminal, typing `Ctrl+AltGr+]`
|
||||||
|
2. Build, flash and run program
|
||||||
|
The serial port is `/dev/ttyUSB0` identified above.
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash monitor
|
||||||
|
```
|
||||||
|
3. Click on RUN `ESP32 OpenOCD`. If an error arises, click again.
|
||||||
|
4. The program stops at the breakpoint and you can see variables and more
|
||||||
|
|
||||||
|
## Generate Doxygen documentation
|
||||||
|
|
||||||
|
You can use [Using Tasks for ESP32](#using-tasks-for-esp32-to-run-debug-project-and-so-on) or follow the steps below.
|
||||||
|
|
||||||
|
1. Open external terminal from vscode, using keyboard shortcut: `Ctrl+Shift+C`, or pressing `F1` key and typing `external`
|
||||||
|
2. Generate HTML documentation in `html_doc` folder
|
||||||
|
|
||||||
|
* From the User interface (allow you updating the `Doxyfile` configuration file)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
doxywizard
|
||||||
|
```
|
||||||
|
|
||||||
|
* Directly from `Doxyfile` configuration file
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
doxygen
|
||||||
|
```
|
||||||
|
3. A new `html` folder is created, the entry file is `index.html`
|
||||||
|
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
|
||||||
|
|
||||||
|
# disable watchdog for task
|
||||||
|
CONFIG_ESP_TASK_WDT=n
|
||||||
|
|
||||||
|
# 2 cores to perform freertos
|
||||||
|
CONFIG_FREERTOS_UNICORE=n
|
||||||
|
|
||||||
10
part3_freertos/lab2-4_single_msg_queue_interrupt/.gitignore
vendored
Normal file
10
part3_freertos/lab2-4_single_msg_queue_interrupt/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
# Configuration files
|
||||||
|
sdkconfig
|
||||||
|
sdkconfig.old
|
||||||
|
|
||||||
|
# Production folder
|
||||||
|
build/
|
||||||
|
|
||||||
|
# HTML documentation
|
||||||
|
html_doc/
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
# The following lines of boilerplate have to be in your project's
|
||||||
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(main)
|
||||||
2494
part3_freertos/lab2-4_single_msg_queue_interrupt/Doxyfile
Normal file
2494
part3_freertos/lab2-4_single_msg_queue_interrupt/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,3 @@
|
|||||||
|
PROJECT_NAME := main
|
||||||
|
|
||||||
|
include $(IDF_PATH)/make/project.mk
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
interface ftdi
|
||||||
|
ftdi_vid_pid 0x0403 0x6010
|
||||||
|
ftdi_layout_init 0x0038 0x003b
|
||||||
|
|
||||||
|
# The ESP32 only supports JTAG.
|
||||||
|
transport select jtag
|
||||||
|
|
||||||
|
# This can go as high as 20MHz if CPU frequency is 80MHz, or 26MHz
|
||||||
|
# if CPU frequency is 160MHz or 240MHz.
|
||||||
|
adapter_khz 20000
|
||||||
|
|
||||||
|
# If single core debugging is required, uncomment the following line
|
||||||
|
#set ESP32_ONLYCPU 1
|
||||||
|
|
||||||
|
# To disable RTOS support, uncomment the following line
|
||||||
|
# set ESP32_RTOS none
|
||||||
|
|
||||||
|
# This option defaults to 3.3v
|
||||||
|
set ESP32_FLASH_VOLTAGE 3.3
|
||||||
|
|
||||||
|
# Source the ESP32 configuration file
|
||||||
|
source [find target/esp32.cfg]
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(
|
||||||
|
SRC_DIRS "."
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
COMPONENT_SRCDIRS := .
|
||||||
|
COMPONENT_ADD_INCLUDEDIRS := .
|
||||||
105
part3_freertos/lab2-4_single_msg_queue_interrupt/main/main.c
Normal file
105
part3_freertos/lab2-4_single_msg_queue_interrupt/main/main.c
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2020 by Fabrice Muller *
|
||||||
|
* *
|
||||||
|
* This file is useful for ESP32 Design course. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file lab2-4_main.c
|
||||||
|
* @author Fabrice Muller
|
||||||
|
* @date 13 Oct. 2020
|
||||||
|
* @brief File containing the lab2-4 of Part 3.
|
||||||
|
*
|
||||||
|
* @see https://github.com/fmuller-pns/esp32-vscode-project-template
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
/* FreeRTOS.org includes. */
|
||||||
|
#include "freertos/FreeRTOSConfig.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
|
||||||
|
#include "my_helper_fct.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "soc/rtc_wdt.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
|
#include "freertos/FreeRTOSConfig.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
|
||||||
|
#include "my_helper_fct.h"
|
||||||
|
|
||||||
|
static const char* TAG = "MsgQ";
|
||||||
|
|
||||||
|
// Push button for interrupt
|
||||||
|
static const gpio_num_t PIN_PUSH_BUTTON = 15;
|
||||||
|
|
||||||
|
/* Stack size for all tasks */
|
||||||
|
const uint32_t TASK_STACK_SIZE = 4096;
|
||||||
|
|
||||||
|
|
||||||
|
void app_main(void) {
|
||||||
|
|
||||||
|
/* Config GPIO */
|
||||||
|
|
||||||
|
|
||||||
|
/* Create Message Queue and Check if created */
|
||||||
|
|
||||||
|
|
||||||
|
/* Create vCounterTask task */
|
||||||
|
|
||||||
|
|
||||||
|
/* Install ISR */
|
||||||
|
|
||||||
|
|
||||||
|
/* to ensure its exit is clean */
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vCounterTask(void *pvParameters) {
|
||||||
|
|
||||||
|
for (;; ) {
|
||||||
|
|
||||||
|
/* Wait for message with 5 sec. otherwise DISPLAY a message to push it */
|
||||||
|
|
||||||
|
/* If pushed */
|
||||||
|
|
||||||
|
// DISPLAY "Button pushed" and the isrCount variable
|
||||||
|
|
||||||
|
// Get the number of items in the queue
|
||||||
|
|
||||||
|
// DISPLAYI (Information display) number of items if greater than 1
|
||||||
|
|
||||||
|
// Waiting for push button signal is 1 again (test every 20 ms)
|
||||||
|
|
||||||
|
// DISPLAY "Button released"
|
||||||
|
|
||||||
|
/* Else If Time out */
|
||||||
|
|
||||||
|
// Display message "Please, push the button!"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void IRAM_ATTR Push_button_isr_handler(void *args) {
|
||||||
|
|
||||||
|
// Increment isrCount
|
||||||
|
|
||||||
|
// Send message
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
294
part3_freertos/lab2-4_single_msg_queue_interrupt/readme.md
Normal file
294
part3_freertos/lab2-4_single_msg_queue_interrupt/readme.md
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
# Visual Studio Code Template for ESP32
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
We consider that the Espressif IoT Development Framework (ESP-IDF), version 4.4.1, and Visual Studio Code environment is installed on the computer.
|
||||||
|
For more details, see:
|
||||||
|
- https://docs.espressif.com/projects/esp-idf/en/v4.4.1/esp32/get-started/index.html#installation-step-by-step
|
||||||
|
- https://code.visualstudio.com/
|
||||||
|
|
||||||
|
As of VS-code v1.56.1 integrated terminals require additional configuration to work correctly. see https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations to edit the `setting.json` file and add the following entry:
|
||||||
|
```bash
|
||||||
|
"terminal.integrated.allowWorkspaceConfiguration":true
|
||||||
|
```
|
||||||
|
|
||||||
|
In Linux (from Ubuntu 20.x), on connecting an ESP32 board with a CP210x USB to serial converter, there is a problem of connection. Add the following entries below that disable both parts of the brltty service and allowed the ESP32 development boards to properly connect.
|
||||||
|
```bash
|
||||||
|
sudo systemctl stop brltty-udev.service
|
||||||
|
sudo systemctl mask brltty-udev.service
|
||||||
|
sudo systemctl stop brltty.service
|
||||||
|
sudo systemctl disable brltty.service
|
||||||
|
```
|
||||||
|
Another solution is to uninstall brltty as below:
|
||||||
|
```bash
|
||||||
|
sudo apt remove brltty
|
||||||
|
```
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
Firstly, you have to clone the `esp32-vscode-project-template` project and follow the next steps.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/fmuller-pns/esp32-vscode-project-template.git
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 1. Rename the `vscode_project_template` folder
|
||||||
|
```bash
|
||||||
|
mv esp32-vscode-project-template <my_project_name>
|
||||||
|
```
|
||||||
|
#### 2. Go to the project directory
|
||||||
|
```bash
|
||||||
|
cd <my_project_name>
|
||||||
|
```
|
||||||
|
#### 3. Remove the GIT directory
|
||||||
|
```bash
|
||||||
|
rm -fR .git
|
||||||
|
```
|
||||||
|
#### 4. Open visual studio code for the new project
|
||||||
|
```bash
|
||||||
|
code .
|
||||||
|
```
|
||||||
|
#### 5. Verify paths in the `c_cpp_properties.json` file and change them if wrong.
|
||||||
|
```json
|
||||||
|
"IDF_TOOLS": "~/.espressif/tools",
|
||||||
|
"IDF_PATH": "~/esp/esp-idf"
|
||||||
|
```
|
||||||
|
#### 6. [Not required] Change the default project name called `main` in files.
|
||||||
|
This step renames the executable file. By default, the executable file is `main.elf`.
|
||||||
|
1. Open `CMakeLists.txt` and replace `main` by <my_project_name>
|
||||||
|
2. Open `Makefile` and replace `main` by <my_project_name>
|
||||||
|
3. Open `.vscode/launch.json` and replace `main` by <my_project_name> (lines 11 and 19)
|
||||||
|
|
||||||
|
#### 7. Open a terminal from Visual Studio Code to perform commands
|
||||||
|
Choose an external or internal terminal.
|
||||||
|
|
||||||
|
##### Open integrated terminal from Visual Studio Code
|
||||||
|
|
||||||
|
* using keyboard shortcut: `Ctrl+Shift+`<sup>2</sup>
|
||||||
|
* or pressing `F1` key and typing `integrated`
|
||||||
|
|
||||||
|
##### Open external terminal from Visual Studio Code
|
||||||
|
|
||||||
|
* using keyboard shortcut: `Ctrl+Shift+C`
|
||||||
|
* or pressing `F1` key and typing `external`
|
||||||
|
|
||||||
|
#### 8. Identify the USB serial port (usually `/dev/ttyUSB0`)
|
||||||
|
```bash
|
||||||
|
ls /dev/ttyUSB*
|
||||||
|
```
|
||||||
|
<span style="color:yellow">/dev/ttyUSB0</span>
|
||||||
|
|
||||||
|
#### 9. Building, flashing and running project
|
||||||
|
The serial port is `/dev/ttyUSB0` identified above.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash monitor
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Push the button on the ESP32 board when connecting
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Serial port /dev/ttyUSB0
|
||||||
|
Connecting........_____....._
|
||||||
|
Detecting chip type... ESP32
|
||||||
|
Chip is ESP32-PICO-D4 (revision 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Flashing and monitoring
|
||||||
|
The message "`Hello ESP32 !`" appears.
|
||||||
|
```bash
|
||||||
|
...
|
||||||
|
W (290) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
|
||||||
|
I (300) cpu_start: Starting scheduler on PRO CPU.
|
||||||
|
I (0) cpu_start: Starting scheduler on APP CPU.
|
||||||
|
Hello ESP32 !
|
||||||
|
```
|
||||||
|
|
||||||
|
To exit monitoring, typing `Ctrl+AltGr+]`
|
||||||
|
|
||||||
|
## Useful Commands
|
||||||
|
|
||||||
|
#### Open external terminal from vscode to perform commands
|
||||||
|
|
||||||
|
* using keyboard shortcut: `Ctrl+Shift+C`
|
||||||
|
* or pressing `F1` key and typing `external`
|
||||||
|
|
||||||
|
#### Open integrated terminal from vscode to perform commands
|
||||||
|
|
||||||
|
* using keyboard shortcut: `Ctrl+Shift+`<sup>2</sup>
|
||||||
|
* or pressing `F1` key and typing `integrated`
|
||||||
|
|
||||||
|
#### Clean project
|
||||||
|
```bash
|
||||||
|
idf.py fullclean
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Configuration of the ESP32 board (only in external terminal)
|
||||||
|
```bash
|
||||||
|
idf.py menuconfig
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Compile and build the executable file (`.elf` extension)
|
||||||
|
```bash
|
||||||
|
idf.py build
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Identify the USB serial port (usually `/dev/ttyUSB0`)
|
||||||
|
```bash
|
||||||
|
ls /dev/ttyUSB*
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Compile, build, flash
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Compile, build, flash and monitor
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash monitor
|
||||||
|
```
|
||||||
|
To exit monitoring, typing `Ctrl+AltGr+]`
|
||||||
|
|
||||||
|
## Using Tasks for ESP32 to run, debug Project and so on
|
||||||
|
|
||||||
|
1. In the menu, select `Run Task...`
|
||||||
|
2. Select the task you want to launch:
|
||||||
|
- `ESP32 - Build only`: just build the project
|
||||||
|
- `ESP32 - Flash and Monitor`: build (when modifications of code), flash and monitor
|
||||||
|
- `ESP32 - Clean Project`: Clean project (Full clean)
|
||||||
|
- `ESP32 - OpenOCD with FT2232`: Run in dedicated terminal the openOCD command to debug the project
|
||||||
|
- `ESP32 - Doxygen - HTML doc.`: Generate HTML documentation with Doxygen
|
||||||
|
|
||||||
|
## Configure GIT for your new project
|
||||||
|
|
||||||
|
#### Go to your new project folder
|
||||||
|
```bash
|
||||||
|
cd <project_name>
|
||||||
|
```
|
||||||
|
#### Configure name and email address
|
||||||
|
```bash
|
||||||
|
git config --global user.name "your name"
|
||||||
|
git config --global user.email "your email address"
|
||||||
|
```
|
||||||
|
#### Avoid typing your username and personal access token in vscode each time
|
||||||
|
This is useful when connecting your GIT to GitHub.
|
||||||
|
```bash
|
||||||
|
git config credential.helper store
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using GITHUB with visual studio code
|
||||||
|
|
||||||
|
We consider you have followed the sections above:
|
||||||
|
* Getting Started
|
||||||
|
* Configure GIT for your new project
|
||||||
|
|
||||||
|
Now, how to communicate with GitHub ?
|
||||||
|
|
||||||
|
1. Open visual studio code.
|
||||||
|
2. Click on the `Source Control` icon on your left side or use `Ctrl+Shift+G` shortcut.
|
||||||
|
3. For the first time, click on `Initialize Repository` button
|
||||||
|
4. Enter a message for your first commit (ex: first commit) and click on Commit icon
|
||||||
|
5. Press `F1` and typing `git add remote` and entering :
|
||||||
|
* *remote name* : your github repository previously created
|
||||||
|
* *remote url* : https://github.com/xxx/your_project.git
|
||||||
|
* *username* and *password*
|
||||||
|
6. Push to the GitHub server (master branch)
|
||||||
|
|
||||||
|
See https://code.visualstudio.com/docs/editor/versioncontrol for more details.
|
||||||
|
|
||||||
|
## Debugging with JTAG FT2232
|
||||||
|
|
||||||
|
You must install FTDI FT2232 driver.
|
||||||
|
### Quick Driver installation for Linux:
|
||||||
|
|
||||||
|
1. Install USB Driver
|
||||||
|
```bash
|
||||||
|
sudo apt-get install libusb-1.0
|
||||||
|
$ lsusb
|
||||||
|
Bus 001 Device 002: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
|
||||||
|
```
|
||||||
|
2. Install OpenOCD rules. The path for rule copy can be different and depend on your ESP-IDF installation.
|
||||||
|
```bash
|
||||||
|
$ sudo usermod -a -G dialout $USER
|
||||||
|
$ sudo usermod -a -G plugdev $USER
|
||||||
|
$ sudo cp ~/.espressif/tools/openocd-esp32/v0.10.0-esp32-20210401/openocd-esp32/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d/
|
||||||
|
$ sudo reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 1: From external terminals
|
||||||
|
|
||||||
|
1. Connect the ESP32 board (USB)
|
||||||
|
2. Open an external terminal for building, flashing and running project
|
||||||
|
The serial port is `/dev/ttyUSB0` identified above.
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash monitor
|
||||||
|
```
|
||||||
|
3. Connect the JTAG FT2232 (USB)
|
||||||
|
4. Open another external terminal for running `openocd` with configuration file (`ftdi_ft2232.cfg`) located in the project root.
|
||||||
|
```bash
|
||||||
|
openocd -f ftdi_ft2232.cfg
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Result on openocd terminal
|
||||||
|
```bash
|
||||||
|
Open On-Chip Debugger v0.10.0-esp32-20190313 (2019-03-13-09:52)
|
||||||
|
Licensed under GNU GPL v2
|
||||||
|
adapter speed: 20000 kHz
|
||||||
|
Info : Configured 2 cores
|
||||||
|
esp32 interrupt mask on
|
||||||
|
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 : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
|
||||||
|
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
|
||||||
|
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
|
||||||
|
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
|
||||||
|
Info : Detected debug stubs @ 3ffb2950 on core0 of target 'esp32'
|
||||||
|
Info : Listening on port 3333 for gdb connections
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 2: From Visual Studio Code
|
||||||
|
1. Click on the left on the line you want to set a breakpoint. A red bullet appears.
|
||||||
|
|
||||||
|
2. Click on debug Icon
|
||||||
|
|
||||||
|
3. Click on RUN `ESP32 OpenOCD`. If an error arises, click again.
|
||||||
|
|
||||||
|
4. The program stops at the breakpoint and you can see variables and more
|
||||||
|
|
||||||
|
### Step 3: When you modify the code
|
||||||
|
|
||||||
|
Do not touch the terminal with `openocd` command.
|
||||||
|
|
||||||
|
1. Stop the program into the terminal, typing `Ctrl+AltGr+]`
|
||||||
|
2. Build, flash and run program
|
||||||
|
The serial port is `/dev/ttyUSB0` identified above.
|
||||||
|
```bash
|
||||||
|
idf.py -p /dev/ttyUSB0 flash monitor
|
||||||
|
```
|
||||||
|
3. Click on RUN `ESP32 OpenOCD`. If an error arises, click again.
|
||||||
|
4. The program stops at the breakpoint and you can see variables and more
|
||||||
|
|
||||||
|
## Generate Doxygen documentation
|
||||||
|
|
||||||
|
You can use [Using Tasks for ESP32](#using-tasks-for-esp32-to-run-debug-project-and-so-on) or follow the steps below.
|
||||||
|
|
||||||
|
1. Open external terminal from vscode, using keyboard shortcut: `Ctrl+Shift+C`, or pressing `F1` key and typing `external`
|
||||||
|
2. Generate HTML documentation in `html_doc` folder
|
||||||
|
|
||||||
|
* From the User interface (allow you updating the `Doxyfile` configuration file)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
doxywizard
|
||||||
|
```
|
||||||
|
|
||||||
|
* Directly from `Doxyfile` configuration file
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
doxygen
|
||||||
|
```
|
||||||
|
3. A new `html` folder is created, the entry file is `index.html`
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user