Skip to content

MT25TL256 32MiB dual-quad FLASH) #25

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

Open
wants to merge 50 commits into
base: contrib
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9b82d26
added STM32CubeMX generated project for STM32H7A3
ChrisIdema Jan 6, 2023
2048558
disabled cubeMX backup
ChrisIdema Jan 6, 2023
def8480
added gitignore
ChrisIdema Jan 6, 2023
1a5c7aa
updated cube generation
ChrisIdema Jan 6, 2023
e17b907
set mode to dual quad and updated defines
ChrisIdema Jan 6, 2023
ea8021e
intermediate commit for ioc file
ChrisIdema Jan 9, 2023
7f3d53b
intermediate commit
ChrisIdema Jan 9, 2023
ce2c14e
intermediate commit
ChrisIdema Jan 9, 2023
6212ce2
intermediate commit reset of chip fails
ChrisIdema Jan 10, 2023
44b11a4
intermediate commit: clocked flash lower, reading of first 2 id bytes…
ChrisIdema Jan 11, 2023
1ad3beb
intermediate commit: reset and read id works
ChrisIdema Jan 11, 2023
195ccbb
added comment
ChrisIdema Jan 11, 2023
aefa971
intermediate commit
ChrisIdema Jan 11, 2023
bb1e08e
intermediate commit: refactored CSP_QSPI_WriteMemory
ChrisIdema Jan 11, 2023
9ef2478
added QSPI_Command to simplify sending commands
ChrisIdema Jan 12, 2023
d65bbd2
intermediate commit: testing driver
ChrisIdema Jan 12, 2023
988f3b9
intermediate commit
ChrisIdema Jan 12, 2023
dd64620
reading from volatile enhanced after writing fails
ChrisIdema Jan 12, 2023
27d563f
intermediate commit, write enable is now set before writing configura…
ChrisIdema Jan 13, 2023
4edec79
ID reading fails in QSPI protocol (0x70 instead of 0x20)
ChrisIdema Jan 13, 2023
c2a35f1
STR command + DTR address/data works
ChrisIdema Jan 13, 2023
7cd85f3
intermediate commit: memory mapped works, write for 1st sector fails
ChrisIdema Jan 13, 2023
a0e5a9f
write doesn't work after erase
ChrisIdema Jan 13, 2023
ac8b8ef
fixed erase function bug and check
ChrisIdema Jan 16, 2023
82348b5
intermediate commit: some refactoring
ChrisIdema Jan 16, 2023
694a6cd
intermediate commit
ChrisIdema Jan 16, 2023
2d03658
refactored CSP_QSPI_WriteMemory
ChrisIdema Jan 16, 2023
9ec7d22
intermediate commit
ChrisIdema Jan 16, 2023
9ebca96
READ_DTR fails at byte 13
ChrisIdema Jan 16, 2023
e6d0266
clocked to 280MHz again, read DTR works
ChrisIdema Jan 16, 2023
90b5513
updated dummy cycles
ChrisIdema Jan 16, 2023
cae8289
updated todos
ChrisIdema Jan 16, 2023
b214a43
removed unused variable
ChrisIdema Jan 16, 2023
fca9fe3
flashing with stm32cube programmer fails
ChrisIdema Jan 16, 2023
fdac6ec
intermediate commit, loader has some issues, memory mapped read somet…
ChrisIdema Jan 17, 2023
93aa59c
intermediate commit
ChrisIdema Jan 17, 2023
1af3d32
doesn't work debug
ChrisIdema Jan 17, 2023
ce3bfc5
intermediate commit, still doesn't work
ChrisIdema Jan 18, 2023
50dc523
fixed bug: if read id after reset fails it resets in quad mode too
ChrisIdema Jan 19, 2023
69ced9e
simplified reset
ChrisIdema Jan 19, 2023
3ccd75f
enabled Discard unused sections (53.38kiB to 15.29kiB)
ChrisIdema Jan 19, 2023
cc89005
updated comment
ChrisIdema Jan 19, 2023
36e0cc7
fixed timeout for mass erase
ChrisIdema Jan 19, 2023
bd8475d
synchronized linker file and ioc file
ChrisIdema Jan 20, 2023
6a9e8d7
changed comments and macros
ChrisIdema Jan 20, 2023
d122ba6
changed naming
ChrisIdema Jan 20, 2023
048d449
forgotten commit
ChrisIdema Jan 26, 2023
b56dd48
added readme
ChrisIdema Jan 26, 2023
0889593
fixed spelling error
ChrisIdema Feb 27, 2025
494edf7
Merge branch 'MT25TL256' into contrib
ChrisIdema Feb 27, 2025
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
190 changes: 190 additions & 0 deletions Demo_Project_H7A3/.cproject

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Demo_Project_H7A3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Debug/
32 changes: 32 additions & 0 deletions Demo_Project_H7A3/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Custom_Loader</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.st.stm32cube.ide.mcu.MCUProjectNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUCubeProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCURootProjectNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
38 changes: 38 additions & 0 deletions Demo_Project_H7A3/Core/Inc/Dev_Inf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

