diff mbox series

[v2,1/3] arch: add support for mcf5441x Colfdire

Message ID 20240410171211.1633127-2-jeanmichel.hautbois@yoseli.org
State New
Headers show
Series Add support for the MCF5441x Coldfire | expand

Commit Message

Jean-Michel Hautbois April 10, 2024, 5:12 p.m. UTC
The m68k family ony has one Coldfire variant, namely the 5208. Add the
support for the MCF5441x CPU family in the configuration file.
This covers MCF54410, MCF54415, MCF54416, MCF54417 and MCF54418.

Commit [1] removed the GCC ARCH configuration which was used to
determine if the architecture is "m68k" or "cf". I have re-introduced
this configuration here, only for the MCF5441x case. It has been tested
as an external toolchain too.

[1]: eda11417be m68k: remove BR2_GCC_TARGET_ARCH

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
---
 arch/Config.in.m68k | 10 ++++++++++
 toolchain/Config.in |  1 +
 2 files changed, 11 insertions(+)

Comments

Thomas Petazzoni April 10, 2024, 7:56 p.m. UTC | #1
Hello,

On Wed, 10 Apr 2024 19:12:09 +0200
Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> wrote:

> The m68k family ony has one Coldfire variant, namely the 5208. Add the
> support for the MCF5441x CPU family in the configuration file.
> This covers MCF54410, MCF54415, MCF54416, MCF54417 and MCF54418.

Interesting. I always thought that Coldfire meant "no MMU" and 68k
meant "MMU", but I was wrong. The family of 68k and coldfire is quite
messy, difficult to find clear and reliable sources of information.

> +config BR2_GCC_TARGET_ARCH
> +	default "cf"            if BR2_m68k_cf5441x

The problem with this is that "cf" is not a valid value for gcc -march=
option. Look at the documentation at:
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/M680x0-Options.html

The valid values of -march are:

  Permissible values of arch for M680x0 architectures are: ‘68000’,
  ‘68010’, ‘68020’, ‘68030’, ‘68040’, ‘68060’ and ‘cpu32’. ColdFire
  architectures are selected according to Freescale’s ISA classification
  and the permissible values are: ‘isaa’, ‘isaaplus’, ‘isab’ and
  ‘isac’. 

What happens when you don't specify -march? Do you know which of isaa,
isaaplus, isab and isac the MCF5441x corresponds to?

Best regards,

Thomas
Jean-Michel Hautbois April 10, 2024, 9:08 p.m. UTC | #2
Hi Thomas,

On 10/04/2024 21:56, Thomas Petazzoni via buildroot wrote:
> Hello,
> 
> On Wed, 10 Apr 2024 19:12:09 +0200
> Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> wrote:
> 
>> The m68k family ony has one Coldfire variant, namely the 5208. Add the
>> support for the MCF5441x CPU family in the configuration file.
>> This covers MCF54410, MCF54415, MCF54416, MCF54417 and MCF54418.
> 
> Interesting. I always thought that Coldfire meant "no MMU" and 68k
> meant "MMU", but I was wrong. The family of 68k and coldfire is quite
> messy, difficult to find clear and reliable sources of information.

Indeed, it *is* a mess :-).

> 
>> +config BR2_GCC_TARGET_ARCH
>> +	default "cf"            if BR2_m68k_cf5441x
> 
> The problem with this is that "cf" is not a valid value for gcc -march=
> option. Look at the documentation at:
> https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/M680x0-Options.html
> 
> The valid values of -march are:
> 
>    Permissible values of arch for M680x0 architectures are: ‘68000’,
>    ‘68010’, ‘68020’, ‘68030’, ‘68040’, ‘68060’ and ‘cpu32’. ColdFire
>    architectures are selected according to Freescale’s ISA classification
>    and the permissible values are: ‘isaa’, ‘isaaplus’, ‘isab’ and
>    ‘isac’.
> 
> What happens when you don't specify -march? Do you know which of isaa,
> isaaplus, isab and isac the MCF5441x corresponds to?

I did not check what happens, but based on the following file it is isac:
https://github.com/gcc-mirror/gcc/blob/master/gcc/config/m68k/m68k-devices.def#L168

JM

> 
> Best regards,
> 
> Thomas
Thomas Petazzoni April 10, 2024, 9:17 p.m. UTC | #3
On Wed, 10 Apr 2024 23:08:14 +0200
Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> wrote:

> > What happens when you don't specify -march? Do you know which of isaa,
> > isaaplus, isab and isac the MCF5441x corresponds to?  
> 
> I did not check what happens, but based on the following file it is isac:
> https://github.com/gcc-mirror/gcc/blob/master/gcc/config/m68k/m68k-devices.def#L168

And if you specify -mcpu instead, does it work? What doesn't work if
you omit -march?

