Skip to content

Commit

Permalink
Merge pull request #14 from thorrak/m1
Browse files Browse the repository at this point in the history
Refresh, Cleanup, and M1 Mac Support
  • Loading branch information
thorrak authored Jan 14, 2022
2 parents f40697f + b53d636 commit 64d2b2c
Show file tree
Hide file tree
Showing 19 changed files with 2,734 additions and 628 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,6 @@ package-lock.json
notarize.sh
staple.sh

# Exclude the pyinstaller directory (if it's here)
pyinstaller/

2 changes: 1 addition & 1 deletion About.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AboutDlg(wx.Dialog):
<p>Version {1}</p>
<p>BrewFlasher - &copy; 2019 John Beeler. Licensed under MIT.</p>
<p>BrewFlasher - &copy; 2019-2021 John Beeler. Licensed under MIT.</p>
<p>Based on <a style="color: #004CE5;" href="https://github.com/marcelstoer/nodemcu-pyflasher">NodeMCU PyFlasher</a>
- &copy; 2019 Marcel St&ouml;r. Licensed under MIT.</p>
Expand Down
15 changes: 15 additions & 0 deletions Distribution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1">
<pkg-ref id="com.brewflasher.macos.pkg"/>
<options customize="never" require-scripts="false" hostArchitectures="arm64"/>
<choices-outline>
<line choice="default">
<line choice="com.brewflasher.macos.pkg"/>
</line>
</choices-outline>
<choice id="default"/>
<choice id="com.brewflasher.macos.pkg" visible="false">
<pkg-ref id="com.brewflasher.macos.pkg"/>
</choice>
<pkg-ref id="com.brewflasher.macos.pkg" version="1.2.0" onConclusion="none">brewflasher.pkg</pkg-ref>
</installer-gui-script>
7 changes: 1 addition & 6 deletions Entitlements.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
<plist version="1.0">
<dict>
<!-- These are required for binaries built by PyInstaller -->
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>

</dict>
</plist>
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MIT License

NodeMCU Flasher Code - Copyright (c) 2016 Marcel Stör
BrewFlasher Changes/ Additions - Copyright (c) 2020 John Beeler
BrewFlasher Changes/ Additions - Copyright (c) 2020-2022 John Beeler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
158 changes: 90 additions & 68 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@
from argparse import Namespace

# Load the import & initialize the firmware_list
import fermentrack_integration
firmware_list = fermentrack_integration.FirmwareList()

__version__ = "1.0"
__flash_help__ = '''
<p>This setting depends on your device - but in most cases you will want to use DIO.<p>
<p>
<ul>
<li>Most ESP32 and ESP8266 ESP-12 use DIO.</li>
<li>Most ESP8266 ESP-01/07 use QIO.</li>
<li>ESP8285 requires DOUT.</li>
</ul>
</p>
<p>
For more information, details are found at at <a style="color: #004CE5;"
href="https://www.esp32.com/viewtopic.php?p=5523&sid=08ef44e13610ecf2a2a33bb173b0fd5c#p5523">http://bit.ly/2v5Rd32</a>
and in the <a style="color: #004CE5;" href="https://github.com/espressif/esptool/#flash-modes">esptool
documentation</a>
</p>
'''
import brewflasher_com_integration
firmware_list = brewflasher_com_integration.FirmwareList()

__version__ = "1.2"
# __flash_help__ = '''
# <p>This setting depends on your device - but in most cases you will want to use DIO.<p>
# <p>
# <ul>
# <li>Most ESP32 and ESP8266 ESP-12 use DIO.</li>
# <li>Most ESP8266 ESP-01/07 use QIO.</li>
# <li>ESP8285 requires DOUT.</li>
# </ul>
# </p>
# <p>
# For more information, details are found at at <a style="color: #004CE5;"
# href="https://www.esp32.com/viewtopic.php?p=5523&sid=08ef44e13610ecf2a2a33bb173b0fd5c#p5523">http://bit.ly/2v5Rd32</a>
# and in the <a style="color: #004CE5;" href="https://github.com/espressif/esptool/#flash-modes">esptool
# documentation</a>
#
# </p>
# '''
__auto_select__ = "Auto-select"
__auto_select_explanation__ = "(first port with Espressif device)"
__supported_baud_rates__ = [9600, 57600, 74880, 115200, 230400, 460800, 921600]
Expand Down Expand Up @@ -68,6 +68,9 @@ def flush(self):
# noinspection PyStatementEffect
None

