Skip to content

Fix SDRAM timing setup during initialization#457

Merged
jklmnn merged 3 commits into
AdaCore:masterfrom
pat-rogers:sdram_timing_fixes
May 5, 2026
Merged

Fix SDRAM timing setup during initialization#457
jklmnn merged 3 commits into
AdaCore:masterfrom
pat-rogers:sdram_timing_fixes

Conversation

@pat-rogers
Copy link
Copy Markdown
Contributor

@pat-rogers pat-rogers commented Mar 24, 2026

stm32-sdram.adb:
We now compute initialization values from the datasheet constants. Specifically, in procedure Initialize:

  • ExitSelfRefreshDelay, SelfRefreshTime, and RowCycleDelay were all derived from a single SDRAM_Min_Delay_In_ns constant, improperly collapsing three distinct timing constraints (TXSR, TRAS, TRC) into one value.

  • SelfRefreshTime was also hardcoded to 4 cycles, valid only at 90 MHz SDCLK.

We replace those with per-parameter ceiling division over named board constants (SDRAM_TXSR_In_Ns, SDRAM_TRAS_In_Ns, SDRAM_TRC_In_Ns) so each constraint is satisfied independently at any clock frequency.

stm32-board.ads:

  • add new SDRAM constants for the sake of the SDRAM initialization

We now compute them from the datasheet constants.
Specifically, in procedure Initialize:

* ExitSelfRefreshDelay, SelfRefreshTime, and RowCycleDelay were all derived
from a single SDRAM_Min_Delay_In_ns constant, collapsing three distinct
timing constraints (TXSR, TRAS, TRC) into one value. SelfRefreshTime was
also hardcoded to 4 cycles, valid only at 90 MHz SDCLK.

* Replace with per-parameter ceiling division over named board constants
(SDRAM_TXSR_In_Ns, SDRAM_TRAS_In_Ns, SDRAM_TRC_In_Ns) so each constraint
is satisfied independently at any clock frequency.

STM32.Board spec:

* add new SDRAM constants for the sake of the SDRAM initialization
@pat-rogers
Copy link
Copy Markdown
Contributor Author

pat-rogers commented Apr 14, 2026

@jklmnn The change to stm32-board.ads doesn't seem to be taken into account by the CI builder, so as a result the change to stm32-sdram.adb fails.

@jklmnn
Copy link
Copy Markdown
Member

jklmnn commented Apr 27, 2026

@jklmnn The change to stm32-board.ads doesn't seem to be taken into account by the CI builder, so as a result the change to stm32-sdram.adb fails.

stm32-sdram.adb is used for all STM32 boards, so the new values need to be added to all stm32-board.ads implementations. The test script for example fails to build the example for the STM32F429.

Copy link
Copy Markdown
Member

@jklmnn jklmnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F429/F469/F769 previously had a single SDRAM_Min_Delay_In_ns; replace
with the same SDRAM_TRAS_In_Ns / SDRAM_TRC_In_Ns / SDRAM_TXSR_In_Ns
trio that the shared SDRAM driver expects. F746 comment block reworked
to cite the actual on-board part (Micron MT48LC4M32B2B5-6A) and the ST
BSP source; tXSR corrected from 70 to 67 to match the Micron datasheet.
Comment on lines +138 to +139
SDRAM_TRAS_In_Ns : constant := 42; -- TRAS
SDRAM_TRC_In_Ns : constant := 70; -- TRC
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines have trailing spaces. Removing these should fix the CI.

Bump copyright year to 2026 on F429/F469/F769 stm32-board.ads

Companion to the SDRAM timing edits in this PR; F746 was already at 2026.
@pat-rogers pat-rogers force-pushed the sdram_timing_fixes branch from ef9ade7 to dadf476 Compare May 5, 2026 15:22
@jklmnn jklmnn merged commit 8663ba9 into AdaCore:master May 5, 2026
3 checks passed
@pat-rogers pat-rogers deleted the sdram_timing_fixes branch May 5, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants