From 95ea03431757a829f0018b2950519add508d2629 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Thu, 31 Aug 2023 10:07:55 +0100 Subject: Add micropython building script --- create_installroot/boot_qemu.sh | 3 + create_tools/config/0001-Mod-micropython.patch | 82 ++++++++++++++++++++++++++ create_tools/create_micropython.sh | 25 ++++++++ create_tools/tools_download.sh | 3 +- 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 create_tools/config/0001-Mod-micropython.patch create mode 100755 create_tools/create_micropython.sh diff --git a/create_installroot/boot_qemu.sh b/create_installroot/boot_qemu.sh index d14b102..11ebc5d 100755 --- a/create_installroot/boot_qemu.sh +++ b/create_installroot/boot_qemu.sh @@ -7,6 +7,9 @@ qemu-system-x86_64 \ -m 256 \ -netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no -device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 +#https://gist.github.com/extremecoders-re/e8fd8a67a515fee0c873dcafc81d811c +#https://stackoverflow.com/questions/15626088/tap-interfaces-and-dev-net-tun-device-using-ip-tuntap-command + #qemu-system-x86_64 -drive format=raw,file=xos_image.img -m 128 #qemu-system-x86_64 \ # -kernel bootfs/vmlinuz-xos \ diff --git a/create_tools/config/0001-Mod-micropython.patch b/create_tools/config/0001-Mod-micropython.patch new file mode 100644 index 0000000..0df5d8e --- /dev/null +++ b/create_tools/config/0001-Mod-micropython.patch @@ -0,0 +1,82 @@ +From bd97b42bdae5685571eaeb077232500c6dfd6234 Mon Sep 17 00:00:00 2001 +From: Arturs Artamonovs +Date: Thu, 31 Aug 2023 09:25:05 +0100 +Subject: [PATCH] Mod micropython + +--- + ports/unix/Makefile | 8 ++++---- + ports/unix/mpconfigport.mk | 6 +++--- + py/stackctrl.c | 2 ++ + 3 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/ports/unix/Makefile b/ports/unix/Makefile +index 403405dcc..116b9f658 100644 +--- a/ports/unix/Makefile ++++ b/ports/unix/Makefile +@@ -44,9 +44,9 @@ INC += -I$(TOP) + INC += -I$(BUILD) + + # compiler settings +-CWARN = -Wall -Werror ++CWARN = -Wall + CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith -Wdouble-promotion -Wfloat-conversion +-CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA) ++CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA) -static + + # Debugging/Optimization + ifdef DEBUG +@@ -102,10 +102,10 @@ else + CC = clang + endif + # Use clang syntax for map file +-LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip ++LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip -static + else + # Use gcc syntax for map file +-LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections ++LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections -static + endif + LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) + +diff --git a/ports/unix/mpconfigport.mk b/ports/unix/mpconfigport.mk +index ce6183c13..11fbbb7b2 100644 +--- a/ports/unix/mpconfigport.mk ++++ b/ports/unix/mpconfigport.mk +@@ -18,10 +18,10 @@ MICROPY_PY_THREAD = 1 + MICROPY_PY_TERMIOS = 1 + + # Subset of CPython socket module +-MICROPY_PY_SOCKET = 1 ++MICROPY_PY_SOCKET = 0 + + # ffi module requires libffi (libffi-dev Debian package) +-MICROPY_PY_FFI = 1 ++MICROPY_PY_FFI = 0 + + # ussl module requires one of the TLS libraries below + MICROPY_PY_USSL = 1 +@@ -37,7 +37,7 @@ MICROPY_PY_JNI = 0 + + # Avoid using system libraries, use copies bundled with MicroPython + # as submodules (currently affects only libffi). +-MICROPY_STANDALONE = 0 ++MICROPY_STANDALONE = 1 + + MICROPY_ROM_TEXT_COMPRESSION = 1 + +diff --git a/py/stackctrl.c b/py/stackctrl.c +index c2f3adb5e..4675532ad 100644 +--- a/py/stackctrl.c ++++ b/py/stackctrl.c +@@ -27,6 +27,8 @@ + #include "py/runtime.h" + #include "py/stackctrl.h" + ++#pragma GCC diagnostic ignored "-Wdangling-pointer=1" ++ + void mp_stack_ctrl_init(void) { + volatile int stack_dummy; + MP_STATE_THREAD(stack_top) = (char *)&stack_dummy; +-- +2.42.0 + diff --git a/create_tools/create_micropython.sh b/create_tools/create_micropython.sh new file mode 100755 index 0000000..0f49dae --- /dev/null +++ b/create_tools/create_micropython.sh @@ -0,0 +1,25 @@ +#!/bin/dash + +SOURCE_DIR=src +MPY_VERSION=1.20.0 + +OUT_DIRECTORY=out + +#prepare +_PWD=`pwd` + +echo "Unarchive busbox" +cd $SOURCE_DIR +tar -xvf micropython-$MPY_VERSION.tar.xz +cd micropython-$MPY_VERSION +#git submodule init +#git submodule update +patch -p1 < ../../config/0001-Mod-micropython.patch +cd ports/unix +make submodules +make -j4 + +#save result +echo "Copy result to out" +cp ./build-standard/micropython ../../../../$OUT_DIRECTORY + diff --git a/create_tools/tools_download.sh b/create_tools/tools_download.sh index e48c536..99597e3 100755 --- a/create_tools/tools_download.sh +++ b/create_tools/tools_download.sh @@ -5,5 +5,6 @@ echo "Download tools" cd src wget -c http://busybox.net/downloads/busybox-1.36.1.tar.bz2 wget -c https://github.com/arsv/minibase/archive/0.7.zip -O minibase.zip - +wget -c https://micropython.org/resources/source/micropython-1.20.0.tar.xz +#git clone --branch v1.20.0 https://github.com/micropython/micropython.git micropython-1.20.0 echo "" -- cgit v1.2.3