Skip to content

Commit

Permalink
Merge branch 'release/factory_demo_with_idf_patch' into 'master'
Browse files Browse the repository at this point in the history
Release/factory demo with idf patch

See merge request ae_group/esp-box!10
  • Loading branch information
Real-YuZhe committed Nov 19, 2021
2 parents 21cc1f3 + 720cf21 commit 5639842
Show file tree
Hide file tree
Showing 47 changed files with 509,287 additions and 307 deletions.
8 changes: 7 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ before_script:
build_demo_cmake:
<<: *build_examples_template
script:
- cd idf_patch
- python3 apply_patch.py -d $IDF_PATH
- cd ../
- cd examples/factory_demo
- idf.py fullclean
- idf.py build
- rm sdkconfig sdkconfig.defaults
- cp sdkconfig.defaults.cn sdkconfig.defaults
- idf.py build
- idf.py fullclean
- cd ../
- cd image_display
- idf.py fullclean
Expand All @@ -40,7 +47,6 @@ build_demo_cmake:
- idf.py fullclean
- idf.py build
- cd ../../


push_to_github:
stage: deploy
Expand Down
2 changes: 1 addition & 1 deletion components/bsp/boards/esp_custom_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <stdbool.h>
#include "bsp_board.h"
#include "bsp_board_esp_custom.h"
#include "esp_custom_board.h"
#include "esp_err.h"

esp_err_t bsp_board_init(void)
Expand Down
4 changes: 2 additions & 2 deletions components/bsp/src/bsp_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ esp_err_t bsp_codec_adc_init(audio_hal_iface_samples_t sample_rate)
.adc_input = AUDIO_HAL_ADC_INPUT_ALL,
.i2s_iface = {
.bits = AUDIO_HAL_BIT_LENGTH_16BITS,
.fmt = AUDIO_HAL_I2S_DSP,
.fmt = AUDIO_HAL_I2S_NORMAL,
.mode = AUDIO_HAL_MODE_SLAVE,
.samples = sample_rate,
},
Expand All @@ -101,7 +101,7 @@ esp_err_t bsp_codec_dac_init(audio_hal_iface_samples_t sample_rate)
.dac_output = AUDIO_HAL_DAC_OUTPUT_LINE1,
.i2s_iface = {
.bits = AUDIO_HAL_BIT_LENGTH_16BITS,
.fmt = AUDIO_HAL_I2S_DSP,
.fmt = AUDIO_HAL_I2S_NORMAL,
.mode = AUDIO_HAL_MODE_SLAVE,
.samples = sample_rate,
},
Expand Down
35 changes: 7 additions & 28 deletions components/bsp/src/bsp_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,17 @@
#define I2S_CONFIG_DEFAULT() { \
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX, \
.sample_rate = sample_rate, \
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, \
.channel_format = I2S_CHANNEL_FMT_MULTIPLE, \
.communication_format = I2S_COMM_FORMAT_STAND_PCM_SHORT, \
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 | ESP_INTR_FLAG_IRAM, \
.dma_buf_count = 4, \
.dma_buf_len = 256, \
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, \
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, \
.communication_format = I2S_COMM_FORMAT_STAND_I2S, \
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, \
.dma_buf_count = 6, \
.dma_buf_len = 160, \
.use_apll = false, \
.tx_desc_auto_clear = true, \
.fixed_mclk = 0, \
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT, \
.bits_per_chan = I2S_BITS_PER_CHAN_16BIT, \
.chan_mask = I2S_TDM_ACTIVE_CH0 | I2S_TDM_ACTIVE_CH1 | I2S_TDM_ACTIVE_CH2, \
.total_chan = 3, \
.left_align = false, \
.big_edin = false, \
.bit_order_msb = false, \
.skip_msk = false, \
.bits_per_chan = I2S_BITS_PER_CHAN_32BIT, \
}

esp_err_t bsp_i2s_init(i2s_port_t i2s_num, uint32_t sample_rate)
Expand All @@ -71,21 +65,6 @@ esp_err_t bsp_i2s_init(i2s_port_t i2s_num, uint32_t sample_rate)
ret_val |= i2s_driver_install(i2s_num, &i2s_config, 0, NULL);
ret_val |= i2s_set_pin(i2s_num, &pin_config);

ret_val |= i2s_stop(I2S_NUM_0);

/* Config I2S channel format of TX and RX */
i2s_ll_tx_set_active_chan_mask(&I2S0, I2S_TDM_ACTIVE_CH0);
i2s_ll_rx_set_active_chan_mask(&I2S0, I2S_TDM_ACTIVE_CH0 | I2S_TDM_ACTIVE_CH1 | I2S_TDM_ACTIVE_CH2);

/* Inverse DSP mode WS signal polarity. See IDF-4140 for more */
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[GPIO_I2S_LRCK], PIN_FUNC_GPIO);
gpio_set_direction(GPIO_I2S_LRCK, GPIO_MODE_OUTPUT);
esp_rom_gpio_connect_out_signal(GPIO_I2S_LRCK, i2s_periph_signal[I2S_NUM_0].m_tx_ws_sig, true, false);

