Git Product home page Git Product logo

Comments (4)

binaryfields avatar binaryfields commented on April 28, 2024

The asm output for the 1st variant (loop over values) generates 32-bit load/stores

   801d8:   ldr   w8, [x1]
   801dc:   movk  w21, #16128, lsl #16
   801e0:   str   w8, [x0, #20]
   801e4:   ldr   w8, [x1, #4]
   801e8:   stp   w8, wzr, [x0, #24]

The second variant (copy_from_slice) seems to use one 64-bit load/store

   801d8:   ldr   x8, [x1]
   801dc:   movk  w21, #16128, lsl #16
   801e0:   str   wzr, [x0, #28]
   801e4:   stur  x8, [x0, #20]

I'm not sure why one would work and not the other.

from rust-raspberrypi-os-tutorials.

andre-richter avatar andre-richter commented on April 28, 2024

Hi,

the cluprit is 801e4: stur x8, [x0, #20], resulting from mbox.buffer[5..7].copy_from_slice(&data[0..2]);, which is indeed an unaligned data access. It tries to store a 64bit word to a non-64bit-aligned address (20%8 != 0).

This causes a synchronous exception in AArch64, that's why your RPi3 hardware just halts.
If you port your code to chapter 0E and insert it after vector tables have been set up, you would get prints from the exception handler pointing you directly to this instruction address. You need to disable the MMU setup though (I opened #11 to remind myself to investigate this).

from rust-raspberrypi-os-tutorials.

binaryfields avatar binaryfields commented on April 28, 2024

Ah, thank you for the pointer and the explanation. That makes perfect sense now. Exceptions are next on my list so I guess now will be as good of a time as ever to jump into them.

Big thanks for the work on this repo and other embedded crates. They made the experience of porting my C64 emulator to bare-metal RPI3 quite enjoyable!

Cheers,

from rust-raspberrypi-os-tutorials.

andre-richter avatar andre-richter commented on April 28, 2024

Glad to hear, thanks 👍

I'll go ahead and close this, and try to get +strict-align upstream so this doesn't happen anymore.

from rust-raspberrypi-os-tutorials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.