[SOLVED]lexerfrozen.c - what's the point of this?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

[SOLVED]lexerfrozen.c - what's the point of this?

Post by jickster » Thu Oct 19, 2017 2:45 am

In the teensy port, there is the following in the makefile

Code: Select all

ifeq ($(USE_FROZEN),1)

ifeq ($(FROZEN_DIR),)
FROZEN_DIR = memzip_files
endif

CFLAGS += -DMICROPY_MODULE_FROZEN_STR

SRC_C += \
	lexerfrozen.c \
	$(BUILD)/frozen.c

endif # USE_FROZEN
I understand why that's there.

What I do not understand is the content of lexerfrozen.c

Code: Select all

#include <stdio.h>

#include "py/lexer.h"
#include "py/runtime.h"
#include "py/mperrno.h"

mp_import_stat_t mp_import_stat(const char *path) {
    return MP_IMPORT_STAT_NO_EXIST;
}

mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
    mp_raise_OSError(MP_ENOENT);
}
That is the entire file.
Last edited by jickster on Mon Nov 06, 2017 5:06 pm, edited 1 time in total.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: lexerfrozen.c - what's the point of this?

Post by dhylands » Thu Oct 19, 2017 3:49 pm

The teensy doesn't have enough flash to support an internal filesystem like the pyboard.
So basically, those functions exist to say that if you're trying to import from a filesystem, then fail.

The teensy supports using frozen modules, which need to be compiled into the firmware.

The teensy3.6 and 3.5 do have sdcard support, and IIRC these were supported in my development branch:
https://github.com/dhylands/micropython/tree/teensy-3.6
which is in need of updating.

Post Reply