ESP32 Arduino upload java.lang.NullPointerException error

Viewed 1153

I am trying to build the simplest example (blink project) on Arduino 1.8.16 using a ESP32 based board (Espduino compatible). It builds correctly but I am not able to upload to the board. I verified that the CH340 driver is loaded and works (I am able to build and upload the same project using platformio) so seems that the problem is related to Arduino IDE 1.8.x. I tryed both a standard installation and a portable installation but both do not work. I also searched the net for help but until know no solution I found solved the problem.

This is the error I have:

java.lang.NullPointerException at cc.arduino.packages.uploaders.SerialUploader.uploadUsingProgrammer(SerialUploader.java:295) at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:90) at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77) at processing.app.SketchController.upload(SketchController.java:732) at processing.app.SketchController.exportApplet(SketchController.java:703) at processing.app.Editor$UploadHandler.run(Editor.java:2061) at java.lang.Thread.run(Thread.java:748)

any help will be appreciated.

1 Answers

It's a bit difficult to diagnose just from this message; I assume you are using https://github.com/arduino/Arduino/blob/master/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java; in line 295 we have:

PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer);

A NullPointerException would eg be triggered if targetPlatform was null. Are you sure you have the right settings there?

Update: the value for the target platform is retrieved here:

  static public TargetPlatform getTargetPlatform() {  
    String packageName = PreferencesData.get("target_package");  
    String platformName = PreferencesData.get("target_platform");  
    return getTargetPlatform(packageName, platformName);  
  }

My suggestion would be to look at those parameters in the configuration.

Related