T32 Simulator: Basic Instruction set sim for ARMM3

The T32 can simulate bare instruction sets without periphery.
For the Cortex-M3 we have complete NVIC model including Systick Timer.
Currently a simple CiAO can run on the simulator.

TODO:
 - Let memlogger log all memory accesses.
 - Interact with FailT32 for a complete simulation/FI
This commit is contained in:
Martin Hoffmann
2013-03-20 17:17:38 +01:00
parent f0e26a9b63
commit 96bc39c05d
42 changed files with 5880 additions and 46 deletions

View File

@ -0,0 +1,43 @@
## Setup T32 target architecture for startup scripts
if(EXISTS $ENV{T32SYS})
SET(T32_SYS $ENV{T32SYS})
message(STATUS "[FAIL*] T32 base directory: T32SYS=${T32_SYS}")
else()
message(FATAL_ERROR "Please set env variable T32SYS to a valid T32 installation base directory.")
endif()
if(EXISTS $ENV{FAIL_ELF_PATH})
SET(T32_ELF_PATH $ENV{FAIL_ELF_PATH})
message(STATUS "[FAIL*] T32 ELF under test: ${T32_ELF_PATH}")
else()
message(FATAL_ERROR "Please set the FAIL_ELF_PATH enviroment variable to the binary under test.")
endif()
OPTION( T32_SIMULATOR "Start LAuterbach as instruction set simulator. No hardware needed." OFF)
if(T32_SIMULATOR)
set(T32_USB_OR_SIM "SIM")
else()
set(T32_USB_OR_SIM "USB")
endif()
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/cmm)
configure_file(config.t32.in ${PROJECT_BINARY_DIR}/cmm/config.t32)
configure_file(t32.cmm.in ${PROJECT_BINARY_DIR}/cmm/t32.cmm)
set(T32_ARCHITECTURE armm3 CACHE PATH "Setup target architecture for default cmm scripts (currently only armm3)")
set(T32_EXE "${T32_SYS}/bin/pc_linux64/" CACHE INTERNAL "") # TODO: set pc_linux64 for 64 bit systems
add_subdirectory(${T32_ARCHITECTURE})
message(STATUS "[FAIL*] T32 Architecture: ${T32_ARCHITECTURE}")
message(STATUS "[FAIL*] T32 CPU name: ${T32_CPUNAME}")
message(STATUS "[FAIL*] T32 Executable: ${T32_EXE}")
add_custom_target(runt32
COMMAND T32CONFIG=${PROJECT_BINARY_DIR}/cmm/config.t32 ${T32_EXE} &
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/cmm"
COMMENT "Starting Lauterbach."
)

View File

@ -0,0 +1,22 @@
### Configure cmm Scripts for ARM Cortex-M3
if(EXISTS $ENV{T32SYS})
SET(T32_SYS $ENV{T32SYS})
else()
message(FATAL_ERROR "Please set env variable T32SYS to valid T32 installation base directory.")
endif(EXISTS $ENV{T32SYS})
if(T32_SIMULATOR)
set(T32_OFF_FOR_SIM ";")
else()
set(T32_OFF_FOR_SIM " ")
endif()
set(T32_EXE "${T32_EXE}/t32marm-qt" CACHE INTERNAL "")
set(T32_CPUNAME STM32F103RG CACHE PATH "CPU name for SYSTEM.CPU call. (e.g. STM32F103RG)")
configure_file(armm3cfg.cmm.in ${PROJECT_BINARY_DIR}/cmm/armm3cfg.cmm)
configure_file(init.cmm.in ${PROJECT_BINARY_DIR}/cmm/init.cmm )
configure_file(loadelf.cmm ${PROJECT_BINARY_DIR}/cmm/loadelf.cmm COPYONLY)
configure_file(t32term.cmm ${PROJECT_BINARY_DIR}/cmm/t32term.cmm COPYONLY)

View File