def isatty(self):
return False

# ---------------------------------------------------------------------------


Expand All @@ -94,13 +97,20 @@ def run(self):
print("Must select the firmware to flash before flashing.")
return

print("Verifying firmware list is up-to-date before downloading...")
if not self._config.firmware_obj.pre_flash_web_verify(brewflasher_version=__version__):
print("Firmware list is not up to date. Relaunch BrewFlasher and try again.")
return

print("Downloading firmware...")
if self._config.firmware_obj.download_to_file():
print("Downloaded successfully!\n")
else:
print("Error - unable to download firmware.\n")
return

if self._config.device_family_string == "ESP32":
# This command matches the ESP32 flash options JSON from BrewFlasher.com
command_extension = ["--chip", "esp32",
"--baud", str(self._config.baud),
"--before", "default_reset", "--after", "hard_reset",
Expand All @@ -123,7 +133,8 @@ def run(self):
else:
command_extension = ["--chip", "esp8266",
"write_flash",
"--flash_mode", self._config.mode, "0x00000",
# "--flash_mode", self._config.mode,
"0x00000",
self._config.firmware_obj.full_filepath("firmware")]

# For both ESP32 and ESP8266 we can directly flash an image to SPIFFS.
Expand Down Expand Up @@ -158,9 +169,19 @@ def run(self):
if self._config.erase_before_flash:
command.append("--erase-all")

# There is a breaking change in esptool 3.0 that changes the flash size from detect to keep. We want to
# support "detect" by default.
command.append("-fs")
command.append("detect")

print("Command: esptool.py %s\n" % " ".join(command))

esptool.main(command)
try:
esptool.main(command)
except:
print("Firmware flashing FAILED. esptool.py raised an error.")
print("Try flashing again, or try flashing with a slower speed.")
return

# The last line printed by esptool is "Staying in bootloader." -> some indication that the process is
# done is needed
Expand All @@ -180,7 +201,7 @@ class FlashConfig:
def __init__(self):
self.baud = 115200
self.erase_before_flash = False
self.mode = "dio"
# self.mode = "dio"
self.firmware_path = None
# self.port = None
self.port = __auto_select__
Expand All @@ -201,15 +222,15 @@ def load(cls, file_path):
data = json.load(f)
conf.port = data['port']
conf.baud = data['baud']
conf.mode = data['mode']
# conf.mode = data['mode']
conf.erase_before_flash = data['erase']
return conf

def safe(self, file_path):
data = {
'port': self.port,
'baud': self.baud,
'mode': self.mode,
# 'mode': self.mode,
'erase': self.erase_before_flash,
}
with open(file_path, 'w') as f:
Expand Down Expand Up @@ -252,11 +273,11 @@ def on_baud_changed(event):
if radio_button.GetValue():
self._config.baud = radio_button.rate

def on_mode_changed(event):
radio_button = event.GetEventObject()

if radio_button.GetValue():
self._config.mode = radio_button.mode
# def on_mode_changed(event):
# radio_button = event.GetEventObject()
#
# if radio_button.GetValue():
# self._config.mode = radio_button.mode

def on_erase_changed(event):
radio_button = event.GetEventObject()
Expand Down Expand Up @@ -345,7 +366,7 @@ def on_select_firmware(event):
serial_boxsizer = wx.BoxSizer(wx.HORIZONTAL)
serial_boxsizer.Add(self.choice, 1, wx.EXPAND)
serial_boxsizer.AddStretchSpacer(0)
serial_boxsizer.Add(reload_button, 0, wx.ALIGN_RIGHT, 20)
serial_boxsizer.Add(reload_button, 0, 0, 20)

project_boxsizer = wx.BoxSizer(wx.HORIZONTAL)
project_boxsizer.Add(self.project_choice, 1, wx.EXPAND)
Expand All @@ -371,20 +392,21 @@ def add_baud_radio_button(sizer, index, baud_rate):
for idx, rate in enumerate(__supported_baud_rates__):
add_baud_radio_button(baud_boxsizer, idx, rate)

flashmode_boxsizer = wx.BoxSizer(wx.HORIZONTAL)

def add_flash_mode_radio_button(sizer, index, mode, label):
style = wx.RB_GROUP if index == 0 else 0
radio_button = wx.RadioButton(panel, name="mode-%s" % mode, label="%s" % label, style=style)
radio_button.Bind(wx.EVT_RADIOBUTTON, on_mode_changed)
radio_button.mode = mode
radio_button.SetValue(mode == self._config.mode)
sizer.Add(radio_button)
sizer.AddSpacer(10)

add_flash_mode_radio_button(flashmode_boxsizer, 0, "qio", "Quad I/O (QIO)")
add_flash_mode_radio_button(flashmode_boxsizer, 1, "dio", "Dual I/O (DIO)")
add_flash_mode_radio_button(flashmode_boxsizer, 2, "dout", "Dual Output (DOUT)")
# As of esptool 2.0 flash_mode is autodetected from the firmware. We've also always ignored it for ESP32.
# flashmode_boxsizer = wx.BoxSizer(wx.HORIZONTAL)
#
# def add_flash_mode_radio_button(sizer, index, mode, label):
# style = wx.RB_GROUP if index == 0 else 0
# radio_button = wx.RadioButton(panel, name="mode-%s" % mode, label="%s" % label, style=style)
# radio_button.Bind(wx.EVT_RADIOBUTTON, on_mode_changed)
# radio_button.mode = mode
# radio_button.SetValue(mode == self._config.mode)
# sizer.Add(radio_button)
# sizer.AddSpacer(10)
#
# add_flash_mode_radio_button(flashmode_boxsizer, 0, "qio", "Quad I/O (QIO)")
# add_flash_mode_radio_button(flashmode_boxsizer, 1, "dio", "Dual I/O (DIO)")
# add_flash_mode_radio_button(flashmode_boxsizer, 2, "dout", "Dual Output (DOUT)")

erase_boxsizer = wx.BoxSizer(wx.HORIZONTAL)

Expand Down Expand Up @@ -416,26 +438,26 @@ def add_erase_radio_button(sizer, index, erase_before_flash, label, value):
device_family_label = wx.StaticText(panel, label="Device Family ")
firmware_label = wx.StaticText(panel, label="Firmware ")
baud_label = wx.StaticText(panel, label="Baud rate ")
flashmode_label = wx.StaticText(panel, label="Flash mode ")

def on_info_hover(event):
from HtmlPopupTransientWindow import HtmlPopupTransientWindow
win = HtmlPopupTransientWindow(self, wx.SIMPLE_BORDER, __flash_help__, "#FFB6C1", (410, 140))

image = event.GetEventObject()
image_position = image.ClientToScreen((0, 0))
image_size = image.GetSize()
win.Position(image_position, (0, image_size[1]))

win.Popup()

icon = wx.StaticBitmap(panel, wx.ID_ANY, images.Info.GetBitmap())
icon.Bind(wx.EVT_MOTION, on_info_hover)

flashmode_label_boxsizer = wx.BoxSizer(wx.HORIZONTAL)
flashmode_label_boxsizer.Add(flashmode_label, 1, wx.EXPAND)
flashmode_label_boxsizer.AddStretchSpacer(0)
flashmode_label_boxsizer.Add(icon, 0, wx.ALIGN_RIGHT, 20)
# flashmode_label = wx.StaticText(panel, label="Flash mode ")

# def on_info_hover(event):
# from HtmlPopupTransientWindow import HtmlPopupTransientWindow
# win = HtmlPopupTransientWindow(self, wx.SIMPLE_BORDER, __flash_help__, "#FFB6C1", (410, 140))
#
# image = event.GetEventObject()
# image_position = image.ClientToScreen((0, 0))
# image_size = image.GetSize()
# win.Position(image_position, (0, image_size[1]))
#
# win.Popup()
#
# icon = wx.StaticBitmap(panel, wx.ID_ANY, images.Info.GetBitmap())
# icon.Bind(wx.EVT_MOTION, on_info_hover)

# flashmode_label_boxsizer = wx.BoxSizer(wx.HORIZONTAL)
# flashmode_label_boxsizer.Add(flashmode_label, 1, wx.EXPAND)
# flashmode_label_boxsizer.AddStretchSpacer(0)
# flashmode_label_boxsizer.Add(icon, 0, 0, 20)

erase_label = wx.StaticText(panel, label="Erase flash")
console_label = wx.StaticText(panel, label="Console")
Expand All @@ -446,11 +468,11 @@ def on_info_hover(event):
device_family_label, (device_family_boxsizer, 1, wx.EXPAND),
firmware_label, (firmware_boxsizer, 1, wx.EXPAND),
baud_label, baud_boxsizer,
flashmode_label_boxsizer, flashmode_boxsizer,
# flashmode_label_boxsizer, flashmode_boxsizer,
erase_label, erase_boxsizer,
(wx.StaticText(panel, label="")), (button, 1, wx.EXPAND),
(console_label, 1, wx.EXPAND), (self.console_ctrl, 1, wx.EXPAND)])
fgs.AddGrowableRow(8, 1)
fgs.AddGrowableRow(7, 1)
fgs.AddGrowableCol(1, 1)
hbox.Add(fgs, proportion=2, flag=wx.ALL | wx.EXPAND, border=15)
panel.SetSizer(hbox)
Expand Down
17 changes: 11 additions & 6 deletions PRIVACY.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
## Privacy Policy

