# Skip the MBR partition table, back up the OneCloud U-Boot contents and compressgzip-dcBoot_SkipUSBBurning.gz|ddof=/dev/mmcblk1bs=512seek=1count=32767# Restore the backed-up U-Boot contentsddif=/dev/mmcblk1bs=512skip=1count=32767|gzip>Boot_SkipUSBBurning.gz
OneCloud GPIO Driver
Starting from Linux 4.8, using the sysfs interface (/sys/class/gpio) to operate GPIO is no longer recommended. Instead, use character devices from user space. The libgpiod library provides an API for GPIO character devices as well as a set of handy tools for debugging. libgpiod includes commands such as gpioget, gpioset, gpiodetect, gpioinfo, gpiofind, and gpiomon.
Below are examples of controlling OneCloud GPIO using both the sysfs interface and libgpiod commands.
# Set a background imagefbitext.png-T1-d/dev/fb0
# Clear ttyecho-e"\033c">/dev/tty1
# Hide cursorecho-e"\033[?25l">/dev/tty1
# Output capture to the HDMI displayustreamer-dump--sink=kvmd::ustreamer::jpeg--output-|ffmpeg-use_wallclock_as_timestamps1-ipipe:c:v-an-pix_fmtbgr24-ffbdev/dev/fb0
importsysimporthidVENDOR_ID=0x5131PRODUCT_ID=0x2007deffind_usbrelay():fordeviceinhid.enumerate():ifdevice.get("vendor_id")==VENDOR_IDanddevice.get("product_id")==PRODUCT_ID:returndevicereturnNonedefsend_command(device_info,channel,onoff):device=hid.device()device.open(device_info['vendor_id'],device_info['product_id'])ifdeviceisNone:print("Failed to open device.")returntry:cmd=[0xA0,channel,onoff,0xA0+channel+onoff]device.write(bytearray(cmd))finally:device.close()defmain():iflen(sys.argv)!=3:print("Usage:\n""\tpython script.py id on|off")returntry:id=int(sys.argv[1])ifsys.argv[2].lower()=='on':onoff=1elifsys.argv[2].lower()=='off':onoff=0else:raiseValueErrorexceptValueError:print("Invalid command, use 'on' or 'off'")returndevice_info=find_usbrelay()ifdevice_infoisNone:print("USB relay not found")else:send_command(device_info,id,onoff)print(f"Sent command to channel {id}: {'ON'ifonoffelse'OFF'}")if__name__=="__main__":main()