rp2040 host usb and xip ssi problem the rp2040 work a host usb when attached the usb device the program stop after the replace this function (flash-bulk-read) by memcpy and re-try the system normal work note i-used this function to fast read data from flash memory and this function allocate into RAM
please help me to resolve this problem and the code is blew
void __no_inline_not_in_flash_func(flash_bulk_read)(uint32_t *rxbuf, uint32_t flash_offs, size_t len, uint dma_chan) {
/**/
// Configure and start the DMA. Note we are avoiding the dma_*() functions
// as we can't guarantee they'll be inlined
dma_hw->ch[dma_chan].read_addr = (uint32_t) & ssi_hw->dr0;
dma_hw->ch[dma_chan].write_addr = (uint32_t) rxbuf;
dma_hw->ch[dma_chan].transfer_count = len;
// SSI must be disabled to set transfer size. If software is executing
// from flash right now then it's about to have a bad time
ssi_hw->ssienr = 0;
ssi_hw->ctrlr1 = len; // NDF, number of data frames
ssi_hw->dmacr = SSI_DMACR_TDMAE_BITS | SSI_DMACR_RDMAE_BITS;
ssi_hw->ssienr = 1;
// Other than NDF, the SSI configuration used for XIP is suitable for a bulk read too.
// Must enable DMA byteswap because non-XIP 32-bit flash transfers are
// big-endian on SSI (we added a hardware tweak to make XIP sensible)
dma_hw->ch[dma_chan].ctrl_trig =
DMA_CH0_CTRL_TRIG_BSWAP_BITS |
DREQ_XIP_SSIRX << DMA_CH0_CTRL_TRIG_TREQ_SEL_LSB |
dma_chan << DMA_CH0_CTRL_TRIG_CHAIN_TO_LSB |
DMA_CH0_CTRL_TRIG_INCR_WRITE_BITS |
DMA_CH0_CTRL_TRIG_DATA_SIZE_VALUE_SIZE_WORD << DMA_CH0_CTRL_TRIG_DATA_SIZE_LSB |
DMA_CH0_CTRL_TRIG_EN_BITS;
// Now DMA is waiting, kick off the SSI transfer (mode continuation bits in LSBs)
ssi_hw->dr0 = (flash_offs << 8u) | 0xa0; /*address + instruction as 8 bnit*/
tight_loop_contents();
tight_loop_contents();
// Wait for DMA finish
while (dma_hw->ch[dma_chan].ctrl_trig & DMA_CH0_CTRL_TRIG_BUSY_BITS);
// Reconfigure SSI before we jump back into flash!
ssi_hw->ssienr = 0;
ssi_hw->ctrlr1 = 0; // Single 32-bit data frame per transfer
ssi_hw->dmacr = 0;
ssi_hw->ssienr = 1;
}
void rgbScanline(uint16_t y, st_VgaMainData_t *mainData, uint16_t *pixels) {
static uint32_t index = 0;
if (y == 0) {
index = 0;
}
flash_bulk_read((uint32_t *) & pixels[0], (uint32_t) ((&screen_1024x768_565[0]) + (index * IMAGE_WIDTH)), (IMAGE_WIDTH >> 1), 2);
index++;
}
the main function
int main() {
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
gpio_put(25, 0);
/*VGA Init*/
st_VgaConfig_t config = {0};
config.stMainParams = vgaGetMainData(VGA_1280_1024_60HZ, 2);
config.pFunscanlinePixel = rgbScanline;
vgaInit(config);
/*USB- Init*/
usb_init(0); // init with root hub 0
while (true) {
usb_host_callback();
gpio_put(25, 1);
sleep_ms(100);
gpio_put(25, 0);
sleep_ms(100);
}
}
when replace this function by memcpy the system work but speed is reduced