Thomas
Jean-Michel Hautbois April 11, 2024, 5:59 a.m. UTC | #4
On 10/04/2024 23:17, Thomas Petazzoni via buildroot wrote:
> On Wed, 10 Apr 2024 23:08:14 +0200
> Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> wrote:
> 
>>> What happens when you don't specify -march? Do you know which of isaa,
>>> isaaplus, isab and isac the MCF5441x corresponds to?
>>
>> I did not check what happens, but based on the following file it is isac:
>> https://github.com/gcc-mirror/gcc/blob/master/gcc/config/m68k/m68k-devices.def#L168
> 
> And if you specify -mcpu instead, does it work? What doesn't work if
> you omit -march?

If I change the line to pass isac, host-gcc-final doest not build at all:
<snip>
checking if mkdir takes one argument... no
Invalid --with-arch=isac
make[3]: *** [Makefile:4553: configure-gcc] Error 1
make[2]: *** [Makefile:1029: all] Error 2
make[1]: *** [package/pkg-generic.mk:283: 
/home/jm/Projects/wabtec/buildroot/output/build/host-gcc-final-12.3.0/.stamp_built] 
Error 2

As I am not as experimented as you with toolchains, I would certainly 
appreciate some guidance to debug if needed.

I can tell for sure that with "cf" and the 54455 family specified, it 
builds my applications ;-).

JM
Jean-Michel Hautbois April 11, 2024, 1:48 p.m. UTC | #5
Hello,

On 11/04/2024 07:59, Jean-Michel Hautbois wrote:
> On 10/04/2024 23:17, Thomas Petazzoni via buildroot wrote:
>> On Wed, 10 Apr 2024 23:08:14 +0200
>> Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> wrote:
>>
>>>> What happens when you don't specify -march? Do you know which of isaa,
>>>> isaaplus, isab and isac the MCF5441x corresponds to?
>>>
>>> I did not check what happens, but based on the following file it is 
>>> isac:
>>> https://github.com/gcc-mirror/gcc/blob/master/gcc/config/m68k/m68k-devices.def#L168
>>
>> And if you specify -mcpu instead, does it work? What doesn't work if
>> you omit -march?
> 
> If I change the line to pass isac, host-gcc-final doest not build at all:
> <snip>
> checking if mkdir takes one argument... no
> Invalid --with-arch=isac
> make[3]: *** [Makefile:4553: configure-gcc] Error 1
> make[2]: *** [Makefile:1029: all] Error 2
> make[1]: *** [package/pkg-generic.mk:283: 
> /home/jm/Projects/wabtec/buildroot/output/build/host-gcc-final-12.3.0/.stamp_built] Error 2
> 
> As I am not as experimented as you with toolchains, I would certainly 
> appreciate some guidance to debug if needed.
> 
> I can tell for sure that with "cf" and the 54455 family specified, it 
> builds my applications ;-).

Small update:
I have to add the following patch in package/gcc/12.3.0 to make it use 
the march="isac".

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 5c378c698ff..a6fe9c2ad53 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4522,7 +4522,7 @@ case "${target}" in
         fido-*-* | m68k*-*-*)
                 supported_defaults="arch cpu"
                 case "$with_arch" in
-               "" | "m68k"| "cf")
+               "" | "m68k"| "cf" | "isac")
                         m68k_arch_family="$with_arch"
                         ;;
                 *)

JM
diff mbox series

Patch

diff --git a/arch/Config.in.m68k b/arch/Config.in.m68k
index 9fd22aaf1e..c707276e9c 100644
--- a/arch/Config.in.m68k
+++ b/arch/Config.in.m68k
@@ -33,11 +33,21 @@  config BR2_m68k_cf5208
 	select BR2_m68k_cf
 	select BR2_SOFT_FLOAT
 
+config BR2_m68k_cf5441x
+	bool "5441x"
+	select BR2_m68k_cf
+	select BR2_USE_MMU
+	select BR2_SOFT_FLOAT
+
 endchoice
 
 config BR2_GCC_TARGET_CPU
 	default "68040"		if BR2_m68k_68040
 	default "5208"		if BR2_m68k_cf5208
+	default "54455"		if BR2_m68k_cf5441x
+
+config BR2_GCC_TARGET_ARCH
+	default "cf"            if BR2_m68k_cf5441x
 
 config BR2_READELF_ARCH_NAME
 	default "MC68000"
diff --git a/toolchain/Config.in b/toolchain/Config.in
index e8b3db64fb..782b9944d5 100644
--- a/toolchain/Config.in
+++ b/toolchain/Config.in
@@ -100,6 +100,7 @@  config BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS
 	depends on !BR2_ARM_CPU_ARMV5
 	depends on !BR2_sparc_v8
 	depends on !BR2_m68k_cf5208
+	depends on !BR2_m68k_cf5441x
 
 # GCC uses thunk functions to adjust the 'this' pointer when calling
 # C++ member functions in classes derived with multiple inheritance.