Bootable sh4 qemu images.
The question was recently raised about QEMU images for sh. Since I maintain those as part of my Aboriginal Linux project, and put out a new release last night, I thought I'd link to and explain them.
The project page is http://landley.net/aboriginal/about.html
The sh4 images are "qemu-system-sh4.tar.gz", the current release (1.4.4) is based on musl-libc and kernel 4.2, and the previous release (1.4.3) was uClibc and 4.1. The stable link to historical prebuilt binary versions is at:
http://landley.net/aboriginal/downloads/old/binaries/
Download a system image, extract it, and run either ./run-emulator.sh (simple initramfs-only, without compiler) or ./dev-environment.sh (with compiler loaded from /dev/sda squashfs image).
Unfortunately qemu's r2d board can't give me multiple block devices yet (-hdb and later are ignored) so the 2 gig ext2 image dev-environment.sh tries to mount on /home is inaccessible, and the native-build.sh script is useless on this target because there's no /dev/[sh]dc. Also this board is hardwired to provide 64 megs of ram (gcc requires 256 megs to build linux from scratch), and when you exit and the kernel tries to halt the emulator, qemu panics and doesn't reset the TTY properly. (Type "reset" and hit enter to get your cursor back.)
In the current release's system image tarball is a "mini.config" file used to build the kernel. You can expand that via:
make ARCH=sh allnoconfig KCONFIG_ALLCONFIG=mini.config
And then you have a big config from which you can build a kernel. There are cross-compilers in each release directory, download and extract cross-compiler-sh4.tar.gz and add its "bin" subdirectory to your path, and use sh4- as the prefix. (Or you can use the full path to the compiler ending with the prefix as the prefix, and not fiddle with the $PATH.)
make ARCH=sh CROSS_COMPILE=sh4-
(There are also sh2eb images and compilers, sh2 big endian, but the kernels in those boot on a Numato board, not under qemu. See
http://nommu.org/jcore for details of that. Those are all still uClibc, they should move to musl next release.)
Again, http://landley.net/aboriginal/about.html should explain or provide links to everything else.
This is what I've been using to regression test the sh4 kernel for the past several years. I only got involved in the sh2 nommu stuff at the end of 2014, and dragged Rich into it what, 6 months ago?
Rob
P.S. Sorry I've fallen a couple kernel versions behind, I'm trying to catch up but with https://lwn.net/Articles/629362/ and
https://lwn.net/Articles/616315/ and now
http://review.cyanogenmod.org/#/c/119819/1 toybox is dominating my todo list...
Quoted 5 lines · Rob Landley
The sh4 images are "qemu-system-sh4.tar.gz", the current release (1.4.4) is based on musl-libc and kernel 4.2
P.S. Sorry I've fallen a couple kernel versions behind, I'm trying to catch up
Ah, so you've not yet found if I broken SH in 4.3 with:
b31fdac2a921 ("sched, sh: Fold finish_arch_switch() into switch_to()")
:-)
Quoted 4 lines · Peter Zijlstra
Quoted 2 lines · Rob Landley
The sh4 images are "qemu-system-sh4.tar.gz", the current release (1.4.4) is based on musl-libc and kernel 4.2
Quoted 8 lines
Quoted 2 lines
P.S. Sorry I've fallen a couple kernel versions behind, I'm trying to catch upAh, so you've not yet found if I broken SH in 4.3 with:
b31fdac2a921("sched, sh: Foldfinish_arch_switch()intoswitch_to()"):-)
It's working fine with 4.3, native compiling static binaries under musl and everything:
(sh4:3) / $ gcc /usr/src/thread-hello2.c -lpthread --static (sh4:3) / $ ./a.out
Hello world!
(sh4:3) / $ cat /proc/version
Linux version 4.3.0 (landley@halfbrick) (gcc version 4.2.1) #1 Mon Jan 11 13:24:23 CST 2016
(sh4:3) / $ cat /proc/cpuinfo
machine : RTS7751R2D
processor : 0
cpu family : sh4
cpu type : SH7751R
cut : unknown
cpu flags : fpu ptea
cache type : split (harvard)
icache size : 4KiB (2-way)
dcache size : 4KiB (2-way)
address sizes : 29 bits physical
bogomips : 120.00
(sh4:3) / $
(Dynamic linked binaries are segfaulting but that's something I did wrong when switching to musl. My toolchain is the last gplv2 releases of everything, patched until they work. Something needs a patch, apparently.)
I might cut a release with _just_ the new kernel version to catch up...
Rob
Quoted 9 lines · Rob Landley
Quoted 5 lines · Peter Zijlstra
Ah, so you've not yet found if I broken SH in 4.3 with:
b31fdac2a921("sched, sh: Foldfinish_arch_switch()intoswitch_to()"):-)
It's working fine with 4.3, native compiling static binaries under musl and everything:
...
Quoted 1 line
I might cut a release with _just_ the new kernel version to catch up...
And I did so, same as last time except newer kernel:
http://landley.net/aboriginal/bin/system-image-sh4.tar.gz
http://landley.net/aboriginal/bin/cross-comiler-sh4.tar.gz
Tested with qemu-system-sh4 2.5.0, ./dev-environment.sh booted to shell prompt and built "hello world". (Static linked, anyway. Dynamic still has a musl hiccup somewhere.)
Of course now 4.4 is out so I'm still a release behind, but mini.config is there as is the cross compiler, so easy enough to make your own linux replacement image (it's just vmlinux renamed, qemu has an elf loader, the initramfs is external to make swapping it out easier, that's why run-emulator.sh is feeding -initrd rootfs.cpio.gz to qemu instead of having it linked in at build time).
Rob