Drag and drop files from PC to the card

Prerequisite

  • a raspberry pi zero W(wifi) with a sdcard in it
  • Kernel v2020.4
  • Shell v2020.4
  • a micro usb cable

Install raspian on rasbperry pi

Install the last raspbian version on sdcard for the raspberry pi zero

After this step, you can now plug usb cable on USB twilighte board port and insert the mini usb connector into “usb” port on raspberry pi zero

Enable the USB driver

Next, we need to enable the USB driver which provides the gadget modes, by editing two configuration files on raspberry pi

sudo nano /boot/config.txt

Scroll to the bottom and append the line below:

dtoverlay=dwc2

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.

sudo nano /etc/modules

Append the line below, just after the i2c-dev line:

dwc2

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.
Now shut down the Pi Zero W with the command:

sudo halt

sudo dd bs=1M if=/dev/zero of=/orixusb.bin conv=notrunc,fdatasync oflag=nocache count=2048

We now need to format the file as a FAT32 file system so that the Twilighte board can understand it. Enter the command below:

sudo mkdosfs /orixusb.bin -F 32 -I

Mount the container file

Now let’s mount the container file locally so we can download some test files. First, create a folder on which we can mount the file system:

modprobe g_mass_storage file=/orixusb.bin stall=0 ro=1

sudo mkdir /mnt/usb_share

Now let’s add this to fstab, the configuration file that records our available disk partitions:

sudo nano /etc/fstab

Append the line below to the end of the file:

/orixusb.bin /mnt/usb_share vfat users,umask=000 0 2

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.
The line we added to fstab allows the USB file system to be error-checked and mounted automatically at boot time. Instead of rebooting, we can manually reload fstab with the command below:

sudo mount -a

The TV should provide a file browsing interface. Locate the Big Buck Bunny file and hit Play.

Once you’re satisfied that all is well, try a dismount:

sudo modprobe -r g_mass_storage

At this step, on Orix, you can type :

/#debug

If it displays that you have mount usb device it’s OK

Install and configure Samba to share file between Oric and pc

The next step is to provide network access to the /mnt/usb_share folder that we created earlier.

sudo apt-get update
sudo apt-get install samba winbind -y

When the installation is complete, we need to configure a Samba network share. For simplicity, this will not require a user name or password, as it is already protected by your wireless network security. If you want more security, see wiki.samba.org.

sudo nano /etc/samba/smb.conf

Scroll down to the end of the file and append the lines below:

[usb]
browseable = yes
path = /mnt/usb_share
guest ok = yes
read only = no
create mask = 777

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.
Now restart the Samba service for the changes to take effect:

sudo systemctl restart smbd.service

Now create a file named : updateOric2pi.sh under the raspberry pi because usb gadget on raspberry pi use mainly kernel linux file cache to manage file modification.

We have to flush file cache on linux very quickly.

in updateOric2pi.sh, the content is :

#! /bin/bash
while true
do
echo 3 > /proc/sys/vm/drop_caches
sleep 1
done

Now add execution flag to the script :

# chmod +x updateOric2pi.sh

Add it to /etc/rc.local file like this :

/root/bin/updateOric2pi.sh &

Now when pi will start with the flush cache script.

Access the share from another computer

Now we can try to access the share from a Windows PC or a Mac. You’ll need the host name the Raspberry Pi is using. To check this, enter the command below

Issues

  • Files dropped on the oric or dropped from PC, does not work (check if /root/bin/updateOric2pi.sh is running on raspberry pi
  • ls does not work : you need to wait that raspberry pi zero has started. If that not the case, you will have strange behavior.
  • Usb drive doest not work : check you cable, and your cable must be connected to usb port on raspberry pi (not power port)
  • How can i check if pi is still booting : type debug into orix, if the command return to ch376 controler #51 instead of #AA
  • Pi boot only one time. If you press reset button on twilighte board, pi does no reset. It’s still working.