Why does the AN12218SW bootloader fails to parse the generated .srec file?

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does the AN12218SW bootloader fails to parse the generated .srec file?

Jump to solution
394 Views
roy_vanlierop
Contributor III

When using the supplied S32K148 bootloader application with a S32DS generated .srec file it fails to write phrases which are not aligned. 

roy_vanlierop_0-1620825629334.png

Please NXP: Fix the srecord parser in the Bootloader or fix the generated .srec file

Edit: Found this 6 year old post with exactly the same problem.

Labels (2)
0 Kudos
1 Solution
378 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

the best option is to use a converter which aligns all the s-record lines and which forces all the lines to have the same length. The advantages are: it helps to keep the bootloader small because the parser will be very simple. Second, you can use any IDE / compiler - regardless of output, you will always have s-record file which will be 100% working.

I used this way in AN5319 which is a serial bootloader for MPC5748G. I wrote simple converter for S3 records (it's included in the SW package). But there are tools which can be used for other formats like:

http://srecord.sourceforge.net/man/man1/srec_cat.html

As far as I know, there's no such configuration in S32DS, so we could add some note to AN12218. Thanks for pointing this out.

Regards,

Lukas

View solution in original post

5 Replies
243 Views
lucianomoretti
Contributor IV

Hi Roy:

I've been fighting with this as well: I wanted to point out that even after running the FW through srec_cat or using the obj-copy --srec-len command we still ran into an issue where the last record could still be 4 or 12 byte aligned as the firmware wasn't evenly divisible by 8 bytes and the last write could fail. I ended up having to add padding functionality in the mem_man.c mem_man_write() function.

AFAIK this works right, but I'm experiencing some inconsistency issues that I'm still debugging.

I also added checks of the return value of the FlashProgram() and added in a call to FlashProgramCheck() to verify that the data actually got written correctly. NXP in their rush to get something to "work" and keep it "small" really skimped on the error handling and it has bitten us hard.

	/* Check alignment and pad if needed.
	 * S32 Flash Program takes 8 byte phrases. Misalligned bytes will result in a failed write.
	 */
	uint16_t sizeMod = data_size % 8;
	if(0 != sizeMod){
		/* set remaining bytes of array to 0xFF (default erased value)
		 * extend data_size to match new length.
		 */
		sizeMod = data_size + (8 - sizeMod); /* Generate new size */
		memset((void *) (BP->F.PhraseData + data_size), 0xFF, MAX_DATA_BP - data_size);
		
		data_size = sizeMod;
	}

 

0 Kudos
239 Views
roy_vanlierop
Contributor III

Hello @lucianomoretti,

I can relate to the troubles you went through. The code quality of the bootloader example is much to be desired. That said: the foundation in the form of the flash_drivers is great and very useful. 

The problem you're describing can be easily fixed by using the srec_cat tool. The command line argument "-range-padding" can align your srecord to arbitrary boundaries. The resulting command that I used looked like:

 

"${ProjDirPath}/Tools/srec_cat.exe" ${ProjName}.srec -fill 0x00 -within ${ProjName}.srec -range-padding 256 -address-length=4 -obs=32 -o aligned_${ProjName}.srec

 

Have a look at my other ticket describing the Post-Build steps: LINK

Good luck, hopes this helps!

0 Kudos
379 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

the best option is to use a converter which aligns all the s-record lines and which forces all the lines to have the same length. The advantages are: it helps to keep the bootloader small because the parser will be very simple. Second, you can use any IDE / compiler - regardless of output, you will always have s-record file which will be 100% working.

I used this way in AN5319 which is a serial bootloader for MPC5748G. I wrote simple converter for S3 records (it's included in the SW package). But there are tools which can be used for other formats like:

http://srecord.sourceforge.net/man/man1/srec_cat.html

As far as I know, there's no such configuration in S32DS, so we could add some note to AN12218. Thanks for pointing this out.

Regards,

Lukas

View solution in original post

348 Views
roy_vanlierop
Contributor III

As you're editing AN12218SW, could you also change this:

community.nxp.com/t5/S32-Design-Studio/Changing-BAUD-rate-in-AN12218SW-bootloader-non-zero-reset-values/m-p/1277536

0 Kudos
358 Views
roy_vanlierop
Contributor III

Hello Lukas,

Thank you for your reply. 

When rewriting/editing AN12218, could you also put a note in about the changes in Java licenses? To be honest, the change makes the windows application quite useless. 

0 Kudos