Skip to contentSkip to conversation

m68k: add support for coldfire with qemu config

PATCH New Waldemar Brodkorb 2 participants 3 messages Apr 27, 2016 – Apr 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: add support for coldfire with qemu config

There are four different possibilities for m68k architecture and cpu support:
m68k with MMU f.e m68040
m68k without MMU f.e. m68020 (without coprocessor) coldfire without MMU f.e. mcf5208
coldfire with MMU f.e. mcf5475

This adds just support for mcf5208.

We need to enable multilib to gcc build to support coldfire. Tested with Qemu and simple flat binaries.

---
It is neither complete coldfire support nor bugfree. After login you can execute a command and then getty is respawning login. Maybe a busybox init problem.

It is a starting point for any coldfire users.

For BR2_BINFMT_FLAT_SEP_DATA mode we must somehow filter-out -msep-data from CFLAGS passed to gcc multilib compile.

---
 arch/Config.in                                 |    2 +-
 arch/Config.in.m68k                            |   16 +
 board/qemu/m68k-mcf5208/busybox-minimal.config | 1057 ++++++++++++++++++++++++
 board/qemu/m68k-mcf5208/linux-4.5.config       |   21 +
 board/qemu/m68k-mcf5208/m68k-post-build.sh     |    4 +
 board/qemu/m68k-mcf5208/readme.txt             |    7 +
 configs/qemu_m68k_mcf5208_defconfig            |   32 +
 package/gcc/4.8.5/891-fix-m68k-uclinux.patch   |   17 +
 package/gcc/4.9.3/891-fix-m68k-uclinux.patch   |   17 +
 package/gcc/5.3.0/891-fix-m68k-uclinux.patch   |   17 +
 package/gcc/gcc-final/gcc-final.mk             |   16 +
 package/gcc/gcc-initial/gcc-initial.mk         |    8 +
 package/uclibc/uclibc.mk                       |   16 +
 13 files changed, 1229 insertions(+), 1 deletion(-)
 create mode 100644 board/qemu/m68k-mcf5208/busybox-minimal.config
 create mode 100644 board/qemu/m68k-mcf5208/linux-4.5.config
 create mode 100755 board/qemu/m68k-mcf5208/m68k-post-build.sh
 create mode 100644 board/qemu/m68k-mcf5208/readme.txt
 create mode 100644 configs/qemu_m68k_mcf5208_defconfig
 create mode 100644 package/gcc/4.8.5/891-fix-m68k-uclinux.patch
 create mode 100644 package/gcc/4.9.3/891-fix-m68k-uclinux.patch
 create mode 100644 package/gcc/5.3.0/891-fix-m68k-uclinux.patch
arch/Config.in +1 -1
index 3f1453f..be37481 100644
@@ -94,7 +94,7 @@ config BR2_i386
 
 config BR2_m68k
 	bool "m68k"
-	select BR2_ARCH_HAS_MMU_MANDATORY
+	# MMU support is set by the subarchitecture file, arch/Config.in.m68k
 	help
 	  Motorola 68000 family microprocessor
 	  http://en.wikipedia.org/wiki/M68k
arch/Config.in.m68k +16 -0
index 94494c8..8eb7e7a 100644
@@ -4,6 +4,14 @@ config BR2_ARCH
 config BR2_ENDIAN
 	default "BIG"
 
+# symbols used to distinguish between m68k and coldfire
+# for gcc multilib
+config BR2_m68k_m68k
+	bool
+
+config BR2_m68k_cf
+	bool
+
 # coldfire variants will be added later
 choice
 	prompt "Target CPU"
@@ -14,8 +22,16 @@ choice
 
 config BR2_m68k_68040
 	bool "68040"
+	select BR2_m68k_m68k
+	select BR2_ARCH_HAS_MMU_OPTIONAL
+
+config BR2_m68k_cf5208
+	bool "5208"
+	select BR2_m68k_cf
+	select BR2_SOFT_FLOAT
 
 endchoice
 
 config BR2_GCC_TARGET_CPU
 	default "68040"		if BR2_m68k_68040
+	default "5208"		if BR2_m68k_cf5208
board/qemu/m68k-mcf5208/busybox-minimal.config new file +1057 -0

1,057 lines not on this page · raw message

board/qemu/m68k-mcf5208/linux-4.5.config new file +21 -0
new file mode 100644
index 0000000..bf30bf4
@@ -0,0 +1,21 @@
+CONFIG_M68K=y
+CONFIG_COLDFIRE=y
+# CONFIG_MMU is not set
+CONFIG_M520x=y
+CONFIG_CLOCK_SET=y
+CONFIG_CLOCK_FREQ=66666666
+CONFIG_CLOCK_DIV=1
+CONFIG_M5208EVB=y
+CONFIG_FREESCALE=y
+CONFIG_RAMBASE=0x40000000
+CONFIG_RAMSIZE=0x0
+CONFIG_VECTORBASE=0x40000000
+CONFIG_KERNELBASE=0x40020000
+CONFIG_4KSTACKS=y
+CONFIG_RAMKERNEL=y
+CONFIG_BINFMT_FLAT=y
+CONFIG_SERIAL_MCF=y
+CONFIG_SERIAL_MCF_BAUDRATE=115200
+CONFIG_SERIAL_MCF_CONSOLE=y
+CONFIG_BOOTPARAM=y
+CONFIG_BOOTPARAM_STRING="console=ttyS0,115200"
board/qemu/m68k-mcf5208/m68k-post-build.sh new file +4 -0
new file mode 100755
index 0000000..3e049cd
@@ -0,0 +1,4 @@
+#!/bin/sh
+rm -f ${TARGET_DIR}/etc/init.d/S20urandom
+rm -f ${TARGET_DIR}/etc/init.d/S40network
+rm -rf ${TARGET_DIR}/etc/network/
board/qemu/m68k-mcf5208/readme.txt new file +7 -0
new file mode 100644
index 0000000..cb75f46
@@ -0,0 +1,7 @@
+Run the emulation with:
+
+ qemu-system-m68k -M mcf5208evb -cpu m5208 -kernel output/images/vmlinux -nographic
+
+The login prompt will appear in the terminal that started Qemu.
+
+Tested with QEMU 2.5.0.
configs/qemu_m68k_mcf5208_defconfig new file +32 -0
new file mode 100644
index 0000000..35c69a3
@@ -0,0 +1,32 @@
+# Architecture
+BR2_m68k=y
+BR2_m68k_cf5208=y
+
+# System
+BR2_SYSTEM_DHCP="eth0"
+
+# Filesystem
+BR2_TARGET_ROOTFS_INITRAMFS=y
+# BR2_TARGET_ROOTFS_TAR is not set
+
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/m68k-mcf5208/m68k-post-build.sh"
+
+# Linux headers same as kernel, a 4.5 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_5=y
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.5"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/m68k-mcf5208/linux-4.5.config"
+BR2_LINUX_KERNEL_VMLINUX=y
+
+# Serial port config
+BR2_TARGET_GENERIC_GETTY=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
+
+# use minimal busybox with hush
+BR2_PACKAGE_BUSYBOX_CONFIG="board/qemu/m68k-mcf5208/busybox-minimal.config"
+# mdev does not work correctly
+BR2_ROOTFS_DEVICE_CREATION_STATIC=y
package/gcc/4.8.5/891-fix-m68k-uclinux.patch new file +17 -0
new file mode 100644
index 0000000..13bf0d9
@@ -0,0 +1,17 @@
+See here:
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833
+
+Signed-off-by: Waldemar Brodkorb <[email protected]>
+
+diff -Nur gcc-4.8.5.orig/libgcc/config.host gcc-4.8.5/libgcc/config.host
+--- gcc-4.8.5.orig/libgcc/config.host	2014-03-20 17:12:30.000000000 +0100
++++ gcc-4.8.5/libgcc/config.host	2016-04-27 15:04:01.521171537 +0200
+@@ -689,7 +689,7 @@
+ m68k*-*-openbsd*)
+ 	;;
+ m68k-*-uclinux*)	# Motorola m68k/ColdFire running uClinux with uClibc
+-	tmake_file="$tmake_file m68k/t-floatlib m68k/t-linux"
++	tmake_file="$tmake_file m68k/t-floatlib"
+ 	md_unwind_header=m68k/linux-unwind.h
+ 	;;
+ m68k-*-linux*)			# Motorola m68k's running GNU/Linux
package/gcc/4.9.3/891-fix-m68k-uclinux.patch new file +17 -0
new file mode 100644
index 0000000..49bf553
@@ -0,0 +1,17 @@
+See here:
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833
+
+Signed-off-by: Waldemar Brodkorb <[email protected]>
+
+diff -Nur gcc-4.9.3.orig/libgcc/config.host gcc-4.9.3/libgcc/config.host
+--- gcc-4.9.3.orig/libgcc/config.host	2014-03-27 16:40:31.000000000 +0100
++++ gcc-4.9.3/libgcc/config.host	2016-04-05 16:20:53.422809885 +0200
+@@ -750,7 +750,7 @@
+ m68k*-*-openbsd*)
+ 	;;
+ m68k-*-uclinux*)	# Motorola m68k/ColdFire running uClinux with uClibc
+-	tmake_file="$tmake_file m68k/t-floatlib m68k/t-linux"
++	tmake_file="$tmake_file m68k/t-floatlib"
+ 	md_unwind_header=m68k/linux-unwind.h
+ 	;;
+ m68k-*-linux*)			# Motorola m68k's running GNU/Linux
package/gcc/5.3.0/891-fix-m68k-uclinux.patch new file +17 -0
new file mode 100644
index 0000000..05e2d05
@@ -0,0 +1,17 @@
+See here:
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833
+
+Signed-off-by: Waldemar Brodkorb <[email protected]>
+
+diff -Nur gcc-5.3.0.orig/libgcc/config.host gcc-5.3.0/libgcc/config.host
+--- gcc-5.3.0.orig/libgcc/config.host	2015-10-01 14:01:18.000000000 +0200
++++ gcc-5.3.0/libgcc/config.host	2016-04-26 21:30:25.353691745 +0200
+@@ -794,7 +794,7 @@
+ m68k*-*-openbsd*)
+ 	;;
+ m68k-*-uclinux*)	# Motorola m68k/ColdFire running uClinux with uClibc
+-	tmake_file="$tmake_file m68k/t-floatlib m68k/t-linux"
++	tmake_file="$tmake_file m68k/t-floatlib"
+ 	md_unwind_header=m68k/linux-unwind.h
+ 	;;
+ m68k-*-linux*)			# Motorola m68k's running GNU/Linux
package/gcc/gcc-final/gcc-final.mk +16 -0
index 69fdc0c..f07d4a0 100644
@@ -74,6 +74,14 @@ HOST_GCC_FINAL_CONF_OPTS += "--with-multilib-list=m4a,m4a-nofpu"
 HOST_GCC_FINAL_GCC_LIB_DIR = $(HOST_DIR)/usr/$(GNU_TARGET_NAME)/lib/!m4*
 endif
 
