Based on tjmnmk gadget_cdrom
- Banana Pi M2 Zero
- Waveshare 1.3inch OLED HAT
- Tested on Armbian jammy current (5.15.77)
- gadget_cdrom converts your Banana Pi M2 Zero to virtual usb cdrom.
- Original tjmnmk Youtube video
You can switch between HDD mode, virtual cdrom mode, and virtual flash drive mode.
Mode | Description | Button |
---|---|---|
CD Mode |
the BPI will pretend to be a cdrom and presenting the .iso you selected |
Key3 |
USB Mode |
the BPI will pretend to be a flash drive, presenting the usb .img you selected. |
Key3 |
HDD Mode |
in that mode your Banana Pi M2 Zero is basically USB flash drive connected to your computer. You can store any files and upload .iso and .img files to use in CD and USB Modes |
Key3 |
Shutdown |
Halt/Shutdown PBI | Joystick Left |
Init |
State that you'll see during internal storage initialization process after first boot | - |
Key1
- Activate selected imageKey2
- Deactivate imageKey3
- Change modeJoystick Down
- next image (only in CD/USB modes)Joystick Up
- previous image (only in CD/USB modes)Joystick Left
- shutdown
In HDD Mode with MicroSDXC Kingston CANVAS Select Plus 1st class V10 A1 64GB
as main storage, my file transfer speed is around 7-8MB/s for read and write.
Ready to use Armbian + gadget_cdrom image
There are customized Armbian images with gadget_cdrom and kernel patch for big isos in the releases section, just write it to sd-card (you can use rpi-imager, dd, etc.), turn BPI on and wait a few minutes (5-7) to get everything ready. Latest prebuild images uses exFAT as defaut HDD Mode partition iso.img
.
-
chekout current
armbian-build
repogit clone https://github.com/armbian/build.git
-
chekout current
gadget_cdrom_bpi_m2_zero
repogit clone -b banana_pi_m2_zero https://github.com/rzrbld/gadget_cdrom_bpi_m2_zero.git
-
copy
userpatches
formgadget_cdrom_bpi_m2_zero
directory to armbianbuild
foldercp -r /git/gadget_cdrom_bpi_m2_zero/armbian/banapi_m2_zero/userpatches/* /git/build/userpatches/
-
compile image
cd /git/build/ && ./compile.sh BOARD=bananapim2zero BRANCH=current RELEASE=jammy BUILD_MINIMAL=yes BUILD_DESKTOP=no KERNEL_ONLY=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,gz
in case of error with debian repos - add this parametersDEBIAN_MIRROR='%my_favorite_mirror%' NO_APT_CACHER=yes
list of Debian mirrors i.e.cd /git/build/ && ./compile.sh BOARD=bananapim2zero BRANCH=current RELEASE=jammy BUILD_MINIMAL=yes BUILD_DESKTOP=no KERNEL_ONLY=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,gz DEBIAN_MIRROR='ftp.ru.debian.org/debian/' NO_APT_CACHER=yes
banapi_m2_zero
└── userpatches
├── customize-image.sh #pre install gadget cdrom
├── kernel #patch for support isos bigger than ~2.5GB (Optional)
├── linux-sunxi-current.config #default linux kernel config (ensure that SPIDEV & Mass Storage is set to <m>/<y>)
└── README.md #compile parameters
apt update -y -q && \
apt install -y -q sed \
git \
vim p7zip-full \
armbian-config \
python3-smbus \
python3-numpy \
python3-pil \
fonts-dejavu \
ntfs-3g \
exfat-fuse \
exfatprogs \
python3-dev \
python3-pip \
zip \
unzip \
dosfstools
#make a file for wiringPi
mkdir /var/lib/bananapi/ && touch /var/lib/bananapi/board.sh
echo "BOARD=bpi-m2z" >> /var/lib/bananapi/board.sh
echo "BOARD_AUTO=bpi-m2z" >> /var/lib/bananapi/board.sh
mkdir -p /opt/BPI-WiringPi2 && git clone https://github.com/bontango/BPI-WiringPi2.git /opt/BPI-WiringPi2/
mkdir -p /opt/RPi.GPIO && git clone https://github.com/GrazerComputerClub/RPi.GPIO.git /opt/RPi.GPIO
mkdir -p /opt/gadget_cdrom && git clone --branch banana_pi_m2_zero https://github.com/rzrbld/gadget_cdrom_bpi_m2_zero.git /opt/gadget_cdrom
#install pip deps
pip3 install wheel && pip3 install spidev
Build patched WiringPi for BPI
cd /opt/BPI-WiringPi2/ && ./build
Build PRi.GPIO for BPI
cd /opt/RPi.GPIO/ && CFLAGS="-fcommon" python3 setup.py install
echo "overlays=spi-spidev" >> /boot/armbianEnv.txt
echo "param_spidev_spi_bus=0" >> /boot/armbianEnv.txt
sed -i '/g_serial/d' /etc/modules
sed -i '/g_ether/d' /etc/modules
# sudo ./create_image.sh
Space available: 24G
Size, e.g. 16G? 8G"
Creating 8G image...
Done!
reboot
gpio readall #shows pinout table
ls -al /dev/spi* #shows spi device
ln -s /opt/gadget_cdrom/gadget_cdrom.service /etc/systemd/system/gadget_cdrom.service && \
systemctl enable gadget_cdrom.service
systemctl start gadget_cdrom.service
Recompile kernel for support isos bigger than ~2.5GB
- Apply this patch
- Build kernel: Armbian Linux Build Framework