XIP of nRF52840

Hello,

I want to try the XIP function on the nrf52840 DK,  because we want to use this  function  later.

But i can not find any example of XIP on 52840.  So i  tried to modify the spi flash example, i try to add the ".ld" file,  and successfully saved an array into external flash, then printed part of its contents using the array name, and everything seems to be working correctly.

/* Map custom readonly section into nRF52840 QSPI XIP window. */
.extflash_rodata 0x12100000 : ALIGN(4)
{
KEEP(*(.extflash_rodata))
}

Then i tried to  store one pcm data, then read it and play it  to i2s, but the problem is when i store the array into external flash, there is no sound, and there is not any waves on the i2s-dout line, but if i store the array into internal flash, everything will be ok, sound is good.

When i stored the array into external flash, I have tried to read the data through "flash_read()" first, sound is also ok, but when i use memcpy, there is no sound. But i want to use XIP, so i can not use "flash_read()".

So i do not know what is the problem, the data stored in the external flash is unquestionably correct, as demonstrated by printing and the "flash_read" operation. However, it cannot be directly utilized when feeding data into I2S. Additionally, I have allocated an I2S buffer here and assigned the data to the buffer.

I noticed that there are "Errata 216" and "Errata 215", but i do not know the real problem of me, maybe other configurations fault(devicetree or kconfig), after all i can not find some example.

So, i will give you my project, i used SDK v3.3.0, nrf52840-Preview-DK.

4578.spi_flash.zip

Can you  have a look of my project? now i have add the "__attribute__((section(".extflash_rodata"), used))" to the "__48kHz16bit_mono_voice_smoke_pcm", so there is no sound...

Thank you very much!

Parents
  • Hello,

    /* Map custom readonly section into nRF52840 QSPI XIP window. */
    .extflash_rodata 0x12100000 : ALIGN(4)
    {
    KEEP(*(.extflash_rodata))
    }

    I have looked at yoru code. First I run this and it shows normal output like I2S starts. Later I added few lines in the code to check if the array is linked into the XIP region 0x12100000  as it's in the code. 

    printk("voice addr = %p\n", __48kHz16bit_mono_voice_smoke_pcm);
    
    const int16_t *p = (const int16_t *)__48kHz16bit_mono_voice_smoke_pcm;
    
    printk("First 8 samples:\n");
    for (int i = 0; i < 8; i++) {
        printk("%d ", p[i]);
    }
    printk("\n");

    And prinktk in the TX data blocks to check I2S DMA buffer

    * Prepare TX data blocks */
    	for (tx_idx = 0; tx_idx < NUM_BLOCKS; tx_idx++) {
    		err = k_mem_slab_alloc(&tx_mem_slab, &tx_block[tx_idx], K_FOREVER);
    printk("tx_block = %p\n", tx_block[tx_idx]);
    		if(err) {
    			LOG_ERR("k_mem_slab_alloc() failed. (err %d)", err);
    			return err;

    The output shows good. The array is linked into the XIP region (0x12100000); no issue with that, I2S DMA buffers are in SRAM (ox2003xxx). 

    But I need to find out why first 8 samples shows zero. I will try to print more samples to check if those are still zero even more into the file. I will get back to you soon.

    Thanks.

    BR
    Kazi

  • Hello  Kazi,

    Thank you very much!

    I have found the problem.

    The important thing is that we need add follow api:

    nrf_qspi_nor_xip_enable(flash_dev, true);

     Otherwise the XIP function is not  really enable.

    Thank you very much again for your reply!

    You can close this ticket.

Reply Children
No Data
Related