[All][RPI] Clean ups and some fixed (+kerenl bump)

This commit is contained in:
j1nx 2023-12-17 13:49:45 +00:00
parent e34033bff1
commit d0c5ebd4d1
27 changed files with 16 additions and 819 deletions

@ -1 +1 @@
Subproject commit 908f00306fc044ab4755d101e1a4e03ae12197b3
Subproject commit d16f62919384610b1fb2e6641ed915c9818bef2f

View File

@ -1,101 +0,0 @@
From 79e6ac0d94c3f60efbf9720b4df8f9313a689441 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Thu, 10 Aug 2023 21:00:51 +0100
Subject: [PATCH] mmc: sdhci: fix max req size based on spec
For almost 2 decades, the max allowed requests were limited to 512KB because of
SDMA's max 512KiB boundary limit.
ADMA2 and ADMA3 do not have such limits and were effectively made so any
kind of block count would not impose interrupt and managing stress to the host.
By limiting that to 512KiB, it effectively downgrades these DMA modes to SDMA.
Fix that by actually following the spec:
When ADMA is selected tuning mode is advised.
On lesser modes 4MiB transfers is selected as max, so re-tuning if timer trigger
or if requested by host interrupt, can be done in time.
Otherwise, the only limit is the variable size of types used.
In this implementation, 16MiB is used as maximum since tests showed that after
that point, there are diminishing returns.
Also 16MiB in worst case scenarios, when card is eMMC and its max speed is a
generous 350MiB/s, will generate interrupts every 45ms on huge data transfers.
A new `adma_get_req_limit` sdhci host function was also introduced, to let
vendors override imposed limits by the generic implementation if needed.
For example, on local tests with rigorous CPU/GPU burn-in tests and abrupt
cut-offs to generate huge temperature changes (upwards/downwards) to the card,
tested host was fine up to 128MB/s transfers on slow cards that used SDR104
bus timing without re-tuning.
In that case the 4MiB limit was overridden with a more than safe 8MiB value.
In all testing cases and boards, that change brought the following:
Depending on bus timing and eMMC/SD specs:
* Max Read throughput increased by 2-20%
* Max Write throughput increased by 50-200%
Depending on CPU frequency and transfer sizes:
* Reduced mmcqd cpu core usage by 4-50%
Signed-off-by: CTCaer <ctcaer@gmail.com>
---
drivers/mmc/host/sdhci.c | 17 ++++++++++++-----
drivers/mmc/host/sdhci.h | 4 ++--
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 84d0d7ac0ae65..518fbaa62e092 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1095,7 +1095,7 @@ static void sdhci_initialize_data(struct sdhci_host *host,
WARN_ON(host->data);
/* Sanity checks */
- BUG_ON(data->blksz * data->blocks > 524288);
+ BUG_ON(data->blksz * data->blocks > host->mmc->max_req_size);
BUG_ON(data->blksz > host->mmc->max_blk_size);
BUG_ON(data->blocks > 65535);
@@ -4720,11 +4720,18 @@ int sdhci_setup_host(struct sdhci_host *host)
/*
* Maximum number of sectors in one transfer. Limited by SDMA boundary
- * size (512KiB). Note some tuning modes impose a 4MiB limit, but this
- * is less anyway.
+ * size and by tuning modes on ADMA. On tuning mode 3 16MiB is more than
+ * enough to cover big data transfers.
*/
- mmc->max_req_size = 524288;
-
+ if (host->flags & SDHCI_USE_ADMA) {
+ if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+ mmc->max_req_size = 4194304;
+ else
+ mmc->max_req_size = 16777216;
+ } else {
+ /* On PIO/SDMA use SDMA boundary size (512KiB). */
+ mmc->max_req_size = 524288;
+ }
/*
* Maximum number of segments. Depends on if the hardware
* can do scatter/gather or not.
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 5ce7cdcc192fd..7c85aeee814d6 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -339,11 +339,11 @@ struct sdhci_adma2_64_desc {
#define ADMA2_END 0x2
/*
- * Maximum segments assuming a 512KiB maximum requisition size and a minimum
+ * Maximum segments assuming a 16MiB maximum requisition size and a minimum
* 4KiB page size. Note this also allows enough for multiple descriptors in
* case of PAGE_SIZE >= 64KiB.
*/
-#define SDHCI_MAX_SEGS 128
+#define SDHCI_MAX_SEGS 4096
/* Allow for a a command request and a data request at the same time */
#define SDHCI_MAX_MRQS 2

View File

@ -1,3 +1,4 @@
options snd_soc_simple_card index=0
options snd_soc_rpi_proto index=0
options snd_bcm2835 index=1
options snd slots=snd-soc-simple-card,snd-bcm2835
options snd slots=snd_soc_simple_card,snd_soc_rpi_proto,snd_bcm2835

View File

@ -1,337 +0,0 @@
state.ALSA {
control.1 {
iface MIXER
name 'PCM Playback Volume'
value 400
comment {
access 'read write'
type INTEGER
count 1
range '-10239 - 400'
dbmin -9999999
dbmax 400
dbvalue.0 400
}
}
control.2 {
iface MIXER
name 'PCM Playback Switch'
value true
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.3 {
iface MIXER
name 'PCM Playback Route'
value 1
comment {
access 'read write'
type INTEGER
count 1
range '0 - 2'
}
}
control.4 {
iface PCM
name 'IEC958 Playback Default'
value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access 'read write'
type IEC958
count 1
}
}
control.5 {
iface PCM
name 'IEC958 Playback Con Mask'
value '0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access read
type IEC958
count 1
}
}
control.6 {
iface PCM
name 'IEC958 Playback PCM Stream'
value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access 'read write inactive'
type IEC958
count 1
}
}
}
state.seeed8micvoicec {
control.1 {
iface MIXER
name 'CH1 digital volume'
value 208
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 3675
}
}
control.2 {
iface MIXER
name 'CH2 digital volume'
value 208
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 3675
}
}
control.3 {
iface MIXER
name 'CH3 digital volume'
value 208
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 3675
}
}
control.4 {
iface MIXER
name 'CH4 digital volume'
value 208
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 3675
}
}
control.5 {
iface MIXER
name 'ADC1 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.6 {
iface MIXER
name 'ADC2 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.7 {
iface MIXER
name 'ADC3 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.8 {
iface MIXER
name 'ADC4 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.9 {
iface MIXER
name 'CH5 digital volume'
value 208
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 3675
}
}
control.10 {
iface MIXER
name 'CH6 digital volume'
value 208
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 3675
}
}
control.11 {
iface MIXER
name 'CH7 digital volume'
value 198
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 2925
}
}
control.12 {
iface MIXER
name 'CH8 digital volume'
value 198
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 2925
}
}
control.13 {
iface MIXER
name 'ADC5 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.14 {
iface MIXER
name 'ADC6 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.15 {
iface MIXER
name 'ADC7 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.16 {
iface MIXER
name 'ADC8 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.17 {
iface MIXER
name 'DAC Playback Volume'
value.0 0
value.1 0
comment {
access 'read write'
type INTEGER
count 2
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 -11925
dbvalue.1 -11925
}
}
control.18 {
iface MIXER
name 'Speaker Playback Volume'
value 25
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin -4800
dbmax -150
dbvalue.0 -1050
}
}
control.19 {
iface MIXER
name 'Headphone Playback Volume'
value 52
comment {
access 'read write'
type INTEGER
count 1
range '0 - 63'
dbmin -6300
dbmax 0
dbvalue.0 -1100
}
}
}

View File

@ -1,181 +0,0 @@
state.ALSA {
control.1 {
iface MIXER
name 'PCM Playback Volume'
value 400
comment {
access 'read write'
type INTEGER
count 1
range '-10239 - 400'
dbmin -9999999
dbmax 400
dbvalue.0 400
}
}
control.2 {
iface MIXER
name 'PCM Playback Switch'
value true
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.3 {
iface MIXER
name 'PCM Playback Route'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 2'
}
}
control.4 {
iface PCM
name 'IEC958 Playback Default'
value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access 'read write'
type IEC958
count 1
}
}
control.5 {
iface PCM
name 'IEC958 Playback Con Mask'
value '0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access read
type IEC958
count 1
}
}
control.6 {
iface PCM
name 'IEC958 Playback PCM Stream'
value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access 'read write inactive'
type IEC958
count 1
}
}
}
state.seeed4micvoicec {
control.1 {
iface MIXER
name 'CH1 digital volume'
value 222
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 4725
}
}
control.2 {
iface MIXER
name 'CH2 digital volume'
value 222
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 4725
}
}
control.3 {
iface MIXER
name 'CH3 digital volume'
value 222
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 4725
}
}
control.4 {
iface MIXER
name 'CH4 digital volume'
value 222
comment {
access 'read write'
type INTEGER
count 1
range '0 - 255'
dbmin -11925
dbmax 7200
dbvalue.0 4725
}
}
control.5 {
iface MIXER
name 'ADC1 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.6 {
iface MIXER
name 'ADC2 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.7 {
iface MIXER
name 'ADC3 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
control.8 {
iface MIXER
name 'ADC4 PGA gain'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 31'
dbmin 0
dbmax 3100
dbvalue.0 0
}
}
}

