run6x 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env perl
  2. $exe = @ARGV[0];
  3. $exe .= ".out" if (! -f $exe);
  4. die if (! -f $exe);
  5. use CCS_SCRIPTING_PERL;
  6. my $studio=new CCS_SCRIPTING_PERL::CCS_Scripting();
  7. $studio->CCSOpenNamed("*","*",1); # connect to board
  8. $studio->TargetReset();
  9. print "loading $exe\n";
  10. $studio->ProgramLoad($exe);
  11. sub write_string {
  12. my ($studio,$addr,$str) = @_;
  13. my $len = length($str);
  14. my $i;
  15. for ($i=0; $i<$len; $i++) {
  16. $studio->MemoryWrite($CCS_SCRIPTING_PERL::PAGE_DATA,$addr+$i,8,vec($str,$i,8));
  17. }
  18. $studio->MemoryWrite($CCS_SCRIPTING_PERL::PAGE_DATA,$addr+$i,8,0);
  19. return $i+1;
  20. }
  21. $addr= $studio->SymbolGetAddress("__c_args");
  22. printf "setting up __c_args at 0x%X\n",$addr;#\n";
  23. $studio->MemoryWrite($CCS_SCRIPTING_PERL::PAGE_DATA,$addr,32,$#ARGV+1);
  24. for ($i=0,$strings=$addr+($#ARGV+3)*4; $i<=$#ARGV; $i++) {
  25. $off = write_string($studio,$strings,@ARGV[$i]);
  26. $studio->MemoryWrite($CCS_SCRIPTING_PERL::PAGE_DATA,$addr+4*($i+1),32,$strings);
  27. $strings += $off;
  28. }
  29. $studio->MemoryWrite($SCC_SCRIPTING_PERL::PAGE_DATA,$addr+4*($i+1),32,0);
  30. print "running...\n";
  31. $studio->TargetRun();