2019-10-15 08:19 PM
I wrote an ST-Link custom external loader with Init(), Read(), Write(), MassErase(), and SectorErase(). When loading into ST-Link Utility, there is no Write() function found. It is in the map file, it does have a non-zero size and the name is not mangled (extern "C" int Write(...)). Any ideas why ST-Link Util cannot find this function?
2019-10-15 08:27 PM
Using what tools specifically?
Check that it actually exported from the ELF object, perhaps inspect with FromELF or objcopy tools.
As it is not called by any functions within the source it could also be subject to dead code elimination by the linker.
2019-10-15 08:33 PM
#ifdef __ICCARM__ //IAR
#define KeepInCompilation __root
#elif __CC_ARM //MDK-ARM
#define KeepInCompilation __attribute__((used))
#elif TASKING //TrueStudio
#define KeepInCompilation __attribute__((used))
#endif
/* Private function prototypes -----------------------------------------------*/
//int Init (void); // Pre 4.2.0
KeepInCompilation int Init (uint8_t configureMemoryMappedMode);
KeepInCompilation int Write (uint32_t Address, uint32_t Size, uint8_t* buffer);
KeepInCompilation int SectorErase (uint32_t EraseStartAddress ,uint32_t EraseEndAddress);
KeepInCompilation uint64_t Verify (uint32_t MemoryAddr, uint32_t RAMBufferAddr, uint32_t Size, uint32_t missalignement);
2019-10-15 09:05 PM
I'm using IAR 8.40.2.
From readelf:
253: 20000ea9 18 FUNC GLOBAL DEFAULT 5 Init
254: 20000ebb 28 FUNC GLOBAL DEFAULT 5 Read
255: 20000ed7 28 FUNC GLOBAL DEFAULT 5 Write
256: 20000ef3 22 FUNC GLOBAL DEFAULT 5 MassErase
257: 20000f09 26 FUNC GLOBAL DEFAULT 5 SectorErase
All other functions are found with no problems.
My functions are declared as follows in Loader_Src.cpp as follows:
extern "C" __root int Init( void );
extern "C" __root int Read (uint32_t Address, uint32_t Size, uint8_t * buffer );
extern "C" __root int Write (uint32_t Address, uint32_t Size, uint8_t * buffer );
extern "C" __root int SectorErase( uint32_t EraseStartAddress, uint32_t EraseEndAddress );
extern "C" __root int MassErase( void );
I just noticed your "Init" declaration: KeepInCompilation int Init (uint8_t configureMemoryMappedMode);
This is the first time I have seen uint8_t configureMemoryMappedMode in the Init function. What is that meant to do exactly?
2019-10-15 09:22 PM
Forgot to put the stlink versions in:
ST-LINK Utility: v4.5.0.0
STLinkUSBDriver.dll: v5.1.2.0
ST-LINK_CLI.exe: v3.5.0.0
2019-10-15 10:23 PM
Ok, I've tried it using STMCubeProgrammer and it erases and programs just fine.I'm just doing a small RAM buffer example to get the functions working first and then will switch over to my SWD code that programs another chip connected to the STM32. It would have been nice to use STLink Utility, but this will do. I would still like to know what the configureMemoryMappedMode parameter to the Init function is for though.