blob: ba545649f382d7972ec4b3a3af24bb1f9587c3b9 (
plain)
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
|
#!/bin/bash
# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
# Copyright (C) 2019-2020 Jean-Baptiste Biernacki <j.biernacki@free.fr>
#
# 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
# (at your option) 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#RPI partitionning :
DEFAULT=""
NEW_PART=n
PRIMARY=p
CHANGE_TYPE=t
CHANGE_BOOTFLAG=a
APPLY=w
PART_BOOT=1
PART_BOOT_FIRST_SECTOR=${DEFAULT}
PART_BOOT_SIZE="+128M"
PART_ROOT=2
PART_ROOT_FIRST_SECTOR=${DEFAULT}
PART_ROOT_SIZE=${DEFAULT}
TYPE_FAT32LBA=c
FDISK_SCRIPT="${NEW_PART}\n${PRIMARY}\n${PART_BOOT}\n${PART_BOOT_FIRST_SECTOR}\n${PART_BOOT_SIZE}\n${CHANGE_TYPE}\n${TYPE_FAT32LBA}\n${NEW_PART}\n${PRIMARY}\n${PART_ROOT}\n${PART_ROOT_FIRST_SECTOR}\n${PART_ROOT_SIZE}\n${CHANGE_BOOTFLAG}\n${PART_BOOT}\n${CHANGE_BOOTFLAG}\n${PART_ROOT}\n${APPLY}\n"
function preImgCreation()
{
title "Download binary blob for Rpi"
for i in ${FIRMWARE_DOWNLOAD_URL}; do
info "Download ${i}"
curl -L -O -J ${i} -s
done
# if ! [ -d "${FIRMWARE_PATH}/${FIRMWARE_DIR}" ]; then # the firmware directory does not exists
# echo "$(ls *.zip| wc -l)"
# if [ "$(ls *.zip| wc -l)" -eq 0 ]; then # the firmware archive does not exists
# warning "The raspberry pi firmware need to be downloaded"
# info "Downloading FIRMWARE_FILENAME"
# wget ${FIRMWARE_DOWNLOAD_URL}
# # curl -L -O -J ${FIRMWARE_DOWNLOAD_URL}
# # curl -L ${FIRMWARE_DOWNLOAD_URL} -o firmware-stable.zip
# if [ ${?} -ne 0 ]; then
# error "line ${LINENO} error downloading raspberry firmware at ${FIRMWARE_DOWNLOAD_URL}: exiting"
# exit 1
# fi
# fi
# info "extracting firmware"
# unzip -d "${FIRMWARE_PATH}" *.zip
# if [ ${?} -ne 0 ]; then
# error "line ${LINENO} error unzipping ${FIRMWARE_PATH} : exiting"
# exit 1
# fi
# fi
title "Creating Pi image"
title "Making raspberry pi image"
return 0
}
function postPrepareChroot()
{
#Nothing to do. (Except replacing default function.)
return 0
}
function bunrningBootloader()
{
#Nothing to do. (Except replacing default function.)
return 0
}
function copyingCustomSystem()
{
info "copying 10-vchiq-permissions.rules"
cp --preserve=mode "${CONFIG_PATH}/10-vchiq-permissions.rules" "${BUILD_PATH}/etc/udev/rules.d/"
info "Making /etc/modules"
echo -e "vchiq\nsnd_bcm2835\nvc4\nbrcmfmac" >> "${BUILD_PATH}"/etc/modules
ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
if ! [ -d "${ARM_BOOT}" ]; then
mkdir -p "${ARM_BOOT}"
fi
info "copying modprobe.conf"
/usr/bin/cp -v --preserve=mode "${CONFIG_PATH}/modprobe.conf" "${BUILD_PATH}/etc/"
chown root:root "${BUILD_PATH}/etc/modprobe.conf"
info "copying firmware, overlays in rpi boot partition"
# cp -v --preserve=mode "${BUILD_PATH}/usr/lib/linux-"* "${BOOT}/dtb"
cp -v --preserve=mode "${FIRMWARE_PATH}/${FIRMWARE_DIR}/boot/start"* "${ARM_BOOT}/"
cp -v --preserve=mode "${FIRMWARE_PATH}/${FIRMWARE_DIR}/boot/fixup"* "${ARM_BOOT}/"
cp -v --preserve=mode "${FIRMWARE_PATH}/${FIRMWARE_DIR}/boot/bootcode.bin"* "${ARM_BOOT}/"
cp -vR --preserve=mode "${FIRMWARE_PATH}/${FIRMWARE_DIR}/boot/overlays" "${ARM_BOOT}/"
info "copying u-boot binary to ${ARM_BOOT}"
case ${TARGET_VERSION} in
"0")
info "copying u-boot for ${TARGET} 0"
cp --preserve=mode "${BUILD_PATH}/usr/lib/u-boot/rpi_0_w/u-boot.bin" "${ARM_BOOT}/kernel.img"
;;
"1")
info "copying u-boot for ${TARGET} 1"
cp --preserve=mode "${BUILD_PATH}/usr/lib/u-boot/rpi/u-boot.bin" "${ARM_BOOT}/kernel.img"
;;
"2")
info "copying u-boot for ${TARGET} 2"
cp --preserve=mode "${BUILD_PATH}/usr/lib/u-boot/rpi_2/u-boot.bin" "${ARM_BOOT}/kernel.img"
;;
"3_32")
info "copying u-boot for ${TARGET} 3 32 bits"
cp --preserve=mode "${BUILD_PATH}/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "${ARM_BOOT}/kernel.img"
;;
"3+")
info "copying u-boot for ${TARGET} 3b+ 32 bits"
cp --preserve=mode "${BUILD_PATH}/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "${ARM_BOOT}/kernel.img"
;;
esac
# info "copying raspberry optionals files in opt"
# /bin/rsync -rlptDH "${FIRMWARE_PATH}/${FIRMWARE_DIR}/opt/" "${BUILD_PATH}/opt/"
info "copying wifi firmware file missing in kernel-firmware-nonfree"
if ! [ -d "${ROOT}/usr/lib/firmware/brcm/" ]; then
/bin/mkdir -p "${ROOT}/usr/lib/firmware/brcm/"
fi
if ! [[ -f "${ROOT}/usr/lib/firmware/brcm/brcmfmac434"* ]]; then
/bin/cp --preserve=mode "${CONFIG_PATH}/brcmfmac434"* "${ROOT}/usr/lib/firmware/brcm/"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error copying wifi firmware in ${ROOTP}/usr/lib/firmware/brcm/ : exiting"
exit ${ERR_1}
fi
fi
info "copying Mageia image to root partition"
/bin/rsync -rlptogDHx --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
/bin/rsync -rlptogDHx "${ARM_BOOT}/" "${BOOT}/"
return 0
}
|