From bc174f13f312dfb07adb24ce42ff41e0d37d650a Mon Sep 17 00:00:00 2001 From: "Ryan J. Dillon" Date: Wed, 14 Oct 2020 07:22:24 +0200 Subject: [PATCH 1/2] Add fw_updataer readme and pip requirements --- esp32/tools/fw_updater/README.md | 40 +++++++++++++++++++++++++ esp32/tools/fw_updater/requirements.txt | 1 + 2 files changed, 41 insertions(+) create mode 100644 esp32/tools/fw_updater/README.md create mode 100644 esp32/tools/fw_updater/requirements.txt diff --git a/esp32/tools/fw_updater/README.md b/esp32/tools/fw_updater/README.md new file mode 100644 index 0000000000..0a9ecdbc36 --- /dev/null +++ b/esp32/tools/fw_updater/README.md @@ -0,0 +1,40 @@ +# Pycom firmware updater +Script for updating firmaware on Pycom modules + +## Download firmware +Links for Pygate firmware for the available modules (WiPy, GPy, and LoPy4) can be found [here](https://docs.pycom.io/advance/downgrade/). + +# Quickstart +Install and activate a `virtualenv` +``` +python3.7 -m venv venv +source venv/bin/activate +``` + +Install dependencies +``` +pip install -r requirements +deactivate +``` + +As root user, activate `venv` and run updater +``` +sudo su +source venv/bin/activate +./updater.py -v -p /dev/ttyACM1 flash -t ~/path/to/firmware/LoPy4-1.20.2.rc11.tar.gz +``` + +Set WiFi Access point SSID and password +``` +./updater.py -v -p /dev/ttyACM1 wifi --ssid --pwd +``` + +Set LoRa Region +``` +./updater.py -v -p /dev/ttyACM1 lpwan --region <'EU868', 'US915', 'AS923', 'AU915', or 'IN865'> +``` + +Set filesystem type +``` +./updater.py -v -p /dev/ttyACM1 pycom --fs_type <'FatFS' or 'LittleFS'> +``` diff --git a/esp32/tools/fw_updater/requirements.txt b/esp32/tools/fw_updater/requirements.txt new file mode 100644 index 0000000000..f6c1a1f572 --- /dev/null +++ b/esp32/tools/fw_updater/requirements.txt @@ -0,0 +1 @@ +pyserial From e674f193a9d20542152cadabe65adbd76871fb9a Mon Sep 17 00:00:00 2001 From: "Ryan J. Dillon" Date: Wed, 14 Oct 2020 07:22:52 +0200 Subject: [PATCH 2/2] Remove erroneous wob argument handling --- esp32/tools/fw_updater/updater.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/esp32/tools/fw_updater/updater.py b/esp32/tools/fw_updater/updater.py index 401330c2cd..2ab7393756 100755 --- a/esp32/tools/fw_updater/updater.py +++ b/esp32/tools/fw_updater/updater.py @@ -666,18 +666,8 @@ def flash_bin(self, dest_and_file_pairs, ui_label=None, file_name=None, progress esptool.write_flash(self.esp, args, ui_label=ui_label, file_name=file_name, resultUpdateList=self.__resultUpdateList, progress_fs=progress_fs) - def set_wifi_config(self, config_block, wifi_ssid=None, wifi_pwd=None, wifi_on_boot=None): + def set_wifi_config(self, config_block, wifi_ssid=None, wifi_pwd=None): config_block = config_block.ljust(int(PARTITIONS.get('config')[1], 16), b'\x00') - if wifi_on_boot is not None: - if wifi_on_boot == True: - wob = b'\xbb' - else: - wob = b'\xba' - else: - if sys.version_info[0] < 3: - wob = config_block[53] - else: - wob = config_block[53].to_bytes(1, byteorder='little') if wifi_ssid is not None: ssid = wifi_ssid.encode().ljust(33, b'\x00') else: @@ -688,8 +678,7 @@ def set_wifi_config(self, config_block, wifi_ssid=None, wifi_pwd=None, wifi_on_b else: pwd = config_block[87:152] - new_config_block = config_block[0:53] \ - +wob \ + new_config_block = config_block[0:54] \ +ssid \ +pwd \ +config_block[152:] @@ -1038,8 +1027,6 @@ def process_arguments(): cmd_parser_wifi = subparsers.add_parser('wifi', help='Get/Set default WIFI parameters') cmd_parser_wifi.add_argument('--ssid', default=None, help='Set Wifi SSID') cmd_parser_wifi.add_argument('--pwd', default=None, help='Set Wifi PWD') - # This doesn't really work as we updated the field to a bitfield - #cmd_parser_wifi.add_argument('--wob', type=str2bool, nargs='?', const=True, help='Set Wifi on boot') cmd_parser_pybytes = subparsers.add_parser('pybytes', help='Read/Write pybytes configuration') cmd_parser_pybytes.add_argument('--token', default=None, help='Set Device Token') @@ -1515,8 +1502,8 @@ def progress_fs(msg): elif args.command == 'wifi': config_block = nPy.read(int(PARTITIONS.get('config')[0], 16), int(PARTITIONS.get('config')[1], 16)) - if (hasattr(args, "ssid") and args.ssid is not None) or (hasattr(args, "pwd") and args.pwd is not None) or (hasattr(args, "wob") and args.wob is not None): - new_config_block = nPy.set_wifi_config(config_block, args.ssid, args.pwd, args.wob) + if (hasattr(args, "ssid") and args.ssid is not None) or (hasattr(args, "pwd") and args.pwd is not None): + new_config_block = nPy.set_wifi_config(config_block, args.ssid, args.pwd) nPy.write(int(PARTITIONS.get('config')[0], 16), new_config_block) sys.stdout = old_stdout else: