aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFarouk Bouabid <farouk.bouabid@theobroma-systems.com>2023-10-13 11:14:15 +0200
committerFarouk Bouabid <farouk.bouabid@theobroma-systems.com>2023-10-13 11:14:15 +0200
commitb5707693f5ec9d8f7ef8c51c5ac78ae4f39a6858 (patch)
treee0062b59da5f486d1841ecee82eec49c99d4fa4d
parent609bf90e5a09a75411535cd39f2a2080b0b5cde6 (diff)
mule-attiny: i2c_flash: support flashloader read-only mode
After entering the flashloader it is safe to set it into read-only mode (by pulling the boot request gpio back low) until the fw_flash() routine is actually called. This avoids having any i2c process, by mistake, write to the wire (flash unwanted/invalid data). Signed-off-by: Farouk Bouabid <farouk.bouabid@theobroma-systems.com>
-rwxr-xr-xmule-attiny/i2c-flash/src/mule-attiny_i2c_flash/i2c_flash.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/mule-attiny/i2c-flash/src/mule-attiny_i2c_flash/i2c_flash.py b/mule-attiny/i2c-flash/src/mule-attiny_i2c_flash/i2c_flash.py
index c424808..c867558 100755
--- a/mule-attiny/i2c-flash/src/mule-attiny_i2c_flash/i2c_flash.py
+++ b/mule-attiny/i2c-flash/src/mule-attiny_i2c_flash/i2c_flash.py
@@ -54,6 +54,16 @@ class BootModeController:
sleep(0.1)
self.__flashMode = True
+ self.enterRoMode()
+
+ # Flashloader sub-mode (read-only: read bootloader data)
+ def enterRoMode(self):
+ if self.__flashMode:
+ self.__bootReq.set_value(0)
+
+ def exitRoMode(self):
+ if self.__flashMode:
+ self.__bootReq.set_value(1)
def exitFlashloader(self):
if self.__bootReq.is_requested():
@@ -178,8 +188,9 @@ def main():
)
try:
- # Request flashloader through bootloader
+ # Request flashloader through bootloader (Set to read-only-mode by default)
bootCtrl.enterFlashloader()
+ bootCtrl.exitRoMode()
ret = fw_flash(_bin, args.i2c_bus)
except Exception as err: