Last active
October 11, 2024 19:28
-
-
Save wido/e0883399e8c9146fe873a9483874511a to your computer and use it in GitHub Desktop.
Tesla Model S/X MCU1 eMMC image creator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Create a 8GB eMMC image for Tesla Model S/X MCU1 | |
# | |
# Example usage: ./mkteslaemmcimg.sh ./vinXXXXX.img ./develop-2019.20.2.1-16-5659e07dfd.img | |
# | |
set -e | |
FIRMWARE=$2 | |
IMAGE=$1 | |
SIZE=7818182656 | |
INDEX=$((10 + RANDOM % 100)) | |
LOOP="loop${INDEX}" | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 <image file> <firmware file>" | |
exit 255 | |
fi | |
if [ -e "${IMAGE}" ]; then | |
echo "Error: ${IMAGE} already exists" | |
exit 1 | |
fi | |
if [ ! -f "${FIRMWARE}" ]; then | |
echo "Error: ${FIRMWARE} does not exist" | |
exit 2 | |
fi | |
echo "Info: Writing empty image file=${IMAGE} size=${SIZE}" | |
dd if=/dev/zero of=${IMAGE} bs=1024 count=7634944 | |
echo "Info: Creating partitions on ${IMAGE}" | |
parted -s ${IMAGE} mklabel msdos | |
parted -s ${IMAGE} mkpart primary 4096s 2101247s | |
parted -s ${IMAGE} mkpart primary 2101248s 4198399s | |
parted -s ${IMAGE} mkpart primary 4198400s 4460543s | |
parted -s ${IMAGE} mkpart primary 4460544s 15269887s | |
echo "Info: Setting up loop device ${LOOP}" | |
sudo losetup -P ${LOOP} ${IMAGE} | |
echo "Info: Writing ${FIRMWARE} to partitions 1 and 2" | |
sudo dd if=${FIRMWARE} of=/dev/${LOOP}p1 | |
sudo dd if=${FIRMWARE} of=/dev/${LOOP}p2 | |
echo "Info: Creating empty ext3 filesystem on partitions 3 and 4" | |
sudo mkfs.ext3 /dev/${LOOP}p3 | |
sudo mkfs.ext3 /dev/${LOOP}p4 | |
echo "Info: Cleaning up loop device ${LOOP}" | |
sudo losetup -d /dev/${LOOP} |
Is it possible to edit /vinXXXXX.img and change vin? or its encrypted?
Is it possible to edit /vinXXXXX.img and change vin? or its encrypted?
vinXXXXX.img is the output file. You can name it whatever you like.
What i missing when i write got fw.img does not exist???
./mkteslaemmcimg.sh --vin.img --fw.img
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
They are not freely available. You will need to have your sources on there to get the firmware.