Giter Site home page Giter Site logo

pulkin / micropython Goto Github PK

View Code? Open in Web Editor NEW

This project forked from neutree/micropython

103.0 17.0 30.0 45.53 MB

MicroPython implementation on Ai-Thinker GPRS module A9 (RDA8955)

Home Page: https://micropython.org

License: MIT License

C 90.45% C++ 0.48% Python 7.69% Makefile 1.15% Shell 0.10% Assembly 0.09% CMake 0.01% JavaScript 0.03%
arduino micropython python embedded lua esp8266 gsm modem a9g sms gprs iot mqtt agps

micropython's Introduction

Important

This repo is only for porting micropython to the GPS+GSM modules A9 and A9G. Go to the port page or visit the MicroPython project page.

The build status displays that of the original repo.

Build Status Coverage Status

The MicroPython project

MicroPython Logo

This is the MicroPython project, which aims to put an implementation of Python 3.x on microcontrollers and small embedded systems. You can find the official website at micropython.org.

WARNING: this project is in beta stage and is subject to changes of the code-base, including project-wide name changes and API changes.

MicroPython implements the entire Python 3.4 syntax (including exceptions, with, yield from, etc., and additionally async/await keywords from Python 3.5). The following core datatypes are provided: str (including basic Unicode support), bytes, bytearray, tuple, list, dict, set, frozenset, array.array, collections.namedtuple, classes and instances. Builtin modules include sys, time, and struct, etc. Select ports have support for _thread module (multithreading). Note that only a subset of Python 3 functionality is implemented for the data types and modules.

MicroPython can execute scripts in textual source form or from precompiled bytecode, in both cases either from an on-device filesystem or "frozen" into the MicroPython executable.

See the repository http://github.com/micropython/pyboard for the MicroPython board (PyBoard), the officially supported reference electronic circuit board.

