3

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.

Jerzy D.
  • 6,707
  • 2
  • 16
  • 22
Massimo Manca
  • 385
  • 1
  • 2
  • 15

2 Answers2

0

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.

Oliver Mason
  • 2,240
  • 2
  • 15
  • 23
  • Well... I agree... seems that I should have a wrong setup but not in the part I can set by myself. I have the board connected to COM6 and I am sure it is right, I set also COM6 for different baud rates and so on. On the tools menu there is no programmer set (No programmer available for this board). – Massimo Manca Oct 12 '21 at 14:31
  • I was wondering if the board type is set correctly, if you're using a compatible (but not explicitly listed) board. – Oliver Mason Oct 12 '21 at 14:32
  • and if I try to write the bootloader it returns also an error: Arduino:1.8.16 (Windows 10), Scheda:"DOIT ESPduino32, 40MHz, 115200, None" java.lang.NullPointerException at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(SerialUploader.java:329) at processing.app.Editor.lambda$handleBurnBootloader$61(Editor.java:2385) at java.lang.Thread.run(Thread.java:748) Errore durante la scrittura del bootloader – Massimo Manca Oct 12 '21 at 14:33
  • @MassimoManca That is the `platform` again... – Oliver Mason Oct 12 '21 at 14:40
  • OK, the point is that with DOIT Espduino32 does not work but changing the board with another model it works, for instance using DOIT ESP32 DEVKIT V1 it works. Honestly I can not understand why... apparently the only difference is the content of pins_arduino.h that are compatible, written in 2 different ways but the content is compatible and does not seem related to the problem. May be that the IDE uses other files as a specific bootloader or anything else automatically without the possibility to set it. Well... I think at the moment I will edit a little bit the .h file – Massimo Manca Oct 12 '21 at 14:46
0

hey man hope this comes good, as a matter of fact is quite cryptic what is happening, i always solve it with changing the port in which my esp-32 is on and then switch it back again to its correct port , ALWAYS WORKS! ;)

viani
  • 16