#ifndef DEV_INF_H_
#define DEV_INF_H_

#define MCU_FLASH 1
#define NAND_FLASH 2
#define NOR_FLASH 3
#define SRAM 4
#define PSRAM 5
#define PC_CARD 6
#define SPI_FLASH 7
#define I2C_FLASH 8
#define SDRAM 9
#define I2C_EEPROM 10

#define SECTOR_NUM 10 // Max Number of Sector types

struct DeviceSectors
{
unsigned long SectorNum; // Number of Sectors
unsigned long SectorSize; // Sector Size in Bytes
};

struct StorageInfo
{
char DeviceName[100]; // Device Name and Description
unsigned short DeviceType; // Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...
unsigned long DeviceStartAddress; // Default Device Start Address
unsigned long DeviceSize; // Total Size of Device
unsigned long PageSize; // Programming Page Size
unsigned char EraseValue; // Content of Erased Memory
struct DeviceSectors sectors[SECTOR_NUM];
};

extern struct StorageInfo const StorageInfo;


#endif /* DEV_INF_H_ */
16 changes: 16 additions & 0 deletions Demo_Project_H7A3/Core/Inc/Loader_Src.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef INC_LOADER_SRC_H_
#define INC_LOADER_SRC_H_

#include <stdint.h>

#define LOADER_OK 0x1
#define LOADER_FAIL 0x0

int Init(void);
int SectorErase(uint32_t EraseStartAddress, uint32_t EraseEndAddress);
int MassErase(void);
int Write(uint32_t Address, uint32_t Size, const uint8_t* buffer);
uint32_t CheckSum(uint32_t StartAddress, uint32_t Size, uint32_t InitVal);
uint64_t Verify(uint32_t MemoryAddr, uint32_t RAMBufferAddr, uint32_t Size,uint32_t missalignement);

#endif // INC_LOADER_SRC_H_
49 changes: 49 additions & 0 deletions Demo_Project_H7A3/Core/Inc/gpio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file gpio.h
* @brief This file contains all the function prototypes for
* the gpio.c file
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GPIO_H__
#define __GPIO_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_GPIO_Init(void);

/* USER CODE BEGIN Prototypes */

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif
#endif /*__ GPIO_H__ */

69 changes: 69 additions & 0 deletions Demo_Project_H7A3/Core/Inc/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
78 changes: 78 additions & 0 deletions Demo_Project_H7A3/Core/Inc/octospi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file octospi.h
* @brief This file contains all the function prototypes for
* the octospi.c file
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __OCTOSPI_H__
#define __OCTOSPI_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern OSPI_HandleTypeDef hospi1;

/* USER CODE BEGIN Private defines */

//MT25TL256 memory parameters (single die specs):
#define MEMORY_FLASH_SIZE (16UL << 20) // 128 Mib => 16MiB
//#define MEMORY_BLOCK_SIZE (?UL << 10) // ? sectors of ?KiB
#define MEMORY_SECTOR_SIZE (4UL << 10) // 4096 subsectors of 4KiB
#define MEMORY_PAGE_SIZE 256 // 65536 pages of 256B
#define SECTORS_COUNT (MEMORY_FLASH_SIZE / MEMORY_SECTOR_SIZE)

//MT25TL256 memory parameters (twin die specs):
#define MEMORY_DUAL_FLASH_SIZE (MEMORY_FLASH_SIZE*2)
#define MEMORY_DUAL_PAGE_SIZE (MEMORY_PAGE_SIZE*2)
#define MEMORY_DUAL_SECTOR_SIZE (MEMORY_SECTOR_SIZE*2)

#define MEMORY_MAPPED_START_ADDRESS 0x90000000




/* USER CODE END Private defines */

void MX_OCTOSPI1_Init(void);

/* USER CODE BEGIN Prototypes */

uint8_t CSP_QUADSPI_Init(void);
uint8_t CSP_QSPI_EraseSector(uint32_t EraseStartAddress ,uint32_t EraseEndAddress);
uint8_t CSP_QSPI_WriteMemory(const uint8_t* buffer, uint32_t address, uint32_t buffer_size);
uint8_t CSP_QSPI_ReadMemory(uint8_t* buffer, uint32_t address, uint32_t buffer_size);
uint8_t CSP_QSPI_EnableMemoryMappedMode(void);
uint8_t CSP_QSPI_Erase_Chip(void);

extern OSPI_HandleTypeDef hospi1;

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __OCTOSPI_H__ */

Loading