Reading from D-Flash causes bus fault exception (S32K148)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading from D-Flash causes bus fault exception (S32K148)

Jump to solution
341 Views
Moh-Moh
Contributor II

Hi there,

I'm having a strange issue where we have partitioned the flash into p flash and d-flash using the NXP example (flash_partitioning_s32k148). 

After loading on the next application, and attempting to read from flash addresses 0x10000000, I am seeing a bus fault handler exception from the MCU. 

Using Eclipse IDE, and using the memory window I can see the data inside this region of flash (0x10000000 onwards), so am unsure what the issue is.

For reference the piece of code Im using is a very simple one and is below 

 

    status_t ret;        /* Store the driver APIs return code */
    uint32 * address;
    uint32 i = 0u;
    uint32 data2[10] = 0u;

    /* Always initialize the driver before calling other functions */
    ret = FLASH_DRV_Init(&Flash1_InitConfig0, &flashSSDConfig);
    DEV_ASSERT(STATUS_SUCCESS == ret);

    for (i = 0; i < 10; i++)
    {
        address = (uint32*)(flashSSDConfig.DFlashBase + (i * 4));
        data2[i] = *address;
    }

 

 

Any help on how to read this region of flash would be very much appreciated

0 Kudos
Reply
1 Solution
313 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Moh-Moh 

wasn't the partition already set before running flash_partitioning_s32k148?

If partition is not set and if you run the example from RAM then Erase All Blocks command is executed. This ensures that everything is in default state and the flash is completely erased. Then it should be possible to read data flash at 0x10000000.

I did quick check on my side and I can't see this problem. Everything works as expected.

To start over, you can try to run this piece of code from the example regardless of EEESize:

lukaszadrapa_0-1722410263123.png

 

In other words, this code is executed only if partition is not set yet. You can modify the condition to run this code in any case. Then the device will be completely erased and I believe the problem will disappear.

Regards,

Lukas

View solution in original post

2 Replies
298 Views
Moh-Moh
Contributor II

Hi Lukas, 

 

Thanks for the help on this! For those that come after me, the actual issue lay with the MPU for me. The application did not have these memory locations as a defined region, and so threw a bus fault when a read was attempted outside mpu defined memory spaces 

0 Kudos
Reply
314 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Moh-Moh 

wasn't the partition already set before running flash_partitioning_s32k148?

If partition is not set and if you run the example from RAM then Erase All Blocks command is executed. This ensures that everything is in default state and the flash is completely erased. Then it should be possible to read data flash at 0x10000000.

I did quick check on my side and I can't see this problem. Everything works as expected.

To start over, you can try to run this piece of code from the example regardless of EEESize:

lukaszadrapa_0-1722410263123.png

 

In other words, this code is executed only if partition is not set yet. You can modify the condition to run this code in any case. Then the device will be completely erased and I believe the problem will disappear.

Regards,

Lukas