diff --git a/io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java b/io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java index 0478b4a74..eb3d1082a 100644 --- a/io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java +++ b/io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java @@ -310,11 +310,19 @@ public static List makeBoardDescriptors(File boardFile) { public BoardDescription() { File boardsFile = new File(myStorageNode.get(KEY_LAST_USED_BOARDS_FILE, EMPTY)); - myBoardTxtFile = new BoardTxtFile(boardsFile); - myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, EMPTY); - myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, EMPTY); - myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, EMPTY); - myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, EMPTY)); + if (!boardsFile.exists()) { + List platforms = BoardsManager.getInstalledPlatforms(); + //If you crash on the next line no platform have been installed + ArduinoPlatformVersion platform = platforms.get(0); + myBoardTxtFile = new BoardTxtFile(platform.getBoardsFile()); + myBoardID = myBoardTxtFile.getAllBoardIDs().get(0); + } else { + myBoardTxtFile = new BoardTxtFile(boardsFile); + myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, EMPTY); + myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, EMPTY); + myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, EMPTY); + myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, EMPTY)); + } } public BoardDescription(BoardDescription srcObject) {