Skip to content

add some gd32 esp32 riscv addon #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/flash/nand/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SPDX-License-Identifier: GPL-2.0-or-later

add_library(nand STATIC)

target_sources(nand PRIVATE
ecc.c
ecc_kw.c
core.c
fileio.c
tcl.c
arm_io.c
nonce.c
davinci.c
lpc3180.c
lpc32xx.c
mxc.c
mx3.c
orion.c
s3c24xx.c
s3c2410.c
s3c2412.c
s3c2440.c
s3c2443.c
s3c6400.c
at91sam9.c
nuc910.c
driver.c
arm_io.h
core.h
driver.h
fileio.h
imp.h
lpc3180.h
lpc32xx.h
mxc.h
mx3.h
s3c24xx.h
s3c24xx_regs.h
nuc910.h
)

# circular dependency
target_link_libraries(nand PRIVATE openocdflash)
112 changes: 112 additions & 0 deletions src/flash/nor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# SPDX-License-Identifier: GPL-2.0-or-later

add_library(nor STATIC)

target_sources(nor PRIVATE
core.c
tcl.c
aduc702x.c
aducm360.c
ambiqmicro.c
at91sam4.c
at91sam4l.c
at91samd.c
at91sam3.c
at91sam7.c
ath79.c
atsamv.c
atsame5.c
avrf.c
bluenrg-x.c
cc3220sf.c
cc26xx.c
cfi.c
dsp5680xx_flash.c
dw-spi.c
efm32.c
em357.c
eneispif.c
esp_flash.c
esp_xtensa.c
esp_riscv.c
esp32.c
esp32s2.c
esp32c2.c
esp32c3.c
esp32s3.c
esp32c5.c
esp32c6.c
esp32c61.c
esp32h2.c
esp32p4.c
esirisc_flash.c
faux.c
fespi.c
fm3.c
fm4.c
jtagspi.c
kinetis.c
kinetis_ke.c
lpc2000.c
lpc288x.c
lpc2900.c
lpcspifi.c
max32xxx.c
mdr.c
msp432.c
mrvlqspi.c
mspm0.c
niietcm4.c
non_cfi.c
npcx.c
nrf5.c
numicro.c
ocl.c
pic32mx.c
psoc4.c
psoc5lp.c
psoc6.c
qn908x.c
renesas_rpchf.c
rp2040.c
rsl10.c
sfdp.c
sh_qspi.c
sim3x.c
spi.c
stmsmi.c
stmqspi.c
stellaris.c
stm32f1x.c
stm32f2x.c
stm32lx.c
stm32l4x.c
stm32h7x.c
str7x.c
str9x.c
str9xpec.c
swm050.c
tms470.c
virtual.c
w600.c
xcf.c
xmc1xxx.c
xmc4xxx.c
drivers.c
core.h
cc3220sf.h
bluenrg-x.h
cc26xx.h
cfi.h
driver.h
imp.h
non_cfi.h
ocl.h
sfdp.h
spi.h
stm32l4x.h
stmqspi.h
msp432.h
)

target_link_libraries(nor PRIVATE helper)
139 changes: 139 additions & 0 deletions src/flash/nor/esp32.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

/**************************************************************************
* ESP32 flash driver for OpenOCD *
* Copyright (C) 2017 Espressif Systems Ltd. *
***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "imp.h"
#include <target/smp.h>
#include <target/espressif/esp_xtensa_apptrace.h>
#include <target/espressif/esp_xtensa_algorithm.h>
#include <target/espressif/esp_xtensa_smp.h>
#include "esp_xtensa.h"

#define ESP_TARGET_ESP32
#include "esp_stub_config.h"
#undef ESP_TARGET_ESP32

#define ESP32_DROM_LOW 0x3F400000
#define ESP32_DROM_HIGH 0x3F800000
#define ESP32_IROM_LOW 0x400D0000
#define ESP32_IROM_HIGH 0x40400000

#define ESP32_FLASH_SECTOR_SIZE 4096

struct esp32_flash_bank {
struct esp_xtensa_flash_bank esp_xtensa;
};

static bool esp32_is_irom_address(target_addr_t addr)
{
return addr >= ESP32_IROM_LOW && addr < ESP32_IROM_HIGH;
}

static bool esp32_is_drom_address(target_addr_t addr)
{
return addr >= ESP32_DROM_LOW && addr < ESP32_DROM_HIGH;
}

static const struct command_map s_cmd_map[ESP_STUB_CMD_FLASH_MAX_ID + 1] = {
MAKE_CMD_MAP_ENTRIES
};

static const struct esp_flasher_stub_config *esp32_get_stub(struct flash_bank *bank, int cmd)
{
struct esp_flash_bank *esp_info = bank->driver_priv;
if (esp_info->stub_log_enabled)
return s_cmd_map[ESP_STUB_CMD_FLASH_WITH_LOG].config;
return s_cmd_map[cmd].config;
}

/* flash bank <bank_name> esp32 <base> <size> 0 0 <target#>
If <size> is zero flash size will be autodetected, otherwise user value will be used
*/
FLASH_BANK_COMMAND_HANDLER(esp32_flash_bank_command)
{
struct esp32_flash_bank *esp32_info;

if (CMD_ARGC < 6)
return ERROR_COMMAND_SYNTAX_ERROR;

esp32_info = malloc(sizeof(struct esp32_flash_bank));
if (esp32_info == NULL)
return ERROR_FAIL;
int ret = esp_xtensa_flash_init(&esp32_info->esp_xtensa,
ESP32_FLASH_SECTOR_SIZE,
esp_xtensa_smp_run_func_image,
esp32_is_irom_address,
esp32_is_drom_address,
esp32_get_stub,
false);
if (ret != ERROR_OK) {
free(esp32_info);
return ret;
}
bank->driver_priv = esp32_info;
return ERROR_OK;
}

static int esp32_get_info(struct flash_bank *bank, struct command_invocation *cmd)
{
/* TODO: print some flash information */
command_print_sameline(cmd, "Flash driver: ESP32\n");
return ERROR_OK;
}

static const struct command_registration esp32_command_handlers[] = {
{
.name = "esp",
.mode = COMMAND_ANY,
.help = "ESP flash command group",
.usage = "",
.chain = esp_flash_exec_flash_command_handlers,
},
COMMAND_REGISTRATION_DONE
};

static const struct command_registration esp32_legacy_command_handlers[] = {
{
.name = "esp32",
.mode = COMMAND_ANY,
.help = "ESP32 flash command group",
.usage = "",
.chain = esp_flash_exec_flash_command_handlers,
},
COMMAND_REGISTRATION_DONE
};

static const struct command_registration esp32_all_command_handlers[] = {
{
.usage = "",
.chain = esp32_command_handlers,
},
{
.usage = "",
.chain = esp32_legacy_command_handlers,
},
COMMAND_REGISTRATION_DONE
};

const struct flash_driver esp32_flash = {
.name = "esp32",
.commands = esp32_all_command_handlers,
.flash_bank_command = esp32_flash_bank_command,
.erase = esp_algo_flash_erase,
.protect = esp_algo_flash_protect,
.write = esp_algo_flash_write,
.read = esp_algo_flash_read,
.probe = esp_algo_flash_probe,
.auto_probe = esp_algo_flash_auto_probe,
.erase_check = esp_algo_flash_blank_check,
.protect_check = esp_algo_flash_protect_check,
.info = esp32_get_info,
.free_driver_priv = default_flash_free_driver_priv,
};
Loading