This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Data abort handler in Cortex M4

Hi,
I wanted to know is there away to simulate data abort handler in cortex M4, I wanted to run some bin images from third party libraries, so I wanted to capture the data access to certain memory areas and replace the required answers to them to some custom error data that I want.

Parents
  • Some foundational skills would help significantly.
    Basic file manipulation via fopen, fseek, fread, fwrite, fclose, etc
    Object file formats, working understanding of .BIN, .HEX and .ELF/AXF
    Use of a Hex Editor
    Use of a Object File Disassembler, like FromELF
    Basic understanding of assembler and opcodes, or machine code

    I did these types of things as a teenager before the internet, so can't be that hard today. If you are truly interested in such things it really doesn't need to be a spoon-feeding exercise where others explain all the details.

Reply
  • Some foundational skills would help significantly.
    Basic file manipulation via fopen, fseek, fread, fwrite, fclose, etc
    Object file formats, working understanding of .BIN, .HEX and .ELF/AXF
    Use of a Hex Editor
    Use of a Object File Disassembler, like FromELF
    Basic understanding of assembler and opcodes, or machine code

    I did these types of things as a teenager before the internet, so can't be that hard today. If you are truly interested in such things it really doesn't need to be a spoon-feeding exercise where others explain all the details.

Children
  • I have managed to trap the memfault, but if I try to use it more than once, the next time I access the violaing memory, it would generate hardfault!!!

    See the code

    #include "LPC43xx.h"                    // Device header
    
    int i=0;
    int main(void)
    {
        static int test;
    
            MPU->RNR = 0;//indicate MPU region 0
            MPU->RBAR = 0x00000000; // update the base address for the region 0
            MPU->RASR = 0x0307003F;
            test = MPU->RASR;
    
            MPU->RNR = 6;
            MPU->RBAR = 0x20080000; // update the base address for the region 6
            MPU->RASR = 0x0007001B;
    
            i = MPU->RASR;
    
            SCB->SHCSR |=(1<<16); //Enable Memory management fault
            MPU->CTRL |= 1;//enable MPU
    
        for(i=0;i<10;i++)
        {
            test = (*(unsigned int *)0x20080000);
        }
    
        while(1)
        {
            i++;
    
        }
    
    }
    
    __asm void __setPsp();
    int value;
    void HardFault_Handler (void)
    {
        int r1;
        value=r1;
    
    __setPsp();
    
    }
    
    __asm void __setPsp()
    {
            add r13,32
            ldr r14,[r13]
            add r14,#2
            mov r0,#0
            MSR IPSR,r0
            mov r15,r14
    }
    
    void MemManage_Handler(void)
    {
            __setPsp();
    }
    
    

    Isn't it suppose to generate memfault again?