0

members

Medium Basics: Project 100b How to upload the custom firmware to Ai Thinker A9 GSM GPRS development board

of Acoptex.com (Not selected)

Basics: Project 100b

Project name: How to upload the custom firmware to Ai Thinker A9 GSM GPRS development board

Tags: A9, A9 GSM GPRS, A9 GSM GPRS development board, ai thinker, Ai Thinker, custom firmware, how to upload custom firmware, Ai-Thinker SDK

Attachments: none

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1. A9 GSM GPRS development board 1 pc

2. Micro USB cable  1 pc.

3. Micro SIM card 1 pc


4. Micro SD card with SD card adapter 1 pc

5. USB to TTL/Serial adaptor/converter 1 pc

General

We will learn how to upload the custom firmware to Ai Thinker A9 GSM GPRS development board.

Understanding the USB to TTL converter

You can read more about them here.

Understanding the A9 and A9G GSM GPRS development boards


A9

The A9 is a complete quad-band GSM / GPRS module in a compact design SMD package. Its stable performance, the appearance of compact, cost-effective, could meet the diverse needs of customers.

The A9 can be used in a wide range of IoT applications and is ideal for IoT applications for home automation, industrial wireless control, wearable electronics, wireless location sensing devices, wireless location system signals and other IoT applications. A9 SMD package, through the standard SMT equipment to achieve rapid production of products, especially for automation, large-scale, low-cost modern production methods for the convenience of a variety of Internet of Things hardware terminal applications. 

Features:

  • RDA 32 bit RISC core, frequency up to 312MHz, with 4k instruction cache, 4k data cache
  • Up to 29 GPIOs (with two download pins)
  • Calendar (Real Time Clock) with alarm
  • 1 USB1.1 device interface
  • 2 UART interface with flow control (+1 download/debug serial port)
  • 2 SPI interface
  • 3 I 2 C interface
  • 1 SDMMC controller (interface)
  • 2 ADC interface, 10 bits
  • 32Mb (4MB) SPI NOR Flash
  • 32Mb (4MB) DDR PSRAM
  • 8kHz, 13Bits/sample ADC mic
  • 48kHz, 16bits/sample DAC Audio
  • Power Management Unit: Lithium battery charge management, integrated DC-DC and LDOs, variable IO voltage
  • 18.8 x 19.2 mm SMD package
  • Quad-band GSM/GPRS (800/900/1800 / 1900MHz)
  • calls
  • SMS service 

A9G

Features:

  • All features of A9
  • GPS integrated(GK9501),connected with GPRS chip internal through the serial port(UART2)

You can find the A9 product specification here and A9G -here.

Other manuals and information links

Signals and connections of the USB to TTL converter

 You can read more about them here.

Signals and connections of the A9 GSM GPRS Development board

A9 chip pinout:

A9G chip pinout:

 

I2C2_SCL - I2C2 clock pin
I2C2_SDA - I2C2 data pin
SD_D3 - SD serial data pin
SD_D2 - SD serial data pin
SD_D1 - SD serial data pin
SD_D0 - SD serial data pin
SD_CMD - SD command pin
SD_CLK - SD clock pin
PWRKEY - the power button gives the pin a Low signal on
VBAT - Connect external power supply to this pin 3.5V-4.2V, the max supply current should be not less than 2A
SPK_P - Speaker positive (+) pin
SPK_N - Speaker negative (-) pin
ADC0 - ADC 0 pin (max. input 1.8V)
ADC1 - ADC 1 pin (max. input 1.8V)
VUSB - USB power supply pin (external power supply)
RESET - Module hardware reset pin. When this pin used the LOW level is <0.05V and the current is around 70 mA. Must use NMOS tube control and ground can not have leakage when it is working normally, otherwise it will cause the module to be unstable and difficult to register to the network.
LCD_CS -LCD  CS pin
LCD_RST - LCD reset pin
LCD-DIO - LCD DIO pin
LCD_SDC - LCD SDC pin
LCD_SCK  - LCD SCK pin
IO29 - special function pin

I2C2_SCL - I2C2 clock pin

I2C2_SDA - I2C2 data pin

SD_D3 - SD serial data pin

SD_D2 - SD serial data pin

SD_D1 - SD serial data pin

SD_D0 - SD serial data pin

SD_CMD - SD command pin

SD_CLK - SD clock pin

PWRKEY - the power button gives the pin a Low signal on

VBAT - lithium battery pin, connect external power supply to this pin 3.5V-4.2V, the max supply current should be not less than 2A

SPK_P - Speaker positive (+) pin

SPK_N - Speaker negative (-) pin

ADC0 - ADC 0 pin (max. input 1.8V)

ADC1 - ADC 1 pin (max. input 1.8V)

VUSB - USB power supply pin (external power supply)

