Skip to main content
Dario BUSONI
ST Employee
December 13, 2022
Solved

External Loader Parsing Error (V2.12.0)

  • December 13, 2022
  • 5 replies
  • 6672 views

Hi,

I have updated STM32CubeProgrammer to version 2.12.0 and our custom External Loader is not load properly anymore. In the EL section I can read "Error: Flash loader error parsing fail" and in the log I can read "Error: Flash loader 'C:\*****/MyExternalLoader.stldr" cannot be loaded."

In 2.11.0 it worked just fine.

Do I have to change anything in my EL project (Dev_Inf.c, Loader_Src.c, linker.ld...) to work in the new version?

Thanks in advance.

Dario

This topic has been closed for replies.
Best answer by Dario BUSONI

Thank you very much Tesla, good advice, it was the structure size, all along. Since I have only 2 types of sectors in my SPI FLASH, my StorageInfo structure was only 136 bytes long instead of 200. I solved by adding 64 padding bytes. After replacing the .stldr file with the fixed one, the error is gone.

typedef struct DeviceSectors
{
 unsigned long		SectorNum; // Number of Sectors
 unsigned long		SectorSize; // Sector Size in Bytes
} device_sector_t;
 
struct StorageInfo
{
 char				DeviceName[100];		// Device Name and Description
 unsigned short	DeviceType;				// Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...
 unsigned long	DeviceStartAddress;		// Default Device Start Address
 unsigned long	DeviceSize;				// Total Size of Device
 unsigned long	PageSize;				// Programming Page Size
 unsigned char	EraseValue;				// Content of Erased Memory
 device_sector_t	sectors[SECTOR_NUM];	// Flash sector types
 unsigned long	padding[16];			// Total size of struct StorageInfo must be 200 bytes
};

5 replies

ST Employee
December 23, 2022

Hello @Dario BUSONI​ ,

Thanks for your feedback,

Could you please specify the MCU and share the used EL for further check?

Thanks,

Sara.

Dario BUSONI
ST Employee
December 23, 2022

Thank you for the answer, the MCU is a STM32G070RBTx.

I'll send the EL project in a private message.

Tesla DeLorean
Guru
December 23, 2022

Could you PM me the .STLDR, don't need the project, issues with the ELF should be more apparent. Thanks.

Perhaps with the symbols it exports, the linker script sections, or the format/content of the StorageInfo structure.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Dario BUSONI
ST Employee
January 2, 2023

Hi,

Thank you for answering. In the V2.11.0 version the same .elf/.stldr file works fine, so those files should still be correct.

I'll PM you the .STLDR, thanks.

ST Employee
December 26, 2022

Hello @Dario BUSONI​ ,

Thanks for raising this issue to our attention,

I submitted an internal Ticket for further check, I'll keep you posted with updates.

Internal ticket number: 141953 (This is an internal tracking number and is not accessible or usable by customers).

  

Sara.

ST Employee
February 14, 2023

Hello @Dario BUSONI​ ,

After further investigation, it turns out that the parsing error is caused by a wrong StorageInfo value, it is expected to be 000000c8 and not 00000088

In previous STM32CubeProgrammer versions, corrupted external loaders were accepted, but starting from v2.12.0 a check is made to display an error when loading a faulty .stldr file.

Let me know if this solves your issue!

Sara.

Dario BUSONI
ST Employee
February 15, 2023

Thank you Sara, I finally managed to solve the issue. My StorageInfo structure was too small (136 bytes instead of 200).

However, the UM2237 does not mention that the StorageInfo structure has to be exactly 200 bytes long (the Dev_Inf.c file is described at page 33). That was the source of the issue (I couldn't know there was a constraint on the structure size). Could you maybe raise a flag to add this information in the UM? Thank you.

Dario BUSONI
ST Employee
February 14, 2023

Hello,

thanks for the update. I've looked for the value you mentioned but I'm having a hard time finding it.

Here is my storage info definition, could you help me find out where is the wrong value?

#define 	SPI_FLASH 7
#define SECTOR_NUM 		2			// Max Number of Sector types
#define MAPPED_ADDRESS				0x90000000 // STM32CubeProgrammer shall see the memory at this address
 
/* This structure contains information used by ST-LINK Utility to program and erase the device */
#if defined (__ICCARM__)
__root struct StorageInfo const StorageInfo = {
#else
struct StorageInfo const StorageInfo = {
#endif
		"M25P16_EVLKST8500GHxxx", 	 	 	// Device Name + version number
		SPI_FLASH, 		// Device Type
		MAPPED_ADDRESS, 		// Device Start Address
		0x00200000, 		// Device Size in Bytes (2MBytes/16Mbits)
		0x00000100, 		// Programming Page Size 256Bytes
		0xFF, 		// Initial Content of Erased Memory
		// Specify Size and Address of Sectors (view example below)
		{
				{ 0x00000020, 0x00010000 }, 		// Sector Num : 32 ,Sector Size: 64KBytes
				{ 0x00000000, 0x00000000 }			// end
		}
};

Tesla DeLorean
Guru
February 14, 2023

Would be sizeof() StorageInfo structure as it gets into the .ELF (STLDR) file.

Could double check size reported in .MAP file, or reported by objcopy or fromelf dumping tools.

From .MAP of one of mine

...
 
.info 0x00000000 0xc8
 *(.rodata.StorageInfo)
 .rodata.StorageInfo
 0x00000000 0xc8 out/Dev_Inf.o
 0x00000000 StorageInfo
 
.prog 0x24000004 0x1b5c
 0x24000004 . = ALIGN (0x4)
 *(.text)
 .text 0x24000004 0x21c c:/ct/tools/gcc49_2014q4/bin/../lib/gcc/arm-none-eabi/4.9.3/armv7e-m\libgcc.a(_arm_addsubsf3.o)
...

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Dario BUSONI
Dario BUSONIAuthorBest answer
ST Employee
February 15, 2023

Thank you very much Tesla, good advice, it was the structure size, all along. Since I have only 2 types of sectors in my SPI FLASH, my StorageInfo structure was only 136 bytes long instead of 200. I solved by adding 64 padding bytes. After replacing the .stldr file with the fixed one, the error is gone.

typedef struct DeviceSectors
{
 unsigned long		SectorNum; // Number of Sectors
 unsigned long		SectorSize; // Sector Size in Bytes
} device_sector_t;
 
struct StorageInfo
{
 char				DeviceName[100];		// Device Name and Description
 unsigned short	DeviceType;				// Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...
 unsigned long	DeviceStartAddress;		// Default Device Start Address
 unsigned long	DeviceSize;				// Total Size of Device
 unsigned long	PageSize;				// Programming Page Size
 unsigned char	EraseValue;				// Content of Erased Memory
 device_sector_t	sectors[SECTOR_NUM];	// Flash sector types
 unsigned long	padding[16];			// Total size of struct StorageInfo must be 200 bytes
};