Frozen modules for my Sipy (Solved)



  • Hi, everybody,

    I have been researching to integrate my .py libraries, as frozen modules, in the firmware of my sipy to be able to call them from the main.py and make my code more secure and efficient.

    I have read that you must build the firmware as they say the instructions in the github repository, but I do not know if before building it should place my modules (.py) in a directory (I think in /py) and run freeze.py or how to do it. I would appreciate any help.

    Regards,



  • @cmisztur Editing pycom-micropython-sigfox/esp32/pycom_version.h you can change the version, but I don't know how to change the name and the other parameters returned by uos.uname(). I'm sorry.

    Regards,



  • @nespressif Helps me! Any idea how to change the version name for the custom build?

    >>> import uos
    >>> uos.uname()
    (sysname='LoPy', nodename='LoPy', release='1.18.1.r1', version='b0520f1-dirty on 2018-10-23', machine='LoPy with ESP32', lorawan='1.0.2')
    


  • Hello everyone,

    I have achieved the correct functioning of the frozen code (my .py libraries) in the firmware of my Sipy 1.0. Now flash a program that imports these libraries without having to include them in the /lib of my program.

    Steps:

    1.- I create a folder and clone in it the two necessary repositories (pycom-micropython-sigfox and pycom-esp-idf) and its submodules, also I download xtense gcc compiler and including it in the variable PATH, as it indicates the readme of the repository.

    2.- Configure the IDF_PATH environment variable with the export command indicating the complete path. $ export IDF_PATH=~/mifolder/pycom-esp-idf

    3.- Once this is done, I copy my libraries in the folder /esp32/frozen/common

    4.- I follow the instructions to build and flash the firmware.
    4.1.- cd mpy-cross && make clean && make & cd ..
    4.2.- cd esp32
    make BOARD=SIPY -j5 TARGET=boot
    make BOARD=SIPY -j5 TARGET=app
    4.3.- Once the firmware has been built without errors:
    make BOARD=SIPY -j5 flash

    And you can now load any program that uses your libraries. I hope it helps someone.

    Regards,



  • @nespressif I know, readme after readme, they all blend together.



  • I've built the new firmware with my integrated libraries, no problem. I placed my .py libraries in the ...esp32/frozen/common folder and then built it following the instructions

    $ cd ../esp32
    $ make BOARD=LOPY -j5 TARGET=boot
    make BOARD=LOPY -j5 TARGET=app
    

    Everything has worked correctly, now I just need to flash the firmware to the board and then it is assumed that any program (main.py) that loads will be able to import my libraries without having to include them in the /lib directory.

    When I try I tell you...



  • @cmisztur Perfect, I didn't see it. I'll try it and if I get it I'll tell it here.

    Thank you



  • Oh duh, it's right there at the bottom of https://github.com/pycom/pycom-micropython-sigfox/tree/master/esp32.

    "Using frozen modules
    Place all the python scripts that you'd like to be frozen into the flash memory of the board inside the 'frozen' folder in the esp32 directory. Then build as indicated before."



  • I haven't tried, but I would think pycom-micropython-sigfox/esp32/frozen/.

    https://github.com/pycom/pycom-micropython-sigfox/blob/b0520f1e17f395952fdf01065865fc71a07e596a/py/mkrules.mk#L112

    Let us know what ends up working for you.

    /c


 

Hello World?

Pylife on Kickstarter - November 2018








Back Us On Kickstarter >

Pycom on Twitter