RESET - Module hardware reset pin. When this pin used the LOW level is <0.05V and the current is around 70 mA. Must use NMOS tube control and ground can not have leakage when it is working normally, otherwise it will cause the module to be unstable and difficult to register to the network.

LCD_CS -LCD  CS pin

LCD_RST - LCD reset pin

LCD-DIO - LCD DIO pin

LCD_SDC - LCD SDC pin

LCD_SCK  - LCD SCK pin

IO29 - special function pin. After the module is working normally with the AT command, pull the pin LOW to enter the shutdown mode.

IO26 - General purpose IO pin. Do not add a pull-up resistor, the level can not be HIGH at power-on. Remark: it is low-power indicator pin - if there is data, SMS, or wake-up call it will be a 50 ms pulse.

IO27 - General purpose IO pin. Do not add a pull-up resistor, the level can not be HIGH at power-on. Remark: the default is 0 as the network status indicator.

GPS_RF - The GPS antena pin can be connected to antenna. If the circuit is connected to the PCB please pay attention to the 50 Ohm trace on the PCB (valid for A9G only)

GND - ground pin

IO28 -General purpose IO pin. Do not add a pull-up resistor, the level can not be HIGH at power-on. Remark: default as GPS status indicator IO pin.

IO30 -General purpose IO pin.

IO25 - General purpose IO pin. Low-power pin and when LOW signal enters to low-power mode.

MIC_N - Microphone negative (-) pin

MIC_P - Microphone positive (+) pin

USB_N - USB D- pin

USB_P - USB D+ pin

HST_TXD - firmware upload pin (transmit pin). pin level 2.8V, compatible with 3V3 (5V not compatible)

HST_RXD - firmware upload pin (receive pin). pin level 2.8V, compatible with 3V3 (5V not compatible)

SM0_DIO - SIM card data pin

VSIM0 - SIM card power supply pin

SM0_CLK - SIM card clock pin

SM0_RST - SIM card reset pin

VIO - Output 3V. Remarks: If it's not in use will be left floating, The load drive current does not exceed 10 mA.

GPRS_RF - the antenna pin can be connected to the antenna. If the circuit is connected to the PCB pay attentian to the 50 Ohm trace on the PCB.

(A9) UART2_RTS - UART2 serial port RTS pin. pin level 2.8V, compatible with 3V3 (5V not compatible)

(A9G) GPS_RTS - GPS serial port RTS pin

(A9) UART2_CTS - UART2 serial port CTS pin. pin level 2.8V, compatible with 3V3 (5V not compatible)

(A9G) GPS_CTS - GPS serial port CTS pin

(A9) UART2_RXD - UART2 serial port RXD (receive) pin. pin level 2.8V, compatible with 3V3 (5V not compatible)

(A9G) GPS_TXD - GPS serial port TXD (transmit) pin

(A9) UART2_TXD - UART2 serial port TXD (transmit) pin. pin level 2.8V, compatible with 3V3 (5V not compatible)

(A9G) GPS_RXD - GPS serial port RXD (receive) pin

Notes on pins 47, 48, 49, 50:

For A9 pin 47,48,49,50 - UART2

For A9 pin 49 is UART2_RXD, pin 50 is UART2_TXD

For A9G pin 47,48,49,50 - GPS 

For A9G pin 49 is GPS_TXD, pin50 is GPS_RXD

The float control functions of A9 and A9G are temporary not supported.

UART1_RTS - AT serial port RTS pin. pin level 2.8V, compatible with 3V3 (5V not compatible)

UART1_CTS - AT serial port CTS pin. pin level 2.8V, compatible with 3V3 (5V not compatible)

UART1_RXD - AT commands serial port RXD (receive) pin. pin level 2.8V, compatible with 3V3 (5V not compatible)

UART1_TXD - AT commands serial port TXD (transmit) pin. pin level 2.8V, compatible with 3V3 (5V not compatible)

Wiring

Step by Step instruction

We are using MS Windows 7 64 bit OS version. This project is made for MS Windows. SDK does not have a specific IDE, and the user chooses the code editor to edit the code. When modifying the code, you must not use the notepad and writing board that windows brings. Please use a more professional editor (recommended as vscode, sublime, atom, eclipse, source insight, or other editors you are familiar with). Please modify the editor settings. The end of the file symbol is set to UNIX style ( (\n) end), and file encoding is UTF-8.

Ai-Thinker published an official SDK documentation, as such as SDK on Github.

