2022-07-29 12:33 PM
I'm working on a project using an STM32H753XI MCU with a touch display. I am not currently using TouchGFX. I would like to preload images into the onboard QSPI during the project load. How do I go about doing this? I have used TouchGFX designer on other projects and know this is automated while loading the project onto the PCA.
Solved! Go to Solution.
2022-07-29 02:27 PM
Either you can use the CubeProgrammer with a suitable "external loader", or make a simple utility to copy the data from your PC using semihosting I/O.
The latter is slow, not good for large amount of data.
A small example below:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
extern void initialise_monitor_handles(void);
void load_stuff(void)
{
printf("Semihosting! read big file from host\n");
initialise_monitor_handles();
const char * fname = "C:/TMP/stuff.bin";
// if NO path: opens relative to openocd.exe (.../STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.openocd.../tools/bin/)
int fd = open(fname, O_RDONLY|O_BINARY);
if (fd <= 0) {
printf("Error open file!\n");
return;
}
static char buf[4096];
unsigned offset = 0;
while (1)
{
int rc = read(fd, buf, sizeof(buf));
if (rc < 0) {
printf("Error read!\n");
break;
}
if (rc == 0) {
printf("Read: normal end!\n");
break;
}
QSPI_FlashWrite(offset , buf, rc);
offset += (unsigned)rc;
}
printf("Read total: %u\n", offset );
close(fd);
}
2022-07-29 02:27 PM
Either you can use the CubeProgrammer with a suitable "external loader", or make a simple utility to copy the data from your PC using semihosting I/O.
The latter is slow, not good for large amount of data.
A small example below:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
extern void initialise_monitor_handles(void);
void load_stuff(void)
{
printf("Semihosting! read big file from host\n");
initialise_monitor_handles();
const char * fname = "C:/TMP/stuff.bin";
// if NO path: opens relative to openocd.exe (.../STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.openocd.../tools/bin/)
int fd = open(fname, O_RDONLY|O_BINARY);
if (fd <= 0) {
printf("Error open file!\n");
return;
}
static char buf[4096];
unsigned offset = 0;
while (1)
{
int rc = read(fd, buf, sizeof(buf));
if (rc < 0) {
printf("Error read!\n");
break;
}
if (rc == 0) {
printf("Read: normal end!\n");
break;
}
QSPI_FlashWrite(offset , buf, rc);
offset += (unsigned)rc;
}
printf("Read total: %u\n", offset );
close(fd);
}
2022-07-30 12:46 AM
Depends on whether you use CubeProgrammer or OpenOCD inside CubeIDE.
For the former, everything had been said above. For the latter: Use stmqspi driver which comes with OpenOCD. For a sample setup see the cfg-files for stm32h754i-disco.