1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # This is a stm32h735g-dk with a single STM32H735IGK6 chip.
4 # https://www.st.com/en/evaluation-tools/stm32h735g-dk.html
7 # This is for using the onboard STLINK
8 source [find interface/stlink.cfg]
10 transport select hla_swd
12 set CHIPNAME stm32h735igk6
15 if {![info exists OCTOSPI1]} {
20 source [find target/stm32h7x.cfg]
22 reset_config srst_only
24 # OCTOSPI initialization
26 proc octospi_init { octo } {
28 mmw 0x58024540 0x000006FF 0 ;# RCC_AHB4ENR |= GPIOAEN-GPIOKEN (enable clocks)
29 mmw 0x58024534 0x00284000 0 ;# RCC_AHB3ENR |= IOMNGREN, OSPI2EN, OSPI1EN (enable clocks)
30 sleep 1 ;# Wait for clock startup
32 mww 0x5200B404 0x03010111 ;# OCTOSPIM_P1CR: assign Port 1 to OCTOSPI1
33 mww 0x5200B408 0x00000000 ;# OCTOSPIM_P2CR: disable Port 2
35 # PG06: OCSPI1_NCS, PF10: OCSPI1_CLK, PB02: OCSPI1_DQS, PD07: OCSPI1_IO7, PG09: OCSPI1_IO6, PD05: OCSPI1_IO5,
36 # PD04: OCSPI1_IO4, PD13: OCSPI1_IO3, PE02: OCSPI1_IO2, PD12: OCSPI1_IO1, PD11: OCSPI1_IO0
38 # PB02:AF10:V, PD13:AF09:V, PD12:AF09:V, PD11:AF09:V, PD07:AF10:V, PD05:AF10:V
39 # PD04:AF10:V, PE02:AF09:V, PF10:AF09:V, PG09:AF09:V, PG06:AF10:V
41 mmw 0x58020400 0x00000020 0x00000010 ;# MODER
42 mmw 0x58020408 0x00000030 0x00000000 ;# OSPEEDR
43 mmw 0x5802040C 0x00000000 0x00000030 ;# PUPDR
44 mmw 0x58020420 0x00000A00 0x00000500 ;# AFRL
45 # Port D: PD13:AF09:V, PD12:AF09:V, PD11:AF09:V, PD07:AF10:V, PD05:AF10:V, PD04:AF10:V
46 mmw 0x58020C00 0x0A808A00 0x05404500 ;# MODER
47 mmw 0x58020C08 0x0FC0CF00 0x00000000 ;# OSPEEDR
48 mmw 0x58020C0C 0x00000000 0x0FC0CF00 ;# PUPDR
49 mmw 0x58020C20 0xA0AA0000 0x50550000 ;# AFRL
50 mmw 0x58020C24 0x00999000 0x00666000 ;# AFRH
52 mmw 0x58021000 0x00000020 0x00000010 ;# MODER
53 mmw 0x58021008 0x00000030 0x00000000 ;# OSPEEDR
54 mmw 0x5802100C 0x00000000 0x00000030 ;# PUPDR
55 mmw 0x58021020 0x00000900 0x00000600 ;# AFRL
57 mmw 0x58021400 0x00200000 0x00100000 ;# MODER
58 mmw 0x58021408 0x00300000 0x00000000 ;# OSPEEDR
59 mmw 0x5802140C 0x00000000 0x00300000 ;# PUPDR
60 mmw 0x58021424 0x00000900 0x00000600 ;# AFRH
61 # Port G: PG09:AF09:V, PG06:AF10:V
62 mmw 0x58021800 0x00082000 0x00041000 ;# MODER
63 mmw 0x58021808 0x000C3000 0x00000000 ;# OSPEEDR
64 mmw 0x5802180C 0x00000000 0x000C3000 ;# PUPDR
65 mmw 0x58021820 0x0A000000 0x05000000 ;# AFRL
66 mmw 0x58021824 0x00000090 0x00000060 ;# AFRH
68 # OCTOSPI1: memory-mapped 1-line read mode with 4-byte addresses
69 mww 0x52005130 0x00001000 ;# OCTOSPI_LPTR: deactivate CS after 4096 clocks when FIFO is full
70 mww 0x52005000 0x3040000B ;# OCTOSPI_CR: FMODE=0x1, APMS=1, FTHRES=0, FSEL=0, DQM=0, TCEN=0
71 mww 0x52005008 0x01190100 ;# OCTOSPI_DCR1: MTYP=0x1, FSIZE=0x19, CSHT=0x01, CKMODE=0, DLYBYP=0
72 mww 0x5200500C 0x00000005 ;# OCTOSPI_DCR2: PRESCALER=5
74 mww 0x52005108 0x00000000 ;# OCTOSPI_TCR: SSHIFT=0, DHQC=0, DCYC=0x0
75 mww 0x52005100 0x01003101 ;# OCTOSPI_CCR: DMODE=0x1, ABMODE=0x0, ADSIZE=0x3, ADMODE=0x1, ISIZE=0x0, IMODE=0x1
76 mww 0x52005110 0x00000013 ;# OCTOSPI_IR: INSTR=READ4B
78 flash probe $a ;# load configuration from CR, TCR, CCR, IR register values
81 stmqspi cmd $a 1 0x71 0x00 0x00 0x00 0x00 ;# Read Conf. Reg. 2, addr 0x00000000: DOPI, SOPI bits
82 stmqspi cmd $a 0 0x06 ;# Write Enable
83 stmqspi cmd $a 1 0x05 ;# Read Status Register
84 stmqspi cmd $a 0 0x72 0x00 0x00 0x00 0x00 0x02 ;# Write Conf. Reg. 2, addr 0x00000000: DTR OPI enable
86 # OCTOSPI1: memory-mapped 8-line read mode with 4-byte addresses
87 mww 0x52005000 0x3040000B ;# OCTOSPI_CR: FMODE=0x3, APMS=1, FTHRES=0, FSEL=0, DQM=0, TCEN=1, EN=1
88 mww 0x52005108 0x10000006 ;# OCTOSPI_TCR: SSHIFT=0, DHQC=1, DCYC=0x6
89 mww 0x52005100 0x2C003C1C ;# OCTOSPI_CCR: DTR, DMODE=0x4, ABMODE=0x0, ADSIZE=0x3, ADMODE=0x4, ISIZE=0x1, IMODE=0x4
90 mww 0x52005110 0x0000EE11 ;# OCTOSPI_IR: INSTR=OCTA DTR Read
92 flash probe $a ;# reload configuration from CR, TCR, CCR, IR register values
94 stmqspi cmd $a 0 0x06 ;# Write Enable
95 stmqspi cmd $a 1 0x05 0x00 0x00 0x00 0x00 ;# Read Status Register (note dummy address in 8-line mode)
96 stmqspi cmd $a 0 0x04 ;# Write Disable
97 stmqspi cmd $a 1 0x05 0x00 0x00 0x00 0x00 ;# Read Status Register (note dummy address in 8-line mode)
98 stmqspi cmd $a 1 0x71 0x00 0x00 0x00 0x00 ;# Read Conf. Reg. 2, addr 0x00000000: DOPI, SOPI bits
102 $_CHIPNAME.cpu0 configure -event reset-init {
106 mmw 0x52002000 0x00000004 0x0000000B ;# FLASH_ACR: 4 WS for 192 MHZ HCLK
108 mmw 0x58024400 0x00000001 0x00000018 ;# RCC_CR: HSIDIV=1, HSI on
109 mmw 0x58024410 0x10000000 0xEE000007 ;# RCC_CFGR: MCO2=system, MCO2PRE=8, HSI as system clock
110 mww 0x58024418 0x00000040 ;# RCC_D1CFGR: D1CPRE=1, D1PPRE=2, HPRE=1
111 mww 0x5802441C 0x00000440 ;# RCC_D2CFGR: D2PPRE2=2, D2PPRE1=2
112 mww 0x58024420 0x00000040 ;# RCC_D3CFGR: D3PPRE=2
113 mww 0x58024428 0x00000040 ;# RCC_PPLCKSELR: DIVM3=0, DIVM2=0, DIVM1=4, PLLSRC=HSI
114 mmw 0x5802442C 0x0001000C 0x00000002 ;# RCC_PLLCFGR: PLL1RGE=8MHz to 16MHz, PLL1VCOSEL=wide
115 mww 0x58024430 0x01070217 ;# RCC_PLL1DIVR: 192 MHz: DIVR1=2, DIVQ=8, DIVP1=2, DIVN1=24
116 mmw 0x58024400 0x01000000 0 ;# RCC_CR: PLL1ON=1
118 mmw 0x58024410 0x00000003 0 ;# RCC_CFGR: PLL1 as system clock