1. Uploading default project - app

  1. Go to 7-zip.org web page, download and install the 7 Zip program in your PC. It’s important to install the 32-bit (also called x86) version of 7-zip for a 32-bit operating system and the 64-bit (also called x64) version for a 64-bit OS, since the x64 version won’t work on x86 and the x86 version won’t run with context menu on x64 machines. If you are not sure if you have a x86 or x64 operating system installed, you can find this out in several ways. Here are 2: a) Press Win+X (this opens the Power User Menu) and select System. Look under System -> System type for the OS type you have installed or b) Click Start (or press the Win key) and type PC Info. Look under System type and find out the type of OS you’re running. Now that you know what type of OS you have installed, download and install the corresponding version of 7-zip.
  2. Download CSDTK4.2 (there are several links: baidu cloud, MEGA cloud, direct link).
  3. Unzip to a CSDTK folder on C: drive in your PC, such as C:\CSDTK.
  4. Run config_env_admin.bat file in C:\CSDTK to set environment variables.
  5. What the script does is to create an environment variable named GPRS_CSDTK42_PATH, which has a variable directory value of CSDTK. If the script fails, you can build it by yourself.
  6. Download GPRS_C_SDK_V2112.7z pre-release from GitHub
  7. Unzip GPRS_C_SDK folder from the GPRS_C_SDK_V2112.7z to  C:\GPRS_C_SDK, use the underscore(_) instead of minus(-).
  8. Go to C:\GPRS_C_SDK and right click with mouse on the blank space in the folder with Shift key pressed. Click on Open command window here to open the powershell of cmd.
  9. Type build.bat app to build the app folder source code in debug mode.
  10. If you see NO CSDTK error, you may need to restart you system (mostly appears on MS Windows 7).
  11. As we have MS Windows 7 let's reboot and start compilation process again.
  12. Go to C:\GPRS_C_SDK and right click with mouse on the blank space in the folder with Shift key pressed. Click on Open command window here to open the powershell of cmd.
  13. Type build.bat app to build the app folder source code in debug mode.
  14. By default, build.bat will build a debug version. In release mode, the watchdog resets the system after an error. A build and a hex folder will be generated after compile.
  15. There are two *.lod files (*_B*.lod and *_flash.lod) in the hex folder. 
  16. You must burn the bigger one to A9 development board at the first time, then you can just burn the little one to reduce the download time.
  17. The bigger file should be flashed after each SDK upgrade. The smaller one will contain the compiled source code and must be uploaded after compilation.
  18. You can use ./build.bat script to build project: ./build.bat $PROJ:compile app module,e.g.:./build.batsh app to compile the source code of app folder; ./build.bat demo $PROJ:compile demo project, e.g.:./build.bat demo gpio to compile gpio demo; ./build.bat clean $PROJ:clear the build files of $PROJ; ./build.bat clean all:clear all the build files; ./build.bat demo $PROJ release:build a release version, e.g.:./build.bat demo gpio release,if the last parameter is not release, it will be default to debug version. The GDB can be used to debug errors after system crashed in debug version, but release version can not, watch dog activate in release version,it will auto restart system when system crashed! e.g.: ./build.sh demo gpio
  19. To power the A9 GSM GPRS development board, you can use a lithium battery (voltage 3.8v ~ 4.2v) (VBAT pins), or use a 5v power supply (5v input pin or USB input). Please note that when using lithium battery power supply, the POWER KEY must be pressed for about 3 seconds to power on the module (not the case with the USB plug).
  20. Do wiring for firmware update. Use the USB-TTL converter to connect the download serial port of the GPRS series module to your PC USB port. GPRS series modules generally have two serial ports, one AT serial port and one download serial port. We will use the HST_TXD, HST_RXD pin to upload the firmware.
  21. Attach GSM/GPRS antenna to A9 GSM GPRS development board.
  22. Insert a valid unlocked Micro SIM card to SIM card slot of A9 GSM GPRS development board.
  23. Insert the Micro CD card to Micro SD card slot.
  24. Plug your USB to TTL converter into your PC USB port.
  25. You can power up A9 GSM GPRS development board Lithium Ion battery V_BAT (3.5-4.2VDC) or use power supply from USB to TTL converter. 
  26. Press  PWR button for 2 seconds. Status indication (blue LED) will be ON. 
  27. Go to C:\CSDTK\cooltools\ and double-click on coolwatcher.exe.
  28. Select profile 8955 and change the lastcomport value by the COM port number of your USB/Serial converter, then click on OK button.
  29. We have COM7 port so we changed the number to 7 close to lastcomport.
  30. You should be connected. Click on Allow access button.
  31. Select the flash programmer from menu. Go to Flash -> Choose Flash Programmer... menu.
  32. In the C:\CSDTK\cooltools\chipgen\Modem2G\toolpool\plugins\fastpf\flash_programmers folder, select the *_8955_*_spi32m_ramrun.lod file (we have host_8955_flsh_spi32m_ramrun.lod) and click on Open button.
  33. You can now burn the firmware. Click on LOD icon.
  34. In the C:\GPRS_C_SDK\hex\app\ folder, you should find a *_debug.lod file and a *_flash_debug.lod file. The *_debug.lod file should be burn first, and *_flash_debug.lod need only to be flashed when the SDK is updated (we have app_B2112_debug.lod and app_flash_debug.lod files).
  35. Select call_B2112_debug.lod and click on Open button.
  36. Click on burn icon.
  37. The burning process starts.
  38. By default we used the default code which is located in C:\GPRS_C_SDK\app\src\
  39. When modifying the code, you must not use the notepad and writing board that windows brings. Please use a more professional editor (recommended as vscode, sublime, atom, eclipse, source insight, or other editors you are familiar with). We used Microsoft Visual Studio 2019 Community program.
  40. To debug click on Plugins -> Active Tracer
  41. Click on Set trace levels icon in the Trace tool window.
  42. Change the settings according to the following screenshot.
  43. You can click on Start sniffing traces button now.
  44. Each time that the Trace() function (api_debug.h) is called in the source code, the trace tool will display the content.

