Page 1 of 2

[SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Sun Aug 09, 2020 12:32 pm
by Mano
Hi all,

just in case anyone encounters the same problem i had...
I successfully used Arduino UI to program my bluepill board using "STM32duino bootloader" (which i serial-loaded to the board before).
After some weeks of playing around with other boards i found that uploading a sketch resulted in

C:\Users\xyz\Documents\Arduino\hardware\Arduino_STM32/tools/win/maple_upload.bat COM12 2 1EAF:0003 C:\Users\xyz\AppData\Local\Temp\arduino_build_457508/Blink.ino.bin

# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000007110b5db, pid=12636, tid=0x0000000000003c0c
#
# JRE version: Java(TM) SE Runtime Environment (8.0_261-b12) (build 1.8.0_261-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.261-b12 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [jSSC-2.8_x86_64.dll+0xb5db]

a bit down in the crash log i found:

Internal exceptions (2 events):
Event: 0.024 Thread 0x0000022c00dd4000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class; name or signature does not match> (0x000000066b187cc0) thrown at [C:\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u261\295\hots
Event: 0.024 Thread 0x0000022c00dd4000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.prefetchRead(Ljava/lang/Object;J)V name or signature does not match> (0x000000066b187fa8) thrown at [C:\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u261\295\hotspot\src\share\vm\p

Events (10 events):
Event: 0.067 loading class jssc/SerialPort$LinuxEventThread
Event: 0.067 loading class jssc/SerialPort$LinuxEventThread done
Event: 0.067 loading class jssc/SerialPortTimeoutException
Event: 0.067 loading class jssc/SerialPortTimeoutException done
Event: 0.067 loading class java/lang/NoSuchMethodException


Updating libraries and reading a bit i found that arduino should come with its own java version and use that... unfornately, that doesn't appy to the maple_upload.bat!

My "default" java installation currenty is java 1.8.0.261.
If found that the latest Arduino IDE 1.8.13 comes with java 1.8.0_191.

I patched the maple_upload.bat (from 2018, which seems to be the latest version...) to use the Arduino java instead of the default one:

set JAVAPATH=C:\Program Files (x86)\Arduino\java\bin\
%driverLetter%
cd %~dp0
"%JAVAPATH%java" -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

With the patched version uploading a sketch works again.

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Sun Aug 09, 2020 5:46 pm
by mrburnette
Mano wrote: Sun Aug 09, 2020 12:32 pm ...
I successfully used Arduino UI to program my bluepill board using "STM32duino bootloader" (which i serial-loaded to the board before).
After some weeks of playing around with other boards i found that uploading a sketch resulted in

C:\Users\xyz\Documents\Arduino\hardware\Arduino_STM32/tools/win/maple_upload.bat COM12 2 1EAF:0003 C:\Users\xyz\AppData\Local\Temp\arduino_build_457508/Blink.ino.bin

# A fatal error has been detected by the Java Runtime Environment:
...
https://forum.arduino.cc/index.php?topic=655780.0
You don't need to install Java because the Arduino IDE comes bundled with its own JRE, so it runs independently from whatever Java you might have installed separately.
Arduino is packaged with the appropriate JAVA and is not actually "installed" outside the Arduino environment. After installing ArduinoIDE on Windows 10 Pro, JRE will not appear in the Path. Installing Java separately on Windows will create a "default" JAVA install but will not be used by ArduinoIDE. The two JAVA/JRE are intended to be separate.

Yes, you can force Arduino to use a default installation of JAVA, but you take on the full responsibility of future support issues as you have created a non-standard environment.


Ray

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Mon Aug 10, 2020 11:11 am
by Mano
Hi Ray,

you are right. However, the maple_upload.bat used by the stm32duino environment in the default version just calls:

java -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

This invokes whichever java is in the path, which is usally the one "installed" outside the arduino environment, and regulary updated.
I just modified the maple_upload.bat to use the Ardunio java instead.

Mano

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Mon Aug 10, 2020 3:05 pm
by mrburnette
Mano wrote: Mon Aug 10, 2020 11:11 am ...
However, the maple_upload.bat used by the stm32duino environment in the default version just calls:

java -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
...
Mano,

What is "supposed" to happen is that the JAVA ArduinoIDE code should call the batch file from within the GUI environment; said call-out effectively shelling the maple_upload.bat and executing the code in an environment which has the JAVA path currently being used by Arduino... a private, encapsulated environment. In this way, batch scripts under Arduino respect the Arduino installed version of JAVA and not the global "default" version.

Your edit of maple_upload.bat defeats that design objective. As a test, add the one line before "java -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9" and then check out the results in Ard_env.txt After you use the ArduinoIDE to upload to a MM board.

Code: Select all

echo %path% > Ard-env.txt
Baseline path from CMD prompt:
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\Ray\AppData\Local\Microsoft\WindowsApps;


Path written to Ard_env.txt being called from within the IDE:
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\Ray\AppData\Local\Microsoft\WindowsApps;;C:\Program Files (x86)\Arduino\java\bin

You will note the IDE appends the JAVA path to the environment variable.

Code: Select all

@echo off
rem: Note %~dp0 get path of this batch file
rem: Need to change drive if My Documents is on a drive other than C:
set driverLetter=%~dp0
set driverLetter=%driverLetter:~0,2%
%driverLetter%
cd %~dp0
echo %path% > Ard-env.txt
java -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

for /l %%x in (1, 1, 40) do (
  ping -w 50 -n 1 192.0.2.1 > nul
  mode %1 > nul
  if ERRORLEVEL 0 goto comPortFound
)

echo timeout waiting for %1 serial

:comPortFound

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Thu Aug 13, 2020 11:45 am
by Mano
Hi Mrburnette,

thanks for your explanation. That actually makes sense, however that doesn't seem to work if you also have a "normally" installed java.

My normal path (with linebreaks for readability, and omission of the various non-java paths):

Code: Select all

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
...
C:\Users\xyz\AppData\Local\Microsoft\WindowsApps;
C:\Users\xyz\AppData\Roaming\npm;
My path as dumped from the Maple_Upload.bat into Ard_env.txt:

Code: Select all

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
...
C:\Users\xyz\AppData\Local\Microsoft\WindowsApps;
C:\Users\xyz\AppData\Roaming\npm;
;
C:\Program Files (x86)\Arduino\java\bin 
The arduino java is appended to the REAR of the path. Howver the normal java installation allready is (and stays) in front of the path. Windows will use the first path containing a java.exe, which is the normal installation. The arduino java would have to be added in FRONT of the original path to work.

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Thu Aug 13, 2020 11:16 pm
by mrburnette
Mano wrote: Thu Aug 13, 2020 11:45 am ...
The arduino java is appended to the REAR of the path. Howver the normal java installation allready is (and stays) in front of the path. Windows will use the first path containing a java.exe, which is the normal installation. The arduino java would have to be added in FRONT of the original path to work.
You can set a new path in the batch file switching the Arduino java ahead of the system one.

https://www.windows-commandline.com/set ... mand-line/
...and...
https://stackoverflow.com/questions/683 ... -executing

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Wed Oct 07, 2020 6:57 am
by tkdzmusyb
mrburnette wrote: Thu Aug 13, 2020 11:16 pm You can set a new path in the batch file switching the Arduino java ahead of the system one.
That's the solution described in the original post.

@Mano:

I was having the same issue, but after successfully uploading to the bluepill once, it now enumerates as "Maple 003" but not as VCP (USB serial port), so uploading fails.
The Arduino IDE apparently does something differently, as I can upload repeatedly (I have to hit the reset button, but the COM port is there after flashing). I have also used the Arduino IDE to "recover" the bluepill after the initial flashing with PlatformIO.
You wouldn't happen to know anything about a solution for that as well, do you? :D

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Wed Oct 07, 2020 11:24 am
by tkdzmusyb

Code: Select all

board_build.core = maple
did the trick.
Also see https://community.platformio.org/t/can- ... dfu/6431/7

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Tue Jan 19, 2021 8:19 am
by Phono
I am facing this problem now. After reading all the posts of this thread, I am a bit puzzled. Solutions have been given which work, but what is the "official" solution? The one that would preserve the integrity of the IDE?
Actually this problem is not very troublesome. I still can upload a sketch provided I set the board in perpetual bootloader mode using the buttons. However, I would like to fix this problem properly.

Re: [SOLVED] Maple_Upload.bat : EXCEPTION_ACCESS_VIOLATION

Posted: Tue Jan 19, 2021 9:03 am
by stevestrong
Actually, this should have been fixed by this commit: https://github.com/rogerclarkmelbourne/ ... 6f538824d9
If you have already this fix, can you please post your complete error log?