Skip to content

Commit 97c1b1a

Browse files
Convert to new toolchain
1 parent 08fcb90 commit 97c1b1a

File tree

2 files changed

+20
-69
lines changed

2 files changed

+20
-69
lines changed
-1.47 KB
Binary file not shown.

src/PicoLittleFS.java

Lines changed: 20 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,23 @@ private long getIntPref(String name){
159159
}
160160

161161
private void createAndUpload(){
162-
if(!PreferencesData.get("target_platform").contentEquals("esp8266")){
162+
if(!PreferencesData.get("target_platform").contentEquals("rp2040")){
163163
System.err.println();
164164
editor.statusError("LittleFS Not Supported on "+PreferencesData.get("target_platform"));
165165
return;
166166
}
167167

168-
if(!BaseNoGui.getBoardPreferences().containsKey("build.spiffs_start") || !BaseNoGui.getBoardPreferences().containsKey("build.spiffs_end")){
168+
if(!BaseNoGui.getBoardPreferences().containsKey("build.fs_start") || !BaseNoGui.getBoardPreferences().containsKey("build.fs_end")){
169169
System.err.println();
170170
editor.statusError("LittleFS Not Defined for "+BaseNoGui.getBoardPreferences().get("name"));
171171
return;
172172
}
173173
long spiStart, spiEnd, spiPage, spiBlock;
174174
try {
175-
spiStart = getIntPref("build.spiffs_start");
176-
spiEnd = getIntPref("build.spiffs_end");
177-
spiPage = getIntPref("build.spiffs_pagesize");
178-
if(spiPage == 0) spiPage = 256;
179-
spiBlock = getIntPref("build.spiffs_blocksize");
180-
if(spiBlock == 0) spiBlock = 4096;
175+
spiStart = getIntPref("build.fs_start");
176+
spiEnd = getIntPref("build.fs_end");
177+
spiPage = 256;
178+
spiBlock = 4096;
181179
} catch(Exception e){
182180
editor.statusError(e);
183181
return;
@@ -192,11 +190,11 @@ private void createAndUpload(){
192190
else
193191
mkspiffsCmd = "mklittlefs";
194192

195-
File tool = new File(platform.getFolder() + "/tools", mkspiffsCmd);
193+
File tool = new File(platform.getFolder() + "/system", mkspiffsCmd);
196194
if (!tool.exists() || !tool.isFile()) {
197-
tool = new File(platform.getFolder() + "/tools/mklittlefs", mkspiffsCmd);
195+
tool = new File(platform.getFolder() + "/system/mklittlefs", mkspiffsCmd);
198196
if (!tool.exists()) {
199-
tool = new File(PreferencesData.get("runtime.tools.mklittlefs.path"), mkspiffsCmd);
197+
tool = new File(PreferencesData.get("runtime.tools.pqt-mklittlefs.path"), mkspiffsCmd);
200198
if (!tool.exists()) {
201199
System.err.println();
202200
editor.statusError("LittleFS Error: mklittlefs not found!");
@@ -205,9 +203,6 @@ private void createAndUpload(){
205203
}
206204
}
207205

208-
Boolean isNetwork = false;
209-
File espota = new File(platform.getFolder()+"/tools");
210-
File esptool = new File(platform.getFolder()+"/tools");
211206
String serialPort = PreferencesData.get("serial.port");
212207
String pythonCmd = PreferencesData.get("runtime.os").contentEquals("windows") ? "python3.exe" : "python3";
213208
String uploadCmd = "";
@@ -220,7 +215,7 @@ private void createAndUpload(){
220215
}
221216

222217
// Find upload.py, don't fail if not present for backwards compat
223-
File uploadPyFile = new File(platform.getFolder()+"/tools", "upload.py");
218+
File uploadPyFile = new File(platform.getFolder()+"/tools", "uf2conv.py");
224219
if (uploadPyFile.exists() && uploadPyFile.isFile()) {
225220
uploadCmd = uploadPyFile.getAbsolutePath();
226221
}
@@ -235,32 +230,6 @@ private void createAndUpload(){
235230
}
236231
// pythonCmd now points to either an installed exe with full path or just plain "python3(.exe)"
237232

238-
//find espota if IP else find esptool
239-
if(serialPort.split("\\.").length == 4){
240-
isNetwork = true;
241-
String espotaCmd = "espota.py";
242-
espota = new File(platform.getFolder()+"/tools", espotaCmd);
243-
if(!espota.exists() || !espota.isFile()){
244-
System.err.println();
245-
editor.statusError("LittleFS Error: espota not found!");
246-
return;
247-
}
248-
} else {
249-
String esptoolCmd = platform.getTool("esptool").get("cmd");
250-
esptool = new File(platform.getFolder()+"/tools", esptoolCmd);
251-
if(!esptool.exists() || !esptool.isFile()){
252-
esptool = new File(platform.getFolder()+"/tools/esptool", esptoolCmd);
253-
if(!esptool.exists()){
254-
esptool = new File(PreferencesData.get("runtime.tools.esptool.path"), esptoolCmd);
255-
if (!esptool.exists() && uploadCmd.isEmpty()) {
256-
System.err.println();
257-
editor.statusError("LittleFS Error: esptool not found!");
258-
return;
259-
}
260-
}
261-
}
262-
}
263-
264233
//load a list of all files
265234
int fileCount = 0;
266235
File dataFolder = new File(editor.getSketch().getFolder(), "data");
@@ -280,11 +249,6 @@ private void createAndUpload(){
280249
String toolPath = tool.getAbsolutePath();
281250
String sketchName = editor.getSketch().getName();
282251
String imagePath = getBuildFolderPath(editor.getSketch()) + "/" + sketchName + ".mklittlefs.bin";
283-
String resetMethod = BaseNoGui.getBoardPreferences().get("upload.resetmethod");
284-
String uploadSpeed = BaseNoGui.getBoardPreferences().get("upload.speed");
285-
String uploadAddress = BaseNoGui.getBoardPreferences().get("build.spiffs_start");
286-
287-
288252

289253
Object[] options = { "Yes", "No" };
290254
String title = "LittleFS Create";
@@ -298,7 +262,7 @@ private void createAndUpload(){
298262

299263
editor.statusNotice("LittleFS Creating Image...");
300264
System.out.println("[LittleFS] data : "+dataPath);
301-
System.out.println("[LittleFS] size : "+((spiEnd - spiStart)/1024));
265+
System.out.println("[LittleFS] size : "+((spiEnd - spiStart)/1024) + "KB");
302266
System.out.println("[LittleFS] page : "+spiPage);
303267
System.out.println("[LittleFS] block : "+spiBlock);
304268

@@ -315,28 +279,15 @@ private void createAndUpload(){
315279
}
316280

317281
editor.statusNotice("LittleFS Uploading Image...");
318-
System.out.println("[LittleFS] upload : "+imagePath);
319-
320-
if(isNetwork){
321-
System.out.println("[LittleFS] IP : "+serialPort);
322-
System.out.println();
323-
sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath});
324-
} else {
325-
System.out.println("[LittleFS] address : "+uploadAddress);
326-
System.out.println("[LittleFS] reset : "+resetMethod);
327-
System.out.println("[LittleFS] port : "+serialPort);
328-
System.out.println("[LittleFS] speed : "+uploadSpeed);
329-
if (!uploadCmd.isEmpty()) {
330-
System.out.println("[LittleFS] python : "+pythonCmd);
331-
System.out.println("[LittleFS] uploader : "+uploadCmd);
332-
}
333-
334-
System.out.println();
335-
if (!uploadCmd.isEmpty()) {
336-
sysExec(new String[]{pythonCmd, uploadCmd, "--chip", "esp8266", "--port", serialPort, "--baud", uploadSpeed, "write_flash", uploadAddress, imagePath});
337-
} else {
338-
sysExec(new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath});
339-
}
282+
System.out.println("[LittleFS] upload : " + imagePath);
283+
System.out.println("[LittleFS] address : " + spiStart + "");
284+
System.out.println("[LittleFS] swerial : " + serialPort);
285+
System.out.println("[LittleFS] python : " + pythonCmd);
286+
System.out.println("[LittleFS] uploader : " + uploadCmd);
287+
288+
System.out.println();
289+
if (!uploadCmd.isEmpty()) {
290+
sysExec(new String[]{pythonCmd, uploadCmd, "--base", (spiStart - 0 * 0x10000000) + "", "--serial", serialPort, "--family", "RP2040", imagePath});
340291
}
341292
}
342293

0 commit comments

Comments
 (0)