This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remote LCD Nokia5510/JLX12864 with ESP32
Hello Sean,

i cant make it work. These are the steps i followed: 

following this guide :

sudo apt-get install esptool
mkdir esp
cd esp
git clone -b v4.2 --recursive
cd esp-idf
source (I know i have to rerun this command each time i quit the terminal session)
mkdir micropython
cd micropython
mkdir esp32
cd esp32
git clone
cd micropython
make -C mpy-cross
cd ports/esp32
make submodules

It builds! So everything is ok until now. 

i uploaded with :
make erase
make deploy

It uploads and micropython is working on the esp32

Now, when i :

cd ~/Desktop
git clone
cd pypilot-master/hat
nano Makefile #to change the MPY-CROSS path to my own
make upload

The .mpy files are created and uploaded to my esp32. I can see the files when i connect to the esp32's console and type :

import os

when i press the reboot button on the esp32 pcb and look at the console i see import pypilot module not found in the file. Ok i knew it because the ugfx module in not in the esp32 and in the file here :

   import micropython
   import ugfx
   #fontpath = '/_#!#_spiffs/ugfxfonts/'
   fontpath = ''
   character = ugfx.surface(64, 84, 1)

   micropython = False
   import os
   from pypilot.hat.ugfx import ugfx

If it fails to load ugfx module, it thinks it is in raspberry enviroment.


Now the fun starts. Compiling the micropython with your micropython_ugfx module.

cd ~/micropython/esp32/micropython
mkdir modules
cd modules
git clone
mv micropython_ugfx ugfx
cd ../ports/esp32
make clean

This one FAILS with 

CMake Error at /home/labcnc/Desktop/micropython/py/usermod.cmake:42 (include):
 include requested file is a directory:

Call Stack (most recent call first):
 main/CMakeLists.txt:10 (include)

I found a very usefull link :

In this link it says that you need to point to the .cmake file but you dont have a .cmake file in github repo. So i took the one in the example folder and altered it and copied it in:

This is the file:
# Create an INTERFACE library for our C module.
add_library(usermod_ugfx INTERFACE)

