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.

3

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.

2

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).

  • The answer here (arduino.stackexchange.com/questions/19985/…) seems to disagree. Specifically, my question: "Is using the Arduino IDE with a fresh out of the box ESP8266 as simple as compiling and uploading or do you need to "clean out" the ESP first? I've held off on buying an ESP because I'm not clear on what I need to do to make it work with the Arduino IDE." Answered: "Yes, you just compile and upload...." – acpilot Jun 13 '16 at 23:51
  • Compiling C is not assembling ASM code. The two are very different. When you compile C it first converts it into the assembly code of your target chip. Each chip family has its own compiler that creates the ASM code that is specific to that chip. – Majenko Jun 13 '16 at 23:52
  • In my experience, the ESP8266 is very particular about what you do in the loop function - running while(true); will (OK, may, I've never done this) trigger a reboot (eventually, matter of a few seconds I think) - – Jaromanda X Jun 13 '16 at 23:55
  • @JaromandaX That is probably the watchdog I would guess. It may well be enabled by default on there. – Majenko Jun 13 '16 at 23:55
  • 1
    That is correct. As long as you stick to c and c++ using the Arduino API and the libraries written for the ESP8266 all will be well. – Majenko Jun 14 '16 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.