MicroPython on ESP32 with SPIRAM support

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Fri Jan 05, 2018 9:04 am

I'm not shure how 32-bit toolchain ended in repository, sorry about that.
The 64-bit is now pushed, you can update using git pull.
After the update just delete your Tools/xtensa-esp32-elf directory, the new one (64-bit) will be unpacked on first run of BUILD.sh.

I have also uploaded the 32-bit toolchain (Tools/Linux/xtensa-esp32-elf_32bit.tar.xz), if anyone is using 32-bit Linux.
Later, I'll update the BUILD.sh script to automatically unpack the right toolchain depending on the Linux version.

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Fri Jan 05, 2018 9:39 am

OutoftheBOTS_ wrote:
Fri Jan 05, 2018 8:52 am
I tried to use my program that was running on last firmware and it wouldn't run on the new firmware. The SPI threw an error
It looks there is a bug in spi initialization, I'm working on it, hope to push the fix shortly.

Edit: The fix is pushed, but Im still working on adding some more funstions to SPI module...

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: MicroPython on ESP32 with SPIRAM support

Post by OutoftheBOTS_ » Fri Jan 05, 2018 7:45 pm

In menuconfig use both core for MiroPython tasks is unchecked. I should leave this unchecked for psRAM boards but checked for non psRAM boards??

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Fri Jan 05, 2018 7:58 pm

OutoftheBOTS_ wrote:
Fri Jan 05, 2018 7:45 pm
In menuconfig use both core for MiroPython tasks is unchecked. I should leave this unchecked for psRAM boards but checked for non psRAM boards??
It makes almost no difference at the moment, it is there for the future development. I'll add the comment about that.
It is in no way related to psRAM.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: MicroPython on ESP32 with SPIRAM support

Post by OutoftheBOTS_ » Fri Jan 05, 2018 8:15 pm

There is also a bug in the deint() for the SPI it throws this error

Code: Select all

OSError: error at deinitialization

ttmetro
Posts: 104
Joined: Mon Jul 31, 2017 12:44 am

Re: MicroPython on ESP32 with SPIRAM support

Post by ttmetro » Sat Jan 06, 2018 9:38 pm

How do I add a custom C-module?

I added it to SRC_C in components/microphython/component.mk.
It compiles, but does not get included in the firmware.

Code (with probably more headers than I need):

Code: Select all

#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <string.h>

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "rom/uart.h"
#include "esp_task_wdt.h"

#include "py/nlr.h"
#include "py/obj.h"
#include "py/mpstate.h"
#include "py/mphal.h"
#include "extmod/misc.h"
#include "lib/utils/pyexec.h"
#include "uart.h"
#include "sdkconfig.h"

//-----------------------------------
// does nothing for now ...
STATIC mp_obj_t iot49_sleep_us(mp_obj_t arg) {
    mp_int_t us = mp_obj_get_int(arg);
    return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(iot49_sleep_us_obj, iot49_sleep_us);

//===============================================================
STATIC const mp_rom_map_elem_t iot49_module_globals_table[] = {
    { MP_ROM_QSTR(MP_QSTR___name__),    MP_ROM_QSTR(MP_QSTR_iot49) },

    { MP_ROM_QSTR(MP_QSTR_sleep_us),	  MP_ROM_PTR(&iot49_sleep_us_obj) },
};
STATIC MP_DEFINE_CONST_DICT(
    iot49_module_globals,
    iot49_module_globals_table
);

//=========================================
const mp_obj_module_t mp_module_iot49 = {
    .base = { &mp_type_module },
    .globals = (mp_obj_dict_t*)&iot49_module_globals,
};

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: MicroPython on ESP32 with SPIRAM support

Post by Roberthh » Sun Jan 07, 2018 7:03 am

If you look at the end of mpconfigport.h, there is a section where the modules a listed. You may add your module there, taking one of the existing definitions as template.

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Sun Jan 07, 2018 4:23 pm

ttmetro wrote:
Sat Jan 06, 2018 9:38 pm
How do I add a custom C-module?

I added it to SRC_C in components/microphython/component.mk.
It compiles, but does not get included in the firmware.
To add your c-module mp_module_iot49 to the built-in modeles edit the mpconfigport.h:

Add before #define MICROPY_PORT_BUILTIN_MODULES

Code: Select all

extern const struct _mp_obj_module_t mp_module_iot49;
#define BUILTIN_MODULE_IOT49 { MP_OBJ_NEW_QSTR(MP_QSTR_iot49), (mp_obj_t)&mp_module_iot49 },
Then add as last entry in #define MICROPY_PORT_BUILTIN_MODULES

Code: Select all

	BUILTIN_MODULE_IOT49 \
Save and run

Code: Select all

./BUILD.sh clean all

ttmetro
Posts: 104
Joined: Mon Jul 31, 2017 12:44 am

Re: MicroPython on ESP32 with SPIRAM support

Post by ttmetro » Sun Jan 07, 2018 6:55 pm

@roberthh and @loboris: Thanks a million, everything works now as expected!
Bernhard Boser

User avatar
rdagger
Posts: 143
Joined: Tue Feb 28, 2017 6:16 pm
Contact:

Re: MicroPython on ESP32 with SPIRAM support

Post by rdagger » Wed Jan 10, 2018 7:13 pm

loboris wrote:
Wed Nov 22, 2017 2:38 pm
Bluetooth does not work, BT module will be (temporarily) removed from build in next commit.
There's a lot of interest in Bluetooth and BLE. Any updates on the BT module?

Post Reply