rust-embedded/rust-raspberrypi-OS-tutorials

Initializing UART driver causes execution to freeze.

zrthxn opened this issue · 2 comments

Discussed in #121

Originally posted by zrthxn October 10, 2021
My setup for this is slightly different from the one shown, but only slightly. I'm using aarch64-none-elf-gcc to compile the assembly file and the using -C link-arg=$(BOOT_OBJ) as an argument to rustc to link the object file into the final ELF.
Up until tutorial 05, everything was working fine with QEMU.

Now after introducing tock-registers I'm having trouble initializing the UART driver.
I've narrowed the problem down to this after a couple days of frustration. When I try to access any register, like the control register or flags register, the execution freezes, maybe because of an infinite nop loop?

I'm able to write to the same memory location with write_volatile and that doesn't cause any problems... for example for the CR

// this works
unsafe { core::ptr::write_volatile(0x3F20_1030 as *mut usize, (0b1 << 31)); }

I'm now out of ideas on what to try, I've tried looking at the disassembly with aarch64-none-elf-objdump and that also doesn't give me any immediate clues. I've even compared every line of my diff to the diff in the readme and its almost all the same except for how I've structured my files. I've even tried structuring my files exactly like in the tutorial but alas to no avail.

Are you having the same issues without your GCC modification as well?

Yes. I created a boot.rs module in the cpu module and put the assembly file in there and used include_str! just like your example, and just used rustc to compile the whole thing instead of compiling with gcc and linking with rustc. That didn't fix the issue.
I've put some updates in the discussion, maybe it's better to use that.