Atom with ESP8266 WiFi connects to the internet

discussion of games, software, hardware & emulators relating to the Acorn Atom
User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Atom with ESP8266 WiFi connects to the internet

Postby roland » Sun Nov 27, 2016 1:58 pm

My wifi seems to be completely broken. Both the original and the new version don't give any answers. Sometimes I don't even see the blue leds blink when sending an AT command. The ESP does accept commands from the terminal program. I'll try to figure out what's going on here - later today....
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6479
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Atom with ESP8266 WiFi connects to the internet

Postby hoglet » Sun Nov 27, 2016 3:20 pm

Hi Kees,
oss003 wrote:Yes, I noticed this also. I wrote this terminal program originally to communicate with a PC serial port as I demonstrated in Manchester:

http://www.retrosoftware.co.uk/wiki/ind ... csHBGW2012

It was used to display typed characters for serial communication which is very slow.
I think that the program can be improved to use the same technique as Type Ahead (keybord buffer) does.
This means buffering the input and the output to speed things up.

I agree.

The reason the current TERM program is dropping characters above 1200 baud is that it is trying to print the received character in the ISR.

One way to improve this would be to use a circular buffer, maybe 8KB, then make the ISR as simple as possible:

Code: Select all

new_intvec:
    lda VIA_t1cl        ; 4     4
    lda UART_control    ; 4     4
    and #2              ; 2     2
    bne return          ; 2     3
    tya                 ; 2
    pha                 ; 3
    ldy #0              ; 2
    lda UART_data       ; 4
    sta (wrtptr), Y     ; 6   
    inc wrtptr          ; 5
    bne nocarry         ; 2
    lda wrptr + 1       ; 3
    clc                 ; 2
    adc #1              ; 2
    and #&E0            ; 2
    sta wrptr + 1       ; 3
nocarry:
    pla                 ; 4
    tay                 ; 2
return:
    pla                 ; 4     4
    rti                 ; 6     6
                        ; --    --
                        ; 64    23
                        ; --    --

The 6502 interrupt latency of 7 cycles needs adding to the above.

You could use free-running mode of the 6522 T1 to avoid having to reload each time.

At 115,200 baud characters are coming in every 86us, so that might just be achievable. It certainly would at 2MHz, or if the code was optimized for a 65C02.

Of course, it would be even better still if the GODIL generated an interrupt!

Dave

User avatar
hoglet
Posts: 6479
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Atom with ESP8266 WiFi connects to the internet

Postby hoglet » Sun Nov 27, 2016 4:15 pm

Roland,

I've updated to the same firmware as you now.

Here's my notes on how I did that (on Linux)...

Download the python esptool:

Code: Select all

git clone https://github.com/themadinventor/esptool.git
cd esptool

Download the firmware zip:

Code: Select all

wget -O at_v0.20_14_11_28.zip http://bbs.espressif.com/download/file.php?id=84

Power up the ESP8266 with GPIO0 grounded.

Test the esptool:

Code: Select all

./esptool.py --port /dev/ttyUSB0 --baud 115200 read_mac
esptool.py v1.3-dev
Connecting...
MAC: 5c:cf:7f:cb:63:3a

Backup the existing firmware in case of disaster:

Code: Select all

./esptool.py --port /dev/ttyUSB0 --baud 115200 read_flash 0x00000 0x80000 orig.bin
esptool.py v1.3-dev
Connecting...
Running Cesanta flasher stub...
Reading 524288 @ 0x0... 524288 (100 %)
Read 524288 bytes at 0x0 in 50.3 seconds (83.4 kbit/s)...

Power cycle, and again power up the ESP8266 with GPIO0 grounded.

Test the esptool:

Code: Select all

./esptool.py --port /dev/ttyUSB0 --baud 115200 read_mac
esptool.py v1.3-dev
Connecting...
MAC: 5c:cf:7f:cb:63:3a

Install new firmware:

Code: Select all

cd at_v0.20_on_SDKv0.9.3/
../esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash 0x00000 ./bin/boot_v1.1.bin 0x01000 ./bin/user1.bin 0x41000 ./bin/user2.bin 0x7c000 ./bin/esp_init_data_default.bin 0x7e000 ./bin/blank.bin
esptool.py v1.3-dev
Connecting...
Auto-detected Flash size: 4m
Running Cesanta flasher stub...
Flash params set to 0x0000
Writing 4096 @ 0x0... 4096 (100 %)
Wrote 4096 bytes at 0x0 in 0.4 seconds (89.5 kbit/s)...
Writing 221184 @ 0x1000... 221184 (100 %)
Wrote 221184 bytes at 0x1000 in 19.2 seconds (92.0 kbit/s)...
Writing 221184 @ 0x41000... 221184 (100 %)
Wrote 221184 bytes at 0x41000 in 19.2 seconds (92.0 kbit/s)...
Writing 4096 @ 0x7c000... 4096 (100 %)
Wrote 4096 bytes at 0x7c000 in 0.4 seconds (89.7 kbit/s)...
Writing 4096 @ 0x7e000... 4096 (100 %)
Wrote 4096 bytes at 0x7e000 in 0.4 seconds (89.6 kbit/s)...
Leaving...

Disconnect GPIO0 from ground, and power cycle.

After doing this, I now have:

Code: Select all

AT+GMR
0020000903

OK

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Atom with ESP8266 WiFi connects to the internet

Postby roland » Sun Nov 27, 2016 5:26 pm

Does this "new" firmware show any changes? I'm going to get my module back working again....
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6479
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Atom with ESP8266 WiFi connects to the internet

Postby hoglet » Sun Nov 27, 2016 5:35 pm

roland wrote:Does this "new" firmware show any changes? I'm going to get my module back working again....

