Skip to content

Commit

Permalink
Add watchpoint hook for setting reset reason on sw reset
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Oct 19, 2023
1 parent 89327b9 commit a7649fa
Show file tree
Hide file tree
Showing 5 changed files with 449 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bootloader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ lto = true # better optimizations
machine-name = 'agp-bootloader'
using-sysbus = true
init-commands = [
'include @../renode/peripherals/STM32F4_RCC.cs',
'include @../renode/peripherals/STM32_Timer.cs',
'include @../renode/peripherals/STM32_UART.cs',
]
Expand All @@ -69,6 +70,7 @@ pre-start-commands = [
#'logFile @/tmp/agp_bootloader_renode.log true',
'cpu PerformanceInMips 1',
'showAnalyzer sysbus.usart6',
'rcc resetReason PowerOnReset',
'''
sysbus.usart2 AddLineHook "PANIC" "Antmicro.Renode.Logging.Logger.Log(LogLevel.Error, line)"
sysbus.usart2 AddLineHook "test result: ok" "Antmicro.Renode.Emulator.Exit()"
Expand Down
13 changes: 13 additions & 0 deletions firmware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ using-sysbus = true
# https://builds.renode.io/renode-latest.linux-portable.tar.gz
# renode = '/opt/renode_1.14.0+20231008gitebcb1b6b_portable/renode'
init-commands = [
'include @../renode/peripherals/STM32F4_RCC.cs',
'include @../renode/peripherals/STM32_Timer.cs',
'include @../renode/peripherals/STM32_UART.cs',
'include @../renode/peripherals/ENC28J60.cs',
Expand Down Expand Up @@ -232,14 +233,26 @@ pre-start-commands = [
connector Connect host.tap switch
''',

# Reset reason: power-on reset RCC.CSR.PORRSTF
'rcc resetReason PowerOnReset',

# When we see a write of 0x5fa0004 to SCB.AIRCR (0xE000ED0C)
# then set the SFTRSTF bit (bit 28) in reset-reset RCC.CSR (0x40023874)
'''
sysbus AddWatchpointHook 0xE000ED0C DoubleWord Write "if value == 0x5fa0004: self.NoisyLog('sw triggered reset'); self.Machine['sysbus.rcc'].SetResetReasonSoftwareReset()"
''',

# TODO - check that these are working...
'''
sysbus.usart2 AddLineHook "Reset reason: Could not determine the cause" "Antmicro.Renode.Logging.Logger.Log(LogLevel.Error, line)"
sysbus.usart2 AddLineHook "PANIC" "Antmicro.Renode.Logging.Logger.Log(LogLevel.Error, line)"
sysbus.usart2 AddLineHook "test result: ok" "Antmicro.Renode.Emulator.Exit()"
''',
]
reset = '''
sysbus LoadELF $bin
# Device ID
sysbus WriteDoubleWord 0x1FFF7A10 $id1
sysbus WriteDoubleWord 0x1FFF7A14 $id2
sysbus WriteDoubleWord 0x1FFF7A18 $id3
Expand Down
5 changes: 5 additions & 0 deletions renode/agp.resc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using sysbus

mach create "agp"

include @renode/peripherals/STM32F4_RCC.cs
include @renode/peripherals/STM32_Timer.cs
include @renode/peripherals/STM32_UART.cs
include @renode/peripherals/ENC28J60.cs
Expand Down Expand Up @@ -87,6 +88,10 @@ connector Connect spi2i2s2.ethernet switch
emulation CreateTap $tap "tap"
connector Connect host.tap switch

rcc resetReason PowerOnReset

sysbus AddWatchpointHook 0xE000ED0C DoubleWord Write "if value == 0x5fa0004: self.NoisyLog('sw triggered reset'); self.Machine['sysbus.rcc'].SetResetReasonSoftwareReset()"

sysbus.usart2 AddLineHook "PANIC" "Antmicro.Renode.Logging.Logger.Log(LogLevel.Error, line)"
sysbus.usart2 AddLineHook "test result: ok" "Antmicro.Renode.Emulator.Exit()"

Expand Down
Loading

0 comments on commit a7649fa

Please sign in to comment.