Description
OpenOCD Haskell interface.
Description
Support for OpenOCDs TCL interface
README.md
hocd
OpenOCD RPC service client.
API
See Haddocks or HOCD.Monad
Example
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
import Data.Word (Word32)
import HOCD
main :: IO ()
main = runOCD example >>= print
-- | For STM32G474
example
:: MonadOCD m
=> m ([Word32], Word32, Word32)
example = do
-- Note that halting a target is not required
-- for writing or reading memory, only for reading
-- CPU registers
halt'
-- Read pc CPU register
pc <- readReg $ regName "pc"
-- Write back same value
writeReg @Word32 (regName "pc") pc
-- Read RCC.CR register
rccCr <- readMemCount @Word32 0x40021000 2
-- Read and increment GPIOA.ODR register
let gpioaOdr = 0x48000014
odr <- readMem32 gpioaOdr
writeMem gpioaOdr [odr+1]
r <- readMem32 gpioaOdr
resume
pure (rccCr, r, pc)
This example is runnable from git repository using:
openocd -f nucleo.cfg
cabal run hocd-readme
Executable
hocd-read-mem
can be used to read a single or multiple addresses:
cabal run hocd-read-mem -- 0x40021000 0x48000014
Outputs:
0x40021000: 0x3030500
0x48000014: 0x9