1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 【HaaS Python适配】AliOS-Things HAAS-Python ESP32-C3开发板适配和编译

【HaaS Python适配】AliOS-Things HAAS-Python ESP32-C3开发板适配和编译

时间:2019-03-01 07:00:29

相关推荐

【HaaS Python适配】AliOS-Things HAAS-Python ESP32-C3开发板适配和编译

AliOS-Things HAAS-Python ESP32-C3适配和编译

版本:v1.0 作者:乔楚、李志清 日期:-04-26

主要处理说明:

引用esp-idf v4.4独立espressif_esp32_c3处理对AliOS-Things的调用编译参数适配:已适配4MB版本和2MB版本

一、ESP-IDF部分的处理:

1. 设置esp-idf 4.4环境

# 设置spressif_esp32_c3mkdir hardware/chip/espressif_esp32_c3cp hardware/chip/espressif_esp32/*.* hardware/chip/espressif_esp32_c3/cp hardware/chip/espressif_esp32/SConscript hardware/chip/espressif_esp32_c3/# ~/esp/esp-idf已经切换到release/v4.4rsync -avP ~/esp/esp-idf hardware/chip/espressif_esp32_c3/

2. 修改必要的文件

2.1 diskio.h -> ff.h

修改 hardware/chip/espressif_esp32_c3/esp-idf/components/fatfs/src/diskio.h,添加对AliOS-Things文件接口调用