# Add our source files to the lib
target_sources(usermod_ugfx INTERFACE

# Add the current directory as an include directory.
target_include_directories(usermod_ugfx INTERFACE

# Link our INTERFACE library to the usermod target.
target_link_libraries(usermod INTERFACE usermod_ugfx)

then again: 

cd ~/micropython/esp32/micropython/ports/esp32/
make clean
make USER_C_MODULES=../../../modules/ugfx/micropython.cmake CFLAGS_EXTRA="-DMODULE_UGFX_ENABLED=1" all
this one FAILS with that error and some warnings :
/home/labcnc/Desktop/micropython2/modules/ugfx/modugfx.c:184:35: error: 'ugfx_surface_free_obj' defined but not used [-Werror=unused-const-variable=]
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ugfx_surface_free_obj, 0, ugfx_surface_free);
/home/labcnc/Desktop/micropython2/py/obj.h:351:36: note: in definition of macro 'MP_DEFINE_CONST_FUN_OBJ_KW'
    const mp_obj_fun_builtin_var_t obj_name = \
cc1: some warnings being treated as errors

I edited the mofugfx.c file and commented out line 184 since it is not used. 
I rerun the make clean and make commants above and this time it FINISHED and i had a smile until my ears ! But lasted not so long  Big Grin Big Grin
I uploaded the binaries with make erase and make deploy and restarted the esp32 with no errors on the console. I tried to import ugfx in the console and ... No existing module named ugfx 
I thought that maybe the 
is not recognized because when i runned the make command i saw that the files where builded

So i edited the modugfx.c file again and in the end i changed the line :

MP_REGISTER_MODULE(MP_QSTR_ugfx, mp_module_ugfx, 1);

again :

make clean
make USER_C_MODULES=../../../modules/ugfx/micropython.cmake all

This time it FAILS after 
Linking CXX executable micropython.elf
with :

/home/labcnc/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: CMakeFiles/micropython.elf.dir/home/labcnc/Desktop/micropython2/modules/ugfx/modugfx.c.obj:(.literal+0x14): undefined reference to `ugfx_surface_c_free'
/home/labcnc/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: CMakeFiles/micropython.elf.dir/home/labcnc/Desktop/micropython2/modules/ugfx/modugfx.c.obj: in function `ugfx_display_surface_refresh':
modugfx.c:(.text+0x39b): undefined reference to `ugfx_surface_c_free'
collect2: error: ld returned 1 exit status

Now i am stucked  Cool

I tried esp-idf 4.0.2 and 4.1.1 and 4.2
i tried the official micropython repository with the same results

Any Ideas ? 

did you modify it to support the lcd you have?

yes obviously you are building it wrong

basically you commented out a function to suppress a warning treated as an error that should not have been considered an error

then this leads to new problems linking, so fix the -Wno-error flag to not set
(2022-01-11, 02:38 AM)seandepagnier Wrote: did you modify it to support the lcd you have?

yes obviously you are building it wrong

basically you commented out a function to suppress a warning treated as an error that should not have been considered an error

then this leads to new problems linking, so fix the -Wno-error flag to not set

No i didnt change anything yet. I will try it with the same screen you have to see that its working and then i will see what i can do for the jlx12864 screen.

I will try this flag in the afternoon after work and i will post back.

Could you also post the pinout connections from the esp to the screen and the buttons ? 

Thank you Sean you are awesome !
i am using ttgo t display module you can find the schematic:

You can redefine the pins by changing the code too.
No... i cant figure it out how i input the -Wno-error=unused-const-variable and -Wno-unused-const-variable flags.

can you tell me what to do ?


I figured how to insert the flags. Now it gets past the previus error. But cant still not compile. I am again in the point of my previous post. Here...

/home/labcnc/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: CMakeFiles/micropython.elf.dir/home/labcnc/Desktop/micropython/modules/micropython_ugfx/modugfx.c.obj:(.literal+0x14): undefined reference to `ugfx_surface_c_free'
/home/labcnc/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: CMakeFiles/micropython.elf.dir/home/labcnc/Desktop/micropython/modules/micropython_ugfx/modugfx.c.obj: in function `ugfx_display_surface_refresh':
modugfx.c:(.text+0x39b): undefined reference to `ugfx_surface_c_free'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Makefile:34: recipe for target 'all' failed
make: *** [all] Error 2

The flags are inserted in the micropython.cmake file i posted above.
Just add this line at the end : 

target_compile_options(usermod_ugfx INTERFACE -Wno-error=unused-const-variable -Wno-unused-const-variable)

Now...does anyone have any suggestions how to proceed ? 

Did you apply the patch in the README to support c++?
No i didnt apply the patch. Where and how do i apply it ?


Ok so i have done my homework. i understand that this thing you posted in the is the output of the git diff command when you made the changes in the /ports/esp32/Makefile.

diff --git a/ports/esp32/Makefile b/ports/esp32/Makefile
index dcf4110cf..c473783e3 100644
--- a/ports/esp32/Makefile
+++ b/ports/esp32/Makefile
@@ -378,7 +378,8 @@ DRIVERS_SRC_C = $(addprefix drivers/,\

OBJ_MP += $(PY_O)
-OBJ_MP += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
+OBJ_SRC_C = $(SRC_C:.c=.o)
+OBJ_MP += $(addprefix $(BUILD)/, $(OBJ_SRC_C:.cpp=.o))
OBJ_MP += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
OBJ_MP += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
OBJ_MP += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))

The thing is that i have the stock Makefile and i dont know where to add thoose. I tried to copy them to a file named test.patch and runned from the repository's root the git apply test.patch but this is returning error.

Could you please give me some usable help here and not only just a few words? I will write a guide for the others afterwards.
If you have no time there is no problem. Just say it and i will give up and sleep more Angel
You could manually apply it is so trivial, anyway, I just invoke patch directly, eg:

patch -p3 < patchfile

do you have your micropython repository online or can show me the exact branch you are using? I can diff from mine.
I cloned your micropython fork
and your only error is because of a warning being treated as an error?

Forum Jump:

Users browsing this thread: 1 Guest(s)