Major components in this repository:

  • py/ -- the core Python implementation, including compiler, runtime, and core library.
  • mpy-cross/ -- the MicroPython cross-compiler which is used to turn scripts into precompiled bytecode.
  • ports/unix/ -- a version of MicroPython that runs on Unix.
  • ports/stm32/ -- a version of MicroPython that runs on the PyBoard and similar STM32 boards (using ST's Cube HAL drivers).
  • ports/minimal/ -- a minimal MicroPython port. Start with this if you want to port MicroPython to another microcontroller.
  • tests/ -- test framework and test scripts.
  • docs/ -- user documentation in Sphinx reStructuredText format. Rendered HTML documentation is available at http://docs.micropython.org.

Additional components:

  • ports/bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used mostly to control code size.
  • ports/teensy/ -- a version of MicroPython that runs on the Teensy 3.1 (preliminary but functional).
  • ports/pic16bit/ -- a version of MicroPython for 16-bit PIC microcontrollers.
  • ports/cc3200/ -- a version of MicroPython that runs on the CC3200 from TI.
  • ports/esp8266/ -- a version of MicroPython that runs on Espressif's ESP8266 SoC.
  • ports/esp32/ -- a version of MicroPython that runs on Espressif's ESP32 SoC.
  • ports/nrf/ -- a version of MicroPython that runs on Nordic's nRF51 and nRF52 MCUs.
  • extmod/ -- additional (non-core) modules implemented in C.
  • tools/ -- various tools, including the pyboard.py module.
  • examples/ -- a few example Python scripts.

The subdirectories above may include READMEs with additional info.

"make" is used to build the components, or "gmake" on BSD-based systems. You will also need bash, gcc, and Python 3.3+ available as the command python3 (if your system only has Python 2.7 then invoke make with the additional option PYTHON=python2).

The MicroPython cross-compiler, mpy-cross

Most ports require the MicroPython cross-compiler to be built first. This program, called mpy-cross, is used to pre-compile Python scripts to .mpy files which can then be included (frozen) into the firmware/executable for a port. To build mpy-cross use:

$ cd mpy-cross
$ make

The Unix version

The "unix" port requires a standard Unix environment with gcc and GNU make. x86 and x64 architectures are supported (i.e. x86 32- and 64-bit), as well as ARM and MIPS. Making full-featured port to another architecture requires writing some assembly code for the exception handling and garbage collection. Alternatively, fallback implementation based on setjmp/longjmp can be used.

To build (see section below for required dependencies):

$ cd ports/unix
$ make submodules
$ make

Then to give it a try:

$ ./micropython
>>> list(5 * x + y for x in range(10) for y in [4, 2, 1])

Use CTRL-D (i.e. EOF) to exit the shell. Learn about command-line options (in particular, how to increase heap size which may be needed for larger applications):

$ ./micropython -h

Run complete testsuite:

$ make test

Unix version comes with a builtin package manager called upip, e.g.:

$ ./micropython -m upip install micropython-pystone
$ ./micropython -m pystone

Browse available modules on PyPI. Standard library modules come from micropython-lib project.

External dependencies

Building MicroPython ports may require some dependencies installed.

For Unix port, libffi library and pkg-config tool are required. On Debian/Ubuntu/Mint derivative Linux distros, install build-essential (includes toolchain and make), libffi-dev, and pkg-config packages.

Other dependencies can be built together with MicroPython. This may be required to enable extra features or capabilities, and in recent versions of MicroPython, these may be enabled by default. To build these additional dependencies, in the port directory you're interested in (e.g. ports/unix/) first execute:

$ make submodules

This will fetch all the relevant git submodules (sub repositories) that the port needs. Use the same command to get the latest versions of submodules as they are updated from time to time. After that execute:

$ make deplibs

This will build all available dependencies (regardless whether they are used or not). If you intend to build MicroPython with additional options (like cross-compiling), the same set of options should be passed to make deplibs. To actually enable/disable use of dependencies, edit ports/unix/mpconfigport.mk file, which has inline descriptions of the options. For example, to build SSL module (required for upip tool described above, and so enabled by default), MICROPY_PY_USSL should be set to 1.

For some ports, building required dependences is transparent, and happens automatically. But they still need to be fetched with the make submodules command.

The STM32 version

The "stm32" port requires an ARM compiler, arm-none-eabi-gcc, and associated bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils, arm-none-eabi-gcc and arm-none-eabi-newlib packages. Otherwise, try here: https://launchpad.net/gcc-arm-embedded

To build:

$ cd ports/stm32
$ make submodules
$ make

You then need to get your board into DFU mode. On the pyboard, connect the 3V3 pin to the P1/DFU pin with a wire (on PYBv1.0 they are next to each other on the bottom left of the board, second row from the bottom).

Then to flash the code via USB DFU to your device:

$ make deploy

This will use the included tools/pydfu.py script. If flashing the firmware does not work it may be because you don't have the correct permissions, and need to use sudo make deploy. See the README.md file in the ports/stm32/ directory for further details.

Contributing

MicroPython is an open-source project and welcomes contributions. To be productive, please be sure to follow the Contributors' Guidelines and the Code Conventions. Note that MicroPython is licenced under the MIT license, and all contributions should follow this license.

micropython's People

Contributors

atx avatar aykevl avatar blmorris avatar chipaca avatar danicampora avatar deshipu avatar dhylands avatar dlech avatar doc-hex avatar dpgeorge avatar flowergrass avatar glennrub avatar iabdalkader avatar jimmo avatar jongy avatar lurch avatar maureenhelm avatar mcauser avatar mrsurly avatar neutree avatar peterhinch avatar pfalcon avatar pi-anl avatar prusnak avatar pulkin avatar rolandvs avatar rosuav avatar stinos avatar tomlogic avatar xbe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

micropython's Issues

How to increase the size of the RX buffer?

Dear Pulkin,
I am used to using an extension of Microsoft Visual Studio Code called PyMakr to develop MicroPython code more easily. It works fine with several boards such as the ESP8266.
There is a command to copy a .py file onto the board similarly to ampy.
But it doesn't work with the A9G board.
I believe it has to do with the A9G RX buffer being too small to store a big chunk of data.
If so, increasing the size of that buffer would solve my issue.
Could you tell me where to size that buffer in the code before building the A9G port?
Thanks,

Possibility to catch CellularError - Enhancement

Would it be possible to catch the CellularError in the futur?
Currently:

>>> import cellular
>>> try:
...     cellular.gprs("not_a_real_apn", "", "")
... except CellularError as e:
...     print(e)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'CellularError' isn't defined
>>>

Port `micropython.native`, `micropython.viper`

ESP8266:

void *esp_native_code_commit(void *buf, size_t len) {
//printf("COMMIT(buf=%p, len=%u, start=%08x, cur=%08x, end=%08x, erased=%08x)\n", buf, len, esp_native_code_start, esp_native_code_cur, esp_native_code_end, esp_native_code_erased);
len = (len + 3) & ~3;
if (esp_native_code_cur + len > esp_native_code_end) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_MemoryError,
"memory allocation failed, allocating %u bytes for native code", (uint)len));
}
void *dest;
if (esp_native_code_location == ESP_NATIVE_CODE_IRAM1) {
dest = (void*)esp_native_code_cur;
memcpy(dest, buf, len);
} else {
SpiFlashOpResult res;
while (esp_native_code_erased < esp_native_code_cur + len) {
ets_loop_iter(); // flash access takes time so run any pending tasks
res = spi_flash_erase_sector(esp_native_code_erased / FLASH_SEC_SIZE);
if (res != SPI_FLASH_RESULT_OK) {
break;
}
esp_native_code_erased += FLASH_SEC_SIZE;
}
ets_loop_iter();
if (res == SPI_FLASH_RESULT_OK) {
res = spi_flash_write(esp_native_code_cur, buf, len);
ets_loop_iter();
}
if (res != SPI_FLASH_RESULT_OK) {
mp_raise_OSError(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO);
}
dest = (void*)(FLASH_START + esp_native_code_cur);
}
esp_native_code_cur += len;
return dest;
}

