Re: qemu-system-sh4eb build has something hinky in the ethernet

Rob Landley <[email protected]> Wed, 31 Dec 2025 02:04:04 -0600
Newsgroups gmane.linux.debian.ports.ia64
Message-ID <6b3fdecb-739b-4149-8736-2fb6bd209d10__9253.7243779347$1767172549$gmane$org@landley.net>
On 11/24/25 01:18, Philippe Mathieu-Daudé wrote:
> On 1/9/25 09:47, Geert Uytterhoeven wrote:
> 
>> On Sun, 24 Aug 2025 at 20:40, Rob Landley <[email protected]> wrote:
>>> Anyway, this works fine on little endian, but the qemu-system-sh4eb
>>> build has something hinky in the ethernet, I haven't tackled it myself
>>> because I don't know whether the device emulation or the driver is
>>> what's missing an endian swap. (I don't want to fix it the "wrong way",
>>
>> That is using sh_eth, right?
>>
>> Last time I tried booting a big-endian ARM kernel on R-Car M2-W,
>> the Linux kernel booted fine, except for Ethernet.  So sh_eth is 
>> definitely
>> not big-endian clean.
> 
> qemu-system-sh4{eb} only emulates the R2D+ board, which AFAIK
> provides ethernet via a RTL8139 over PCI. While old, RTL8139
> is very tested and expected to have endianness well handled.

Expected, sure. In reality? Compare the sh4 vs sh4eb tarballs in 
https://landley.net/bin/mkroot/0.8.13/ (in each case extract and 
./run-qemu.sh should get you a shell prompt).

The sh4 one has working ethernet, the sh4eb one always reports link down 
and it doesn't seem to probe the mac address right. Built from almost 
the same configs, the only difference is:

https://github.com/landley/toybox/blob/0.8.13/mkroot/mkroot.sh#L297

Line 305 adds:
     [ "$CROSS" == sh4eb ] && KCONF+=,CPU_BIG_ENDIAN

When I tried to track it down, I didn't know if the kernel or qemu was 
what had it backwards, so it went back on the todo heap and composted...

>> [*] I didn't have a big-endian userspace.

That script builds one, the resulting binary tarball is at 
https://landley.net/bin/mkroot/0.8.13/sh2eb.tgz and the toolchain I used 
is at 
https://landley.net/bin/toolchains/25-03-2024/sh4eb-linux-musl-cross.tar.xz 
which was built with https://landley.net/toybox/faq.html#cross2

There might also be something wrong with -hda block device support, I'd 
have to check my notes. But I can work around lack of -hda with 
nbd-server, kinda hard to do it the other way...

Rob