diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index dee349e..bc0b6eb 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -2,3 +2,4 @@ set(COMPONENT_SRCDIRS ". ugui") set(COMPONENT_ADD_INCLUDEDIRS ".") register_component() component_compile_options(-DPROJECT_VER="${PROJECT_VER}") +component_compile_options(-Wno-error=stringop-truncation) diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild new file mode 100644 index 0000000..5096ad3 --- /dev/null +++ b/main/Kconfig.projbuild @@ -0,0 +1,16 @@ +menu "Hardware configuration" + choice EMULATOR_HARDWARE + prompt "Hardware to run on" + default TARGET_ODROID_GO + help + This emulator can run on various types of hardware. Select what you have here. + config TARGET_ODROID_GO + bool "ODROID-GO Hardware" + config TARGET_MRGC_G32 + bool "MyRetroGameCase G32 Hardware" + config TARGET_RETRO_ESP32 + bool "RETRO ESP32 Hardware" + config TARGET_ESPLAY_S3 + bool "ESPLAY S3 Hardware (ESP32S3N8R8 Based)" + endchoice +endmenu diff --git a/main/display.c b/main/display.c index 4ad6168..f4a98fa 100644 --- a/main/display.c +++ b/main/display.c @@ -10,7 +10,7 @@ #include "display.h" static spi_device_handle_t spi; -static DMA_ATTR uint16_t dma_buffer[SCREEN_WIDTH]; +static DMA_ATTR uint16_t dma_buffer[RG_SCREEN_WIDTH]; static const struct { uint8_t cmd; @@ -19,7 +19,7 @@ static const struct { } ili_init_cmds[] = { {0x01, {0}, 0x80}, {0x3A, {0x55}, 1}, // Pixel Format Set RGB565 -#ifdef TARGET_MRGC_G32 +#ifdef CONFIG_TARGET_MRGC_G32 {0x36, {(0x00|0x00|0x00)}, 1}, {0xB1, {0x00, 0x10}, 2}, // Frame Rate Control (1B=70, 1F=61, 10=119) {0xB2, {0x0c, 0x0c, 0x00, 0x33, 0x33}, 5}, @@ -33,6 +33,28 @@ static const struct { {0xD0, {0xA4, 0xA1}, 2}, {0xE0, {0xD0, 0x00, 0x03, 0x09, 0x13, 0x1C, 0x3A, 0x55, 0x48, 0x18, 0x12, 0x0E, 0x19, 0x1E}, 14}, {0xE1, {0xD0, 0x00, 0x03, 0x09, 0x05, 0x25, 0x3A, 0x55, 0x50, 0x3D, 0x1C, 0x1D, 0x1D, 0x1E}, 14}, +#elif CONFIG_TARGET_ESPLAY_S3 + //-----------------------ST7789V Frame rate setting-----------------// + {0x3A, {0X05}, 1}, //65k mode + {0xC5, {0x1A}, 1}, //VCOM + {0x36, {0x60}, 1}, //屏幕显示方向设置 + //-------------ST7789V Frame rate setting-----------// + {0xB2, {0x05, 0x05, 0x00, 0x33, 0x33}, 5}, //Porch Setting + {0xB7, {0x05}, 1}, //Gate Control //12.2v -10.43v + //--------------ST7789V Power setting---------------// + {0xBB, {0x3F}, 1}, //VCOM + {0xC0, {0x2c}, 1}, //Power control + {0xC2, {0x01}, 1}, //VDV and VRH Command Enable + {0xC3, {0x0F}, 1}, //VRH Set 4.3+( vcom+vcom offset+vdv) + {0xC4, {0xBE}, 1}, //VDV Set 0v + {0xC6, {0X01}, 1}, //Frame Rate Control in Normal Mode 111Hz + {0xD0, {0xA4,0xA1}, 2}, //Power Control 1 + {0xE8, {0x03}, 1}, //Power Control 1 + {0xE9, {0x09,0x09,0x08}, 3}, //Equalize time control + //---------------ST7789V gamma setting-------------// + {0xE0, {0xD0,0x05,0x09,0x09,0x08,0x14,0x28,0x33,0x3F,0x07,0x13,0x14,0x28,0x30}, 14},//Set Gamma + {0XE1, {0xD0, 0x05, 0x09, 0x09, 0x08, 0x03, 0x24, 0x32, 0x32, 0x3B, 0x14, 0x13, 0x28, 0x2F, 0x1F}, 14},//Set Gamma + {0x20, {0}, 0},//反显 #else {0xCF, {0x00, 0xc3, 0x30}, 3}, {0xED, {0x64, 0x03, 0x12, 0x81}, 4}, @@ -82,15 +104,15 @@ static void ili_data(spi_device_handle_t spi, const void *data, int len) static void ili_spi_pre_transfer_callback(spi_transaction_t *t) { - gpio_set_level(LCD_PIN_NUM_DC, (int)t->user & 1); + gpio_set_level(RG_GPIO_LCD_DC, (int)t->user & 1); } void ili9341_writeLE(const uint16_t *buffer) { const int left = 0; - const int top = SCREEN_OFFSET_TOP; - const int width = SCREEN_WIDTH; - const int height = SCREEN_HEIGHT; + const int top = RG_SCREEN_MARGIN_TOP; + const int width = RG_SCREEN_WIDTH; + const int height = RG_SCREEN_HEIGHT; uint8_t tx_data[4]; @@ -124,8 +146,8 @@ void ili9341_writeLE(const uint16_t *buffer) void ili9341_deinit() { spi_bus_remove_device(spi); - gpio_reset_pin(LCD_PIN_NUM_DC); - gpio_reset_pin(LCD_PIN_NUM_BCKL); + gpio_reset_pin(RG_GPIO_LCD_DC); + gpio_reset_pin(RG_GPIO_LCD_BCKL); } void ili9341_init() @@ -143,7 +165,7 @@ void ili9341_init() ledc_channel_config(&(ledc_channel_config_t){ .channel = LEDC_CHANNEL_0, .duty = 0x1fff, - .gpio_num = LCD_PIN_NUM_BCKL, + .gpio_num = RG_GPIO_LCD_BCKL, .intr_type = LEDC_INTR_FADE_END, .speed_mode = LEDC_LOW_SPEED_MODE, .timer_sel = LEDC_TIMER_0, @@ -154,34 +176,48 @@ void ili9341_init() ESP_LOGI(__func__, "LCD: spi init..."); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[LCD_PIN_NUM_DC], PIN_FUNC_GPIO); - gpio_set_direction(LCD_PIN_NUM_DC, GPIO_MODE_OUTPUT); - gpio_set_level(LCD_PIN_NUM_DC, 1); +#if defined(CONFIG_IDF_TARGET_ESP32) + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[RG_GPIO_LCD_DC], PIN_FUNC_GPIO); +#endif + gpio_set_direction(RG_GPIO_LCD_DC, GPIO_MODE_OUTPUT); + gpio_set_level(RG_GPIO_LCD_DC, 1); // Initialize SPI spi_bus_config_t buscfg = { - .miso_io_num = LCD_PIN_NUM_MISO, - .mosi_io_num = LCD_PIN_NUM_MOSI, - .sclk_io_num = LCD_PIN_NUM_CLK, + .miso_io_num = RG_GPIO_LCD_MISO, + .mosi_io_num = RG_GPIO_LCD_MOSI, + .sclk_io_num = RG_GPIO_LCD_CLK, .quadwp_io_num = GPIO_NUM_NC, .quadhd_io_num = GPIO_NUM_NC, }; spi_device_interface_config_t devcfg = { - .clock_speed_hz = SPI_MASTER_FREQ_40M, +#ifdef CONFIG_TARGET_ESPLAY_S3 + .clock_speed_hz = SPI_MASTER_FREQ_80M, +#else + .clock_speed_hz = SPI_MASTER_FREQ_40M, +#endif .mode = 0, - .spics_io_num = LCD_PIN_NUM_CS, + .spics_io_num = RG_GPIO_LCD_CS, .queue_size = 4, .pre_cb = ili_spi_pre_transfer_callback, .flags = SPI_DEVICE_NO_DUMMY, }; - - ret = spi_bus_initialize(HSPI_HOST, &buscfg, 1); - //assert(ret==ESP_OK); - - ret = spi_bus_add_device(HSPI_HOST, &devcfg, &spi); +#ifdef CONFIG_TARGET_ESPLAY_S3 + ret = spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO); + assert(ret==ESP_OK); + ret = spi_bus_add_device(SPI2_HOST, &devcfg, &spi); + assert(ret==ESP_OK); + gpio_set_direction(RG_GPIO_LCD_RST,GPIO_MODE_OUTPUT); + gpio_set_level(RG_GPIO_LCD_RST,0); + vTaskDelay(120 / portTICK_RATE_MS); + gpio_set_level(RG_GPIO_LCD_RST,1); +#else + ret = spi_bus_initialize(HSPI_HOST, &buscfg, 1); assert(ret==ESP_OK); + ret = spi_bus_add_device(HSPI_HOST, &devcfg, &spi); + assert(ret==ESP_OK); +#endif for (int cmd = 0; cmd < sizeof(ili_init_cmds)/sizeof(ili_init_cmds[0]); cmd++) { @@ -202,9 +238,9 @@ void ili9341_init() ili_cmd(spi, 0x2B); ili_data(spi, (uint8_t[]){0, 0, 0xFF, 0xFF}, 4); ili_cmd(spi, 0x2C); - memset(dma_buffer, 0, SCREEN_WIDTH * 2); - for (int p = 0; p < 320 * 240; p += SCREEN_WIDTH) - ili_data(spi, dma_buffer, SCREEN_WIDTH * 2); + memset(dma_buffer, 0, RG_SCREEN_WIDTH * 2); + for (int p = 0; p < 320 * 240; p += RG_SCREEN_WIDTH) + ili_data(spi, dma_buffer, RG_SCREEN_WIDTH * 2); ESP_LOGI(__func__, "LCD Initialized."); } diff --git a/main/display.h b/main/display.h index cb5bbfb..156fc19 100644 --- a/main/display.h +++ b/main/display.h @@ -1,28 +1,5 @@ #pragma once - -#ifdef TARGET_MRGC_G32 -#define LCD_PIN_NUM_MISO GPIO_NUM_NC -#define LCD_PIN_NUM_MOSI GPIO_NUM_23 -#define LCD_PIN_NUM_CLK GPIO_NUM_18 -#define LCD_PIN_NUM_CS GPIO_NUM_5 -#define LCD_PIN_NUM_DC GPIO_NUM_12 -#define LCD_PIN_NUM_BCKL GPIO_NUM_27 - -#define SCREEN_OFFSET_TOP 28 -#define SCREEN_WIDTH 240 -#define SCREEN_HEIGHT 224 -#else -#define LCD_PIN_NUM_MISO GPIO_NUM_19 -#define LCD_PIN_NUM_MOSI GPIO_NUM_23 -#define LCD_PIN_NUM_CLK GPIO_NUM_18 -#define LCD_PIN_NUM_CS GPIO_NUM_5 -#define LCD_PIN_NUM_DC GPIO_NUM_21 -#define LCD_PIN_NUM_BCKL GPIO_NUM_14 - -#define SCREEN_OFFSET_TOP 0 -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 240 -#endif +#include "target.h" void ili9341_init(void); void ili9341_deinit(void); diff --git a/main/input.c b/main/input.c index 2ad92fc..9644cce 100644 --- a/main/input.c +++ b/main/input.c @@ -8,9 +8,35 @@ #include "input.h" -#ifdef TARGET_MRGC_G32 +#ifdef CONFIG_TARGET_MRGC_G32 #define TRY(x) if ((err = (x)) != ESP_OK) { goto fail; } +static bool rg_i2c_read(uint8_t addr, int reg, void *read_data, size_t read_len) +{ + esp_err_t err = ESP_FAIL; + + i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + if (reg >= 0) + { + TRY(i2c_master_start(cmd)); + TRY(i2c_master_write_byte(cmd, (addr << 1) | I2C_MASTER_WRITE, true)); + TRY(i2c_master_write_byte(cmd, (uint8_t)reg, true)); + } + TRY(i2c_master_start(cmd)); + TRY(i2c_master_write_byte(cmd, (addr << 1) | I2C_MASTER_READ, true)); + TRY(i2c_master_read(cmd, read_data, read_len, I2C_MASTER_LAST_NACK)); + TRY(i2c_master_stop(cmd)); + TRY(i2c_master_cmd_begin(I2C_NUM_0, cmd, pdMS_TO_TICKS(500))); + i2c_cmd_link_delete(cmd); + return true; + +fail: + ESP_LOGE(__func__, "Read from 0x%02x failed. reg=%d, err=0x%x\n", addr, reg, err); + return false; +} +#elif CONFIG_TARGET_ESPLAY_S3 + #define TRY(x) if ((err = (x)) != ESP_OK) { goto fail; } + static bool rg_i2c_read(uint8_t addr, int reg, void *read_data, size_t read_len) { esp_err_t err = ESP_FAIL; @@ -52,7 +78,7 @@ uint32_t input_read_raw(void) { uint32_t state = 0; -#ifdef TARGET_MRGC_G32 +#ifdef CONFIG_TARGET_MRGC_G32 uint8_t data[5]; if (rg_i2c_read(0x20, -1, &data, 5)) { @@ -69,6 +95,23 @@ uint32_t input_read_raw(void) if (buttons & (1 << 6)) state |= (1 << ODROID_INPUT_A); if (buttons & (1 << 7)) state |= (1 << ODROID_INPUT_B); } +#elif CONFIG_TARGET_ESPLAY_S3 + uint8_t data[5]; + if (rg_i2c_read(0x20, -1, &data, 5)) + { + int buttons = ~((data[2] << 8) | data[1]); + + if (buttons & (1 << 2)) state |= (1 << ODROID_INPUT_UP); + if (buttons & (1 << 3)) state |= (1 << ODROID_INPUT_DOWN); + if (buttons & (1 << 4)) state |= (1 << ODROID_INPUT_LEFT); + if (buttons & (1 << 5)) state |= (1 << ODROID_INPUT_RIGHT); + if (buttons & gpio_get_level(RG_GPIO_GAMEPAD_MENU)) state |= (1 << ODROID_INPUT_MENU); + if (buttons & (1 << 1)) state |= (1 << ODROID_INPUT_SELECT); + if (buttons & (1 << 0)) state |= (1 << ODROID_INPUT_START); + if (buttons & (1 << 6)) state |= (1 << ODROID_INPUT_A); + if (buttons & (1 << 7)) state |= (1 << ODROID_INPUT_B); +// printf("input_read_raw: %#X\n",state); + } #else int joyX = adc1_get_raw(ODROID_GAMEPAD_IO_X); int joyY = adc1_get_raw(ODROID_GAMEPAD_IO_Y); @@ -165,12 +208,12 @@ static void input_task(void *arg) void input_init(void) { -#ifdef TARGET_MRGC_G32 +#ifdef CONFIG_TARGET_MRGC_G32 const i2c_config_t i2c_config = { .mode = I2C_MODE_MASTER, - .sda_io_num = GPIO_NUM_21, + .sda_io_num = RG_GPIO_I2C_SDA, .sda_pullup_en = GPIO_PULLUP_ENABLE, - .scl_io_num = GPIO_NUM_22, + .scl_io_num = RG_GPIO_I2C_SCL, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master.clk_speed = 200000, }; @@ -180,26 +223,43 @@ void input_init(void) TRY(i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0)); ESP_LOGI(__func__, "I2C driver ready (SDA:%d SCL:%d).\n", i2c_config.sda_io_num, i2c_config.scl_io_num); fail: +#elif CONFIG_TARGET_ESPLAY_S3 + const i2c_config_t i2c_config = { + .mode = I2C_MODE_MASTER, + .sda_io_num = RG_GPIO_I2C_SDA, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_io_num = RG_GPIO_I2C_SCL, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .master.clk_speed = 400000, + }; + esp_err_t err = ESP_FAIL; + + TRY(i2c_param_config(I2C_NUM_0, &i2c_config)); + TRY(i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0)); + ESP_LOGI(__func__, "I2C driver ready (SDA:%d SCL:%d).\n", i2c_config.sda_io_num, i2c_config.scl_io_num); + + gpio_set_direction(RG_GPIO_GAMEPAD_MENU, GPIO_MODE_INPUT); + fail: #else - gpio_set_direction(ODROID_GAMEPAD_IO_SELECT, GPIO_MODE_INPUT); - gpio_set_pull_mode(ODROID_GAMEPAD_IO_SELECT, GPIO_PULLUP_ONLY); + gpio_set_direction(RG_GPIO_GAMEPAD_SELECT, GPIO_MODE_INPUT); + gpio_set_pull_mode(RG_GPIO_GAMEPAD_SELECT, GPIO_PULLUP_ONLY); - gpio_set_direction(ODROID_GAMEPAD_IO_START, GPIO_MODE_INPUT); + gpio_set_direction(RG_GPIO_GAMEPAD_START, GPIO_MODE_INPUT); - gpio_set_direction(ODROID_GAMEPAD_IO_A, GPIO_MODE_INPUT); - gpio_set_pull_mode(ODROID_GAMEPAD_IO_A, GPIO_PULLUP_ONLY); + gpio_set_direction(RG_GPIO_GAMEPAD_A, GPIO_MODE_INPUT); + gpio_set_pull_mode(RG_GPIO_GAMEPAD_A, GPIO_PULLUP_ONLY); - gpio_set_direction(ODROID_GAMEPAD_IO_B, GPIO_MODE_INPUT); - gpio_set_pull_mode(ODROID_GAMEPAD_IO_B, GPIO_PULLUP_ONLY); + gpio_set_direction(RG_GPIO_GAMEPAD_B, GPIO_MODE_INPUT); + gpio_set_pull_mode(RG_GPIO_GAMEPAD_B, GPIO_PULLUP_ONLY); adc1_config_width(ADC_WIDTH_12Bit); - adc1_config_channel_atten(ODROID_GAMEPAD_IO_X, ADC_ATTEN_11db); - adc1_config_channel_atten(ODROID_GAMEPAD_IO_Y, ADC_ATTEN_11db); + adc1_config_channel_atten(RG_GPIO_GAMEPAD_X, ADC_ATTEN_11db); + adc1_config_channel_atten(RG_GPIO_GAMEPAD_Y, ADC_ATTEN_11db); - gpio_set_direction(ODROID_GAMEPAD_IO_MENU, GPIO_MODE_INPUT); - gpio_set_pull_mode(ODROID_GAMEPAD_IO_MENU, GPIO_PULLUP_ONLY); + gpio_set_direction(RG_GPIO_GAMEPAD_MENU, GPIO_MODE_INPUT); + gpio_set_pull_mode(RG_GPIO_GAMEPAD_MENU, GPIO_PULLUP_ONLY); - gpio_set_direction(ODROID_GAMEPAD_IO_VOLUME, GPIO_MODE_INPUT); +// gpio_set_direction(RG_GPIO_GAMEPAD_VOLUME, GPIO_MODE_INPUT); #endif // Start background polling diff --git a/main/input.h b/main/input.h index b76f05c..21e9443 100644 --- a/main/input.h +++ b/main/input.h @@ -1,7 +1,6 @@ #pragma once - #include - +#include enum { ODROID_INPUT_UP = 0, diff --git a/main/main.c b/main/main.c index d9f201d..54fada4 100644 --- a/main/main.c +++ b/main/main.c @@ -57,7 +57,7 @@ #define BATTERY_VMAX (4.20f) #define BATTERY_VMIN (3.30f) -#define ITEM_COUNT ((SCREEN_HEIGHT-32)/52) +#define ITEM_COUNT ((RG_SCREEN_HEIGHT-32)/52) #define ALIGN_ADDRESS(val, alignment) (((val & (alignment-1)) != 0) ? (val & ~(alignment-1)) + alignment : val) #define SET_STATUS_LED(on) gpio_set_level(GPIO_NUM_2, on); @@ -135,7 +135,7 @@ static int apps_count = -1; static int apps_max = 4; static int apps_seq = 0; static int firstAppOffset = 0x100000; // We scan the table to find the real value but this is a reasonable default -static uint16_t fb[SCREEN_WIDTH * SCREEN_HEIGHT]; +static uint16_t fb[RG_SCREEN_WIDTH * RG_SCREEN_HEIGHT]; static UG_GUI gui; static esp_err_t sdcardret; static nvs_handle nvs_h; @@ -144,7 +144,7 @@ static float read_battery(void); static void pset(UG_S16 x, UG_S16 y, UG_COLOR color) { - fb[y * SCREEN_WIDTH + x] = color; + fb[y * RG_SCREEN_WIDTH + x] = color; } static void UpdateDisplay(void) @@ -154,24 +154,24 @@ static void UpdateDisplay(void) static void DisplayCenter(int top, const char *str) { - const int maxlen = SCREEN_WIDTH / (gui.font.char_width + 1); - int left = RG_MAX(0, (SCREEN_WIDTH - strlen(str) * (gui.font.char_width + 1)) / 2); + const int maxlen = RG_SCREEN_WIDTH / (gui.font.char_width + 1); + int left = RG_MAX(0, (RG_SCREEN_WIDTH - strlen(str) * (gui.font.char_width + 1)) / 2); int height = gui.font.char_height + 4 + 4; char tempstring[128] = {0}; - UG_FillFrame(0, top, SCREEN_WIDTH-1, top + height - 1, UG_GetBackcolor()); + UG_FillFrame(0, top, RG_SCREEN_WIDTH-1, top + height - 1, UG_GetBackcolor()); UG_PutString(left, top + 4 , strncpy(tempstring, str, maxlen)); } static void DisplayPage(const char *title, const char *footer) { - UG_FillFrame(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, C_WHITE); + UG_FillFrame(0, 0, RG_SCREEN_WIDTH-1, RG_SCREEN_HEIGHT-1, C_WHITE); UG_FontSelect(&FONT_8X8); UG_SetBackcolor(C_MIDNIGHT_BLUE); UG_SetForecolor(C_WHITE); DisplayCenter(0, title); UG_SetForecolor(C_LIGHT_GRAY); - DisplayCenter(SCREEN_HEIGHT - 16, footer); + DisplayCenter(RG_SCREEN_HEIGHT - 16, footer); } static void DisplayIndicators(int page, int totalPages) @@ -188,7 +188,7 @@ static void DisplayIndicators(int page, int totalPages) // Battery indicator int percent = (read_battery() - BATTERY_VMIN) / (BATTERY_VMAX - BATTERY_VMIN) * 100.f; sprintf(tempstring, "%d%%", RG_MIN(100, RG_MAX(0, percent))); - UG_PutString(SCREEN_WIDTH - (9 * strlen(tempstring)) - 4, 4, tempstring); + UG_PutString(RG_SCREEN_WIDTH - (9 * strlen(tempstring)) - 4, 4, tempstring); } static void DisplayError(const char *message) @@ -196,7 +196,7 @@ static void DisplayError(const char *message) UG_FontSelect(&FONT_8X12); UG_SetForecolor(C_RED); UG_SetBackcolor(C_WHITE); - DisplayCenter((SCREEN_HEIGHT / 2) - (12 / 2), message); + DisplayCenter((RG_SCREEN_HEIGHT / 2) - (12 / 2), message); UpdateDisplay(); } @@ -205,7 +205,7 @@ static void DisplayMessage(const char *message) UG_FontSelect(&FONT_8X12); UG_SetForecolor(C_BLACK); UG_SetBackcolor(C_WHITE); - DisplayCenter((SCREEN_HEIGHT / 2) + 8 + (12 / 2) + 16, message); + DisplayCenter((RG_SCREEN_HEIGHT / 2) + 8 + (12 / 2) + 16, message); UpdateDisplay(); } @@ -214,7 +214,7 @@ static void DisplayNotification(const char *message) UG_FontSelect(&FONT_8X8); UG_SetForecolor(C_WHITE); UG_SetBackcolor(C_BLUE); - DisplayCenter(SCREEN_HEIGHT - 16, message); + DisplayCenter(RG_SCREEN_HEIGHT - 16, message); UpdateDisplay(); } @@ -223,8 +223,8 @@ static void DisplayProgress(int percent) const int WIDTH = 200; const int HEIGHT = 12; const int FILL_WIDTH = WIDTH * ((percent > 100 ? 100 : percent) / 100.0f); - int left = (SCREEN_WIDTH / 2) - (WIDTH / 2); - int top = (SCREEN_HEIGHT / 2) - (HEIGHT / 2) + 16; + int left = (RG_SCREEN_WIDTH / 2) - (WIDTH / 2); + int top = (RG_SCREEN_HEIGHT / 2) - (HEIGHT / 2) + 16; UG_FillFrame(left - 1, top - 1, left + WIDTH + 1, top + HEIGHT + 1, C_WHITE); UG_DrawFrame(left - 1, top - 1, left + WIDTH + 1, top + HEIGHT + 1, C_BLACK); if (FILL_WIDTH > 0) @@ -233,36 +233,36 @@ static void DisplayProgress(int percent) static void DisplayFooter(const char *message) { - int left = (SCREEN_WIDTH / 2) - (strlen(message) * 9 / 2); - int top = SCREEN_HEIGHT - (16 * 2) - 8; + int left = (RG_SCREEN_WIDTH / 2) - (strlen(message) * 9 / 2); + int top = RG_SCREEN_HEIGHT - (16 * 2) - 8; UG_FontSelect(&FONT_8X12); UG_SetForecolor(C_BLACK); UG_SetBackcolor(C_WHITE); - UG_FillFrame(0, top, SCREEN_WIDTH-1, top + 12, C_WHITE); + UG_FillFrame(0, top, RG_SCREEN_WIDTH-1, top + 12, C_WHITE); UG_PutString(left, top, message); } static void DisplayHeader(const char *message) { - int left = (SCREEN_WIDTH / 2) - (strlen(message) * 9 / 2); + int left = (RG_SCREEN_WIDTH / 2) - (strlen(message) * 9 / 2); int top = (16 + 8); UG_FontSelect(&FONT_8X12); UG_SetForecolor(C_BLACK); UG_SetBackcolor(C_WHITE); - UG_FillFrame(0, top, SCREEN_WIDTH-1, top + 12, C_WHITE); + UG_FillFrame(0, top, RG_SCREEN_WIDTH-1, top + 12, C_WHITE); UG_PutString(left, top, message); } static void DisplayRow(int line, const char *line1, const char *line2, uint16_t color, const uint16_t *tile, bool selected) { - const int margin = SCREEN_WIDTH > 240 ? 6 : 2; + const int margin = RG_SCREEN_WIDTH > 240 ? 6 : 2; const int itemHeight = 52; const int textLeft = margin + FIRMWARE_TILE_WIDTH + margin; const int top = 16 + (line * itemHeight) - 1; UG_FontSelect(&FONT_8X12); UG_SetBackcolor(selected ? C_YELLOW : C_WHITE); - UG_FillFrame(0, top + 2, SCREEN_WIDTH-1, top + itemHeight - 1 - 1, UG_GetBackcolor()); + UG_FillFrame(0, top + 2, RG_SCREEN_WIDTH-1, top + itemHeight - 1 - 1, UG_GetBackcolor()); UG_SetForecolor(C_BLACK); UG_PutString(textLeft, top + 2 + 2 + 7, line1); UG_SetForecolor(color); @@ -820,7 +820,7 @@ static void flash_firmware(const char *fullPath) DisplayMessage("[START]"); DisplayFooter("[B] Cancel"); - int tileLeft = (SCREEN_WIDTH / 2) - (FIRMWARE_TILE_WIDTH / 2); + int tileLeft = (RG_SCREEN_WIDTH / 2) - (FIRMWARE_TILE_WIDTH / 2); int tileTop = (16 + 16 + 16); for (int i = 0 ; i < FIRMWARE_TILE_HEIGHT; ++i) @@ -1101,8 +1101,8 @@ static int ui_choose_dialog(dialog_option_t *options, int optionCount, bool canc while (true) { - int top = (SCREEN_HEIGHT - height) / 2; - int left = (SCREEN_WIDTH - width) / 2; + int top = (RG_SCREEN_HEIGHT - height) / 2; + int left = (RG_SCREEN_WIDTH - width) / 2; UG_FillFrame(left, top, left + width, top + height, C_BLUE); UG_FillFrame(left + border, top + border, left + width - border, top + height - border, C_WHITE); @@ -1414,7 +1414,7 @@ void app_main(void) ili9341_init(); input_init(); - UG_Init(&gui, pset, SCREEN_WIDTH, SCREEN_HEIGHT); + UG_Init(&gui, pset, RG_SCREEN_WIDTH, RG_SCREEN_HEIGHT); SET_STATUS_LED(0); diff --git a/main/sdcard.c b/main/sdcard.c index 79b9058..0c54653 100644 --- a/main/sdcard.c +++ b/main/sdcard.c @@ -18,13 +18,23 @@ extern esp_err_t ff_diskio_get_drive(BYTE* out_pdrv); extern void ff_diskio_register_sdmmc(unsigned char pdrv, sdmmc_card_t* card); -#ifdef TARGET_MRGC_G32 +#ifdef CONFIG_TARGET_MRGC_G32 #define DECLARE_SDCARD_CONFIG() \ sdmmc_host_t host_config = SDMMC_HOST_DEFAULT(); \ host_config.flags = SDMMC_HOST_FLAG_1BIT; \ host_config.max_freq_khz = SDMMC_FREQ_HIGHSPEED; \ sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT(); \ slot_config.width = 1; +#elif CONFIG_TARGET_ESPLAY_S3 +#define DECLARE_SDCARD_CONFIG() \ + sdmmc_host_t host_config = SDMMC_HOST_DEFAULT(); \ + host_config.flags = SDMMC_HOST_FLAG_1BIT; \ + host_config.max_freq_khz = SDMMC_FREQ_DEFAULT; \ + sdmmc_slot_config_t slot_config = { \ + .width = 1, .flags = 0, \ + .d0 = RG_GPIO_SDSPI_D0, .d1 = -1, .d2 = -1, .d3 = -1, .d4 = -1, .d5 = -1, .d6 = -1, .d7 = -1, \ + .clk = RG_GPIO_SDSPI_CLK, .cmd = RG_GPIO_SDSPI_CMD, .cd = -1, .wp = -1,}; \ + slot_config.width = 1; #else #define DECLARE_SDCARD_CONFIG() \ sdmmc_host_t host_config = SDSPI_HOST_DEFAULT(); \ @@ -153,14 +163,23 @@ void odroid_sdcard_files_free(char** files, int count) esp_err_t odroid_sdcard_open(void) { DECLARE_SDCARD_CONFIG(); - +#if RG_SDSPI_HIGHSPEED == 1 + host_config.max_freq_khz = SDMMC_FREQ_HIGHSPEED; +#endif esp_vfs_fat_sdmmc_mount_config_t mount_config = { .format_if_mount_failed = false, .max_files = 5, +#ifdef CONFIG_TARGET_ESPLAY_S3 + .allocation_unit_size = 32 * 1024 +#endif }; esp_err_t ret = esp_vfs_fat_sdmmc_mount(SDCARD_BASE_PATH, &host_config, &slot_config, &mount_config, NULL); - +#ifdef CONFIG_TARGET_ESPLAY_S3 + if (ret != ESP_OK){ + ESP_LOGE(__func__, "esp_vfs_fat_sdmmc_mount failed (%d)", ret); + } +#else if (ret == ESP_OK || ret == ESP_ERR_INVALID_STATE) { ret = ESP_OK; @@ -169,7 +188,7 @@ esp_err_t odroid_sdcard_open(void) { ESP_LOGE(__func__, "esp_vfs_fat_sdmmc_mount failed (%d)", ret); } - +#endif return ret; } @@ -214,8 +233,10 @@ esp_err_t odroid_sdcard_format(int fs_type) goto _cleanup; } -#ifdef TARGET_MRGC_G32 +#ifdef CONFIG_TARGET_MRGC_G32 err = sdmmc_host_init_slot(host_config.slot, &slot_config); +#elif CONFIG_TARGET_ESPLAY_S3 + err = sdmmc_host_init_slot(host_config.slot,&slot_config); #else err = sdspi_host_init_slot(host_config.slot, &slot_config); #endif diff --git a/main/sdcard.h b/main/sdcard.h index cff47cd..a982546 100644 --- a/main/sdcard.h +++ b/main/sdcard.h @@ -1,7 +1,6 @@ #pragma once - #include "esp_err.h" - +#include "target.h" #define SDCARD_BASE_PATH "/sd" esp_err_t odroid_sdcard_open(void); diff --git a/main/target.h b/main/target.h new file mode 100644 index 0000000..d5b7eff --- /dev/null +++ b/main/target.h @@ -0,0 +1,249 @@ +// REF: https://wiki.odroid.com/odroid_go/odroid_go +#include "sdkconfig.h" +#if defined(CONFIG_TARGET_ODROID_GO) +// Target definition +#define RG_TARGET_NAME "ODROID-GO" + +// Storage and Settings +#define RG_STORAGE_DRIVER 1 // 1 = SDSPI, 2 = SDMMC, 3 = USB +#define RG_SETTINGS_USE_NVS 0 + +// Video +#define RG_SCREEN_DRIVER 0 // 0 = ILI9341 +#define RG_SCREEN_TYPE 32 +#define RG_SCREEN_WIDTH 320 +#define RG_SCREEN_HEIGHT 240 +#define RG_SCREEN_ROTATE 0 +#define RG_SCREEN_MARGIN_TOP 0 +#define RG_SCREEN_MARGIN_BOTTOM 0 +#define RG_SCREEN_MARGIN_LEFT 0 +#define RG_SCREEN_MARGIN_RIGHT 20 + +// Input +#define RG_GAMEPAD_DRIVER 1 // 1 = ODROID-GO, 2 = Serial, 3 = MRGC-IO +#define RG_GAMEPAD_HAS_MENU_BTN 1 +#define RG_GAMEPAD_HAS_OPTION_BTN 0 +#define RG_BATTERY_ADC_CHANNEL ADC1_CHANNEL_0 +#define RG_BATTERY_CALC_PERCENT(raw) (((raw) * 2.f - 3500.f) / (4200.f - 3500.f) * 100.f) +#define RG_BATTERY_CALC_VOLTAGE(raw) ((raw) * 2.f * 0.001f) + +// Status LED +#define RG_GPIO_LED GPIO_NUM_2 + +// I2C BUS +// #define RG_GPIO_I2C_SDA GPIO_NUM_15 +// #define RG_GPIO_I2C_SCL GPIO_NUM_4 + +// Built-in gamepad +#define RG_GPIO_GAMEPAD_X ADC1_CHANNEL_6 +#define RG_GPIO_GAMEPAD_Y ADC1_CHANNEL_7 +#define RG_GPIO_GAMEPAD_SELECT GPIO_NUM_27 +#define RG_GPIO_GAMEPAD_START GPIO_NUM_39 +#define RG_GPIO_GAMEPAD_A GPIO_NUM_32 +#define RG_GPIO_GAMEPAD_B GPIO_NUM_33 +#define RG_GPIO_GAMEPAD_MENU GPIO_NUM_13 +#define RG_GPIO_GAMEPAD_OPTION GPIO_NUM_0 + +// SNES-style gamepad +// #define RG_GPIO_GAMEPAD_LATCH GPIO_NUM_NC +// #define RG_GPIO_GAMEPAD_CLOCK GPIO_NUM_NC +// #define RG_GPIO_GAMEPAD_DATA GPIO_NUM_NC + +// SPI Display +#define RG_GPIO_LCD_HOST SPI2_HOST +#define RG_GPIO_LCD_MISO GPIO_NUM_19 +#define RG_GPIO_LCD_MOSI GPIO_NUM_23 +#define RG_GPIO_LCD_CLK GPIO_NUM_18 +#define RG_GPIO_LCD_CS GPIO_NUM_5 +#define RG_GPIO_LCD_DC GPIO_NUM_21 +#define RG_GPIO_LCD_BCKL GPIO_NUM_14 + +// SPI SD Card +#define RG_GPIO_SDSPI_HOST SPI2_HOST +#define RG_GPIO_SDSPI_MISO GPIO_NUM_19 +#define RG_GPIO_SDSPI_MOSI GPIO_NUM_23 +#define RG_GPIO_SDSPI_CLK GPIO_NUM_18 +#define RG_GPIO_SDSPI_CS GPIO_NUM_22 +#elif defined(CONFIG_TARGET_MRGC_G32) +// Parts: +// - ESP32-WROVER-B (SoC) +// - STM32F071cbu7 (Apparently buttons, charging, LED, backlight?) +// - NXP 1334A (I2S DAC) +// - CS5082E (Power controller) +// - P8302E (Amplifier) +// - YT280S002 (ILI9341 LCD) +// + +/** + * IO35 - MENU BTN + * IO25 - I2S DAC + * IO26 - I2S DAC + * IO15 - SD CARD + * IO2 - SD CARD + * IO0 - SELECT BTN + * IO4 - AMP EN + * IO5 - LCD SPI CS + * IO12 - LCD DC + * IO18 - SPI CLK + * IO23 - SPI MOSI + * IO21 - STM32F (I2C) + * IO22 - STM32F (I2C) + * + * IO27 - resistor then STM32? + * + * Power LED is connected to the STM32 + */ + +// Target definition +#define RG_TARGET_NAME "MRGC-G32" + +// Storage +#define RG_STORAGE_DRIVER 2 // 1 = SDSPI, 2 = SDMMC, 3 = USB + +// Video +#define RG_SCREEN_DRIVER 0 // 0 = ILI9341 +#define RG_SCREEN_TYPE 1 +#define RG_SCREEN_WIDTH 240 +#define RG_SCREEN_HEIGHT 320 +#define RG_SCREEN_ROTATE 0 +#define RG_SCREEN_MARGIN_TOP 28 +#define RG_SCREEN_MARGIN_BOTTOM 68 +#define RG_SCREEN_MARGIN_LEFT 0 +#define RG_SCREEN_MARGIN_RIGHT 0 + +// Input +#define RG_GAMEPAD_DRIVER 3 // 1 = ODROID-GO, 2 = Serial, 3 = MRGC-IO +#define RG_GAMEPAD_HAS_MENU_BTN 1 +#define RG_GAMEPAD_HAS_OPTION_BTN 0 +// #define RG_BATTERY_ADC_CHANNEL ADC1_CHANNEL_0 +#define RG_BATTERY_CALC_PERCENT(raw) (((raw) - 170) / 30.f * 100.f) +#define RG_BATTERY_CALC_VOLTAGE(raw) (0) + +// Status LED +// #define RG_GPIO_LED GPIO_NUM_NC + +// I2C BUS +#define RG_GPIO_I2C_SDA GPIO_NUM_21 +#define RG_GPIO_I2C_SCL GPIO_NUM_22 + +// Display +#define RG_GPIO_LCD_HOST SPI2_HOST +#define RG_GPIO_LCD_MISO GPIO_NUM_NC +#define RG_GPIO_LCD_MOSI GPIO_NUM_23 +#define RG_GPIO_LCD_CLK GPIO_NUM_18 +#define RG_GPIO_LCD_CS GPIO_NUM_5 +#define RG_GPIO_LCD_DC GPIO_NUM_12 +#define RG_GPIO_LCD_BCKL GPIO_NUM_27 +#elif defined(CONFIG_TARGET_RETRO_ESP32) +// Target definition +#define RG_TARGET_NAME "ODROID-GO" + +// Storage and Settings +#define RG_STORAGE_DRIVER 1 // 1 = SDSPI, 2 = SDMMC, 3 = USB +#define RG_SETTINGS_USE_NVS 0 + +// Video +#define RG_SCREEN_DRIVER 0 // 0 = ILI9341 +#define RG_SCREEN_TYPE 32 +#define RG_SCREEN_WIDTH 320 +#define RG_SCREEN_HEIGHT 240 +#define RG_SCREEN_ROTATE 0 +#define RG_SCREEN_MARGIN_TOP 0 +#define RG_SCREEN_MARGIN_BOTTOM 0 +#define RG_SCREEN_MARGIN_LEFT 0 +#define RG_SCREEN_MARGIN_RIGHT 20 + +// Input +#define RG_GAMEPAD_DRIVER 1 // 1 = ODROID-GO, 2 = Serial, 3 = MRGC-IO +#define RG_GAMEPAD_HAS_MENU_BTN 1 +#define RG_GAMEPAD_HAS_OPTION_BTN 0 +#define RG_BATTERY_ADC_CHANNEL ADC1_CHANNEL_0 +#define RG_BATTERY_CALC_PERCENT(raw) (((raw) * 2.f - 3500.f) / (4200.f - 3500.f) * 100.f) +#define RG_BATTERY_CALC_VOLTAGE(raw) ((raw) * 2.f * 0.001f) + +// Status LED +#define RG_GPIO_LED GPIO_NUM_2 + +// I2C BUS +// #define RG_GPIO_I2C_SDA GPIO_NUM_15 +// #define RG_GPIO_I2C_SCL GPIO_NUM_4 + +// Built-in gamepad +#define RG_GPIO_GAMEPAD_X ADC1_CHANNEL_6 +#define RG_GPIO_GAMEPAD_Y ADC1_CHANNEL_7 +#define RG_GPIO_GAMEPAD_SELECT GPIO_NUM_27 +#define RG_GPIO_GAMEPAD_START GPIO_NUM_39 +#define RG_GPIO_GAMEPAD_A GPIO_NUM_32 +#define RG_GPIO_GAMEPAD_B GPIO_NUM_33 +#define RG_GPIO_GAMEPAD_MENU GPIO_NUM_13 +#define RG_GPIO_GAMEPAD_OPTION GPIO_NUM_0 + +// SPI Display +#define RG_GPIO_LCD_HOST SPI2_HOST +#define RG_GPIO_LCD_MISO GPIO_NUM_19 +#define RG_GPIO_LCD_MOSI GPIO_NUM_23 +#define RG_GPIO_LCD_CLK GPIO_NUM_18 +#define RG_GPIO_LCD_CS GPIO_NUM_5 +#define RG_GPIO_LCD_DC GPIO_NUM_21 +#define RG_GPIO_LCD_BCKL GPIO_NUM_14 + +// SPI SD Card +#define RG_GPIO_SDSPI_HOST SPI2_HOST +#define RG_GPIO_SDSPI_MISO GPIO_NUM_19 +#define RG_GPIO_SDSPI_MOSI GPIO_NUM_23 +#define RG_GPIO_SDSPI_CLK GPIO_NUM_18 +#define RG_GPIO_SDSPI_CS GPIO_NUM_22 +#elif defined(CONFIG_TARGET_ESPLAY_S3) +// Target definition +#define RG_TARGET_NAME "ESPLAY-S3" + +// Storage +#define RG_STORAGE_DRIVER 2 // 1 = SDSPI, 2 = SDMMC, 3 = USB + +// Video +#define RG_SCREEN_DRIVER 0 // 0 = ILI9341 +#define RG_SCREEN_TYPE 4 // 4 = ESPLAY-ST7789V2 +#define RG_SCREEN_WIDTH 320 +#define RG_SCREEN_HEIGHT 240 +#define RG_SCREEN_ROTATE 0 +#define RG_SCREEN_MARGIN_TOP 0 +#define RG_SCREEN_MARGIN_BOTTOM 0 +#define RG_SCREEN_MARGIN_LEFT 0 +#define RG_SCREEN_MARGIN_RIGHT 0 + +// Input +#define RG_GAMEPAD_DRIVER 5 // 1 = ODROID-GO, 2 = Serial, 3 = MRGC-IO 5 = ESPLAY +#define RG_GAMEPAD_HAS_MENU_BTN 1 +#define RG_GAMEPAD_HAS_OPTION_BTN 1 +#define RG_BATTERY_ADC_CHANNEL ADC1_CHANNEL_3 +#define RG_BATTERY_CALC_PERCENT(raw) (((raw) * 2.f - 3500.f) / (4200.f - 3500.f) * 100.f) +#define RG_BATTERY_CALC_VOLTAGE(raw) ((raw) * 2.f * 0.001f) + +// Status LED +#define RG_GPIO_LED GPIO_NUM_38 + +// I2C BUS +#define RG_GPIO_I2C_SDA GPIO_NUM_48 +#define RG_GPIO_I2C_SCL GPIO_NUM_47 + +// Built-in gamepad +#define RG_GPIO_GAMEPAD_L GPIO_NUM_2 +#define RG_GPIO_GAMEPAD_R GPIO_NUM_5 +#define RG_GPIO_GAMEPAD_MENU GPIO_NUM_9 + +// SPI Display +#define RG_GPIO_LCD_HOST SPI2_HOST +#define RG_GPIO_LCD_MISO GPIO_NUM_NC +#define RG_GPIO_LCD_MOSI GPIO_NUM_11 +#define RG_GPIO_LCD_CLK GPIO_NUM_14 +#define RG_GPIO_LCD_CS GPIO_NUM_12 +#define RG_GPIO_LCD_DC GPIO_NUM_13 +#define RG_GPIO_LCD_BCKL GPIO_NUM_10 +#define RG_GPIO_LCD_RST GPIO_NUM_21 + +// SPI SD Card +#define RG_GPIO_SDSPI_CMD GPIO_NUM_41 +#define RG_GPIO_SDSPI_CLK GPIO_NUM_40 +#define RG_GPIO_SDSPI_D0 GPIO_NUM_39 +#define RG_SDSPI_HIGHSPEED 0 +#endif diff --git a/sdkconfig.defaults.esp32s3 b/sdkconfig.defaults.esp32s3 new file mode 100644 index 0000000..ebc62fe --- /dev/null +++ b/sdkconfig.defaults.esp32s3 @@ -0,0 +1,134 @@ +# +# Automatically generated file. DO NOT EDIT. +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_CMAKE=y +CONFIG_IDF_TARGET_ARCH_XTENSA=y +CONFIG_IDF_TARGET="esp32s3" +CONFIG_IDF_TARGET_ESP32S3=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009 + +# +# SDK tool configuration +# +CONFIG_SDK_TOOLPREFIX="xtensa-esp32s3-elf-" +# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set +# end of SDK tool configuration + +# +# Build type +# +CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y +# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set +CONFIG_APP_BUILD_GENERATE_BINARIES=y +CONFIG_APP_BUILD_BOOTLOADER=y +CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y +# end of Build type + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_FLASHMODE_QIO=y +CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y +CONFIG_ESPTOOLPY_FLASHMODE="dio" +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +CONFIG_ESPTOOLPY_FLASHFREQ="80m" +CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="8MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +# end of Serial flasher config + +# +# Partition Table +# +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +# end of Partition Table + +# +# Hardware configuration +# +CONFIG_TARGET_ESPLAY_S3=y +# end of Hardware configuration + +# +# ESP-TLS +# +CONFIG_ESP_TLS_USING_MBEDTLS=y +CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y +# end of ESP-TLS + +# +# ESP32S3-Specific +# +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240 + +# +# Cache config +# +CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y +CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x8000 +CONFIG_ESP32S3_INSTRUCTION_CACHE_4WAYS=y +CONFIG_ESP32S3_ICACHE_ASSOCIATED_WAYS=4 +CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_32B=y +CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_SIZE=32 +CONFIG_ESP32S3_DATA_CACHE_64KB=y +CONFIG_ESP32S3_DATA_CACHE_SIZE=0x10000 +CONFIG_ESP32S3_DATA_CACHE_4WAYS=y +CONFIG_ESP32S3_DCACHE_ASSOCIATED_WAYS=4 +CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y +CONFIG_ESP32S3_DATA_CACHE_LINE_SIZE=64 +# end of Cache config + +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +CONFIG_SPIRAM_MODE_OCT=y +CONFIG_SPIRAM_TYPE_AUTO=y +CONFIG_SPIRAM_SIZE=-1 + +# +# PSRAM Clock and CS IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM Clock and CS IO for ESP32S3 + +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +CONFIG_SPIRAM_USE_MALLOC=y +CONFIG_SPIRAM_MEMTEST=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 +# end of SPI RAM config + +CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM=0x0 +CONFIG_ESP32S3_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32S3_DEBUG_OCDAWARE=y +CONFIG_ESP32S3_BROWNOUT_DET=y +CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y +CONFIG_ESP32S3_BROWNOUT_DET_LVL=7 +CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_FRC1=y +CONFIG_ESP32S3_RTC_CLK_SRC_INT_RC=y +CONFIG_ESP32S3_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000 +# end of ESP32S3-Specific + +# +# SPI Flash driver +# +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED=y +CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y +CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 +CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 +CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 +CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y +# end of SPI Flash driver