View File

@ -1,58 +0,0 @@
state.ALSA {
control.1 {
iface MIXER
name 'PCM Playback Volume'
value -31
comment {
access 'read write'
type INTEGER
count 1
range '-10239 - 400'
dbmin -9999999
dbmax 400
dbvalue.0 -31
}
}
control.2 {
iface MIXER
name 'PCM Playback Switch'
value true
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.3 {
iface MIXER
name 'PCM Playback Route'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 3'
}
}
control.4 {
iface PCM
name 'IEC958 Playback Default'
value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access 'read write'
type IEC958
count 1
}
}
control.5 {
iface PCM
name 'IEC958 Playback Con Mask'
value '0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access read
type IEC958
count 1
}
}
}

View File

@ -0,0 +1,2 @@
git+https://github.com/OpenVoiceOS/ovos-PHAL-plugin-mk1.git
git+https://github.com/NeonGeckoCom/neon-phal-plugin-linear_led.git

View File

@ -1,11 +1,9 @@
[Unit]
Description=I2C Sound configuration service
After=alsa-restore.service
Requires=dev-i2c\x2d1.device
After=dev-i2c\x2d1.device
Requires=systemd-modules-load.service
After=systemd-modules-load.service
Before=pulseaudio.service
[Service]
Type=oneshot

View File

@ -1,58 +0,0 @@
state.ALSA {
control.1 {
iface MIXER
name 'PCM Playback Volume'
value -31
comment {
access 'read write'
type INTEGER
count 1
range '-10239 - 400'
dbmin -9999999
dbmax 400
dbvalue.0 -31
}
}
control.2 {
iface MIXER
name 'PCM Playback Switch'
value true
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.3 {
iface MIXER
name 'PCM Playback Route'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 3'
}
}
control.4 {
iface PCM
name 'IEC958 Playback Default'
value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access 'read write'
type IEC958
count 1
}
}
control.5 {
iface PCM
name 'IEC958 Playback Con Mask'
value '0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access read
type IEC958
count 1
}
}
}

View File

@ -28,7 +28,7 @@ BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/ovos/ova/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="--ova"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.66"
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.68"
BR2_LINUX_KERNEL_DEFCONFIG="x86_64"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL)/kernel/ovos.config $(BR2_EXTERNAL)/kernel/device-drivers.config $(BR2_EXTERNAL)/kernel/docker.config $(BR2_EXTERNAL)/board/ovos/ova/kernel.config"
BR2_LINUX_KERNEL_LZ4=y

View File

@ -29,7 +29,7 @@ BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi3/post-i
BR2_ROOTFS_POST_SCRIPT_ARGS="--rpi3"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,3d9d7e7b2aa312f79f8034a9d42b7e7ccb92c54b)/linux-3d9d7e7b2aa312f79f8034a9d42b7e7ccb92c54b.tar.gz"
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,e41b05a8fc73f95425aceaf15a68fc25da1d1fe5)/linux-e41b05a8fc73f95425aceaf15a68fc25da1d1fe5.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="bcmrpi3"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL)/kernel/ovos.config $(BR2_EXTERNAL)/kernel/device-drivers.config $(BR2_EXTERNAL)/kernel/docker.config $(BR2_EXTERNAL)/board/ovos/raspberrypi/kernel.config"
BR2_LINUX_KERNEL_LZ4=y

View File

@ -30,7 +30,7 @@ BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi4/post-i
BR2_ROOTFS_POST_SCRIPT_ARGS="--rpi4"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,3d9d7e7b2aa312f79f8034a9d42b7e7ccb92c54b)/linux-3d9d7e7b2aa312f79f8034a9d42b7e7ccb92c54b.tar.gz"
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,e41b05a8fc73f95425aceaf15a68fc25da1d1fe5)/linux-e41b05a8fc73f95425aceaf15a68fc25da1d1fe5.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL)/kernel/ovos.config $(BR2_EXTERNAL)/kernel/device-drivers.config $(BR2_EXTERNAL)/kernel/docker.config $(BR2_EXTERNAL)/board/ovos/raspberrypi/kernel.config"
BR2_LINUX_KERNEL_LZ4=y

