Skip to content

Commit

Permalink
chaged release bin creation
Browse files Browse the repository at this point in the history
  • Loading branch information
dewenni committed Jul 16, 2023
1 parent 0225e70 commit 4d0963d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 40 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Then adapt the `upload_port` and corresponding settings in `platformio.ini` to y

## ESP-Flash-Tool

In the releases, you can find also the binary of the Software. If you don´t want to use PlatformIO, you can also use the `ESP_Buderus_KM271_vx.x.x_install.bin` file and flash it directly on the ESP. This bin-file is already a merge with bootloader.bin, partitions.bin and the application.bin. You can flash this image an the ESP at address 0x00.
In the releases, you can find also the binary of the Software. If you don´t want to use PlatformIO, you can also use the `buderus_km271_esp32_flash_vx.x.x.bin` file and flash it directly on the ESP. This bin-file is already a merge with bootloader.bin, partitions.bin and the application.bin. You can flash this image an the ESP at address 0x00.

**Windows**
There are several tools available to flash binaries to the ESP.
Expand All @@ -135,7 +135,7 @@ for Mac it is hard to find a tool with a graphical UI, but you can simple use th
3. optional get the install path: `which esptool.py`
4. set path: `export PATH="$PATH:/path/to/esptool.py"` (<- change path with result from 3.)
5. goto path where the bin file is located
6. upload: `esptool.py -p <UPLOAD-PORT> write_flash 0x00 ESP_Buderus_KM271_vx.x.x_install.bin`
6. upload: `esptool.py -p <UPLOAD-PORT> write_flash 0x00 buderus_km271_esp32_flash_vx.x.x.bin`

## OTA-Updates

Expand All @@ -144,7 +144,7 @@ You can find the link to that separate webserver in the settings tab of the norm

![ota-ip](Doc/ota-ip.png)

here you can choose "Firmware" and select the `ESP_Buderus_KM271_vx.x.x_OTA_update.bin` file from the release section
here you can choose "Firmware" and select the `buderus_km271_ota_update_vx.x.x.bin` file from the release section

![ota-1](Doc/ota_1.png)

Expand Down
16 changes: 15 additions & 1 deletion changelog
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,18 @@ see detailed description in README.md in chapter **ESP-Flash-Tool**
## changelog

- bugfix in Heating Circuit 2 - #37
- mqtt bootup message (Topic: "../message" - Payload: "restarted!") - can be used to ignore alarms after reboot
- mqtt bootup message (Topic: "../message" - Payload: "restarted!") - can be used to ignore alarms after reboot

# v3.2.3

## what's new

update release assets:
- buderus_km271_esp32_flash_v3.2.3.bin (for initital installation of esp32 boards like the78mole boards)
- buderus_km271_ota_update_v3.2.3.bin (for OTA Update of the application)

see detailed description in README.md in chapter **ESP-Flash-Tool**

## changelog

- changed bin-file creation in platformio_release.py
5 changes: 2 additions & 3 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
/*-------------------------------------------------------------------------------
General Configuration
--------------------------------------------------------------------------------*/
#define PROJECT "ESP_Buderus_KM271" // project info
#define VERSION "v3.2.2" // internal program version
#define DEBUG_ON // enable debug messages
#define VERSION "v3.2.3" // internal program version
#define DEBUG_ON // enable debug messages

#define WIFI_RECONNECT 10000 // Delay between wifi reconnection tries
#define MQTT_RECONNECT 10000 // Delay between mqtt reconnection tries
Expand Down
3 changes: 1 addition & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ monitor_filters = esp32_exception_decoder, colorize
build_type = release

extra_scripts =
platformio_upload.py
platformio_release.py
platformio_upload.py


; ----------------------------------------------------------------
; OPTION 1: direct cable upload
; ----------------------------------------------------------------
Expand Down
78 changes: 47 additions & 31 deletions platformio_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
import re
import shutil

def extract_project():
config_path = env.subst("$PROJECT_DIR/include/config.h")
with open(config_path, "r") as file:
content = file.read()
match = re.search(r'#define PROJECT\s+"(.+)"', content)
if match:
return match.group(1)
else:
return None

OTA_NAME = "buderus_km271_ota_update" # prefix for ota release image
INSTALL_NAME = "buderus_km271_esp32_flash" # prefix for merged flash image

APP_BIN = "$BUILD_DIR/${PROGNAME}.bin"
MERGED_BIN = "$BUILD_DIR/${PROGNAME}_merged.bin"
RELEASE_PATH = "$PROJECT_DIR/release"
BOARD_CONFIG = env.BoardConfig()


# extract program version from /include/config.h
def extract_version():
config_path = env.subst("$PROJECT_DIR/include/config.h")
with open(config_path, "r") as file:
Expand All @@ -23,25 +24,40 @@ def extract_version():
else:
return None

def merge_bin(target, source, env):
project = extract_project()
version = extract_version()

build_dir = env.subst("$BUILD_DIR")
binary_path = os.path.join(build_dir, "firmware.bin")
bootloader_path = os.path.join(build_dir, "bootloader.bin")
partitions_path = os.path.join(build_dir, "partitions.bin")
release_path = os.path.join(env.subst("$PROJECT_DIR"), "release")

# Leeren des release-Ordners
if os.path.exists(release_path):
shutil.rmtree(release_path)
os.makedirs(release_path)

merged_file = os.path.join(release_path, f"{project}_{version}_install.bin")
ota_update_file = os.path.join(release_path, f"{project}_{version}_OTA_update.bin")

env.Execute(f'esptool.py --chip ESP32 merge_bin -o {merged_file} --flash_mode dio --flash_size 4MB 0x1000 {bootloader_path} 0x8000 {partitions_path} 0x10000 {binary_path}')
shutil.copyfile(binary_path, ota_update_file)

env.AddPostAction("buildprog", merge_bin)
def merge_bin(source, target, env):
# The list contains all extra images (bootloader, partitions, eboot) and
# the final application binary
flash_images = env.Flatten(env.get("FLASH_EXTRA_IMAGES", [])) + ["$ESP32_APP_OFFSET", APP_BIN]
# Run esptool to merge images into a single binary
env.Execute(
" ".join(
[
"$PYTHONEXE",
"$OBJCOPY",
"--chip",
BOARD_CONFIG.get("build.mcu", "esp32"),
"merge_bin",
"--flash_size", #optional: --fill-flash-size
BOARD_CONFIG.get("upload.flash_size", "4MB"),
"-o",
MERGED_BIN,
]
+ flash_images
)
)

release_path = env.subst(RELEASE_PATH) # path to release folder
# delete old release files
if os.path.exists(env.subst(RELEASE_PATH)):
shutil.rmtree(env.subst(RELEASE_PATH))
os.makedirs(env.subst(RELEASE_PATH))

version = extract_version() # get version from config
merged_file = os.path.join(release_path, f"{INSTALL_NAME}_{version}.bin") # path and name of merged image
ota_update_file = os.path.join(release_path, f"{OTA_NAME}_{version}.bin") # path and name of ota image
shutil.copyfile(env.subst(MERGED_BIN), merged_file) # copy files
shutil.copyfile(env.subst(APP_BIN), ota_update_file) # copy files


# Add a post action that runs esptoolpy to merge available flash images
env.AddPostAction(APP_BIN , merge_bin)

0 comments on commit 4d0963d

Please sign in to comment.