Extract .s19 from module

Discussion to talk about software related topics only.
Post Reply
caleb
Posts: 7
Joined: Wed Nov 20, 2013 12:05 pm

Extract .s19 from module

Post by caleb »

Is there a means to extract the .s19 off of a MOD5272? We are trying to determine the exact version of the .s19 binary that we loaded onto it.
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: Extract .s19 from module

Post by Chris Ruff »

no.

You can, however, calculate a checksum or CRC of the resultant FLASH image- load each of your previous versions into an dentical board and get the flash checksums or CRCs in a list.

Then whichever version matches the one in your device- is the version you have loaded in there.

Chris
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: Extract .s19 from module

Post by pbreed »

If you have the s19 and you want to know what one you have....

Boot to the monitor 'A' to abort... etc...

From the monitor command prompt (Mod5272 specific addresses)

type md.l ffc08000

This will dump out some bytes....

Now load your canidate version into a different MOD5272 and do the same test...
when the number are the same you found the correct image....
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: Extract .s19 from module

Post by pbreed »

I have some tools that I can sometimes extract an _APP.S19 from a module, but
I would have to have physical possession of the module and I will only use these if you can
really convince me that you have legitimate rights to the code you are trying to extract.

We deliberately make this a bit hard to do so we can protect the developers that use our environment from having their code stolen.


Paul
caleb
Posts: 7
Joined: Wed Nov 20, 2013 12:05 pm

Re: Extract .s19 from module

Post by caleb »

Thanks for the suggestions. I think I can work some "Monitor" memory commands to get a good feel for which binary is which. Some microcontroller make it easy to read-back the binary until you blow a "lock-bit" fuse or some other gimmick, and then it will protect your IP, so I was just having wishful thinking on the NB.

I wouldn't suppose there is any auto-version rolling option in NB Eclipse? It'd be nice in the future to have every compilation have a unique number that can be queried from a console. We currently do that with a manual version string, but of course people tend to forget to roll it.

Actually, maybe I should just combine your ideas and calculate a CRC for the entire memory space and report that back.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: Extract .s19 from module

Post by pbreed »

The compcode step can caluclate a SHA-1 checksum of the image.
-D

I need to dig it up but I have code to calculate this same value from within the app...

so you can verify....

Mostly I just use the DATE and TIME macros when compiling...
pevans
Posts: 2
Joined: Fri Sep 21, 2012 1:05 pm

Re: Extract .s19 from module

Post by pevans »

I got the original code from somewhere, but now it has been added as a menu option from the diagnostic menu that is available in my code. Because of regulation agencies require ability to randomly select one of our products and require us to be able to verify it is running the exact code that we told them it was. Below is the function that is called from the menu option, and hasn't failed the check yet. It writes from flash to the SD card, which then can be removed and checked for comparison with the .S19 file they have secured. It was designed for a MOD5270 with SD card wired like the development board.

Code: Select all

// Used to read from the flash, the current running software and write it to a file
void write_app_file(int fd)
{
	char write_buf[WRITE_BUFSIZE];
	FlashStartUpStruct *psu = ( FlashStartUpStruct * ) &FlashAppBase;
	int out_len = psu->dwSrcBlockSize + sizeof( FlashStartUpStruct );
	unsigned long cur_addr =(DWORD)&FlashAppBase;
	unsigned char * cp = ( unsigned char * ) &FlashAppBase;

	sprintf (write_buf, "\r\n***** OPENING FILE FOR STREAM *****\r\n" );
	writestring(fd, write_buf);

	f_enterFS();
	InitSD(); // SD card initialization script
	F_FILE* fp;

	fp = f_open( APP_FILE, "a" );
	if ( fp )
	{
	   siprintf( write_buf, "S0%s\r\n", PlatformName );
	   f_write( write_buf, 1, strlen( write_buf ), fp );

	   while ( out_len )
	   {
		  int mklen;
		  if ( out_len > 16 )
		  {
			 mklen = 16;
		  }
		  else
		  {
			 mklen = out_len;
		  }
		  WriteS3_SD( fp, cur_addr, cp, mklen );
		  out_len -= mklen;
	   }
	   siprintf( write_buf, "S70502000000F8\r\n" );
	   f_write( write_buf, 1, strlen( write_buf ), fp );
	   f_close(fp);
	}
	else
	{
		sprintf (write_buf, "\r\n*** Error opening file \"%s\", fp = %d\r\n", APP_FILE, (int)fp );
		writestring(fd, write_buf);
	}
	UnmountSD(); // quick unmount script.
	f_releaseFS();

	sprintf (write_buf, "\r\n***** FILE SAVE COMPLETE *****\r\n" );
	writestring(fd, write_buf);

}
Hope this helps, figured it might be close to what you are looking for.
Post Reply