@ -0,0 +1,169 @@
;========================================================================
; CPU setup
IF SYSTEM.MODE()<5
(
SYStem.RESet
SYStem.CPU @T32_CPUNAME@
SYStem.Up
)
;========================================================================
; Flash declaration
FLASH.RESet
GOSUB FlashDeclaration
ENDDO
;========================================================================
; Flash declaration depending on selected CPU
FlashDeclaration:
LOCAL &FlashSize
LOCAL &RAMSize
IF ((CPU()=="STM32F100C4")||(CPU()=="STM32F100R4")||(CPU()=="STM32F101C4")||(CPU()=="STM32F101R4")||(CPU()=="STM32F101T4")||(CPU()=="STM32F102C4")||(CPU()=="STM32F102R4"))
(
&FlashSize=0x4000
&RAMSize=0x1000
)
ELSE IF ((CPU()=="STM32F103C4")||(CPU()=="STM32F103R4")||(CPU()=="STM32F103T4"))
(
&FlashSize=0x4000
&RAMSize=0x1800
)
ELSE IF ((CPU()=="STM32F100C6")||(CPU()=="STM32F100R6"))
(
&FlashSize=0x8000
&RAMSize=0x1000
)
ELSE IF ((CPU()=="STM32F101C6")||(CPU()=="STM32F101R6")||(CPU()=="STM32F101T6")||(CPU()=="STM32F102C6")||(CPU()=="STM32F102R6"))
(
&FlashSize=0x8000
&RAMSize=0x1800
)
ELSE IF ((CPU()=="STM32F103C6")||(CPU()=="STM32F103R6")||(CPU()=="STM32F103T6"))
(
&FlashSize=0x8000
&RAMSize=0x2800
)
ELSE IF ((CPU()=="STM32F100C8")||(CPU()=="STM32F100R8")||(CPU()=="STM32F100V8"))
(
&FlashSize=0x10000
&RAMSize=0x2000
)
ELSE IF ((CPU()=="STM32F101C8")||(CPU()=="STM32F101R8")||(CPU()=="STM32F101T8")||(CPU()=="STM32F101V8")||(CPU()=="STM32F102C8")||(CPU()=="STM32F102R8"))
(
&FlashSize=0x10000
&RAMSize=0x2800
)
ELSE IF ((CPU()=="STM32F103C8")||(CPU()=="STM32F103R8")||(CPU()=="STM32F103T8")||(CPU()=="STM32F103V8")||(CPU()=="STM32F105R8")||(CPU()=="STM32F105V8"))
(
&FlashSize=0x10000
&RAMSize=0x2800
)
ELSE IF ((CPU()=="STM32F100CB")||(CPU()=="STM32F100RB")||(CPU()=="STM32F100VB"))
(
&FlashSize=0x20000
&RAMSize=0x2000
)
ELSE IF ((CPU()=="STM32F101CB")||(CPU()=="STM32F101RB")||(CPU()=="STM32F101VB")||(CPU()=="STM32F102CB")||(CPU()=="STM32F102RB"))
(
&FlashSize=0x20000
&RAMSize=0x4000
)
ELSE IF ((CPU()=="STM32F103CB")||(CPU()=="STM32F103RB")||(CPU()=="STM32F103VB"))
(
&FlashSize=0x20000
&RAMSize=0x5000
)
ELSE IF ((CPU()=="STM32F105RB")||(CPU()=="STM32F105VB"))
(
&FlashSize=0x20000
&RAMSize=0x8000
)
ELSE IF ((CPU()=="STM32F107RB")||(CPU()=="STM32F107VB"))
(
&FlashSize=0x20000
&RAMSize=0x8000
)
ELSE IF ((CPU()=="STM32F101RC")||(CPU()=="STM32F101VC")||(CPU()=="STM32F101ZC"))
(
&FlashSize=0x40000
&RAMSize=0x8000
)
ELSE IF ((CPU()=="STM32F103RC")||(CPU()=="STM32F103VC")||(CPU()=="STM32F103ZC"))
(
&FlashSize=0x40000
&RAMSize=0xc000
)
ELSE IF ((CPU()=="STM32F105RC")||(CPU()=="STM32F105VC")||(CPU()=="STM32F107RC")||(CPU()=="STM32F107VC"))
(
&FlashSize=0x40000
&RAMSize=0x10000
)
ELSE IF ((CPU()=="STM32F101RD")||(CPU()=="STM32F101VD")||(CPU()=="STM32F101ZD"))
(
&FlashSize=0x60000
&RAMSize=0xc000
)
ELSE IF ((CPU()=="STM32F103RD")||(CPU()=="STM32F103VD")||(CPU()=="STM32F103ZD"))
(
&FlashSize=0x60000
&RAMSize=0x10000
)
ELSE IF ((CPU()=="STM32F101RE")||(CPU()=="STM32F101VE")||(CPU()=="STM32F101ZE"))
(
&FlashSize=0x80000
&RAMSize=0xc000
)
ELSE IF ((CPU()=="STM32F103RE")||(CPU()=="STM32F103VE")||(CPU()=="STM32F103ZE"))
(
&FlashSize=0x80000
&RAMSize=0x10000
)
ELSE IF ((CPU()=="STM32F101RF")||(CPU()=="STM32F101VF")||(CPU()=="STM32F101ZF")||(CPU()=="STM32F103RF")||(CPU()=="STM32F103VF")||(CPU()=="STM32F103ZF"))
(
&FlashSize=0xc0000
&RAMSize=0x18000
)
ELSE IF ((CPU()=="STM32F101RG")||(CPU()=="STM32F101VG")||(CPU()=="STM32F101ZG")||(CPU()=="STM32F103RG")||(CPU()=="STM32F103VG")||(CPU()=="STM32F103ZG"))
(
&FlashSize=0x100000
&RAMSize=0x18000
)
ELSE
(
PRINT %ERROR "FLASH size of CPU type is unknown"
ENDDO
)
IF &FlashSize>=0x40000
(
FLASH.Create 1. 0x08000000++(&FlashSize-0x01) 0x800 TARGET Word
)
ELSE
(
FLASH.Create 1. 0x08000000++(&FlashSize-0x01) 0x400 TARGET Word
)
IF &FlashSize>0x80000
(
FLASH.TARGET 0x20000000 0x20001000 0x800 ~~/demo/arm/flash/word/stm32f100xl.bin
)
ELSE IF &RAMSize>=0x1800
(
FLASH.TARGET 0x20000000 0x20000800 0x800 ~~/demo/arm/flash/word/stm32f100.bin
)
ELSE IF &RAMSize>=0x1000
(
FLASH.TARGET 0x20000000 0x20000800 0x400 ~~/demo/arm/flash/word/stm32f100.bin
)
ELSE
(
DIALOG.OK "Not enough memory for flash algorithm."
ENDDO
)
RETURN

