Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tjmnmk committed Feb 23, 2021
2 parents 0d5691e + f9b1ca2 commit df70460
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 3 deletions.
7 changes: 6 additions & 1 deletion create_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ FILE="/iso.img"

if [ -f "$FILE" ]; then
if [ "$auto" -eq 0 ]; then
echo "$FILE already exists"
echo "$FILE already exists" 1>&2
exit 1
fi
exit 0
fi

if [ -f "/etc/init.d/resize2fs_once" ] && [ "$auto" -eq 1 ]; then # this is ugly hack :(
echo "/etc/init.d/resize2fs_once exists" 2>&1
exit 1
fi

size=0
if [ "$auto" -eq 0 ]; then
free="$(df -h / | tail -n1 | awk '{print $4}')"
Expand Down
3 changes: 2 additions & 1 deletion gadget_cdrom.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[Unit]
Description=gadget_cdrom
After=local-fs.target
Before=basic.target
After=local-fs.target sysinit.target
DefaultDependencies=no

[Service]
Type=simple
Expand Down
3 changes: 2 additions & 1 deletion gadget_cdrom_auto_img.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[Unit]
Description=gadget_cdrom
After=local-fs.target
Before=basic.target
After=local-fs.target sysinit.target
DefaultDependencies=no

[Service]
Type=simple
Expand Down
18 changes: 18 additions & 0 deletions tools/kernel/00-remove_iso_limit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This is not a good way how to do it, we should rather emulate dvd for big isos, but it should work for data isos.
diff --git a/drivers/usb/gadget/function/storage_common.c b/drivers/usb/gadget/function/storage_common.c
index f7e6c42558eb..8db8cda0c930 100644
--- a/drivers/usb/gadget/function/storage_common.c
+++ b/drivers/usb/gadget/function/storage_common.c
@@ -243,12 +243,6 @@ int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
min_sectors = 1;
if (curlun->cdrom) {
min_sectors = 300; /* Smallest track is 300 frames */
- if (num_sectors >= 256*60*75) {
- num_sectors = 256*60*75 - 1;
- LINFO(curlun, "file too big: %s\n", filename);
- LINFO(curlun, "using only first %d blocks\n",
- (int) num_sectors);
- }
}
if (num_sectors < min_sectors) {
LINFO(curlun, "file too small: %s\n", filename);
4 changes: 4 additions & 0 deletions tools/pi-gen/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
IMG_NAME=gadget_cdrom
RELEASE=buster
USE_QCOW2=0
STAGE_LIST="stage0 stage1 stage2 stage-gc"
7 changes: 7 additions & 0 deletions tools/pi-gen/pi-gen-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash -eu
#modprobe binfmt_misc
git clone https://github.com/RPi-Distro/pi-gen.git
rsync -av config pi-gen/
rsync -av stage-gc pi-gen/
cd pi-gen
PRESERVE_CONTAINER=1 ./build-docker.sh
1 change: 1 addition & 0 deletions tools/pi-gen/stage-gc/00-gadget_cdrom/00-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python3-numpy python3-pil fonts-dejavu ntfs-3g p7zip-full python3-rpi.gpio python3-smbus python3-spidev
34 changes: 34 additions & 0 deletions tools/pi-gen/stage-gc/00-gadget_cdrom/01-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash -eu

function set_config_txt {
local key="$1"
local value="$2"

if egrep -q "^${key}=" "${ROOTFS_DIR}/boot/config.txt"; then
sed "s/${key}=.*/${key}=${value}/g" -i "${ROOTFS_DIR}/boot/config.txt"
else
echo >> "${ROOTFS_DIR}/boot/config.txt"
echo "${key}=${value}" >> "${ROOTFS_DIR}/boot/config.txt"
fi
}

cd "${ROOTFS_DIR}/opt"
git clone https://github.com/tjmnmk/gadget_cdrom.git

on_chroot << EOF
systemctl enable /opt/gadget_cdrom/gadget_cdrom_auto_img.service
EOF

echo >> "${ROOTFS_DIR}/etc/modules"
echo dwc2 >> "${ROOTFS_DIR}/etc/modules"

vmlinuz_fname=$(dpkg -c /pi-gen/stage-gc/00-gadget_cdrom/files/kernel_packages/linux-image-*_armhf.deb |grep ./boot/vmlinuz |awk -F"/" '{print $NF}')
for i in /pi-gen/stage-gc/00-gadget_cdrom/files/kernel_packages/linux*.deb; do
install -m 644 "$i" "${ROOTFS_DIR}/root/"
done
install -m 755 "/pi-gen/stage-gc/00-gadget_cdrom/files/config.txt" "${ROOTFS_DIR}/boot/"
on_chroot << EOF
dpkg -i /root/linux*.deb
EOF

set_config_txt "kernel" "$vmlinuz_fname"
68 changes: 68 additions & 0 deletions tools/pi-gen/stage-gc/00-gadget_cdrom/files/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=dwc2
#dtoverlay=dwc2

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=dwc2
max_framebuffers=2

[all]
dtoverlay=dwc2

dtparam=spi=on

Empty file.
3 changes: 3 additions & 0 deletions tools/pi-gen/stage-gc/01-sys-tweaks/01-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -e

install -m 755 /pi-gen/stage-gc/01-sys-tweaks/files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/"
13 changes: 13 additions & 0 deletions tools/pi-gen/stage-gc/01-sys-tweaks/files/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2015 Raspberry Pi (Trading) Ltd.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 changes: 27 additions & 0 deletions tools/pi-gen/stage-gc/01-sys-tweaks/files/resize2fs_once
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: 3
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:
### END INIT INFO
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting resize2fs_once"
ROOT_DEV=$(findmnt / -o source -n)
resize2fs $ROOT_DEV
update-rc.d resize2fs_once remove
rm /etc/init.d/resize2fs_once
log_end_msg $?
reboot
;;
*)
echo "Usage: $0 start" >&2
exit 3
;;
esac

1 change: 1 addition & 0 deletions tools/pi-gen/stage-gc/EXPORT_IMAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IMG_SUFFIX="-gc"
5 changes: 5 additions & 0 deletions tools/pi-gen/stage-gc/prerun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

if [ ! -d "${ROOTFS_DIR}" ]; then
copy_previous
fi

0 comments on commit df70460

Please sign in to comment.