/* Clear I2S DMA buffer and start I2S */
ret_val |= i2s_zero_dma_buffer(I2S_NUM_0);
ret_val |= i2s_start(I2S_NUM_0);

return ret_val;
}

Expand Down
1 change: 0 additions & 1 deletion components/codec/es7210/es7210.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ esp_err_t es7210_config_fmt(audio_hal_iface_format_t fmt)
break;
}
ret |= es7210_write_reg(ES7210_SDP_INTERFACE1_REG11, adc_iface);
ret |= es7210_write_reg(ES7210_SDP_INTERFACE2_REG12, 0x01);
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion components/esp-sr
Submodule esp-sr updated 65 files
+19 −0 .github/workflows/issue_comment.yml
+19 −0 .github/workflows/new_issues.yml
+24 −0 .github/workflows/new_prs.yml
+30 −9 CMakeLists.txt
+4 −9 Kconfig.projbuild
+12 −11 README.md
+55 −0 docs/audio_front_end/Espressif_Microphone_Design_Guidelines.md
+120 −92 docs/audio_front_end/README.md
+125 −98 docs/audio_front_end/README_CN.md
+156 −0 docs/flash_model/README.md
+154 −0 docs/flash_model/README_CN.md
+ docs/img/AFE_overview.png
+ docs/img/AFE_workflow.png
+ docs/img/add_speech_ch.png
+ docs/img/add_speech_en.png
+ docs/img/model-1.png
+ docs/img/support.png
+51 −42 docs/speech_command_recognition/README.md
+59 −74 docs/wake_word_engine/ESP_Wake_Words_Customization.md
+20 −14 docs/wake_word_engine/README.md
+7 −0 esp-tts/CMakeLists.txt
+ esp-tts/esp_tts_chinese/libesp_tts_chinese.a
+ esp-tts/esp_tts_chinese/libesp_tts_chinese_esp32s2.a
+ esp-tts/esp_tts_chinese/libesp_tts_chinese_esp32s3.a
+ esp-tts/esp_tts_chinese/libvoice_set_xiaole_esp32s3.a
+8 −0 include/customized_word_wn5.h
+1 −2 include/dl_lib.h
+20 −1 include/esp_afe_sr_iface.h
+8 −0 include/esp_agc.h
+13 −1 include/esp_map.h
+14 −1 include/esp_mase.h
+1 −1 include/esp_mn_iface.h
+8 −0 include/hijeson_wn5X3.h
+8 −0 include/hilexin_wn5.h
+8 −0 include/hilexin_wn5X2.h
+8 −0 include/hilexin_wn5X3.h
+9 −0 include/multinet2_ch.h
+8 −0 include/nihaoxiaoxin_wn5X3.h
+8 −0 include/nihaoxiaoxin_wn6.h
+8 −0 include/nihaoxiaozhi_wn5.h
+8 −0 include/nihaoxiaozhi_wn5X2.h
+8 −0 include/nihaoxiaozhi_wn5X3.h
+ lib/esp32/libc_speech_features.a
+ lib/esp32/libcustomized_word_wn5.a
+ lib/esp32/libdl_lib.a
+ lib/esp32/libdl_lib_esp32.a
+ lib/esp32/libesp_audio_front_end.a
+ lib/esp32/libesp_audio_processor.a
+ lib/esp32/libhilexin_wn5.a
+ lib/esp32/libhilexin_wn5X2.a
+ lib/esp32/libhilexin_wn5X3.a
+ lib/esp32/libmultinet.a
+ lib/esp32/libmultinet2_ch.a
+ lib/esp32/libnihaoxiaoxin_wn5X3.a
+ lib/esp32/libnihaoxiaozhi_wn5.a
+ lib/esp32/libnihaoxiaozhi_wn5X2.a
+ lib/esp32/libnihaoxiaozhi_wn5X3.a
+ lib/esp32/libwakenet.a
+1 −1 libversion
+4 −4 model/movemodel.py
+25 −9 src/esp_afe_sr_1mic.c
+1 −1 src/model_path.c
+0 −0 tool/README
+0 −0 tool/multinet_g2p.py
+0 −0 tool/requirements
2 changes: 2 additions & 0 deletions examples/factory_demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.5)

set(PROJECT_VER "0.1.1")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

set(EXTRA_COMPONENT_DIRS
Expand Down
83 changes: 31 additions & 52 deletions examples/factory_demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@

This is the factory demo for ESP32-S3-Box development board.

## How to Compile

Since some bug fixes of esp-idf may not be synced to GitHub, you need to manually apply some patches to build the example.

### Apply Patch

For Linux and macOS, you can apply the patch by entering the following command on the command line / terminal:

```shell
cd /path/to/esp-box/idf_patch
python3 apply_patch.py -d /path/to/esp-idf
. /path/to/esp-idf/export.sh
```

For Windows users, you may need to do the following manually:

- Change the working directory to the folder where esp-idf is located
- Run the following commands in cmd in sequence:
- `git fetch origin`
- `git checkout 35b20cadce65ce79c14cf2018efc87c44d71ab21`
- `git apply X:\path\to/esp-box\idf_patch\idf_patch.patch`
- Copy the files in the `idf_patch\components\esp_phy` folder and replace them to the same location under esp-idf in turn
- Run `install.bat` in the esp-idf directory
- Run `export.bat` in the esp-idf directory
- Enter the esp-box repo to compile the project you want

### Compile Example

The project provides `sdkconfig.defaults.cn` and `sdkconfig.defaults.en`, which are the default configuration files corresponding to Chinese and English respectively. By replacing `sdkconfig.defaults` with the above file, deleting `sdkconfig`, rebuilding and burning, you can burn routines in the specified language to ESP-Box.

## How to Use

### Hardware Required
Expand All @@ -24,6 +54,7 @@ Say "Hi esp" to wake up the device. Then say command word list is as follows aft

- Turn On/Off The Light
- Turn Red / Green / Blue / White
- Custom Color

The detected command word will be displayed on the screen. If the LED is correctly connected to the device, its color will change according to the command word.

Expand All @@ -44,58 +75,6 @@ Once a complete flash process has been performed, you can use `idf.py app-flash

(To exit the serial monitor, type `Ctrl-]`. Please reset the development board f you cannot exit the monitor.)

## Example Output

Run this example, you will see the following output log:

```
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd0108,len:0x51c
load:0x403b6000,len:0x93c
load:0x403ba000,len:0x2c48
entry 0x403b6164
I (33) opi psram: vendor id : 0x0d (AP)
I (34) opi psram: dev id : 0x02 (generation 3)
I (34) opi psram: density : 0x03 (64 Mbit)
I (37) opi psram: good-die : 0x01 (Pass)
I (42) opi psram: Latency : 0x01 (Fixed)
I (46) opi psram: VCC : 0x01 (3V)
I (51) opi psram: SRF : 0x01 (Fast Refresh)
I (56) opi psram: BurstType : 0x01 (Hybrid Wrap)
I (62) opi psram: BurstLen : 0x01 (32 Byte)
I (67) opi psram: Readlatency : 0x02 (10 cycles@Fixed)
I (73) opi psram: DriveStrength: 0x00 (1/1)
W (77) PSRAM: DO NOT USE FOR MASS PRODUCTION! Timing parameters will be updated in future IDF version.
I (88) spiram: Found 64MBit SPI RAM device
I (92) spiram: SPI RAM mode: sram 80m
I (96) spiram: PSRAM initialized, cache is in normal (1-core) mode.
I (103) cpu_start: Pro cpu up.
I (107) cpu_start: Starting app cpu, entry point is 0x403796c4
0x403796c4: call_start_cpu1 at /home/zhe/esp/gitlab/idf/esp-idf-hmi/components/esp_system/port/cpu_start.c:156
I (0) cpu_start: App cpu up.
I (402) spiram: SPI SRAM memory test OK
I (411) cpu_start: Pro cpu start user code
I (411) cpu_start: cpu freq: 240000000
I (411) cpu_start: Application information:
I (411) cpu_start: Project name: factory_demo
I (411) cpu_start: App version: b720353-dirty
I (411) cpu_start: Compile time: Nov 9 2021 11:25:23
I (412) cpu_start: ELF file SHA256: e12c5b6471e7e231...
I (412) cpu_start: ESP-IDF: v5.0-dev-19-g290c805aa8-dirty
I (412) heap_init: Initializing. RAM available for dynamic allocation:
I (413) heap_init: At 3FCB4708 len 0002B8F8 (174 KiB): D/IRAM
I (413) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (413) spiram: Adding pool of 8192K of external SPI memory to heap allocator
I (414) spi_flash: detected chip: gd
I (414) spi_flash: flash io: qio
I (415) sleep: Configure to isolate all GPIO pins in sleep state
I (415) sleep: Enable automatic switching of GPIO sleep configuration
I (415) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
```

## Troubleshooting

* Program upload failure
Expand Down
2 changes: 1 addition & 1 deletion examples/factory_demo/main/app/app_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool audio_is_playing(void)
/* **************** AUDIO DEBUG TOOL **************** */
esp_err_t audio_record_to_file(size_t time_ms, const char *file_name)
{
size_t audio_channel = 3;
size_t audio_channel = 4;
size_t audio_sample_rate = 16000;
size_t bytes_per_sample = sizeof(int16_t);
size_t file_size = audio_sample_rate * time_ms / 1000 * bytes_per_sample * audio_channel;
Expand Down
Loading

0 comments on commit 5639842

Please sign in to comment.