FTP Server Unaligned Memory failure
STM32H743
STM32CubeIDE - Version: 1.14.1 Build: 20064_20240111_1413 (UTC)
STM32CubeMX - Version: 6.10.0-RC9 Build: 20231120-2037 (UTC)
Software Pack (AzureRTOS) 3.2.0
STM32Cube_FW_H7_V1.11.1
OS: Linux LMint 21
I am using the FTP server which works when compiled with Optimization None(-O0).
However, if I compile with Optimization Debug(-Og), the application ends up in the Hard_Fault Handler.
The fault analyzer is showing Bus, memory management or usage fault (FORCED)
with Usage Fault Details of Attempt to perform an unaligned access (UNALIGNED).
With Optimization None(-O0), I placed a break just before the fault which is:
if (attributes & FX_READ_ONLY)
{
memcpy(&buffer_ptr[1], "r--r--r--", 9); /* Use case of memcpy is verified. */
}
else
{
memcpy(&buffer_ptr[1], "rw-rw-rw-", 9); /* Use case of memcpy is verified. */
}
at line 3480 (line 1 above) of the -nx_ftp_server_command_process() call in the nxd_ftp_server.c file.
The fault occurs at line 3486 (line 7 above) when Optimization is anything other than None.
When Optimization is None line 3486 executes OK and the target memory looks like this:

as it should. With Optimization set to anything other than None and the fault occurs the target memory is untouched.
A work around might be to just use Optimization set to None, but that causes problems elsewhere in the code as well as running very slow compared to Optimization on.
Difficult to believe this is a code bug in the FTP server. More likely a problem with the tool.