+# m68k/coldfire needs special configure options
+ifeq ($(BR2_m68k_m68k),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=m68k --enable-multilib --with-system-zlib
+endif
+ifeq ($(BR2_m68k_cf),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=cf --enable-multilib --with-system-zlib
+endif
+
 # Disable shared libs like libstdc++ if we do static since it confuses linking
 ifeq ($(BR2_STATIC_LIBS),y)
 HOST_GCC_FINAL_CONF_OPTS += --disable-shared
@@ -125,6 +133,14 @@ endef
 HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_LD_LINUX_LINK
 endif
 
+# coldfire is not working without removing these object files from libgcc.a
+ifeq ($(BR2_m68k_cf),y)
+define HOST_GCC_FINAL_M68K_LIBGCC_FIXUP
+	find $(STAGING_DIR) -name libgcc.a -print | while read t; do $(GNU_TARGET_NAME)-ar dv "$t" _ctors.o; done
+endef
+HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_M68K_LIBGCC_FIXUP
+endif
+
 # Cannot use the HOST_GCC_FINAL_USR_LIBS mechanism below, because we want
 # libgcc_s to be installed in /lib and not /usr/lib.
 define HOST_GCC_FINAL_INSTALL_LIBGCC
package/gcc/gcc-initial/gcc-initial.mk +8 -0
index 1e58d8b..623665a 100644
@@ -49,6 +49,14 @@ HOST_GCC_INITIAL_CONF_OPTS = \
 	--disable-nls \
 	$(call qstrip,$(BR2_EXTRA_GCC_CONFIG_OPTIONS))
 
+# m68k/coldfire needs special configure options
+ifeq ($(BR2_m68k_m68k),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=m68k --enable-multilib --with-system-zlib
+endif
+ifeq ($(BR2_m68k_cf),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=cf --enable-multilib --with-system-zlib
+endif
+
 HOST_GCC_INITIAL_CONF_ENV = \
 	$(HOST_GCC_COMMON_CONF_ENV)
 
package/uclibc/uclibc.mk +16 -0
index 0dfb454..b8ccee2 100644
@@ -101,6 +101,21 @@ endif
 endif # arm
 
 #
+# m68k/coldfire definitions
+#
+
+ifeq ($(UCLIBC_TARGET_ARCH),m68k)
+
+# disable DOPIC for flat without separate data
+ifeq ($(BR2_BINFMT_FLAT_ONE),y)
+define UCLIBC_M68K_BINFMT_FLAT
+	$(call KCONFIG_DISABLE_OPT,DOPIC,$(@D)/.config)
+endef
+endif
+
+endif # m68k/coldfire
+
+#
 # MIPS definitions
 #
 
@@ -372,6 +387,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS
 	$(UCLIBC_ARM_ABI_CONFIG)
 	$(UCLIBC_ARM_BINFMT_FLAT)
 	$(UCLIBC_ARM_NO_CONTEXT_FUNCS)
+	$(UCLIBC_M68K_BINFMT_FLAT)
 	$(UCLIBC_MIPS_ABI_CONFIG)
 	$(UCLIBC_MIPS_ISA_CONFIG)
 	$(UCLIBC_SH_TYPE_CONFIG)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 m68k: add support for coldfire with qemu config

Hello,

Cool, some coldfire stuff!

Quoted 10 lines · Waldemar Brodkorb

There are four different possibilities for m68k architecture and cpu support:
m68k with MMU f.e m68040
m68k without MMU f.e. m68020 (without coprocessor) coldfire without MMU f.e. mcf5208
coldfire with MMU f.e. mcf5475

This adds just support for mcf5208.

We need to enable multilib to gcc build to support coldfire.

Can you give more details as to why multilib is needed? That's a fairly significant change, so we shouldn't do it lightly.

Quoted 7 lines

Tested with Qemu and simple flat binaries.

---
It is neither complete coldfire support nor bugfree. After login you can execute a command and then getty is respawning login. Maybe a busybox init problem.

Hum, not great :-/

Quoted 11 lines

It is a starting point for any coldfire users.

For BR2_BINFMT_FLAT_SEP_DATA mode we must somehow filter-out -msep-data from CFLAGS passed to gcc multilib compile.

---
 arch/Config.in                                 |    2 +-
 arch/Config.in.m68k                            |   16 +
 board/qemu/m68k-mcf5208/busybox-minimal.config | 1057 ++++++++++++++++++++++++

Is this minimal Busybox config significantly different than the one in board/stmicroelectronics/busybox-minimal.config ? If not, then maybe it's time to move it to package/busybox/.

Quoted 11 lines
 board/qemu/m68k-mcf5208/linux-4.5.config       |   21 +
 board/qemu/m68k-mcf5208/m68k-post-build.sh     |    4 +
 board/qemu/m68k-mcf5208/readme.txt             |    7 +
 configs/qemu_m68k_mcf5208_defconfig            |   32 +
 package/gcc/4.8.5/891-fix-m68k-uclinux.patch   |   17 +
 package/gcc/4.9.3/891-fix-m68k-uclinux.patch   |   17 +
 package/gcc/5.3.0/891-fix-m68k-uclinux.patch   |   17 +
 package/gcc/gcc-final/gcc-final.mk             |   16 +
 package/gcc/gcc-initial/gcc-initial.mk         |    8 +
 package/uclibc/uclibc.mk                       |   16 +
 13 files changed, 1229 insertions(+), 1 deletion(-)

This whole thing should be split into more patches. At least split the:

1/ Architecture + toolchain support
2/ Defconfig stuff
3/ Addition of the Busybox configuration in package/busybox

Quoted 20 lines
arch/Config.in.m68k +8 -0
index 94494c8..8eb7e7a 100644
@@ -4,6 +4,14 @@ config BR2_ARCH
 config BR2_ENDIAN
 	default "BIG"
 
+# symbols used to distinguish between m68k and coldfire
+# for gcc multilib
+config BR2_m68k_m68k
+	bool
+
+config BR2_m68k_cf
+	bool
+
 # coldfire variants will be added later
 choice
 	prompt "Target CPU"

arch/Config.in.m68k choice · line 26

Quoted 5 lines
arch/Config.in.m68k +2 -0
@@ -14,8 +22,16 @@ choice
 
 config BR2_m68k_68040
 	bool "68040"
+	select BR2_m68k_m68k
+	select BR2_ARCH_HAS_MMU_OPTIONAL

We used to select BR2_ARCH_HAS_MMU_MANDATORY. Are you sure you can effectively run Linux on a 68040 with the MMU disabled? If you're not sure, just keep BR2_ARCH_HAS_MMU_MANDATORY.

arch/Config.in.m68k choice · line 37

Quoted 10 lines
arch/Config.in.m68k +5 -0
+config BR2_m68k_cf5208
+	bool "5208"
+	select BR2_m68k_cf
+	select BR2_SOFT_FLOAT
 
 endchoice
 
 config BR2_GCC_TARGET_CPU
 	default "68040"		if BR2_m68k_68040
+	default "5208"		if BR2_m68k_cf5208

You also want to add:

config BR2_GCC_TARGET_ARCH

	default "m68k" if BR2_m68k_m68k
	default "cf" if BR2_m68k_cf

this will allow to remove some stuff later on.

arch/Config.in.m68k choice · line 37

Quoted 1 line
arch/Config.in.m68k +1 -0
+rm -f ${TARGET_DIR}/etc/init.d/S20urandom

Why ?

arch/Config.in.m68k

Quoted 2 lines
arch/Config.in.m68k +2 -0
+# mdev does not work correctly
+BR2_ROOTFS_DEVICE_CREATION_STATIC=y

The default is not to use mdev, but to use devtmpfs only. Do you have issues with this?

package/gcc/4.8.5/891-fix-m68k-uclinux.patch line 2

Quoted 8 lines
package/gcc/4.8.5/891-fix-m68k-uclinux.patch new file +2 -0
new file mode 100644
index 0000000..13bf0d9
@@ -0,0 +1,17 @@
+See here:
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833

Giving a link is good, but it's still good to add a quick description of the patch nonetheless.

package/gcc/gcc-final/gcc-final.mk HOST_GCC_FINAL_CONF_OPTS += "--with-multilib-list=m4a,m4a-nofpu" · line 79

Quoted 11 lines
package/gcc/gcc-final/gcc-final.mk +3 -0
index 69fdc0c..f07d4a0 100644
@@ -74,6 +74,14 @@ HOST_GCC_FINAL_CONF_OPTS += "--with-multilib-list=m4a,m4a-nofpu"
 HOST_GCC_FINAL_GCC_LIB_DIR = $(HOST_DIR)/usr/$(GNU_TARGET_NAME)/lib/!m4*
 endif
 
+# m68k/coldfire needs special configure options
+ifeq ($(BR2_m68k_m68k),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=m68k --enable-multilib --with-system-zlib

You're in gcc-final, so touching HOST_GCC_INITIAL_CONF_OPTS looks weird.

You can remove the --with-arch part, is it already passed by package/gcc/gcc.mk:

ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),) HOST_GCC_COMMON_CONF_OPTS += --with-arch=$(BR2_GCC_TARGET_ARCH) endif

Also, if you need to pass options to both the gcc-initial and gcc-final, you should do it in package/gcc/gcc.mk, by appending to HOST_GCC_COMMON_CONF_OPTS.

It would be good to have a better justification than "m68k/coldfire needs special configure options" to explain why --enable-multilib --with-system-zlib are needed.

package/gcc/gcc-final/gcc-final.mk endef · line 139

Quoted 4 lines
package/gcc/gcc-final/gcc-final.mk +4 -0
+# coldfire is not working without removing these object files from libgcc.a
+ifeq ($(BR2_m68k_cf),y)
+define HOST_GCC_FINAL_M68K_LIBGCC_FIXUP
+	find $(STAGING_DIR) -name libgcc.a -print | while read t; do $(GNU_TARGET_NAME)-ar dv "$t" _ctors.o; done

Yerk, this looks really ugly. Is this a known problem in upstream gcc?

package/gcc/gcc-final/gcc-final.mk HOST_GCC_FINAL_CONF_OPTS += "--with-multilib-list=m4a,m4a-nofpu" · line 83

Quoted 7 lines
package/gcc/gcc-final/gcc-final.mk +7 -0
+# m68k/coldfire needs special configure options
+ifeq ($(BR2_m68k_m68k),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=m68k --enable-multilib --with-system-zlib
+endif
+ifeq ($(BR2_m68k_cf),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=cf --enable-multilib --with-system-zlib
+endif

Same comments as above.

package/gcc/gcc-final/gcc-final.mk

Quoted 12 lines

#

package/gcc/gcc-final/gcc-final.mk +11 -0
+# m68k/coldfire definitions
+#
+
+ifeq ($(UCLIBC_TARGET_ARCH),m68k)
+
+# disable DOPIC for flat without separate data
+ifeq ($(BR2_BINFMT_FLAT_ONE),y)
+define UCLIBC_M68K_BINFMT_FLAT
+	$(call KCONFIG_DISABLE_OPT,DOPIC,$(@D)/.config)
+endef
+endif

In the end, isn't the removal of DOPIC necessary for all architectures when binfmt_flat is used? We did the same thing for ARMv7-M, so I'm wondering if we shouldn't make that generic.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 m68k: add support for coldfire with qemu config

Hi Thomas,
Thomas Petazzoni wrote,

Thanks for the detailed feedback.

Quoted 12 lines

Hello,

Cool, some coldfire stuff!

Quoted 7 lines · Waldemar Brodkorb

There are four different possibilities for m68k architecture and cpu support:
m68k with MMU f.e m68040
m68k without MMU f.e. m68020 (without coprocessor) coldfire without MMU f.e. mcf5208
coldfire with MMU f.e. mcf5475

Quoted 6 lines
Quoted 3 lines

This adds just support for mcf5208.

We need to enable multilib to gcc build to support coldfire.

Can you give more details as to why multilib is needed? That's a fairly significant change, so we shouldn't do it lightly.

I have done more testing, it seems not to be required :)

Quoted 3 lines

Is this minimal Busybox config significantly different than the one in board/stmicroelectronics/busybox-minimal.config ? If not, then maybe it's time to move it to package/busybox/.

It is the same. Maybe networking stuff could be enabled later, because with a minor kernel patch you can enable networking in qemu-system-m68k.

Quoted 5 lines

This whole thing should be split into more patches. At least split the:

1/ Architecture + toolchain support
2/ Defconfig stuff
3/ Addition of the Busybox configuration in package/busybox

Will be done in the next patch series.

Quoted 8 lines

arch/Config.in.m68k choice · line 26

Quoted 4 lines

config BR2_m68k_68040

arch/Config.in.m68k +2 -0
 	bool "68040"
+	select BR2_m68k_m68k
+	select BR2_ARCH_HAS_MMU_OPTIONAL

We used to select BR2_ARCH_HAS_MMU_MANDATORY. Are you sure you can effectively run Linux on a 68040 with the MMU disabled? If you're not sure, just keep BR2_ARCH_HAS_MMU_MANDATORY.

Okay.

Quoted 14 lines

arch/Config.in.m68k choice · line 37

Quoted 10 lines
arch/Config.in.m68k +5 -0
+config BR2_m68k_cf5208
+	bool "5208"
+	select BR2_m68k_cf
+	select BR2_SOFT_FLOAT
 
 endchoice
 
 config BR2_GCC_TARGET_CPU
 	default "68040"		if BR2_m68k_68040
+	default "5208"		if BR2_m68k_cf5208

You also want to add:

config BR2_GCC_TARGET_ARCH

Quoted 8 lines
	default "m68k" if BR2_m68k_m68k
	default "cf" if BR2_m68k_cf

this will allow to remove some stuff later on.

Quoted 1 line

+rm -f ${TARGET_DIR}/etc/init.d/S20urandom

Why ?

No reason. It was there because I tried to get the thing booting to the command line and iteratively disabled or add some stuff to make it work. :)

Quoted 5 lines

configs/qemu_m68k_mcf5208_defconfig line 32

Quoted 2 lines
configs/qemu_m68k_mcf5208_defconfig new file +2 -0
+# mdev does not work correctly
+BR2_ROOTFS_DEVICE_CREATION_STATIC=y

The default is not to use mdev, but to use devtmpfs only. Do you have issues with this?

Yes, it does not boot, no shell or getty.

Quoted 11 lines

package/gcc/4.8.5/891-fix-m68k-uclinux.patch line 2

Quoted 8 lines
package/gcc/4.8.5/891-fix-m68k-uclinux.patch new file +2 -0
new file mode 100644
index 0000000..13bf0d9
@@ -0,0 +1,17 @@
+See here:
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833

Giving a link is good, but it's still good to add a quick description of the patch nonetheless.

Okay.

Quoted 21 lines

package/gcc/gcc-final/gcc-final.mk HOST_GCC_FINAL_CONF_OPTS += "--with-multilib-list=m4a,m4a-nofpu" · line 79

Quoted 11 lines
package/gcc/gcc-final/gcc-final.mk +3 -0
index 69fdc0c..f07d4a0 100644
@@ -74,6 +74,14 @@ HOST_GCC_FINAL_CONF_OPTS += "--with-multilib-list=m4a,m4a-nofpu"
 HOST_GCC_FINAL_GCC_LIB_DIR = $(HOST_DIR)/usr/$(GNU_TARGET_NAME)/lib/!m4*
 endif
 
+# m68k/coldfire needs special configure options
+ifeq ($(BR2_m68k_m68k),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=m68k --enable-multilib --with-system-zlib

You're in gcc-final, so touching HOST_GCC_INITIAL_CONF_OPTS looks weird.

You can remove the --with-arch part, is it already passed by package/gcc/gcc.mk:

ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),) HOST_GCC_COMMON_CONF_OPTS += --with-arch=$(BR2_GCC_TARGET_ARCH) endif

Quoted 7 lines

Also, if you need to pass options to both the gcc-initial and gcc-final, you should do it in package/gcc/gcc.mk, by appending to HOST_GCC_COMMON_CONF_OPTS.

It would be good to have a better justification than "m68k/coldfire needs special configure options" to explain why --enable-multilib --with-system-zlib are needed.

Completely removed as not needed. :)

Quoted 6 lines

package/gcc/gcc-final/gcc-final.mk endef · line 139

Quoted 4 lines
package/gcc/gcc-final/gcc-final.mk +4 -0
+# coldfire is not working without removing these object files from libgcc.a
+ifeq ($(BR2_m68k_cf),y)
+define HOST_GCC_FINAL_M68K_LIBGCC_FIXUP
+	find $(STAGING_DIR) -name libgcc.a -print | while read t; do $(GNU_TARGET_NAME)-ar dv "$t" _ctors.o; done

Yerk, this looks really ugly. Is this a known problem in upstream gcc?

Sorry, yes this is required. In the past I used a gcc wrapper and a modified spec file, this is a more simple solution I got from uClinux toolchain build script. I asked on the uClinux mailinglist about this, but the technical reasons for this workaround are unknown to at least Greg, which seems the only active uClinux developer. So at the moment I would say, let keep it this way.
I like to have the linux-atomic.c ice stuff next to get fixed in gcc upstream. The other m68k fix got applied to trunk recently.

Sometimes bugs in binutils/gcc needs 1-2 years to get fixed upstream, so don't give up ;)
https://sourceware.org/bugzilla/show_bug.cgi?id=17334

Quoted 11 lines

package/gcc/gcc-final/gcc-final.mk HOST_GCC_FINAL_CONF_OPTS += "--with-multilib-list=m4a,m4a-nofpu" · line 83

Quoted 7 lines
package/gcc/gcc-final/gcc-final.mk +7 -0
+# m68k/coldfire needs special configure options
+ifeq ($(BR2_m68k_m68k),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=m68k --enable-multilib --with-system-zlib
+endif
+ifeq ($(BR2_m68k_cf),y)
+HOST_GCC_INITIAL_CONF_OPTS += --with-arch=cf --enable-multilib --with-system-zlib
+endif

Same comments as above.

Quoted 16 lines

package/gcc/gcc-final/gcc-final.mk

Quoted 12 lines

#

package/gcc/gcc-final/gcc-final.mk +11 -0
+# m68k/coldfire definitions
+#
+
+ifeq ($(UCLIBC_TARGET_ARCH),m68k)
+
+# disable DOPIC for flat without separate data
+ifeq ($(BR2_BINFMT_FLAT_ONE),y)
+define UCLIBC_M68K_BINFMT_FLAT
+	$(call KCONFIG_DISABLE_OPT,DOPIC,$(@D)/.config)
+endef
+endif

In the end, isn't the removal of DOPIC necessary for all architectures when binfmt_flat is used? We did the same thing for ARMv7-M, so I'm wondering if we shouldn't make that generic.

It is not required for Blackfin binfmt_flat, so I would like to keep it only for ARM and M68K for now. May be I will add some code to make it automatically right inside uClibc-ng.

best regards
Waldemar