1;******************************************************************************* 2; Copyright 2023 NXP * 3; * 4; Lauterbach Trace32 start-up script for S32K344 / Cortex-M7 * 5; * 6; Parameters: * 7; - command operation to execute * 8; valid values: flash, debug * 9; - elfFile filepath of ELF to load * 10; - loadTo if "flash", the application will be downloaded to SoC * 11; program flash by a flash programming routine; if "sram" it * 12; will be downloaded to SoC SRAM. * 13; valid values: flash, sram * 14; default: flash * 15; - eraseFlash if set to "yes", the whole content in Flash device will be * 16; erased before the application is downloaded to either Flash * 17; or SRAM. This routine takes time to execute * 18; default: "no" * 19; - verifyFlash if set to "yes", verify after program application to Flash * 20; default: "no" * 21;******************************************************************************* 22 23ENTRY %LINE &args 24 25&command=STRing.SCANAndExtract("&args","command=","") 26&elfFile=STRing.SCANAndExtract("&args","elfFile=","") 27&loadTo=STRing.SCANAndExtract("&args","loadTo=","flash") 28&eraseFlash=STRing.SCANAndExtract("&args","eraseFlash=","no") 29&verifyFlash=STRing.SCANAndExtract("&args","verifyFlash=","no") 30 31IF ("&elfFile"=="") 32( 33 PRINT %ERROR "Missing ELF file path" 34 PLIST 35 STOP 36 ENDDO 37) 38 39; Initialize debugger 40RESet 41SYStem.RESet 42SYStem.CPU S32K344-M7 43SYStem.CONFIG.DEBUGPORTTYPE JTAG 44SYStem.Option.DUALPORT ON 45SYStem.Option.DisMode THUMB 46SYStem.MemAccess DAP 47SYStem.JtagClock 10MHz 48Trace.DISable 49TrOnchip.Set MMERR OFF 50TrOnchip.Set BUSERR OFF 51SYStem.Up 52 53; Init SRAM 54DO ~~/demo/arm/hardware/s32k3/scripts/init_sram.cmm 55 56; Only declares flash, does not execute flash programming 57DO ~~/demo/arm/flash/s32k3.cmm PREPAREONLY 58 59; The prepare cmm is protecting flash area for HSE firmware, but 60; since HSE firmware usage feature is not enabled, this region can 61; be used by application core, marked as programmable. 62FLASH.CHANGEtype 0x007D4000--0x7F3FFF TARGET 63 64IF ("&eraseFlash"=="yes") 65( 66 FLASH.Erase ALL 67) 68 69IF ("&loadTo"=="flash") 70( 71 ; Switch target flash to reprogramming state, erase virtual flash programming memory, 72 ; all target non-empty flash sectors are marked as pending, to be reprogrammed. 73 FLASH.ReProgram ALL /Erase 74 75 ; Write contents of the file to virtual Flash programming memory 76 Data.LOAD.Elf &elfFile 77 78 ; Program only changed sectors to target flash and erase obsolete code 79 FLASH.ReProgram off 80 81 IF ("&verifyFlash"=="yes") 82 ( 83 Data.LOAD.Elf &elfFile /DIFF 84 85 IF FOUND() 86 ( 87 AREA.view 88 PRINT %ERROR "ERROR ! Failed to download the code to flash" 89 Data.LOAD.Elf &elfFile /ComPare 90 ENDDO 91 ) 92 ) 93 94 ; Reset the processor 95 SYStem.Up 96) 97ELSE 98( 99 ; Init ITCM 100 DO ~~/demo/arm/hardware/s32k3/scripts/init_itcm.cmm 101 102 Data.LOAD.Elf &elfFile 103) 104 105IF ("&command"=="flash") 106( 107 ; Execute the application and quit 108 Go 109 QUIT 110) 111ELSE IF ("&command"=="debug") 112( 113 ; Setup minimal debug environment 114 WinCLEAR 115 SETUP.Var.%SpotLight 116 WinPOS 0. 0. 120. 30. 117 List.auto 118 WinPOS 125. 0. 80. 10. 119 Frame.view 120 WinPOS 125. 18. 121 Register.view /SpotLight 122) 123ELSE 124( 125 PRINT %ERROR "Invalid command" 126) 127 128ENDDO 129