{"id":129,"date":"2019-01-04T14:07:08","date_gmt":"2019-01-04T04:37:08","guid":{"rendered":"https:\/\/sighmon.com\/says\/?p=129"},"modified":"2019-01-12T14:31:23","modified_gmt":"2019-01-12T05:01:23","slug":"upgrading-the-things-uno-rn2903-firmware","status":"publish","type":"post","link":"https:\/\/sighmon.com\/says\/upgrading-the-things-uno-rn2903-firmware\/","title":{"rendered":"Upgrading The Things Uno RN2903 firmware"},"content":{"rendered":"\n<p>It turns out that it wasn&#8217;t only the range that might have been causing my connection problems to The Things Network &#8211; Andrew Sargent from OpenSensing spotted that in my logs the LoRaWAN RN2903 chip was reporting a firmware version 0.9.5 whereas the version needed to connect is 1.0.3<\/p>\n\n\n\n<p>I&#8217;m on macOS, so ideally wanted to use my mac to upgrade the firmware. Here are the steps that I followed:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Download the Microchip Development Suite software and install just the Application: <a href=\"https:\/\/www.microchip.com\/DevelopmentTools\/ProductDetails\/DV164140-2\">https:\/\/www.microchip.com\/DevelopmentTools\/ProductDetails\/DV164140-2<\/a><\/li><li>Install Java8 to run it via <a href=\"https:\/\/brew.sh\">Homebrew<\/a>: $ brew cask install java8<ul><li>You may also need to tap versions first if you haven&#8217;t already: $ brew tap caskroom\/versions<\/li><\/ul><\/li><li>Find that java8 installation (I also have a new version of Java I didn&#8217;t want to disrupt): $ \/usr\/libexec\/java_home -v 1.8<\/li><li>Download the new RN2903 SA1.0.3 firmware (Hex) from: <a href=\"https:\/\/github.com\/TheThingsNetwork\/arduino-device-lib\/files\/1899025\/RN2903.SA1.0.3.Hex.zip\">https:\/\/github.com\/TheThingsNetwork\/arduino-device-lib\/files\/1899025\/RN2903.SA1.0.3.Hex.zip<\/a><\/li><li>Upload the PassThrough sketch using the Arduino IDE to The Things Uno so that we can talk directly to the RN2903: <\/li><li>File > Examples > TheThingsNetwork > PassThrough<\/li><li>Back in Terminal, cd into the directory with LoRaDevUtility.jar<\/li><li>Run the Microchip utility: $ \/Library\/Java\/JavaVirtualMachines\/jdk1.8.0_192.jdk\/Contents\/Home\/bin\/java -jar LoRaDevUtility.jar<\/li><li>Click &#8216;RN Module 0&#8217; from the left.<\/li><li>Click the DFU tab.<\/li><li>Upload the new firmware.<\/li><\/ul>\n\n\n\n<p>Unfortunately clicking the &#8216;Select File:&#8217; button causes a Java exception on the mac:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Exception in thread \"JavaFX Application Thread\" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException\n\tat javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)\n...\nCaused by: java.lang.IllegalArgumentException: Folder parameter must be a valid folder\n\tat com.sun.glass.ui.CommonDialogs.convertFolder(CommonDialogs.java:238)\n\tat com.sun.glass.ui.CommonDialogs.showFileChooser(CommonDialogs.java:190)\n\tat com.sun.javafx.tk.quantum.QuantumToolkit.showFileChooser(QuantumToolkit.java:1496)\n\tat javafx.stage.FileChooser.showDialog(FileChooser.java:416)\n\tat javafx.stage.FileChooser.showOpenDialog(FileChooser.java:350)\n\tat fed.FEDFXMLController.onFileBrowse(FEDFXMLController.java:7049)\n\t... 83 more\n<\/code><\/pre>\n\n\n\n<p>Decompiling the .jar, I found this in DFUFXMLController.java<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@FXML\n  void onFileBrowse()\n  {\n    try {\n      fileOpenDialog.setInitialDirectory(new File(Preferences.userNodeForPackage(getClass()).get(\"FilePath\", \"C:\\\\\")));\n      fileOpenDialog.getExtensionFilters().add(new javafx.stage.FileChooser.ExtensionFilter(\".hex\", new String[] { \"*.hex\" }));\n      File fileChosen = fileOpenDialog.showOpenDialog(application.getViewer().getScene().getWindow());\n      \n      if (fileChosen != null) {\n        selectedFile.setText(fileChosen.getName());\n        if (application.device.updateValueFlag) {\n          application.device.dfuPojo.setHexFileName(fileChosen.getAbsolutePath());\n        }\n        Preferences.userNodeForPackage(getClass()).put(\"FilePath\", fileChosen.getAbsolutePath().substring(0, fileChosen.getAbsolutePath().indexOf(fileChosen.getName())));\n      }\n    } catch (IllegalArgumentException ex) {\n      if (ex.getMessage().contains(\"Folder parameter must be a valid folder\")) {\n        fileOpenDialog.setInitialDirectory(new File(\"C:\\\\\"));\n        fileOpenDialog.getExtensionFilters().add(new javafx.stage.FileChooser.ExtensionFilter(\".hex\", new String[] { \"*.hex\" }));\n        File fileChosen = fileOpenDialog.showOpenDialog(application.getViewer().getScene().getWindow());\n        \n        if (fileChosen != null) {\n          selectedFile.setText(fileChosen.getName());\n          if (application.device.updateValueFlag) {\n            application.device.dfuPojo.setHexFileName(fileChosen.getAbsolutePath());\n          }\n          Preferences.userNodeForPackage(getClass()).put(\"FilePath\", fileChosen.getAbsolutePath().substring(0, fileChosen.getAbsolutePath().indexOf(fileChosen.getName())));\n        }\n      }\n    }\n  }<\/code><\/pre>\n\n\n\n<p>So it looks like C:\\\\ is hardcoded as the default location, which appears to be why it&#8217;s failing unless there&#8217;s a default path set (which there isn&#8217;t on first run).<\/p>\n\n\n\n<p>This was reported to <a href=\"https:\/\/www.microchip.com\/forums\/m952860.aspx\">Microchip in 2016<\/a> so is unlikely to be fixed anytime soon.<\/p>\n\n\n\n<p>Leo <a href=\"https:\/\/www.gaggl.com\/2018\/04\/microchip-lorawan-development-utility-on-ubuntu\/\">found a solution for Linux<\/a> by adding a default FilePath entry, so I used that to add a default entry for macOS:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Open a finder window: $ open ~\/Library\/Preferences\/<\/li><li>Search for com.apple.java.util.prefs in the finder window.<\/li><li>Right-click to open com.apple.java.util.prefs.plist in Xcode<\/li><li>Create a &#8216;Dictionary&#8217; entry for fed\/ and dfu\/<\/li><li>Add a &#8216;String&#8217; entry for FilePath with the value \/Users\/&lt;your username&gt;\/ under fed\/ and dfu\/<\/li><li>Save and close.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"993\" src=\"https:\/\/sighmon.com\/says\/wp-content\/uploads\/2019\/01\/java-plist-macos-1024x993.png\" alt=\"\" class=\"wp-image-130\" srcset=\"https:\/\/sighmon.com\/says\/wp-content\/uploads\/2019\/01\/java-plist-macos-1024x993.png 1024w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2019\/01\/java-plist-macos-300x291.png 300w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2019\/01\/java-plist-macos-768x744.png 768w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2019\/01\/java-plist-macos-1568x1520.png 1568w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2019\/01\/java-plist-macos.png 1824w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Adding default FilePath values for Java on macOS<\/figcaption><\/figure>\n\n\n\n<p>Now you should be able to run the Microchip utility and select the firmware to upload: $ \/Library\/Java\/JavaVirtualMachines\/jdk1.8.0_192.jdk\/Contents\/Home\/bin\/java -jar LoRaDevUtility.jar<\/p>\n\n\n\n<p>Don&#8217;t do what I did and select the unzipped folder, instead copy the file RN2903_Parser.production.unified.hex to the Desktop and select it from there.<\/p>\n\n\n\n<p>If you <strong>did<\/strong> try and flash the folder and it failed and won&#8217;t connect anymore, fear not &#8211; you can select Module &gt; Boot Load Recover. And select the other hex file: RN2903_Parser.production.hex to recover. &#x1f60a; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It turns out that it wasn&#8217;t only the range that might have been causing my connection problems to The Things Network &#8211; Andrew Sargent from OpenSensing spotted that in my logs the LoRaWAN RN2903 chip was reporting a firmware version 0.9.5 whereas the version needed to connect is 1.0.3 I&#8217;m on macOS, so ideally wanted &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/sighmon.com\/says\/upgrading-the-things-uno-rn2903-firmware\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Upgrading The Things Uno RN2903 firmware&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11,27,26,25,28],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-arduino","tag-firmware","tag-rn2903","tag-the-things-uno","tag-upgrade","entry"],"_links":{"self":[{"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":7,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":303,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/posts\/129\/revisions\/303"}],"wp:attachment":[{"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}