2026-03-04 2:49 PM - last edited on 2026-03-06 1:22 AM by Gyessine
I want to be able to program the external flash via VCP. So far, I have taken the combined code from the CM4 and CM7 core, then using memory address 0x90000000, I write to the QSPI using the BSP function:
if (receiving_ext_flash) {
if (BSP_QSPI_Write(0, Buf, qspi_write_address, Len) != BSP_ERROR_NONE) {
CDC_Transmit_FS((uint8_t*)"QSPI Write Error\r\n", strlen("QSPI Write Error\r\n"));
receiving_ext_flash = 0;
return;
}
qspi_write_address += Len;
}
Has anyone tried doing something like this? I have not been able to get this to work.
Thanks!
2026-03-04 5:59 PM
Talking to QSPI and sending/receiving over the VCP are independent. Which one isn't working?
2026-03-05 7:50 AM
The receiving over VCP seems to work fine... I am not sure if it is receiving the bytes properly from the code because I was never able to get the debug mode with the dual core working well.
I realize now that I should store the receiving data into some kind of ring buffer as it gets written into the QSPI.
I guess I am asking more about the concept because so much of the hardware is abstracted on this development board. Is my line of thinking correct? Can I simply use the BSP_QSPI_Write starting at the base address with the data being sent over VCP to the QSPI?
Also, my python script that does the writing converts the hex to binary before sending as such:
def send_binary_data(ser, bin_file, chunk_size):
try:
with open(bin_file, 'rb') as f:
total_sent = 0
while True:
chunk = f.read(chunk_size)
if not chunk:
break
ser.write(chunk)
total_sent += len(chunk)
time.sleep(0.01) #delay
print(f"[INFO] Sent {total_sent} bytes of binary data.")
return True
except Exception as e:
print(f"[ERROR] Failed to send binary data: {e}")
return FalseIs this the correct approach? Any advice here would be helpful because this is all pretty new to me...
Thanks!
2026-03-05 9:24 AM
> Can I simply use the BSP_QSPI_Write starting at the base address with the data being sent over VCP to the QSPI?
Yes.
However, if this is within an interrupt, your code will block until the operation is complete. That's not so good and can cause USB issues. It would be better to send it to a ring buffer and write it out when you have enough data. Maybe chunks of 512 bytes or 4096 bytes.
I recommend writing to the QSPI in a loop that doesn't involve VCP at first. Write values to the entire memory and then read them back and verify. That will ensure QSPI operations are working.
Note that QSPI is flash, not ram, and will need to be erased before it can be written to again.
2026-03-06 1:39 PM
> Is this the correct approach? Any advice here would be helpful because this is all pretty new to me...
Actually this approach is charmingly naïve. The sender program/script does not check the outcome of the writing a chunk. There's no way to retry. Suggesting to find helping hands and/or instructor in programming here. Get the basics of it.
2026-03-09 5:15 AM
Thank you for the advice!
2026-03-09 5:19 AM
>The sender program/script does not check the outcome of the writing a chunk. There's no way to retry.
Thank you for this piece of advice! That is the kind of thing I am looking for.
As for looking for outside help, ideally I would like to figure out how to do this on my own, but I will take into consideration looking for someone if I cannot get this working on my own. I came here looking for more conceptual advice and if it is something that can be/has been done.