2021-03-07 16:25:34 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-07-30 18:45:55 -07:00
|
|
|
# from firmware folder:
|
|
|
|
# hw_layer/mass_storage/create_ini_image_compressed.sh tunerstudio/generated/rusefi.ini hw_layer/mass_storage/ramdisk_image.h 1024 test https://rusefi.com/s/test
|
|
|
|
|
2021-03-07 16:25:34 -08:00
|
|
|
# fail on error
|
|
|
|
set -e
|
2021-07-30 13:23:01 -07:00
|
|
|
|
2021-07-30 13:07:22 -07:00
|
|
|
FULL_INI=$1
|
|
|
|
H_OUTPUT=$2
|
|
|
|
FS_SIZE=$3
|
|
|
|
SHORT_BOARDNAME=$4
|
2021-07-30 18:17:10 -07:00
|
|
|
BOARD_SPECIFIC_URL=$5
|
2021-03-07 16:25:34 -08:00
|
|
|
|
2021-11-04 13:06:44 -07:00
|
|
|
IMAGE=ramdisk.image
|
2021-07-30 13:23:01 -07:00
|
|
|
|
2021-11-04 13:06:44 -07:00
|
|
|
echo "create_ini_image_compressed: ini $FULL_INI to $H_OUTPUT size $FS_SIZE for $SHORT_BOARDNAME [$BOARD_SPECIFIC_URL]"
|
|
|
|
|
|
|
|
rm -f $IMAGE $IMAGE.gz
|
2021-03-07 16:25:34 -08:00
|
|
|
|
2021-07-30 13:07:22 -07:00
|
|
|
# copy *count*KB of zeroes
|
2022-04-17 19:48:48 -07:00
|
|
|
dd if=/dev/zero of=$IMAGE bs=1152 count=$FS_SIZE
|
2021-03-07 16:25:34 -08:00
|
|
|
|
|
|
|
# create a FAT filesystem inside, name it RUSEFI
|
2021-11-04 13:06:44 -07:00
|
|
|
mkfs.fat $IMAGE
|
2021-07-30 13:23:01 -07:00
|
|
|
# labels can be no longer than 11 characters
|
2021-11-04 13:06:44 -07:00
|
|
|
fatlabel $IMAGE RUSEFI
|
2021-03-07 16:25:34 -08:00
|
|
|
|
2021-07-30 13:07:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-30 18:45:55 -07:00
|
|
|
cp hw_layer/mass_storage/filesystem_contents/rusEFI_Wiki_template.url hw_layer/mass_storage/wiki.temp
|
2021-07-30 19:23:52 -07:00
|
|
|
echo "URL=${BOARD_SPECIFIC_URL}" >> hw_layer/mass_storage/wiki.temp
|
|
|
|
cp hw_layer/mass_storage/filesystem_contents/README.nozip.template.txt hw_layer/mass_storage/readme.temp
|
|
|
|
echo ${BOARD_SPECIFIC_URL} >> hw_layer/mass_storage/readme.temp
|
2021-07-30 18:17:10 -07:00
|
|
|
|
2021-03-07 16:25:34 -08:00
|
|
|
# Put the zip inside the filesystem
|
2021-11-04 13:06:44 -07:00
|
|
|
mcopy -i $IMAGE $FULL_INI ::
|
2021-03-07 16:25:34 -08:00
|
|
|
# Put a readme text file in there too
|
2021-11-04 13:06:44 -07:00
|
|
|
mcopy -i $IMAGE hw_layer/mass_storage/readme.temp ::README.txt
|
|
|
|
mcopy -i $IMAGE hw_layer/mass_storage/filesystem_contents/rusEFI\ Forum.url ::
|
|
|
|
mcopy -i $IMAGE hw_layer/mass_storage/filesystem_contents/rusEFI\ Quick\ Start.url ::
|
|
|
|
mcopy -i $IMAGE hw_layer/mass_storage/wiki.temp ::rusEFI\ ${SHORT_BOARDNAME}\ Wiki.url
|
2021-03-07 16:25:34 -08:00
|
|
|
|
|
|
|
# Compress the image as DEFLATE with gzip
|
2021-11-04 13:06:44 -07:00
|
|
|
gzip $IMAGE
|
2021-03-07 16:25:34 -08:00
|
|
|
|
|
|
|
# write out as a C array, with "static const" tacked on the front
|
2021-11-04 13:06:44 -07:00
|
|
|
xxd -i $IMAGE.gz \
|
2021-03-07 16:25:34 -08:00
|
|
|
| cat <(echo -n "static const ") - \
|
2021-07-30 13:07:22 -07:00
|
|
|
> $H_OUTPUT
|
2021-03-07 16:25:34 -08:00
|
|
|
|
2021-11-04 13:06:44 -07:00
|
|
|
rm $IMAGE.gz
|