Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change behavior of piconfig module #180

Merged
merged 6 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/modules/is_req_preinstall/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,4 @@ echo_green "Cleanup ..."
sudo -u "${BASE_USER}" rm -rf "/home/${BASE_USER}/.cache"
popd &> /dev/null || exit 1

## Enable spi interface by default
echo_green "Enabling SPI Interface..."
sed -i 's/#dtparam=spi=on/dtparam=spi=on/' "${IS_REQ_PREINSTALL_CFG_FILE}"

echo_green "Install Input Shaper requirements ... done!"
8 changes: 6 additions & 2 deletions src/modules/piconfig/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@

[ -n "$PICONFIG_CONFIG_TXT_FILE" ] || PICONFIG_CONFIG_TXT_FILE="/boot/config.txt"
[ -n "$PICONFIG_CMDLINE_TXT_FILE" ] || PICONFIG_CMDLINE_TXT_FILE="/boot/cmdline.txt"
[ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/orig-config.txt"
[ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/orig-cmdline.txt"
[ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/config.txt.backup"
[ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/cmdline.txt.backup"

[ -n "$PICONFIG_SWAP_CONF_FILE" ] || PICONFIG_SWAP_CONF_FILE="/etc/dphys-swapfile"
[ -n "$PICONFIG_SWAP_SIZE" ] || PICONFIG_SWAP_SIZE="256"
[ -n "$PICONFIG_SWAP_MAX" ] || PICONFIG_SWAP_MAX="1024"
119 changes: 0 additions & 119 deletions src/modules/piconfig/filesystem/root/boot/config.txt

This file was deleted.

26 changes: 0 additions & 26 deletions src/modules/piconfig/filesystem/root/etc/dphys-swapfile

This file was deleted.

66 changes: 66 additions & 0 deletions src/modules/piconfig/filesystem/tmp/msos_config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

####################################################
#### MainsailOS specific configurations ####
####################################################
#### DO NOT CHANGE SECTION BELOW !!! ####
#### UNLESS YOU KNOW WHAT YOU ARE DOING !!! ####
####################################################

## For more options and information see
## https://www.raspberrypi.com/documentation/computers/config_txt.html
## Some settings may impact device functionality. See link above for details

## For additional information about device filters see
## https://www.raspberrypi.com/documentation/computers/config_txt.html#model-filters


[pi0]
## This affects Pi Zero(W) and Pi Zero2
## Due lag of RAM, limit GPU RAM
gpu_mem=128

[pi2]
gpu_mem=256

[pi3]
## Use 256 if 1Gb Ram Model!
gpu_mem=128
# gpu_mem=256

[pi4]
## Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
## Do not use more than 256Mb on Pi Model 4, it uses its own Management.
gpu_mem=256

[all]

## SPI Interface is enabled by default for Input Shaper
## This colides with Hyperpixel Display!
## Hyperpixel Screen uses the same Pin for Backlight.
dtparam=spi=on


## Enable Hardware UART for Serial Communication
## This also disables Bluetooth!
enable_uart=1
dtoverlay=disable-bt


## Disable libcamera (interferes with ustreamer, when using raspicams)
camera_auto_detect=0

## Enable VideoCore at boot, needed for Crowsnest (Raspicams and DSI devices).
start_x=1


### EXPERIMENTAL - Enable 64bit Kernel
### The 64-bit kernel will only work on:
### Raspberry Pi 3, 3+, 4, 400, Zero 2 W and 2B rev 1.2
### and Raspberry Pi Compute Modules 3, 3+ and 4.
# arm_64bit=1

####################################################

[all]
35 changes: 29 additions & 6 deletions src/modules/piconfig/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,42 @@ fi
source /common.sh
install_cleanup_trap

echo_green "Backup original config.txt and cmdline.txt ..."
# Step 1: Copy msos_config.txt
echo_green "Copying temporary file ..."
unpack /filesystem/tmp /tmp root

echo_green "Merge MainsailOS configuration with default config.txt ..."
# Step 2: Copy default config to "/tmp"
cp "${PICONFIG_CONFIG_TXT_FILE}" /tmp

# Step 3: Move default config to backup file
mv "${PICONFIG_CONFIG_TXT_FILE}" "${PICONFIG_CONFIG_BAK_FILE}"
cp "${PICONFIG_CMDLINE_TXT_FILE}" "${PICONFIG_CMDLINE_BAK_FILE}"

echo_green "Copying files to root filesystem ..."
unpack /filesystem/root /
# Step 4: Concatenate files to config
cat /tmp/config.txt /tmp/msos_config.txt > /tmp/config.new

# Step 5: Copy new config to "/boot/config.txt"
cp /tmp/config.new "${PICONFIG_CONFIG_TXT_FILE}"

# Step 6: Cleanup
rm -f /tmp/*config*

### Disable Console and services to enable Hardware Serial.
# Step 7: Copy default cmdline.txt to backup file
cp "${PICONFIG_CMDLINE_TXT_FILE}" "${PICONFIG_CMDLINE_BAK_FILE}"

# Step 8: Disable serial console to enable Hardware Serial (PL011).
echo_green "Disable Serial Linux console ..."
sed -i 's/console=serial0,115200 //' "${PICONFIG_CMDLINE_TXT_FILE}"

### disable bluetooth and related services
# Step 9: Disable bluetooth and related services
echo_green "Disabling Bluetooth related services..."
systemctl_if_exists disable hciuart.service
systemctl_if_exists disable bluetooth.service
systemctl_if_exists disable bluealsa.service

# Step 10: Increase swapfile size
if [[ -f "${PICONFIG_SWAP_CONF_FILE}" ]]; then
echo_green "Increasing swap file size to ${PICONFIG_SWAP_SIZE} Mb. Limit to ${PICONFIG_SWAP_MAX} Mb"
sed -i 's/^CONF_SWAPSIZE.*/'CONF_SWAPSIZE="${PICONFIG_SWAP_SIZE}"'/' "${PICONFIG_SWAP_CONF_FILE}"
sed -i 's/^#CONF_MAXSWAP.*/'CONF_MAXSWAP="${PICONFIG_SWAP_MAX}"'/' "${PICONFIG_SWAP_CONF_FILE}"
fi