PRACTICE Script To Quickly Halt CPU

huangapple go评论89阅读模式
英文:

PRACTICE Script To Quickly Halt CPU

问题

我正在尝试编写一个脚本,在上电后立即停止CPU(例如,我们安装了一个有问题的代码到S32K144设备的闪存中,使芯片保持在复位状态)。除了基本功能如SYSTEM.UP、BREAK、SYSTEM.MODE.ATTACH之外,是否还有其他停止CPU在执行主函数之前的方法?我在Lauterbach的参考文献中看到了关于GLOBALON事件(如POWERUP和POWERDOWN)的内容。如果有可能的方法,请提供有关如何创建脚本以在执行主函数之前重复发送停止命令的详细指导和示例,基于PDF中的信息。

我已尝试使用Lauterbach在MCB1700板上提供的LCP1768演示脚本进行执行。

以下是我的脚本:

  SYStem.RESet
  SYStem.CPU LPC1768
  SYStem.CONFIG SWDP    ON
  SYStem.Option EnReset OFF
IF UTRACE()||COMBIPROBE()
(
  SYStem.CONFIG.CONNECTOR MIPI20T
)
  SYStem.up

; 将演示代码加载到SRAM
  Data.LOAD.Elf ~~~~/demo.axf
  symbol.sourcepath.set C:\T32\demo\arm\compiler\gnu\src
  Register.Set PC 0x10000748
  Register.Set R13 0x10005000

  IF hardware.COMBIPROBE()||hardware.UTRACE()
  (
    ; 启用跟踪
    Data.Set 0x4002C028 %Long 0x00000008

    ETM.ON
    ITM.ON

    ETM.PortMode Continuous
    ETM.PortSize 4.

    Trace.METHOD CAnalyzer   ; 使用CombiProbe
    Trace.OFF                ; 启用跟踪并关闭它
  )

ENDDO`
英文:

I am trying write a script to halt CPU right after powerup (for example we install a faulty code to flash of S32K144 device and make the chip stuck in reset. Other than the basic functions like SYSTEM.UP, BREAK, SYSTEM.MODE.ATTACH , is there any other way to stop the CPU before it executes the main function. I have come across a Lauterbach reference about GLOBALON event, such as POWERUP and POWERDOWN. If there is possible way, please provide kind guidance and example on the creating the script for halt command repeatedly before it go main function. based on the info from the pdf.

I have tried the execution using demo script given by Lauterbach on LCP1768 on board MCB1700.

This is my script:

  SYStem.RESet
  SYStem.CPU LPC1768
  SYStem.CONFIG SWDP    ON
  SYStem.Option EnReset OFF
IF UTRACE()||COMBIPROBE()
(
  SYStem.CONFIG.CONNECTOR MIPI20T
)
  SYStem.up


; Load the demo code into the SRAM
  Data.LOAD.Elf ~~~~/demo.axf
  symbol.sourcepath.set C:\T32\demo\arm\compiler\gnu\src
  Register.Set PC 0x10000748
  Register.Set R13 0x10005000

  IF hardware.COMBIPROBE()||hardware.UTRACE()
  (
    ; Enable Trace
    Data.Set 0x4002C028 %Long 0x00000008

    ETM.ON
    ITM.ON

    ETM.PortMode Continuous
    ETM.PortSize 4.

    Trace.METHOD CAnalyzer   ; Using CombiProbe
    Trace.OFF                ; Enable the trace and turn it off
  )

ENDDO`

</details>


# 答案1
**得分**: 2

如果它会成功,这在所使用的硬件上有一些依赖。调试器内部尚未对您的用例提供原生支持,但PRACTICE脚本语言应该可以解决此问题。

思路是在上电后保持板子处于复位状态,并让调试器自动执行SYStem.Up。这将允许调试器连接到核心并在其上执行任何代码之前将其停止:

// 系统设置
RESet
SYStem.CPU S32K144
//... 其他系统设置

// 确保板子已断电
IF STATE.POWER()
(
  PRINT "Power down the board!"
  WAIT !STATE.POWER()
)

// 保持调试连接器上的复位断开
JTAG.PIN ENable
JTAG.PIN NRESET Low

// 现在可以重新上电板子
PRINT "Power up the board!"
WAIT STATE.POWER()

// 连接到核心并停在复位向量上
PRINT "Connecting..."
SYStem.Up

PRINT "Done!"

//... 继续执行脚本的其余部分

ENDDO

还存在一些硬件,无法在上电期间保持复位状态。例如,CombiProbe HS毛刷就是一个例子。但如果您的板子有一个复位按钮,那么您可以在断电时保持按下,然后在上电后,在调试器状态行中显示"Connecting..."后释放它。

这个序列应该也适用于其他控制器。我无法测试LPC1768本身,因为目前我无法访问这样的板子。

最好的问候,
Steffen。

<details>
<summary>英文:</summary>

If it will have success depends a little bit on the used hardware. There isn&#39;t yet native support for your use case inside the debugger, but the PRACTICE script language should be fine to solve it.

The idea is to keep the board in reset after power up and let the debugger automatically execute a SYStem.Up. This will let the debugger connect to the core and halt it without having any code being exectuted on it:

    // System settings
    RESet
    SYStem.CPU S32K144
    //... other system settings
    
    // Make sure the board is powered down
    IF STATE.POWER()
    (
      PRINT &quot;Power down the board!&quot;
      WAIT !STATE.POWER()
    )
    
    // Keep reset asserted on the debug connector
    JTAG.PIN ENable
    JTAG.PIN NRESET Low
    
    // Now the board can be powered again
    PRINT &quot;Power up the board!&quot;
    WAIT STATE.POWER()
    
    // Connect to the core and stop on the reset vector
    PRINT &quot;Connecting...&quot;
    SYStem.Up
    
    PRINT &quot;Done!&quot;
    
    //... continue with the rest of the script
    
    ENDDO

There exists hardware, that is not able to keep the reset being asserted during the power-up. This is for example the CombiProbe HS whisker. But if your board has a reset button, then you can keep it pressed while powered down and realease it after power up as soon as &quot;Connecting...&quot; is shown inside the status line of the debugger.

The sequence should work on other controllers, too. I could not test the LPC1768 itself, because I currently do not have access to a board like this.

Best Regards,
Steffen.

</details>



huangapple
  • 本文由 发表于 2023年6月12日 16:18:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76454731.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定