diff options
| author | iabdalkader <i.abdalkader@gmail.com> | 2025-02-19 14:42:05 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-04-09 00:22:32 +1000 |
| commit | 68b1dae011dd9f2696e9f6f2f914317d827c879d (patch) | |
| tree | d7248847bda3635e77da2ce8a87514ec14575de5 | |
| parent | 182b5f3a12427d3dc21744b0164d546663ea696b (diff) | |
alif: Link with libnosys.
This allows the correct start up functions to be called by the stdlib.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
| -rw-r--r-- | ports/alif/alif.mk | 22 | ||||
| -rw-r--r-- | ports/alif/main.c | 2 | ||||
| -rw-r--r-- | ports/alif/nosys_stubs.c | 46 |
3 files changed, 58 insertions, 12 deletions
diff --git a/ports/alif/alif.mk b/ports/alif/alif.mk index aa2451d7a..7e58aa572 100644 --- a/ports/alif/alif.mk +++ b/ports/alif/alif.mk @@ -68,9 +68,9 @@ CFLAGS += $(INC) \ -mtune=cortex-m55 \ $(CFLAGS_FPU) \ -march=armv8.1-m.main+fp+mve.fp \ - -nostdlib \ -fdata-sections \ -ffunction-sections \ + --specs=nosys.specs \ -D$(MCU_CORE)=1 \ -DCORE_$(MCU_CORE) \ -DALIF_CMSIS_H="\"$(MCU_CORE).h\"" @@ -95,18 +95,17 @@ CFLAGS += $(CFLAGS_EXTRA) AFLAGS = -mthumb -march=armv8.1-m.main+fp+mve.fp $(CFLAGS_FPU) -LDFLAGS += -nostdlib \ - -T$(BUILD)/ensemble.ld \ - -Map=$@.map \ - --cref \ - --gc-sections \ - --print-memory-usage +CFLAGS += -Wl,-T$(BUILD)/ensemble.ld \ + -Wl,-Map=$@.map \ + -Wl,--cref \ + -Wl,--gc-sections \ + -Wl,--print-memory-usage \ + -Wl,--no-warn-rwx-segment + ifeq ($(MCU_CORE),M55_HP) -LDFLAGS += --wrap=dcd_event_handler +CFLAGS += -Wl,--wrap=dcd_event_handler endif -LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)" - ################################################################################ # Source files and libraries @@ -126,6 +125,7 @@ SRC_C = \ mpu.c \ mpuart.c \ msc_disk.c \ + nosys_stubs.c \ ospi_ext.c \ ospi_flash.c \ pendsv.c \ @@ -256,7 +256,7 @@ $(BUILD)/ensemble.ld: $(LD_FILE) $(BUILD)/firmware.elf: $(OBJ) $(BUILD)/ensemble.ld $(ECHO) "Link $@" - $(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) + $(Q)$(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS) $(Q)$(SIZE) $@ $(BUILD)/firmware.bin: $(BUILD)/firmware.elf diff --git a/ports/alif/main.c b/ports/alif/main.c index 975ee7ed2..793425fff 100644 --- a/ports/alif/main.c +++ b/ports/alif/main.c @@ -55,7 +55,7 @@ NORETURN void panic(const char *msg) { } } -void _start(void) { +int main(void) { system_tick_init(); MICROPY_BOARD_STARTUP(); diff --git a/ports/alif/nosys_stubs.c b/ports/alif/nosys_stubs.c new file mode 100644 index 000000000..a394ec8f1 --- /dev/null +++ b/ports/alif/nosys_stubs.c @@ -0,0 +1,46 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2024 OpenMV LLC. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include <errno.h> + +int _write(int handle, char *buffer, int size) { + errno = ENOSYS; + return -1; +} + +int _read(int handle, char *buffer, int size) { + errno = ENOSYS; + return -1; +} + +int _close(int f) { + errno = ENOSYS; + return -1; +} + +int _lseek(int f, int ptr, int dir) { + errno = ENOSYS; + return -1; +} |