View File

@ -0,0 +1,64 @@
;RESET
&t32scriptdir=OS.PPD()
;========================================================================
; CPU setup
SYStem.RESet
IF (SIMULATOR())
(
SYS.DOWN
AREA.view
SIM.UNLOAD
SIM.LOAD @T32_MEMLOGGER_LIB@
SIM.LOAD @T32_NVIC_LIB@
SIM.LIST
SYS.CPU cortexm3
SYS.UP
)
ELSE
(
if OS.FILE(&(t32scriptdir)/armm3cfg.cmm)
(
DO &(t32scriptdir)/armm3cfg.cmm
)
)
IF (SIMULATOR())
(
DATA.LOAD.ELF &appimage
; Copy first bytes to address 0 to make simulator work
DATA.COPY 0x8000000++0x200 0x00
; Load Stack pointer and Instruction Pointer
REGISTER.RES
; Be aware of the HACK!
; To get over the RCC Initialisation, we have to get to the second read
; of the RCC Register and inject some initilized looking values.
; for STM32
BREAK.SET 0x40021000 /Read /DISableHit /Count 2
GO
wait !state.run()
DATA.SET 0x40021000 %long ~0
DATA.SET 0x40021004 %long 0x8
)
else
(
;========================================================================
; Flash programming
;
DO &(t32scriptdir)/loadelf.cmm
)
;========================================================================
; Optional Parts
if OS.FILE(&(t32scriptdir)/t32term.cmm)
(
DO &(t32scriptdir)/t32term.cmm
)
ENDDO

View File

@ -0,0 +1,15 @@
;========================================================================
; Flash programming example
FLASH.ReProgram ALL /Erase
Data.LOAD.elf &appimage /GNU /CPP /GLOBTYPES
FLASH.ReProgram off
; Verify flash programming
Data.LOAD.ELF &appimage /ComPare
; Reset device
SYStem.Down
SYStem.Up
Symbol.Demangle ON ON

View File

@ -0,0 +1,6 @@
; This is currently output only, to support input we'd need a separate buffer
TERM.METHOD BUFFERE e:_ZN2hw3hal7T32Term9OutBufferE e:_ZN2hw3hal7T32Term9OutBufferE
TERM.MODE ASCII
TERM.GATE

View File

@ -0,0 +1,58 @@
;
;please refer the installation guide for more information
;about your configuration
;
;
;uncomment the following 3 lines if you don't use already environment variables
;changes to the actual directory names are necessary
;OS=
;SYS=/opt/t32
;TMP=/usr/tmp
;
;uncomment the following 4 lines if you use PowerTrace, PowerNexus or PowerDebugEthernet
;with onhost driver executable (t32m*) via ethernet interface
;the nodename is only the default name, please replace it with the actual node name
;PBI=
;NET
;NODE=t32
;PACKLEN=1024
;uncomment the following 2 lines if you use PowerTrace, PowerNexus, PowerDebugEthernet or
;PowerDebugInterface USB with onhost driver executable (t32m*) via USB interface
;please refer the installation manual (file icd_quick_installation.pdf) about more details
;concerning USB driver installation
PBI=@T32_USB_OR_SIM@
;
;uncomment the following 3 lines if you use an ICE or PodbusEthernetController
;with standard hostdriver executable (t32cde) via ethernet interface
;the nodename is only the default name, please replace it with the actual node name
;LINK=NET
;NODE=t32
;PACKLEN=1024
;uncomment the following 1 lines if you use SCSI interface (ICE)
;LINK=SCSI
;uncomment the following 3 lines if you want to use TRACE32 fonts
;SCREEN=
;FONT=DEC
;FONT=SMALL
;uncomment the following 2 lines if you want to use TRACE32 bitmap fonts
;SCREEN=
;FONTMODE=3
;uncomment the following 2 lines if you use OPENWINDOWS
;SCREEN=
;WMGR=OW16
;uncomment the following 2 lines if you use MOTIF
;SCREEN=
;WMGR=MOTIF16
RCL=NETASSIST
PACKLEN=1024
PORT=@T32_PORTNUM@

10
scripts/t32cmm/t32.cmm.in Normal file
View File

@ -0,0 +1,10 @@
;===== Cortex-M3 Lauterbach initialisation ====
&appimage="@T32_ELF_PATH@"
DO init.cmm
;VAr.Frame /LOCALS /CALLER
REGISTER /SPOTLIGHT
;Data.ListAsm