Skip to content

Add password for OTA upload to LittleFS #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
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
Binary file added PasswordDialogBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ On the OS X create the tools directory in ~/Documents/Arduino/ and unpack the fi

![Screenshot](screenshot.png)

![DialogBox](PasswordDialogBox.png)

## Credits and license

- Copyright (c) 2015 Hristo Gochkov (ficeto at ficeto dot com)
Expand Down
Binary file added esp8266littlefs.jar
Binary file not shown.
46 changes: 46 additions & 0 deletions makeLittleFS.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ECHO off

REM set pde_path=C:/temp/JavaTrials/Arduino-master/build/windows/work/lib/pde.jar
REM set pde_path=C:/temp/JavaTrials/Arduino-master/app/pde.jar
set pde_path=D:/Program Files (x86)/Arduino/lib/pde.jar

REM set core_path=C:/temp/JavaTrials/Arduino-master/build/windows/work/lib/arduino-core.jar
REM set core_path=C:/temp/JavaTrials/Arduino-master/arduino-core/arduino-core.jar
set core_path=D:/Program Files (x86)/Arduino/lib/arduino-core.jar
REM set lib_path=C:/temp/JavaTrials/Arduino-master/build/windows/work/lib/commons-codec-1.7.jar
REM set lib_path=C:/temp/JavaTrials/Arduino-master/app/lib/commons-codec-1.7.jar
REM set lib_path=C:/temp/JavaTrials/Arduino-master/arduino-core/lib/commons-codec-1.7.jar
set lib_path=D:/Program Files (x86)/Arduino/lib/commons-codec-1.7.jar

echo pde_path: %pde_path%
echo core_path: %core_path%
echo lib_path: %lib_path%

mkdir bin

ECHO on
javac -target 1.8 -source 1.8 -cp "%pde_path%;%core_path%;%lib_path%" -d bin src/ESP8266LittleFS.java
ECHO off

mkdir tools
mkdir tools\ESP8266LittleFS
mkdir tools\ESP8266LittleFS\tool
erase tools\ESP8266LittleFS\tool\esp8266littlefs.jar

cd bin

jar cfveM ..\tools\ESP8266LittleFS\tool\esp8266littlefs.jar -C com\esp8266\mklittlefs ESP8266LittleFS.class ESP8266LittleFS$1.class ESP8266LittleFS$2.class

cd ..

exit /B

REM popd

REM dist=$PWD/dist
REM rev=$(git describe --tags)
REM mkdir -p $dist
REM pushd $INSTALLDIR/tools
REM rm -f $dist/*.zip
REM zip -r $dist/ESP8266LittleFS-$rev.zip ESP8266LittleFS/
REM popd
13 changes: 12 additions & 1 deletion src/ESP8266LittleFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

Original copyright (c) 2015 Hristo Gochkov (ficeto at ficeto dot com)
Modified from SPIFFS to LittleFS by Earle F. Philhower, III
Modified for OTA password by Ladi Kehl

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -320,7 +321,17 @@ private void createAndUpload(){
if(isNetwork){
System.out.println("[LittleFS] IP : "+serialPort);
System.out.println();
sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath});

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think you could actually see if an AUTH is needed before presenting the box? I understand that you're using it, but since ArduinoOTA is so insecure anyway I have a feeling that most people will not be using a password at all.

It's possible to probe the board using UDP comms (connect to ESP8266, send SPIFFS command, check for AUTH response, see espota.py), or even just call espota.py once, and if it fails then prompt for a PWD and try again.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice and simple, BTW! Just trying to make the default case the easiest/simplest for end users.

// ask for a password
String passCode = JOptionPane.showInputDialog(editor, "Please enter password:\n(leave empty if none required!)","ESP8266LittleFS OTA Update", JOptionPane.QUESTION_MESSAGE);
if(passCode != null) {
if(passCode.isEmpty()) {
sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath});
} else {
sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath, "-a", passCode});
}
}

} else {
System.out.println("[LittleFS] address : "+uploadAddress);
System.out.println("[LittleFS] reset : "+resetMethod);
Expand Down