rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
board_storage.cpp File Reference

Detailed Description

Storage configuration file.

Date
May 27, 2024
Author
Andrey Gusakov, 2023

Definition in file board_storage.cpp.

Functions

bool boardInitMfs ()
 
const MFSConfig * boardGetMfsConfig ()
 

Variables

static NO_CACHE SNORDriver snor1
 
static NO_CACHE snor_nocache_buffer_t snor1buf
 
static const SPIConfig W25SpiCfg
 
static const SNORConfig W25FlashConfig
 
const MFSConfig mfsd_nor_config
 

Function Documentation

◆ boardGetMfsConfig()

const MFSConfig * boardGetMfsConfig ( void  )

Definition at line 131 of file board_storage.cpp.

132{
133 return &mfsd_nor_config;
134}
const MFSConfig mfsd_nor_config

◆ boardInitMfs()

bool boardInitMfs ( void  )

Definition at line 98 of file board_storage.cpp.

99{
100#if SNOR_SHARED_BUS == FALSE
101 spiStart(&EFI_FLASH_SDPID, &W25SpiCfg);
102#endif
103
104 palSetPad(EFI_FLASH_SPI_CS_GPIO, EFI_FLASH_SPI_CS_PIN);
105 palSetPadMode(EFI_FLASH_SPI_CS_GPIO, EFI_FLASH_SPI_CS_PIN,
106 PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
107 palSetPadMode(getBrainPinPort(EFI_FLASH_SPI_SCK), getBrainPinIndex(EFI_FLASH_SPI_SCK),
108 PAL_MODE_ALTERNATE(EFI_FLASH_SPI_AF) | PAL_STM32_OSPEED_HIGHEST);
109 palSetPadMode(getBrainPinPort(EFI_FLASH_SPI_MISO), getBrainPinIndex(EFI_FLASH_SPI_MISO),
110 PAL_MODE_ALTERNATE(EFI_FLASH_SPI_AF) | PAL_STM32_OSPEED_HIGHEST);
111 palSetPadMode(getBrainPinPort(EFI_FLASH_SPI_MOSI), getBrainPinIndex(EFI_FLASH_SPI_MOSI),
112 PAL_MODE_ALTERNATE(EFI_FLASH_SPI_AF) | PAL_STM32_OSPEED_HIGHEST);
113 /* Deactivate WP */
114 palSetPad(getBrainPinPort(EFI_FLASH_WP), getBrainPinIndex(EFI_FLASH_WP));
115 palSetPadMode(getBrainPinPort(EFI_FLASH_WP), getBrainPinIndex(EFI_FLASH_WP),
116 PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
117 /* Deactivate HOLD */
118 palSetPad(getBrainPinPort(EFI_FLASH_HOLD), getBrainPinIndex(EFI_FLASH_HOLD));
119 palSetPadMode(getBrainPinPort(EFI_FLASH_HOLD), getBrainPinIndex(EFI_FLASH_HOLD),
120 PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
121
122 /*
123 * Initializing and starting flash driver.
124 */
125 snorObjectInit(&snor1, &snor1buf);
126 snorStart(&snor1, &W25FlashConfig);
127
128 return true;
129}
static NO_CACHE SNORDriver snor1
static NO_CACHE snor_nocache_buffer_t snor1buf
static const SPIConfig W25SpiCfg
static const SNORConfig W25FlashConfig
int getBrainPinIndex(Gpio brainPin)
ioportid_t getBrainPinPort(brain_pin_e brainPin)
Here is the call graph for this function:

Variable Documentation

◆ mfsd_nor_config

const MFSConfig mfsd_nor_config
Initial value:
= {
.flashp = (BaseFlash *)&snor1,
.erased = 0xFFFFFFFFU,
#if 1
.bank_size = 512 * 1024U,
.bank0_start = 0U,
.bank0_sectors = 128U,
.bank1_start = 128U,
.bank1_sectors = 128U
#else
.bank_size = 64 * 1024U,
.bank0_start = 0U,
.bank0_sectors = 16U,
.bank1_start = 16U,
.bank1_sectors = 16U
#endif
}

Definition at line 73 of file board_storage.cpp.

73 {
74 .flashp = (BaseFlash *)&snor1,
75 .erased = 0xFFFFFFFFU,
76#if 1
77 /* it takes:
78 * 147 mS to write 25K of settings whithout garbage collector (when there is free space in current bank)
79 * 4750 mS to write settings with garbage collection (packing and moving to another bank, erasing old one)
80 * GC happens rougly every ((512 / 25) - 1) ~= 19 write */
81 .bank_size = 512 * 1024U,
82 .bank0_start = 0U,
83 .bank0_sectors = 128U, /* 128 * 4 K = 0.5 Mb */
84 .bank1_start = 128U,
85 .bank1_sectors = 128U
86#else
87 /* it takes:
88 * same 147 mS to write setting without GC
89 * 1500 mS to write setting with GC, but GC happens every time we write settings */
90 .bank_size = 64 * 1024U,
91 .bank0_start = 0U,
92 .bank0_sectors = 16U, /* 16 * 4 K = 64 Kb */
93 .bank1_start = 16U,
94 .bank1_sectors = 16U
95#endif
96};

Referenced by boardGetMfsConfig().

◆ snor1

NO_CACHE SNORDriver snor1
static

Definition at line 37 of file board_storage.cpp.

Referenced by boardInitMfs().

◆ snor1buf

NO_CACHE snor_nocache_buffer_t snor1buf
static

Definition at line 38 of file board_storage.cpp.

Referenced by boardInitMfs().

◆ W25FlashConfig

const SNORConfig W25FlashConfig
static
Initial value:
= {
.busp = &EFI_FLASH_SDPID,
.buscfg = &W25SpiCfg
}

Definition at line 68 of file board_storage.cpp.

68 {
69 .busp = &EFI_FLASH_SDPID,
70 .buscfg = &W25SpiCfg
71};

Referenced by boardInitMfs().

◆ W25SpiCfg

const SPIConfig W25SpiCfg
static
Initial value:
= {
.circular = false,
#ifdef _CHIBIOS_RT_CONF_VER_6_1_
.end_cb = NULL,
#else
.slave = false,
.data_cb = NULL,
.error_cb = NULL,
#endif
.ssport = EFI_FLASH_SPI_CS_GPIO,
.sspad = EFI_FLASH_SPI_CS_PIN,
.cr1 =
SPI_CR1_8BIT_MODE |
((0 << SPI_CR1_BR_Pos) & SPI_CR1_BR) |
0,
.cr2 =
SPI_CR2_8BIT_MODE |
0,
}

Definition at line 45 of file board_storage.cpp.

45 {
46 .circular = false,
47#ifdef _CHIBIOS_RT_CONF_VER_6_1_
48 .end_cb = NULL,
49#else
50 .slave = false,
51 .data_cb = NULL,
52 .error_cb = NULL,
53#endif
54 .ssport = EFI_FLASH_SPI_CS_GPIO,
55 .sspad = EFI_FLASH_SPI_CS_PIN,
56 .cr1 =
57 SPI_CR1_8BIT_MODE |
58 ((0 << SPI_CR1_BR_Pos) & SPI_CR1_BR) |
59 0,
60 .cr2 =
61 SPI_CR2_8BIT_MODE |
62 0,
63};

Referenced by boardInitMfs().

Go to the source code of this file.