//**********************************************************************// // This EXAMPLE shows how to use most needed instructions during the R&D process // This script can be added to H/W Inti Script field of the DCC Loader Settings dialog // for automatic initialization of target state prior DCC Loader uploading. //**********************************************************************// // 1. Setup target connection //***************************// //setup core type system.cpu ARM926EJ ;system.cpu ARM946E ;system.cpu ARM920T ;system.cpu CORTEXA8 ;system.cpu PXA270 ;system.cpu PXA312 ;system.cpu ARM1136J // setup JTAG TCK clock system.jc RTCK ;systen.JC 8MHz // multichain configuration (note: dot is used so script engine interpretes value as decimal) system.config IRPRE 0. system.config IRPOST 0. system.config DRPRE 0. system.config DRPOST 0. ;system.config IRPRE 0. ;system.config IRPOST 12. ;system.config DRPRE 1. ;system.config DRPOST 0. // NOTE: IOVoltage is dedicated RIFF's feature. Is not present in original PRACTICE language system.config IOVoltage 2600. // (in millivolts): selects RIFF BOX's DAC to 2.6V // Reset & Halt the target: system.up // OR Just Halt target break // OR Reset&Halt the target only in case it is not already stopped: if run() system.up // 2. Direct access to memory plus exmample for subroutines //*****************************************************// gosub Example_How_To_Access_Memory // 3. loop/poll example plus example how to pass/receive parameters //*****************************************************// &my_param1=1000. // dot means 'decimal' no 'hexadecimal' value gosub Example_Making_Loop_or_Poll &my_param1 entry &my_result if &my_result==0x00 print "ERROR: Timeout" else print "SUCCESS!!!" // 4. Uploading binary/elf files example //*****************************************************// data.load.binary c:\1234.bin // upload full binary file into default address 0 data.load.binary c:\1234.bin 0x12340000 // upload full binary file into address 0x12340000 data.load.binary c:\1234.bin 0x0000..0x00FF //upload 0x0100 bytes of binary file into address 0x0000 // uploading ELF files data.load.elf c:\elffile.elf // uploads ELF file into RAM memory (since it is ELF all addressing is inside of the ELF file) // if file path/name contains spaces use quotation marks for name: data.load.binary "c:\Documents and Settings\mybinaryfile.bin" 0x1234 // upload full binary file into 0x1234 RAM address // 5. processor registers control example //*****************************************************// r.s R0 0x12345678 // write value 0x12345678 into register R0 register.set R1 0x12 // same as previous 'short' version (r.s), this time write 0x12 into R1 r.s CPSR 0xD3 // write to CPSR register // 6. core execution control example //*****************************************************// r.s PC 0x0000 // setup PC register r.s CPSR 0xD3 // setup CPSR register (bit5=0 == ARM mode) go 0x10 // start core along with setting breakpoint on address 0x10 wait !run() // wait untill core is stopped (that is when PC will reach breakpointed address 0x10) break.delete 0x10 // delete breakpoint manually: delete explicit breakpoint on address 0x10 break.delete /all // delete all breakpoints (this frees for ARM7/ARM9 both h/w breakpoint slots) break.set 0x20 // set breakpoint at address 0x20 break.set 0x30 // set breakpoint at address 0x30 break.set 0x40 // this instruction will generate error for ARM9 core since it has only 2 slots for breakpoints go // start core: this time it just resumes from last PC (which was = 0x10) wait !run() // wait untill core is stopped (will happen only if PC will hit address 0x20 or 0x30) break.delete /all // delete all breakpoints (this frees for ARM7/ARM9 both h/w breakpoint slots) enddo //**********************************************************************// //**********************************************************************// Example_How_To_Access_Memory: // read word from specified address (32-bit access on bus) &my_var32=data.long(0xFFFF0000) // read half word from specified address (16-bit access on bus) &my_var16=data.word(0xFFFF0002) // read byte from specified address (8-bit access on bus) &my_var8=data.byte(0xFFFF0001) // write word into the specified address (32-bit access on bus) using constant and variable &my_var32=&my_var32|0x00100 ;just example of arythmetic operation on variable data.set 0x78000000 %long 0x12345678 data.set 0x78000004 %long &my_var32 // write half word into the specified address (16-bit access on bus) using constant and variable data.set 0x78000000 %word 0x9ABC data.set 0x78000002 %word &my_var16 // write byte into the specified address (8-bit access on bus) using constant and variable data.set 0x78000000 %byte 0xDE data.set 0x78000001 %byte 0xAD data.set 0x78000002 %byte 0xBE data.set 0x78000003 %byte 0xEF data.set 0x78000004 %byte &my_var8 ;return from subroutine return //**********************************************************************// //**********************************************************************// Example_Making_Loop_or_Poll: // take parameters from caller Entry &my_arg1 // for example we assign "i" as loop variable &i=0 while &i<&my_arg1 ( // read some imaginary h/w register &value=data.word(0x0DEADBEE) // check if bit0 is set then make condition to leave loop if &value&0x01==0x01 &i=&my_arg1 &i=&i+1 ) // if variable "i" is equal to my_arg1 then it means cycle timed-out and no bit0 was set during all polling period if &i==&my_arg1 return 0x00 // otherwise pass to caller the 0x01 as first parameter return 0x01 //**********************************************************************//