forked from Archive/PX4-Autopilot
Merge pull request #3242 from PX4/master_uavcan_travis
Move uavcan bin files to ROMFS based on naming convention
This commit is contained in:
commit
0b14266eff
|
@ -102,9 +102,8 @@ script:
|
|||
- echo 'Building UAVCAN node firmware..' && git clone https://github.com/thiemar/vectorcontrol
|
||||
- cd vectorcontrol
|
||||
- BOARD=s2740vc_1_0 make && BOARD=px4esc_1_6 make
|
||||
- ../Tools/uavcan_copy.sh
|
||||
- cd ..
|
||||
- mkdir -p ROMFS/px4fmu_common/uavcan/fw/com.thiemar.s2740vc-v1/1.0/
|
||||
- mkdir -p ROMFS/px4fmu_common/uavcan/fw/org.pixhawk.px4esc-v1/1.0/
|
||||
- echo 'Building NuttX px4fmu-v1 Firmware..' && make px4fmu-v1_default
|
||||
- echo 'Building NuttX px4fmu-v2 Firmware..' && make px4fmu-v2_default
|
||||
- echo 'Building NuttX px4fmu-v4 Firmware..' && make px4fmu-v4_default
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
UAVCANFW=../ROMFS/px4fmu_common/uavcan/fw
|
||||
ROMFS_REFIX=_
|
||||
echo Removing : $UAVCANFW
|
||||
rm -fr $UAVCANFW
|
||||
for f in $(find firmware -type f -name "*.*.bin")
|
||||
do
|
||||
UAVCAN_NAME=$(echo $f | cut -d"/" -f2 | cut -d. -f1-4 | cut -d- -f1-2)
|
||||
UAVCAN_HW=$(echo $f cut -d/ -f2 | cut -d. -f1-4 | cut -d- -f3)
|
||||
DST=${ROMFS_REFIX}$(echo $f | cut -d. -f3-7 | cut -d- -f1,2,3).$(echo $f | cut -d. -f6,7)
|
||||
# deal with legacy non conforming naming
|
||||
if [[ ${DST:(-7)} == bin.bin ]]
|
||||
then
|
||||
echo " WARNING: Improper name format!!!!!!!!! $f see should be <uavcan_name>-<HW_MAJOR>.<HW_MINOR)-<HW_MAJOR>.<HW_MINOR).<git hash[8]>.bin"
|
||||
DST=${DST%????}
|
||||
fi
|
||||
echo Processing file: $f Length:${#DST}
|
||||
if [ ${#DST} -le 28 ]
|
||||
then
|
||||
if [ -d "${UAVCANFW}/${UAVCAN_NAME}/${UAVCAN_HW}" ]
|
||||
then
|
||||
echo " ERROR: name colision directory ${UAVCANFW}/${UAVCAN_NAME}/${UAVCAN_HW} exits!"
|
||||
exit 2
|
||||
fi
|
||||
echo " Creating Directory ${UAVCANFW}/${UAVCAN_NAME}/${UAVCAN_HW}"
|
||||
mkdir -p ${UAVCANFW}/${UAVCAN_NAME}/${UAVCAN_HW}
|
||||
echo " Copying $f to ${UAVCANFW}/${UAVCAN_NAME}/${UAVCAN_HW}/${DST}"
|
||||
cp $f ${UAVCANFW}/${UAVCAN_NAME}/${UAVCAN_HW}/${DST}
|
||||
else
|
||||
echo " ERROR: $DST is ${#DST} charaters and needs to be less than or equal to 28"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
exit 0
|
|
@ -886,16 +886,19 @@ void UavcanServers::unpackFwFromROMFS(const char* sd_path, const char* romfs_pat
|
|||
|
||||
/fs/microsd/fw
|
||||
- /c
|
||||
- - /1a2b3c4d.bin cache file (copy of /fs/microsd/fw/org.pixhawk.nodename-v1/1.1/1a2b3c4d.bin)
|
||||
- /org.pixhawk.nodename-v1 device directory for org.pixhawk.nodename-v1
|
||||
- - /1.0 version directory for hardware 1.0
|
||||
- - /1.1 version directory for hardware 1.1
|
||||
- - - /1a2b3c4d.bin firmware file for org.pixhawk.nodename-v1 nodes, hardware version 1.1
|
||||
- /com.example.othernode-v3 device directory for com.example.othernode-v3
|
||||
- - /1.0 version directory for hardawre 1.0
|
||||
- - - /deadbeef.bin firmware file for com.example.othernode-v3, hardware version 1.0
|
||||
- /nodename-v1-1.0.25d0137d.bin cache file (copy of /fs/microsd/fw/org.pixhawk.nodename-v1/1.1/nodename-v1-1.0.25d0137d.bin)
|
||||
- /othernode-v3-1.6.25d0137d.bin cache file (copy of /fs/microsd/fw/com.example.othernode-v3/1.6/othernode-v3-1.6.25d0137d.bin)
|
||||
- /org.pixhawk.nodename-v1 device directory for org.pixhawk.nodename-v1
|
||||
- - /1.0 version directory for hardware 1.0
|
||||
- - /1.1 version directory for hardware 1.1
|
||||
- - - /nodename-v1-1.0.25d0137d.bin firmware file for org.pixhawk.nodename-v1 nodes, hardware version 1.1
|
||||
- /com.example.othernode-v3 device directory for com.example.othernode-v3
|
||||
- - /1.0 version directory for hardawre 1.0
|
||||
- - - /othernode-v3-1.6.25d0137d.bin firmware file for com.example.othernode-v3, hardware version 1.6
|
||||
|
||||
The ROMFS directory structure is the same, but located at /etc/uavcan/fw
|
||||
Files located there are prefixed with _ to identify them a comming from the rom
|
||||
file system.
|
||||
|
||||
We iterate over all device directories in the ROMFS base directory, and create
|
||||
corresponding device directories on the SD card if they don't already exist.
|
||||
|
@ -903,9 +906,12 @@ void UavcanServers::unpackFwFromROMFS(const char* sd_path, const char* romfs_pat
|
|||
In each device directory, we iterate over each version directory and create a
|
||||
corresponding version directory on the SD card if it doesn't already exist.
|
||||
|
||||
In each version directory, we remove any files with a name starting with "romfs_"
|
||||
In each version directory, we remove any files with a name starting with "_"
|
||||
in the corresponding directory on the SD card that don't match the bundled firmware
|
||||
filename; if the directory is empty after that process, we copy the bundled firmware.
|
||||
|
||||
todo:This code would benefit from the use of strcat.
|
||||
|
||||
*/
|
||||
const size_t maxlen = UAVCAN_MAX_PATH_LENGTH;
|
||||
const size_t sd_path_len = strlen(sd_path);
|
||||
|
@ -1037,7 +1043,7 @@ void UavcanServers::unpackFwFromROMFS(const char* sd_path, const char* romfs_pat
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!memcmp(&fw_dirent->d_name[sizeof(UAVCAN_ROMFS_FW_PREFIX) - 1], src_fw_dirent->d_name, fw_len)) {
|
||||
if (!memcmp(&fw_dirent->d_name, src_fw_dirent->d_name, fw_len)) {
|
||||
/*
|
||||
* Exact match between SD card filename and ROMFS filename; must be the same version
|
||||
* so don't bother deleting and rewriting it.
|
||||
|
@ -1045,17 +1051,16 @@ void UavcanServers::unpackFwFromROMFS(const char* sd_path, const char* romfs_pat
|
|||
copy_fw = false;
|
||||
} else if (!memcmp(fw_dirent->d_name, UAVCAN_ROMFS_FW_PREFIX, sizeof(UAVCAN_ROMFS_FW_PREFIX) - 1)) {
|
||||
size_t fw_len = strlen(fw_dirent->d_name);
|
||||
size_t dstpath_fw_len = dstpath_ver_len + sizeof(UAVCAN_ROMFS_FW_PREFIX) + fw_len;
|
||||
size_t dstpath_fw_len = dstpath_ver_len + fw_len;
|
||||
if (dstpath_fw_len > maxlen) {
|
||||
// sizeof(prefix) includes trailing NUL, cancelling out the +1 for the path separator
|
||||
warnx("unlink: path '%s/%s%s' too long", dstpath, UAVCAN_ROMFS_FW_PREFIX, fw_dirent->d_name);
|
||||
warnx("unlink: path '%s/%s' too long", dstpath, fw_dirent->d_name);
|
||||
} else {
|
||||
// File name starts with "romfs_", delete it.
|
||||
// File name starts with "_", delete it.
|
||||
dstpath[dstpath_ver_len] = '/';
|
||||
memcpy(&dstpath[dstpath_ver_len + 1], fw_dirent->d_name, fw_len + 1);
|
||||
unlink(dstpath);
|
||||
|
||||
warnx("unlink: removed '%s/%s%s'", dstpath, UAVCAN_ROMFS_FW_PREFIX, fw_dirent->d_name);
|
||||
warnx("unlink: removed '%s'", dstpath);
|
||||
}
|
||||
} else {
|
||||
// User file, don't copy firmware
|
||||
|
@ -1068,20 +1073,19 @@ void UavcanServers::unpackFwFromROMFS(const char* sd_path, const char* romfs_pat
|
|||
// If we need to, copy the file from ROMFS to the SD card
|
||||
if (copy_fw) {
|
||||
size_t srcpath_fw_len = srcpath_ver_len + 1 + fw_len;
|
||||
size_t dstpath_fw_len = dstpath_ver_len + sizeof(UAVCAN_ROMFS_FW_PREFIX) + fw_len;
|
||||
size_t dstpath_fw_len = dstpath_ver_len + fw_len;
|
||||
|
||||
if (srcpath_fw_len > maxlen) {
|
||||
warnx("copy: srcpath '%s/%s' too long", srcpath, src_fw_dirent->d_name);
|
||||
} else if (dstpath_fw_len > maxlen) {
|
||||
warnx("copy: dstpath '%s/%s%s' too long", dstpath, UAVCAN_ROMFS_FW_PREFIX, src_fw_dirent->d_name);
|
||||
warnx("copy: dstpath '%s/%s' too long", dstpath, src_fw_dirent->d_name);
|
||||
} else {
|
||||
// All OK, make the paths and copy the file
|
||||
srcpath[srcpath_ver_len] = '/';
|
||||
memcpy(&srcpath[srcpath_ver_len + 1], src_fw_dirent->d_name, fw_len + 1);
|
||||
|
||||
dstpath[dstpath_ver_len] = '/';
|
||||
memcpy(&dstpath[dstpath_ver_len + 1], UAVCAN_ROMFS_FW_PREFIX, sizeof(UAVCAN_ROMFS_FW_PREFIX));
|
||||
memcpy(&dstpath[dstpath_ver_len + sizeof(UAVCAN_ROMFS_FW_PREFIX)], src_fw_dirent->d_name, fw_len + 1);
|
||||
memcpy(&dstpath[dstpath_ver_len +1], src_fw_dirent->d_name, fw_len + 1);
|
||||
|
||||
rv = copyFw(dstpath, srcpath);
|
||||
if (rv != 0) {
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
#define UAVCAN_NODE_DB_PATH "/fs/microsd/uavcan.db"
|
||||
#define UAVCAN_FIRMWARE_PATH "/fs/microsd/fw"
|
||||
#define UAVCAN_ROMFS_FW_PATH "/etc/uavcan/fw"
|
||||
#define UAVCAN_ROMFS_FW_PREFIX "romfs_"
|
||||
#define UAVCAN_ROMFS_FW_PREFIX "_"
|
||||
#define UAVCAN_MAX_PATH_LENGTH (128 + 40)
|
||||
#define UAVCAN_LOG_FILE UAVCAN_NODE_DB_PATH"/trace.log"
|
||||
|
||||
|
|
Loading…
Reference in New Issue