mirror of
https://github.com/Fishwaldo/build.git
synced 2025-06-21 21:58:51 +00:00
Enable crash detection. Sway a little with Banana Pi M3
This commit is contained in:
parent
e5c1088124
commit
ced9ca0c91
2 changed files with 260 additions and 285 deletions
|
@ -1,73 +0,0 @@
|
||||||
From 0d0c1ff54f2f61282d6f1e66e2f27eb3a4f31595 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Siarhei Siamashka <siarhei.siamashka@gmail.com>
|
|
||||||
Date: Wed, 23 Dec 2015 11:49:42 +0200
|
|
||||||
Subject: [PATCH] ARM: sun8i: Add SMP support for the Allwinner H3
|
|
||||||
|
|
||||||
The H3 is a quad Cortex-A7. Add the logic to use the IPs used to
|
|
||||||
control the CPU configuration and the CPU power so that we can
|
|
||||||
bring up secondary CPUs at boot.
|
|
||||||
|
|
||||||
CPUCFG in H3 is similar to CPUCFG in A31, but not exactly the
|
|
||||||
same. H3 PRCM is not documented at all. The SMP code in the
|
|
||||||
Allwinner SDK is guarded by the same ifdefs for A31 and H3, so
|
|
||||||
at least bringing up secondary CPU cores is likely compatible
|
|
||||||
between these two SoC variants.
|
|
||||||
|
|
||||||
Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
|
|
||||||
---
|
|
||||||
arch/arm/boot/dts/sun8i-h3.dtsi | 11 +++++++++++
|
|
||||||
arch/arm/mach-sunxi/platsmp.c | 6 ++++++
|
|
||||||
2 files changed, 17 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi
|
|
||||||
index 0faa38a..d23ed84 100644
|
|
||||||
--- a/arch/arm/boot/dts/sun8i-h3.dtsi
|
|
||||||
+++ b/arch/arm/boot/dts/sun8i-h3.dtsi
|
|
||||||
@@ -51,6 +51,7 @@
|
|
||||||
cpus {
|
|
||||||
#address-cells = <1>;
|
|
||||||
#size-cells = <0>;
|
|
||||||
+ enable-method = "allwinner,sun6i-a31";
|
|
||||||
|
|
||||||
cpu@0 {
|
|
||||||
compatible = "arm,cortex-a7";
|
|
||||||
@@ -591,5 +592,15 @@
|
|
||||||
interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
|
|
||||||
<GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
|
|
||||||
};
|
|
||||||
+
|
|
||||||
+ prcm@01f01400 {
|
|
||||||
+ compatible = "allwinner,sun8i-h3-prcm";
|
|
||||||
+ reg = <0x01f01400 0x200>;
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ cpucfg@01f01c00 {
|
|
||||||
+ compatible = "allwinner,sun8i-h3-cpuconfig";
|
|
||||||
+ reg = <0x01f01c00 0x300>;
|
|
||||||
+ };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
diff --git a/arch/arm/mach-sunxi/platsmp.c b/arch/arm/mach-sunxi/platsmp.c
|
|
||||||
index e8483ec7..8ca4064 100644
|
|
||||||
--- a/arch/arm/mach-sunxi/platsmp.c
|
|
||||||
+++ b/arch/arm/mach-sunxi/platsmp.c
|
|
||||||
@@ -44,6 +44,9 @@ static void __init sun6i_smp_prepare_cpus(unsigned int max_cpus)
|
|
||||||
struct device_node *node;
|
|
||||||
|
|
||||||
node = of_find_compatible_node(NULL, NULL, "allwinner,sun6i-a31-prcm");
|
|
||||||
+ if (!node)
|
|
||||||
+ node = of_find_compatible_node(NULL, NULL,
|
|
||||||
+ "allwinner,sun8i-h3-prcm");
|
|
||||||
if (!node) {
|
|
||||||
pr_err("Missing A31 PRCM node in the device tree\n");
|
|
||||||
return;
|
|
||||||
@@ -57,6 +60,9 @@ static void __init sun6i_smp_prepare_cpus(unsigned int max_cpus)
|
|
||||||
|
|
||||||
node = of_find_compatible_node(NULL, NULL,
|
|
||||||
"allwinner,sun6i-a31-cpuconfig");
|
|
||||||
+ if (!node)
|
|
||||||
+ node = of_find_compatible_node(NULL, NULL,
|
|
||||||
+ "allwinner,sun8i-h3-cpuconfig");
|
|
||||||
if (!node) {
|
|
||||||
pr_err("Missing A31 CPU config node in the device tree\n");
|
|
||||||
return;
|
|
|
@ -5,25 +5,12 @@
|
||||||
# Required-Stop: glibc
|
# Required-Stop: glibc
|
||||||
# Default-Start: 2 3 4 5
|
# Default-Start: 2 3 4 5
|
||||||
# Default-Stop: 0 1 6
|
# Default-Stop: 0 1 6
|
||||||
# Short-Description: Get some info about hardware for some ARM single board computers and set some basic things
|
# Short-Description: Armbian gathering informations about hardware
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
# Immediately exit if not called from init system at startup
|
|
||||||
if [ "X$1" != "Xstart" ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
create_motd_warning() {
|
collect_informations() {
|
||||||
cat > /etc/update-motd.d/90-warning <<EOT
|
|
||||||
#!/bin/bash
|
|
||||||
echo -e "\e[0;91mAttention:\x1B[0m $1\n"
|
|
||||||
rm "\$0"
|
|
||||||
EOT
|
|
||||||
chmod +x /etc/update-motd.d/90-warning
|
|
||||||
} # create_motd_warning
|
|
||||||
|
|
||||||
TMPFILE=$(mktemp /tmp/${0##*/}.XXXXXX)
|
TMPFILE=$(mktemp /tmp/${0##*/}.XXXXXX)
|
||||||
trap "rm \"${TMPFILE}\" ; exit 0" 0 1 2 3 15
|
trap "rm \"${TMPFILE}\" ; exit 0" 0 1 2 3 15
|
||||||
dmesg >"${TMPFILE}"
|
dmesg >"${TMPFILE}"
|
||||||
|
@ -37,12 +24,16 @@ HARDWARE=$(awk '/Hardware/ {print $3}' </proc/cpuinfo)
|
||||||
GMAC=$(grep "sun6i_gmac" "${TMPFILE}")$(grep "gmac0-" "${TMPFILE}")
|
GMAC=$(grep "sun6i_gmac" "${TMPFILE}")$(grep "gmac0-" "${TMPFILE}")
|
||||||
SUN8IPHY="$(awk -F"PHY ID " '/PHY ID / {print $2}' <"${TMPFILE}")"
|
SUN8IPHY="$(awk -F"PHY ID " '/PHY ID / {print $2}' <"${TMPFILE}")"
|
||||||
LEDS=$(grep "green:ph02:led1" "${TMPFILE}")
|
LEDS=$(grep "green:ph02:led1" "${TMPFILE}")
|
||||||
TERMINUS=$(lsusb | grep "1a40:0101")
|
TERMINUS=$(lsusb | grep -i "1a40:0101")
|
||||||
|
GL830=$(lsusb | grep -i "05e3:0718")
|
||||||
SWITCH=$(grep "BCM53125" "${TMPFILE}")
|
SWITCH=$(grep "BCM53125" "${TMPFILE}")
|
||||||
INTERUPT=$(grep "eth0" /proc/interrupts)
|
INTERUPT=$(grep "eth0" /proc/interrupts)
|
||||||
WIFI8189ES=$(lsmod | grep 8189es | grep -v "0 $" | grep -v "0$") # ignore when not loaded
|
WIFI8189ES=$(lsmod | grep 8189es | grep -v "0 $" | grep -v "0$") # ignore when not loaded
|
||||||
WIFIAP6211=$(lsmod | grep ap6211)
|
WIFIAP6211=$(lsmod | grep ap6211)
|
||||||
|
read VERSION </proc/version
|
||||||
|
} # collect_informations
|
||||||
|
|
||||||
|
set_io_scheduler() {
|
||||||
for i in $( lsblk -idn -o NAME ); do
|
for i in $( lsblk -idn -o NAME ); do
|
||||||
read ROTATE </sys/block/$i/queue/rotational
|
read ROTATE </sys/block/$i/queue/rotational
|
||||||
|
|
||||||
|
@ -55,7 +46,14 @@ for i in $( lsblk -idn -o NAME ); do
|
||||||
echo -e "[\e[0;32m ok \x1B[0m] Setting noop I/O scheduler for $i"
|
echo -e "[\e[0;32m ok \x1B[0m] Setting noop I/O scheduler for $i"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
} # set_io_scheduler
|
||||||
|
|
||||||
|
do_initialisation() {
|
||||||
|
# parse /etc/armbian-boards.conf and adjust everything
|
||||||
|
:
|
||||||
|
} # do_initialisation
|
||||||
|
|
||||||
|
detect_board() {
|
||||||
if [ "$ARCH" = "armv7l" ]; then
|
if [ "$ARCH" = "armv7l" ]; then
|
||||||
if [ $HARDWARE = "ODROID-XU3" ]; then
|
if [ $HARDWARE = "ODROID-XU3" ]; then
|
||||||
ID="Odroid XU4"
|
ID="Odroid XU4"
|
||||||
|
@ -123,6 +121,7 @@ if [ "$ARCH" = "armv7l" ]; then
|
||||||
if [ $HARDWARE = "sun8i" ]; then
|
if [ $HARDWARE = "sun8i" ]; then
|
||||||
ID="Orange H3"
|
ID="Orange H3"
|
||||||
# 3 or 30 sec user feedback that the board is ready after 1st login with 3.4 kernel
|
# 3 or 30 sec user feedback that the board is ready after 1st login with 3.4 kernel
|
||||||
|
# TODO: BPi M3 uses different led colors
|
||||||
SwapState="$(grep swap /etc/fstab)"
|
SwapState="$(grep swap /etc/fstab)"
|
||||||
if [ -f /sys/class/leds/green_led/trigger -a "X${SwapState}" != "X" ]; then
|
if [ -f /sys/class/leds/green_led/trigger -a "X${SwapState}" != "X" ]; then
|
||||||
echo timer >/sys/class/leds/green_led/trigger
|
echo timer >/sys/class/leds/green_led/trigger
|
||||||
|
@ -140,7 +139,11 @@ if [ "$ARCH" = "armv7l" ]; then
|
||||||
echo 8 >/proc/irq/$(awk -F":" "/${GbE}/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
echo 8 >/proc/irq/$(awk -F":" "/${GbE}/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
||||||
ID="Orange Pi+"
|
ID="Orange Pi+"
|
||||||
if [ $MEMTOTAL -gt 1500 ]; then
|
if [ $MEMTOTAL -gt 1500 ]; then
|
||||||
|
if [ ${CORES} -eq 4 ]; then
|
||||||
ID="Orange Pi+ 2"
|
ID="Orange Pi+ 2"
|
||||||
|
else
|
||||||
|
ID="Banana Pi M3"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
case ${SUN8IPHY} in
|
case ${SUN8IPHY} in
|
||||||
00441400*)
|
00441400*)
|
||||||
|
@ -175,7 +178,7 @@ if [ "$ARCH" = "armv7l" ]; then
|
||||||
ScriptBinName="$(echo "${ID}" | tr '[:upper:]' '[:lower:]' | sed -e 's/+/plus/' -e 's/\ //g' -e 's/2mini$/2/g' -e 's/plus2$/plus/g').bin"
|
ScriptBinName="$(echo "${ID}" | tr '[:upper:]' '[:lower:]' | sed -e 's/+/plus/' -e 's/\ //g' -e 's/2mini$/2/g' -e 's/plus2$/plus/g').bin"
|
||||||
ScriptBinUsed="$(readlink -f "/boot/script.bin")"
|
ScriptBinUsed="$(readlink -f "/boot/script.bin")"
|
||||||
if [ "X${ScriptBinName}" != "X${ScriptBinUsed##*/}" -a ! -f "/root/.not_logged_in_yet" ]; then
|
if [ "X${ScriptBinName}" != "X${ScriptBinUsed##*/}" -a ! -f "/root/.not_logged_in_yet" ]; then
|
||||||
create_motd_warning "It seems the image is running on ${ID} but you're using wrong settings: ${ScriptBinUsed##*/}"
|
show_motd_warning "It seems the image is running on ${ID} but you're using wrong settings: ${ScriptBinUsed##*/}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ "$ARCH" = "aarch64" ]; then
|
elif [ "$ARCH" = "aarch64" ]; then
|
||||||
|
@ -201,31 +204,76 @@ if [[ $MACHINE == *Cubietruck* ]]; then ID="Cubietruck"; fi
|
||||||
if [[ $MACHINE == *Cubieboard* ]]; then ID="Cubieboard"; fi
|
if [[ $MACHINE == *Cubieboard* ]]; then ID="Cubieboard"; fi
|
||||||
if [[ $MACHINE == *Pro* ]]; then ID="Banana Pro"; fi
|
if [[ $MACHINE == *Pro* ]]; then ID="Banana Pro"; fi
|
||||||
if [[ $MACHINE == *M2* ]]; then ID="Banana M2"; fi
|
if [[ $MACHINE == *M2* ]]; then ID="Banana M2"; fi
|
||||||
|
} # detect_board
|
||||||
|
|
||||||
|
log_hardware_info() {
|
||||||
|
Log=${Log}
|
||||||
|
if [ -f ${Log} ]; then
|
||||||
|
echo -e "\n\n\n$(date) $HARDWARE $ARCH $KERNELID $MACHINE $ID" >>${Log}
|
||||||
|
else
|
||||||
|
echo "$(date) $HARDWARE $ARCH $KERNELID $MACHINE $ID" >>${Log}
|
||||||
|
chmod 755 ${Log}
|
||||||
|
fi
|
||||||
|
echo "${VERSION}" >>${Log}
|
||||||
|
echo -e "\n### dmesg:\n" >>${Log}
|
||||||
|
cat "${TMPFILE}" >>${Log}
|
||||||
|
echo -e "\n### lsusb:" >>${Log}
|
||||||
|
lsusb -v 2>/dev/null >>${Log}
|
||||||
|
echo -e "\n### lscpu:\n" >>${Log}
|
||||||
|
lscpu >>${Log}
|
||||||
|
echo -e "\n### cpuinfo:\n" >>${Log}
|
||||||
|
cat /proc/cpuinfo >>${Log}
|
||||||
|
echo -e "\n### meminfo:\n" >>${Log}
|
||||||
|
cat /proc/meminfo >>${Log}
|
||||||
|
echo -e "\n### interrupts:\n" >>${Log}
|
||||||
|
cat /proc/interrupts >>${Log}
|
||||||
|
echo -e "\n### ifconfig:\n" >>${Log}
|
||||||
|
ifconfig >>${Log}
|
||||||
|
echo -e "\n### df:\n" >>${Log}
|
||||||
|
df -h >>${Log}
|
||||||
|
# TODO: logrotate is missing
|
||||||
|
} # log_hardware_info
|
||||||
|
|
||||||
|
show_motd_warning() {
|
||||||
|
cat > /etc/update-motd.d/90-warning <<EOT
|
||||||
|
#!/bin/bash
|
||||||
|
echo -e "\e[0;91mAttention:\x1B[0m $1\n"
|
||||||
|
rm "\$0"
|
||||||
|
EOT
|
||||||
|
chmod +x /etc/update-motd.d/90-warning
|
||||||
|
} # show_motd_warning
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
*start*)
|
||||||
|
# get hardware informations
|
||||||
|
collect_informations
|
||||||
|
|
||||||
|
# set optimal disk scheduler settings
|
||||||
|
set_io_scheduler
|
||||||
|
|
||||||
|
# hardware detection
|
||||||
|
detect_board
|
||||||
|
|
||||||
|
# display message, log hardware id to file, write log
|
||||||
echo -e "[\e[0;32m ok \x1B[0m] Starting ARM hardware info: $ID"
|
echo -e "[\e[0;32m ok \x1B[0m] Starting ARM hardware info: $ID"
|
||||||
echo $ID > /var/run/machine.id
|
echo $ID > /var/run/machine.id
|
||||||
export HARDWARE DISTROID DISTROCODE ARCH KERNELID MACHINE ID
|
log_hardware_info
|
||||||
|
|
||||||
if [ -f /var/log/armhwinfo.log ]; then
|
# crash detection, enable verbose logging and disable it at clean shutdown
|
||||||
echo -e "\n\n\n$(date) $HARDWARE $DISTROID $DISTROCODE $ARCH $KERNELID $MACHINE $ID" >>/var/log/armhwinfo.log
|
echo "$(date "+%s") $HARDWARE $ARCH $KERNELID $MACHINE $ID $VERSION" >/boot/.verbose
|
||||||
else
|
sync
|
||||||
echo "$(date) $HARDWARE $DISTROID $DISTROCODE $ARCH $KERNELID $MACHINE $ID" >>/var/log/armhwinfo.log
|
;;
|
||||||
chmod 755 /var/log/armhwinfo.log
|
query)
|
||||||
|
# armbianmonitor mode -- only interested in hardware info
|
||||||
|
collect_informations >/dev/null
|
||||||
|
detect_board >/dev/null
|
||||||
|
export HARDWARE ARCH KERNELID MACHINE ID VERSION
|
||||||
|
;;
|
||||||
|
*stop*)
|
||||||
|
# remove /boot/.verbose only if /boot/.force-verbose doesn't exist.
|
||||||
|
# If our users demand verbose messages they get them
|
||||||
|
if [ -f /boot/.verbose ! -a -f /boot/.force-verbose ]; then
|
||||||
|
rm /boot/.verbose
|
||||||
fi
|
fi
|
||||||
cat /proc/version >>/var/log/armhwinfo.log
|
;;
|
||||||
echo -e "\n### dmesg:\n" >>/var/log/armhwinfo.log
|
esac
|
||||||
cat "${TMPFILE}" >>/var/log/armhwinfo.log
|
|
||||||
echo -e "\n### lsusb:" >>/var/log/armhwinfo.log
|
|
||||||
lsusb -v >>/var/log/armhwinfo.log
|
|
||||||
echo -e "\n### lscpu:\n" >>/var/log/armhwinfo.log
|
|
||||||
lscpu >>/var/log/armhwinfo.log
|
|
||||||
echo -e "\n### cpuinfo:\n" >>/var/log/armhwinfo.log
|
|
||||||
cat /proc/cpuinfo >>/var/log/armhwinfo.log
|
|
||||||
echo -e "\n### meminfo:\n" >>/var/log/armhwinfo.log
|
|
||||||
cat /proc/meminfo >>/var/log/armhwinfo.log
|
|
||||||
echo -e "\n### interrupts:\n" >>/var/log/armhwinfo.log
|
|
||||||
cat /proc/interrupts >>/var/log/armhwinfo.log
|
|
||||||
echo -e "\n### ifconfig:\n" >>/var/log/armhwinfo.log
|
|
||||||
ifconfig >>/var/log/armhwinfo.log
|
|
||||||
echo -e "\n### df:\n" >>/var/log/armhwinfo.log
|
|
||||||
df -h >>/var/log/armhwinfo.log
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue