From b5707693f5ec9d8f7ef8c51c5ac78ae4f39a6858 Mon Sep 17 00:00:00 2001 From: Farouk Bouabid Date: Fri, 13 Oct 2023 11:14:15 +0200 Subject: 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 --- .../i2c-flash/src/mule-attiny_i2c_flash/i2c_flash.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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: -- cgit v1.2.3