Skip to content

Commit 96d57d4

Browse files
committed
change: rename Device ID to Flash ID for better semantic
1 parent 6e50000 commit 96d57d4

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

include/common/flash_impl_get_id_from_rom.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <target/soc_impl.h>
1515

1616
/**
17-
* @brief Sets the correct device_id in the flash config from SPI_MEM_FLASH_RDID in ROM code
17+
* @brief Sets the correct flash_id in the flash config from SPI_MEM_FLASH_RDID in ROM code
1818
*
1919
*/
2020
extern void esp_rom_spi_flash_update_id(void);
@@ -36,20 +36,20 @@ __attribute__((always_inline)) inline static
3636
uint32_t flash_impl_get_id_from_rom(void)
3737
{
3838
esp_rom_spi_flash_update_id();
39-
return stub_target_rom_get_flash_config()->device_id;
39+
return stub_target_rom_get_flash_config()->flash_id;
4040
}
4141

4242
uint32_t stub_target_flash_get_flash_id(void)
4343
{
4444
// TODO: remove dev tracing
45-
STUB_LOG_TRACEF("Uninit ROM's flash_id: 0x%x\n", stub_target_rom_get_flash_config()->device_id);
45+
STUB_LOG_TRACEF("Uninit ROM's flash_id: 0x%x\n", stub_target_rom_get_flash_config()->flash_id);
4646

4747
// TODO: it's just for development. remove this option then
4848
uint32_t rdid = flash_impl_get_id_from_rdid_reg();
4949
(void)rdid;
50-
STUB_LOG_TRACEF("Device ID: 0x%x (from SPI RDID)\n", rdid);
50+
STUB_LOG_TRACEF("Flash ID: 0x%x (from SPI RDID)\n", rdid);
5151

5252
uint32_t id = flash_impl_get_id_from_rom();
53-
STUB_LOG_TRACEF("Device ID: 0x%x (from ROM code)\n", stub_target_rom_get_flash_config()->device_id);
53+
STUB_LOG_TRACEF("Flash ID: 0x%x (from ROM code)\n", stub_target_rom_get_flash_config()->flash_id);
5454
return id;
5555
}

include/common/target_rom.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
#define STUB_FLASH_STATUS_MASK 0xFFFF
1616

1717
typedef struct esp_rom_spiflash_chip {
18-
uint32_t device_id;
18+
uint32_t flash_id;
1919
uint32_t chip_size; // chip size in bytes
2020
uint32_t block_size;
2121
uint32_t sector_size;
2222
uint32_t page_size;
2323
uint32_t status_mask;
2424
} esp_rom_spiflash_chip_t;
2525

26-
extern int esp_rom_spiflash_config_param(uint32_t device_id, uint32_t chip_size,
26+
extern int esp_rom_spiflash_config_param(uint32_t flash_id, uint32_t chip_size,
2727
uint32_t block_size, uint32_t sector_size,
2828
uint32_t page_size, uint32_t status_mask);
2929

src/esp32/src/target_flash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void stub_target_flash_init(void)
148148
uint32_t stub_target_flash_get_flash_id(void)
149149
{
150150
// TODO: remove dev tracing
151-
STUB_LOG_TRACEF("Uninit g_rom_flashchip.device_id: 0x%x\n", g_rom_flashchip.device_id);
151+
STUB_LOG_TRACEF("Uninit g_rom_flashchip.flash_id: 0x%x\n", g_rom_flashchip.flash_id);
152152
uint32_t id = get_id_from_rdid_cmd();
153-
STUB_LOG_TRACEF("Device ID: 0x%x (from SPI RDID)\n", id);
153+
STUB_LOG_TRACEF("Flash ID: 0x%x (from SPI RDID)\n", id);
154154
return id;
155155
}

src/flash.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
#include <target/rom_impl.h> // corresponding implementation for common/target_rom.h
1414
#include <target/flash_impl.h> // corresponding implementation for common/target_flash.h
1515

16-
static uint32_t device_id_to_flash_size(uint32_t device_id)
16+
static uint32_t flash_id_to_flash_size(uint32_t flash_id)
1717
{
1818
// TODO: remove dev tracing
19-
STUB_LOG_TRACEF("device_id: 0x%x\n", device_id);
19+
STUB_LOG_TRACEF("flash_id: 0x%x\n", flash_id);
2020

21-
const uint32_t id = device_id & 0xff;
21+
const uint32_t id = flash_id & 0xff;
2222
switch (id) {
2323
case 0x12: // 256 KB
2424
case 0x13:
@@ -36,7 +36,7 @@ static uint32_t device_id_to_flash_size(uint32_t device_id)
3636
return 32 * 1024 * 1024;
3737
}
3838

39-
STUB_LOGE("Unknown device_id! 0x%x", device_id);
39+
STUB_LOGE("Unknown flash_id! 0x%x", flash_id);
4040
return 0;
4141
}
4242

@@ -47,11 +47,11 @@ void stub_lib_flash_init(void **state)
4747
// TODO: check if we don't need the first initialization?
4848
// how we can check - only via EXTMEM_ICACHE_ENABLE?
4949
stub_target_flash_init();
50-
// TODO: check if we should use "flash_id" instead of "device_id" (see the IDF's bootloader_flash and the esptool's legacy stub)
51-
const uint32_t device_id = stub_target_flash_get_flash_id();
52-
const uint32_t flash_size = device_id_to_flash_size(device_id);
50+
// TODO: check if we should use "flash_id" instead of "flash_id" (see the IDF's bootloader_flash and the esptool's legacy stub)
51+
const uint32_t flash_id = stub_target_flash_get_flash_id();
52+
const uint32_t flash_size = flash_id_to_flash_size(flash_id);
5353
STUB_LOG_TRACEF("Flash size: %d MB\n", flash_size / (1024 * 1024));
54-
stub_target_rom_update_flash_config(device_id, flash_size);
54+
stub_target_rom_update_flash_config(flash_id, flash_size);
5555
STUB_LOG_TRACEF("config_param has been set\n");
5656
}
5757

@@ -64,7 +64,7 @@ void stub_lib_flash_get_info(stub_lib_flash_info_t *info)
6464
{
6565
const esp_rom_spiflash_chip_t * chip = stub_target_rom_get_flash_config();
6666

67-
info->id = chip->device_id;
67+
info->id = chip->flash_id;
6868
info->size = chip->chip_size;
6969
info->block_size = chip->block_size;
7070
info->sector_size = chip->sector_size;

0 commit comments

Comments
 (0)