USB stick update application

From Idrive
Jump to navigation Jump to search

USB stick update documentation

UPDATE: Running custom script

UPDATE 2: USB Recovery tool


The update tool is composed of the following files:

1. 01-usb-stick.rules should pe copied to /etc/udev/rules.d/. It is used as a configuration file for udev. Because it starts with “01” it will have the highest priority in the udev list, meaning that it will be interpreted first by udev. It specifies the conditions that will trigger the execution of the script.

The “RUN” parameter of the ADD rule can be modified in order to reflect the required mount folder (second parameter given to the script), destination folder (third parameter given to the script, obsolete now because destination folder is determined in the update program by the file extensions, but should still be there) and the required extensions of files that need to be copied as the next parameters (e.g. “.cfg”, “.txt” etc.). The “%N” parameter should always be first and untouched because it gives the script the absolute path of the partition that will be mounted.

2. update.sh should be copied to /lib/udev/. It must have execution rights. It is executed when an usb stick is added. The script handles the creation of the mount folder and mounts the usb stick. It checks if the inserted usb stick has update files. If it does, the script will create the destination folder if it does not exist, will create an update.flag file on root and will execute the update program. The stick is unmounted at the end. The “x2idr.fw” string can be modified to the real name of the idrive application and will be passed to the program.

3. update should be copied to /lib/udev/. It must have execution rights. It starts by killing the “x2idr.fw” process and then makes a list of all files on the root of USB stick that have one of the given extensions and copies them to their respective paths (/root/lib for .so, /root/modules for .ko and /root for others) with .new extension. After that, the existing files on the board with the same name as the original files from the stick will be backed up to .old extension. The last step involves renaming the .new files to their respective extensions. The green LEDs will blink while copying the files and 10 s after that at 5 Hz and for 10 seconds after at 1 Hz.

4. reboot.sh should be copied to /lib/udev/. It must have execution rights. The script will be activated on stick removal. It will execute only if an update was done because the udev rule will check the existence of the update.flag file. The script will remove the flag and will reboot the system.

IMPORTANT: While the update tool was tested, we found out that it will not work with a NTFS formated stick. The stick should be formated as FAT32 or ext3. Other file systems might or might not work.

UPDATE: The update.sh tool was modified in order to run a custom script from the usb stick. The custom script should be named idrive_custom_script.sh and should be placed on the root of the usb stick. This modification WILL OVERRIDE the update and reboot behavior, meaning that if the custom script is found on the usb stick it will be executed and the stick will be unmounted after a 1 second sleep. A test script is provided in script folder.

NOTE: Every echo command in the idrive_custom_script.sh file will be redirected to the update_stick_log.txt file on the USB stick. The correct way to reboot the stick in this case is to add the following command at the end of your script:

touch /root//update.flag

UPDATE 2: The provided idrive_custom_script.sh is now a USB Recovery tool. The contents of the device_recovery_files folder and the script should be copied to the USB stick. The config.txt file can be edited and copied on the USB stick with the following content, each on a separate line:

1. Serial number of the device

2. IP address of the device

3. Netmask of the device

The script will copy each of the files to their respective path on the device if they are not already there, except for config.txt. If this file is found on the USB Stick, the ip.cfg and mac.cfg files will be generated with the correct information if they are not present on the device. The old files will be deleted if they already existed on the device. If config.txt is not found on the USB stick, the ip.cfg and mac.cfg files from the device will be left untouched.