extern "C" {#endif+ // add for HaaSPython+ #include "ff.h"/* Status of Disk Functions */typedef BYTE DSTATUS;

2.2 esp_vfs.h --> statfs

修改 hardware/chip/espressif_esp32_c3/esp-idf/components/vfs/include/esp_vfs.h,添加statfs_p和statfs

esp_err_t (*end_select)(void *end_select_args);#endif // CONFIG_VFS_SUPPORT_SELECT+ // add for HaaSPython+ union {+ int (*statfs_p)(void *ctx, const char *path, void* sb);+ int (*statfs)(const char *path, void *sb);+ };} esp_vfs_t;

二、AliOS-Things部分的处理:

1. 编译环境匹配

1.1 espressif_esp32_c3/package.yaml

修改hardware/chip/espressif_esp32_c3/package.yaml 设置为c3环境:

## 第一部分: 基础信息name: espressif_esp32_c3 # <必选项> 包名称 (符合C语言变量命名规则),长度少于等于64字节version: dev_aos# <必选项> 组件版本号description: esp-idf for esp32-c3 # <必选项> 建议至少20字以上type: chip # <必选项> 组件类型,为:solution, chip, board, common, sdktag: 核心模块# <可选项> 组件分类,缺省值: ''keywords: # <可选项> 标签,会影响到组件被搜索的效果,合理的标签很重要- baselicense: Apache license v2.0 # <可选项> 源代码的许可证,要确保所有代码、文件的许可证不冲突。如:MIT,Apache license v2.0,BSD# 指定该组件依赖的组件及版本,版本支持条件比较,支持:>=v1.0, >v1.0, ==v1.0, <=v1.0, <v1.0, v1.0# 未指定条件时,默认为 ==,如 v1.0 与 ==v1.0# depends: # <可选项> 该组件依赖其他的组件,合理的依赖才能保证组件能编译、使用# - libc_stub: dev_aos# - aos: >=v7.2.0## 第四部分:编译连接信息# build_config: # <可选项> 编译配置项# include: # <可选项> 编译时,影响编译器的-I 参数 ,全局有效#- src # include 只能是该软件包下的目录,不能使用外部目录# internal_include: # <可选项> 编译时,影响编译器的-I 参数 ,组件内有效#- include# cflag: ''# <可选项> C 编译器所需要要的编译参数# cxxflag: '' # <可选项> CXX 编译器所需要要的编译参数# asmflag: '' # <可选项> 汇编器所需要要参数# define: # <可选项> 宏定义, 增加编译器的-D 选项,如:#XXX: 1 # -DXXX=1#AAA: 1 # -DAAA#STR: "abc" # -DSTR="abc"# libs: # 该组件中支持的二进制静态库,如:libxxx.a, libyyy.a#- xxx # -lxxx#- yyy # -lyyy# libpath: # 指定静态库所在的路径(相对于该组件路径)#- libs # -Llibsbuild_config:cflag: >-march=rv32imc -ffunction-sections -fdata-sections -Wall -Wextra -Wno-unused-parameter-Wno-sign-compare -ggdb -nostartfiles -Wno-format -O2 -fstrict-volatile-bitfields-fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration-Wno-clobbered -Wno-deprecated-declarations -Wno-missing-field-initializers -DKERNEL=FREERTOScxxflag: >-march=rv32imc -ffunction-sections -fdata-sections -Wall -Wextra -Wno-unused-parameter-Wno-sign-compare -ggdb -nostartfiles -Wno-format -O2 -fstrict-volatile-bitfields-fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration-Wno-clobbered -Wno-deprecated-declarations -Wno-missing-field-initializers-std=gnu++11 -fno-exceptions -fno-rtti -fpermissive -DKERNEL=FREERTOSldflag: >-march=rv32imc -nostartfiles --specs=nosys.specs -Wl,--cref -Wl,--Map="aos.map" -Wl,--gc-sections-fno-rtti -fno-lto -Wl,--wrap=vPortCleanUpTCB-uesp_app_desc -upthread_include_pthread_impl -upthread_include_pthread_cond_impl -u__ubsan_include-upthread_include_pthread_local_storage_impl -upthread_include_pthread_rwlock_impl-u__cxx_fatal_exception -uvfs_include_syscalls_impl -uapp_main -unewlib_include_heap_impl-unewlib_include_syscalls_impl -unewlib_include_pthread_impl -unewlib_include_assert_impl-u__cxa_guard_dummy -Tmemory.ld -Tsections.ld -Tesp32c3.rom.ld -Tesp32c3.rom.api.ld-Tesp32c3.rom.libgcc.ld -Tesp32c3.rom.newlib.ld -Tesp32c3.rom.version.ld -Tesp32c3.rom.eco3.ld-Tesp32c3.peripherals.ld -Wl,--undefined=uxTopUsedPriority-Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting -Wl,--wrap=__register_frame_info_bases-Wl,--wrap=__register_frame_info -Wl,--wrap=__register_frame-Wl,--wrap=__register_frame_info_table_bases -Wl,--wrap=__register_frame_info_table-Wl,--wrap=__register_frame_table -Wl,--wrap=__deregister_frame_info_bases-Wl,--wrap=__deregister_frame_info -Wl,--wrap=_Unwind_Find_FDE -Wl,--wrap=_Unwind_GetGR-Wl,--wrap=_Unwind_GetCFA -Wl,--wrap=_Unwind_GetIP -Wl,--wrap=_Unwind_GetIPInfo-Wl,--wrap=_Unwind_GetRegionStart -Wl,--wrap=_Unwind_GetDataRelBase-Wl,--wrap=_Unwind_GetTextRelBase -Wl,--wrap=_Unwind_SetIP -Wl,--wrap=_Unwind_SetGR-Wl,--wrap=_Unwind_GetLanguageSpecificData -Wl,--wrap=_Unwind_FindEnclosingFunction-Wl,--wrap=_Unwind_Resume -Wl,--wrap=_Unwind_RaiseException-Wl,--wrap=_Unwind_DeleteException -Wl,--wrap=_Unwind_ForcedUnwind-Wl,--wrap=_Unwind_Resume_or_Rethrow -Wl,--wrap=_Unwind_Backtrace-Wl,--wrap=__cxa_call_unexpected -Wl,--wrap=__gxx_personality_v0-lstdc++ -lgcc -lgcov -lc -lm -z muldefsinclude:- esp-idf/components/newlib/platform_include- esp-idf/components/freertos/include- esp-idf/components/freertos/include/esp_additions/freertos- esp-idf/components/freertos/port/riscv/include- esp-idf/components/freertos/include/esp_additions- esp-idf/components/esp_hw_support/include- esp-idf/components/esp_hw_support/include/soc- esp-idf/components/esp_hw_support/include/soc/esp32c3- esp-idf/components/esp_hw_support/port/esp32c3- esp-idf/components/esp_hw_support/port/esp32c3/private_include- esp-idf/components/heap/include- esp-idf/components/log/include- esp-idf/components/lwip/include/apps- esp-idf/components/lwip/include/apps/sntp- esp-idf/components/lwip/lwip/src/include- esp-idf/components/lwip/port/esp32/include- esp-idf/components/lwip/port/esp32/include/arch- esp-idf/components/soc/include- esp-idf/components/soc/esp32c3- esp-idf/components/soc/esp32c3/include- esp-idf/components/hal/esp32c3/include- esp-idf/components/hal/include- esp-idf/components/hal/platform_port/include- esp-idf/components/esp_rom/include- esp-idf/components/esp_rom/include/esp32c3- esp-idf/components/esp_rom/esp32c3- esp-idf/components/esp_common/include- esp-idf/components/esp_system/include- esp-idf/components/esp_system/port/soc- esp-idf/components/esp_system/port/include/riscv- esp-idf/components/esp_system/port/public_compat- esp-idf/components/riscv/include- esp-idf/components/driver/include- esp-idf/components/driver/esp32c3/include- esp-idf/components/esp_pm/include- esp-idf/components/esp_ringbuf/include- esp-idf/components/efuse/include- esp-idf/components/efuse/esp32c3/include- esp-idf/components/vfs/include- esp-idf/components/esp_wifi/include- esp-idf/components/esp_event/include- esp-idf/components/esp_netif/include- esp-idf/components/esp_eth/include- esp-idf/components/tcpip_adapter/include- esp-idf/components/esp_phy/include- esp-idf/components/esp_phy/esp32c3/include- esp-idf/components/esp_ipc/include- esp-idf/components/app_trace/include- esp-idf/components/esp_timer/include- esp-idf/components/app_update/include- esp-idf/components/spi_flash/include- esp-idf/components/bootloader_support/include- esp-idf/components/bt/common/osi/include- esp-idf/components/bt/include/esp32c3/include- esp-idf/components/bt/common/api/include/api- esp-idf/components/bt/common/btc/profile/esp/blufi/include- esp-idf/components/bt/common/btc/profile/esp/include- esp-idf/components/bt/host/nimble/nimble/porting/nimble/include- esp-idf/components/bt/host/nimble/port/include- esp-idf/components/bt/host/nimble/nimble/nimble/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/ans/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/bas/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/dis/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gap/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gatt/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/ias/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/ipss/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/lls/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/services/tps/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/util/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/store/ram/include- esp-idf/components/bt/host/nimble/nimble/nimble/host/store/config/include- esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include- esp-idf/components/bt/host/nimble/esp-hci/include- esp-idf/components/nvs_flash/include- esp-idf/components/mbedtls/port/include- esp-idf/components/mbedtls/mbedtls/include- esp-idf/components/mbedtls/esp_crt_bundle/include- esp-idf/components/mdns/include- esp-idf/components/console- esp-idf/components/sdmmc/include- esp-idf/components/fatfs/vfs- esp-idf/components/fatfs/src- esp-idf/components/wear_levelling/include- esp-idf/components/json/cJSON- esp-idf/components/soc/esp32s3/includelibs:- esp_ringbuf- efuse- esp_ipc- driver- esp_pm- mbedtls- mbedcrypto- mbedx509- coexist- core- espnow- mesh- net80211- pp- smartconfig- wapi- app_update- bootloader_support- spi_flash- nvs_flash- pthread- esp_gdbstub- espcoredump- esp_phy- esp_system- esp_rom- hal- vfs- esp_eth- tcpip_adapter- esp_netif- esp_event- wpa_supplicant- esp_wifi- console- lwip- log- heap- soc- esp_hw_support- riscv- esp_common- esp_timer- freertos- newlib- cxx- app_trace- asio- bt- cbor- unity- cmock- coap- nghttp- esp-tls- esp_adc_cal- esp_hid- tcp_transport- esp_http_client- esp_http_server- esp_https_ota- esp_lcd- protobuf-c- protocomm- mdns- esp_local_ctrl- sdmmc- esp_serial_slave_link- esp_websocket_client- expat- wear_levelling- fatfs- freemodbus- jsmn- json- liblibsodium- mqtt- openssl- spiffs- wifi_provisioning- main- btdm_app- btbb- phylibpath:- esp-idf/components/bt/controller/lib_esp32c3_family/esp32c3- esp-idf/components/esp_phy/lib/esp32c3- esp-idf/components/esp_wifi/lib/esp32c3- esp-idf/components/soc/esp32c3/ld- esp-idf/components/esp_rom/esp32c3/ld## 第五部分:配置信息def_config:# 组件的可配置项IDF_VER: "8153bfe4"ESP_PLATFORM: 1OS_FREERTOS: 1MBEDTLS_CONFIG_FILE: "mbedtls/esp_config.h"CONFIG_ESP_DISPATCHER_DELEGATE_TASK_CORE: 0CONFIG_ESP_DISPATCHER_DELEGATE_TASK_PRIO: 10CONFIG_ESP_DISPATCHER_DELEGATE_STACK_SIZE: 4096hw_info:arch_name: riscvcpu_name: ESP32-C3toolchain_prefix: riscv32-esp-elfvendor_name: espressifld_script: espressif_idf.lds## 第六部分:安装信息# install:# - dest: include/ # 安装的目的路径 dest是相当路径,通常是相对于YoC SDK 安装目录#source:# 安装源列表#- src/*.h # 支持通配符,相对路径# install:# - dest: "include"#source:# - hal/2ndboot/*.h# - aos/*.h# - aos/arch/*.h# - drivers/platform/hal/*.h# - drivers/platform/cmsis/inc/*.h# - drivers/rtos/rhino/cmsis/*.h# - drivers/utils/hwtimer_list/*.h# - drivers/platform/hal/haas1000/*.h# - drivers/services/wifi_app/alsa_adapter/*.h# - dest: "lib"#source:# - drivers/libmcuhaas1000.a ? <!CONFIG_A7_DSP_ENABLE># - drivers/libmcuhaas1000_a7.a ? <CONFIG_A7_DSP_ENABLE>## 第七部分:导出部分# export:# - dest: "<SOLUTION_PATH>/generated/data" # 安装的目的路径 dest是相当路径#source: # 安装源列表# - "bootimgs/boot"# - "bootimgs/tee"# - "bootimgs/mtb"# - "configs/config.yaml"

1.2 espressif_idf.lds设置

# 重命名.lds文件,该文件内容为空mv hardware/chip/espressif_esp32_c3/_esp32_alios.lds hardware/chip/espressif_esp32_c3/espressif_idf.lds

2. board配置:

2.1 生成nodemcu32_c3/package.yaml

cp -a hardware/board/nodemcu32s hardware/board/nodemcu32s_c3

修改hardware/board/nodemcu32_c3/package.yaml

## 第一部分: 基础信息name: nodemcu32s_c3 # <必选项> 包名称 (符合C语言变量命名规则),长度少于等于64字节version: dev_aos# <必选项> 组件版本号description: NodeMCU-32SC3 board configure. # <必选项> 建议至少20字以上type: board# <必选项> 组件类型,为:solution, chip, board, commontag: 核心模块 # <可选项> 组件分类,缺省值: ''## 第二部分:依赖信息# 指定该组件依赖的组件及版本,版本支持条件比较,支持:>=v1.0, >v1.0, ==v1.0, <=v1.0, <v1.0, v1.0# 未指定条件时,默认为 ==,如 v1.0 与 ==v1.0# depends: # <可选项> 该组件依赖其他的组件,合理的依赖才能保证组件能编译、使用# - minilibc: v7.2.0# - aos: >=v7.2.0depends:- espressif_esp32_c3: masterboard:chip_name: espressif_esp32_c3def_config:BOARD_NODEMCU32C3: 1SYSINFO_MCU: "ESP32"SYSINFO_BOARD: "NODEMCU32C3"# littlefs configCONFIG_LITTLEFS_CNT: 1 # lfs supports up to 2 partitions, please choose 1 or 2 hereCONFIG_LFS_MOUNTPOINT: "" # the mount path of the lfs partitionCONFIG_MAX_FILES: 10 # concurrently opened files numCONFIG_LFS_PROG_SIZE: 256CONFIG_LFS_PAGE_NUM_PER_BLOCK: 16LFS_CONFIG_DEBUG: 0LFS_CONFIG_TRACE: 0# CONFIG_LFS_PROG_SIZE: 1024 # the mininal programable size, usually page size for nand and any size for nor# CONFIG_LFS_PAGE_NUM_PER_BLOCK: 4 # choose the right value for nand, and usually any value for nor# CONFIG_LFS_BLOCK_NUMS: 1198 # the total block count for lfs parition

3. 工程配置:

3.1 package.yaml(无需修改)

文件:solutions/py_engine_esp32_demo/package.yaml 文件根据工程选择,自动修改

3.2 makeimg.sh

文件:solutions/py_engine_esp32_demo/makeimg.sh

修改 espressif_esp32 为 espressif_esp32_c3修改 --chip esp32 为 --chip esp32c3

3.3 makeimg.py

文件:olutions/py_engine_esp32_demo/makeimg.py

可根据需要,注释如下data部分:

files_in = [("bootloader", offset_bootloader, max_size_bootloader, arg_bootloader_bin),("partitions", offset_partitions, max_size_partitions, arg_partitions_bin),("application", offset_application, max_size_application, arg_application_bin),//("data", offset_data, max_size_data, arg_data_bin),]

4. 组件配置

4.1 设置编译配置参数:GENERIC_C3/sdkconfig.board

修改文件文件components/py_engine/adapter/esp32/boards/GENERIC_C3/sdkconfig.board,添加如下信息:

CONFIG_ESP32C3_REV_MIN_3=yCONFIG_ESP32C3_REV_MIN=3CONFIG_ESP32C3_BROWNOUT_DET=yCONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_7=CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_4=yCONFIG_ESP32C3_BROWNOUT_DET_LVL=4CONFIG_ESP_CONSOLE_UART_DEFAULT=yCONFIG_ESP_CONSOLE_USB_CDC=CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=4096

4.1.1 2MB规格开发板特殊处理
4.1.1.1 启用2MB配置

修改文件文件components/py_engine/adapter/esp32/boards/GENERIC_C3/sdkconfig.board,继续添加如下信息:

# 此处应修改该文件中已有的配置CONFIG_PARTITION_TABLE_OFFSET=0x9000# 2M规格CONFIG_ESPTOOLPY_FLASHSIZE_2MB=yCONFIG_PARTITION_TABLE_CUSTOM=yCONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-2MiB.csv"

4.1.1.2 配置对应分区表

修改文件文件components/py_engine/adapter/esp32/partitions-2MiB.csv:

# 注释原有的,添加下面的:factory, app, factory,0x10000, 1900k,nvs, data, nvs, 0x1eb000, 4K,phy_init, data, phy, 0x1ec000, 4K,vfs, data, fat, 0x1ed000, 72K,kv, data, 131, 0x1ff000, 4K,

说明:因为固件本身接近1.9M,故取消了OTA分区,其他分区也相应减小

4.2 修改源码:components/py_engine/

4.2.1 adapter/esp32/main.c

文件:components/py_engine/adapter/esp32/main.c,注释machine_i2s_init0调用;

或者修改adapter/esp32/mpconfigport.h设置MICROPY_PY_MACHINE_I2S定义为0

#if MICROPY_PY_MACHINE_I2S- machine_i2s_init0();+ // machine_i2s_init0();#endif

#ifndef MICROPY_PY_MACHINE_I2S- #define MICROPY_PY_MACHINE_I2S (1)+ #define MICROPY_PY_MACHINE_I2S (0)#endif

4.2.2 adapter/esp32/uart.c

文件:components/py_engine/adapter/esp32/uart.c 大量修改

#include "uart.h"STATIC void uart_irq_handler(void *arg);void uart_init(void) {uart_config_t uartcfg = {.baud_rate = MICROPY_HW_UART_REPL_BAUD,.data_bits = UART_DATA_8_BITS,.parity = UART_PARITY_DISABLE,.stop_bits = UART_STOP_BITS_1,.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,.rx_flow_ctrl_thresh = 0};uart_param_config(MICROPY_HW_UART_REPL, &uartcfg);const uint32_t rxbuf = 129; // IDF requires > 128 minconst uint32_t txbuf = 0;uart_driver_install(MICROPY_HW_UART_REPL, rxbuf, txbuf, 0, NULL, 0);uart_isr_handle_t handle;uart_isr_free(MICROPY_HW_UART_REPL);uart_isr_register(MICROPY_HW_UART_REPL, uart_irq_handler, NULL, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM, &handle);uart_enable_rx_intr(MICROPY_HW_UART_REPL);}int uart_stdout_tx_strn(const char *str, size_t len) {size_t remaining = len;// TODO add a timeoutfor (;;) {int ret = uart_tx_chars(MICROPY_HW_UART_REPL, str, remaining);if (ret == -1) {return -1;}remaining -= ret;if (remaining <= 0) {break;}str += ret;ulTaskNotifyTake(pdFALSE, 1);}return len - remaining;}STATIC void IRAM_ATTR uart_irq_handler(void *arg) {volatile uart_dev_t *uart = &UART0;#if CONFIG_IDF_TARGET_ESP32S3uart->int_clr.rxfifo_full_int_clr = 1;uart->int_clr.rxfifo_tout_int_clr = 1;#elseuart->int_clr.rxfifo_full = 1;uart->int_clr.rxfifo_tout = 1;uart->int_clr.frm_err = 1;#endifwhile (uart->status.rxfifo_cnt) {#if CONFIG_IDF_TARGET_ESP32uint8_t c = uart->fifo.rw_byte;#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3uint8_t c = READ_PERI_REG(UART_FIFO_AHB_REG(0)); // UART0#endifif (c == mp_interrupt_char) {mp_sched_keyboard_interrupt();} else {// this is an inline function so will be in IRAMringbuf_put(&stdin_ringbuf, c);}}}

4.2.3 adapter/esp32/uart.h

文件:components/py_engine/adapter/esp32/uart.h

#ifndef MICROPY_INCLUDED_ESP32_UART_H#define MICROPY_INCLUDED_ESP32_UART_H+ #ifndef MICROPY_HW_UART_REPL+ #define MICROPY_HW_UART_REPL (UART_NUM_0)+ #endif+ #ifndef MICROPY_HW_UART_REPL_BAUD+ #define MICROPY_HW_UART_REPL_BAUD (115200)+ #endifvoid uart_init(void);+ int uart_stdout_tx_strn(const char *str, size_t len);#endif // MICROPY_INCLUDED_ESP32_UART_H

4.3 脚本:

4.3.1 build_cmake.sh(无需修改)

文件:components/py_engine/build_cmake.sh

无需修改,内置C3,只要前面board配置正确名称为NODEMCU32C3即可

三、编译

使用haas studio的编译按钮编译,或者使用如下指令:

# 在 AliOS-Things 根目录操作aos make V=1 2>&1 | tee build.log

如编译错误,通过build.log查看错误信息,关键字:【error:】、【failed】、【raise】

四、烧录

# esptool.py 在macOS、Linux命令会自动查找可用串口esptool.py --chip esp32c3 --baud 460800 write_flash -z 0x0 firmware.bin# 手动设置串口: --port 串口名称# 如遇到问题,可以先清空flash: esptool.py --chip esp32c3 erase_flash

五、测试

# 使用串口工具或者终端连接,波特率115200>>> help()>>> import machine>>> machine.reset()>>> help('modules')

六、可能问题

1. sdkconfig.h

提示:fatal error: sdkconfig.h: No such file or directory原因:查找该信息前面的错误信息,找到根源

2. genhdr/qstrdefs.generated.h

# components/py_engine/engine/py/qstr.h问题:components/py_engine/engine/py/qstr.h:44:14: fatal error: genhdr/qstrdefs.generated.h: No such file or directory检查:vim components/py_engine/engine/py/qstr.h#define QDEF0(id, str) id,#define QDEF1(id, str)#include "genhdr/qstrdefs.generated.h"#undef QDEF0#undef QDEF1find . -name "qstrdefs.generated.h"./adapter/esp32/build-GENERIC_C3/genhdr/qstrdefs.generated.h./engine/mpy-cross/build/genhdr/qstrdefs.generated.h处理:正确设置hardware/board/nodemcu32_c3/package.yaml中的BOARD_NODEMCU32C3,就不会出现该错误

3. esp32/machine_pin.c

# components/py_engine/adapter/esp32/machine_pin.c问题:components/py_engine/adapter/esp32/machine_pin.c:264:29: error: 'USB_DEVICE_CONF0_REG' undeclared (first use in this function); did you mean 'UART_SWFC_CONF0_REG'?处理:考虑先注释掉? 注释后,micropython部分可以编译通过#if CONFIG_IDF_TARGET_ESP32C3if (self->id == 18 || self->id == 19) {// CLEAR_PERI_REG_MASK(USB_DEVICE_CONF0_REG, USB_DEVICE_USB_PAD_ENABLE);}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。