BrianSidebotham / arm-tutorial-rpi

Raspberry-Pi Bare Metal Programming in C Tutorial
https://www.valvers.com/open-software/raspberry-pi/bare-metal-programming-in-c-part-1/
MIT License
587 stars 177 forks source link

Problem with interrupts on the Pi2 #6

Closed StuartCartmill closed 4 years ago

StuartCartmill commented 8 years ago

I am having a problem with interrupts on the Pi2. It appears that the first interrupt causes execution to jump to somewhere and not return. I have checked the disassembly listing and the vector table looks ok.Has anyone had this problem and fixed it?

sergio-uma commented 5 years ago

I had the same issue because I updated the firmware (bootcode.bin & start.elf) and from that moment my RPi 2 model B (v1.1) goes to hypervisor mode (0x1A). I put this code just before IVT copy:

.arch_extension sec
.arch_extension virt
    mrs     r0, cpsr
    and     r0, r0, #0x1F
    cmp     r0, #CPSR_MODE_SVR
    beq     svc_mode
    mov     r0, #CPSR_MODE_SVR
    msr     spsr_cxsf, r0
    add     r0, pc, #4
    msr     ELR_hyp, r0
    eret
svc_mode:

And now it is working properly.

BrianSidebotham commented 4 years ago

@sergio-uma Thanks for reporting this. I have only recently been able to fix the entire tutorial set. Just part-5 to go now. All the rest work across the complete set of RPI hardware, including RPI4.