Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Remove wake-on-boot argument parsing causing errors #486

Open
wants to merge 2 commits into
base: Dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions esp32/tools/fw_updater/README.md
Original file line number Diff line number Diff line change
@@ -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 <ssid name> --pwd <password>
```

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'>
```
1 change: 1 addition & 0 deletions esp32/tools/fw_updater/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyserial
21 changes: 4 additions & 17 deletions esp32/tools/fw_updater/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:]
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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:
Expand Down