BrewFlasher does not explicitly collect or transmit any user information or usage statistics.
BrewFlasher does not explicitly collect or transmit any user information.

BrewFlasher accesses [fermentrack.com](http://www.fermentrack.com) to download a list of
BrewFlasher accesses [brewflasher.com](http://www.brewflasher.com) to download a list of
available firmware, as well as other websites to download the firmware itself. These
websites - like all websites - may keep logs of access history which could include
(amongst other things) the IP address from which the request was made.
(amongst other things) the IP address from which the request was made. BrewFlasher.com
does anonymously log when a specific firmware item is selected to be flashed for the
purposes of tracking the popularity of various projects.

Although the author of BrewFlasher does not use this access information for any marketing
purposes, it is possible that the websites serving individual firmware files might. Using
BrewFlasher requires that you understand and accept this risk.
Although BrewFlasher.com provides BrewFlasher with links to the firmware to be flashed,
neither BrewFlasher or BrewFlasher.com actually provide the firmware itself. Firmware is
downloaded directly from the sites on which it is hosted. The privacy policies of these
websites may - and likely do - differ from this privacy policy, and may log additional
information beyond what this policy specifies. This is outside BrewFlasher's control.
Using BrewFlasher requires that you understand and accept this risk.


18 changes: 18 additions & 0 deletions PackageOptions.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>BundleHasStrictIdentifier</key>
<true/>
<key>BundleIsRelocatable</key>
<false/>
<key>BundleIsVersionChecked</key>
<true/>
<key>BundleOverwriteAction</key>
<string>upgrade</string>
<key>RootRelativeBundlePath</key>
<string>BrewFlasher.app</string>
</dict>
</array>
</plist>
Loading

0 comments on commit 64d2b2c

Please sign in to comment.