SSD1306 i2c oled display library

I slightly modified adafruit-ssd1306.py oled display driver library for use with A9G pudding and non-standard I2C library.

I did some tests using hw i2c ports 2 and 3 and had no issues.

The main difference is how to init display:

oled = ssd1306_a9g.SSD1306_I2C(width, height, i2c_id, i2c_freq, addr)

where i2c_id is 2 or 3 and i2c_freq = clk frequency in kHz
i.e oled = ssd1306_a9g.SSD1306_I2C(128, 64, 3, 400)

Hoping it could be useful to somebody.

# MicroPython SSD1306 OLED driver, I2C and SPI interfaces created by Adafruit
# ported to A9G pudding by iemmeti

import framebuf
import i2c
import time

# register definitions
SET_CONTRAST        = const(0x81)
SET_ENTIRE_ON       = const(0xa4)
SET_NORM_INV        = const(0xa6)
SET_DISP            = const(0xae)
SET_MEM_ADDR        = const(0x20)
SET_COL_ADDR        = const(0x21)
SET_PAGE_ADDR       = const(0x22)
SET_DISP_START_LINE = const(0x40)
SET_SEG_REMAP       = const(0xa0)
SET_MUX_RATIO       = const(0xa8)
SET_COM_OUT_DIR     = const(0xc0)
SET_DISP_OFFSET     = const(0xd3)
SET_COM_PIN_CFG     = const(0xda)
SET_DISP_CLK_DIV    = const(0xd5)
SET_PRECHARGE       = const(0xd9)
SET_VCOM_DESEL      = const(0xdb)
SET_CHARGE_PUMP     = const(0x8d)

# Timings (after some try and error)
CMD_TIMEOUT = 20
FB_TIMEOUT = 100


class SSD1306:
    def __init__(self, width, height, external_vcc):
        self.width = width
        self.height = height
        self.external_vcc = external_vcc
        self.pages = self.height // 8
        # Note the subclass must initialize self.framebuf to a framebuffer.
        # This is necessary because the underlying data buffer is different
        # between I2C and SPI implementations (I2C needs an extra byte).
        self.poweron()
        self.init_display()

    def init_display(self):
        for cmd in (
            SET_DISP | 0x00, # off
            # address setting
            SET_MEM_ADDR, 0x00, # horizontal
            # resolution and layout
            SET_DISP_START_LINE | 0x00,
            SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0
            SET_MUX_RATIO, self.height - 1,
            SET_COM_OUT_DIR | 0x08, # scan from COM[N] to COM0
            SET_DISP_OFFSET, 0x00,
            SET_COM_PIN_CFG, 0x02 if self.height == 32 else 0x12,
            # timing and driving scheme
            SET_DISP_CLK_DIV, 0x80,
            SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1,
            SET_VCOM_DESEL, 0x30, # 0.83*Vcc
            # display
            SET_CONTRAST, 0xff, # maximum
            SET_ENTIRE_ON, # output follows RAM contents
            SET_NORM_INV, # not inverted
            # charge pump
            SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14,
            SET_DISP | 0x01): # on
            self.write_cmd(cmd)
        self.fill(0)
        self.show()

    def poweroff(self):
        self.write_cmd(SET_DISP | 0x00)
    
    def poweron(self):
        self.write_cmd(SET_DISP | 0x01)

    def contrast(self, contrast):
        self.write_cmd(SET_CONTRAST)
        self.write_cmd(contrast)

    def invert(self, invert):
        self.write_cmd(SET_NORM_INV | (invert & 1))

    def show(self):
        x0 = 0
        x1 = self.width - 1
        if self.width == 64:
            # displays with width of 64 pixels are shifted by 32
            x0 += 32
            x1 += 32
        self.write_cmd(SET_COL_ADDR)
        self.write_cmd(x0)
        self.write_cmd(x1)
        self.write_cmd(SET_PAGE_ADDR)
        self.write_cmd(0)
        self.write_cmd(self.pages - 1)
        self.write_framebuf()

    def fill(self, col):
        self.framebuf.fill(col)

    def pixel(self, x, y, col):
        self.framebuf.pixel(x, y, col)

    def scroll(self, dx, dy):
        self.framebuf.scroll(dx, dy)

    def text(self, string, x, y, col=1):
        self.framebuf.text(string, x, y, col)


