clean up
This commit is contained in:
1 parent
3186db019d
commit
2dfa19c8e6
3 files changed
-334
No files matched your search
@@ -1 +0,0 @@
|
||||
My Page
|
||||
@@ -1,148 +0,0 @@
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "sandeepmistry",
|
||||
"maintainer": "Sandeep Mistry",
|
||||
"websiteURL": "https://github.com/sandeepmistry/arduino-nRF5",
|
||||
"email": "sandeep.mistry@gmail.com",
|
||||
"help": {
|
||||
"online": "https://github.com/sandeepmistry/arduino-nRF5/issues"
|
||||
},
|
||||
"platforms": [
|
||||
{
|
||||
"name": "Nordic Semiconductor nRF5 Boards",
|
||||
"architecture": "nRF5",
|
||||
"version": "0.1.0",
|
||||
"category": "Contributed",
|
||||
"help": {
|
||||
"online": "https://github.com/sandeepmistry/arduino-nRF5/issues"
|
||||
},
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/archive/0.1.0.tar.gz",
|
||||
"archiveFileName": "arduino-nRF52-0.1.0.tar.gz",
|
||||
"checksum": "MD5:1825f6420104225f5fee11b467923b7d",
|
||||
"size": "591297",
|
||||
"boards": [
|
||||
{"name": "nRF52 DK"},
|
||||
{"name": "Bluz DK"}
|
||||
],
|
||||
"toolsDependencies": [
|
||||
{
|
||||
"packager": "sandeepmistry",
|
||||
"name": "gcc-arm-none-eabi",
|
||||
"version": "5_2-2015q4"
|
||||
},
|
||||
{
|
||||
"packager": "sandeepmistry",
|
||||
"name": "openocd",
|
||||
"version": "0.10.0-dev.nrf5"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Nordic Semiconductor nRF5 Boards",
|
||||
"architecture": "nRF5",
|
||||
"version": "0.2.0",
|
||||
"category": "Contributed",
|
||||
"help": {
|
||||
"online": "https://github.com/sandeepmistry/arduino-nRF5/issues"
|
||||
},
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/archive/0.2.0.tar.gz",
|
||||
"archiveFileName": "arduino-nRF52-0.2.0.tar.gz",
|
||||
"checksum": "MD5:1ed95ee9030e4ca1371665258a3cdee4",
|
||||
"size": "562847",
|
||||
"boards": [
|
||||
{"name": "nRF52 DK"},
|
||||
{"name": "Bluz DK"},
|
||||
{"name": "RedBearLab BLE Nano"},
|
||||
{"name": "RedBearLab nRF51822"},
|
||||
{"name": "BBC micro:bit"},
|
||||
{"name": "OSHChip"},
|
||||
{"name": "Generic nRF51822"}
|
||||
],
|
||||
"toolsDependencies": [
|
||||
{
|
||||
"packager": "sandeepmistry",
|
||||
"name": "gcc-arm-none-eabi",
|
||||
"version": "5_2-2015q4"
|
||||
},
|
||||
{
|
||||
"packager": "sandeepmistry",
|
||||
"name": "openocd",
|
||||
"version": "0.10.0-dev.nrf5"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tools":[
|
||||
{
|
||||
"name": "gcc-arm-none-eabi",
|
||||
"version": "5_2-2015q4",
|
||||
"systems": [
|
||||
{
|
||||
"host": "i386-apple-darwin11",
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/releases/download/tools/gcc-arm-none-eabi-5_2-2015q4-20151219-mac.tar.bz2",
|
||||
"archiveFileName": "gcc-arm-none-eabi-5_2-2015q4-20151219-mac.tar.bz2",
|
||||
"size": "96372129",
|
||||
"checksum": "MD5:603bcce8e59683ac27054b3197a53254"
|
||||
},
|
||||
{
|
||||
"host": "i686-linux-gnu",
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/releases/download/tools/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2",
|
||||
"archiveFileName": "gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2",
|
||||
"size": "92811866",
|
||||
"checksum": "MD5:f88caac80b4444a17344f57ccb760b90"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/releases/download/tools/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2",
|
||||
"archiveFileName": "gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2",
|
||||
"size": "92811866",
|
||||
"checksum": "MD5:f88caac80b4444a17344f57ccb760b90"
|
||||
},
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/releases/download/tools/gcc-arm-none-eabi-5_2-2015q4-20151219-win32.tar.bz2",
|
||||
"archiveFileName": "gcc-arm-none-eabi-5_2-2015q4-20151219-win32.tar.bz2",
|
||||
"size": "102981732",
|
||||
"checksum": "MD5:32d950225b6c7c886f6225c1fc578934"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "openocd",
|
||||
"version": "0.10.0-dev.nrf5",
|
||||
"systems": [
|
||||
{
|
||||
"host": "i386-apple-darwin11",
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/releases/download/tools/openocd-osx-0.10.0-dev-nrf5.tar.gz",
|
||||
"archiveFileName": "openocd-osx-0.10.0-dev-nrf5.tar.gz",
|
||||
"size": "1345243",
|
||||
"checksum": "MD5:3ffaa4e7cd4b96770eec65002c5959e3"
|
||||
},
|
||||
{
|
||||
"host": "i686-linux-gnu",
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/releases/download/tools/openocd-linux32-0.10.0-dev-nrf5.tar.gz",
|
||||
"archiveFileName": "openocd-linux32-0.10.0-dev-nrf5.tar.gz",
|
||||
"size": "3585042",
|
||||
"checksum": "MD5:02b3f4a3004cae86631bf13837c84504"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/releases/download/tools/openocd-linux32-0.10.0-dev-nrf5.tar.gz",
|
||||
"archiveFileName": "openocd-linux32-0.10.0-dev-nrf5.tar.gz",
|
||||
"size": "3585042",
|
||||
"checksum": "MD5:02b3f4a3004cae86631bf13837c84504"
|
||||
},
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://github.com/sandeepmistry/arduino-nRF5/releases/download/tools/openocd-win32-0.10.0-dev-nrf5.tar.gz",
|
||||
"archiveFileName": "openocd-win32-0.10.0-dev-nrf5.tar.gz",
|
||||
"size": "5498373",
|
||||
"checksum": "MD5:3acd3b08afda2bb09e75a0de5ac7c3cd"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package com.github.sandeepmistry.arduino.nRF5;
|
||||
|
||||
import cc.arduino.packages.Uploader;
|
||||
import cc.arduino.packages.uploaders.SerialUploader;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import java.lang.Runnable;
|
||||
import java.lang.Thread;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import processing.app.Editor;
|
||||
import processing.app.PreferencesData;
|
||||
import processing.app.tools.Tool;
|
||||
|
||||
public class nRF5FlashSoftDevice implements Tool {
|
||||
private Map<String, String> urls = new HashMap<String, String>();
|
||||
private Map<String, String> filenames = new HashMap<String, String>();
|
||||
private Editor editor;
|
||||
|
||||
public void init(Editor editor) {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
public String getMenuTitle() {
|
||||
return "nRF5 Flash SoftDevice";
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (!PreferencesData.get("target_platform").equals("nRF5")) {
|
||||
editor.statusError(getMenuTitle() + " is only supported on 'Nordic Semiconductor nRF5 Boards' boards!");
|
||||
return;
|
||||
}
|
||||
|
||||
Path softdeviceTxtPath = Paths.get(PreferencesData.get("runtime.platform.path"), "softdevices.txt");
|
||||
Properties softdevices = new Properties();
|
||||
|
||||
try {
|
||||
softdevices.load(new FileInputStream(softdeviceTxtPath.toString()));
|
||||
} catch (Exception e) {
|
||||
editor.statusError("Error while flashing SoftDevice.");
|
||||
System.err.println(e);
|
||||
return;
|
||||
}
|
||||
|
||||
String[] names = softdevices.getProperty("names").split(",");
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
String name = names[i];
|
||||
String url = softdevices.getProperty(name + ".url");
|
||||
String filename = softdevices.getProperty(name + ".filename");
|
||||
|
||||
urls.put(name, url);
|
||||
filenames.put(name, filename);
|
||||
}
|
||||
|
||||
String softDevice = PreferencesData.get("custom_softdevice");
|
||||
if (softDevice == null || softDevice.endsWith("none")) {
|
||||
editor.statusError("No SoftDevice selected!");
|
||||
return;
|
||||
}
|
||||
|
||||
String programmer = PreferencesData.get("programmer");
|
||||
if (programmer == null || !programmer.startsWith("sandeepmistry:")) {
|
||||
editor.statusError("Unsupported programmer!");
|
||||
return;
|
||||
}
|
||||
|
||||
softDevice = softDevice.substring(softDevice.lastIndexOf("_") + 1);
|
||||
String url = urls.get(softDevice);
|
||||
|
||||
if (url == null) {
|
||||
editor.statusError("Unsupported SoftDevice!");
|
||||
return;
|
||||
}
|
||||
|
||||
Path softdevicePath = Paths.get(PreferencesData.get("runtime.platform.path"), "cores", "nRF5", "SDK", "components", "softdevice", softDevice, "hex");
|
||||
Path softdeviceHexFile = Paths.get(softdevicePath.toString(), filenames.get(softDevice));
|
||||
|
||||
Runnable runnable = () -> {
|
||||
try {
|
||||
if (Files.notExists(softdeviceHexFile)) {
|
||||
System.out.println("Downloading '" +url + "' ...");
|
||||
|
||||
InputStream is = new URL(url).openStream();
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
|
||||
byte[] chunk = new byte[32 * 1024];
|
||||
int bytesRead;
|
||||
|
||||
while ((bytesRead = is.read(chunk)) > 0) {
|
||||
System.out.print(".");
|
||||
outputStream.write(chunk, 0, bytesRead);
|
||||
}
|
||||
|
||||
System.out.println("done");
|
||||
|
||||
ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(outputStream.toByteArray()));
|
||||
ZipEntry entry;
|
||||
|
||||
String licenseAgreementFilename = null;
|
||||
StringBuilder licenseAgreementBuilder = new StringBuilder();
|
||||
|
||||
String softdeviceFilename = null;
|
||||
StringBuilder softdeviceBuilder = new StringBuilder();
|
||||
|
||||
while ((entry = zis.getNextEntry()) != null) {
|
||||
if (entry.getName().endsWith("agreement.txt")) {
|
||||
licenseAgreementFilename = entry.getName();
|
||||
|
||||
for (int i = 0; i < entry.getSize(); i++) {
|
||||
licenseAgreementBuilder.append((char)zis.read());
|
||||
}
|
||||
} else if (entry.getName().endsWith("softdevice.hex")) {
|
||||
softdeviceFilename = entry.getName();
|
||||
|
||||
for (int i = 0; i < entry.getSize(); i++) {
|
||||
softdeviceBuilder.append((char)zis.read());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (licenseAgreementFilename != null) {
|
||||
JTextArea textArea = new JTextArea(licenseAgreementBuilder.toString());
|
||||
textArea.setColumns(80);
|
||||
textArea.setRows(50);
|
||||
textArea.setLineWrap(true);
|
||||
textArea.setWrapStyleWord(true);
|
||||
textArea.setSize(textArea.getPreferredSize().width, 1);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(textArea);
|
||||
scrollPane.setPreferredSize( new Dimension(textArea.getPreferredSize().width, 500 ) );
|
||||
|
||||
int result = JOptionPane.showOptionDialog(null, scrollPane, "NORDIC SEMICONDUCTOR ASA SOFTDEVICE LICENSE AGREEMENT", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[]{"Accept", "Decline"}, "Decline");
|
||||
|
||||
if (result != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Files.write(Paths.get(softdevicePath.toString(), licenseAgreementFilename), String.valueOf(licenseAgreementBuilder).getBytes());
|
||||
}
|
||||
|
||||
if (softdeviceFilename != null) {
|
||||
Files.write(Paths.get(softdevicePath.toString(), softdeviceFilename), String.valueOf(softdeviceBuilder).getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
Uploader uploader = new SerialUploader();
|
||||
if (uploader.burnBootloader()) {
|
||||
editor.statusNotice("Done flashing SoftDevice.");
|
||||
} else {
|
||||
editor.statusError("Error while flashing SoftDevice.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
editor.statusError("Error while flashing SoftDevice.");
|
||||
System.err.println(e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user