Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Lademeister
#66886 Just got my hands on A20 chip itself and on a A20 breakoutboard (the one with DIP switches).
I took me a while to figure out how to flash it because documentation is rare - especially as most information is in Chinese.
Below you will find what you all are searching for.

I am able to flash as well the AI-Thinker A20 chip alone and also the breakout-board.
The A20 has an internal ESP8285 chip. The ESP8285 can communicate with the internal GSM part using AT commands. You need to establish a connection between serial (or software serial) pins of internal ESP8285 and the serial pins of the GSM part (modem), if you want to control GSM login and SIM card within the A20 chip itself.

You can also control the GSM part via AT commands directly from your computer, in my case a RaspberryPi.

Flashing A20's internal ESP8285:
This one can be programmed same way as the ESP8285 on Wemos D1 mini Lite (small difference to ESP8266!!)
So this is how you do it, I hope you guys program a lot so I can copy back :-)

How to flash A20:
In arduino IDE select "generic ESP8285" as board
Baud rate 115200 worked, but not always, so I used 57600.
All dip switches off (in case you have the board and not the chip alone)
Small hint I f you have the A20board: the data pins on the boards USB connector are NOT connected, the USB port is for power only. You need an extra USB/Serial adapter (less than 1$ on Ali express) or any other serial port like on RaspberryPi.

Connections you have to make for flashing the A20:
Wf_RXd to USB/serial adapter RX
Wf_TXd to USB/serial adapter TX
Wf_io0 = low
Wf_RST = high 5kOhm to 3.3V - do not connect it to USB/serial adapter's RST pin if it has one!
Wf_io15 = low
Wf_io2 = high 5kOhm to 3.3V (update: not necessary, but flashing might fail if something like an LED is connected to GPIO2 during flashing procedure!)
Then:
Power on 5V (and 3.3V to the corresponding Pin on A20 chip if you have the chip alone without board) - e.g. use 5V and 3.3V from external USB/serial adapter CH340. For the A20 breakout board you only need to connect +5V.
When flashing is complete, switch Wfio0 to 3.3V high and remove WfRST from high and let it open (last step might be optional but seems to be necessary some times I tried)
Then repower

What about the DIP switches on the board?
A20 GPS GSM Board (breakoutboard) with dip switches:
Dip switches: 2,4 ON: Wfio13 and Wfio15 of A20's internal ESP8285 are connected to the Serial Pins of GPRS part of the A20 Chip to control it with AT commands:
Wfio 13 --> UART_TXD
Wfio15 --> UART_RXD
(This is what you want to enable to control GSM from internal ESP8285)
BE CAREFUL: this means that you use GPIO13 and GPIO15 of ESP8285 for serial communication, you have to do (UPDATE: either SoftwareSerial which works great!) or Serial.swap(); in setup section of your sketch to use the other hardware serial.
Here comes something I dit not figure out yet about the hardware serial ports: ESP8285 should have three hardware serials: Wf_RXD,Wf_TXD and Wf_io13, and as a third hardware serial port Wf_io15 as TX only.
But I was only able to get running the following:
Serial.begin(115200);
Serial1.begin(115200);
Serial.swap();
This results in a serial RX/TX connection to A20 chip to control it with AT commands on Wf_io13 and Wf_io15 (when DIP switches 2 and 4 are ON) and in a serial output on Wf_io04 (TX only). I did not manage to get both bidirectional hardware serials to work at the same time. Serial0.begin(115200); does not work, nor Serial2.begin(115200);

DIP Switches 5 and 6 control whether the GPIO13 and GPIO15 of the ESP8285 are also connected to the pins on the breakoutboard.
GPIO13->Pin "Wfio13" on breakoutboard
GPIO15-> Pin "Wfio15" on breakoutboard

DIP switches 1 and 3 control whether the GPRS serial pins of A20 chip (UART_TXD and UART_RXD on the chip itself) are also connected to the corresponding pins on the breakoutboard (named H_TXD and H_RXD)
In Short: you can switch on all for testing after you have programmed internal ESP8285.
If you want ESP8285 to have NO(!!) onboard contact to GPRS part switch OFF DIP switch 2 and 4.
If you only want ESP8285 to control GPRS part of A20 chip with AT commands by internal ESP8285 but you don't need access to the pins for extra monitoring then you only need to switch ON Dip switch 2 and 4 and leave the others OFF.
If you want to use Wfio13 and Wfio15 of the ESP8285 (for other purpose use of GPIO13 and GPIO15) switch ON Dip switch 5 and 6 so that the pins Wfio13 and Wfio15 on the breakoutboard are connected to ESP8285, and leave OFF Dip switches 2 and 4.
If you want to control GPRS part of the A20 from external source, you need to switch OFF dip switches 2 and 4 and switch ON Dip switches 1 and 3 so that UART_RXD and UART_TXD are connected to the pins U_RXD and U_TXD on the breakoutboard but NOT to ESP8285. At the same time you may also switch ON Dip switches 5 and 6 to use Wfio13 and Wfio15 of ESP8285 for other purposes.
Again: Be sure to switch off DIP switches 2 and 4 during flashing of A20's internal ESP8285 because otherwise there will be flashing failures sometimes when the GSM part sends data on its serial port.
Last edited by Lademeister on Mon Jun 26, 2017 12:00 am, edited 2 times in total.
User avatar
By Lademeister
#66991 Update: SoftwareSerial works. It was just my library that was broken.
I successfully tested SoftwareSerial on GPIO13 and GPIO15 (named WF_io13 and WF_io15 on the pins of the board).
I was able to log in to GSM network and obtain an IP address, as well as doing http upload, and GPIO control using MQTT over a GPRS connection.
Of course Wifi also works with the internal ESP8285 -just as with the famous ESP8266 on other boards like the Wemos D1 mini.
I recommend you to use TinyGSM library (you can find it on Github).
You want to change the code examples provided with the library to use AI thinker A6 (AT commands are exactly the same for A20 chip)
So just uncomment the corresponding line in the first lines of the .ino file so that you end up with
#define TINY_GSM_MODEM_A6
...and you are ready to go.
So the above description still applies (DIP switches, flashing...) but you want to use Software Serial to communicate to A20 chip.

You need to have the following lines in your .ino for the A20 board:
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(13,15);

Again, you might want to use TinyGSM code examples to start from.
User avatar
By Lademeister
#83624 No, maybe I should have a look!
By the way, I am currently quite happy when using Hardware serial to control a SIM800L module from a ESP-12F, so I would change my recommendation to not use software serial but hardware serial instead for the A20 chip.