View File

@ -5,7 +5,6 @@ options saa7134-alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2
options snd-usb-audio index=-2
options snd-usb-usx2y index=-2
options snd-usb-caiaq index=-2
options snd-usb-ua101 index=-2

View File

@ -1,3 +0,0 @@
{
"max_allowed_core_version": 21.2
}

View File

@ -49,14 +49,20 @@
},
"tts": {
"module": "ovos-tts-plugin-server",
"ovos-tts-plugin-piper": {
"model": "alan_low"
"ovos-tts-plugin-server": {
"host": "https://tts.smartgic.io/piper",
"voice": "ryan-high"
},
"fallback_module": "ovos-tts-plugin-mimic",
"ovos-tts-plugin-mimic": {
"voice": "ap"
}
},
"stt": {
"ovos-stt-plugin-server": {
"url": "https://stt.smartgic.io/fasterwhisper/stt"
}
},
"padatious": {
"regex_only": false
},

View File

@ -1,18 +0,0 @@
#
# Note that two different ALSA card state management schemes exist and they
# can be switched using a file exist check - /etc/alsa/state-daemon.conf .
#
[Unit]
Description=Save/Restore Sound Card State
ConditionPathExists=!/etc/alsa/state-daemon.conf
ConditionPathExistsGlob=/dev/snd/control*
ConditionPathExists=/etc/voicecard/asound.state
[Service]
Type=oneshot
RemainAfterExit=true
ExecStartPre=/bin/mkdir -p /run/alsa
ExecStart=-/usr/sbin/alsactl -E HOME=/run/alsa -f /etc/voicecard/asound.state restore
ExecStop=-/usr/sbin/alsactl -E HOME=/run/alsa -f /etc/voicecard/asound.state store

View File

@ -1,50 +0,0 @@
#!/bin/sh
set -euo pipefail
PATH=/sbin:/bin:/usr/sbin:/usr/bin
/bin/mount -t proc proc /proc
/bin/mount -t sysfs sysfs /sys
grep -w "/dev" /proc/mounts >/dev/null || /bin/mount -t devtmpfs none /dev
[ -z "${CMDLINE+x}" ] && CMDLINE=`cat /proc/cmdline`
for arg in $CMDLINE; do
optarg=`expr "x$arg" : 'x[^=]*=\(.*\)' || echo ''`
case $arg in
root=*)
ROOT_RODEVICE=$optarg ;;
rootfstype=*)
ROOT_ROFSTYPE=$optarg ;;
esac
done
ROOT_ROMOUNTPARAMS="-t $ROOT_ROFSTYPE -o noatime,nodiratime $ROOT_RODEVICE"
if ! /bin/mount $ROOT_ROMOUNTPARAMS /media/rfs/ro 2>/dev/null && \
[ "x-o bind /" == "x$ROOT_ROMOUNTPARAMS" ] || \
log "Could not mount $ROOT_RODEVICE, bind mounting..." && \
! /bin/mount -o bind / /media/rfs/ro; then
fatal "Could not mount read-only rootfs"
fi
if ! /bin/mount -o remount,ro /media/rfs/ro; then
fatal "Could not remount read-only rootfs as read only"
fi
if ! /bin/mount PARTUUID=f1326040-5236-40eb-b683-aaa100a9afcf /media/rfs/rw -t auto -o relatime,nosuid,nodev ; then
fatal "Could not mount read-write rootfs"
fi
mkdir -p /media/rfs/rw/upperdir /media/rfs/rw/work
/bin/mount -t overlay overlay -o lowerdir=/media/rfs/ro,upperdir=/media/rfs/rw/upperdir,workdir=/media/rfs/rw/work /mnt
mkdir -p /mnt/media/rfs/ro /mnt/media/rfs/rw
/bin/mount -n --move /media/rfs/ro /mnt/media/rfs/ro
/bin/mount -n --move /media/rfs/rw /mnt/media/rfs/rw
/bin/mount -n --move /proc /mnt/proc
/bin/mount -n --move /sys /mnt/sys
/bin/mount -n --move /dev /mnt/dev
cd /mnt
exec chroot /mnt /sbin/init || fatal "Couldn't chroot, dropping to shell"