1

I bought a nodeMCU 8266 and I'm hoping that it can replace my bulkier UNO+WiFi 101.

I'm getting an error when I compile: Error: unknown opcode or format name 'jmp'

I'm using it in void SoftReset() function:

void softReset() {
  delay(1000);
  asm volatile ("  jmp 0");
}

This reset works great with my Uno+101 setup but, for whatever reason, doesn't like the ESP8266. I removed the WiFi101 library and added the ESP8266 WiFi libraries. That has been the only change.

Can you please help me understand why I'm receiving this error?

EDIT: I have read this SO answer but the "syntactical sugar" didn't work for me.

I am also perusing various ESP8266 sites but they are not as well managed as SE/SO and answers are tough to find.

2 Answers 2

5

The proper way to reset the esp8266 when using the Arduino IDE is to call ESP.reset(). You may need to #include <Esp.h>, but almost all esp8266 headers you include to use any of its functionality will have included it already.

1

The ESP8266 is not an Arduino Uno. It talks a completely different language.

It's like you're talking Spanish to a Chinese person. It can't understand you.

If you want to use assembly language then you have to use the assembly language of the chip you are programming for - not the assembly language of a completely different chip.

The assembly language is detailed here: http://techblog.realisaatio.fi/wp-content/uploads/2015/04/xtensalx_overview_handbook.pdf

Bear in mind, though, that jumping to 0 may not reset the device - it may do something nasty.

The only sure-fire way of resetting a chip where you don't really know what is going on inside is to connect a GPIO signal to the RESET pin and use that GPIO to pull RESET low and reset the board that way.

If you want to call address 0 and don't know how to do it in assembly there are ways of arranging it in C using a function pointer:

void (*addressZero)() = 0;

void setup() {
    addressZero(); // Call address 0
}

void loop() {
}

That way it will work on multiple different architectures without having to understand the underlying assembly language. That, of course, is assuming that calling address 0 is a valid way of resetting the board on the target chip.

Browsing through the document I link to above it looks most likely that you would first have to load a register with 0 and then use JX to jump to the address stored in the register (i.e., zero).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.