class SSD1306_I2C(SSD1306):
    # modified for A9G i2c library
    def __init__(self, width, height, i2c_id=3, i2c_freq = 100, addr=0x3C, external_vcc=False):
        self.i2c_id = i2c_id
        self.i2c_freq = i2c_freq
        i2c.init(i2c_id, i2c_freq)
        self.addr = addr
        self.temp = bytearray(2)
        # Add an extra byte to the data buffer to hold an I2C data/command byte
        # to use hardware-compatible I2C transactions.  A memoryview of the
        # buffer is used to mask this byte from the framebuffer operations
        # (without a major memory hit as memoryview doesn't copy to a separate
        # buffer).
        self.buffer = bytearray(((height // 8) * width) + 1)
        self.buffer[0] = 0x40  # Set first byte of data buffer to Co=0, D/C=1
        self.framebuf = framebuf.FrameBuffer1(memoryview(self.buffer)[1:], width, height)
        super().__init__(width, height, external_vcc)

    def write_cmd(self, cmd):
        self.temp[0] = 0x80 # Co=1, D/C#=0
        self.temp[1] = cmd
        # modified for A9G i2c library
        i2c.transmit(self.i2c_id, self.addr, self.temp, CMD_TIMEOUT)

    def write_framebuf(self):
        # Blast out the frame buffer using a single I2C transaction to support
        # hardware I2C interfaces.
        # modified for A9G i2c library
        i2c.transmit(self.i2c_id, self.addr, self.buffer, FB_TIMEOUT)

    def poweron(self):
        pass

ADC

Analog-digital converter in machine.ADC

Cannot connect to the REPL

I think I successfully built the firmware despite getting some warnings:

../../py/nlrsetjmp.c: In function ‘nlr_jump’:
../../py/nlrsetjmp.c:41: warning: ‘noreturn’ function does return

../../py/modbuiltins.c: In function ‘mp_builtin_round’:../../py/modbuiltins.c:497: warning: declaration of ‘floor’ shadows a global declaration
/home/vagrant/A9G/micropython/lib/GPRS_C_SDK/include/std_inc/math.h:328: warning: shadowed declaration is here

../../py/modmath.c: In function ‘mp_math_frexp’:../../py/modmath.c:238: warning: declaration of ‘significand’ shadows a global declaration
/home/vagrant/A9G/micropython/lib/GPRS_C_SDK/include/std_inc/math.h:397: warning: shadowed declaration is here


main.c: In function ‘MicroPyTask’:main.c:161: warning: unused variable ‘event’

modcellular.c:636: warning: ‘modcellular_sms_from_raw’ defined but not usedCC modgps.c

AS gchelper.sCC ../../lib/axtls/ssl/asn1.c

../../lib/axtls/ssl/tls1.c: In function ‘add_hmac_digest’:../../lib/axtls/ssl/tls1.c:695: warning: incompatible implicit declaration of built-in function ‘alloca’
../../lib/axtls/ssl/tls1.c: In function ‘send_packet’:
../../lib/axtls/ssl/tls1.c:1177: warning: incompatible implicit declaration of built-in function ‘alloca’

../../lib/axtls/crypto/rsa.c: In function ‘RSA_decrypt’:../../lib/axtls/crypto/rsa.c:150: warning: incompatible implicit declaration of built-in function ‘alloca’

Indeed, in the end, I got BUILD OK and the two .lod files got available in the hex folder.
Than, I believe I successfully burned both .lod files using coolwatcher as I didn't observe any error message.

But now, I cannot connect to the MicroPython REPL.
I only observe garbage in the console when running the miniterm.py /dev/ttyUSB1 115200 --raw command and pressing on the board reset button.

What could be my issue?
Should I connect the serial adapter to other pins than HST_TX and HST_RX to access the REPL?
Thks,

MPY Example Code

Thanks for your great work!

Do you have any Micropython example code to share to simplify my understanding of your different APIs?

I would like to transmit regularly some GPS (together with some AGPS) coordinates to a MQTT broker using SSL/TLS and the cellular connection.

Maybe you already wrote such piece of software?

Reverse-engineer file system

.. and explore whether formatting it to FAT32 is possible. Flash dump:
flash-dump.bin.gz

binwalk:

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
9820          0x265C          CRC32 polynomial table, little endian
1975160       0x1E2378        CRC32 polynomial table, little endian
2057636       0x1F65A4        Neighborly text, "neighbor entryis required"
2097655       0x2001F7        PARity archive data - file number 19807
2109185       0x202F01        Neighborly text, "NeighborCellInfo != NULL, neighbor cell number:%d_ProcessData pNeighborCellInfo[%d] sMcc=%d%d%d,sMnc=%d%d%d,sLac=%x,sCellID=%x,iBsic=%d,iRxLev=%d,iRxLevSub=%d,nArfcn=%d,nTSM_BCC"
2109211       0x202F1B        Neighborly text, "neighbor cell number:%dInfo[%d] sMcc=%d%d%d,sMnc=%d%d%d,sLac=%x,sCellID=%x,iBsic=%d,iRxLev=%d,iRxLevSub=%d,nArfcn=%d,nTSM_BCCHDec=%d,nTSM_C1Value=%d"
2109262       0x202F4E        Neighborly text, "NeighborCellInfo[%d] sMcc=%d%d%d,sMnc=%d%d%d,sLac=%x,sCellID=%x,iBsic=%d,iRxLev=%d,iRxLevSub=%d,nArfcn=%d,nTSM_BCCHDec=%d,nTSM_C,iBsic=%d,iRxLev=%d,iRxLevSub=%d,nArfcn=%d,nTSM_BCCHDec=%d,nTSM_C1Value=%d"
2120345       0x205A99        Unix path: /dev/ota/v4.1/update_and_check/%s HTTP/1.1
2122488       0x2062F8        CRC32 polynomial table, little endian
2126635       0x20732B        Unix path: /./mupnp/src/mupnp/http/http_packet.c
2131744       0x208720        PEM RSA private key
2131808       0x208760        PEM EC private key
2132835       0x208B63        Unix path: /./mupnp/src/mupnp/net/socket.c
2133203       0x208CD3        Unix path: /./mbedtls/library/ssl_tls.c
2140668       0x20A9FC        PEM certificate
2157484       0x20EBAC        SHA256 hash constants, little endian
2169315       0x2119E3        Unix path: /./mbedtls/library/ssl_cli.c
2369610       0x24284A        Certificate in DER format (x509 v3), header length: 4, sequence length: 2063
2491470       0x26044E        Certificate in DER format (x509 v3), header length: 4, sequence length: 2048
2491474       0x260452        Certificate in DER format (x509 v3), header length: 4, sequence length: 17408
2491478       0x260456        Certificate in DER format (x509 v3), header length: 4, sequence length: 0
2492038       0x260686        Certificate in DER format (x509 v3), header length: 4, sequence length: 17408
2492042       0x26068A        Certificate in DER format (x509 v3), header length: 4, sequence length: 2048
2492046       0x26068E        Certificate in DER format (x509 v3), header length: 4, sequence length: 1024
2502362       0x262EDA        Certificate in DER format (x509 v3), header length: 4, sequence length: 15
2502366       0x262EDE        Certificate in DER format (x509 v3), header length: 4, sequence length: 11279
2502370       0x262EE2        Certificate in DER format (x509 v3), header length: 4, sequence length: 12305
2502374       0x262EE6        Certificate in DER format (x509 v3), header length: 4, sequence length: 19456
2502506       0x262F6A        Certificate in DER format (x509 v3), header length: 4, sequence length: 18432
2503146       0x2631EA        Certificate in DER format (x509 v3), header length: 4, sequence length: 19456
2503150       0x2631EE        Certificate in DER format (x509 v3), header length: 4, sequence length: 12305
2503154       0x2631F2        Certificate in DER format (x509 v3), header length: 4, sequence length: 15377
2503158       0x2631F6        Certificate in DER format (x509 v3), header length: 4, sequence length: 21504
2503162       0x2631FA        Certificate in DER format (x509 v3), header length: 4, sequence length: 20480
2507558       0x264326        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507562       0x26432A        Certificate in DER format (x509 v3), header length: 4, sequence length: 22784
2507590       0x264346        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507594       0x26434A        Certificate in DER format (x509 v3), header length: 4, sequence length: 22784
2507614       0x26435E        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507638       0x264376        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507662       0x26438E        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507690       0x2643AA        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507694       0x2643AE        Certificate in DER format (x509 v3), header length: 4, sequence length: 22784
2507718       0x2643C6        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507746       0x2643E2        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507782       0x264406        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507786       0x26440A        Certificate in DER format (x509 v3), header length: 4, sequence length: 22784
2507814       0x264426        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507842       0x264442        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507878       0x264466        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507882       0x26446A        Certificate in DER format (x509 v3), header length: 4, sequence length: 22784
2507910       0x264486        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2507974       0x2644C6        Certificate in DER format (x509 v3), header length: 4, sequence length: 23552
2508598       0x264736        Certificate in DER format (x509 v3), header length: 4, sequence length: 19482
2509002       0x2648CA        Certificate in DER format (x509 v3), header length: 4, sequence length: 25600
2509006       0x2648CE        Certificate in DER format (x509 v3), header length: 4, sequence length: 26624
2509334       0x264A16        Certificate in DER format (x509 v3), header length: 4, sequence length: 28672
2510130       0x264D32        Certificate in DER format (x509 v3), header length: 4, sequence length: 27648
2511942       0x265446        Certificate in DER format (x509 v3), header length: 4, sequence length: 29696
2512082       0x2654D2        Certificate in DER format (x509 v3), header length: 4, sequence length: 26624
2512170       0x26552A        Certificate in DER format (x509 v3), header length: 4, sequence length: 26880
2512450       0x265642        Certificate in DER format (x509 v3), header length: 4, sequence length: 23040
2512454       0x265646        Certificate in DER format (x509 v3), header length: 4, sequence length: 22784
2512458       0x26564A        Certificate in DER format (x509 v3), header length: 4, sequence length: 24064
2512466       0x265652        Certificate in DER format (x509 v3), header length: 4, sequence length: 19481
2512474       0x26565A        Certificate in DER format (x509 v3), header length: 4, sequence length: 22528
2519978       0x2673AA        Certificate in DER format (x509 v3), header length: 4, sequence length: 7168
2522198       0x267C56        Certificate in DER format (x509 v3), header length: 4, sequence length: 15
2522418       0x267D32        Certificate in DER format (x509 v3), header length: 4, sequence length: 15
2522422       0x267D36        Certificate in DER format (x509 v3), header length: 4, sequence length: 14336
2522486       0x267D76        Certificate in DER format (x509 v3), header length: 4, sequence length: 13312
2522554       0x267DBA        Certificate in DER format (x509 v3), header length: 4, sequence length: 15
2522602       0x267DEA        Certificate in DER format (x509 v3), header length: 4, sequence length: 10240
2555366       0x26FDE6        Certificate in DER format (x509 v3), header length: 4, sequence length: 12316
2555370       0x26FDEA        Certificate in DER format (x509 v3), header length: 4, sequence length: 30748
2555374       0x26FDEE        Certificate in DER format (x509 v3), header length: 4, sequence length: 26658
2555382       0x26FDF6        Certificate in DER format (x509 v3), header length: 4, sequence length: 8219
2555386       0x26FDFA        Certificate in DER format (x509 v3), header length: 4, sequence length: 3100
2560002       0x271002        Certificate in DER format (x509 v3), header length: 4, sequence length: 0
2613852       0x27E25C        Private key in DER format (PKCS header length: 4, sequence length: 605
2614464       0x27E4C0        Certificate in DER format (x509 v3), header length: 4, sequence length: 600
2616272       0x27EBD0        SHA256 hash constants, little endian
2654964       0x2882F4        CRC32 polynomial table, little endian
2674860       0x28D0AC        Neighborly text, "neighbor entryis required"
2718067       0x297973        PARity archive data - file number 19807
2726540       0x299A8C        JPEG image data, JFIF standard 1.01
2754216       0x2A06A8        PEM RSA private key
2754280       0x2A06E8        PEM EC private key
2755731       0x2A0C93        Unix path: /./mbedtls/library/ssl_tls.c
2762952       0x2A28C8        PEM certificate
2777432       0x2A6158        SHA256 hash constants, little endian
2789263       0x2A8F8F        Unix path: /./mbedtls/library/ssl_cli.c
2794408       0x2AA3A8        Base64 standard index table
2805117       0x2ACD7D        Neighborly text, "NeighborCellInfo[%d] sMcc=%d%d%d,sMnc=%d%d%d,sLac=%x,sCellID=%x,iBsic=%d,iRxLev=%d,iRxLevSub=%d",iBsic=%d,iRxLev=%d,iRxLevSub=%d""
2924621       0x2CA04D        Ubiquiti firmware header, third party, ~CRC32: 0x0, version: " SERVER),(1,65535)"
2936844       0x2CD00C        Ubiquiti firmware header, third party, ~CRC32: 0x0, version: "NING"
2999300       0x2DC404        CRC32 polynomial table, little endian
3003651       0x2DD503        Unix path: /./mupnp/src/mupnp/http/http_packet.c
3004683       0x2DD90B        Unix path: /./mupnp/src/mupnp/net/socket.c
3756544       0x395200        PC bitmap, Windows 3.x format,, 128 x 160 x 24

Вопрос об uart 0

Здравствуйте.
Подскажите есть ли возможность полноценно работать с uart 0?
При попытке получить данные с другого устройства я получаю очень странные результаты. Возможно это связана с тем, что там постоянно работает REPL и пытается обрабатывать ввод? Есть ли возможность отключить REPL?

Providing a way to tell if gps.get_location() is the actual position

Currently gps.get_location() will return the latest location if it cannot get the current location.
There should be a way to tell if gps.get_location() is the actual position.

Both time and location are from NMEA RMC sentence which probably means that they correspond to each other.
I think about giving access to the timestamp of the last reported location (if there is any). Unfortunately, GPS does not really provide something on demand: it just spams UART2 with its messages

API evolution

Dear pukin, here are some thoughts:

  • Rather than giving the latest available location maybe gps.get_location() could yield (None, None) if not capable of getting the current location?
  • Maybe cellular.gprs(...) would rather not throw an error if already connected as everything is fine,
  • Could you provide the bit-wise specs of get_network_status()?
  • Do you still plan to swap latitude and longitude?

Sync time to RTC

So, I don't really understand what's going on. I don't see anywhere on the code a way to sync the internal RTC to an external time value. This normally is done in mycropython via the ntptime module in this line:

https://github.com/micropython/micropython/blob/4371c971e3dfb743388ccb493c137a25aa9cdd35/ports/esp8266/modules/ntptime.py#L40

We don't have a machine.RTC() function here like the ESP modules but is definitely possible to do one via https://ai-thinker-open.github.io/GPRS_C_SDK_DOC/en/c-sdk/function-api/timertc.html

What I don't understand is that sometimes it just automatically sync when i do some ntptime request/connect to the internet, don't really now when, and utime.time() start giving me the right value. Sometimes it jus't dont sync and I have to restart the module and keep trying.

If I restart the module, connect and try again and so, it will eventually sync and start giving the same right values of ntptime, and stay like this for a while even if the module is restarted.

Is there already a way to do tell the module to sync or it is necessary to change the modutime or modmachine to have access to TIME_SetRtcTime. Btw, I'm using A9 module, not A9G, so I don't have access to gps.time().

1-Wire/Open Drain support

I'm trying to enable 1-Wire support on A9. For that it's necessary to implement Open-Drain GPIO Output somehow by software using SDK GPIO lib, doing something like this: https://embeddedartistry.com/blog/2018/06/11/simulating-open-drain-gpio-in-software/

From what I see, would be necessary to create a way to define a Pin in machine_pin as OpenDrain, to be able to call pin.init(pin.OPEN_DRAIN, pin.PULL_UP) on drivers/onewire/onewire.py. I've stumbled in how to do that, will try further but any help would be appreciated.

ESP8266/ESP32/STM32 are some ports that already support 1-Wire/OpenDrain.

Software UART

Consider implementing it with SYS_EnterCriticalSection

Calls

Implement voice calls in cellular.

mmc sd card ?

First, thanks a lot for this port.
i have a newbie question: Is possible to log gps data to sdcard ?

WebREPL over GPRS

Is it possible to implement something like WebREPL on the A9g but over the GPRS instead of WIFI in the ESP8266. It will allow for sending remote updates to devices over the internet, it will be of great use in many projects. From what I have read a daemon running in the background which forwards the serial REPL through socket must be set. But initially we need to get the GPRS connected of course.

SPI

SPI in machine.SPI

Bugs and limitations of socket module

On the A9G board, with s being a Berkeley socket (import socket; s = socket.socket()) entering the following commands yields errors:

  • s.recv(50) when rx buffer is empty freezes the board, even after a s.settimeout(3),
  • s.connect((url, port)) executed twice in a row freezes the board,
  • looking at s yields <socket> only.

By comparison, behaviors of those commands on an ESP8266 with the latest firmware are:

  • s.recv(50) when rx buffer is empty results in an OSError: [Errno 110] ETIMEDOUT error, after having set s.settimeout(3),
  • s.connect((url, port)) executed twice yields an OSError: 106 error, and the socket remains connected,
  • looking at s yields <socket state=0 timeout=-1 incoming=0 off=0> which gives enhanced state of the socket (e.g., to track network errors).

gps.time() rolls back to zero after mqtt.publish()

I have noticed that gps.time() rolls back to its original value 2525040000 after executing mqtt.publish(topic, message).
I believe the GPS resets completely in that situation for an unknown reason.

UART performance

Make this work:

  • all ampy commands
  • uploading large chunks of data
  • vscode plugin

Explore the USB connection

There are no csdk functions available, however, the module seems to support it while elf/lod contains hal_Usb* functions (signatures are here). It would be nice to implement the serial port over USB as a start.

Supplying parameters for `cellular.gprs` with one or two characters leads to module halt

I am having an issue using cellular.gprs as this command hangs forever when providing my SIM Card APN (TM).
(Providing a wrong APN such as wrong_apn yields an error but the command doesn't hang.)

Example code that hangs my board:

import cellular
cellular.is_network_registered() # returns True!!!!
cellular.gprs("TM", "", "")

Is there a setting I forgot to enter before invoking cellular.gprs?

Official settings for my SIM Card (Things Mobile) are:

  1. If no parameter is set, the device automatically reads the APN: pepper
  2. If you are prompted to set the APN, use the following parameter: TM
  3. If you are asked your username and password, leave the fields empty
  4. Enable data roaming on your device

Additional optional parameters are:

  1. SMS Service Center: 447797704000
  2. MCC: 234
  3. MNC: 50
  4. Operator Code (PLMN): 23450

Additionally I tried to send my phone a SMS from the board invoking cellular.SMS("+33612345678", "test message") as I believe this action is independent from being connected to an APN.
But I didn't receive the SMS... (I entered the correct phone number.)

Any example or hint to perform this action would be appreciated.
Thanks,

Enhancements in `socket`

  • Figure out IPv6
  • Implement server functions and test them somehow
  • Figure out proper implementation of socket.getaddrinfo
  • Figure out whether setting custom DNS is possible and which DNS is used by default

Rebooting the board with Ctrl-D doesn't clear the watchdog

I have noticed that when rebooting the board with Ctrl-D the watchdog remains on (if set before).
It might be the same with machine.reset().

If I remember well, this was also the case on some other MicroPython ports but got fixed.

PWM

Pulse-width modulation in machine.PWM

Fix debugging tools

coolwatcher interaction seems to be broken for a long time (no events being received, for example).

Thonny IDE compatibility

Hi,
thanks a lot for your work!
I tried Thonny IDE with your firmware.
REPL works flawlessly, but file upload/download is impossible, returning a lot of errors/exceptions.
If you are interested about fixing this behaviour, I'll be happy to test, if needed (I m afraid I couldn't do much more than that, because I'm a real newbie in python).
Thanks in advance.

UART

UART in machine.UART

Three hardware UARTs are present in the system: two of them are occupied (service and REPL ports). The third UART may be attached to GPS. Implement software UART?

Fix `ussl` and `uhashlib`

Resolve issues with the build system and move MICROPY_* variables from the Makefile back to mpconfigport.h. Enable uhashlib which causes build failures at this point.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.