update esp32 bsp, support esp32c3 and esp32s3

This commit is contained in:
李昂 2023-05-02 23:53:19 +08:00
parent 1ce9fc0707
commit 9a49ad985e
21 changed files with 191 additions and 3314 deletions

4
bsp/esp32/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
build/
.cache/
*.old
sdkconfig

View File

@ -6,5 +6,6 @@ esp-idf 5.0
- on windows
```
idf.py set-target <esp32c3/esp32s3>
make.bat
```
```

View File

@ -0,0 +1,6 @@
pikascript-core==v1.12.1
PikaStdLib==v1.12.1
PikaStdDevice==v2.3.7
ESP32==v0.4.0
time==v0.1.4
pika_libc==v1.0.2

View File

@ -1,68 +1,74 @@
#include "PikaVM.h"
#include "driver/gpio.h"
#include "driver/uart.h"
#include "driver/usb_serial_jtag.h"
#include "esp_core_dump.h"
#include "esp_err.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_system.h"
#include "esp_vfs_dev.h"
#include "esp_vfs_fat.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "sdmmc_cmd.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include "driver/gpio.h"
#include "driver/uart.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_system.h"
#include "esp_vfs_fat.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "sdmmc_cmd.h"
#include "esp_http_client.h"
#include "esp_https_ota.h"
#include "esp_ota_ops.h"
#include "esp_partition.h"
#include "esp_wifi.h"
#include "nvs.h"
#include "nvs_flash.h"
#include "pikaScript.h"
#include <esp_ota_ops.h>
#include <esp_partition.h>
#include <time.h>
static volatile char gRXC = EOF;
static volatile uint8_t gNeedPut = 0;
char pika_platform_getchar() {
gRXC = getc(stdin);
while (gRXC == (char)EOF) {
gRXC = getc(stdin);
/* Replace (fflush(stdout) or printf("\n"))'s function!!! */
if (gNeedPut) {
#if CONFIG_IDF_TARGET_ESP32C3
uint32_t EP1_Conf_Reg = 0x00;
/* Read USB_SERIAL_JTAG_EP1_CONF_REG (BaseAddr: 0x60043000
* Offset: 0x0004) */
EP1_Conf_Reg = *((uint32_t*)(0x60043004));
/* Set 'USB_SERIAL_JTAG_WR_DONE' bit*/
EP1_Conf_Reg |= 0x01;
/* Write USB_SERIAL_JTAG_EP1_CONF_REG Back */
*((uint32_t*)(0x60043004)) = EP1_Conf_Reg;
gNeedPut = 0;
#else
fflush(stdout);
#endif
}
vTaskDelay(1);
while (1) {
char buff[1] = {0};
if (usb_serial_jtag_read_bytes(buff, 1, 100) > 0) {
return buff[0];
}
return gRXC;
vTaskDelay(1);
}
}
int pika_platform_putchar(char ch) {
putc(ch, stdout);
gNeedPut = 1;
return 0;
usb_serial_jtag_write_bytes(&ch, 1, 0);
return 0;
}
int64_t pika_platform_get_tick(void) {
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
}
void app_main(void) {
usb_serial_jtag_driver_config_t usb_serial_jtag_config = {
.rx_buffer_size = 1024 * 8, .tx_buffer_size = 1024};
usb_serial_jtag_driver_install(&usb_serial_jtag_config);
esp_vfs_usb_serial_jtag_use_driver();
printf("Minimum free heap size: %" PRIu32 " bytes\n",
esp_get_minimum_free_heap_size());
pikaScriptShell(pikaScriptInit());
}
void pika_platform_reboot(void) {
/* reboot */
abort();
}

View File

@ -1,3 +1,2 @@
#define PIKA_SHELL_NO_NEWLINE 1
#define PIKA_OPTIMIZE PIKA_OPTIMIZE_SPEED
// #define PIKA_DEBUG_ENABLE 1

View File

@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
app0, app, ota_0, 0x10000, 0xF80000,
script, 0x5A, 0x5A, 0xF90000, 0x20000,
spiffs, data, spiffs,0xFB0000, 0x40000,
fdb, 0x5A, 0x5B, 0xFF0000, 0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x6000
3 phy_init data phy 0xf000 0x1000
4 app0 app ota_0 0x10000 0xF80000
5 script 0x5A 0x5A 0xF90000 0x20000
6 spiffs data spiffs 0xFB0000 0x40000
7 fdb 0x5A 0x5B 0xFF0000 0x10000

View File

@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
app0, app, ota_0, 0x10000, 0x380000,
script, 0x5A, 0x5A, 0x390000, 0x20000,
spiffs, data, spiffs, 0x3B0000, 0x40000,
fdb, 0x5A, 0x5B, 0x3F0000, 0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x6000
3 phy_init data phy 0xf000 0x1000
4 app0 app ota_0 0x10000 0x380000
5 script 0x5A 0x5A 0x390000 0x20000
6 spiffs data spiffs 0x3B0000 0x40000
7 fdb 0x5A 0x5B 0x3F0000 0x10000

View File

@ -0,0 +1,45 @@
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
CONFIG_BOOTLOADER_LOG_LEVEL=1
CONFIG_BOOT_ROM_LOG_ALWAYS_OFF=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_ESP_TLS_INSECURE=y
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y
CONFIG_ESP_MAIN_TASK_STACK_SIZE=16284
CONFIG_ESP_INT_WDT=y
CONFIG_ESP_INT_WDT_TIMEOUT_MS=10000
CONFIG_ESP_TASK_WDT=y
CONFIG_ESP_TASK_WDT_TIMEOUT_S=5
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
CONFIG_FREERTOS_UNICORE=y
CONFIG_FREERTOS_HZ=1000
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
CONFIG_LWIP_LOCAL_HOSTNAME="pikapython"
CONFIG_LWIP_SNTP_MAX_SERVERS=3
CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_PM_ENABLE=y
CONFIG_LOG_COLORS=n
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
CONFIG_MBEDTLS_TLS_CLIENT_ONLY=y
CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=n
CONFIG_MBEDTLS_TLS_SERVER=n
CONFIG_MBEDTLS_PSK_MODES=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK=y
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192
CONFIG_LWIP_IPV6=n
CONFIG_LWIP_TCP_MSL=2000

View File

@ -0,0 +1,33 @@
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.4m.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.4m.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x8000
CONFIG_PARTITION_TABLE_MD5=y
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
CONFIG_ESPTOOLPY_FLASHMODE="dio"
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
CONFIG_ESPTOOLPY_AFTER="hard_reset"
CONFIG_ESPTOOLPY_MONITOR_BAUD=921600
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y
CONFIG_ESP_CONSOLE_UART=y
CONFIG_ESP_CONSOLE_UART_NUM=0
CONFIG_ESP_CONSOLE_UART_TX_GPIO=21
CONFIG_ESP_CONSOLE_UART_RX_GPIO=20
CONFIG_ESP_CONSOLE_UART_BAUDRATE=921600
CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y
CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION=y
CONFIG_ESP_PHY_DEFAULT_INIT_IF_INVALID=y

View File

@ -0,0 +1,44 @@
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="16MB"
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.16m.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.16m.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x8000
CONFIG_PARTITION_TABLE_MD5=y
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHMODE="qio"
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
CONFIG_ESPTOOLPY_AFTER="hard_reset"
CONFIG_ESPTOOLPY_MONITOR_BAUD=921600
#CONFIG_ESP_CONSOLE_UART_CUSTOM=y
#CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y
#CONFIG_ESP_CONSOLE_UART=y
#CONFIG_ESP_CONSOLE_UART_NUM=0
#CONFIG_ESP_CONSOLE_UART_TX_GPIO=21
#CONFIG_ESP_CONSOLE_UART_RX_GPIO=20
#CONFIG_ESP_CONSOLE_UART_BAUDRATE=921600
CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y
CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION=y
CONFIG_ESP_PHY_DEFAULT_INIT_IF_INVALID=y
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_TYPE_AUTO=y
CONFIG_SPIRAM_SIZE=-1
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=1024

View File

@ -1 +0,0 @@
build/

View File

@ -1,13 +0,0 @@
file(GLOB_RECURSE SOURCES *.c)
idf_component_register(
SRCS ${SOURCES}
INCLUDE_DIRS
"pikascript-api"
"pikascript-core"
"pikascript-lib/PikaStdLib"
"pikascript-lib/PikaStdDevice"
"pikascript-lib/ESP32"
"../../main"
WHOLE_ARCHIVE
REQUIRES driver
)

View File

@ -1,5 +0,0 @@
pikascript-core==v1.12.0
PikaStdLib==v1.12.0
time==v0.1.0
PikaStdDevice==v2.3.1
ESP32==v0.2.0

View File

@ -1,7 +0,0 @@
# Embed the server root certificate into the final binary
idf_build_get_property(project_dir PROJECT_DIR)
idf_component_register(SRCS "main.c"
INCLUDE_DIRS ".")
# add macro
idf_build_set_property(
COMPILE_DEFINITIONS "-DPIKA_CONFIG_ENABLE" APPEND)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff