USB
Luckfox Pico Ultra and Luckfox Pico Ultra W have both added a USB-A port for convenient connection to USB peripherals. However, it is important to note that USB-A and USB-C cannot be used simultaneously. By using a switch chip to selectively connect the USB Type-C or USB Type-A port, signal conflicts and power management issues can be effectively avoided, ensuring system stability and reliability.
- When the
USB-C
port is powered, theUSB
connection will switch to theUSB-C
port. - When the
USB-C
port is not powered, theUSB
connection will switch back to theUSB-A
port (mainly used in conjunction with thePOE
module or an external power module).
HOST Mode
Use luckfox-config
to enable the relevant configuration:
- Use the ↑ and ↓ keys on the keyboard to select menu items, the Enter key to enter, the ← and → keys or Tab to select the OK and Cancel buttons, the Esc key to cancel and return, and the spacebar to select an option. Any changes will take effect after rebooting. Note: ADB login cannot use the Arrow keys and Tab, only numbers can be used to select options, and Enter to confirm.
Open the
luckfox-config
tool in the terminal:luckfox-config
Select
Advanced Options
:Select
USB
:Select
host
mode:After pressing Enter to confirm, press
Esc
to exit:Reboot the development board.
reboot
Mounting a USB Flash Drive
Power on the device and check the current USB mode; it should return "host."
cat /sys/devices/platform/ff3e0000.usb2-phy/otg_mode
Insert a USB flash drive or card reader, and it should be displayed as follows:
[ 143.364405] usb 1-1.4: new high-speed USB device number 3 using xhci-hcd
[ 143.513956] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[ 143.517513] usb-storage 1-1.4:1.0: Quirks match for vid 05e3 pid 0749: 520
[ 143.519454] scsi host1: usb-storage 1-1.4:1.0
[ 144.536147] scsi 1:0:0:0: Direct-Access Generic MassStorageClass 1536 PQ: 0 ANSI: 6
[ 144.770829] sd 1:0:0:0: [sdb] 30949376 512-byte logical blocks: (15.8 GB/14.8 GiB)
[ 144.771907] sd 1:0:0:0: [sdb] Write Protect is off
[ 144.772903] sd 1:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 144.780888] sdb: sdb1
[ 144.785345] sd 1:0:0:0: [sdb] Attached SCSI removable diskkAccording to the prompt, the new device is sdb; check the sda file under dev.
# ls /dev/sd*
/dev/sdb1 /dev/sdb /dev/sdaMount sdb1 to the /mnt/sdcard folder.
mount -t vfat /dev/sdb1 /mnt/sdcard/
Check the files in the sdcard folder.
ls /mnt/sdcard/
USB Camera
There are various types of USB cameras, and it's not feasible to comprehensively test all models. In this section, we'll use two cameras, OV5640 5MP USB Camera (B) and IMX179 8MP USB Camera (A) , from Waveshare as examples.
Before starting the test, make sure that USB is set to host mode. To avoid power issues, it's recommended to use a USB HUB with power supply functionality.
Taking Photos
- After inserting the USB camera, check if the device is recognized using the following command:
Capture a photo with the USB camera and save it with a specified filename:
# fswebcam -d /dev/video0 -r 1920x1080 /root/image01.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Unable to load font 'sans': Could not find/open font
Disabling the the banner.
Writing JPEG image to '/root/image01.jpg'.-d /dev/video0
: Specifies the device to use.-r 1920x1080
: Specifies the resolution of the captured photo./root/image01.jpg
: Specifies the path and name of the output file.
Recording video
The current video recording is based on the Luckfox-Pico-Max development board. Due to the limited memory of Luckfox-Pico series development boards, high-resolution recording is not supported.
ffmpeg -f v4l2 -video_size 320x240 -framerate 30 -i /dev/video21 output.mp4
If you want to adjust the video resolution, you can use the
scale
filter to resize the input video frame size to a width of 640 pixels and a height of 480 pixels.ffmpeg -f v4l2 -i /dev/video21 -vf "scale=640:480" output1.mp4
Video effect: