Compare commits
24 Commits
a25418d3d2
...
main
Author | SHA1 | Date | |
---|---|---|---|
057adc4d0f | |||
8c591b1e78 | |||
440b78190e | |||
b09c23f7c7 | |||
626b1e4629 | |||
7183a4cedc | |||
a1e9f6604b | |||
0e0c57820d | |||
49de09c977 | |||
69e6c63312 | |||
8fecd02a38 | |||
be73825923 | |||
b13f698b30 | |||
b1379d19a7 | |||
658351920c | |||
af40a71e00 | |||
14cd7eb3a6 | |||
43ae85b56f | |||
e4e07214c4 | |||
1ae00b40b9 | |||
f1a16c6b33 | |||
b36e7212a3 | |||
3abc6d8804 | |||
4f4811813c |
103
README.md
103
README.md
@ -1,42 +1,89 @@
|
|||||||
# BMW Coding Guides
|
# 🚗 BMW Coding Guides
|
||||||
|
|
||||||
Welcome to the BMW Coding Guides repository! This repository contains a collection of PDF guides designed to help you with various BMW coding tasks, from enabling features to customizing settings in your vehicle.
|
Welcome to the **BMW Coding Guides** repository! This collection provides easy-to-follow guides and tools for customizing and coding your BMW. Whether you’re enabling features or tweaking settings, you’ll find the resources you need right here.
|
||||||
|
|
||||||
## Table of Contents
|
---
|
||||||
|
|
||||||
- [Introduction](#introduction)
|
## 📋 Table of Contents
|
||||||
- [Guides](#guides)
|
|
||||||
- [Tools](#tools)
|
|
||||||
- [License](#license)
|
|
||||||
|
|
||||||
## Introduction
|
- [✨ Introduction](#-introduction)
|
||||||
|
- [📚 Guides](#-guides)
|
||||||
|
- [📄Available Guides](#available-guides)
|
||||||
|
- [🔧 Tools](#-tools)
|
||||||
|
- [🛡️ License](#-license)
|
||||||
|
|
||||||
This repository aims to provide comprehensive and easy-to-follow guides for coding and customizing BMW vehicles. Each guide is available as a PDF document that can be downloaded and used to enable, modify, or enhance different features of your BMW.
|
---
|
||||||
|
|
||||||
## Guides
|
## ✨ Introduction
|
||||||
|
|
||||||
The guides are organized in the `guides` directory. Each PDF file in this directory provides step-by-step instructions for a specific coding task or feature enhancement.
|
This repository aims to provide **comprehensive** and **easy-to-follow** guides for coding and customizing BMW vehicles. Each guide is available as a **PDF document** for download, offering step-by-step instructions to **enable**, **modify**, or **enhance** different features of your BMW.
|
||||||
|
|
||||||
|
Feel free to explore the guides and tools we offer below!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 Guides
|
||||||
|
|
||||||
|
All the guides are located in the `guides` directory, and each PDF provides step-by-step instructions for specific coding tasks or feature enhancements.
|
||||||
|
|
||||||
### Available Guides
|
### Available Guides
|
||||||
|
|
||||||
- [Enabling the Bluetooth Music Option with Combox Module](guides/Enhanced_Bluetooth_Music.pdf)
|
Here are some of the popular guides included in this repository:
|
||||||
- [Hacking NBTEVO ID6 Car Image](https://davidpetric.com/2024/06/21/nbt-evo-id6-hacking-the-car-image/)
|
|
||||||
- [BMW FSC Certificate Extraction Guide](guides/BMW_FSC_Certificate_Extraction_Guide.pdf)
|
|
||||||
- [FSC Code IDs](guides/BMW_FSC_Code_Number_ID.pdf)
|
|
||||||
- [F3x/F2x/F1x Cheat Sheet](guides/F3x_F2x_F1x_Cheat_Sheet.pdf)
|
|
||||||
- [F Series ECUs with Description](guides/BMW_F_Series_ECUs.pdf)
|
|
||||||
- [BMW Navigation Europe East/West Coverage](guides/BMW_Europe_Navi_East_West_Diff.pdf)
|
|
||||||
- [E-SYS Manual](guides/E-Sys_Manual_V23_10_ENG.pdf)
|
|
||||||
- [ENET IP Configuration](guides/BMW_ENET_Static_IP_Setup_Guide.pdf)
|
|
||||||
|
|
||||||
### Available Tools
|
- [🎵 Enabling Bluetooth Music with Combox Module](guides/Enhanced_Bluetooth_Music.pdf)
|
||||||
|
- [🛠️ Hacking NBTEVO ID6 Car Image](https://davidpetric.com/2024/06/21/nbt-evo-id6-hacking-the-car-image/)
|
||||||
|
- [🔑 BMW FSC Certificate Extraction Guide](guides/BMW_FSC_Certificate_Extraction_Guide.pdf)
|
||||||
|
- [🗃️ FSC Code IDs](guides/BMW_FSC_Code_Number_ID.pdf)
|
||||||
|
- [🛡️ F3x/F2x/F1x Cheat Sheet](guides/F3x_F2x_F1x_Cheat_Sheet.pdf)
|
||||||
|
- [🧩 F Series ECUs with Descriptions](guides/BMW_F_Series_ECUs.pdf)
|
||||||
|
- [🗺️ BMW Navigation Europe East/West Coverage](guides/BMW_Europe_Navi_East_West_Diff.pdf)
|
||||||
|
- [📖 E-SYS Manual](guides/E-Sys_Manual_V23_10_ENG.pdf)
|
||||||
|
- [🌐 ENET IP Configuration Guide](guides/BMW_ENET_Static_IP_Setup_Guide.pdf)
|
||||||
|
- [🚦 SLI Unsupported Country Coding](guides/BMW_SLI_Unsupported_Country_Coding.pdf)
|
||||||
|
- [💡 IKON Headlights Retrofit Coding](guides/BMW_IKON_Headlights_Retrofit.pdf)
|
||||||
|
- [🖥️ CarPlay Compatibility List](guides/BMW_CarPlay_Android_Screen_Mirroring_Compatibility.pdf)
|
||||||
|
- [🔧 PsDzData I-Step Versions](guides/BMW_ISTA_PSDZData_Versions.pdf)
|
||||||
|
- [🖼️ Update Guide for Full-Screen CarPlay](guides/Update_Guide_for_Full_Screen_CarPlay.pdf)
|
||||||
|
- [🚶♂️ 8TF Pedestrian Protection Disable](guides/8TF_Pedestrian_Safety_Removal_Guide.pdf)
|
||||||
|
- [🏎️ M-Sport Steering Wheel Cruise Control Coding](guides/Cruise_Control_Retrofit_M_Sport_Guide.pdf)
|
||||||
|
- [🔄 MFL * LRE Wrong Version Coding](guides/Disable_MFL_Wrong_Version_Error_Guide.pdf)
|
||||||
|
- [⚙️ EDC Delete for Coilover Install](guides/EDC_Delete_BMW_FXX_Guide_Updated.pdf)
|
||||||
|
- [💡 Led Swap Headlight Error Coding](guides/Led_Swap_Headlight_Error_Coding_Guide.pdf)
|
||||||
|
- [📉 Disable TPMS (RDC) & Enable FTM](guides/TPMS_Disable.pdf)
|
||||||
|
- [💡 Vertical Aim Control Disable](guides/Disable_Headlight_Vertical_Aim_Guide.pdf)
|
||||||
|
|
||||||
| Tool Name | Description |
|
---
|
||||||
|------------------|------------------------------------------------------|
|
|
||||||
| `fat32format.txt` | Application for formatting USB drives to FAT32. |
|
|
||||||
| `copie_scr.sh` | Script for pulling the 1b file out of CIC systems. |
|
|
||||||
| `navigation_lookup_generator.ps1` | Powershell script for generating new maps lookup for FSC generators. |
|
|
||||||
|
|
||||||
## License
|
## 🔧 Tools
|
||||||
|
|
||||||
This repository is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
|
Below are the tools provided for various BMW-related tasks:
|
||||||
|
|
||||||
|
| 🔧 **Tool Name** | **Description** |
|
||||||
|
|-------------------|-----------------------------------------------------------|
|
||||||
|
| `fat32format.txt` | Application for formatting USB drives to FAT32. |
|
||||||
|
| `copie_scr.sh` | Script for pulling the 1b file out of CIC systems. |
|
||||||
|
| `maps_swid.sh` | CIC/NBT System get FSCShort/SWID from Maps archive. |
|
||||||
|
| `sysetV850io` | NBT System adjustment block dump tool. |
|
||||||
|
| `scp` | NBT SCP binary for /bin |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🤝 Contributing
|
||||||
|
|
||||||
|
Pull requests are welcome! For major changes, please open an issue first to discuss what you’d like to change.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📞 Need Help?
|
||||||
|
|
||||||
|
Feel free to reach out on Instagram:
|
||||||
|
- [@turbocode_os](https://www.instagram.com/turbocode_os)
|
||||||
|
- [@almost.m4](https://www.instagram.com/almost.m4)
|
||||||
|
|
||||||
|
## 🛡️ License
|
||||||
|
|
||||||
|
This repository is licensed under the **MIT License**. For more information, please see the [LICENSE](LICENSE) file.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
We hope you find these guides helpful! 🚘
|
||||||
|
BIN
assets/f32.png
Normal file
BIN
assets/f32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
BIN
guides/8TF_Pedestrian_Safety_Removal_Guide.pdf
Normal file
BIN
guides/8TF_Pedestrian_Safety_Removal_Guide.pdf
Normal file
Binary file not shown.
BIN
guides/BMW_CarPlay_Android_Screen_Mirroring_Compatibility.pdf
Normal file
BIN
guides/BMW_CarPlay_Android_Screen_Mirroring_Compatibility.pdf
Normal file
Binary file not shown.
BIN
guides/BMW_IKON_Headlights_Retrofit.pdf
Normal file
BIN
guides/BMW_IKON_Headlights_Retrofit.pdf
Normal file
Binary file not shown.
BIN
guides/BMW_ISTA_PSDZData_Versions.pdf
Normal file
BIN
guides/BMW_ISTA_PSDZData_Versions.pdf
Normal file
Binary file not shown.
BIN
guides/BMW_SLI_Unsupported_Country_Coding.pdf
Normal file
BIN
guides/BMW_SLI_Unsupported_Country_Coding.pdf
Normal file
Binary file not shown.
BIN
guides/Cruise_Control_Retrofit_M_Sport_Guide.pdf
Normal file
BIN
guides/Cruise_Control_Retrofit_M_Sport_Guide.pdf
Normal file
Binary file not shown.
BIN
guides/Disable_Headlight_Vertical_Aim_Guide.pdf
Normal file
BIN
guides/Disable_Headlight_Vertical_Aim_Guide.pdf
Normal file
Binary file not shown.
BIN
guides/Disable_MFL_Wrong_Version_Error_Guide.pdf
Normal file
BIN
guides/Disable_MFL_Wrong_Version_Error_Guide.pdf
Normal file
Binary file not shown.
BIN
guides/EDC_Delete_BMW_FXX_Guide_Updated.pdf
Normal file
BIN
guides/EDC_Delete_BMW_FXX_Guide_Updated.pdf
Normal file
Binary file not shown.
BIN
guides/Led_Swap_Headlight_Error_Coding_Guide.pdf
Normal file
BIN
guides/Led_Swap_Headlight_Error_Coding_Guide.pdf
Normal file
Binary file not shown.
BIN
guides/TPMS_Disable.pdf
Normal file
BIN
guides/TPMS_Disable.pdf
Normal file
Binary file not shown.
BIN
guides/Update_Guide_for_Full_Screen_CarPlay.pdf
Normal file
BIN
guides/Update_Guide_for_Full_Screen_CarPlay.pdf
Normal file
Binary file not shown.
250
tools/maps_swid.sh
Normal file
250
tools/maps_swid.sh
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Set variables
|
||||||
|
INFO_MAP_FILENAME="Info_Map.imp"
|
||||||
|
VERBOSE=0
|
||||||
|
GENERATEXML=0
|
||||||
|
MAP_FOLDER=""
|
||||||
|
ARCHIVE_FILE=""
|
||||||
|
DIRECT_FILE=""
|
||||||
|
LOG_FILE="./script.log"
|
||||||
|
DEFAULT=""
|
||||||
|
DEPENDENCIES=("7z" "hexdump" "awk")
|
||||||
|
|
||||||
|
# Functions declaration
|
||||||
|
|
||||||
|
# Check if all required commands are available
|
||||||
|
check_dependencies() {
|
||||||
|
for cmd in "${DEPENDENCIES[@]}"; do
|
||||||
|
if ! command -v "$cmd" &> /dev/null; then
|
||||||
|
echo "ERROR: Required command '$cmd' is not installed. Please install it and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Log message to console and file
|
||||||
|
log_message() {
|
||||||
|
if [[ $VERBOSE -eq 1 ]]; then
|
||||||
|
echo "$1" | tee -a "$LOG_FILE"
|
||||||
|
else
|
||||||
|
echo "$1" >> "$LOG_FILE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean up temporary files when script exits
|
||||||
|
cleanup() {
|
||||||
|
if [[ -f "/tmp/$INFO_MAP_FILENAME" ]]; then
|
||||||
|
rm "/tmp/$INFO_MAP_FILENAME"
|
||||||
|
fi
|
||||||
|
log_message "Cleaned up temporary files."
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
# Progress bar for long operations
|
||||||
|
show_progress() {
|
||||||
|
for i in {1..4}; do
|
||||||
|
sleep 1
|
||||||
|
case $i in
|
||||||
|
1) echo -ne 'Processing: [# ] (0%)\r' ;;
|
||||||
|
2) echo -ne 'Processing: [##### ] (25%)\r' ;;
|
||||||
|
3) echo -ne 'Processing: [########## ] (50%)\r' ;;
|
||||||
|
4) echo -ne 'Processing: [############### ] (75%)\r' ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo -ne 'Processing: [####################### ] (100%)\r\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse Info_Map.imp file
|
||||||
|
parseInfoMapFile() {
|
||||||
|
log_message "Parsing file..."
|
||||||
|
|
||||||
|
MAP_NAME=$(hexdump -C "$INFOMAP_FILE" | awk -F"|" '{ print $2 }' | tr -d "\n" | cut -c 21-200)
|
||||||
|
MAP_SWID_FscShort=$(hexdump -C "$INFOMAP_FILE" | awk 'NR==1 {print toupper($10$11$12$13)}')
|
||||||
|
MAP_REGION=$(hexdump -C "$INFOMAP_FILE" | awk 'NR==1 {print "0x" toupper($11)}')
|
||||||
|
MAP_YEAR=$(hexdump -C "$INFOMAP_FILE" | awk 'NR==1 {print "0x" toupper($13)}')
|
||||||
|
log_message "Parsing completed [OK]"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display map information
|
||||||
|
showMapInfos() {
|
||||||
|
echo -e "\n===================== Map Information ========================="
|
||||||
|
echo -e "Map Name : \"$MAP_NAME\""
|
||||||
|
echo -e "SWID_FscShort : \"$MAP_SWID_FscShort\""
|
||||||
|
echo -e "Map Region : \"$MAP_REGION\""
|
||||||
|
echo -e "Map Year : \"$MAP_YEAR\""
|
||||||
|
echo -e "===============================================================\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Show the XML entry to add
|
||||||
|
showLookupXMLEntry() {
|
||||||
|
LONG_MAP_NAME="$MAP_NAME (SWID_FscShort=$MAP_SWID_FscShort, MapRegion=$MAP_REGION, MapYear=$MAP_YEAR)"
|
||||||
|
echo -e "\n===================== XML Generation ==========================="
|
||||||
|
echo -e "Add this entry at the end of the maps list in your Lookup.xml file:\n"
|
||||||
|
echo -e "<SgbmId id=\"NAVD_000024A8_255_007_034\" SWID_FscShort=\"$MAP_SWID_FscShort\" name=\"$LONG_MAP_NAME\" supplier=\"NTQ\" sop=\"01.05.2021\" version=\"10_09\" MapOrderNumberBMW=\"\" MapOrderNumberMINI=\"\" MapOrderNumberRR=\"\" successorMapOrderNumberBMW=\"\" successorMapOrderNumberMINI=\"\" successorMapOrderNumberRR=\"\" NextNo=\"01826\">\n\t<EcuVariant CompatibilityIdentifier=\"NBTevo-HB\" Format=\"CIC\" />\n\t<SwUpdate SwUpdateEntry=\"\"/>\n</SgbmId>"
|
||||||
|
echo -e "\n===============================================================\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Validate input file permissions
|
||||||
|
validate_file() {
|
||||||
|
if [[ ! -r "$1" ]]; then
|
||||||
|
echo "ERROR: Cannot read file $1. Check permissions."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Process an archive file
|
||||||
|
processArchiveFile() {
|
||||||
|
if [[ ! -f "$ARCHIVE_FILE" ]]; then
|
||||||
|
log_message "ERROR: Archive file \"$ARCHIVE_FILE\" does not exist"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_message "File archive exists"
|
||||||
|
|
||||||
|
PATH_TO_INFOMAP_FILE=$(7z l "$ARCHIVE_FILE" | grep "$INFO_MAP_FILENAME" | grep -v "LIGHT" | awk '{print $NF}')
|
||||||
|
|
||||||
|
log_message "Looking for \"$INFO_MAP_FILENAME\" in the archive... [OK] - $PATH_TO_INFOMAP_FILE"
|
||||||
|
|
||||||
|
filename=$(basename -- "$ARCHIVE_FILE")
|
||||||
|
extension="${filename##*.}"
|
||||||
|
|
||||||
|
case "$extension" in
|
||||||
|
"7z"|"7Z")
|
||||||
|
log_message "Extracting \"$INFO_MAP_FILENAME\" from 7zip archive..."
|
||||||
|
show_progress
|
||||||
|
7z -y e "$ARCHIVE_FILE" -o"/tmp" "$PATH_TO_INFOMAP_FILE"
|
||||||
|
;;
|
||||||
|
"zip"|"ZIP"|"tar")
|
||||||
|
show_progress
|
||||||
|
7z -y e "$ARCHIVE_FILE" -o"/tmp" "$PATH_TO_INFOMAP_FILE" > /dev/null
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_message "Unsupported archive format: $extension"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ -f "/tmp/$INFO_MAP_FILENAME" ]]; then
|
||||||
|
INFOMAP_FILE="/tmp/$INFO_MAP_FILENAME"
|
||||||
|
else
|
||||||
|
log_message "ERROR: \"$INFO_MAP_FILENAME\" not found in /tmp"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Process map folder
|
||||||
|
processFolder() {
|
||||||
|
log_message "Processing folder \"$MAP_FOLDER\"..."
|
||||||
|
|
||||||
|
if [[ -d "$MAP_FOLDER/1" ]]; then
|
||||||
|
INFOMAP_FILE=$(find "$MAP_FOLDER/1" -name "$INFO_MAP_FILENAME" | grep -v "LIGHT" | head -n 1)
|
||||||
|
if [[ -z "$INFOMAP_FILE" ]]; then
|
||||||
|
log_message "ERROR: \"$INFO_MAP_FILENAME\" not found in folder(s) 1/INFO*"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_message "ERROR: Folder \"$MAP_FOLDER\" does not contain expected map files"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Batch process for multiple maps
|
||||||
|
process_batch() {
|
||||||
|
for file in "$1"/*; do
|
||||||
|
if [[ -d "$file" ]]; then
|
||||||
|
log_message "Processing folder: $file"
|
||||||
|
processFolder "$file"
|
||||||
|
elif [[ -f "$file" ]]; then
|
||||||
|
log_message "Processing archive: $file"
|
||||||
|
processArchiveFile "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
setWorkDir() {
|
||||||
|
if [[ -d "$MAP_FOLDER" ]]; then
|
||||||
|
cd "$MAP_FOLDER" || exit 1
|
||||||
|
log_message "Using map folder \"$MAP_FOLDER\"... [OK]"
|
||||||
|
else
|
||||||
|
log_message "ERROR: Given folder \"$MAP_FOLDER\" does not exist"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prompt for confirmation before overwriting
|
||||||
|
prompt_for_confirmation() {
|
||||||
|
read -p "File $1 exists. Overwrite? (y/n): " choice
|
||||||
|
case "$choice" in
|
||||||
|
y|Y ) log_message "Overwriting...";;
|
||||||
|
n|N ) log_message "Skipping..."; exit 0;;
|
||||||
|
* ) log_message "Invalid choice"; exit 1;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Show usage/help message
|
||||||
|
show_help() {
|
||||||
|
echo "Usage: InfoMap.sh [OPTIONS]"
|
||||||
|
echo "Extract hex information from downloaded BMW / Mini / RR Maps"
|
||||||
|
echo "Options:"
|
||||||
|
echo " -d <dir> Specify the map folder to process."
|
||||||
|
echo " -z <file> Specify the archive file to process (zip, 7z, etc.)."
|
||||||
|
echo " -f <file> Specify the Info_Map.imp file directly."
|
||||||
|
echo " -v Enable verbose mode."
|
||||||
|
echo " -x Generate XML entry."
|
||||||
|
echo " -b <dir> Batch process multiple folders or archives in the directory."
|
||||||
|
echo " -h Show this help message."
|
||||||
|
}
|
||||||
|
|
||||||
|
############# Main Program Starts #############
|
||||||
|
|
||||||
|
# Show help if no arguments are provided
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
POSITIONAL_ARGS=()
|
||||||
|
|
||||||
|
while getopts ":d:z:f:xb:vh" option; do
|
||||||
|
case $option in
|
||||||
|
d) MAP_FOLDER="$OPTARG" ;;
|
||||||
|
z) ARCHIVE_FILE="$OPTARG" ;;
|
||||||
|
f) DIRECT_FILE="$OPTARG" ;;
|
||||||
|
v) VERBOSE=1 ;;
|
||||||
|
x) GENERATEXML=1 ;;
|
||||||
|
b) process_batch "$OPTARG"; exit 0 ;;
|
||||||
|
h) show_help; exit 0 ;;
|
||||||
|
*) echo "Invalid option: -$OPTARG"; show_help; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
# Check dependencies
|
||||||
|
check_dependencies
|
||||||
|
|
||||||
|
# Processing logic based on provided arguments
|
||||||
|
if [[ -n "$DIRECT_FILE" ]]; then
|
||||||
|
validate_file "$DIRECT_FILE"
|
||||||
|
INFOMAP_FILE="$DIRECT_FILE"
|
||||||
|
elif [[ -n "$MAP_FOLDER" ]]; then
|
||||||
|
setWorkDir
|
||||||
|
processFolder
|
||||||
|
elif [[ -n "$ARCHIVE_FILE" ]]; then
|
||||||
|
processArchiveFile
|
||||||
|
else
|
||||||
|
log_message "No valid input provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Parsing Info_Map.imp file
|
||||||
|
parseInfoMapFile
|
||||||
|
|
||||||
|
# Display map information
|
||||||
|
showMapInfos
|
||||||
|
|
||||||
|
# Generate XML entry if required
|
||||||
|
if [[ $GENERATEXML -eq 1 ]]; then
|
||||||
|
showLookupXMLEntry
|
||||||
|
fi
|
@ -1,231 +0,0 @@
|
|||||||
# Created by David Petric
|
|
||||||
# This script parses Map informations and helps to create new entry in Lookup.xml used for FSC generators
|
|
||||||
# https://davidpetric.com
|
|
||||||
|
|
||||||
# Set variables
|
|
||||||
$INFO_MAP_FILENAME = "Info_Map.imp"
|
|
||||||
$VERBOSE = $false
|
|
||||||
$GENERATEXML = $false
|
|
||||||
$MAP_FOLDER = ""
|
|
||||||
$ARCHIVE_FILE = ""
|
|
||||||
|
|
||||||
# Function to install prerequisites
|
|
||||||
function Install-Prerequisites {
|
|
||||||
Write-Host "Checking for prerequisites..."
|
|
||||||
# Check for 7-Zip installation
|
|
||||||
if (-not (Get-Command "7z" -ErrorAction SilentlyContinue)) {
|
|
||||||
Write-Host "7-Zip not found. Installing 7-Zip..."
|
|
||||||
Invoke-WebRequest -Uri "https://www.7-zip.org/a/7z1900-x64.msi" -OutFile "$env:TEMP\7z1900-x64.msi"
|
|
||||||
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i $env:TEMP\7z1900-x64.msi /quiet" -Wait
|
|
||||||
Remove-Item "$env:TEMP\7z1900-x64.msi"
|
|
||||||
Write-Host "7-Zip installed."
|
|
||||||
} else {
|
|
||||||
Write-Host "7-Zip is already installed."
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check for hexdump installation
|
|
||||||
if (-not (Get-Command "hexdump" -ErrorAction SilentlyContinue)) {
|
|
||||||
Write-Host "Hexdump not found. Installing hexdump..."
|
|
||||||
$hexdumpZipUrl = "https://www.di-mgt.com.au/src/hexdump-2.1.0.zip"
|
|
||||||
$hexdumpZipPath = "$env:TEMP\hexdump-2.1.0.zip"
|
|
||||||
$hexdumpExtractPath = "C:\binaries"
|
|
||||||
|
|
||||||
Invoke-WebRequest -Uri $hexdumpZipUrl -OutFile $hexdumpZipPath
|
|
||||||
Expand-Archive -Path $hexdumpZipPath -DestinationPath $hexdumpExtractPath -Force
|
|
||||||
Remove-Item $hexdumpZipPath
|
|
||||||
|
|
||||||
# Ensure the directory is in the PATH
|
|
||||||
$env:Path += ";$hexdumpExtractPath"
|
|
||||||
|
|
||||||
# Update system PATH
|
|
||||||
[System.Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
|
|
||||||
Write-Host "Hexdump installed and added to PATH."
|
|
||||||
} else {
|
|
||||||
Write-Host "Hexdump is already installed."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Functions declaration
|
|
||||||
|
|
||||||
function Parse-InfoMapFile {
|
|
||||||
param (
|
|
||||||
[string]$InfoMapFile
|
|
||||||
)
|
|
||||||
if ($VERBOSE) { Write-Host "Parsing file..." -NoNewline }
|
|
||||||
$hexDump = hexdump -C $InfoMapFile
|
|
||||||
$MAP_NAME = ($hexDump | Select-String -Pattern "\|" | ForEach-Object { $_.Line.Split('|')[1].Trim() }).Substring(20)
|
|
||||||
$hexDumpUpper = $hexDump | ForEach-Object { $_.ToUpper() }
|
|
||||||
$MAP_SWID_FscShort = ($hexDumpUpper[0] -split ' ')[9..12] -join ''
|
|
||||||
$MAP_REGION = "0x$($hexDumpUpper[0].Split(' ')[10])"
|
|
||||||
$MAP_YEAR = "0x$($hexDumpUpper[0].Split(' ')[12])"
|
|
||||||
if ($VERBOSE) { Write-Host " [OK]" }
|
|
||||||
}
|
|
||||||
|
|
||||||
function Show-MapInfos {
|
|
||||||
Write-Host " "
|
|
||||||
Write-Host "===================== Map Informations =========================" -ForegroundColor Yellow
|
|
||||||
Write-Host "MapName : `"$MAP_NAME`""
|
|
||||||
Write-Host "SWID_FscShort: `"$MAP_SWID_FscShort`""
|
|
||||||
Write-Host "MapRegion : `"$MAP_REGION`""
|
|
||||||
Write-Host "MapYear : `"$MAP_YEAR`""
|
|
||||||
Write-Host "================================================================" -ForegroundColor Yellow
|
|
||||||
Write-Host " "
|
|
||||||
}
|
|
||||||
|
|
||||||
function Show-LookupXMLEntry {
|
|
||||||
$LONG_MAP_NAME = "$MAP_NAME (SWID_FscShort=$MAP_SWID_FscShort, MapRegion=$MAP_REGION, MapYear=$MAP_YEAR)"
|
|
||||||
Write-Host "===================== XML Generation ===========================" -ForegroundColor Yellow
|
|
||||||
Write-Host "Add this entry at the end of the maps list of your Lookup.xml file :"
|
|
||||||
Write-Host "
|
|
||||||
<-- From the line below -->
|
|
||||||
|
|
||||||
<SgbmId id=`"NAVD_000024A8_255_007_034`" SWID_FscShort=`"$MAP_SWID_FscShort`" name=`"$MAP_NAME (SWID_FscShort=$MAP_SWID_FscShort, MapRegion=$MAP_REGION, MapYear=$MAP_YEAR)`" supplier=`"NTQ`" sop=`"01.05.2021`" version=`"10_09`" MapOrderNumberBMW=`"`" MapOrderNumberMINI=`"`" MapOrderNumberRR=`"`" successorMapOrderNumberBMW=`"`" successorMapOrderNumberMINI=`"`" successorMapOrderNumberRR=`"`" NextNo=`"01826`">
|
|
||||||
<EcuVariant CompatibilityIdentifier=`"NBTevo-HB`" Format=`"CIC`" />
|
|
||||||
<SwUpdate SwUpdateEntry=`"`"/>
|
|
||||||
</SgbmId>
|
|
||||||
|
|
||||||
<-- To the upper line --> "
|
|
||||||
Write-Host " "
|
|
||||||
Write-Host "You will find a new map called $LONG_MAP_NAME in other tools ;-)" -ForegroundColor Yellow
|
|
||||||
Write-Host "As is you will have all informations in one place." -ForegroundColor Yellow
|
|
||||||
Write-Host "================================================================" -ForegroundColor Yellow
|
|
||||||
}
|
|
||||||
|
|
||||||
function Process-ArchiveFile {
|
|
||||||
if ($ARCHIVE_FILE) {
|
|
||||||
if (Test-Path $ARCHIVE_FILE) {
|
|
||||||
if ($VERBOSE) { Write-Host "File archive exists" }
|
|
||||||
$PATH_TO_INFOMAP_FILE = 7z l "$ARCHIVE_FILE" | Select-String -Pattern "$INFO_MAP_FILENAME" -NotMatch "LIGHT" | ForEach-Object { $_.Line.Split()[3] }
|
|
||||||
if ($VERBOSE) {
|
|
||||||
Write-Host "Archive content ..."
|
|
||||||
7z l "$ARCHIVE_FILE"
|
|
||||||
}
|
|
||||||
if ($VERBOSE) { Write-Host "Looking for $INFO_MAP_FILENAME file into archive... [OK] - $PATH_TO_INFOMAP_FILE" }
|
|
||||||
|
|
||||||
# Get filename extension
|
|
||||||
$extension = [System.IO.Path]::GetExtension($ARCHIVE_FILE).Trim('.').ToLower()
|
|
||||||
if ($VERBOSE) {
|
|
||||||
Write-Host "Archive extension is : $extension"
|
|
||||||
Write-Host "OS says : $(file $ARCHIVE_FILE)"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Switch case
|
|
||||||
if ($extension -eq "7z") {
|
|
||||||
Write-Host "Please note that only one file will be extracted from archive, so do not worry about spacedisk."
|
|
||||||
Write-Host " "
|
|
||||||
Write-Host "Please wait a little bit (i.e. 2 or 3 minutes) while we are looking for the file in a 7zip archive!" -ForegroundColor Yellow
|
|
||||||
7z e "$ARCHIVE_FILE" -o"/tmp" "$PATH_TO_INFOMAP_FILE" -y
|
|
||||||
} else {
|
|
||||||
7z e "$ARCHIVE_FILE" -o"/tmp" "$PATH_TO_INFOMAP_FILE" -y > $null
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verifying presence of Info_Map.imp file on disk
|
|
||||||
if ($VERBOSE) { Write-Host "Verifying presence of Info_Map.imp file on disk" }
|
|
||||||
if (Test-Path "/tmp/$INFO_MAP_FILENAME") {
|
|
||||||
if ($VERBOSE) { Write-Host (ls -l "/tmp/$INFO_MAP_FILENAME") }
|
|
||||||
$INFOMAP_FILE = "/tmp/$INFO_MAP_FILENAME"
|
|
||||||
} else {
|
|
||||||
Write-Host "ERROR : $INFO_MAP_FILENAME file not extracted in /tmp"
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Write-Host "ERROR : $ARCHIVE_FILE file does not exist"
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Write-Host "Function Process-ArchiveFile called but variable ARCHIVE_FILE is missing"
|
|
||||||
exit 99 # Internal error (i.e. BUG)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Set-WorkDir {
|
|
||||||
param (
|
|
||||||
[string]$MapFolder
|
|
||||||
)
|
|
||||||
if (Test-Path -PathType Container $MapFolder) {
|
|
||||||
Set-Location $MapFolder
|
|
||||||
if ($VERBOSE) { Write-Host "Using Map folder: $MapFolder ... [OK]" }
|
|
||||||
} else {
|
|
||||||
Write-Host "ERROR the given folder in argument doesn't exist"
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Process-Folder {
|
|
||||||
param (
|
|
||||||
[string]$MapFolder
|
|
||||||
)
|
|
||||||
if ($VERBOSE) { Write-Host "Processing in folder $MapFolder ..." }
|
|
||||||
|
|
||||||
if (Test-Path "./1") {
|
|
||||||
$MAP_DIR = Get-Location
|
|
||||||
if ($VERBOSE) { Write-Host "We are inside Map folder: $MapFolder ... [OK]" }
|
|
||||||
|
|
||||||
if ($VERBOSE) { Write-Host "Looking for InfoMap file ($INFO_MAP_FILENAME)" -NoNewline }
|
|
||||||
$INFOMAP_FILE = Get-ChildItem -Path 1/INFO*/$INFO_MAP_FILENAME -Exclude *LIGHT* -ErrorAction SilentlyContinue
|
|
||||||
if (!$INFOMAP_FILE) {
|
|
||||||
$ERROR = "Cannot find $INFO_MAP_FILENAME file in folder(s) 1/INFO*"
|
|
||||||
Write-Host "`n $ERROR`n"
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Write-Host " "
|
|
||||||
Write-Host "---------------------------------- [ERROR] -----------------------------------------------" -ForegroundColor Red
|
|
||||||
Write-Host "We are not in a map folder (or try to delete spaces/special characters in folder name/path)" -ForegroundColor Red
|
|
||||||
Write-Host " "
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
############# Program starts from here #############
|
|
||||||
|
|
||||||
# Install prerequisites
|
|
||||||
Install-Prerequisites
|
|
||||||
|
|
||||||
# Prompt the user to select options and input necessary paths
|
|
||||||
Write-Host "Select the mode of operation:"
|
|
||||||
Write-Host "1. Process a map folder"
|
|
||||||
Write-Host "2. Process an archive file"
|
|
||||||
$mode = Read-Host "Enter the number corresponding to your choice"
|
|
||||||
|
|
||||||
switch ($mode) {
|
|
||||||
1 {
|
|
||||||
$MAP_FOLDER = Read-Host "Enter the path to the map folder"
|
|
||||||
$VERBOSE = Read-Host "Enable verbose mode? (yes/no)" -eq "yes"
|
|
||||||
$GENERATEXML = Read-Host "Generate XML entry? (yes/no)" -eq "yes"
|
|
||||||
|
|
||||||
if ($MAP_FOLDER) {
|
|
||||||
if ($VERBOSE) { Write-Host "Switching to directory $MAP_FOLDER" }
|
|
||||||
Set-WorkDir -MapFolder $MAP_FOLDER
|
|
||||||
Process-Folder -MapFolder $MAP_FOLDER
|
|
||||||
} else {
|
|
||||||
Write-Host "No map folder path provided. Exiting..."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2 {
|
|
||||||
$ARCHIVE_FILE = Read-Host "Enter the path to the archive file"
|
|
||||||
$VERBOSE = Read-Host "Enable verbose mode? (yes/no)" -eq "yes"
|
|
||||||
$GENERATEXML = Read-Host "Generate XML entry? (yes/no)" -eq "yes"
|
|
||||||
|
|
||||||
if ($ARCHIVE_FILE) {
|
|
||||||
if ($VERBOSE) { Write-Host "Looking into archive file $ARCHIVE_FILE" }
|
|
||||||
Process-ArchiveFile
|
|
||||||
} else {
|
|
||||||
Write-Host "No archive file path provided. Exiting..."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
Write-Host "Invalid selection. Exiting..."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# InfoMap.imp file found
|
|
||||||
if ($VERBOSE) { Write-Host " $INFOMAP_FILE - [OK]" }
|
|
||||||
Parse-InfoMapFile -InfoMapFile $INFOMAP_FILE
|
|
||||||
Show-MapInfos
|
|
||||||
|
|
||||||
# Generate XML entry to add in Lookup.xml
|
|
||||||
if ($GENERATEXML) { Show-LookupXMLEntry }
|
|
BIN
tools/sysetV850io
Normal file
BIN
tools/sysetV850io
Normal file
Binary file not shown.
Reference in New Issue
Block a user