It seems to crash a bit less often.

I can now set the baud rate with AT+IPR=

It still seems to run your test program just fine at 115,200 baud.

Dave

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Atom with ESP8266 WiFi connects to the internet

Postby roland » Sun Nov 27, 2016 7:00 pm

I am really stuck with this module. The only way it communicates is with the Atom Term program. It won't communicate with minicom, nor with the wifi commands we're writing. If I test with esptool I only get connection errors (baud rate not correct) or invalid response errors (baud rate is correct).

The USB-to-serial module is all right: I connected the Atom to the laptop and I could send and receive characters in both directions.

Time for a new ESP module?
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6479
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Atom with ESP8266 WiFi connects to the internet

Postby hoglet » Sun Nov 27, 2016 7:10 pm

roland wrote:I am really stuck with this module. The only way it communicates is with the Atom Term program. It won't communicate with minicom, nor with the wifi commands we're writing. If I test with esptool I only get connection errors (baud rate not correct) or invalid response errors (baud rate is correct).

Do you get any echoing of characters in minicom (or gtkterm)?

Are you remembering to also type ^J after pressing return?

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Atom with ESP8266 WiFi connects to the internet

Postby roland » Mon Nov 28, 2016 7:29 am

Nope, when I type in some characters they are not echoed back, so there is no response from the ESP. Sometimes it gets in a loop and I can see it displaying some garbage characters and the word ready. Today I haven't time for it and tomorrow I will first check the wires, maybe there's something wrong with them. But still, why does it work with the Atom terminal and not with the wifibox commands? Questions and challenges :?
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6479
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Atom with ESP8266 WiFi connects to the internet

Postby hoglet » Mon Nov 28, 2016 4:06 pm

Hi Guys,

I've done a bit of work on the terminal program this afternoon:
- added a circular receive buffer, so that speeds of up to 115200 baud work
- added support for VGA 80.

It's a bit snappier at 2MHz, but does work correctly at 1MHz.

I've added the code to github, so we can better track changes:
https://github.com/hoglet67/term2015/commits/master

Here's a quick build to out:
term2015.zip
(1.99 KiB) Downloaded 15 times

Dave

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Atom with ESP8266 WiFi connects to the internet

Postby roland » Mon Nov 28, 2016 4:34 pm

Damn ... I have to work this evening otherwise I could test if my ESP works better with this terminal :(
I'll try it soon!
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Atom with ESP8266 WiFi connects to the internet

Postby roland » Fri Dec 02, 2016 10:39 pm

This evening at the Atom User Group meeting I tried the new terminal program. It works much better now but I still can't get a full list of available wireless networks. And also my own routines still are not working. I guess I have to take out my logic analyser to find out what's going on in these wires...
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6479
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Atom with ESP8266 WiFi connects to the internet

Postby hoglet » Sat Dec 03, 2016 1:11 pm

Hi Roland,
roland wrote:This evening at the Atom User Group meeting I tried the new terminal program. It works much better now but I still can't get a full list of available wireless networks. And also my own routines still are not working. I guess I have to take out my logic analyser to find out what's going on in these wires...

I'm sorry to hear you are still having problems.

What speed is your Atom running at (I've mostly been testing at 1MHz)?

Could you post an example of a corrupted AT+CWLAP command?

I'm wondering if there are any clues in the pattern of corruption.

If fact, could you post the results of the same command three times?

Also, if you connect the ESP8266 Tx wire to a TTL (or 3.3v) level USB serial adapter at the same time, does the response come through correctly?

Dave

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Atom with ESP8266 WiFi connects to the internet

Postby roland » Sun Dec 04, 2016 7:30 pm

I have connected my ESP to both my Atom and my laptop. The output from the ESP seems to be wrong:

IMG_1637.JPG


minicom.png


I also managed to get the wifibox working for a little while, but it wasn't stable. Still lost characters and incomplete data transfers. The baud rate is 1200 and the Atom running at both 1 and 2 MHz, no different behaviour.

I can't imagine that my read routines are too slow. They do nothing but storing data into memory and when after some time no more data is received, it starts printing. I'll have a look into the new term communication routines.
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6479
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Atom with ESP8266 WiFi connects to the internet

Postby hoglet » Sun Dec 04, 2016 8:24 pm

Hi Roland,

So you are getting the same output on the Atom and the PC terminal. Interesting.

It looks like your ESP8266 is crashing and rebooting half way through each AT+CWLAP command.

The clue is the garbage then the "ready"

During reset, the serial speed is initially 115,200 baud, and only at the end does it drop down to your configured baud rate. So the garbage you see is the reset message, at the wrong baud rate.

This looks to me like your firmware needs re-flashing.... Or maybe there are just too many Wifi networks, I've only got three within range.

If you switch to 115200 baud (AT+IPR=115200) then you will probably see all of the reset message, and it will be clearer what's going on.

Dave

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Atom with ESP8266 WiFi connects to the internet

Postby roland » Sun Dec 04, 2016 8:58 pm

This is the result at 115200 baud :shock:

IMG_1639.JPG


So it looks that transmitting at 1200 baud is faulty in the module. With too much data the transmit buffer overflows which make the ESP8266 crash. At least, that's what it seems to me...
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6479
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Atom with ESP8266 WiFi connects to the internet

Postby hoglet » Sun Dec 04, 2016 9:00 pm

roland wrote:So it looks that transmitting at 1200 baud is faulty in the module. With too much data the transmit buffer overflows which make the ESP8266 crash. At least, that's what it seems to me...

I did try running mine at 1200 baud, and it was fine, but I didn't have so many wireless networks visible.

But good to see it wasn't the Atom side that was faulty!

Dave


Return to “acorn atom”

Who is online

Users browsing this forum: No registered users and 2 guests