2. Uploading demo

 

  1. You can try it as we did with the CALL example (C:\GPRS_C_SDK\demo\call\). When modifying the code, you must not use the notepad and writing board that windows brings. Please use a more professional editor (recommended as vscode, sublime, atom, eclipse, source insight, or other editors you are familiar with). We used Microsoft Visual Code program. You need to change cell number - use the format "0037163054127". 00 are set instead of +, then country code, area code and ...
  2. Go to C:\GPRS_C_SDK and right click with mouse on the blank space in the folder with Shift key pressed. Click on Open command window here to open the powershell of cmd.
  3. Type build.bat clean all to clean the build and hex folders from previous project files.
  4. Type build.bat demo call to compile the demo\call project files.
  5. build and a hex folder will be generated after compile.
  6. To power the A9 GSM GPRS development board, you can use a lithium battery (voltage 3.8v ~ 4.2v) (VBAT pins), or use a 5v power supply (5v input pin or USB input). Please note that when using lithium battery power supply, the POWER KEY must be pressed for about 3 seconds to power on the module (not the case with the USB plug).
  7. Do wiring for firmware update. Use the USB-TTL converter to connect the download serial port of the GPRS series module to your PC USB port. GPRS series modules generally have two serial ports, one AT serial port and one download serial port. We will use the HST_TXD, HST_RXD pin to upload the firmware.
  8. Attach GSM/GPRS antenna to A9 GSM GPRS development board.
  9. Insert a valid unlocked Micro SIM card to SIM card slot of A9 GSM GPRS development board.
  10. Insert the Micro CD card to Micro SD card slot.
  11. Plug your USB to TTL converter into your PC USB port.
  12. You can power up A9 GSM GPRS development board Lithium Ion battery V_BAT (3.5-4.2VDC) or use power supply from USB to TTL converter. 
  13. Press  PWR button for 2 seconds. Status indication (blue LED) will be ON. 
  14. Go to C:\CSDTK\cooltools\ and double-click on coolwatcher.exe.
  15. Select profile 8955 and change the lastcomport value by the COM port number of your USB/Serial converter, then click on OK button.
  16. We have COM7 port so we changed the number to 7 close to lastcomport.
  17. You should be connected. 
  18. Select the flash programmer from menu. Go to Flash -> Choose Flash Programmer... menu.
  19. In the C:\CSDTK\cooltools\chipgen\Modem2G\toolpool\plugins\fastpf\flash_programmersfolder, select the *_8955_*_spi32m_ramrun.lod file (we have host_8955_flsh_spi32m_ramrun.lod) and click on Open button.
  20. You can now burn the firmware. Click on LOD icon.
  21. In the C:\GPRS_C_SDK\hex\call\ folder, you should find a *_debug.lod file and a *_flash_debug.lod file. The *_debug.lod file should be burn first, and *_flash_debug.lod need only to be flashed when the SDK is updated (we have call_B2112_debug.lod and call_flash_debug.lod files).
  22. Select call_B2112_debug.lod and click on Open button.
  23. Click on burn icon.
  24. The burning process starts.
  25. To debug click on Plugins -> Active Tracer
  26. Click on Set trace levels icon in the Trace tool window.
  27. Change the settings according to the following screenshot.
  28. You can click on Start sniffing traces button now.
  29. A9 GSM GPRS development board will start to call to your number. 
  30. You can also try other projects from demo folder. More information about SDK you can find here.

Summary

We have learnt how to upload the custom firmware to Ai Thinker A9 GSM GPRS development board.

The main difficulty will be to drive other modules as the GPIO levels (1.9V or 2.8V) are quite different from DIY modules (3.3V / 5V).

Libraries

  • None

Script

  • None


Other projects of Acoptex.com
Easy Basics: Project 105a SIM900A GSM GPRS mini module of Acoptex.com in NANO 28-11-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 24-11-2019
Viewed: 280 times