;-------------------------------------------------------------------------- ; ; ; PEEDI sample target configuration file ; ; Ronetix GmbH ; ; Supported devices : STM32 L4, L4+ (Cortex-M4) ; ; Boards : e.g. NUCLEO-L412KB ; ; Revision : 1.0 ; ; Date : November 15, 2026 ; ; The file is delivered "AS IS" without warranty or condition of any ; kind, either express, implied or statutory. This includes without ; limitation any warranty or condition with respect to merchantability or ; fitness for any particular purpose, or against the infringements of ; intellectual property rights of others. ; ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- ; The following section contains licenses that are required for PEEDI to ; operate. These licenses must be filled before using this file. ; The [LICENSE] section may contain license keys for one or more PEEDIs. ; ; Example: ; [LICENSE] ; KEY = UPDATE_24MAY2010, 1111-1111-1111-1 ; KEY = XXXXX, 2222-2222-2222-2 ; ; The [LICENSE] section may point to an external file which contains ; license keys for one or more PEEDIs. The external file must include ; the text [LICENSE] followed by all keys. ; ; Example: ; [LICENSE] ; FILE = tftp://192.168.3.10/license.txt ; or ; FILE=eep:license.txt ; or ; FILE = ftp://user:password@192.168.3.10/license.txt ; ; ; PEEDI is shipped with license keys stored in "eep:license.txt" and ; printed on a label on the bottom side of PEEDI. ; [LICENSE] FILE=eep:license.txt ;-------------------------------------------------------------------------- [DEBUGGER] PROTOCOL = gdb_remote ; debug protocol REMOTE_PORT = 2000 ; TCP/IP port FLASH = FLASH_STM32 ; flash section to be used when programming via gdb ;FLASH = FLASH_GDB ; flash section, FLASH at address 0 [TARGET] PLATFORM = Cortex-M_SWD ;PLATFORM = Cortex-M [PLATFORM_Cortex-M] JTAG_CHAIN = 5, 4 ; list of TAP controllers in the JTAG chain JTAG_CLOCK = 100, 2000 ; JTAG Clock in [kHz] TRST_TYPE = OPENDRAIN ; type of TRST output: OPENDRAIN or PUSHPULL RESET_TIME = 20 ; length of RESET pulse in ms; 0 means no RESET ;RESET_TYPE = RST_NOGATE ; enable if PEEDI is unable to connect CORE0 = Cortex-M,1 CORE0_STARTUP_MODE = RESET ; stop the core immediately after reset CORE0_ENDIAN = LITTLE ; core is little endian CORE0_BREAKMODE = SOFT ; breakpoint mode CORE0_INIT = INIT_STM32L4 CORE0_FLASH0 = FLASH_STM32 ; FLASH section CORE0_FLASH1 = FLASH_STM32_DIRECT ; FLASH section CORE0_FLASH2 = FLASH_GDB CORE0_WORKSPACE = 0x20000000, 0x2000 ; workspace for agent programming CORE0_SWO = 0, 2001 ; ITM stimulus port 0 -> TCP port 2001 ;CORE0_SWO = 1, 2002 ; ITM stimulus port 1 -> TCP port 2002 ;CORE0_SWO = DWT, 2003 ; DWT packets (PC samples) -> TCP port 2003 CORE0_PATH = "tftp://192.168.3.10" ; default path ;CORE0_PATH = "card:" [PLATFORM_Cortex-M_SWD] SWD_CLOCK = 100, 2000 ; SWD Clock in [kHz] RESET_TYPE = RST_NOGATE ; RST is asserted during the connect phase TRST_TYPE = OPENDRAIN ; type of TRST output: OPENDRAIN or PUSHPULL RESET_TIME = 20 ; length of RESET pulse in ms; 0 means no RESET CORE0 = Cortex-M ;CORE0_RESET_MODE = sysresetreq ; software reset: sysresetreq or vectreset CORE0_STARTUP_MODE = RESET ; stop the core immediately after reset CORE0_ENDIAN = LITTLE ; core is little endian CORE0_BREAKMODE = SOFT ; breakpoint mode CORE0_INIT = INIT_STM32L4 CORE0_FLASH0 = FLASH_STM32 ; FLASH section CORE0_FLASH1 = FLASH_STM32_DIRECT ; FLASH section CORE0_FLASH2 = FLASH_GDB CORE0_WORKSPACE = 0x20000000, 0x2000 ; workspace for agent programming CORE0_SWO = 0, 2001 ; ITM stimulus port 0 -> TCP port 2001 ;CORE0_SWO = 1, 2002 ; ITM stimulus port 1 -> TCP port 2002 ;CORE0_SWO = DWT, 2003 ; DWT packets (PC samples) -> TCP port 2003 CORE0_PATH = "tftp://192.168.3.10" ; default path ;CORE0_PATH = "card:" [INIT_STM32L4] ; Stop watchdog counters during halt ; DBGMCU_APB1_FZ |= DBG_IWDG_STOP | DBG_WWDG_STOP mem write 0xE0042008 0x00001800 ; DBGMCU_CR |= DBG_STANDBY | DBG_STOP | DBG_SLEEP mem or 0xE0042004 0x00000007 mem write 0x40021000 0x00000063 ; Set HSION in RCC_CR mem write 0x40021004 0x40700086 mem write 0x40021008 0 mem write 0x4002100c 0x00001000 ; Set HSI as SYSCLK mem write 0x40022000 0x0 ; disable I/D flash cache ; init SWO (TPIU at 0xE0040000), Manchester encoding, see the PEEDI manual ; section "Serial Wire Output (SWO)" mem wr 0xE0042004 0x20 ; STM32 DBGMCU_CR: TRACE_IOEN (async mode) mem wr 0xE0040010 2 ; TPIU_ACPR: SWO prescaler = 2 + 1 mem wr 0xE00400F0 1 ; TPIU_SPPR: Manchester encoding mem wr 0xE0040304 0 ; TPIU: disable formatter mem wr 0xE0000FB0 0xC5ACCE55 ; ITM: unlock ITM_TCR mem wr 0xE0000E80 0x10009 ; ITM_TCR: TXENA + ITMENA + TraceBusID=0x1 mem wr 0xE0000E40 0xF ; en. all tracing ports mem wr 0xE0000E00 0xFFFFFFFF ; en. all stimulus ports ;-------------------------------------------------------------------------- ; Option bytes (RM0394) ; ; FLASH_OPTR depends on the device and on what was programmed before, e.g. ; NUCLEO-L412RB-P: factory value 0xFFEFF8AA. Do not write a fixed FLASH_OPTR ; value copied from another device: the BOR level, the boot (nBOOT0, ; nSWBOOT0) and the watchdog bits would change too. ; ; If the flash can not be erased or programmed: ; "device protected" (WRPERR) - a write protected page (WRP1AR/WRP1BR) ; blocks the mass erase: run $disable_wrp ; "timeout while waiting for response from the agent" - the independent ; watchdog runs in hardware mode (FLASH_OPTR.IWDG_SW = 0) and resets ; the MCU during programming: run $iwdg_sw.tcl ;-------------------------------------------------------------------------- ; show FLASH_OPTR, PCROP1SR, PCROP1ER, WRP1AR, WRP1BR: run $show_options [show_options] mem read 0x40022020 5 ; disable both write protection areas (start > end), resets the MCU [disable_wrp] flash this option 0x2C 0x000000FF ; WRP1AR: area A disabled flash this option 0x30 0x000000FF ; WRP1BR: area B disabled flash this option load ; activate, resets the MCU # select the software watchdog (FLASH_OPTR.IWDG_SW = 1), only this bit is # changed; resets the MCU [iwdg_sw.tcl] set val [| [mrw 0x40022020] 0x10000] mon "flash this option 0x20 $val" mon "flash this option load" [FLASH_STM32] CHIP = STM32 ; flash chip, detected automatically BASE_ADDR = 0x08000000 ; flash is mapped at 0x08000000 ACCESS_METHOD = AGENT ; use agent programming AUTO_ERASE = NO ; erase before program FILE = test32k.bin 0x8000000 ; file to program [FLASH_STM32_DIRECT] CHIP = STM32 ; flash chip, detected automatically BASE_ADDR = 0x08000000 ; flash is mapped at 0x08000000 ACCESS_METHOD = DIRECT ; use direct programming AUTO_ERASE = NO ; erase before program FILE = test32k.bin 0x8000000 ; file to program [FLASH_GDB] ; used when programming via gdb CHIP = STM32 ; flash chip, detected automatically BASE_ADDR = 0x0 ; flash is mapped at 0x00000000 ACCESS_METHOD = AGENT ; use agent programming AUTO_ERASE = NO ; erase before program FILE = test32k.bin 0x0 ; file to program [SERIAL] ; serial port configuration BAUD = 115200 STOP_BITS = 1 PARITY = NONE TCP_PORT = 0 [TELNET] PROMPT = "stm32l4> " ; telnet prompt ;BACKSPACE = 127 ; comment out for autodetect [DISPLAY] BRIGHTNESS = 20 ; LED indicator brightness VOLUME = 25 ; beeper volume [ACTIONS] ; user defined scripts ;AUTORUN = 2 ; executed on every target connect 1 = erase 2 = prog 3 = dump_ram 4 = dump_flash 5 = eraseprogram.tcl ; erase, program, verify with RDP [erase] ; erase flash flash erase [prog] ; program flash flash prog [dump_ram] ; dump RAM memory dump 0x20000000 0x5000 tftp://192.168.3.10/ram.bin [dump_flash] ; dump FLASH memory dump 0x08000000 0x20000 tftp://192.168.3.10/flash.bin #----------------------------------------------------------------------- # Erase, program and verify with read protection (RDP) # # FLASH_OPTR (0x40022020) bits 7:0 = RDP: 0xAA - level 0 (not protected) # 0xBB - level 1 (read protection) # Only the RDP byte is changed, all other option bits keep their values, # so the script works for all devices of this family. # # Protected: set RDP to level 0 - the MCU erases the whole flash - # and "load" activates it. "load" resets the MCU, which # stops this script. After the reconnect run it again # (or let AUTORUN start it): the chip is then not # protected and the script continues below. # Not protected: erase the flash. # # Note: the partcl "if" has no "else" keyword - the third block is the # else branch. # Never use RDP level 2 (0xCC): it disables the debug interface for ever. #----------------------------------------------------------------------- [eraseprogram.tcl] set optr 0x40022020 if {!= [& [mrw $optr] 0xFF] 0xAA} \ { \ mon "echo ++ info: Removing Code protection"; \ set val [| [& [mrw $optr] ~0xFF] 0xAA]; \ mon "flash this option 0x20 $val"; \ mon "flash this option load"; \ } \ { \ mon "flash erase" \ } mon "flash program" mon "flash verify" # enable the read protection (RDP level 1) mon "echo ++ info: Set Code protection" set val [| [& [mrw $optr] ~0xFF] 0xBB] mon "flash this option 0x20 $val" # activate it now; resets the MCU. With AUTORUN this restarts the script # endlessly - remove this line, the protection is then active after the # next power-on. mon "flash this option load"