Re: [PATCH 3/3] board: Add QEMU m68k virt board support

2025-12-22 Thread Kuan-Wei Chiu
Hi Daniel,

On Sun, Dec 21, 2025 at 01:37:24PM +0900, Daniel Palmer wrote:
> Hi Kuan-Wei,
> 
> On Fri, 19 Dec 2025 at 04:06, Kuan-Wei Chiu  wrote:
> >
> > Add support for the QEMU 'virt' machine on the m68k architecture. This
> > board emulates a generic machine based on the Motorola 68040 CPU
> > equipped with Goldfish virtual peripherals.
> 
> Since I already have this setup working and able to boot linux I will
> add some input:
> - The virt machine can use any supported CPU type, even 000 without
> mmu, you should really handle that.

You're right. Regarding the support for other 680x0 CPUs, would you
prefer to see them included in v2, or would you think that it is better
to integrate them incrementally after this baseline series is merged?

> - m68k linux for mmu machines uses "bootinfo" that is a structure
> after the kernel image that the bootloader prepares so linux can work
> out what CPU etc is present. QEMU does this as well but it will be
> after the u-boot image now, so to boot linux you must save it before
> it gets destroyed and when the kernel is loaded copy it to after the
> kernel. I use ELF images to boot linux. I have a hack in bootelf to
> put the bootinfo in place just before jumping to the entry point.
> - Since QEMU gives you the bootinfo and you need to parse it to work
> out how much to save either way you should use it to detect the
> selected CPU in u-boot. If the code is built for 000 it will run on
> anything and just needs to handle the differences in the caches. In my
> setup I fixup the cpu compatible string in u-boot's devicetree and
> then use that to work out what cache function to call for the current
> CPU.

Currently, I only parse the bootinfo to retrieve the RAM size and
haven't looked into the specific requirements for booting Linux yet.

If full Linux boot support isn't a blocker for this initial series,
could you advise on any specific structural adjustments I should make
now to facilitate that integration later?

> 
> Glad to see I'm not alone in messing around with this. :)

Same here! Glad to know I'm not the only one. :)

Regards,
Kuan-Wei


Re: [PATCH 3/3] board: Add QEMU m68k virt board support

2025-12-20 Thread Daniel Palmer
Hi Kuan-Wei,

On Fri, 19 Dec 2025 at 04:06, Kuan-Wei Chiu  wrote:
>
> Add support for the QEMU 'virt' machine on the m68k architecture. This
> board emulates a generic machine based on the Motorola 68040 CPU
> equipped with Goldfish virtual peripherals.

Since I already have this setup working and able to boot linux I will
add some input:
- The virt machine can use any supported CPU type, even 000 without
mmu, you should really handle that.
- m68k linux for mmu machines uses "bootinfo" that is a structure
after the kernel image that the bootloader prepares so linux can work
out what CPU etc is present. QEMU does this as well but it will be
after the u-boot image now, so to boot linux you must save it before
it gets destroyed and when the kernel is loaded copy it to after the
kernel. I use ELF images to boot linux. I have a hack in bootelf to
put the bootinfo in place just before jumping to the entry point.
- Since QEMU gives you the bootinfo and you need to parse it to work
out how much to save either way you should use it to detect the
selected CPU in u-boot. If the code is built for 000 it will run on
anything and just needs to handle the differences in the caches. In my
setup I fixup the cpu compatible string in u-boot's devicetree and
then use that to work out what cache function to call for the current
CPU.

Glad to see I'm not alone in messing around with this. :)

Cheers,

Daniel


Re: [PATCH 3/3] board: Add QEMU m68k virt board support

2025-12-20 Thread Kuan-Wei Chiu
Hi Tom,

On Thu, Dec 18, 2025 at 01:04:15PM -0600, Tom Rini wrote:
> On Thu, Dec 18, 2025 at 06:52:52PM +, Kuan-Wei Chiu wrote:
> 
> > Add support for the QEMU 'virt' machine on the m68k architecture. This
> > board emulates a generic machine based on the Motorola 68040 CPU
> > equipped with Goldfish virtual peripherals.
> > 
> > Introduce the necessary board configuration and initialization
> > infrastructure. The implementation includes logic to parse the QEMU
> > bootinfo interface, enabling dynamic detection of system RAM size to
> > adapt to the virtual machine's configuration.
> > 
> > Enable the Goldfish TTY driver to provide a serial console, which
> > facilitates interaction when running QEMU with the -nographic option.
> > Additionally, include comprehensive documentation covering build
> > instructions and usage examples to guide users in deploying U-Boot
> > within the virtualization environment.
> > 
> > Signed-off-by: Kuan-Wei Chiu 
> [snip]
> > diff --git a/board/emulation/qemu-m68k/MAINTAINERS 
> > b/board/emulation/qemu-m68k/MAINTAINERS
> > new file mode 100644
> > index 000..c2f4cc40a56
> > --- /dev/null
> > +++ b/board/emulation/qemu-m68k/MAINTAINERS
> > @@ -0,0 +1,10 @@
> > +QEMU M68K VIRT BOARD
> > +M:  Kuan-Wei Chiu 
> > +S:  Maintained
> > +F:  board/emulation/qemu-m68k/
> > +F:  board/emulation/common/
> > +F:  include/configs/qemu-m68k.h
> > +F:  configs/qemu-m68k_defconfig
> > +F:  arch/m68k/cpu/m68040/
> > +F:  arch/m68k/include/asm/bootinfo.h
> > +F:  doc/board/emulation/qemu-m68k.rst
> 
> There was Kconfig spacing issues here as well, but also MAINTAINERS
> files are usually tab not spaces. But if get_maintainer.pl is fine, OK.

Will convert them to tabs in v2.

> 
> > diff --git a/configs/qemu-m68k_defconfig b/configs/qemu-m68k_defconfig
> > new file mode 100644
> > index 000..765ed9b7424
> > --- /dev/null
> > +++ b/configs/qemu-m68k_defconfig
> > @@ -0,0 +1,17 @@
> > +CONFIG_M68K=y
> > +CONFIG_TARGET_QEMU_M68K=y
> > +CONFIG_TEXT_BASE=0x
> > +CONFIG_SYS_LOAD_ADDR=0x
> > +CONFIG_SYS_MONITOR_LEN=262144
> > +CONFIG_SYS_BOOTM_LEN=0x100
> > +CONFIG_SYS_MALLOC_LEN=0x2
> > +# CONFIG_DISPLAY_BOARDINFO is not set
> > +CONFIG_BAUDRATE=115200
> > +
> > +# CONFIG_OF_CONTROL is not set
> 
> This wasn't made with "make savedefconfig" and needs to be, please
> generate it that way.

Will rectify that in v2.

> 
> > diff --git a/doc/board/emulation/qemu-m68k.rst 
> > b/doc/board/emulation/qemu-m68k.rst
> > new file mode 100644
> > index 000..19898e17cfc
> > --- /dev/null
> > +++ b/doc/board/emulation/qemu-m68k.rst
> > @@ -0,0 +1,38 @@
> > +.. SPDX-License-Identifier: GPL-2.0+
> > +.. Copyright (C) 2025, Kuan-Wei Chiu 
> 
> Docs are good, thank you. But it needs to update the index.rst file too
> to be included and also not trigger CI failure when building docs.

Sorry for missing that. I will fix it in v2 and ensure the docs build
successfully before respinning.

Regards,
Kuan-Wei


Re: [PATCH 3/3] board: Add QEMU m68k virt board support

2025-12-18 Thread Tom Rini
On Thu, Dec 18, 2025 at 06:52:52PM +, Kuan-Wei Chiu wrote:

> Add support for the QEMU 'virt' machine on the m68k architecture. This
> board emulates a generic machine based on the Motorola 68040 CPU
> equipped with Goldfish virtual peripherals.
> 
> Introduce the necessary board configuration and initialization
> infrastructure. The implementation includes logic to parse the QEMU
> bootinfo interface, enabling dynamic detection of system RAM size to
> adapt to the virtual machine's configuration.
> 
> Enable the Goldfish TTY driver to provide a serial console, which
> facilitates interaction when running QEMU with the -nographic option.
> Additionally, include comprehensive documentation covering build
> instructions and usage examples to guide users in deploying U-Boot
> within the virtualization environment.
> 
> Signed-off-by: Kuan-Wei Chiu 
[snip]
> diff --git a/board/emulation/qemu-m68k/MAINTAINERS 
> b/board/emulation/qemu-m68k/MAINTAINERS
> new file mode 100644
> index 000..c2f4cc40a56
> --- /dev/null
> +++ b/board/emulation/qemu-m68k/MAINTAINERS
> @@ -0,0 +1,10 @@
> +QEMU M68K VIRT BOARD
> +M:  Kuan-Wei Chiu 
> +S:  Maintained
> +F:  board/emulation/qemu-m68k/
> +F:  board/emulation/common/
> +F:  include/configs/qemu-m68k.h
> +F:  configs/qemu-m68k_defconfig
> +F:  arch/m68k/cpu/m68040/
> +F:  arch/m68k/include/asm/bootinfo.h
> +F:  doc/board/emulation/qemu-m68k.rst

There was Kconfig spacing issues here as well, but also MAINTAINERS
files are usually tab not spaces. But if get_maintainer.pl is fine, OK.

> diff --git a/configs/qemu-m68k_defconfig b/configs/qemu-m68k_defconfig
> new file mode 100644
> index 000..765ed9b7424
> --- /dev/null
> +++ b/configs/qemu-m68k_defconfig
> @@ -0,0 +1,17 @@
> +CONFIG_M68K=y
> +CONFIG_TARGET_QEMU_M68K=y
> +CONFIG_TEXT_BASE=0x
> +CONFIG_SYS_LOAD_ADDR=0x
> +CONFIG_SYS_MONITOR_LEN=262144
> +CONFIG_SYS_BOOTM_LEN=0x100
> +CONFIG_SYS_MALLOC_LEN=0x2
> +# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_BAUDRATE=115200
> +
> +# CONFIG_OF_CONTROL is not set

This wasn't made with "make savedefconfig" and needs to be, please
generate it that way.

> diff --git a/doc/board/emulation/qemu-m68k.rst 
> b/doc/board/emulation/qemu-m68k.rst
> new file mode 100644
> index 000..19898e17cfc
> --- /dev/null
> +++ b/doc/board/emulation/qemu-m68k.rst
> @@ -0,0 +1,38 @@
> +.. SPDX-License-Identifier: GPL-2.0+
> +.. Copyright (C) 2025, Kuan-Wei Chiu 

Docs are good, thank you. But it needs to update the index.rst file too
to be included and also not trigger CI failure when building docs.

-- 
Tom


signature.asc
Description: PGP signature