-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathzynthian_envars_extended.sh
executable file
·166 lines (138 loc) · 5.99 KB
/
zynthian_envars_extended.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
#******************************************************************************
# ZYNTHIAN PROJECT: Zynthian System Configuration
#
# Set extended environment for configuration scripts
#
# Copyright (C) 2015-2022 Fernando Moyano <[email protected]>
#
#******************************************************************************
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the LICENSE.txt file.
# ****************************************************************************
#------------------------------------------------------------------------------
# Load Standard Environment Variables
#------------------------------------------------------------------------------
if [ -z "$ZYNTHIAN_CONFIG_DIR" ]; then
export ZYNTHIAN_CONFIG_DIR="/zynthian/config"
export ZYNTHIAN_SYS_DIR="/zynthian/zynthian-sys"
fi
if [ -f "$ZYNTHIAN_CONFIG_DIR/zynthian_envars.sh" ]; then
source "$ZYNTHIAN_CONFIG_DIR/zynthian_envars.sh"
elif [ -f "$ZYNTHIAN_SYS_DIR/scripts/zynthian_envars.sh" ]; then
source "$ZYNTHIAN_SYS_DIR/scripts/zynthian_envars.sh"
elif [ -f "zynthian_envars.sh" ]; then
source "zynthian_envars.sh"
else
echo "ERROR: Can't load zynthian configuration! => zynthian_envars.sh"
fi
#------------------------------------------------------------------------------
# Load Extended Environment Variables
#------------------------------------------------------------------------------
if [ -z "$ZYNTHIAN_EXTENDED_ENVARS_DEFINED" ]; then
export ZYNTHIAN_EXTENDED_ENVARS_DEFINED=1
#------------------------------------------------------------------------------
# Set system info envars
#------------------------------------------------------------------------------
export LINUX_OS_VERSION=$(lsb_release -cs)
export LINUX_KERNEL_VERSION=$(uname -r)
export ZYNTHIAN_OS_VERSION=$(cat /etc/zynthianos_version)
if [ -z "$VIRTUALIZATION" ]; then
export VIRTUALIZATION=$(systemd-detect-virt)
fi
echo ""
echo "----------------------------------------------"
echo "Linux Version: $LINUX_OS_VERSION"
echo "Kernel Version: $LINUX_KERNEL_VERSION"
echo "ZynthianOS Version: $ZYNTHIAN_OS_VERSION"
echo "Virtualization: $VIRTUALIZATION"
#------------------------------------------------------------------------------
# Build framework envars
#------------------------------------------------------------------------------
if [ -z "$RASPI" ]; then
# Hardware Architecture & Optimization Options
hw_architecture=$(uname -m 2>/dev/null)
if [ -e "/sys/firmware/devicetree/base/model" ]; then
# THIS MUST BE FIXED!!! IT DOESN'T WORK!
rbpi_version=$(tr -d '\0' < /sys/firmware/devicetree/base/model)
else
rbpi_version="Unknown"
fi
if [ "$hw_architecture" = "armv7l" ]; then
# 32bits => RPi3 (default)
CFLAGS="-mcpu=cortex-a53 -mfloat-abi=hard -mfpu=neon-fp-armv8 -mneon-for-64bits -mtune=cortex-a53"
#CFLAGS="${CFLAGS} -mlittle-endian -munaligned-access -mvectorize-with-neon-quad -ftree-vectorize"
CFLAGS_UNSAFE="-funsafe-loop-optimizations -funsafe-math-optimizations -ffast-math"
#RPi2 => Not supported anymore!
#CFLAGS="-mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4 -mtune=cortex-a7"
elif [ "$hw_architecture" = "aarch64" ]; then
# 64 bits => RPi4
CFLAGS="-mcpu=cortex-a72 -mtune=cortex-a72"
#CFLAGS="${CFLAGS} -mlittle-endian -munaligned-access -mvectorize-with-neon-quad -ftree-vectorize"
CFLAGS_UNSAFE="-funsafe-loop-optimizations -funsafe-math-optimizations -ffast-math"
fi
rbpi_words=($rbpi_version)
rbpi_version_number=${rbpi_words[2]}
if [[ $rbpi_version_number == "5" ]]; then
gpio_chip_device="/dev/gpiochip4"
if [[ ! -e "$gpio_chip_device" ]]; then
ln -s "/dev/gpiochip0" "$gpio_chip_device"
fi
i2c_device="/dev/i2c-1"
elif [[ $rbpi_version_number == "4" ]]; then
gpio_chip_device="/dev/gpiochip0"
i2c_device="/dev/i2c-1"
elif [[ $rbpi_version_number == "400" ]]; then
gpio_chip_device="/dev/gpiochip0"
i2c_device="/dev/i2c-1"
elif [[ $rbpi_version_number == "3" ]]; then
gpio_chip_device="/dev/gpiochip0"
i2c_device="/dev/i2c-1"
elif [[ $rbpi_version_number == "2" ]]; then
gpio_chip_device="/dev/gpiochip0"
i2c_device="/dev/i2c-1"
else
rbpi_version="$rbpi_version (UNSUPPORTED!)"
gpio_chip_device="/dev/gpiochip0"
i2c_device="/dev/i2c-1"
fi
export MACHINE_HW_NAME=$hw_architecture
export RBPI_VERSION=$rbpi_version
export RBPI_VERSION_NUMBER=$rbpi_version_number
export GPIO_CHIP_DEVICE=$gpio_chip_device
export I2C_DEVICE=$i2c_device
export CXXFLAGS=${CFLAGS}
export CFLAGS_UNSAFE=""
export RASPI="true"
echo "Hardware Architecture: ${hw_architecture}"
echo "Hardware Model: ${rbpi_version}"
fi
#------------------------------------------------------------------------------
# Apt Options
#------------------------------------------------------------------------------
export DEBIAN_FRONTEND="noninteractive"
export ZYNTHIAN_SETUP_APT_CLEAN="TRUE" # Set TRUE to clean /var/cache/apt during build, FALSE to leave alone
#------------------------------------------------------------------------------
# Software versions: Branches & Tags
#------------------------------------------------------------------------------
export ZYNTHIAN_STABLE_BRANCH="oram"
export ZYNTHIAN_STABLE_TAG="2409"
export ZYNTHIAN_TESTING_BRANCH="vangelis"
#------------------------------------------------------------------------------
# Enter python virtual environment
#------------------------------------------------------------------------------
source "$ZYNTHIAN_DIR/venv/bin/activate"
#------------------------------------------------------------------------------
echo "----------------------------------------------"
echo ""
fi