Enable coredumps from systemd units

On ARM, backtraces on C code are not terribly useful by default because
the stack cannot really be unwound, hence a custom compiler flag for
this. This has never been a problem because I've only ever debugged C++
code *on the device itself*, and for C++ code stack unwinding is enabled
by the language frontend because it's needed for exception support. On
the C code, not so much.

With this flag, U-Boot fails to build, but just its examples. There's no
need to help these examples in the first place, though, so let's just
screw^Wskip them.

I *think* I also need to explicitly enable non-zero core sizes, even if
I already have systemd-coredumpctl enabled via systemd magic.

Change-Id: I094c52c2ead9c1dd581de4974e9edd432c8b6894
diff --git a/board/czechlight/clearfog/patches/u-boot/0004-examples-make-examples-optional.patch b/board/czechlight/clearfog/patches/u-boot/0004-examples-make-examples-optional.patch
new file mode 100644
index 0000000..3dbad3f
--- /dev/null
+++ b/board/czechlight/clearfog/patches/u-boot/0004-examples-make-examples-optional.patch
@@ -0,0 +1,57 @@
+From 25591463ae3bfbb359c42edde15158a714437c65 Mon Sep 17 00:00:00 2001
+From: Heinrich Schuchardt <xypron.glpk@gmx.de>
+Date: Wed, 23 Sep 2020 19:09:51 +0200
+Subject: [PATCH] examples: make examples/ optional
+
+Most users don't need the standalone API examples. Distributions like SUSE
+do not supply libgcc for cross-compiling and we cannot do without on ARMv8
+for building examples/.
+
+Make examples selectable via symbol CONFIG_EXAMPLES. It defaults to
+yes on ARCH_QEMU to ensure that we compile the API as part of our
+continuous integration.
+
+Cc: Matthias Brugger <mbrugger@suse.com>
+Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
+Reviewed-by: Tom Rini <trini@konsulko.com>
+Reviewed-by: Simon Glass <sjg@chromium.org>
+Reviewed-by: Matthias Brugger <mbrugger@suse.com>
+---
+ Kconfig           | 8 ++++++++
+ examples/Makefile | 2 +-
+ 2 files changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/Kconfig b/Kconfig
+index d96e3373c1..b272def247 100644
+--- a/Kconfig
++++ b/Kconfig
+@@ -221,6 +221,14 @@ config BUILD_ROM
+ 	  which are not shipped in the U-Boot source tree.
+ 	  Please, see doc/README.x86 for details.
+ 
++config EXAMPLES
++	bool "Compile API examples"
++	depends on !SANDBOX
++	default y if ARCH_QEMU
++	help
++	  U-Boot provides an API for standalone applications. Examples are
++	  provided in directory examples/.
++
+ endmenu		# General setup
+ 
+ menu "Boot images"
+diff --git a/examples/Makefile b/examples/Makefile
+index d440bc5655..bf518bd221 100644
+--- a/examples/Makefile
++++ b/examples/Makefile
+@@ -1,6 +1,6 @@
+ # SPDX-License-Identifier: GPL-2.0+
+ 
+-ifndef CONFIG_SANDBOX
++ifdef CONFIG_EXAMPLES
+ 
+ ifdef FTRACE
+ subdir-ccflags-y += -finstrument-functions -DFTRACE
+-- 
+2.29.0
+
diff --git a/board/czechlight/clearfog/uboot.fragment b/board/czechlight/clearfog/uboot.fragment
index d231b5d..40082ef 100644
--- a/board/czechlight/clearfog/uboot.fragment
+++ b/board/czechlight/clearfog/uboot.fragment
@@ -1 +1,2 @@
 CONFIG_CMD_SETEXPR=y
+CONFIG_EXAMPLES=n
diff --git a/board/czechlight/common/overlay/etc/systemd/system.conf b/board/czechlight/common/overlay/etc/systemd/system.conf
new file mode 100644
index 0000000..8f3e655
--- /dev/null
+++ b/board/czechlight/common/overlay/etc/systemd/system.conf
@@ -0,0 +1,72 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+#
+# Entries in this file show the compile time defaults.
+# You can change settings by editing this file.
+# Defaults can be restored by simply deleting this file.
+#
+# See systemd-system.conf(5) for details.
+
+[Manager]
+#LogLevel=info
+#LogTarget=journal-or-kmsg
+#LogColor=yes
+#LogLocation=no
+#LogTime=no
+#DumpCore=yes
+#ShowStatus=yes
+#CrashChangeVT=no
+#CrashShell=no
+#CrashReboot=no
+#CtrlAltDelBurstAction=reboot-force
+#CPUAffinity=1 2
+#NUMAPolicy=default
+#NUMAMask=
+#RuntimeWatchdogSec=0
+#RebootWatchdogSec=10min
+#ShutdownWatchdogSec=10min
+#KExecWatchdogSec=0
+#WatchdogDevice=
+#CapabilityBoundingSet=
+#NoNewPrivileges=no
+#SystemCallArchitectures=
+#TimerSlackNSec=
+#StatusUnitFormat=description
+#DefaultTimerAccuracySec=1min
+#DefaultStandardOutput=journal
+#DefaultStandardError=inherit
+#DefaultTimeoutStartSec=90s
+#DefaultTimeoutStopSec=90s
+#DefaultTimeoutAbortSec=
+#DefaultRestartSec=100ms
+#DefaultStartLimitIntervalSec=10s
+#DefaultStartLimitBurst=5
+#DefaultEnvironment=
+#DefaultCPUAccounting=no
+#DefaultIOAccounting=no
+#DefaultIPAccounting=no
+#DefaultBlockIOAccounting=no
+#DefaultMemoryAccounting=yes
+#DefaultTasksAccounting=yes
+#DefaultTasksMax=15%
+#DefaultLimitCPU=
+#DefaultLimitFSIZE=
+#DefaultLimitDATA=
+#DefaultLimitSTACK=
+#DefaultLimitCORE=
+DefaultLimitCORE=infinity
+#DefaultLimitRSS=
+#DefaultLimitNOFILE=1024:524288
+#DefaultLimitAS=
+#DefaultLimitNPROC=
+#DefaultLimitMEMLOCK=
+#DefaultLimitLOCKS=
+#DefaultLimitSIGPENDING=
+#DefaultLimitMSGQUEUE=
+#DefaultLimitNICE=
+#DefaultLimitRTPRIO=
+#DefaultLimitRTTIME=
diff --git a/configs/czechlight_clearfog_defconfig b/configs/czechlight_clearfog_defconfig
index 0f11ee4..399a9ab 100644
--- a/configs/czechlight_clearfog_defconfig
+++ b/configs/czechlight_clearfog_defconfig
@@ -12,7 +12,7 @@
 BR2_TOOLCHAIN_EXTERNAL=y
 BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
 BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY=y
-BR2_TARGET_OPTIMIZATION="-Wno-psabi"
+BR2_TARGET_OPTIMIZATION="-Wno-psabi -fasynchronous-unwind-tables"
 BR2_TARGET_GENERIC_HOSTNAME="czechlight"
 BR2_TARGET_GENERIC_ISSUE="Welcome to Czech Light"
 BR2_INIT_SYSTEMD=y
@@ -64,6 +64,7 @@
 BR2_PACKAGE_RAUC=y
 BR2_PACKAGE_RAUC_NETWORK=y
 BR2_PACKAGE_SYSTEMD_JOURNAL_REMOTE=y
+BR2_PACKAGE_SYSTEMD_COREDUMP=y
 # BR2_PACKAGE_SYSTEMD_HWDB is not set
 BR2_PACKAGE_SYSTEMD_RANDOMSEED=y
 # BR2_PACKAGE_SYSTEMD_VCONSOLE is not set
@@ -81,7 +82,7 @@
 BR2_TARGET_UBOOT_CUSTOM_GIT=y
 BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://gerrit.cesnet.cz/github/trini/u-boot"
 BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="v2018.09"
-BR2_TARGET_UBOOT_PATCH="$(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/boot.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0001-Remove-redundant-YYLOC-global-declaration.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0002-Kbuild-fix-escaping-in-.cmd-files-for-future-Make.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0003-kbuild-fix-escaping-in-appending-U-Boot-own-DT.patch"
+BR2_TARGET_UBOOT_PATCH="$(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/boot.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0001-Remove-redundant-YYLOC-global-declaration.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0002-Kbuild-fix-escaping-in-.cmd-files-for-future-Make.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0003-kbuild-fix-escaping-in-appending-U-Boot-own-DT.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0004-examples-make-examples-optional.patch"
 BR2_TARGET_UBOOT_BOARD_DEFCONFIG="clearfog"
 BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/uboot.fragment"
 BR2_TARGET_UBOOT_NEEDS_DTC=y