Trying to compile Rust code for a RG300 console (retrofw buildroot, mipsel, uclibc...)

Hmmm:

# gdb foo
...
Reading symbols from foo...done.
warning: Unsupported auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/retrofw/foo.
(gdb) r
Starting program: /home/retrofw/foo 

Program received signal SIGILL, Illegal instruction.
0x5555a4d4 in core::mem::zeroed::h85bfc6085f88bd9d () at /home/alex/git/buildroot/output/build/host-rust-1.33.0/src/libcore/mem.rs:497
497     /home/alex/git/buildroot/output/build/host-rust-1.33.0/src/libcore/mem.rs: No such file or directory.
(gdb) display/i $pc
1: x/i $pc
=> 0x5555a4d4 <core::mem::zeroed::h85bfc6085f88bd9d+36>:        seb     a1,zero
(gdb) 

seb is apparently a mips32r2 instruction, but it seems my device is mips32 (r1, if you will). Probably need to work on that.

Poked a bit following:

https://github.com/rust-lang/rust/issues/37507#issuecomment-476026815

, but it seems that I can't get it not to generate the seb instruction

Ah, it might be that std has been compiled for mips32r2, according to:

https://github.com/rust-lang/rust/pull/48874

Opened a bug to Rust to see if a specific target could be added:

https://github.com/rust-lang/rust/issues/68865

2 Likes

Well, I got it to work with ugly hacks. I patched buildroot to patch Rust to disable mips32r2 instructions, and I've been able to compile and run a basic rust-sdl example:

This should work on similar devices too (LDK, RS97, etc).

With a little bit of luck, Rust devs would modify the mips targets (or add a new one) so mips32 non-r2 is supported and the buildroot devs could enable uclibc building... and this could be incorporated in a new RetroFW release, which would make the whole process much simpler... but this will suffice me for now...

If someone wants to reproduce the process, see:

https://github.com/alexpdp7/retrofw2-rust

3 Likes

Well, did some further updates, now the program built demonstrates drawing, control handling and sound.

Had to go through the "ao" sound library, due to the system having old-fashioned OSS Linux sound; had to patch some old ao Rust bindings to update them.

So I think this gives all what's needed to build simple games :slight_smile: Hopefully it will be of use to someone else; I think these devices are an attractive target.

4 Likes

Great work!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.