Skip to content

Commit

Permalink
examples/natmod: Gen .mpy for deepcraft models. Gen working.
Browse files Browse the repository at this point in the history
Signed-off-by: NikhitaR-IFX <[email protected]>
  • Loading branch information
NikhitaR-IFX committed Jan 28, 2025
1 parent 9ddd321 commit 30608e7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/natmod/deepcraft_dyn/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MPY_DIR = ../../..
MOD = deepcraft

# Source files (.c or .py)
SRC = model.c dc_mp_iface.c
SRC = dc_mp_iface.c model_1.c

# Architecture to build for (x86, x64, armv7m, xtensa, xtensawin, rv32imc)
ARCH = armv7emsp
Expand Down
11 changes: 4 additions & 7 deletions examples/natmod/deepcraft_dyn/dc_mp_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

#include "py/dynruntime.h"

#if !defined(__linux__)
/*#if !defined(__linux__)
void *memcpy(void *dst, const void *src, size_t n) {
return mp_fun_table.memmove_(dst, src, n);
}
void *memset(void *s, int c, size_t n) {
return mp_fun_table.memset_(s, c, n);
}
#endif
#endif*/

int native_errno=0;
/*int native_errno=0;
#if defined(__linux__)
int *__errno_location (void)
#else
int *__errno (void)
#endif
{
return &native_errno;
}
}*/

mp_obj_full_type_t dcmodel_type;

Expand All @@ -41,9 +41,6 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a

mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_deepcraft));
mp_store_global(MP_QSTR_DEEPCRAFT, MP_OBJ_FROM_PTR(&dcmodel_type));
/*mp_store_global(MP_QSTR_RAW, MP_OBJ_NEW_SMALL_INT(DEFLATEIO_FORMAT_RAW));
mp_store_global(MP_QSTR_ZLIB, MP_OBJ_NEW_SMALL_INT(DEFLATEIO_FORMAT_ZLIB));
mp_store_global(MP_QSTR_GZIP, MP_OBJ_NEW_SMALL_INT(DEFLATEIO_FORMAT_GZIP));*/

MP_DYNRUNTIME_INIT_EXIT
}
Expand Down
2 changes: 1 addition & 1 deletion examples/natmod/deepcraft_dyn/mp_src.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string.h>

static mp_obj_t init(void){
//assign();
assign();
IMAI_init();
return mp_const_none;
}
Expand Down
6 changes: 3 additions & 3 deletions py/dynruntime.mk
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ LIBGCC_PATH := $(realpath $(shell $(CROSS)gcc $(CFLAGS) --print-libgcc-file-name
LIBM_PATH := $(realpath $(shell $(CROSS)gcc $(CFLAGS) --print-file-name=libm.a))
#LIBC_PATH := $(realpath $(shell $(CROSS)gcc $(CFLAGS) --print-file-name=libc_nano.a))
# Include all .a files in a specific directory
#LIBRARY_DIR := /home/nikhita/ModusToolbox/tools_3.0/gcc/arm-none-eabi/lib/thumb/v7e-m+fp/hard/
#ALL_A_FILES := $(wildcard $(LIBRARY_DIR)/*.a)
LIBRARY_DIR := /home/nikhita/ModusToolbox/tools_3.0/gcc/arm-none-eabi/lib/thumb/v7e-m+fp/hard/
ALL_A_FILES := $(wildcard $(LIBRARY_DIR)/*.a)

MPY_LD_FLAGS += $(addprefix -l, $(LIBGCC_PATH) $(LIBM_PATH))
MPY_LD_FLAGS += $(addprefix -l, $(LIBGCC_PATH) $(LIBM_PATH) $(ALL_A_FILES))
LDFLAGS += --specs=nano.specs -u _printf_float -u _scanf_float
endif

Expand Down

0 comments on commit 30608e7

Please sign in to comment.