From 4afd06555fe700e6934c3238c93e7f0016f42aae Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Fri, 15 Oct 2021 16:11:06 +0800 Subject: [PATCH 01/21] qemu newlibc test ok --- baremetal/example/libc_port/README.md | 44 +++++ baremetal/example/libc_port/glibc.sh | 27 +++ baremetal/example/libc_port/newlibc.sh | 38 ++++ baremetal/example/libc_port/run.sh | 19 ++ baremetal/example/libc_port/startup.s | 93 ++++++++++ baremetal/example/libc_port/syscalls.c | 119 ++++++++++++ baremetal/example/libc_port/test.c | 59 ++++++ baremetal/example/libc_port/test.ld | 56 ++++++ baremetal/example/qemu_libc_test/build.sh | 28 +++ baremetal/example/qemu_libc_test/clean.sh | 14 ++ baremetal/example/qemu_libc_test/link.ld | 67 +++++++ baremetal/example/qemu_libc_test/main.c | 78 ++++++++ baremetal/example/qemu_libc_test/run.sh | 19 ++ baremetal/example/qemu_libc_test/start.S | 172 ++++++++++++++++++ baremetal/example/qemu_libc_test/syscalls.c | 119 ++++++++++++ baremetal/example/qemu_test/build.sh | 21 +++ baremetal/example/qemu_test/clean.sh | 14 ++ baremetal/example/qemu_test/link.ld | 61 +++++++ baremetal/example/qemu_test/main.c | 46 +++++ baremetal/example/qemu_test/run.sh | 19 ++ baremetal/example/qemu_test/start.S | 172 ++++++++++++++++++ baremetal/example/qemu_test/start.S.old | 192 ++++++++++++++++++++ 22 files changed, 1477 insertions(+) create mode 100644 baremetal/example/libc_port/README.md create mode 100644 baremetal/example/libc_port/glibc.sh create mode 100644 baremetal/example/libc_port/newlibc.sh create mode 100644 baremetal/example/libc_port/run.sh create mode 100644 baremetal/example/libc_port/startup.s create mode 100644 baremetal/example/libc_port/syscalls.c create mode 100644 baremetal/example/libc_port/test.c create mode 100644 baremetal/example/libc_port/test.ld create mode 100644 baremetal/example/qemu_libc_test/build.sh create mode 100644 baremetal/example/qemu_libc_test/clean.sh create mode 100644 baremetal/example/qemu_libc_test/link.ld create mode 100644 baremetal/example/qemu_libc_test/main.c create mode 100644 baremetal/example/qemu_libc_test/run.sh create mode 100644 baremetal/example/qemu_libc_test/start.S create mode 100644 baremetal/example/qemu_libc_test/syscalls.c create mode 100644 baremetal/example/qemu_test/build.sh create mode 100644 baremetal/example/qemu_test/clean.sh create mode 100644 baremetal/example/qemu_test/link.ld create mode 100644 baremetal/example/qemu_test/main.c create mode 100644 baremetal/example/qemu_test/run.sh create mode 100644 baremetal/example/qemu_test/start.S create mode 100644 baremetal/example/qemu_test/start.S.old diff --git a/baremetal/example/libc_port/README.md b/baremetal/example/libc_port/README.md new file mode 100644 index 000000000..3a99a5028 --- /dev/null +++ b/baremetal/example/libc_port/README.md @@ -0,0 +1,44 @@ + + +- https://sourceware.org/newlib/ftp/ +- get newlib source code +``` +wget ftp://sourceware.org/pub/newlib/newlib-4.1.0.tar.gz +tar xzf newlib-4.1.0.tar.gz +cd newlib-4.1.0/ +./configure --target arm-none-eabi --disable-newlib-supplied-syscalls +make +cd .. +``` + +- compile the program with the Glib +``` +arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o test.o test.c +arm-none-eabi-as -mcpu=cortex-a8 -o startup.o startup.s +arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o syscalls.o syscalls.c +arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o $AARCH32_CROSS_PATH/arm-none-eabi/lib/thumb/v7/nofp/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.3.1/libgcc.a -o test +arm-none-eabi-objcopy -O binary test test.bin +qemu-system-arm -M realview-pb-a8 -serial stdio -kernel test.bin +``` + +- compile the program with the Newlib +``` +arm-none-eabi-gcc -mcpu=cortex-a8 -I ./newlib-4.1.0/newlib/libc/include -c -o test.o test.c +arm-none-eabi-as -mcpu=cortex-a8 -o startup.o startup.s +arm-none-eabi-gcc -mcpu=cortex-a8 -I ./newlib-4.1.0/newlib/libc/include -c -o syscalls.o syscalls.c +arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o ./newlib-4.1.0/arm-none-eabi/newlib/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.3.1/libgcc.a -o test +arm-none-eabi-objcopy -O binary test test.bin +qemu-system-arm -M realview-pb-a8 -serial stdio -kernel test.bin +``` \ No newline at end of file diff --git a/baremetal/example/libc_port/glibc.sh b/baremetal/example/libc_port/glibc.sh new file mode 100644 index 000000000..ef75f8b19 --- /dev/null +++ b/baremetal/example/libc_port/glibc.sh @@ -0,0 +1,27 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-10-15 11:31:43 + # @LastEditTime: 2021-10-15 11:45:37 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### +echo "compiling test.c" +arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o test.o test.c +echo "compiling startup.s" +arm-none-eabi-as -mcpu=cortex-a8 -o startup.o startup.s +echo "compiling syscalls.s" +arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o syscalls.o syscalls.c +echo "linking" +arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o $AARCH32_CROSS_PATH/arm-none-eabi/lib/thumb/v7/nofp/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.3.1/libgcc.a -o test +echo "objcopying" +arm-none-eabi-objcopy -O binary test test.bin +echo "running" +#$PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -M realview-pb-a8 -serial stdio -kernel test.bin +$PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -machine vexpress-a9 -m 1024M \ + -serial stdio -kernel test.bin diff --git a/baremetal/example/libc_port/newlibc.sh b/baremetal/example/libc_port/newlibc.sh new file mode 100644 index 000000000..a2db701c9 --- /dev/null +++ b/baremetal/example/libc_port/newlibc.sh @@ -0,0 +1,38 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-10-15 11:31:43 + # @LastEditTime: 2021-10-15 14:44:38 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### +# echo "compiling test.c" +# arm-none-eabi-gcc -mcpu=cortex-a8 -I ./newlib-4.1.0/newlib/libc/include -c -o test.o test.c +# echo "compiling syscalls.s" +# arm-none-eabi-as -mcpu=cortex-a8 -o startup.o startup.s +# echo "compiling startup.s" +# arm-none-eabi-gcc -mcpu=cortex-a8 -I ./newlib-4.1.0/newlib/libc/include -c -o syscalls.o syscalls.c +# echo "linking" +# arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o ./newlib-4.1.0/arm-none-eabi/newlib/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.2.1/libgcc.a -o test +# echo "objcopying" +# arm-none-eabi-objcopy -O binary test test.bin + +echo "compiling startup.s" +arm-none-eabi-as -o startup.o startup.s + +echo "compiling test.c" +arm-none-eabi-gcc -I ./newlib-4.1.0/newlib/libc/include -c -nostdlib -nostartfiles -o test.o test.c + +echo "compiling syscalls.c" +arm-none-eabi-gcc -I ./newlib-4.1.0/newlib/libc/include -c -nostdlib -nostartfiles -o syscalls.o syscalls.c + +echo "linking" +arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o ./newlib-4.1.0/arm-none-eabi/newlib/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.2.1/libgcc.a -o test + +echo "objcopying" +arm-none-eabi-objcopy -O binary test test.bin \ No newline at end of file diff --git a/baremetal/example/libc_port/run.sh b/baremetal/example/libc_port/run.sh new file mode 100644 index 000000000..57c695048 --- /dev/null +++ b/baremetal/example/libc_port/run.sh @@ -0,0 +1,19 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-10-15 14:13:51 + # @LastEditTime: 2021-10-15 15:10:14 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### +echo "running" +# $PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -machine vexpress-a9 -m 1024M \ +# -serial stdio -kernel test.bin + +qemu-system-arm -M vexpress-a9 -kernel test.bin -nographic +#qemu-system-arm -machine vexpress-a9 -m 1024M -serial stdio -kernel test.bin \ No newline at end of file diff --git a/baremetal/example/libc_port/startup.s b/baremetal/example/libc_port/startup.s new file mode 100644 index 000000000..0d6936758 --- /dev/null +++ b/baremetal/example/libc_port/startup.s @@ -0,0 +1,93 @@ +/* Some defines */ +.equ MODE_FIQ, 0x11 +.equ MODE_IRQ, 0x12 +.equ MODE_SVC, 0x13 + +.section .vector_table, "x" +.global _Reset +.global _start +_Reset: + b Reset_Handler + b Abort_Exception /* 0x4 Undefined Instruction */ + b . /* 0x8 Software Interrupt */ + b Abort_Exception /* 0xC Prefetch Abort */ + b Abort_Exception /* 0x10 Data Abort */ + b . /* 0x14 Reserved */ + b . /* 0x18 IRQ */ + b . /* 0x1C FIQ */ + +.section .text /* The code segment, RD, program’s executable code */ +Reset_Handler: + bl early_print + /* FIQ stack */ + /* Current Program Status Register, + change cpsr without affacting the + condition flags */ + msr cpsr_c, MODE_FIQ /* switch the processor to FIQ mode */ + ldr r1, =_fiq_stack_start /* load start address into R1 */ + ldr sp, =_fiq_stack_end /* load the end address of the FIQ stack into SP */ + movw r0, #0xFEFE + movt r0, #0xFEFE /* corresponds to loading x << 16 | y into r0 */ + +/* This is the loop that actually fills the stack with 0xFEFEFEFE */ +fiq_loop: + cmp r1, sp /* compares the value in R1 to the value in SP */ + strlt r0, [r1], #4 /* If R1 is less than SP, + the value in R0 will be written to the + address stored in R1, + and R1 gets increased by 4 */ + blt fiq_loop /* the loop continues as long as R1 is less than SP */ + + /* IRQ stack */ + msr cpsr_c, MODE_IRQ + ldr r1, =_irq_stack_start + ldr sp, =_irq_stack_end + +/* fill irq stack */ +irq_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt irq_loop + + /* Supervisor mode */ + msr cpsr_c, MODE_SVC + ldr r1, =_stack_start + ldr sp, =_stack_end + +/* fill the supervisor mode stack */ +stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt stack_loop + + /* Start copying data */ + ldr r0, =_text_end /* section address has been defined in ld script */ + ldr r1, =_data_start + ldr r2, =_data_end + +/* loop continues over the entirety of .data in ROM */ +data_loop: + cmp r1, r2 + ldrlt r3, [r0], #4 /* t load 4 bytes of data from ROM into R3 */ + strlt r3, [r1], #4 + blt data_loop + + /* Initialize .bss */ + mov r0, #0 + ldr r1, =_bss_start + ldr r2, =_bss_end + +/* loop over memory between the addresses _bss_start and _bss_end */ +/* there is no ROM address, and zeros just take up space */ +bss_loop: + cmp r1, r2 + strlt r0, [r1], #4 + blt bss_loop + + bl early_print + bl c_entry /* continue running in case the main function */ + b Abort_Exception /* indicate an error, never execute when main contains infinite loop */ + +Abort_Exception: + swi 0xFF + diff --git a/baremetal/example/libc_port/syscalls.c b/baremetal/example/libc_port/syscalls.c new file mode 100644 index 000000000..7d37a0d1c --- /dev/null +++ b/baremetal/example/libc_port/syscalls.c @@ -0,0 +1,119 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-10-15 09:53:06 + * @LastEditTime: 2021-10-15 14:11:58 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include + +enum { + UART_FR_RXFE = 0x10, + UART_FR_TXFF = 0x20, + UART0_ADDR = 0x10009000, +}; + +#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr)) +#define UART_FR(baseaddr) (*(((unsigned int *)(baseaddr))+6)) + +int _close(int file) +{ + return -1; +} + +int _fstat(int file, struct stat* st) +{ + st->st_mode = S_IFCHR; + return 0; +} + +int _isatty(int file) +{ + return 1; +} + +int _lseek(int file, int ptr, int dir) +{ + return 0; +} + +int _open(const char* name, int flags, int mode) +{ + return -1; +} + +int _read(int file, char* ptr, int len) +{ + int todo; + + if (len == 0) { + return 0; + } + + while (UART_FR(UART0_ADDR) & UART_FR_RXFE); + + *ptr++ = UART_DR(UART0_ADDR); + + for (todo = 1; todo < len; todo++) { + if (UART_FR(UART0_ADDR) & UART_FR_RXFE) { + break; + } + + *ptr++ = UART_DR(UART0_ADDR); + } + + return todo; +} + +char* heap_end = 0; +caddr_t _sbrk(int incr) +{ + extern char heap_low; /* Defined by the linker */ + extern char heap_top; /* Defined by the linker */ + char* prev_heap_end; + + if (heap_end == 0) { + heap_end = &heap_low; + } + + prev_heap_end = heap_end; + + if (heap_end + incr > &heap_top) { + /* Heap and stack collision */ + return (caddr_t)0; + } + + heap_end += incr; + return (caddr_t) prev_heap_end; +} + +int _write(int file, char* ptr, int len) +{ + int todo; + + for (todo = 0; todo < len; todo++) { + UART_DR(UART0_ADDR) = *ptr++; + } + + return len; +} + +void _kill(int pid, int sig) { + return; +} + +int _getpid(void) { + return -1; +} + +void abort(void) +{ + return; +} \ No newline at end of file diff --git a/baremetal/example/libc_port/test.c b/baremetal/example/libc_port/test.c new file mode 100644 index 000000000..3485f6d84 --- /dev/null +++ b/baremetal/example/libc_port/test.c @@ -0,0 +1,59 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-10-15 09:42:15 + * @LastEditTime: 2021-10-15 14:38:04 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ +#include +#include +#include + +extern char* heap_end; /* Defined in syscalls.c */ + +volatile uint8_t* uart0 = (uint8_t*)0x10009000; /* ctrl register */ +/* writing a UART driver */ +void write(const char* str) +{ + while (*str) { + *uart0 = *str++; + } +} + +void early_print() +{ + write("zhugengyu something...\n"); +} + +void c_entry() +{ + char c; + char* ptr = NULL; + size_t alloc_size = 1; + + early_print(); + do + { + c = getchar(); + printf("%d: %c\n", c, c); + + ptr = realloc(ptr, alloc_size); + + if (ptr == NULL) { + puts("Out of memory!\nProgram halting."); + + for (;;); + } else { + printf("new alloc of %d bytes at address 0x%X\n", alloc_size, + (unsigned int)ptr); + alloc_size <<= 1; + printf("Heap end = 0x%X\n", (unsigned int)heap_end); + } + } while (1); +} \ No newline at end of file diff --git a/baremetal/example/libc_port/test.ld b/baremetal/example/libc_port/test.ld new file mode 100644 index 000000000..00d07578d --- /dev/null +++ b/baremetal/example/libc_port/test.ld @@ -0,0 +1,56 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_Reset) + +/* pretend that 0x60000000 is ROM, 0x70000000 is RAM */ +/* because vexpress-qemu is not able to emulate flash memory as ROM */ +/* space is significant to avoid syntax error when linking */ +MEMORY +{ + ROM (rx) : ORIGIN = 0x60000000, LENGTH = 1M + RAM (rwx): ORIGIN = 0x70000000, LENGTH = 32M +} + +SECTIONS +{ + .text : { + startup.o (.vector_table) + *(.text*) + *(.rodata*) /* make life easier without rodata section */ + } > ROM /* .text should linked to ROM */ + _text_end = .; + /* data segment, contains data that can be modified by the program at run-time, + global and static variables that have a non-zero initial value will normally go here */ + .data : AT(ADDR(.text) + SIZEOF(.text)) /* AT specify the load address right after .text */ + { + _data_start = .; /* .data section will be redise at runtime */ + *(.data) + . = ALIGN(8); + _data_end = .; + } > RAM /* link it all to RAM */ + /* unitialized data segment, variables explicitly initialized with zero to BSS */ + .bss : { + _bss_start = .; + *(.bss) + . = ALIGN(8); + _bss_end = .; + } > RAM + + _fiq_stack_start = ADDR(.bss) + SIZEOF(.bss); + _fiq_stack_end = _fiq_stack_start + 0x1000; /* 64 KB */ + + _irq_stack_start = _fiq_stack_end; + _irq_stack_end = _irq_stack_start + 0x1000; /* 64 KB */ + + _stack_start = _irq_stack_end; + _stack_end = _stack_start + 0x1000; /* 64 KB */ + + _irq_stack_size = _irq_stack_end - _irq_stack_start; + _fiq_stack_size = _fiq_stack_end - _fiq_stack_start; + + . = ALIGN(8); + heap_low = .; /* for _sbrk */ + . = . + 0x10000; /* 64kB of heap memory */ + heap_top = .; /* for _sbrk */ + . = . + 0x10000; /* 64kB of stack memory */ +} \ No newline at end of file diff --git a/baremetal/example/qemu_libc_test/build.sh b/baremetal/example/qemu_libc_test/build.sh new file mode 100644 index 000000000..d1a587d96 --- /dev/null +++ b/baremetal/example/qemu_libc_test/build.sh @@ -0,0 +1,28 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-06-10 08:52:12 + # @LastEditTime: 2021-10-15 16:04:35 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### + +./clean.sh + +TARGET=qemu_aarch32 +echo "building "$TARGET +echo "compiling startup.s" +arm-none-eabi-as -o start.o start.S +echo "compiling syscalls.c" +arm-none-eabi-gcc -I ./newlib-4.1.0/newlib/libc/include -c -nostdlib -nostartfiles -o syscalls.o syscalls.c +echo "compiling main.s" +arm-none-eabi-gcc -I ./newlib-4.1.0/newlib/libc/include -c -nostdlib -nostartfiles -o main.o main.c +echo "linking" +arm-none-eabi-ld -T link.ld main.o start.o syscalls.o ./newlib-4.1.0/arm-none-eabi/newlib/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.2.1/libgcc.a -o $TARGET.elf +echo "objcopying" +arm-none-eabi-objcopy -O binary $TARGET.elf $TARGET.bin diff --git a/baremetal/example/qemu_libc_test/clean.sh b/baremetal/example/qemu_libc_test/clean.sh new file mode 100644 index 000000000..8da30fea0 --- /dev/null +++ b/baremetal/example/qemu_libc_test/clean.sh @@ -0,0 +1,14 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-06-10 10:00:43 + # @LastEditTime: 2021-10-15 15:46:55 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### +rm *.o *.bin *.elf \ No newline at end of file diff --git a/baremetal/example/qemu_libc_test/link.ld b/baremetal/example/qemu_libc_test/link.ld new file mode 100644 index 000000000..9f4ee84e0 --- /dev/null +++ b/baremetal/example/qemu_libc_test/link.ld @@ -0,0 +1,67 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) + +MEMORY +{ + ROM (rx) : ORIGIN = 0x80100000, LENGTH = 1M + RAM (rwx): ORIGIN = 0x81000000, LENGTH = 32M +} + +SECTIONS +{ + .text : { + start.o (.vector_table) + *(.text*) + *(.rodata*) + } > ROM + _text_end = .; + .data : AT(ADDR(.text) + SIZEOF(.text)) + { + _data_start = .; + *(.data) + . = ALIGN(8); + _data_end = .; + } > RAM + .bss : { + _bss_start = .; + *(.bss) + . = ALIGN(8); + _bss_end = .; + } > RAM + + _fiq_stack_start = ADDR(.bss) + SIZEOF(.bss); + _fiq_stack_end = _fiq_stack_start + 0x1000; /* 64 KB */ + + _irq_stack_start = _fiq_stack_end; + _irq_stack_end = _irq_stack_start + 0x1000; /* 64 KB */ + + _svc_stack_start = _irq_stack_end; + _svc_stack_end = _svc_stack_start + 0x1000; /* 64 KB */ + + _sys_stack_start = _svc_stack_end; + _sys_stack_end = _sys_stack_start + 0x1000; /* 64 KB */ + + _abt_stack_start = _sys_stack_end; + _abt_stack_end = _abt_stack_start + 0x1000; /* 64 KB */ + + _udf_stack_start = _abt_stack_end; + _udf_stack_end = _udf_stack_start + 0x1000; /* 64 KB */ + + _usr_stack_start = _udf_stack_end; + _usr_stack_end = _usr_stack_start + 0x1000; /* 64 KB */ + + _irq_stack_size = _irq_stack_end - _irq_stack_start; + _fiq_stack_size = _fiq_stack_end - _fiq_stack_start; + _svc_stack_size = _svc_stack_end - _svc_stack_start; + _sys_stack_size = _sys_stack_end - _sys_stack_start; + _abt_stack_size = _abt_stack_end - _abt_stack_start; + _udf_stack_size = _udf_stack_end - _udf_stack_start; + _usr_stack_size = _usr_stack_end - _usr_stack_start; + + . = ALIGN(8); + heap_low = .; /* for _sbrk */ + . = . + 0x10000; /* 64kB of heap memory */ + heap_top = .; /* for _sbrk */ + . = . + 0x10000; /* 64kB of stack memory */ +} diff --git a/baremetal/example/qemu_libc_test/main.c b/baremetal/example/qemu_libc_test/main.c new file mode 100644 index 000000000..7cc7b47f5 --- /dev/null +++ b/baremetal/example/qemu_libc_test/main.c @@ -0,0 +1,78 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-05-24 14:20:10 + * @LastEditTime: 2021-10-15 16:05:54 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ +#include +#include +#include + +extern char* heap_end; /* Defined in syscalls.c */ + +volatile uint8_t *uart0 = (uint8_t *)0x10009000; + +/* writing a UART driver */ +void write(const char* str) +{ + while (*str) { + *uart0 = *str++; + } +} +void c_entry() +{ + char c; + char* ptr = NULL; + size_t alloc_size = 1; + + do + { + c = getchar(); + printf("%d: %c\n", c, c); + + ptr = realloc(ptr, alloc_size); + + if (ptr == NULL) { + puts("Out of memory!\nProgram halting."); + + for (;;); + } else { + printf("new alloc of %d bytes at address 0x%X\n", alloc_size, + (unsigned int)ptr); + alloc_size <<= 1; + printf("Heap end = 0x%X\n", (unsigned int)heap_end); + } + } while (1); +} + +int main() +{ + const char *s = "Hello world from aarch32 bare-metal!\n"; + uart0 = (uint8_t *)0x10009000; + write(s); + *uart0 = 'A'; + *uart0 = 'B'; + *uart0 = 'C'; + *uart0 = '\n'; + while (*s != '\0') + { + *uart0 = *s; + s++; + } + + *uart0 = 'C'; + *uart0 = 'E'; + *uart0 = 'N'; + *uart0 = '\n'; + c_entry(); + + return 0; +} + diff --git a/baremetal/example/qemu_libc_test/run.sh b/baremetal/example/qemu_libc_test/run.sh new file mode 100644 index 000000000..5b6510ea1 --- /dev/null +++ b/baremetal/example/qemu_libc_test/run.sh @@ -0,0 +1,19 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-06-10 08:52:26 + # @LastEditTime: 2021-10-15 15:47:32 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### + +TARGET=qemu_aarch32 +# qemu-system-arm -machine vexpress-a9 -m 1024M \ +# -serial stdio -kernel $TARGET.elf +$PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -M vexpress-a9 -m 1024M \ + -serial stdio -kernel $TARGET.elf \ No newline at end of file diff --git a/baremetal/example/qemu_libc_test/start.S b/baremetal/example/qemu_libc_test/start.S new file mode 100644 index 000000000..7b3660e30 --- /dev/null +++ b/baremetal/example/qemu_libc_test/start.S @@ -0,0 +1,172 @@ +.equ MODE_USR, 0x10 @ PL0 +.equ MODE_FIQ, 0x11 @ PL1 +.equ MODE_IRQ, 0x12 @ PL1 +.equ MODE_SVC, 0x13 @ PL1 +@.equ MODE_MON, 0x16 @ PL1 Secure only +.equ MODE_ABT, 0x17 @ PL1 +.equ MODE_HYP, 0x1A @ PL2, Non-secure +.equ MODE_UDF, 0x1B @ PL1 +.equ MODE_SYS, 0X1F @ PL1 + +.global _start +_start: + b Reset_Handler @0x0 Reset + b Undefined_Handler @0x4 Undefined Instruction + b SVC_Handler @0x8 Supervisor Call + b PrefetchAbort_Handler @0xC Prefetch Abort + b DataAbort_Handler @0x10 Data Abort + NOP @0x14 Reserved + b IRQ_Handler @0x18 IRQ interrupt + b FIQ_Handler @0x1C FIQ interrupt + +Reset_Handler: + cpsid i /* 关闭全局中断 */ + + /* 关闭I,DCache和MMU + * 采取读-改-写的方式。 + */ + mrc p15, 0, r0, c1, c0, 0 /* 读取CP15的C1寄存器到R0中 */ + bic r0, r0, #(0x1 << 12) /* 清除C1寄存器的bit12位(I位),关闭I Cache */ + bic r0, r0, #(0x1 << 2) /* 清除C1寄存器的bit2(C位),关闭D Cache */ + bic r0, r0, #0x2 /* 清除C1寄存器的bit1(A位),关闭对齐 */ + bic r0, r0, #(0x1 << 11) /* 清除C1寄存器的bit11(Z位),关闭分支预测 */ + bic r0, r0, #0x1 /* 清除C1寄存器的bit0(M位),关闭MMU */ + mcr p15, 0, r0, c1, c0, 0 /* 将r0寄存器中的值写入到CP15的C1寄存器中 */ + +setup_stack_for_allmode: + cps MODE_FIQ @ change the processor mode + ldr r1, =_fiq_stack_start /* load start address into R1 */ + ldr sp, =_fiq_stack_end /* load the end address of the FIQ stack into SP */ + + movw r0, #0xFEFE + movt r0, #0xFEFE /* corresponds to loading x << 16 | y into r0 */ + +/* This is the loop that actually fills the stack with 0xFEFEFEFE */ +fiq_stack_loop: + cmp r1, sp /* compares the value in R1 to the value in SP */ + strlt r0, [r1], #4 /* If R1 is less than SP, + the value in R0 will be written to the + address stored in R1, + and R1 gets increased by 4 */ + blt fiq_stack_loop /* the loop continues as long as R1 is less than SP */ + + /* IRQ stack */ + @msr cpsr_c, MODE_IRQ + cps MODE_IRQ + ldr r1, =_irq_stack_start + ldr sp, =_irq_stack_end + +/* fill irq stack */ +irq_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt irq_stack_loop + + /* Supervisor mode */ + @msr cpsr_c, MODE_SVC + cps MODE_SVC + ldr r1, =_svc_stack_start + ldr sp, =_svc_stack_end + +/* fill the supervisor mode stack */ +svc_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt svc_stack_loop + + /* System mode */ + @msr cpsr_c, MODE_SYS + cps MODE_SYS + ldr r1, =_sys_stack_start + ldr sp, =_sys_stack_end + +/* fill the system mode stack */ +sys_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt sys_stack_loop + + /* Abort mode */ + @msr cpsr_c, MODE_ABT + cps MODE_ABT + ldr r1, =_abt_stack_start + ldr sp, =_abt_stack_end + +/* fill the Abort mode stack */ +abt_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt abt_stack_loop + + /* Undef mode */ + @msr cpsr_c, MODE_UDF + cps MODE_UDF + ldr r1, =_udf_stack_start + ldr sp, =_udf_stack_end + +/* fill the Undef mode stack */ +udf_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt udf_stack_loop + + /* Usr mode */ + @msr cpsr_c, MODE_USR + cps MODE_USR + ldr r1, =_usr_stack_start + ldr sp, =_usr_stack_end + +/* fill the Usr mode stack */ +usr_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt usr_stack_loop + + /* Start copying data */ + ldr r0, =_text_end /* section address has been defined in ld script */ + ldr r1, =_data_start + ldr r2, =_data_end + +/* loop continues over the entirety of .data in ROM */ +data_loop: + cmp r1, r2 + ldrlt r3, [r0], #4 /* t load 4 bytes of data from ROM into R3 */ + strlt r3, [r1], #4 + blt data_loop + + /* Initialize .bss */ + mov r0, #0 + ldr r1, =_bss_start + ldr r2, =_bss_end + +/* loop over memory between the addresses _bss_start and _bss_end */ +/* there is no ROM address, and zeros just take up space */ +bss_loop: + cmp r1, r2 + strlt r0, [r1], #4 + blt bss_loop + + cpsie i /* enable irq */ + bl main /* continue running in case the main function */ + b Abort_Exception /* indicate an error, never execute when main contains infinite loop */ + +Abort_Exception: + swi 0xFF + +Undefined_Handler: + b Abort_Exception + +SVC_Handler: + b Abort_Exception + +PrefetchAbort_Handler: + b Abort_Exception + +DataAbort_Handler: + b Abort_Exception + +IRQ_Handler: + b Abort_Exception + +FIQ_Handler: + b Abort_Exception diff --git a/baremetal/example/qemu_libc_test/syscalls.c b/baremetal/example/qemu_libc_test/syscalls.c new file mode 100644 index 000000000..7d37a0d1c --- /dev/null +++ b/baremetal/example/qemu_libc_test/syscalls.c @@ -0,0 +1,119 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-10-15 09:53:06 + * @LastEditTime: 2021-10-15 14:11:58 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include + +enum { + UART_FR_RXFE = 0x10, + UART_FR_TXFF = 0x20, + UART0_ADDR = 0x10009000, +}; + +#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr)) +#define UART_FR(baseaddr) (*(((unsigned int *)(baseaddr))+6)) + +int _close(int file) +{ + return -1; +} + +int _fstat(int file, struct stat* st) +{ + st->st_mode = S_IFCHR; + return 0; +} + +int _isatty(int file) +{ + return 1; +} + +int _lseek(int file, int ptr, int dir) +{ + return 0; +} + +int _open(const char* name, int flags, int mode) +{ + return -1; +} + +int _read(int file, char* ptr, int len) +{ + int todo; + + if (len == 0) { + return 0; + } + + while (UART_FR(UART0_ADDR) & UART_FR_RXFE); + + *ptr++ = UART_DR(UART0_ADDR); + + for (todo = 1; todo < len; todo++) { + if (UART_FR(UART0_ADDR) & UART_FR_RXFE) { + break; + } + + *ptr++ = UART_DR(UART0_ADDR); + } + + return todo; +} + +char* heap_end = 0; +caddr_t _sbrk(int incr) +{ + extern char heap_low; /* Defined by the linker */ + extern char heap_top; /* Defined by the linker */ + char* prev_heap_end; + + if (heap_end == 0) { + heap_end = &heap_low; + } + + prev_heap_end = heap_end; + + if (heap_end + incr > &heap_top) { + /* Heap and stack collision */ + return (caddr_t)0; + } + + heap_end += incr; + return (caddr_t) prev_heap_end; +} + +int _write(int file, char* ptr, int len) +{ + int todo; + + for (todo = 0; todo < len; todo++) { + UART_DR(UART0_ADDR) = *ptr++; + } + + return len; +} + +void _kill(int pid, int sig) { + return; +} + +int _getpid(void) { + return -1; +} + +void abort(void) +{ + return; +} \ No newline at end of file diff --git a/baremetal/example/qemu_test/build.sh b/baremetal/example/qemu_test/build.sh new file mode 100644 index 000000000..16a4a9802 --- /dev/null +++ b/baremetal/example/qemu_test/build.sh @@ -0,0 +1,21 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-06-10 08:52:12 + # @LastEditTime: 2021-06-10 11:11:40 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### + +./clean.sh + +TARGET=qemu_aarch32 +arm-none-eabi-as -o start.o start.S +arm-none-eabi-gcc -c -nostdlib -nostartfiles -c -g -o main.o main.c +arm-none-eabi-ld -T link.ld -o $TARGET.elf start.o main.o +arm-none-eabi-objcopy -O binary $TARGET.elf $TARGET.bin diff --git a/baremetal/example/qemu_test/clean.sh b/baremetal/example/qemu_test/clean.sh new file mode 100644 index 000000000..8da30fea0 --- /dev/null +++ b/baremetal/example/qemu_test/clean.sh @@ -0,0 +1,14 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-06-10 10:00:43 + # @LastEditTime: 2021-10-15 15:46:55 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### +rm *.o *.bin *.elf \ No newline at end of file diff --git a/baremetal/example/qemu_test/link.ld b/baremetal/example/qemu_test/link.ld new file mode 100644 index 000000000..85d63048c --- /dev/null +++ b/baremetal/example/qemu_test/link.ld @@ -0,0 +1,61 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) + +MEMORY +{ + ROM (rx) : ORIGIN = 0x80100000, LENGTH = 1M + RAM (rwx): ORIGIN = 0x81000000, LENGTH = 32M +} + +SECTIONS +{ + .text : { + start.o (.vector_table) + *(.text*) + *(.rodata*) + } > ROM + _text_end = .; + .data : AT(ADDR(.text) + SIZEOF(.text)) + { + _data_start = .; + *(.data) + . = ALIGN(8); + _data_end = .; + } > RAM + .bss : { + _bss_start = .; + *(.bss) + . = ALIGN(8); + _bss_end = .; + } > RAM + + _fiq_stack_start = ADDR(.bss) + SIZEOF(.bss); + _fiq_stack_end = _fiq_stack_start + 0x1000; /* 64 KB */ + + _irq_stack_start = _fiq_stack_end; + _irq_stack_end = _irq_stack_start + 0x1000; /* 64 KB */ + + _svc_stack_start = _irq_stack_end; + _svc_stack_end = _svc_stack_start + 0x1000; /* 64 KB */ + + _sys_stack_start = _svc_stack_end; + _sys_stack_end = _sys_stack_start + 0x1000; /* 64 KB */ + + _abt_stack_start = _sys_stack_end; + _abt_stack_end = _abt_stack_start + 0x1000; /* 64 KB */ + + _udf_stack_start = _abt_stack_end; + _udf_stack_end = _udf_stack_start + 0x1000; /* 64 KB */ + + _usr_stack_start = _udf_stack_end; + _usr_stack_end = _usr_stack_start + 0x1000; /* 64 KB */ + + _irq_stack_size = _irq_stack_end - _irq_stack_start; + _fiq_stack_size = _fiq_stack_end - _fiq_stack_start; + _svc_stack_size = _svc_stack_end - _svc_stack_start; + _sys_stack_size = _sys_stack_end - _sys_stack_start; + _abt_stack_size = _abt_stack_end - _abt_stack_start; + _udf_stack_size = _udf_stack_end - _udf_stack_start; + _usr_stack_size = _usr_stack_end - _usr_stack_start; +} diff --git a/baremetal/example/qemu_test/main.c b/baremetal/example/qemu_test/main.c new file mode 100644 index 000000000..6d1685a97 --- /dev/null +++ b/baremetal/example/qemu_test/main.c @@ -0,0 +1,46 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-05-24 14:20:10 + * @LastEditTime: 2021-06-10 08:51:32 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ +#include + +volatile uint8_t *uart0 = (uint8_t *)0x10009000; + +void write(const char *str) +{ + while (*str) + { + *uart0 = *str++; + } +} + +int main() +{ + const char *s = "Hello world from aarch32 bare-metal!\n"; + uart0 = (uint8_t *)0x10009000; + write(s); + *uart0 = 'A'; + *uart0 = 'B'; + *uart0 = 'C'; + *uart0 = '\n'; + while (*s != '\0') + { + *uart0 = *s; + s++; + } + while (1) + { + }; + + return 0; +} + diff --git a/baremetal/example/qemu_test/run.sh b/baremetal/example/qemu_test/run.sh new file mode 100644 index 000000000..5b6510ea1 --- /dev/null +++ b/baremetal/example/qemu_test/run.sh @@ -0,0 +1,19 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-06-10 08:52:26 + # @LastEditTime: 2021-10-15 15:47:32 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### + +TARGET=qemu_aarch32 +# qemu-system-arm -machine vexpress-a9 -m 1024M \ +# -serial stdio -kernel $TARGET.elf +$PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -M vexpress-a9 -m 1024M \ + -serial stdio -kernel $TARGET.elf \ No newline at end of file diff --git a/baremetal/example/qemu_test/start.S b/baremetal/example/qemu_test/start.S new file mode 100644 index 000000000..7b3660e30 --- /dev/null +++ b/baremetal/example/qemu_test/start.S @@ -0,0 +1,172 @@ +.equ MODE_USR, 0x10 @ PL0 +.equ MODE_FIQ, 0x11 @ PL1 +.equ MODE_IRQ, 0x12 @ PL1 +.equ MODE_SVC, 0x13 @ PL1 +@.equ MODE_MON, 0x16 @ PL1 Secure only +.equ MODE_ABT, 0x17 @ PL1 +.equ MODE_HYP, 0x1A @ PL2, Non-secure +.equ MODE_UDF, 0x1B @ PL1 +.equ MODE_SYS, 0X1F @ PL1 + +.global _start +_start: + b Reset_Handler @0x0 Reset + b Undefined_Handler @0x4 Undefined Instruction + b SVC_Handler @0x8 Supervisor Call + b PrefetchAbort_Handler @0xC Prefetch Abort + b DataAbort_Handler @0x10 Data Abort + NOP @0x14 Reserved + b IRQ_Handler @0x18 IRQ interrupt + b FIQ_Handler @0x1C FIQ interrupt + +Reset_Handler: + cpsid i /* 关闭全局中断 */ + + /* 关闭I,DCache和MMU + * 采取读-改-写的方式。 + */ + mrc p15, 0, r0, c1, c0, 0 /* 读取CP15的C1寄存器到R0中 */ + bic r0, r0, #(0x1 << 12) /* 清除C1寄存器的bit12位(I位),关闭I Cache */ + bic r0, r0, #(0x1 << 2) /* 清除C1寄存器的bit2(C位),关闭D Cache */ + bic r0, r0, #0x2 /* 清除C1寄存器的bit1(A位),关闭对齐 */ + bic r0, r0, #(0x1 << 11) /* 清除C1寄存器的bit11(Z位),关闭分支预测 */ + bic r0, r0, #0x1 /* 清除C1寄存器的bit0(M位),关闭MMU */ + mcr p15, 0, r0, c1, c0, 0 /* 将r0寄存器中的值写入到CP15的C1寄存器中 */ + +setup_stack_for_allmode: + cps MODE_FIQ @ change the processor mode + ldr r1, =_fiq_stack_start /* load start address into R1 */ + ldr sp, =_fiq_stack_end /* load the end address of the FIQ stack into SP */ + + movw r0, #0xFEFE + movt r0, #0xFEFE /* corresponds to loading x << 16 | y into r0 */ + +/* This is the loop that actually fills the stack with 0xFEFEFEFE */ +fiq_stack_loop: + cmp r1, sp /* compares the value in R1 to the value in SP */ + strlt r0, [r1], #4 /* If R1 is less than SP, + the value in R0 will be written to the + address stored in R1, + and R1 gets increased by 4 */ + blt fiq_stack_loop /* the loop continues as long as R1 is less than SP */ + + /* IRQ stack */ + @msr cpsr_c, MODE_IRQ + cps MODE_IRQ + ldr r1, =_irq_stack_start + ldr sp, =_irq_stack_end + +/* fill irq stack */ +irq_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt irq_stack_loop + + /* Supervisor mode */ + @msr cpsr_c, MODE_SVC + cps MODE_SVC + ldr r1, =_svc_stack_start + ldr sp, =_svc_stack_end + +/* fill the supervisor mode stack */ +svc_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt svc_stack_loop + + /* System mode */ + @msr cpsr_c, MODE_SYS + cps MODE_SYS + ldr r1, =_sys_stack_start + ldr sp, =_sys_stack_end + +/* fill the system mode stack */ +sys_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt sys_stack_loop + + /* Abort mode */ + @msr cpsr_c, MODE_ABT + cps MODE_ABT + ldr r1, =_abt_stack_start + ldr sp, =_abt_stack_end + +/* fill the Abort mode stack */ +abt_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt abt_stack_loop + + /* Undef mode */ + @msr cpsr_c, MODE_UDF + cps MODE_UDF + ldr r1, =_udf_stack_start + ldr sp, =_udf_stack_end + +/* fill the Undef mode stack */ +udf_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt udf_stack_loop + + /* Usr mode */ + @msr cpsr_c, MODE_USR + cps MODE_USR + ldr r1, =_usr_stack_start + ldr sp, =_usr_stack_end + +/* fill the Usr mode stack */ +usr_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt usr_stack_loop + + /* Start copying data */ + ldr r0, =_text_end /* section address has been defined in ld script */ + ldr r1, =_data_start + ldr r2, =_data_end + +/* loop continues over the entirety of .data in ROM */ +data_loop: + cmp r1, r2 + ldrlt r3, [r0], #4 /* t load 4 bytes of data from ROM into R3 */ + strlt r3, [r1], #4 + blt data_loop + + /* Initialize .bss */ + mov r0, #0 + ldr r1, =_bss_start + ldr r2, =_bss_end + +/* loop over memory between the addresses _bss_start and _bss_end */ +/* there is no ROM address, and zeros just take up space */ +bss_loop: + cmp r1, r2 + strlt r0, [r1], #4 + blt bss_loop + + cpsie i /* enable irq */ + bl main /* continue running in case the main function */ + b Abort_Exception /* indicate an error, never execute when main contains infinite loop */ + +Abort_Exception: + swi 0xFF + +Undefined_Handler: + b Abort_Exception + +SVC_Handler: + b Abort_Exception + +PrefetchAbort_Handler: + b Abort_Exception + +DataAbort_Handler: + b Abort_Exception + +IRQ_Handler: + b Abort_Exception + +FIQ_Handler: + b Abort_Exception diff --git a/baremetal/example/qemu_test/start.S.old b/baremetal/example/qemu_test/start.S.old new file mode 100644 index 000000000..5d86703af --- /dev/null +++ b/baremetal/example/qemu_test/start.S.old @@ -0,0 +1,192 @@ +/* Some defines */ +.equ MODE_USR, 0x10 @ PL0 +.equ MODE_FIQ, 0x11 @ PL1 +.equ MODE_IRQ, 0x12 @ PL1 +.equ MODE_SVC, 0x13 @ PL1 +@.equ MODE_MON, 0x16 @ PL1 Secure only +.equ MODE_ABT, 0x17 @ PL1 +.equ MODE_HYP, 0x1A @ PL2, Non-secure +.equ MODE_UDF, 0x1B @ PL1 +.equ MODE_SYS, 0X1F @ PL1 + +.section .vector_table, "x" +.global _start +_start: + b Reset_Handler @0x0 Reset + b Undefined_Handler @0x4 Undefined Instruction + b SVC_Handler @0x8 Supervisor Call + b PrefetchAbort_Handler @0xC Prefetch Abort + b DataAbort_Handler @0x10 Data Abort + NOP @0x14 Reserved + b IRQ_Handler @0x18 IRQ interrupt + b FIQ_Handler @0x1C FIQ interrupt + +.section .text /* The code segment, RD, program’s executable code */ +Reset_Handler: + cpsid aif @ disable asynchronous abort, irq and fiq + + @ Disable MMU + MRC p15, 0, r1, c1, c0, 0 @ Read Control Register configuration data + BIC r1, r1, #0x1 + MCR p15, 0, r1, c1, c0, 0 @ Write Control Register configuration data + + @ Disable L1 Caches + MRC p15, 0, r1, c1, c0, 0 @ Read Control Register configuration data + BIC r1, r1, #(0x1 << 12) @ Disable I Cache + BIC r1, r1, #(0x1 << 2) @ Disable D Cache + MCR p15, 0, r1, c1, c0, 0 @ Write Control Register configuration data + + @ Invalidate L1 Caches + @ Invalidate Instruction cache + MOV r1, #0 + MCR p15, 0, r1, c7, c5, 0 + + @ Invalidate TLB + MCR p15, 0, r1, c8, c7, 0 + + @ Enable Branch Prediction + MOV r1, #0 + MRC p15, 0, r1, c1, c0, 0 @ Read Control Register configuration data + ORR r1, r1, #(0x1 << 11) @ Global BP Enable bit + MCR p15, 0, r1, c1, c0, 0 @ Write Control Register configuration data + + @ Enable D-side Prefetch + MRC p15, 0, r1, c1, c0, 1 @ Read Auxiliary Control Register + ORR r1, r1, #(0x1 <<2) @ Enable D-side prefetch + MCR p15, 0, r1, c1, c0, 1 ; @ Write Auxiliary Control Register + DSB + ISB + + @ @ Initialize MMU + @ MOV r1,#0x0 + @ MCR p15, 0, r1, c2, c0, 2 @ Write Translation Table Base Control Register + @ LDR r1, ttb_address + @ MCR p15, 0, r1, c2, c0, 0 @ Write Translation Table Base Register 0 + + @ @ Enable MMU + @ MRC p15, 0, r1, c1, c0, 0 @ Read Control Register configuration data + @ ORR r1, r1, #0x1 @ Bit 0 is the MMU enable + @ MCR p15, 0, r1, c1, c0, 0 @ Write Control Register configuration data + +@======================================================= +/* Processors are in Secure SVC mode after reset */ +/* FIQ stack */ +/* Current Program Status Register, + change cpsr without affacting the + condition flags */ + @msr cpsr_c, MODE_FIQ /* switch the processor to FIQ mode */ + cps MODE_FIQ @ change the processor mode + ldr r1, =_fiq_stack_start /* load start address into R1 */ + ldr sp, =_fiq_stack_end /* load the end address of the FIQ stack into SP */ + + movw r0, #0xFEFE + movt r0, #0xFEFE /* corresponds to loading x << 16 | y into r0 */ + +/* This is the loop that actually fills the stack with 0xFEFEFEFE */ +fiq_stack_loop: + cmp r1, sp /* compares the value in R1 to the value in SP */ + strlt r0, [r1], #4 /* If R1 is less than SP, + the value in R0 will be written to the + address stored in R1, + and R1 gets increased by 4 */ + blt fiq_stack_loop /* the loop continues as long as R1 is less than SP */ + + /* IRQ stack */ + @msr cpsr_c, MODE_IRQ + cps MODE_IRQ + ldr r1, =_irq_stack_start + ldr sp, =_irq_stack_end + +/* fill irq stack */ +irq_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt irq_stack_loop + + /* Supervisor mode */ + @msr cpsr_c, MODE_SVC + cps MODE_SVC + ldr r1, =_svc_stack_start + ldr sp, =_svc_stack_end + +/* fill the supervisor mode stack */ +svc_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt svc_stack_loop + + /* System mode */ + @msr cpsr_c, MODE_SYS + cps MODE_SYS + ldr r1, =_sys_stack_start + ldr sp, =_sys_stack_end + +/* fill the system mode stack */ +sys_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt sys_stack_loop + + /* Abort mode */ + @msr cpsr_c, MODE_ABT + cps MODE_ABT + ldr r1, =_abt_stack_start + ldr sp, =_abt_stack_end + +/* fill the Abort mode stack */ +abt_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt abt_stack_loop + + /* Undef mode */ + @msr cpsr_c, MODE_UDF + cps MODE_UDF + ldr r1, =_udf_stack_start + ldr sp, =_udf_stack_end + +/* fill the Undef mode stack */ +udf_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt udf_stack_loop + + /* Usr mode */ + @msr cpsr_c, MODE_USR + cps MODE_USR + ldr r1, =_usr_stack_start + ldr sp, =_usr_stack_end + +/* fill the Usr mode stack */ +usr_stack_loop: + cmp r1, sp + strlt r0, [r1], #4 + blt usr_stack_loop + +@================================================= + /* Start copying data */ + ldr r0, =_text_end /* section address has been defined in ld script */ + ldr r1, =_data_start + ldr r2, =_data_end + +/* loop continues over the entirety of .data in ROM */ +data_loop: + cmp r1, r2 + ldrlt r3, [r0], #4 /* t load 4 bytes of data from ROM into R3 */ + strlt r3, [r1], #4 + blt data_loop + + /* Initialize .bss */ + mov r0, #0 + ldr r1, =_bss_start + ldr r2, =_bss_end + +/* loop over memory between the addresses _bss_start and _bss_end */ +/* there is no ROM address, and zeros just take up space */ +bss_loop: + cmp r1, r2 + strlt r0, [r1], #4 + blt bss_loop + + bl main /* continue running in case the main function */ + b Abort_Exception /* indicate an error, never execute when main contains infinite loop */ \ No newline at end of file -- Gitee From 6423b7fa5b41dc7eafca6cb10086fe1925a84880 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Fri, 15 Oct 2021 18:35:04 +0800 Subject: [PATCH 02/21] update --- baremetal/example/newlibc_test/Kconfig | 11 ++ baremetal/example/newlibc_test/README.md | 59 ++++++++ baremetal/example/newlibc_test/main.c | 20 +++ baremetal/example/newlibc_test/makefile | 21 +++ baremetal/example/newlibc_test/sdkconfig | 107 ++++++++++++++ baremetal/example/newlibc_test/sdkconfig.h | 99 +++++++++++++ board/d2000/early_uart.c | 10 +- board/d2000/early_uart.h | 30 +++- lib/Kconfig | 8 +- lib/lib.mk | 14 +- lib/newlibc/syscalls.c | 153 +++++++++++++++++++++ make/complier.mk | 36 ++++- 12 files changed, 543 insertions(+), 25 deletions(-) create mode 100644 baremetal/example/newlibc_test/Kconfig create mode 100644 baremetal/example/newlibc_test/README.md create mode 100644 baremetal/example/newlibc_test/main.c create mode 100644 baremetal/example/newlibc_test/makefile create mode 100644 baremetal/example/newlibc_test/sdkconfig create mode 100644 baremetal/example/newlibc_test/sdkconfig.h create mode 100644 lib/newlibc/syscalls.c diff --git a/baremetal/example/newlibc_test/Kconfig b/baremetal/example/newlibc_test/Kconfig new file mode 100644 index 000000000..16847f50f --- /dev/null +++ b/baremetal/example/newlibc_test/Kconfig @@ -0,0 +1,11 @@ +mainmenu "Phytium Baremetal Configuration" + +menu "Project Configuration" + config TARGET_NAME + string "Build Target Name" + default "baremetal" + help + Build Target name for the demo +endmenu + +source "$(STANDALONE_SDK_ROOT)/Kconfig" diff --git a/baremetal/example/newlibc_test/README.md b/baremetal/example/newlibc_test/README.md new file mode 100644 index 000000000..f1d63f864 --- /dev/null +++ b/baremetal/example/newlibc_test/README.md @@ -0,0 +1,59 @@ + +# XXX + +## 1. 例程介绍 + +>介绍例程的用途,使用场景,相关基本概念,描述用户可以使用例程完成哪些工作
+ +## 2. 如何使用例程 + +>描述开发平台准备,使用例程配置,构建和下载镜像的过程
+ +### 2.1 硬件配置方法 + +>哪些硬件平台是支持的,需要哪些外设,例程与开发板哪些IO口相关等(建议附录开发板照片,展示哪些IO口被引出)
+ +### 2.2 SDK配置方法 + +>依赖哪些驱动、库和第三方组件,如何完成配置(列出需要使能的关键配置项)
+ +### 2.3 构建和下载 + +>描述构建、烧录下载镜像的过程,列出相关的命令
+ +- 开发板侧使用bootelf命令跳转 +``` +setenv ipaddr 192.168.4.20 +setenv serverip 192.168.4.50 +setenv gatewayip 192.168.4.1 +tftpboot 0x90100000 baremetal.elf +bootelf -p 0x90100000 +``` + +### 2.4 输出与实验现象 + +>描述输入输出情况,列出存在哪些输出,对应的输出是什么(建议附录相关现象图片)
+ +## 3. 如何解决问题 + +>主要记录使用例程中可能会遇到的问题,给出相应的解决方案
+ +## 4. 修改历史记录 + +>记录例程的重大修改记录,标明修改发生的版本号
+ + + + diff --git a/baremetal/example/newlibc_test/main.c b/baremetal/example/newlibc_test/main.c new file mode 100644 index 000000000..acd6770e8 --- /dev/null +++ b/baremetal/example/newlibc_test/main.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-07-09 08:08:39 + * @LastEditTime: 2021-10-15 18:29:13 + * @Description:  This files is for phytium baremetal hello world + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ +#include + +int main() +{ + printf("hello baremetal phytium %f\r\n", 3.1415); + return 0; +} diff --git a/baremetal/example/newlibc_test/makefile b/baremetal/example/newlibc_test/makefile new file mode 100644 index 000000000..cb4b44e9e --- /dev/null +++ b/baremetal/example/newlibc_test/makefile @@ -0,0 +1,21 @@ +# 指定工程项目根目录为当前(只能指定一个目录) +export PROJECT_DIR ?= . +# 用户添加的源文件夹和头文件夹(可以指定多个) +export USR_SRC_DIR ?= . \ + ./src +export USR_INC_DIR ?= . \ + ./inc + +# 用户定义的编译目标文件上传路径 +USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp + +# 设置启动镜像名 +BOOT_IMG_NAME ?= baremetal + +# 指定编译freertos项目使用的makefile +include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk + +# 完成编译 +boot: + make + @cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf diff --git a/baremetal/example/newlibc_test/sdkconfig b/baremetal/example/newlibc_test/sdkconfig new file mode 100644 index 000000000..5f0568843 --- /dev/null +++ b/baremetal/example/newlibc_test/sdkconfig @@ -0,0 +1,107 @@ + +# +# Project Configuration +# +CONFIG_TARGET_NAME="d2000_baremetal_a32" +# end of Project Configuration + +# +# Board Setting +# + +# +# Arch Configuration +# +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +CONFIG_USE_L3CACHE=y +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +CONFIG_USE_AARCH64_L1_TO_AARCH32=y +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +# CONFIG_TARGET_E2000 is not set +CONFIG_TARGET_D2000=y +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_EBABLE_GICV3=y +# CONFIG_USE_SERIAL is not set +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# end of Components Configuration +# end of Board Setting + +# +# Building Option +# +CONFIG_ENVI_UBUNTU_20_04=y + +# +# Cross-Compiler Setting +# +CONFIG_COMPILER_NO_STD_STARUP=y +# CONFIG_USE_EXT_COMPILER is not set +# end of Cross-Compiler Setting + +# CONFIG_LOG_VERBOS is not set +# CONFIG_LOG_DEBUG is not set +CONFIG_LOG_INFO=y +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set + +# +# Linker Options +# +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set +# CONFIG_QEMU_AARCH32_RAM_LD is not set +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x04000 +CONFIG_STACK_SIZE=0x1000 +# end of Linker Options +# end of Building Option + +# +# Library Configuration +# +# CONFIG_USE_LIBC is not set +CONFIG_USE_NEW_LIBC=y +# end of Library Configuration + +# +# Third-Party Configuration +# +# CONFIG_USE_LWIP is not set +# CONFIG_USE_LETTER_SHELL is not set +# CONFIG_USE_AMP is not set +# CONFIG_USE_YAFFS2 is not set +# CONFIG_USE_SDMMC_CMD is not set +# end of Third-Party Configuration diff --git a/baremetal/example/newlibc_test/sdkconfig.h b/baremetal/example/newlibc_test/sdkconfig.h new file mode 100644 index 000000000..89252ad2c --- /dev/null +++ b/baremetal/example/newlibc_test/sdkconfig.h @@ -0,0 +1,99 @@ +#ifndef SDK_CONFIG_H__ +#define SDK_CONFIG_H__ + +/* Project Configuration */ + +#define CONFIG_TARGET_NAME "d2000_baremetal_a32" +/* end of Project Configuration */ + +/* Board Setting */ + +/* Arch Configuration */ + +#define CONFIG_TARGET_ARMV8_AARCH32 +/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ +/* CONFIG_TARGET_ARMV7 is not set */ +#define CONFIG_USE_CACHE +#define CONFIG_USE_L3CACHE +#define CONFIG_USE_MMU +/* CONFIG_USE_SYS_TICK is not set */ +#define CONFIG_USE_AARCH64_L1_TO_AARCH32 +/* end of Arch Configuration */ + +/* Board Configuration */ + +/* CONFIG_TARGET_F2000_4 is not set */ +/* CONFIG_TARGET_E2000 is not set */ +#define CONFIG_TARGET_D2000 +/* end of Board Configuration */ + +/* Components Configuration */ + +/* CONFIG_USE_SPI is not set */ +/* CONFIG_USE_QSPI is not set */ +#define CONFIG_USE_GIC +#define CONFIG_EBABLE_GICV3 +/* CONFIG_USE_SERIAL is not set */ +/* CONFIG_USE_GPIO is not set */ +/* CONFIG_USE_IOMUX is not set */ +/* CONFIG_USE_ETH is not set */ +/* CONFIG_USE_CAN is not set */ +/* CONFIG_USE_I2C is not set */ +/* CONFIG_USE_TIMER is not set */ +/* CONFIG_USE_SDMMC is not set */ +/* CONFIG_USE_PCIE is not set */ +/* CONFIG_USE_WDT is not set */ +/* CONFIG_USE_DMA is not set */ +/* CONFIG_USE_NAND is not set */ +/* end of Components Configuration */ +/* end of Board Setting */ + +/* Building Option */ + +#define CONFIG_ENVI_UBUNTU_20_04 + +/* Cross-Compiler Setting */ + +#define CONFIG_COMPILER_NO_STD_STARUP +/* CONFIG_USE_EXT_COMPILER is not set */ +/* end of Cross-Compiler Setting */ +/* CONFIG_LOG_VERBOS is not set */ +/* CONFIG_LOG_DEBUG is not set */ +#define CONFIG_LOG_INFO +/* CONFIG_LOG_WARN is not set */ +/* CONFIG_LOG_ERROR is not set */ +/* CONFIG_LOG_NONE is not set */ + +/* Linker Options */ + +#define CONFIG_AARCH32_RAM_LD +/* CONFIG_AARCH64_RAM_LD is not set */ +/* CONFIG_QEMU_AARCH32_RAM_LD is not set */ +/* CONFIG_USER_DEFINED_LD is not set */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0x80100000 +#define CONFIG_ROM_SIZE_MB 1 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0x81000000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 0x04000 +#define CONFIG_STACK_SIZE 0x1000 +/* end of Linker Options */ +/* end of Building Option */ + +/* Library Configuration */ + +/* CONFIG_USE_LIBC is not set */ +#define CONFIG_USE_NEW_LIBC +/* end of Library Configuration */ + +/* Third-Party Configuration */ + +/* CONFIG_USE_LWIP is not set */ +/* CONFIG_USE_LETTER_SHELL is not set */ +/* CONFIG_USE_AMP is not set */ +/* CONFIG_USE_YAFFS2 is not set */ +/* CONFIG_USE_SDMMC_CMD is not set */ +/* end of Third-Party Configuration */ + +#endif diff --git a/board/d2000/early_uart.c b/board/d2000/early_uart.c index e37315877..0262d2625 100644 --- a/board/d2000/early_uart.c +++ b/board/d2000/early_uart.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0. * * @Date: 2021-08-06 08:07:52 - * @LastEditTime: 2021-09-18 15:23:02 + * @LastEditTime: 2021-10-15 16:32:50 * @Description:  This files is for * * @Modify History: @@ -16,13 +16,6 @@ #include "parameters.h" #include "early_uart.h" -#define EARLY_UART_BASE FT_UART1_BASE_ADDR -#define EARLY_UART_UARTDR (EARLY_UART_BASE + 0x0) /* UART 数据寄存器地址 */ -#define EARLY_UART_UARTFR (EARLY_UART_BASE + 0x18) /* UART 状态寄存器地址 */ -#define EARLY_UART_TXFF BIT(5) /* 发送 FIFO 已满标志位 */ -#define EARLY_UART_RXFE BIT(4) /* 接收 FIFO 为空标志位 */ -#define EARLY_UART_DATA_MASK GENMASK(7, 0) - void OutByte(s8 byte) { /* wait until tx fifo is not full */ @@ -44,3 +37,4 @@ char GetByte(void) return (char)(EARLY_UART_DATA_MASK & FtIn32(EARLY_UART_UARTDR)); } + diff --git a/board/d2000/early_uart.h b/board/d2000/early_uart.h index c54993238..79e70d87a 100644 --- a/board/d2000/early_uart.h +++ b/board/d2000/early_uart.h @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0. * * @Date: 2021-08-06 08:07:52 - * @LastEditTime: 2021-10-12 21:54:30 + * @LastEditTime: 2021-10-15 17:19:40 * @Description:  This files is for * * @Modify History: @@ -20,6 +20,34 @@ extern "C" #endif #include "ft_types.h" +#include "kernel.h" +#include "parameters.h" + +#ifdef CONFIG_TARGET_EARY_UART0 +#define EARLY_UART_BASE FT_UART0_BASE_ADDR +#define EARLY_UART_IRQ_NUM FT_UART0_IRQ_NUMa +#else +#define EARLY_UART_BASE FT_UART1_BASE_ADDR +#define EARLY_UART_IRQ_NUM FT_UART1_IRQ_NUM +#endif // CONFIG_TARGET_EARY_UART1 + +#define EARLY_UART_UARTDR (EARLY_UART_BASE + 0x0) /* UART 数据寄存器地址 */ +#define EARLY_UART_UARTFR (EARLY_UART_BASE + 0x18) /* UART 状态寄存器地址 */ +#define EARLY_UART_UARTCR (EARLY_UART_BASE + 0x30) +#define EARLY_UART_UARTCR_UARTEN BIT(0) +#define EARLY_UART_UARTCR_TXE BIT(8) +#define EARLY_UART_UARTCR_RXE BIT(9) +#define EARLY_UART_UARTCR_INIT (EARLY_UART_UARTCR_UARTEN | EARLY_UART_UARTCR_TXE | \ + EARLY_UART_UARTCR_RXE) +#define EARLY_UART_UARTIMSC (EARLY_UART_BASE + 0x38) +#define EARLY_UART_UARTIMSC_RXIM BIT(4) +#define EARLY_UART_UARTIMSC_RTIM BIT(6) +#define EARLY_UART_UARTMIS (EARLY_UART_BASE + 0x40) +#define EARLY_UART_UARTICR (EARLY_UART_BASE + 0x44) +#define EARLY_UART_TXFF BIT(5) /* 发送 FIFO 已满标志位 */ +#define EARLY_UART_RXFE BIT(4) /* 接收 FIFO 为空标志位 */ +#define EARLY_UART_DATA_MASK GENMASK(7, 0) +#define EARLY_UART_RXI_MASK BIT(4) void OutByte(s8 byte); char GetByte(void); diff --git a/lib/Kconfig b/lib/Kconfig index c6f5c3d9c..7650f06ba 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1,12 +1,14 @@ choice - prompt "StdLibC or NonStdLibC" + prompt "Select C Standard Library" default USE_LIBC - config USE_LIBC - bool "Use C Standard Library" + bool "Use GLibC" select USE_CACHE + config USE_NEW_LIBC + bool "Use NewLibC" + endchoice diff --git a/lib/lib.mk b/lib/lib.mk index 927db06a0..79ee7f4e6 100644 --- a/lib/lib.mk +++ b/lib/lib.mk @@ -4,14 +4,16 @@ LIB_CUR_DIR := $(STANDALONE_DIR)/lib ifdef CONFIG_USE_LIBC -SRC_DIR += $(LIB_CUR_DIR)/libc -INC_DIR += $(LIB_CUR_DIR)/libc + SRC_DIR += $(LIB_CUR_DIR)/libc + INC_DIR += $(LIB_CUR_DIR)/libc endif ifdef CONFIG_USE_NOSTD_LIBC -SRC_DIR += $(LIB_CUR_DIR)/nostdlib -INC_DIR += $(LIB_CUR_DIR)/nostdlib + SRC_DIR += $(LIB_CUR_DIR)/nostdlib + INC_DIR += $(LIB_CUR_DIR)/nostdlib endif - - +ifdef CONFIG_USE_NEW_LIBC + SRC_DIR += $(LIB_CUR_DIR)/newlibc + INC_DIR += $(LIB_CUR_DIR)/newlibc +endif \ No newline at end of file diff --git a/lib/newlibc/syscalls.c b/lib/newlibc/syscalls.c new file mode 100644 index 000000000..9e69c0b3f --- /dev/null +++ b/lib/newlibc/syscalls.c @@ -0,0 +1,153 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-10-15 09:53:06 + * @LastEditTime: 2021-10-15 18:19:12 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include "early_uart.h" + +enum { + UART_FR_RXFE = EARLY_UART_RXFE, + UART_FR_TXFF = EARLY_UART_TXFF, + UART0_ADDR = EARLY_UART_BASE, +}; + +#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr)) +#define UART_FR(baseaddr) (*(((unsigned int *)(baseaddr))+6)) + +/* _exit - Simple implementation. Does not return. +*/ +void _exit(int return_value) +{ + (void)return_value; + asm("dsb sy"); + while (1) + { + asm("wfi"); + } +} + +int _close(int file) +{ + return -1; +} + +int _fstat(int file, struct stat* st) +{ + st->st_mode = S_IFCHR; + return 0; +} + +int _isatty(int file) +{ + return 1; +} + +int _lseek(int file, int ptr, int dir) +{ + return 0; +} + +int _open(const char* name, int flags, int mode) +{ + return -1; +} + +int _read(int file, char* ptr, int len) +{ + int todo; + + if (len == 0) { + return 0; + } + + while (UART_FR(UART0_ADDR) & UART_FR_RXFE); + + *ptr++ = UART_DR(UART0_ADDR); + + for (todo = 1; todo < len; todo++) { + if (UART_FR(UART0_ADDR) & UART_FR_RXFE) { + break; + } + + *ptr++ = UART_DR(UART0_ADDR); + } + + return todo; +} + +//char* heap_end = 0; + +extern u8 _heap_start[]; +extern u8 _heap_end[]; +extern char HeapBase[]; +extern char HeapLimit[]; + +caddr_t _sbrk(int nbytes) +{ + // extern char HeapBase; /* Defined by the linker */ + // extern char HeapLimit; /* Defined by the linker */ + // char* prev_heap_end; + + // if (heap_end == 0) { + // heap_end = &HeapBase; + // } + + // prev_heap_end = heap_end; + + // if (heap_end + incr > &HeapLimit) { + // /* Heap and stack collision */ + // return (caddr_t)0; + // } + + // heap_end += incr; + // return (caddr_t) prev_heap_end; + char *base; + static char *heap_ptr = HeapBase; + + base = heap_ptr; + if((heap_ptr != NULL) && (heap_ptr + nbytes <= (char *)&HeapLimit + 1)) { + heap_ptr += nbytes; + return base; + } else { + errno = ENOMEM; + return ((char *)-1); + } +} + +int _write(int file, char* ptr, int len) +{ + int todo; + + for (todo = 0; todo < len; todo++) { + UART_DR(UART0_ADDR) = *ptr++; + } + + return len; +} + +void _kill(int pid, int sig) { + if(pid == 1) { + _exit(sig); + } + return; +} + +int _getpid(void) { + return 1; +} + +void abort(void) +{ + _exit(1); +} \ No newline at end of file diff --git a/make/complier.mk b/make/complier.mk index ec918552d..a61729994 100755 --- a/make/complier.mk +++ b/make/complier.mk @@ -108,19 +108,34 @@ ifdef CONFIG_TARGET_ARMV8_AARCH32 CFLAGS := $(CFLAGS) -mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp -march=$(ARCH) endif -ifdef CONFIG_TARGET_ARMV8_AARCH64 - CROSS_PATH := $(AARCH64_CROSS_PATH) -endif +# ifdef CONFIG_TARGET_ARMV8_AARCH64 +# CROSS_PATH := $(AARCH64_CROSS_PATH) +# endif LDFLAGS = -Wl,--build-id=none ifdef CONFIG_USE_LIBC -ifdef CONFIG_TARGET_ARMV8_AARCH32 -LDFLAGS += -lgcc -L $(LIBPATH) + ifdef CONFIG_TARGET_ARMV8_AARCH32 + LDFLAGS += -lgcc -L $(LIBPATH) + endif endif -else -LDFLAGS += -nostdlib -nostartfiles + +ifdef CONFIG_USE_NEW_LIBC + ifdef CONFIG_TARGET_ARMV8_AARCH32 + LIBPATH := $(CROSS_PATH)/newlib/arm-none-eabi/newlib + LDFLAGS += -nostdlib -nostartfiles + LDFLAGS += -lgcc -L $(LIBPATH) + INC_DIR := $(INC_DIR) $(CROSS_PATH)/newlib/newlib/libc/include + endif endif +ifdef CONFIG_USE_NOSTD_LIBC + LDFLAGS += -nostdlib -nostartfiles +endif + +# else +# LDFLAGS += -nostdlib -nostartfiles +# endif + TARGET_ARCH = -march=$(ARCH) #mkdir 创建输出文件目录 @@ -145,6 +160,13 @@ else DO_ECHO = endif +ifdef CONFIG_USE_NEW_LIBC + ifdef CONFIG_TARGET_ARMV8_AARCH32 + OBJ_FILES += $(CROSS_PATH)/newlib/arm-none-eabi/newlib/libc.a \ + $(CROSS_PATH)/lib/gcc/arm-none-eabi/10.2.1/libgcc.a + endif +endif + .phony: all linkscript clean rebuild all: $(APP) -- Gitee From f01db918cddb5bb4fa9244e942dbfb88e1fc25a6 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Mon, 18 Oct 2021 10:54:49 +0800 Subject: [PATCH 03/21] update --- Kconfig | 2 +- baremetal/example/can_test/sdkconfig | 2 +- baremetal/example/can_test/sdkconfig.h | 2 +- baremetal/example/gdma_test/sdkconfig | 2 +- baremetal/example/gdma_test/sdkconfig.h | 2 +- baremetal/example/lwip_test/sdkconfig | 2 +- baremetal/example/lwip_test/sdkconfig.h | 2 +- baremetal/example/nand_flash_test/sdkconfig | 2 +- baremetal/example/newlibc_test/sdkconfig | 9 ++- baremetal/example/newlibc_test/sdkconfig.h | 9 ++- baremetal/example/overall_test/sdkconfig | 2 +- baremetal/example/overall_test/sdkconfig.h | 2 +- baremetal/example/pcie_test/sdkconfig | 2 +- baremetal/example/pcie_test/sdkconfig.h | 2 +- baremetal/example/qspi_nor_flash/sdkconfig | 2 +- baremetal/example/qspi_nor_flash/sdkconfig.h | 2 +- baremetal/example/spi_test/sdkconfig | 2 +- baremetal/example/spi_test/sdkconfig.h | 2 +- baremetal/example/template-mingw64/sdkconfig | 2 +- .../example/template-mingw64/sdkconfig.h | 2 +- baremetal/example/template/sdkconfig | 2 +- baremetal/example/template/sdkconfig.h | 2 +- baremetal/example/timer_tacho/sdkconfig | 2 +- baremetal/example/timer_tacho/sdkconfig.h | 2 +- baremetal/example/uart_test/sdkconfig | 2 +- baremetal/example/uart_test/sdkconfig.h | 2 +- baremetal/example/wdt_test/sdkconfig | 2 +- baremetal/example/wdt_test/sdkconfig.h | 2 +- baremetal/example/xmac_test/sdkconfig | 2 +- baremetal/example/xmac_test/sdkconfig.h | 2 +- common/Kconfig | 8 +- configs/d2000_aarch32_amp_master_defconfig | 2 +- configs/d2000_aarch32_amp_slave_defconfig | 2 +- configs/d2000_aarch32_defconfig | 2 +- configs/d2000_aarch64_defconfig | 2 +- configs/e2000_aarch32_defconfig | 2 +- configs/e2000_aarch64_defconfig | 2 +- configs/ft2004_aarch32_defconfig | 2 +- configs/ft2004_aarch64_defconfig | 2 +- lib/Kconfig | 4 +- lib/lib.mk | 2 +- make/complier.mk | 77 +++++++++---------- third-party/Kconfig | 2 +- 43 files changed, 92 insertions(+), 91 deletions(-) diff --git a/Kconfig b/Kconfig index a727b708e..139e79d35 100644 --- a/Kconfig +++ b/Kconfig @@ -3,7 +3,7 @@ STANDALONE_DIR := $(STANDALONE_SDK_ROOT) -menu "Board Setting" +menu "Platform Setting" source "$(STANDALONE_DIR)/arch/Kconfig" source "$(STANDALONE_DIR)/board/Kconfig" source "$(STANDALONE_DIR)/drivers/Kconfig" diff --git a/baremetal/example/can_test/sdkconfig b/baremetal/example/can_test/sdkconfig index dfda2419e..9ecbb4c2b 100644 --- a/baremetal/example/can_test/sdkconfig +++ b/baremetal/example/can_test/sdkconfig @@ -111,7 +111,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/can_test/sdkconfig.h b/baremetal/example/can_test/sdkconfig.h index 372552ce7..caf7c8386 100644 --- a/baremetal/example/can_test/sdkconfig.h +++ b/baremetal/example/can_test/sdkconfig.h @@ -96,7 +96,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/gdma_test/sdkconfig b/baremetal/example/gdma_test/sdkconfig index cf3b71ce0..b1e983153 100644 --- a/baremetal/example/gdma_test/sdkconfig +++ b/baremetal/example/gdma_test/sdkconfig @@ -107,7 +107,7 @@ CONFIG_STACK_TOP_ADDR=0x82000000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/gdma_test/sdkconfig.h b/baremetal/example/gdma_test/sdkconfig.h index b511f9682..7ab74f5b7 100644 --- a/baremetal/example/gdma_test/sdkconfig.h +++ b/baremetal/example/gdma_test/sdkconfig.h @@ -94,7 +94,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/lwip_test/sdkconfig b/baremetal/example/lwip_test/sdkconfig index fd1e7222d..16b1d939f 100644 --- a/baremetal/example/lwip_test/sdkconfig +++ b/baremetal/example/lwip_test/sdkconfig @@ -116,7 +116,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/lwip_test/sdkconfig.h b/baremetal/example/lwip_test/sdkconfig.h index 80d82b8a7..5bdc51bac 100644 --- a/baremetal/example/lwip_test/sdkconfig.h +++ b/baremetal/example/lwip_test/sdkconfig.h @@ -102,7 +102,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/nand_flash_test/sdkconfig b/baremetal/example/nand_flash_test/sdkconfig index e97a89350..fa7fe6fa1 100644 --- a/baremetal/example/nand_flash_test/sdkconfig +++ b/baremetal/example/nand_flash_test/sdkconfig @@ -96,7 +96,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/newlibc_test/sdkconfig b/baremetal/example/newlibc_test/sdkconfig index 5f0568843..51d532717 100644 --- a/baremetal/example/newlibc_test/sdkconfig +++ b/baremetal/example/newlibc_test/sdkconfig @@ -6,7 +6,7 @@ CONFIG_TARGET_NAME="d2000_baremetal_a32" # end of Project Configuration # -# Board Setting +# Platform Setting # # @@ -50,7 +50,7 @@ CONFIG_EBABLE_GICV3=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # end of Components Configuration -# end of Board Setting +# end of Platform Setting # # Building Option @@ -61,6 +61,7 @@ CONFIG_ENVI_UBUNTU_20_04=y # Cross-Compiler Setting # CONFIG_COMPILER_NO_STD_STARUP=y +CONFIG_COMPILER_VERSION="10.2.1" # CONFIG_USE_EXT_COMPILER is not set # end of Cross-Compiler Setting @@ -92,8 +93,8 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -# CONFIG_USE_LIBC is not set -CONFIG_USE_NEW_LIBC=y +CONFIG_USE_G_LIBC=y +# CONFIG_USE_NEW_LIBC is not set # end of Library Configuration # diff --git a/baremetal/example/newlibc_test/sdkconfig.h b/baremetal/example/newlibc_test/sdkconfig.h index 89252ad2c..889f30f71 100644 --- a/baremetal/example/newlibc_test/sdkconfig.h +++ b/baremetal/example/newlibc_test/sdkconfig.h @@ -6,7 +6,7 @@ #define CONFIG_TARGET_NAME "d2000_baremetal_a32" /* end of Project Configuration */ -/* Board Setting */ +/* Platform Setting */ /* Arch Configuration */ @@ -46,7 +46,7 @@ /* CONFIG_USE_DMA is not set */ /* CONFIG_USE_NAND is not set */ /* end of Components Configuration */ -/* end of Board Setting */ +/* end of Platform Setting */ /* Building Option */ @@ -55,6 +55,7 @@ /* Cross-Compiler Setting */ #define CONFIG_COMPILER_NO_STD_STARUP +#define CONFIG_COMPILER_VERSION "10.2.1" /* CONFIG_USE_EXT_COMPILER is not set */ /* end of Cross-Compiler Setting */ /* CONFIG_LOG_VERBOS is not set */ @@ -83,8 +84,8 @@ /* Library Configuration */ -/* CONFIG_USE_LIBC is not set */ -#define CONFIG_USE_NEW_LIBC +#define CONFIG_USE_G_LIBC +/* CONFIG_USE_NEW_LIBC is not set */ /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/overall_test/sdkconfig b/baremetal/example/overall_test/sdkconfig index 241352bc5..0e4547314 100644 --- a/baremetal/example/overall_test/sdkconfig +++ b/baremetal/example/overall_test/sdkconfig @@ -109,7 +109,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/overall_test/sdkconfig.h b/baremetal/example/overall_test/sdkconfig.h index 215c44f2e..ad9e49316 100644 --- a/baremetal/example/overall_test/sdkconfig.h +++ b/baremetal/example/overall_test/sdkconfig.h @@ -97,7 +97,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/pcie_test/sdkconfig b/baremetal/example/pcie_test/sdkconfig index 61412c911..9d63a905c 100644 --- a/baremetal/example/pcie_test/sdkconfig +++ b/baremetal/example/pcie_test/sdkconfig @@ -140,7 +140,7 @@ CONFIG_STACK_TOP_ADDR=0x82000000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/pcie_test/sdkconfig.h b/baremetal/example/pcie_test/sdkconfig.h index 560637d02..ec5e690dc 100644 --- a/baremetal/example/pcie_test/sdkconfig.h +++ b/baremetal/example/pcie_test/sdkconfig.h @@ -118,7 +118,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/qspi_nor_flash/sdkconfig b/baremetal/example/qspi_nor_flash/sdkconfig index c5e5bfe05..b02c2e93e 100644 --- a/baremetal/example/qspi_nor_flash/sdkconfig +++ b/baremetal/example/qspi_nor_flash/sdkconfig @@ -94,7 +94,7 @@ CONFIG_STACK_TOP_ADDR=0x82000000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/qspi_nor_flash/sdkconfig.h b/baremetal/example/qspi_nor_flash/sdkconfig.h index f6a6191ac..e82709f60 100644 --- a/baremetal/example/qspi_nor_flash/sdkconfig.h +++ b/baremetal/example/qspi_nor_flash/sdkconfig.h @@ -85,7 +85,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/spi_test/sdkconfig b/baremetal/example/spi_test/sdkconfig index 86f876a66..80711e46b 100644 --- a/baremetal/example/spi_test/sdkconfig +++ b/baremetal/example/spi_test/sdkconfig @@ -131,7 +131,7 @@ CONFIG_STACK_TOP_ADDR=0x82000000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/spi_test/sdkconfig.h b/baremetal/example/spi_test/sdkconfig.h index ac8dee893..f8b4c00ce 100644 --- a/baremetal/example/spi_test/sdkconfig.h +++ b/baremetal/example/spi_test/sdkconfig.h @@ -111,7 +111,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/template-mingw64/sdkconfig b/baremetal/example/template-mingw64/sdkconfig index 7e3866fc4..0e354a635 100644 --- a/baremetal/example/template-mingw64/sdkconfig +++ b/baremetal/example/template-mingw64/sdkconfig @@ -91,7 +91,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/template-mingw64/sdkconfig.h b/baremetal/example/template-mingw64/sdkconfig.h index 8c3bf5b65..c3c6097fb 100644 --- a/baremetal/example/template-mingw64/sdkconfig.h +++ b/baremetal/example/template-mingw64/sdkconfig.h @@ -82,7 +82,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/template/sdkconfig b/baremetal/example/template/sdkconfig index 263fc5188..701008e24 100644 --- a/baremetal/example/template/sdkconfig +++ b/baremetal/example/template/sdkconfig @@ -90,7 +90,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/template/sdkconfig.h b/baremetal/example/template/sdkconfig.h index d3c891f80..55d3b66f7 100644 --- a/baremetal/example/template/sdkconfig.h +++ b/baremetal/example/template/sdkconfig.h @@ -81,7 +81,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/timer_tacho/sdkconfig b/baremetal/example/timer_tacho/sdkconfig index 2763f60bd..f1373a501 100644 --- a/baremetal/example/timer_tacho/sdkconfig +++ b/baremetal/example/timer_tacho/sdkconfig @@ -97,7 +97,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/timer_tacho/sdkconfig.h b/baremetal/example/timer_tacho/sdkconfig.h index 2a908300c..a50321de3 100644 --- a/baremetal/example/timer_tacho/sdkconfig.h +++ b/baremetal/example/timer_tacho/sdkconfig.h @@ -86,7 +86,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/uart_test/sdkconfig b/baremetal/example/uart_test/sdkconfig index f6a2e84e3..38d9a13a1 100644 --- a/baremetal/example/uart_test/sdkconfig +++ b/baremetal/example/uart_test/sdkconfig @@ -99,7 +99,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/uart_test/sdkconfig.h b/baremetal/example/uart_test/sdkconfig.h index 24a7f5bcc..b146e5266 100644 --- a/baremetal/example/uart_test/sdkconfig.h +++ b/baremetal/example/uart_test/sdkconfig.h @@ -88,7 +88,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/wdt_test/sdkconfig b/baremetal/example/wdt_test/sdkconfig index e8f12ee2f..30bce2f99 100644 --- a/baremetal/example/wdt_test/sdkconfig +++ b/baremetal/example/wdt_test/sdkconfig @@ -106,7 +106,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/wdt_test/sdkconfig.h b/baremetal/example/wdt_test/sdkconfig.h index 3b9f2ee92..490efe618 100644 --- a/baremetal/example/wdt_test/sdkconfig.h +++ b/baremetal/example/wdt_test/sdkconfig.h @@ -93,7 +93,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/xmac_test/sdkconfig b/baremetal/example/xmac_test/sdkconfig index 14cfaada5..f71e11f0c 100644 --- a/baremetal/example/xmac_test/sdkconfig +++ b/baremetal/example/xmac_test/sdkconfig @@ -130,7 +130,7 @@ CONFIG_STACK_TOP_ADDR=0x82000000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/xmac_test/sdkconfig.h b/baremetal/example/xmac_test/sdkconfig.h index ac3b37ef2..708b054f0 100644 --- a/baremetal/example/xmac_test/sdkconfig.h +++ b/baremetal/example/xmac_test/sdkconfig.h @@ -109,7 +109,7 @@ /* Library Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/common/Kconfig b/common/Kconfig index 0c602035e..2760082a8 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1,7 +1,7 @@ choice SDK_ENVI_TYPE - prompt "SDK Develope Platfrom" + prompt "Dev-Host Type" default ENVI_UBUNTU_20_04 help SDK development host environment type. @@ -18,6 +18,12 @@ menu "Cross-Compiler Setting" help Select if do not want to gcc provide startup file + config COMPILER_VERSION + string "Compiler Version" + default "10.2.1" if TARGET_ARMV8_AARCH32 + help + Select Cross Compiler version + config USE_EXT_COMPILER bool "Use User-Specified Compiler" default n diff --git a/configs/d2000_aarch32_amp_master_defconfig b/configs/d2000_aarch32_amp_master_defconfig index 511aeef77..27db8b493 100644 --- a/configs/d2000_aarch32_amp_master_defconfig +++ b/configs/d2000_aarch32_amp_master_defconfig @@ -105,7 +105,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/configs/d2000_aarch32_amp_slave_defconfig b/configs/d2000_aarch32_amp_slave_defconfig index 89239fd12..32b6320d7 100644 --- a/configs/d2000_aarch32_amp_slave_defconfig +++ b/configs/d2000_aarch32_amp_slave_defconfig @@ -112,7 +112,7 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/configs/d2000_aarch32_defconfig b/configs/d2000_aarch32_defconfig index e819044a4..20d30461a 100644 --- a/configs/d2000_aarch32_defconfig +++ b/configs/d2000_aarch32_defconfig @@ -81,7 +81,7 @@ CONFIG_AARCH32_RAM_LD=y # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/configs/d2000_aarch64_defconfig b/configs/d2000_aarch64_defconfig index bbbf53ac5..46a141e30 100644 --- a/configs/d2000_aarch64_defconfig +++ b/configs/d2000_aarch64_defconfig @@ -99,7 +99,7 @@ CONFIG_STACK_TOP_ADDR=0x82000000 # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/configs/e2000_aarch32_defconfig b/configs/e2000_aarch32_defconfig index 941984f37..e303256cf 100644 --- a/configs/e2000_aarch32_defconfig +++ b/configs/e2000_aarch32_defconfig @@ -80,7 +80,7 @@ CONFIG_AARCH32_RAM_LD=y # Library Configuration # # CONFIG_USE_NOSTD_LIBC is not set -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/configs/e2000_aarch64_defconfig b/configs/e2000_aarch64_defconfig index 14fa38810..3bbb5b5fd 100644 --- a/configs/e2000_aarch64_defconfig +++ b/configs/e2000_aarch64_defconfig @@ -80,7 +80,7 @@ CONFIG_AARCH64_RAM_LD=y # Library Configuration # # CONFIG_USE_NOSTD_LIBC is not set -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/configs/ft2004_aarch32_defconfig b/configs/ft2004_aarch32_defconfig index 8690c265e..e78fdad36 100644 --- a/configs/ft2004_aarch32_defconfig +++ b/configs/ft2004_aarch32_defconfig @@ -88,7 +88,7 @@ CONFIG_AARCH32_RAM_LD=y # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/configs/ft2004_aarch64_defconfig b/configs/ft2004_aarch64_defconfig index 26fdcf532..1dda90930 100644 --- a/configs/ft2004_aarch64_defconfig +++ b/configs/ft2004_aarch64_defconfig @@ -82,7 +82,7 @@ CONFIG_AARCH64_RAM_LD=y # # Library Configuration # -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y # end of Library Configuration # diff --git a/lib/Kconfig b/lib/Kconfig index 7650f06ba..e8f141373 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1,9 +1,9 @@ choice prompt "Select C Standard Library" - default USE_LIBC + default USE_G_LIBC - config USE_LIBC + config USE_G_LIBC bool "Use GLibC" select USE_CACHE diff --git a/lib/lib.mk b/lib/lib.mk index 79ee7f4e6..5d9180b27 100644 --- a/lib/lib.mk +++ b/lib/lib.mk @@ -3,7 +3,7 @@ LIB_CUR_DIR := $(STANDALONE_DIR)/lib -ifdef CONFIG_USE_LIBC +ifdef CONFIG_USE_G_LIBC SRC_DIR += $(LIB_CUR_DIR)/libc INC_DIR += $(LIB_CUR_DIR)/libc endif diff --git a/make/complier.mk b/make/complier.mk index a61729994..b4a6f51c6 100755 --- a/make/complier.mk +++ b/make/complier.mk @@ -90,6 +90,12 @@ define EOL = endef +ifdef CONFIG_DUMMY_COMPILE + DO_ECHO = @echo +else + DO_ECHO = +endif + RM_FILES = $(foreach file,$(1),rm -f $(file)$(EOL)) RM_DIRS = $(foreach dir,$(1),rm -rf $(dir)$(EOL)) @@ -99,42 +105,7 @@ CPPFLAGS = $(DEFINES) $(INCLUDES) $(DEPEND_FLAGS) $(CPPFLAGS_EXTRA) CFLAGS = $(DEBUG_FLAGS) -DGUEST -ffreestanding -Wextra -g -O$(OPT_LEVEL) -lnosys #-Wall ASFLAGS = $(CFLAGS) -LIBC ?= -LIBPATH ?= -ifdef CONFIG_TARGET_ARMV8_AARCH32 - LIBPATH += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp -# support float and div, turn on by default for aarch64 -mfpu=crypto-neon-fp-armv8。 - ASFLAGS := $(ASFLAGS) -mfpu=crypto-neon-fp-armv8 -ftree-vectorize -mfloat-abi=softfp -ffast-math -fsingle-precision-constant -march=$(ARCH) - CFLAGS := $(CFLAGS) -mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp -march=$(ARCH) -endif - -# ifdef CONFIG_TARGET_ARMV8_AARCH64 -# CROSS_PATH := $(AARCH64_CROSS_PATH) -# endif - -LDFLAGS = -Wl,--build-id=none -ifdef CONFIG_USE_LIBC - ifdef CONFIG_TARGET_ARMV8_AARCH32 - LDFLAGS += -lgcc -L $(LIBPATH) - endif -endif - -ifdef CONFIG_USE_NEW_LIBC - ifdef CONFIG_TARGET_ARMV8_AARCH32 - LIBPATH := $(CROSS_PATH)/newlib/arm-none-eabi/newlib - LDFLAGS += -nostdlib -nostartfiles - LDFLAGS += -lgcc -L $(LIBPATH) - INC_DIR := $(INC_DIR) $(CROSS_PATH)/newlib/newlib/libc/include - endif -endif - -ifdef CONFIG_USE_NOSTD_LIBC - LDFLAGS += -nostdlib -nostartfiles -endif - -# else -# LDFLAGS += -nostdlib -nostartfiles -# endif +#LIBC ?= TARGET_ARCH = -march=$(ARCH) @@ -150,23 +121,45 @@ OBJ_FILES := $(patsubst %, $(OUTPUT_DIR)/%, $(APP_S_SRC:.S=.o)) \ EXCL_OBJS ?= $(patsubst %, $(OUTPUT_DIR)/%, $(EXCL_SRC:.c=.o)) OBJ_FILES := $(filter-out $(EXCL_OBJS), $(OBJ_FILES)) -OBJ_FILES += $(LIBC) +#OBJ_FILES += $(LIBC) DEP_FILES := $(OBJ_FILES:%=%.d) -ifdef CONFIG_DUMMY_COMPILE - DO_ECHO = @echo -else - DO_ECHO = +LIBPATH ?= +ifdef CONFIG_TARGET_ARMV8_AARCH32 + # support float and div, turn on by default for aarch64 -mfpu=crypto-neon-fp-armv8。 + ASFLAGS := $(ASFLAGS) -mfpu=crypto-neon-fp-armv8 -ftree-vectorize -mfloat-abi=softfp -ffast-math -fsingle-precision-constant -march=$(ARCH) + CFLAGS := $(CFLAGS) -mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp -march=$(ARCH) endif +# 使用编译链自带的Glibc +ifdef CONFIG_USE_G_LIBC + ifdef CONFIG_TARGET_ARMV8_AARCH32 + LIBPATH += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp + LDFLAGS += -lgcc -L $(LIBPATH) + INC_DIR := $(INC_DIR) $(CROSS_PATH)/arm-none-eabi/include + OBJ_FILES += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp/libc.a \ + $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CONFIG_COMPILER_VERSION)/libgcc.a + endif +endif + +# 使用外链的NewLibc ifdef CONFIG_USE_NEW_LIBC ifdef CONFIG_TARGET_ARMV8_AARCH32 + LIBPATH := $(CROSS_PATH)/newlib/arm-none-eabi/newlib + LDFLAGS += -nostdlib -nostartfiles + LDFLAGS += -lgcc -L $(LIBPATH) + INC_DIR := $(INC_DIR) $(CROSS_PATH)/newlib/newlib/libc/include OBJ_FILES += $(CROSS_PATH)/newlib/arm-none-eabi/newlib/libc.a \ - $(CROSS_PATH)/lib/gcc/arm-none-eabi/10.2.1/libgcc.a + $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CONFIG_COMPILER_VERSION)/libgcc.a endif endif +# 不使用Libc库 +ifdef CONFIG_USE_NOSTD_LIBC + LDFLAGS += -nostdlib -nostartfiles +endif + .phony: all linkscript clean rebuild all: $(APP) diff --git a/third-party/Kconfig b/third-party/Kconfig index 504ee022f..1880577c8 100644 --- a/third-party/Kconfig +++ b/third-party/Kconfig @@ -1,6 +1,6 @@ # config USE_COREMARK # bool -# depends on USE_LIBC +# depends on USE_G_LIBC # prompt "Use Coremark" # help # Include Coremark for Benchmark -- Gitee From 902abaf18b3da553a9df8c7345d2cc55aecf42c0 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Mon, 18 Oct 2021 18:33:35 +0800 Subject: [PATCH 04/21] update --- README.md | 252 +++++++----------- baremetal/example/can_test/sdkconfig | 2 +- baremetal/example/can_test/sdkconfig.h | 2 +- baremetal/example/gdma_test/sdkconfig | 2 +- baremetal/example/gdma_test/sdkconfig.h | 2 +- baremetal/example/letter_shell_test/sdkconfig | 2 +- baremetal/example/libc_port/README.md | 11 +- .../configs/d2000_amp_core0_aarch32_defconfig | 2 +- .../configs/d2000_amp_core0_aarch64_defconfig | 2 +- .../configs/d2000_amp_core1_aarch32_defconfig | 2 +- .../configs/d2000_amp_core1_aarch64_defconfig | 2 +- .../example/libmetal_test/core0/sdkconfig | 2 +- .../example/libmetal_test/core0/sdkconfig.h | 2 +- .../example/libmetal_test/core1/sdkconfig | 2 +- .../example/libmetal_test/core1/sdkconfig.h | 2 +- baremetal/example/lwip_test/sdkconfig | 2 +- baremetal/example/lwip_test/sdkconfig.h | 2 +- baremetal/example/nand_flash_test/sdkconfig | 2 +- baremetal/example/nand_flash_test/sdkconfig.h | 2 +- baremetal/example/newlibc_test/README.md | 7 +- baremetal/example/newlibc_test/makefile | 7 +- baremetal/example/newlibc_test/sdkconfig | 28 +- baremetal/example/newlibc_test/sdkconfig.h | 27 +- baremetal/example/overall_test/sdkconfig | 2 +- baremetal/example/overall_test/sdkconfig.h | 2 +- baremetal/example/pcie_test/sdkconfig | 2 +- baremetal/example/pcie_test/sdkconfig.h | 2 +- baremetal/example/qspi_nor_flash/sdkconfig | 2 +- baremetal/example/qspi_nor_flash/sdkconfig.h | 2 +- baremetal/example/spi_test/sdkconfig | 2 +- baremetal/example/spi_test/sdkconfig.h | 2 +- baremetal/example/template-mingw64/makefile | 6 +- baremetal/example/template-mingw64/sdkconfig | 2 +- .../example/template-mingw64/sdkconfig.h | 2 +- baremetal/example/template/makefile | 7 +- baremetal/example/template/sdkconfig | 2 +- baremetal/example/template/sdkconfig.h | 2 +- baremetal/example/timer_tacho/sdkconfig | 2 +- baremetal/example/timer_tacho/sdkconfig.h | 2 +- baremetal/example/uart_test/sdkconfig | 2 +- baremetal/example/uart_test/sdkconfig.h | 2 +- baremetal/example/wdt_test/sdkconfig | 2 +- baremetal/example/wdt_test/sdkconfig.h | 2 +- baremetal/example/xmac_test/sdkconfig | 2 +- baremetal/example/xmac_test/sdkconfig.h | 2 +- common/Kconfig | 18 -- configs/d2000_aarch32_amp_master_defconfig | 2 +- configs/d2000_aarch32_amp_slave_defconfig | 2 +- configs/d2000_aarch32_defconfig | 2 +- configs/d2000_aarch64_defconfig | 2 +- configs/e2000_aarch32_defconfig | 2 +- configs/e2000_aarch64_defconfig | 2 +- configs/ft2004_aarch32_defconfig | 2 +- configs/ft2004_aarch64_defconfig | 2 +- install.py | 90 ++----- lib/Kconfig | 3 + make/complier.mk | 20 +- scripts/compress.md | 5 +- 58 files changed, 250 insertions(+), 321 deletions(-) diff --git a/README.md b/README.md index 58bb521ae..dc1a7cd32 100644 --- a/README.md +++ b/README.md @@ -12,85 +12,88 @@ --- -## 2. 安装使用 +## 2. 安装方法 -### 2.1 Windows 10 x86_64 环境下使用 Standalone SDK +### 2.1 SDK使用支持的平台 -#### 2.1.1 在线安装`Msys2`搭建开发环境 +- Windows10 +- Ubuntu 20.04 x86_64 +- Kylis OS aarch64 -> 如果不想安装,可以参考 2.1.2 使用已经安装好的Portable开发环境 +### 2.2 配置SDK的DEV目录 -##### 2.1.1.1 准备安装包 +- 创建一个目录,并将目录记录在环境变量`$PHYTIUM_DEV_PATH`中,用于后续放置交叉编译链等工具, +- 具体步骤安装开发平台参考以下配置流程 -1. 获取[Windows环境安装包](https://pan.baidu.com/s/17WX5hec7t8_ubAKzFCwQAA) +#### 2.2.1 Windows 10 环境配置 -> 提取码:MGW6 - -- msys2, `msys2-x86_64-20210725.exe` -- mingw64-arm交叉编译链, `gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz` -- tftp工具,`tftp.zip` - -##### 2.1.1.2 配置开发环境目录 +- Windows10下使用SDK依赖Msys2, 推荐使用Portable的Msys2, 也可以参考配置Msys2环境 +- (1). 从以下链接下载**Windows开发环境压缩包**,然后解压,创建DEV目录,如`d:\phytium-dev` -1. 创建Windows集成开发环境(DEV目录),如`D:/phytium-dev`, 将DEV目录添加在Windows环境变量中,变量名为`PHYTIUM_DEV_PATH`,如下图所示,保存环境变量, - -> 对于Windows 10,在桌面左下角系统搜索框中输入“环境变量”即可进入环境变量编辑界面 - -> DEV目录中不要留空格 - -![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/192453_4e609b79_8736513.png "配置环境变量.png") +[下载链接](https://pan.baidu.com/s/1rF0fh4RwgiIpuTI0pk47xg) +> 提取码:MGW6 -2. 保存DEV环境变量后,打开一个控制台,输入`echo %PHYTIUM_DEV_PATH%`,检查环境变量是否设置成功, +- (2). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),指向文件夹`D:\PHYTIUM-DEV`(可以自定义) -![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164646_3fbc5df8_8736513.png "检查环境变量.png") +![配置环境变量](https://images.gitee.com/uploads/images/2021/1013/164551_934da3d7_8736513.png "配置环境变量.png") -##### 2.1.1.3 安装`Msys2`到开发环境中 -1. 双击`msys2-x86_64-20210725.exe`,设置`Msys2`的安装路径在DEV路径下,其余设置按默认安装,注意安装完成后不要马上启动,最后一步取消勾选“马上启动Msys2” - -![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164805_4169d4d2_8736513.png "安装Msys2.png") +- (3). 双击脚本`run_mingw64.cmd`, 进入mingw64控制台, 创建SDK的profile文件, 并添加读写权限 +``` +$ touch /etc/profile.d/phytium_standalone_sdk.sh +$ chmod 666 /etc/profile.d/phytium_standalone_sdk.sh +``` -![Msys2安装过程](https://images.gitee.com/uploads/images/2021/1013/135101_c8fc0454_8736513.png "Msys2安装过程.png") +#### 2.2.2 Kylin OS/Ubuntu 20.04 环境配置 -2. `Msys2`安装完成后,需要添加国内软件源,否则下载速度会很慢,进入`D:\phytium-dev\msys64\etc\pacman.d`目录下,找到以下三个文件,在文件末尾分别添加对应的软件源 +- (1). 创建DEV目录,如`~/phytium-dev`, 从以下链接下载交叉编译链,放置在DEV目录下 -- mirrorlist.mingw32 +- (2). 打开控制台,以管理员权限创建SDK的Profile文件,/etc/profile.d/phytium_standalone_sdk.sh(文件和路径不能自定义),并给与非sudo用户读写权限 ``` -Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686 +$ sudo touch /etc/profile.d/phytium_standalone_sdk.sh +$ sudo chmod 666 /etc/profile.d/phytium_standalone_sdk.sh ``` -- mirrorlist.mingw64 +- (3). 更新DEV目录,记录在环境变量`PHYTIUM_DEV_PATH`中,保存在SDK的Profile文件中 ``` -Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64 +$ +# 删除profile文件可能存在的DEV目录 +$ sed -i '/export PHYTIUM_DEV_PATH=/d /etc/profile.d/phytium_standalone_sdk.sh +# 将PHYTIUM_DEV_PATH记录在Profile中 +$ echo "export PHYTIUM_DEV_PATH=~/phytium-dev" >> /etc/profile.d/phytium_standalone_sdk.sh +# 在当前控制台窗口中生效PHYTIUM_DEV_PATH +$ source /etc/profile.d/phytium_standalone_sdk.sh ``` -- mirrorlist.msys -``` -Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch -``` +### 2.3 获取交叉编译工具链 -3. 进入`D:\phytium-dev\msys64`目录,双击`msys2_shell.cmd`启动运行`Msys2`,输入以下命令,更新`Msys2`软件,安装必要组件 +- 交叉编译链工具需要更加开发平台下载,放置在DEV目录下,后续由SDK安装脚本处理安装 -> 如果执行失败,可以多次尝试,直到没有报错 +> 注意不要修改交叉编译工具压缩包的名字,名字包含了版本和平台信息 -> 安装过程全部选用默认方式`default`或选择`y`,注意如果没有`default = all`,需要输入`y` +> 注意交叉编译工具压缩包需要放置在`PHYTIUM_DEV_PATH`目录下,否则SDK安装脚本无法处理 -``` -$ pacman -Syu -$ pacman -S mingw-w64-x86_64-toolchain -$ pacman -S base-devel git python3 python3-pip -``` +#### 2.3.1 Windows 10 Mingw64 交叉编译链 -![更新Msys2软件源](https://images.gitee.com/uploads/images/2021/1013/140545_6cda8ecc_8736513.png "更新Msys2软件源.png") +[Mingw64交叉编译链](https://pan.baidu.com/s/1nSeePtYsj4xFPEhMKwt0cg) +> 提取码:MGW6 -4. 运行以下命令,检查组件是否安装完全 -``` -$ pacman -Q make git wget python3 python3-pip -``` +#### 2.3.2 Linux x86_64 交叉编译链 -##### 2.1.1.4 安装SDK和交叉编译链 +[Linux x86_64交叉编译链](https://pan.baidu.com/s/1K03OKOjHLq4ktBiaC5HVRw) +> 提取码:LX64 -- 通过 Gitee 拉取 Standalone SDK 源代码到DEV目录下,如`D:\PHYTIUM-DEV\phytium-standalone-sdk` +#### 2.3.3 Linux aarch64 交叉编译链 + +[Linux aarch64交叉编译链](https://pan.baidu.com/s/1rqfttxdv9yxKCSg5K2Yrsg) +> 提取码:LA64 + +### 2.4 获取SDK并完成安装 + +- (1). 通过 Gitee 拉取 Standalone SDK 源代码到DEV目录下 +> 对于Windows 10平台,2.1.1章节的开发环境压缩包中通过Mingw64控制台提供了git工具 + +> 对于Linux/KylinOS平台,可以通过`sudo apt-get install build-essential`安装git等工具 ``` $ git clone https://gitee.com/phytium_embedded/phytium-standalone-sdk.git @@ -98,152 +101,89 @@ $ git clone https://gitee.com/phytium_embedded/phytium-standalone-sdk.git $ cd ./phytium-standalone-sdk ``` -- 将交叉编译链压缩包`gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz`放置在`D:\PHYTIUM-DEV\phytium-standalone-sdk\tools`下 +- (2). 运行`install.py`完成SDK安装 -- 创建SDK的profile文件,并添加读写权限 -``` -$ touch /etc/profile.d/phytium_standalone_sdk.sh -$ chmod 666 /etc/profile.d/phytium_standalone_sdk.sh -``` +- (3). **安装完成后重启系统,生效 Standalone SDK 环境**, 检查SDK路径是否与环境变量`STANDALONE_SDK_ROOT`一致 -- 在`D:\phytium-dev\phytium-standalone-sdk`目录下通过`Msys2`运行`./install.py` +### 2.5 Windows 10安装Msys2 -> 如果出现安装成功信息`[5]: Success!!!`表示安装成功,否则根据相应提示信息排查错误 +- (1). 获取[Windows环境安装包](https://pan.baidu.com/s/17WX5hec7t8_ubAKzFCwQAA) -> Windows环境不支持使用在线安装,即不支持使用`./install.py -online` +> 提取码:MGW6 -![检查安装需要的组件](https://images.gitee.com/uploads/images/2021/1014/153121_815cdc26_8736513.png "检查安装需要的组件.png") +- msys2, `msys2-x86_64-20210725.exe` +- mingw64-arm交叉编译链, `gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz` +- tftp工具,`tftp.zip` -![SDK安装过程](https://images.gitee.com/uploads/images/2021/1014/153155_ccaba2ab_8736513.png "SDK安装过程.png") +- (2). 创建Windows集成开发环境(DEV目录),如`D:/phytium-dev`, 将DEV目录添加在Windows环境变量中,变量名为`PHYTIUM_DEV_PATH`,如下图所示,保存环境变量, -![SDK安装完成](https://images.gitee.com/uploads/images/2021/1014/153529_929928b2_8736513.png "SDK安装完成.png") +> 对于Windows 10,在桌面左下角系统搜索框中输入“环境变量”即可进入环境变量编辑界面 -- **安装完成后重启系统,生效 Standalone SDK 环境**, 检查SDK路径是否与环境变量`STANDALONE_SDK_ROOT`一致 +> DEV目录中不要留空格 -![SDK安装完成环境变量](https://images.gitee.com/uploads/images/2021/1014/153641_9ceb3358_8736513.png "SDK安装完成环境变量.png") +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/192453_4e609b79_8736513.png "配置环境变量.png") -#### 2.1.2 使用Portable的开发环境 +- (3). 保存DEV环境变量后,打开一个控制台,输入`echo %PHYTIUM_DEV_PATH%`,检查环境变量是否设置成功, -- 下载开发环境然后解压,如`D:\PHYTIUM-DEV` +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164646_3fbc5df8_8736513.png "检查环境变量.png") -[下载链接](https://pan.baidu.com/s/1rF0fh4RwgiIpuTI0pk47xg) -> 提取码:MGW6 +- (4). 双击`msys2-x86_64-20210725.exe`,设置`Msys2`的安装路径在DEV路径下,其余设置按默认安装,注意安装完成后不要马上启动,最后一步取消勾选“马上启动Msys2” -- 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名不能自定义,必须用这个名字,SDK内部会使用)指向`D:\PHYTIUM-DEV`(可以自定义) +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164805_4169d4d2_8736513.png "安装Msys2.png") -![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164551_934da3d7_8736513.png "配置环境变量.png") +![Msys2安装过程](https://images.gitee.com/uploads/images/2021/1013/135101_c8fc0454_8736513.png "Msys2安装过程.png") -- 通过 Gitee 拉取 Standalone SDK 源代码到DEV目录下的`D:\PHYTIUM-DEV\phytium-standalone-sdk` +- (5). `Msys2`安装完成后,需要添加国内软件源,否则下载速度会很慢,进入`D:\phytium-dev\msys64\etc\pacman.d`目录下,找到以下三个文件,在文件末尾分别添加对应的软件源 +- mirrorlist.mingw32 ``` -$ git clone https://gitee.com/phytium_embedded/phytium-standalone-sdk.git ./phytium-standalone-sdk -$ cd ./phytium-standalone-sdk +Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686 ``` -- 将交叉编译链压缩包`gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz`放置在`D:\PHYTIUM-DEV\phytium-standalone-sdk\tools`下 - -- 创建SDK的profile文件,并添加读写权限 +- mirrorlist.mingw64 ``` -$ touch /etc/profile.d/phytium_standalone_sdk.sh -$ chmod 666 /etc/profile.d/phytium_standalone_sdk.sh +Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64 ``` -- 在`D:\phytium-dev\phytium-standalone-sdk`目录下双击`run_mingw64.cmd`, 启动`Msys2`控制台,在控制台输入`./install.py`完成SDK安装 - -- **安装完成后关闭shell重新打开,生效 Standalone SDK 环境**, 检查SDK路径是否与环境变量`STANDALONE_SDK_ROOT`一致 - -#### 2.1.3 卸载开发环境 - -- 在SDK目录`D:\phytium-dev\phytium-standalone-sdk`目录双击`run_mingw64.cmd`, 启动`Msys2`控制台,在控制台输入`./uninstall.py`完成SDK卸载 - -- 在`Msys2`控制台运行`sudo rm /etc/profile.d/phytium_standalone_sdk.sh`,删除SDK配置文件 - -- 在DEV目录`D:\phytium-dev\tftp`下以**管理员权限**打开Windows命令行中断,运行`uninstall.cmd`完成Tftd卸载 - -### 2.2 Ubuntu 20.04 x86_64 环境下使用 Standalone SDK - -#### 2.2.1 选择在线方式安装 SDK - -- 通过 Gitee 拉取 Standalone SDK 源代码 - +- mirrorlist.msys ``` -$ git clone https://gitee.com/phytium_embedded/phytium-standalone-sdk.git ~/standalone_sdk -$ cd ~/standalone_sdk +Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch ``` -- 检查 install.py 的执行权限, 如果没有执行权限`x`,需要利用`chmod +x ./install.py`添加执行权限 +- (6). 进入`D:\phytium-dev\msys64`目录,双击`msys2_shell.cmd`启动运行`Msys2`,输入以下命令,更新`Msys2`软件,安装必要组件 -``` -$ ls ./install.py -l --rwxrwxrwx 1 usr usr 6353 Jul 21 10:13 ./install.py -``` +> 如果执行失败,可以多次尝试,直到没有报错 -- 在线下载源代码和编译环境,创建SDK的profile,并为用户添加读写权限,然后完成 Standalone SDK 安装 -> 注意不要使用'sudo ./install.py',否则环境变量配置可能不正确 +> 安装过程全部选用默认方式`default`或选择`y`,注意如果没有`default = all`,需要输入`y` ``` -$ sudo touch /etc/profile.d/phytium_standalone_sdk.sh -$ sudo chmod 666 /etc/profile.d/phytium_standalone_sdk.sh -$ ./install.py -online +$ pacman -Syu +$ pacman -S mingw-w64-x86_64-toolchain +$ pacman -S base-devel git python3 python3-pip ``` -![输入图片说明](https://images.gitee.com/uploads/images/2021/1014/112439_2a038045_8736513.png "安装过程.png") - - -- **安装完成后重启系统,生效 Standalone SDK 环境** - ->请注意使用虚拟机进行开发时不要将sdk安装在挂载的共享文件夹下,否则交叉编译链的部分链接文件可能无法工作 - -#### 2.2.2 选择离线方式安装 SDK - -- 下载[Phytium Standalone SDK](https://gitee.com/phytium_embedded/phytium-standalone-sdk)源代码 -- 下载[AARCH32](https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776847/download/gcc-arm-x86_64-none-eabi-10-2020-q4-major.tar.xz)编译器 -- 下载[AARCH64](https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776846/download/gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11.tar.xz)编译器 - -- 解压 phytium_standalone_sdk.zip 为`~/standalone_sdk`(路径名可以自定义) -- 将 AARCH32、AARCH64 编译器压缩包放置在`~/standalone_sdk/tools`(必须放置在 tools 路径下) -- 确保 install.py 有执行权限,`~/standalone_sdk`Standalone SDK 安装 +![更新Msys2软件源](https://images.gitee.com/uploads/images/2021/1013/140545_6cda8ecc_8736513.png "更新Msys2软件源.png") +- (7). 运行以下命令,检查组件是否安装完全 ``` -$ sudo touch /etc/profile.d/phytium_standalone_sdk.sh -$ sudo chmod 666 /etc/profile.d/phytium_standalone_sdk.sh -$ ./install.py +$ pacman -Q make git wget python3 python3-pip ``` -- **安装完成后重启系统,生效 Standalone SDK 环境** - -#### 2.2.3 卸载开发环境 - -- 在SDK目录运行`./uninstall.py`完成SDK卸载 - -- 运行`sudo rm /etc/profile.d/phytium_standalone_sdk.sh`,删除SDK配置文件 - -### 2.3 Kylin OS/Ubuntu 20.04 AARCH64 环境下使用 Standalone SDK - -#### 2.3.1 选择在线方式安装 SDK +### 2.6 卸载开发环境 -参考 2.3.1 选择在线方式安装 SDK - -#### 2.3.2 选择离线方式安装 SDK +- 在SDK目录`D:\phytium-dev\phytium-standalone-sdk`目录双击`run_mingw64.cmd`, 启动`Msys2`控制台,在控制台输入`./uninstall.py`完成SDK卸载 -- 下载[Phytium Standalone SDK](https://gitee.com/phytium_embedded/phytium-standalone-sdk)源代码 -- 下载[AARCH32](https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/779742/download/gcc-arm-aarch64-none-eabi-10-2020-q4-major.tar.xz)编译器 -- 下载[AARCH64](https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/779743/download/gcc-arm-10.2-2020.11-aarch64-aarch64-none-elf.tar.xz)编译器 +- 在`Msys2`控制台运行`sudo rm /etc/profile.d/phytium_standalone_sdk.sh`,删除SDK配置文件 -- 解压 phytium_standalone_sdk.zip 为`~/standalone_sdk`(路径名可以自定义) -- 将 AARCH32、AARCH64 编译器压缩包放置在`~/standalone_sdk/tools`(必须放置在 tools 路径下) -- 确保 install.py 有执行权限,`~/standalone_sdk`Standalone SDK 安装 +- 在DEV目录`D:\phytium-dev\tftp`下以**管理员权限**打开Windows命令行中断,运行`uninstall.cmd`完成Tftd卸载 -``` -$ sudo touch /etc/profile.d/phytium_standalone_sdk.sh -$ ./install.py -``` +## 3. 使用方法 -### 2.4 新建一个 baremetal 应用工程 +### 3.1 新建一个 baremetal 应用工程 -#### 2.4.1 选择工程模板 +#### 3.1.1 选择工程模板 -##### 2.4.1.1 Window环境使用工程 +##### 3.1.1.1 Window环境使用工程 - 复制`~/standalone-sdk/example/template-mingw64`目录,作为baremetal应用工程 @@ -264,7 +204,7 @@ src --> 用户源文件* - 双击run_mingw64.cmd,在当前目录启动mingw64控制台 -##### 2.4.1.2 Linux环境使用工程 +##### 3.1.1.2 Linux环境使用工程 - 复制`~/standalone-sdk/example/template`目录,作为 baremetal 应用工程 diff --git a/baremetal/example/can_test/sdkconfig b/baremetal/example/can_test/sdkconfig index 9ecbb4c2b..559e61777 100644 --- a/baremetal/example/can_test/sdkconfig +++ b/baremetal/example/can_test/sdkconfig @@ -74,7 +74,7 @@ CONFIG_ENABLE_F_CAN=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX=y # # Cross-Compiler Setting diff --git a/baremetal/example/can_test/sdkconfig.h b/baremetal/example/can_test/sdkconfig.h index caf7c8386..317cc33e6 100644 --- a/baremetal/example/can_test/sdkconfig.h +++ b/baremetal/example/can_test/sdkconfig.h @@ -63,7 +63,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX /* Cross-Compiler Setting */ diff --git a/baremetal/example/gdma_test/sdkconfig b/baremetal/example/gdma_test/sdkconfig index b1e983153..7db58a123 100644 --- a/baremetal/example/gdma_test/sdkconfig +++ b/baremetal/example/gdma_test/sdkconfig @@ -70,7 +70,7 @@ CONFIG_ENABLE_F_GDMA=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX=y # # Cross-Compiler Setting diff --git a/baremetal/example/gdma_test/sdkconfig.h b/baremetal/example/gdma_test/sdkconfig.h index 7ab74f5b7..e2fa569d5 100644 --- a/baremetal/example/gdma_test/sdkconfig.h +++ b/baremetal/example/gdma_test/sdkconfig.h @@ -61,7 +61,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX /* Cross-Compiler Setting */ diff --git a/baremetal/example/letter_shell_test/sdkconfig b/baremetal/example/letter_shell_test/sdkconfig index 1a7413bc4..583af6fbc 100644 --- a/baremetal/example/letter_shell_test/sdkconfig +++ b/baremetal/example/letter_shell_test/sdkconfig @@ -62,7 +62,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX=y # # Cross-Compiler Setting diff --git a/baremetal/example/libc_port/README.md b/baremetal/example/libc_port/README.md index 3a99a5028..1056e6000 100644 --- a/baremetal/example/libc_port/README.md +++ b/baremetal/example/libc_port/README.md @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0. * * @Date: 2021-10-15 09:01:01 - * @LastEditTime: 2021-10-15 11:30:13 + * @LastEditTime: 2021-10-18 11:34:51 * @Description:  This files is for * * @Modify History: @@ -23,6 +23,15 @@ make cd .. ``` +``` +wget ftp://sourceware.org/pub/newlib/newlib-4.1.0.tar.gz +tar xzf newlib-4.1.0.tar.gz +cd newlib-4.1.0/ +./configure --target aarch64-none-elf --disable-newlib-supplied-syscalls +make +cd .. +``` + - compile the program with the Glib ``` arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o test.o test.c diff --git a/baremetal/example/libmetal_test/configs/d2000_amp_core0_aarch32_defconfig b/baremetal/example/libmetal_test/configs/d2000_amp_core0_aarch32_defconfig index c0690fe86..861b8200f 100644 --- a/baremetal/example/libmetal_test/configs/d2000_amp_core0_aarch32_defconfig +++ b/baremetal/example/libmetal_test/configs/d2000_amp_core0_aarch32_defconfig @@ -77,7 +77,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/libmetal_test/configs/d2000_amp_core0_aarch64_defconfig b/baremetal/example/libmetal_test/configs/d2000_amp_core0_aarch64_defconfig index ab059023e..c096c88a9 100644 --- a/baremetal/example/libmetal_test/configs/d2000_amp_core0_aarch64_defconfig +++ b/baremetal/example/libmetal_test/configs/d2000_amp_core0_aarch64_defconfig @@ -76,7 +76,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/libmetal_test/configs/d2000_amp_core1_aarch32_defconfig b/baremetal/example/libmetal_test/configs/d2000_amp_core1_aarch32_defconfig index 0bdc9f9c5..c4c078283 100644 --- a/baremetal/example/libmetal_test/configs/d2000_amp_core1_aarch32_defconfig +++ b/baremetal/example/libmetal_test/configs/d2000_amp_core1_aarch32_defconfig @@ -69,7 +69,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/libmetal_test/configs/d2000_amp_core1_aarch64_defconfig b/baremetal/example/libmetal_test/configs/d2000_amp_core1_aarch64_defconfig index 1d0dc5662..537ea8259 100644 --- a/baremetal/example/libmetal_test/configs/d2000_amp_core1_aarch64_defconfig +++ b/baremetal/example/libmetal_test/configs/d2000_amp_core1_aarch64_defconfig @@ -68,7 +68,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/libmetal_test/core0/sdkconfig b/baremetal/example/libmetal_test/core0/sdkconfig index ab059023e..c096c88a9 100644 --- a/baremetal/example/libmetal_test/core0/sdkconfig +++ b/baremetal/example/libmetal_test/core0/sdkconfig @@ -76,7 +76,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/libmetal_test/core0/sdkconfig.h b/baremetal/example/libmetal_test/core0/sdkconfig.h index 7c0b37a9a..b253c6938 100644 --- a/baremetal/example/libmetal_test/core0/sdkconfig.h +++ b/baremetal/example/libmetal_test/core0/sdkconfig.h @@ -66,7 +66,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/libmetal_test/core1/sdkconfig b/baremetal/example/libmetal_test/core1/sdkconfig index 1d0dc5662..537ea8259 100644 --- a/baremetal/example/libmetal_test/core1/sdkconfig +++ b/baremetal/example/libmetal_test/core1/sdkconfig @@ -68,7 +68,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/libmetal_test/core1/sdkconfig.h b/baremetal/example/libmetal_test/core1/sdkconfig.h index c5ad15e9e..ada3fc51e 100644 --- a/baremetal/example/libmetal_test/core1/sdkconfig.h +++ b/baremetal/example/libmetal_test/core1/sdkconfig.h @@ -60,7 +60,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/lwip_test/sdkconfig b/baremetal/example/lwip_test/sdkconfig index 16b1d939f..e9f1c3e20 100644 --- a/baremetal/example/lwip_test/sdkconfig +++ b/baremetal/example/lwip_test/sdkconfig @@ -79,7 +79,7 @@ CONFIG_F_GMAC_PHY_AR803X=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/lwip_test/sdkconfig.h b/baremetal/example/lwip_test/sdkconfig.h index 5bdc51bac..f2cee10b0 100644 --- a/baremetal/example/lwip_test/sdkconfig.h +++ b/baremetal/example/lwip_test/sdkconfig.h @@ -69,7 +69,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/nand_flash_test/sdkconfig b/baremetal/example/nand_flash_test/sdkconfig index fa7fe6fa1..98503aff2 100644 --- a/baremetal/example/nand_flash_test/sdkconfig +++ b/baremetal/example/nand_flash_test/sdkconfig @@ -59,7 +59,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX=y # # Cross-Compiler Setting diff --git a/baremetal/example/nand_flash_test/sdkconfig.h b/baremetal/example/nand_flash_test/sdkconfig.h index b1c01ae47..8ce5c6f21 100644 --- a/baremetal/example/nand_flash_test/sdkconfig.h +++ b/baremetal/example/nand_flash_test/sdkconfig.h @@ -52,7 +52,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/newlibc_test/README.md b/baremetal/example/newlibc_test/README.md index f1d63f864..da2389583 100644 --- a/baremetal/example/newlibc_test/README.md +++ b/baremetal/example/newlibc_test/README.md @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0. * * @Date: 2021-08-27 10:37:27 - * @LastEditTime: 2021-10-15 17:49:06 + * @LastEditTime: 2021-10-18 11:07:09 * @Description:  This files is for * * @Modify History: @@ -33,6 +33,11 @@ >描述构建、烧录下载镜像的过程,列出相关的命令
+- host侧设置重启host侧tftp服务器 +``` +sudo service tftpd-hpa restart +``` + - 开发板侧使用bootelf命令跳转 ``` setenv ipaddr 192.168.4.20 diff --git a/baremetal/example/newlibc_test/makefile b/baremetal/example/newlibc_test/makefile index cb4b44e9e..3e4c839e5 100644 --- a/baremetal/example/newlibc_test/makefile +++ b/baremetal/example/newlibc_test/makefile @@ -7,7 +7,11 @@ export USR_INC_DIR ?= . \ ./inc # 用户定义的编译目标文件上传路径 -USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp +ifeq ($(OS),Windows_NT) + USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp +else + USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp +endif # 设置启动镜像名 BOOT_IMG_NAME ?= baremetal @@ -19,3 +23,4 @@ include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk boot: make @cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf + @ls $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf -l diff --git a/baremetal/example/newlibc_test/sdkconfig b/baremetal/example/newlibc_test/sdkconfig index 51d532717..9b13a5241 100644 --- a/baremetal/example/newlibc_test/sdkconfig +++ b/baremetal/example/newlibc_test/sdkconfig @@ -2,7 +2,7 @@ # # Project Configuration # -CONFIG_TARGET_NAME="d2000_baremetal_a32" +CONFIG_TARGET_NAME="d2000_baremetal_a64" # end of Project Configuration # @@ -12,14 +12,13 @@ CONFIG_TARGET_NAME="d2000_baremetal_a32" # # Arch Configuration # -CONFIG_TARGET_ARMV8_AARCH32=y -# CONFIG_TARGET_ARMV8_AARCH64 is not set +# CONFIG_TARGET_ARMV8_AARCH32 is not set +CONFIG_TARGET_ARMV8_AARCH64=y # CONFIG_TARGET_ARMV7 is not set CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y # CONFIG_USE_SYS_TICK is not set -CONFIG_USE_AARCH64_L1_TO_AARCH32=y # end of Arch Configuration # @@ -37,7 +36,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set # CONFIG_USE_ETH is not set @@ -55,13 +61,11 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y # # Cross-Compiler Setting # CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_COMPILER_VERSION="10.2.1" # CONFIG_USE_EXT_COMPILER is not set # end of Cross-Compiler Setting @@ -75,8 +79,8 @@ CONFIG_LOG_INFO=y # # Linker Options # -CONFIG_AARCH32_RAM_LD=y -# CONFIG_AARCH64_RAM_LD is not set +# CONFIG_AARCH32_RAM_LD is not set +CONFIG_AARCH64_RAM_LD=y # CONFIG_QEMU_AARCH32_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set CONFIG_LINK_SCRIPT_ROM=y @@ -86,15 +90,15 @@ CONFIG_LINK_SCRIPT_RAM=y CONFIG_RAM_START_UP_ADDR=0x81000000 CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=0x04000 -CONFIG_STACK_SIZE=0x1000 +CONFIG_STACK_TOP_ADDR=0x82000000 # end of Linker Options # end of Building Option # # Library Configuration # -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +# CONFIG_USE_G_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/newlibc_test/sdkconfig.h b/baremetal/example/newlibc_test/sdkconfig.h index 889f30f71..f2d27dff5 100644 --- a/baremetal/example/newlibc_test/sdkconfig.h +++ b/baremetal/example/newlibc_test/sdkconfig.h @@ -3,21 +3,20 @@ /* Project Configuration */ -#define CONFIG_TARGET_NAME "d2000_baremetal_a32" +#define CONFIG_TARGET_NAME "d2000_baremetal_a64" /* end of Project Configuration */ /* Platform Setting */ /* Arch Configuration */ -#define CONFIG_TARGET_ARMV8_AARCH32 -/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ +/* CONFIG_TARGET_ARMV8_AARCH32 is not set */ +#define CONFIG_TARGET_ARMV8_AARCH64 /* CONFIG_TARGET_ARMV7 is not set */ #define CONFIG_USE_CACHE #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU /* CONFIG_USE_SYS_TICK is not set */ -#define CONFIG_USE_AARCH64_L1_TO_AARCH32 /* end of Arch Configuration */ /* Board Configuration */ @@ -33,7 +32,12 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_EBABLE_GICV3 -/* CONFIG_USE_SERIAL is not set */ +#define CONFIG_USE_SERIAL + +/* Usart Configuration */ + +#define CONFIG_ENABLE_Pl011_UART +/* end of Usart Configuration */ /* CONFIG_USE_GPIO is not set */ /* CONFIG_USE_IOMUX is not set */ /* CONFIG_USE_ETH is not set */ @@ -50,12 +54,9 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 - /* Cross-Compiler Setting */ #define CONFIG_COMPILER_NO_STD_STARUP -#define CONFIG_COMPILER_VERSION "10.2.1" /* CONFIG_USE_EXT_COMPILER is not set */ /* end of Cross-Compiler Setting */ /* CONFIG_LOG_VERBOS is not set */ @@ -67,8 +68,8 @@ /* Linker Options */ -#define CONFIG_AARCH32_RAM_LD -/* CONFIG_AARCH64_RAM_LD is not set */ +/* CONFIG_AARCH32_RAM_LD is not set */ +#define CONFIG_AARCH64_RAM_LD /* CONFIG_QEMU_AARCH32_RAM_LD is not set */ /* CONFIG_USER_DEFINED_LD is not set */ #define CONFIG_LINK_SCRIPT_ROM @@ -78,14 +79,14 @@ #define CONFIG_RAM_START_UP_ADDR 0x81000000 #define CONFIG_RAM_SIZE_MB 64 #define CONFIG_HEAP_SIZE 0x04000 -#define CONFIG_STACK_SIZE 0x1000 +#define CONFIG_STACK_TOP_ADDR 0x82000000 /* end of Linker Options */ /* end of Building Option */ /* Library Configuration */ -#define CONFIG_USE_G_LIBC -/* CONFIG_USE_NEW_LIBC is not set */ +/* CONFIG_USE_G_LIBC is not set */ +#define CONFIG_USE_NEW_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/baremetal/example/overall_test/sdkconfig b/baremetal/example/overall_test/sdkconfig index 0e4547314..0ffab711c 100644 --- a/baremetal/example/overall_test/sdkconfig +++ b/baremetal/example/overall_test/sdkconfig @@ -72,7 +72,7 @@ CONFIG_USE_F_SDMMC=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/overall_test/sdkconfig.h b/baremetal/example/overall_test/sdkconfig.h index ad9e49316..02efdd143 100644 --- a/baremetal/example/overall_test/sdkconfig.h +++ b/baremetal/example/overall_test/sdkconfig.h @@ -64,7 +64,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/pcie_test/sdkconfig b/baremetal/example/pcie_test/sdkconfig index 9d63a905c..acfc0d6ca 100644 --- a/baremetal/example/pcie_test/sdkconfig +++ b/baremetal/example/pcie_test/sdkconfig @@ -103,7 +103,7 @@ CONFIG_ENABLE_F_PCIE=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/pcie_test/sdkconfig.h b/baremetal/example/pcie_test/sdkconfig.h index ec5e690dc..0ffede323 100644 --- a/baremetal/example/pcie_test/sdkconfig.h +++ b/baremetal/example/pcie_test/sdkconfig.h @@ -85,7 +85,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/qspi_nor_flash/sdkconfig b/baremetal/example/qspi_nor_flash/sdkconfig index b02c2e93e..7a9bbc788 100644 --- a/baremetal/example/qspi_nor_flash/sdkconfig +++ b/baremetal/example/qspi_nor_flash/sdkconfig @@ -57,7 +57,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/qspi_nor_flash/sdkconfig.h b/baremetal/example/qspi_nor_flash/sdkconfig.h index e82709f60..fe7272502 100644 --- a/baremetal/example/qspi_nor_flash/sdkconfig.h +++ b/baremetal/example/qspi_nor_flash/sdkconfig.h @@ -52,7 +52,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/spi_test/sdkconfig b/baremetal/example/spi_test/sdkconfig index 80711e46b..69f6b424f 100644 --- a/baremetal/example/spi_test/sdkconfig +++ b/baremetal/example/spi_test/sdkconfig @@ -94,7 +94,7 @@ CONFIG_ENABLE_FIOMUX=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/spi_test/sdkconfig.h b/baremetal/example/spi_test/sdkconfig.h index f8b4c00ce..798747db7 100644 --- a/baremetal/example/spi_test/sdkconfig.h +++ b/baremetal/example/spi_test/sdkconfig.h @@ -78,7 +78,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/template-mingw64/makefile b/baremetal/example/template-mingw64/makefile index a9e515db0..8a5c502ed 100644 --- a/baremetal/example/template-mingw64/makefile +++ b/baremetal/example/template-mingw64/makefile @@ -7,7 +7,11 @@ export USR_INC_DIR ?= . \ ./inc # 用户定义的编译目标文件上传路径 (建议放置在tftp工具目录下) -USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp +ifeq ($(OS),Windows_NT) + USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp +else + USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp +endif # 设置启动镜像名 BOOT_IMG_NAME ?= baremetal diff --git a/baremetal/example/template-mingw64/sdkconfig b/baremetal/example/template-mingw64/sdkconfig index 0e354a635..7871d17b4 100644 --- a/baremetal/example/template-mingw64/sdkconfig +++ b/baremetal/example/template-mingw64/sdkconfig @@ -54,7 +54,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/template-mingw64/sdkconfig.h b/baremetal/example/template-mingw64/sdkconfig.h index c3c6097fb..27238bdb9 100644 --- a/baremetal/example/template-mingw64/sdkconfig.h +++ b/baremetal/example/template-mingw64/sdkconfig.h @@ -49,7 +49,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/template/makefile b/baremetal/example/template/makefile index 36d7ec5bc..3e4c839e5 100644 --- a/baremetal/example/template/makefile +++ b/baremetal/example/template/makefile @@ -7,7 +7,11 @@ export USR_INC_DIR ?= . \ ./inc # 用户定义的编译目标文件上传路径 -USR_BOOT_DIR ?= /mnt/d/tftboot/ +ifeq ($(OS),Windows_NT) + USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp +else + USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp +endif # 设置启动镜像名 BOOT_IMG_NAME ?= baremetal @@ -19,3 +23,4 @@ include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk boot: make @cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf + @ls $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf -l diff --git a/baremetal/example/template/sdkconfig b/baremetal/example/template/sdkconfig index 701008e24..bc42fb652 100644 --- a/baremetal/example/template/sdkconfig +++ b/baremetal/example/template/sdkconfig @@ -53,7 +53,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/template/sdkconfig.h b/baremetal/example/template/sdkconfig.h index 55d3b66f7..0768410b7 100644 --- a/baremetal/example/template/sdkconfig.h +++ b/baremetal/example/template/sdkconfig.h @@ -48,7 +48,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/timer_tacho/sdkconfig b/baremetal/example/timer_tacho/sdkconfig index f1373a501..0a47aee94 100644 --- a/baremetal/example/timer_tacho/sdkconfig +++ b/baremetal/example/timer_tacho/sdkconfig @@ -60,7 +60,7 @@ CONFIG_ENABLE_TIMER_TACHO=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/timer_tacho/sdkconfig.h b/baremetal/example/timer_tacho/sdkconfig.h index a50321de3..9347dfb88 100644 --- a/baremetal/example/timer_tacho/sdkconfig.h +++ b/baremetal/example/timer_tacho/sdkconfig.h @@ -53,7 +53,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/uart_test/sdkconfig b/baremetal/example/uart_test/sdkconfig index 38d9a13a1..01afc02cb 100644 --- a/baremetal/example/uart_test/sdkconfig +++ b/baremetal/example/uart_test/sdkconfig @@ -62,7 +62,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/uart_test/sdkconfig.h b/baremetal/example/uart_test/sdkconfig.h index b146e5266..65108dcd5 100644 --- a/baremetal/example/uart_test/sdkconfig.h +++ b/baremetal/example/uart_test/sdkconfig.h @@ -55,7 +55,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/wdt_test/sdkconfig b/baremetal/example/wdt_test/sdkconfig index 30bce2f99..493ab6b94 100644 --- a/baremetal/example/wdt_test/sdkconfig +++ b/baremetal/example/wdt_test/sdkconfig @@ -69,7 +69,7 @@ CONFIG_ENABLE_FWDT=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/wdt_test/sdkconfig.h b/baremetal/example/wdt_test/sdkconfig.h index 490efe618..10c44311d 100644 --- a/baremetal/example/wdt_test/sdkconfig.h +++ b/baremetal/example/wdt_test/sdkconfig.h @@ -60,7 +60,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/baremetal/example/xmac_test/sdkconfig b/baremetal/example/xmac_test/sdkconfig index f71e11f0c..d81c468df 100644 --- a/baremetal/example/xmac_test/sdkconfig +++ b/baremetal/example/xmac_test/sdkconfig @@ -93,7 +93,7 @@ CONFIG_ENABLE_F_XMAC=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/baremetal/example/xmac_test/sdkconfig.h b/baremetal/example/xmac_test/sdkconfig.h index 708b054f0..b72248362 100644 --- a/baremetal/example/xmac_test/sdkconfig.h +++ b/baremetal/example/xmac_test/sdkconfig.h @@ -76,7 +76,7 @@ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 +#define CONFIG_ENVI_LINUX_X86_64 /* Cross-Compiler Setting */ diff --git a/common/Kconfig b/common/Kconfig index 2760082a8..8f3e7d8d6 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1,16 +1,4 @@ - -choice SDK_ENVI_TYPE - prompt "Dev-Host Type" - default ENVI_UBUNTU_20_04 - help - SDK development host environment type. - - config ENVI_UBUNTU_20_04 - bool - prompt "Ubuntu 20.04 x85_64" -endchoice # SDK_ENVI_TYPE - menu "Cross-Compiler Setting" config COMPILER_NO_STD_STARUP bool "Non-Use GCC Provide Startup Files" @@ -18,12 +6,6 @@ menu "Cross-Compiler Setting" help Select if do not want to gcc provide startup file - config COMPILER_VERSION - string "Compiler Version" - default "10.2.1" if TARGET_ARMV8_AARCH32 - help - Select Cross Compiler version - config USE_EXT_COMPILER bool "Use User-Specified Compiler" default n diff --git a/configs/d2000_aarch32_amp_master_defconfig b/configs/d2000_aarch32_amp_master_defconfig index 27db8b493..76eb7c48f 100644 --- a/configs/d2000_aarch32_amp_master_defconfig +++ b/configs/d2000_aarch32_amp_master_defconfig @@ -68,7 +68,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/configs/d2000_aarch32_amp_slave_defconfig b/configs/d2000_aarch32_amp_slave_defconfig index 32b6320d7..c625c1421 100644 --- a/configs/d2000_aarch32_amp_slave_defconfig +++ b/configs/d2000_aarch32_amp_slave_defconfig @@ -75,7 +75,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/configs/d2000_aarch32_defconfig b/configs/d2000_aarch32_defconfig index 20d30461a..a8309dce4 100644 --- a/configs/d2000_aarch32_defconfig +++ b/configs/d2000_aarch32_defconfig @@ -52,7 +52,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/configs/d2000_aarch64_defconfig b/configs/d2000_aarch64_defconfig index 46a141e30..7aa405afe 100644 --- a/configs/d2000_aarch64_defconfig +++ b/configs/d2000_aarch64_defconfig @@ -62,7 +62,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/configs/e2000_aarch32_defconfig b/configs/e2000_aarch32_defconfig index e303256cf..bc5dbf470 100644 --- a/configs/e2000_aarch32_defconfig +++ b/configs/e2000_aarch32_defconfig @@ -50,7 +50,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/configs/e2000_aarch64_defconfig b/configs/e2000_aarch64_defconfig index 3bbb5b5fd..1838caf54 100644 --- a/configs/e2000_aarch64_defconfig +++ b/configs/e2000_aarch64_defconfig @@ -50,7 +50,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/configs/ft2004_aarch32_defconfig b/configs/ft2004_aarch32_defconfig index e78fdad36..2024ae61c 100644 --- a/configs/ft2004_aarch32_defconfig +++ b/configs/ft2004_aarch32_defconfig @@ -59,7 +59,7 @@ CONFIG_ENABLE_Pl011_UART=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/configs/ft2004_aarch64_defconfig b/configs/ft2004_aarch64_defconfig index 1dda90930..b6d873d8f 100644 --- a/configs/ft2004_aarch64_defconfig +++ b/configs/ft2004_aarch64_defconfig @@ -53,7 +53,7 @@ CONFIG_EBABLE_GICV3=y # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y +CONFIG_ENVI_LINUX_X86_64=y # # Cross-Compiler Setting diff --git a/install.py b/install.py index cb1a2ec17..52f8f1c05 100755 --- a/install.py +++ b/install.py @@ -35,10 +35,6 @@ windows_msys2 = 2 ### environment constant sdk_profile_path = "/etc/profile.d/phytium_standalone_sdk.sh" -# argv[1]: online/offline -# print(sys.argv) -is_online = False - # check file attributes def is_readable(path, user): user_info = pwd.getpwnam(user) @@ -75,16 +71,8 @@ def un_tar(src_path, dst_dir): ################################################################# # STEP 1: Check environment -# check if it is offline install or online install -for i in range(1, len(sys.argv)): - if('-online' == sys.argv[i]) or ('-on' == sys.argv[i]) or ('-o' == sys.argv[i]): - is_online = True - -print("[1]: Online install" if is_online else "[1]: Offline install") # check install environment -install_platform = -1 - if (platform.system() == 'Linux' ) and (platform.processor() == 'x86_64'): install_platform = linux_x86 elif (platform.system() == 'Linux' ) and (platform.processor() == 'aarch64'): @@ -98,10 +86,6 @@ else: # features for msys2 platform, windows platform do not support online ######################################### if (install_platform == windows_msys2): - if (is_online == True): - print("[1]: Windows Msys2 do not support online install!!!") - exit() - if (None == os.environ.get("PHYTIUM_DEV_PATH")): print("[1]: Please set 'PHYTIUM_DEV_PATH' fisrt!!!") exit() @@ -170,34 +154,36 @@ os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING END/d' "+ old_profile_pat print("[2]: Reset environment") -## STEP 3: install cross-platform compiler +## STEP 3: get cross-platform compiler cc_install_path = standalone_sdk_path + '/' + 'tools' + '/' # set cc package name, download url and install dst dir if (install_platform == linux_x86): - aarch32_cc = 'gcc-arm-x86_64-none-eabi-10-2020-q4-major' - aarch64_cc = 'gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11' + + aarch32_cc = 'gcc-arm-10.3-2021.07-x86_64-arm-none-eabi' + aarch64_cc = 'gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf' # cc package name aarch32_cc_pack = aarch32_cc + '.tar.xz' aarch64_cc_pack = aarch64_cc + '.tar.xz' - aarch32_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776847/download/gcc-arm-x86_64-none-eabi-10-2020-q4-major.tar.xz' - aarch64_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776846/download/gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11.tar.xz' + #aarch32_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776847/download/gcc-arm-x86_64-none-eabi-10-2020-q4-major.tar.xz' + #aarch64_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776846/download/gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11.tar.xz' aarch32_cc_install_path = cc_install_path + aarch32_cc aarch64_cc_install_path = cc_install_path + aarch64_cc + elif (install_platform == linux_aarch64): - aarch32_cc = 'gcc-arm-aarch64-none-eabi-10-2020-q4-major' - aarch64_cc = 'gcc-arm-10.2-2020.11-aarch64-aarch64-none-elf' + aarch32_cc = 'gcc-arm-10.3-2021.07-aarch64-arm-none-eabi' + aarch64_cc = 'gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf' # cc package name aarch32_cc_pack = aarch32_cc + '.tar.xz' aarch64_cc_pack = aarch64_cc + '.tar.xz' - aarch32_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/779742/download/gcc-arm-aarch64-none-eabi-10-2020-q4-major.tar.xz' - aarch64_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/779743/download/gcc-arm-10.2-2020.11-aarch64-aarch64-none-elf.tar.xz' + # aarch32_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/779742/download/gcc-arm-aarch64-none-eabi-10-2020-q4-major.tar.xz' + # aarch64_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/779743/download/gcc-arm-10.2-2020.11-aarch64-aarch64-none-elf.tar.xz' aarch32_cc_install_path = cc_install_path + aarch32_cc aarch64_cc_install_path = cc_install_path + aarch64_cc @@ -239,66 +225,44 @@ if (install_platform == windows_msys2) and (not os.path.exists(aarch64_cc_dl_dst print("[3] Copy AARCH64 CC from {}".format(aarch32_cc_dev_path)) shutil.copy2(aarch64_cc_dev_path, aarch64_cc_dl_dst) ######################################### +if not os.path.exists(aarch32_cc_dl_dst): + print("[3]: Failed, AARCH32 CC package {} non found !!!".format(aarch32_cc_dl_dst)) + exit() -if is_online: #online - import wget - - # download aarch32 cc package - if not aarch32_cc_is_installed: - print("[3] Download AARCH32 CC from {}...".format(aarch32_cc_url)) - cc_file = wget.download(aarch32_cc_url, aarch32_cc_dl_dst) - if not os.path.exists(cc_file) or not (cc_file == aarch32_cc_dl_dst): - print("[3]: Download AARCH32 CC failed!!!") - exit() - else: - print("[3]: Download AARCH32 CC at {}".format(aarch32_cc_dl_dst)) - - # download aarch64 cc package - if not aarch64_cc_is_installed: - print("[3] Download AARCH64 CC from {}...".format(aarch64_cc_url)) - cc_file = wget.download(aarch64_cc_url, aarch64_cc_dl_dst) - if not os.path.exists(cc_file) or not (cc_file == aarch64_cc_dl_dst): - print("[3]: Download AARCH64 CC failed!!!") - exit() - else: - print("[3]: Download AARCH64 CC at {}".format(aarch64_cc_dl_dst)) - -else: #offline, assert cc package exists - if not os.path.exists(aarch32_cc_dl_dst): - print("[3]: Failed, AARCH32 CC package {} non found !!!".format(aarch32_cc_dl_dst)) - exit() - - if not os.path.exists(aarch64_cc_dl_dst): - print("[3]: Failed, AARCH64 CC package {} non found !!!".format(aarch64_cc_dl_dst)) - exit() +if not os.path.exists(aarch64_cc_dl_dst): + print("[3]: Failed, AARCH64 CC package {} non found !!!".format(aarch64_cc_dl_dst)) + exit() +## STEP 4:install cc # untar aarch32 cc if not aarch32_cc_is_installed: if os.path.exists(aarch32_cc_dl_dst): - print("[3]: Install AARCH32 CC...") + print("[4]: Install AARCH32 CC...") un_tar(aarch32_cc_dl_dst, cc_install_path) # write aarch32 cc path if os.path.exists(aarch32_cc_install_path): - print("[3]: AARCH32 CC install success at {}".format(aarch32_cc_install_path)) + print("[4]: AARCH32 CC install success at {}".format(aarch32_cc_install_path)) else: - print("[3]: AARCH32 CC install failed !!!") + print("[4]: AARCH32 CC install failed !!!") exit() # untar aarch64 cc if not aarch64_cc_is_installed: if os.path.exists(aarch64_cc_dl_dst): - print("[3]: Install AARCH64 CC...") + print("[4]: Install AARCH64 CC...") un_tar(aarch64_cc_dl_dst, cc_install_path) # write aarch64 cc path if os.path.exists(aarch64_cc_install_path): - print("[3]: AARCH64 CC install success at {}".format(aarch64_cc_install_path)) + print("[4]: AARCH64 CC install success at {}".format(aarch64_cc_install_path)) else: - print("[3]: AARCH64 CC install failed !!!") + print("[4]: AARCH64 CC install failed !!!") exit() -## STEP 4: write environment variables +print("[4]: GNU CC version: 10.3.1-2021.07") + +## STEP 5: write environment variables os.environ['STANDALONE_SDK_ROOT'] = standalone_sdk_path os.environ['AARCH32_CROSS_PATH'] = aarch32_cc_install_path os.environ['AARCH64_CROSS_PATH'] = aarch64_cc_install_path diff --git a/lib/Kconfig b/lib/Kconfig index e8f141373..c482ee1ad 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -10,5 +10,8 @@ choice config USE_NEW_LIBC bool "Use NewLibC" + #config USE_NOSTD_LIBC + # bool "Use NoStdLbC" + endchoice diff --git a/make/complier.mk b/make/complier.mk index b4a6f51c6..6a4f125d4 100755 --- a/make/complier.mk +++ b/make/complier.mk @@ -126,6 +126,7 @@ OBJ_FILES := $(filter-out $(EXCL_OBJS), $(OBJ_FILES)) DEP_FILES := $(OBJ_FILES:%=%.d) LIBPATH ?= +CC_VERSION = 10.3.1 ifdef CONFIG_TARGET_ARMV8_AARCH32 # support float and div, turn on by default for aarch64 -mfpu=crypto-neon-fp-armv8。 ASFLAGS := $(ASFLAGS) -mfpu=crypto-neon-fp-armv8 -ftree-vectorize -mfloat-abi=softfp -ffast-math -fsingle-precision-constant -march=$(ARCH) @@ -139,7 +140,7 @@ ifdef CONFIG_USE_G_LIBC LDFLAGS += -lgcc -L $(LIBPATH) INC_DIR := $(INC_DIR) $(CROSS_PATH)/arm-none-eabi/include OBJ_FILES += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp/libc.a \ - $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CONFIG_COMPILER_VERSION)/libgcc.a + $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CC_VERSION)/libgcc.a endif endif @@ -147,12 +148,20 @@ endif ifdef CONFIG_USE_NEW_LIBC ifdef CONFIG_TARGET_ARMV8_AARCH32 LIBPATH := $(CROSS_PATH)/newlib/arm-none-eabi/newlib - LDFLAGS += -nostdlib -nostartfiles - LDFLAGS += -lgcc -L $(LIBPATH) INC_DIR := $(INC_DIR) $(CROSS_PATH)/newlib/newlib/libc/include OBJ_FILES += $(CROSS_PATH)/newlib/arm-none-eabi/newlib/libc.a \ - $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CONFIG_COMPILER_VERSION)/libgcc.a + $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CC_VERSION)/libgcc.a endif + + ifdef CONFIG_TARGET_ARMV8_AARCH64 + LIBPATH := $(CROSS_PATH)/newlib/aarch64-none-elf/newlib + INC_DIR := $(INC_DIR) $(CROSS_PATH)/newlib/newlib/libc/include + OBJ_FILES += $(CROSS_PATH)/newlib/aarch64-none-elf/newlib/libc.a \ + $(CROSS_PATH)/lib/gcc/aarch64-none-elf/$(CC_VERSION)/libgcc.a + endif + + LDFLAGS += -nostdlib -nostartfiles + LDFLAGS += -lgcc -L $(LIBPATH) endif # 不使用Libc库 @@ -203,9 +212,6 @@ clean: $(call RM_FILES,*.map) $(call RM_FILES,*.tar.gz) - - - # Make sure everything is rebuilt if this makefile is changed $(OBJ_FILES) $(APP): makefile diff --git a/scripts/compress.md b/scripts/compress.md index d8886251c..2001292d3 100644 --- a/scripts/compress.md +++ b/scripts/compress.md @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0. * * @Date: 2021-07-22 11:46:04 - * @LastEditTime: 2021-10-12 18:51:28 + * @LastEditTime: 2021-10-18 15:36:46 * @Description:  This files is for * * @Modify History: @@ -16,7 +16,8 @@ - 将文件夹xxx压缩成tar.xz格式 ```shell tar -cvf xxx.tar xxx # 生成xxx.tar文件 -xz -z xxx.tar # 生成xxx.tar.xz文件, 耗时较长,压缩效率高 +xz -z -k 8 xxx.tar # 生成xxx.tar.xz文件, 耗时较长,压缩效率高 +tar -Jcvf xxx.tar.xz xxx ``` - 解压缩tar.xz文件 -- Gitee From c58588331652de9706bef35311491a04f1f38268 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 08:49:12 +0800 Subject: [PATCH 05/21] update --- README.md | 27 ++++++++----- baremetal/example/newlibc_test/README.md | 2 +- baremetal/example/newlibc_test/sdkconfig | 26 +++++------- baremetal/example/newlibc_test/sdkconfig.h | 24 +++++------ install.py | 47 +++++++++------------- make/ld/Kconfig | 2 +- run_mingw64.cmd | 2 - run_tftd.cmd | 2 - scripts/update_dev_path.sh | 27 +++++++++++++ 9 files changed, 85 insertions(+), 74 deletions(-) delete mode 100644 run_mingw64.cmd delete mode 100644 run_tftd.cmd create mode 100644 scripts/update_dev_path.sh diff --git a/README.md b/README.md index dc1a7cd32..95f820ca2 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ - (3). 双击脚本`run_mingw64.cmd`, 进入mingw64控制台, 创建SDK的profile文件, 并添加读写权限 ``` -$ touch /etc/profile.d/phytium_standalone_sdk.sh -$ chmod 666 /etc/profile.d/phytium_standalone_sdk.sh +touch /etc/profile.d/phytium_standalone_sdk.sh +chmod 666 /etc/profile.d/phytium_standalone_sdk.sh ``` #### 2.2.2 Kylin OS/Ubuntu 20.04 环境配置 @@ -49,20 +49,27 @@ $ chmod 666 /etc/profile.d/phytium_standalone_sdk.sh - (1). 创建DEV目录,如`~/phytium-dev`, 从以下链接下载交叉编译链,放置在DEV目录下 - (2). 打开控制台,以管理员权限创建SDK的Profile文件,/etc/profile.d/phytium_standalone_sdk.sh(文件和路径不能自定义),并给与非sudo用户读写权限 -``` -$ sudo touch /etc/profile.d/phytium_standalone_sdk.sh -$ sudo chmod 666 /etc/profile.d/phytium_standalone_sdk.sh +```shell +sudo touch /etc/profile.d/phytium_standalone_sdk.sh +sudo chmod 666 /etc/profile.d/phytium_standalone_sdk.sh ``` - (3). 更新DEV目录,记录在环境变量`PHYTIUM_DEV_PATH`中,保存在SDK的Profile文件中 -``` -$ +```shell +# 指定sdk profle文件 +export sdk_profile=/etc/profile.d/phytium_standalone_sdk.sh +# 检查sdk profile文件是否存在 +ls $sdk_profile -l # 删除profile文件可能存在的DEV目录 -$ sed -i '/export PHYTIUM_DEV_PATH=/d /etc/profile.d/phytium_standalone_sdk.sh +sudo sed -i "/export PHYTIUM_DEV_PATH=/d" $sdk_profile # 将PHYTIUM_DEV_PATH记录在Profile中 -$ echo "export PHYTIUM_DEV_PATH=~/phytium-dev" >> /etc/profile.d/phytium_standalone_sdk.sh +echo "export PHYTIUM_DEV_PATH=/mnt/d/phytium-dev" >> $sdk_profile +# 检查DEV目录环境变量是否已定义 +cat $sdk_profile | grep PHYTIUM_DEV_PATH # 在当前控制台窗口中生效PHYTIUM_DEV_PATH -$ source /etc/profile.d/phytium_standalone_sdk.sh +source $sdk_profile +# 检查DEV目录 +echo $PHYTIUM_DEV_PATH ``` ### 2.3 获取交叉编译工具链 diff --git a/baremetal/example/newlibc_test/README.md b/baremetal/example/newlibc_test/README.md index da2389583..8e575ed2a 100644 --- a/baremetal/example/newlibc_test/README.md +++ b/baremetal/example/newlibc_test/README.md @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0. * * @Date: 2021-08-27 10:37:27 - * @LastEditTime: 2021-10-18 11:07:09 + * @LastEditTime: 2021-10-18 19:22:06 * @Description:  This files is for * * @Modify History: diff --git a/baremetal/example/newlibc_test/sdkconfig b/baremetal/example/newlibc_test/sdkconfig index 9b13a5241..4681129e4 100644 --- a/baremetal/example/newlibc_test/sdkconfig +++ b/baremetal/example/newlibc_test/sdkconfig @@ -2,7 +2,7 @@ # # Project Configuration # -CONFIG_TARGET_NAME="d2000_baremetal_a64" +CONFIG_TARGET_NAME="d2000_baremetal_a32" # end of Project Configuration # @@ -12,13 +12,14 @@ CONFIG_TARGET_NAME="d2000_baremetal_a64" # # Arch Configuration # -# CONFIG_TARGET_ARMV8_AARCH32 is not set -CONFIG_TARGET_ARMV8_AARCH64=y +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set # CONFIG_TARGET_ARMV7 is not set CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y # CONFIG_USE_SYS_TICK is not set +CONFIG_USE_AARCH64_L1_TO_AARCH32=y # end of Arch Configuration # @@ -36,14 +37,7 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_SERIAL=y - -# -# Usart Configuration -# -CONFIG_ENABLE_Pl011_UART=y -# end of Usart Configuration - +# CONFIG_USE_SERIAL is not set # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set # CONFIG_USE_ETH is not set @@ -79,8 +73,8 @@ CONFIG_LOG_INFO=y # # Linker Options # -# CONFIG_AARCH32_RAM_LD is not set -CONFIG_AARCH64_RAM_LD=y +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set # CONFIG_QEMU_AARCH32_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set CONFIG_LINK_SCRIPT_ROM=y @@ -90,15 +84,15 @@ CONFIG_LINK_SCRIPT_RAM=y CONFIG_RAM_START_UP_ADDR=0x81000000 CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=0x04000 -CONFIG_STACK_TOP_ADDR=0x82000000 +CONFIG_STACK_SIZE=0x1000 # end of Linker Options # end of Building Option # # Library Configuration # -# CONFIG_USE_G_LIBC is not set -CONFIG_USE_NEW_LIBC=y +CONFIG_USE_G_LIBC=y +# CONFIG_USE_NEW_LIBC is not set # end of Library Configuration # diff --git a/baremetal/example/newlibc_test/sdkconfig.h b/baremetal/example/newlibc_test/sdkconfig.h index f2d27dff5..df40c87c9 100644 --- a/baremetal/example/newlibc_test/sdkconfig.h +++ b/baremetal/example/newlibc_test/sdkconfig.h @@ -3,20 +3,21 @@ /* Project Configuration */ -#define CONFIG_TARGET_NAME "d2000_baremetal_a64" +#define CONFIG_TARGET_NAME "d2000_baremetal_a32" /* end of Project Configuration */ /* Platform Setting */ /* Arch Configuration */ -/* CONFIG_TARGET_ARMV8_AARCH32 is not set */ -#define CONFIG_TARGET_ARMV8_AARCH64 +#define CONFIG_TARGET_ARMV8_AARCH32 +/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ /* CONFIG_TARGET_ARMV7 is not set */ #define CONFIG_USE_CACHE #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU /* CONFIG_USE_SYS_TICK is not set */ +#define CONFIG_USE_AARCH64_L1_TO_AARCH32 /* end of Arch Configuration */ /* Board Configuration */ @@ -32,12 +33,7 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_EBABLE_GICV3 -#define CONFIG_USE_SERIAL - -/* Usart Configuration */ - -#define CONFIG_ENABLE_Pl011_UART -/* end of Usart Configuration */ +/* CONFIG_USE_SERIAL is not set */ /* CONFIG_USE_GPIO is not set */ /* CONFIG_USE_IOMUX is not set */ /* CONFIG_USE_ETH is not set */ @@ -68,8 +64,8 @@ /* Linker Options */ -/* CONFIG_AARCH32_RAM_LD is not set */ -#define CONFIG_AARCH64_RAM_LD +#define CONFIG_AARCH32_RAM_LD +/* CONFIG_AARCH64_RAM_LD is not set */ /* CONFIG_QEMU_AARCH32_RAM_LD is not set */ /* CONFIG_USER_DEFINED_LD is not set */ #define CONFIG_LINK_SCRIPT_ROM @@ -79,14 +75,14 @@ #define CONFIG_RAM_START_UP_ADDR 0x81000000 #define CONFIG_RAM_SIZE_MB 64 #define CONFIG_HEAP_SIZE 0x04000 -#define CONFIG_STACK_TOP_ADDR 0x82000000 +#define CONFIG_STACK_SIZE 0x1000 /* end of Linker Options */ /* end of Building Option */ /* Library Configuration */ -/* CONFIG_USE_G_LIBC is not set */ -#define CONFIG_USE_NEW_LIBC +#define CONFIG_USE_G_LIBC +/* CONFIG_USE_NEW_LIBC is not set */ /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/install.py b/install.py index 52f8f1c05..f8c359612 100755 --- a/install.py +++ b/install.py @@ -84,12 +84,10 @@ else: exit() # features for msys2 platform, windows platform do not support online -######################################### -if (install_platform == windows_msys2): - if (None == os.environ.get("PHYTIUM_DEV_PATH")): - print("[1]: Please set 'PHYTIUM_DEV_PATH' fisrt!!!") - exit() -######################################### +phytium_dev_path = os.environ.get("PHYTIUM_DEV_PATH") +if (None == phytium_dev_path): + print("[1]: Please set 'PHYTIUM_DEV_PATH' fisrt!!!") + exit() # create '/etc/profile.d/phytium_standalone_sdk.sh' need sudo right, ask user to create it first if not os.path.exists(sdk_profile_path): @@ -152,10 +150,19 @@ os.system("sed -i '/export PATH=\$PATH:\$AARCH64_CROSS_PATH/d' " + old_profile_p os.system("sed -i '/export STANDALONE_SDK_ROOT=/d' " + old_profile_path) os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING END/d' "+ old_profile_path) +# remove environment variables +os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING START/d' "+ sdk_profile_path) +os.system("sed -i '/export AARCH32_CROSS_PATH=/d' " + sdk_profile_path) +os.system("sed -i '/export PATH=\$PATH:\$AARCH32_CROSS_PATH/d' " + sdk_profile_path) +os.system("sed -i '/export AARCH64_CROSS_PATH=/d' " + sdk_profile_path) +os.system("sed -i '/export PATH=\$PATH:\$AARCH64_CROSS_PATH/d' " + sdk_profile_path) +os.system("sed -i '/export STANDALONE_SDK_ROOT=/d' " + sdk_profile_path) +os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING END/d' "+ sdk_profile_path) + print("[2]: Reset environment") ## STEP 3: get cross-platform compiler -cc_install_path = standalone_sdk_path + '/' + 'tools' + '/' +cc_install_path = phytium_dev_path + '/' + 'cross_tool' + '/' # set cc package name, download url and install dst dir if (install_platform == linux_x86): @@ -167,9 +174,6 @@ if (install_platform == linux_x86): aarch32_cc_pack = aarch32_cc + '.tar.xz' aarch64_cc_pack = aarch64_cc + '.tar.xz' - #aarch32_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776847/download/gcc-arm-x86_64-none-eabi-10-2020-q4-major.tar.xz' - #aarch64_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776846/download/gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11.tar.xz' - aarch32_cc_install_path = cc_install_path + aarch32_cc aarch64_cc_install_path = cc_install_path + aarch64_cc @@ -182,9 +186,6 @@ elif (install_platform == linux_aarch64): aarch32_cc_pack = aarch32_cc + '.tar.xz' aarch64_cc_pack = aarch64_cc + '.tar.xz' - # aarch32_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/779742/download/gcc-arm-aarch64-none-eabi-10-2020-q4-major.tar.xz' - # aarch64_cc_url = 'https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/779743/download/gcc-arm-10.2-2020.11-aarch64-aarch64-none-elf.tar.xz' - aarch32_cc_install_path = cc_install_path + aarch32_cc aarch64_cc_install_path = cc_install_path + aarch64_cc @@ -208,22 +209,12 @@ aarch32_cc_is_installed = os.path.exists(aarch32_cc_install_path) aarch64_cc_is_installed = os.path.exists(aarch64_cc_install_path) # cc download target -aarch32_cc_dl_dst = cc_install_path + aarch32_cc_pack -aarch64_cc_dl_dst = cc_install_path + aarch64_cc_pack +# aarch32_cc_dl_dst = cc_install_path + aarch32_cc_pack +# aarch64_cc_dl_dst = cc_install_path + aarch64_cc_pack + +aarch32_cc_dl_dst = phytium_dev_path + '/' + aarch32_cc_pack +aarch64_cc_dl_dst = phytium_dev_path + '/' + aarch64_cc_pack -# features for msys2 platform, copy cc package from DEV PATH to SDK PATH -######################################### -if (install_platform == windows_msys2) and (not os.path.exists(aarch32_cc_dl_dst)): - aarch32_cc_dev_path = os.environ.get('PHYTIUM_DEV_PATH') + '\\' + aarch32_cc_pack - if (os.path.exists(aarch32_cc_dev_path)): - print("[3] Copy AARCH32 CC from {}".format(aarch32_cc_dev_path)) - shutil.copy2(aarch32_cc_dev_path, aarch32_cc_dl_dst) - -if (install_platform == windows_msys2) and (not os.path.exists(aarch64_cc_dl_dst)): - aarch64_cc_dev_path = os.environ.get('PHYTIUM_DEV_PATH') + '\\' + aarch64_cc_pack - if (os.path.exists(aarch64_cc_dev_path)): - print("[3] Copy AARCH64 CC from {}".format(aarch32_cc_dev_path)) - shutil.copy2(aarch64_cc_dev_path, aarch64_cc_dl_dst) ######################################### if not os.path.exists(aarch32_cc_dl_dst): print("[3]: Failed, AARCH32 CC package {} non found !!!".format(aarch32_cc_dl_dst)) diff --git a/make/ld/Kconfig b/make/ld/Kconfig index 4f265b7f7..b831ac842 100644 --- a/make/ld/Kconfig +++ b/make/ld/Kconfig @@ -82,7 +82,7 @@ menu "Linker Options" config HEAP_SIZE hex "Heap Size" - default "0x0400" + default "0x04000" help Assign Heap size in Linkscript diff --git a/run_mingw64.cmd b/run_mingw64.cmd deleted file mode 100644 index 409e4e512..000000000 --- a/run_mingw64.cmd +++ /dev/null @@ -1,2 +0,0 @@ -%PHYTIUM_DEV_PATH%\msys64\msys2_shell.cmd -where %CD% -msys2 -shell bash -pause \ No newline at end of file diff --git a/run_tftd.cmd b/run_tftd.cmd deleted file mode 100644 index 73d5e6fe2..000000000 --- a/run_tftd.cmd +++ /dev/null @@ -1,2 +0,0 @@ -%PHYTIUM_DEV_PATH%\tftp\tftpd64_gui.exe -pause \ No newline at end of file diff --git a/scripts/update_dev_path.sh b/scripts/update_dev_path.sh new file mode 100644 index 000000000..f045819d1 --- /dev/null +++ b/scripts/update_dev_path.sh @@ -0,0 +1,27 @@ +### + # @ : Copyright (c) 2021 Phytium Information Technology, Inc. + # + # SPDX-License-Identifier: Apache-2.0. + # + # @Date: 2021-10-19 08:10:14 + # @LastEditTime: 2021-10-19 08:29:14 + # @Description:  This files is for + # + # @Modify History: + # Ver   Who        Date         Changes + # ----- ------     --------    -------------------------------------- +### +# 指定sdk profle文件 +export sdk_profile=/etc/profile.d/phytium_standalone_sdk.sh +# 检查sdk profile文件是否存在 +ls $sdk_profile -l +# 删除profile文件可能存在的DEV目录 +sudo sed -i "/export PHYTIUM_DEV_PATH=/d" $sdk_profile +# 将PHYTIUM_DEV_PATH记录在Profile中 +echo "export PHYTIUM_DEV_PATH=/mnt/d/phytium-dev" >> $sdk_profile +# 检查DEV目录环境变量是否已定义 +cat $sdk_profile | grep PHYTIUM_DEV_PATH +# 在当前控制台窗口中生效PHYTIUM_DEV_PATH +source $sdk_profile +# 检查DEV目录 +echo $PHYTIUM_DEV_PATH \ No newline at end of file -- Gitee From d166d60cf2d7597f70f672157a3f9c9577e12717 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 02:05:17 +0000 Subject: [PATCH 06/21] update README.md. --- README.md | 98 ++++++++++++++++--------------------------------------- 1 file changed, 29 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 95f820ca2..94b301da0 100644 --- a/README.md +++ b/README.md @@ -14,94 +14,54 @@ ## 2. 安装方法 -### 2.1 SDK使用支持的平台 +### 2.1 获取SDK的开发环境 - Windows10 -- Ubuntu 20.04 x86_64 -- Kylis OS aarch64 - -### 2.2 配置SDK的DEV目录 - -- 创建一个目录,并将目录记录在环境变量`$PHYTIUM_DEV_PATH`中,用于后续放置交叉编译链等工具, -- 具体步骤安装开发平台参考以下配置流程 - -#### 2.2.1 Windows 10 环境配置 - -- Windows10下使用SDK依赖Msys2, 推荐使用Portable的Msys2, 也可以参考配置Msys2环境 -- (1). 从以下链接下载**Windows开发环境压缩包**,然后解压,创建DEV目录,如`d:\phytium-dev` - -[下载链接](https://pan.baidu.com/s/1rF0fh4RwgiIpuTI0pk47xg) -> 提取码:MGW6 - -- (2). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),指向文件夹`D:\PHYTIUM-DEV`(可以自定义) - -![配置环境变量](https://images.gitee.com/uploads/images/2021/1013/164551_934da3d7_8736513.png "配置环境变量.png") +- Ubuntu 20.04 x86_64 +![linux-x86_64](https://images.gitee.com/uploads/images/2021/1019/095533_a960e2a6_8736513.png "linux-x86_64.png") -- (3). 双击脚本`run_mingw64.cmd`, 进入mingw64控制台, 创建SDK的profile文件, 并添加读写权限 -``` -touch /etc/profile.d/phytium_standalone_sdk.sh -chmod 666 /etc/profile.d/phytium_standalone_sdk.sh -``` +- Ubuntu/Kylis OS aarch64 -#### 2.2.2 Kylin OS/Ubuntu 20.04 环境配置 -- (1). 创建DEV目录,如`~/phytium-dev`, 从以下链接下载交叉编译链,放置在DEV目录下 +Q:如何解压SDK开发环境压缩包 +> Windows环境下可以用通用的unzip工具解压,如7zip和winrar -- (2). 打开控制台,以管理员权限创建SDK的Profile文件,/etc/profile.d/phytium_standalone_sdk.sh(文件和路径不能自定义),并给与非sudo用户读写权限 -```shell -sudo touch /etc/profile.d/phytium_standalone_sdk.sh -sudo chmod 666 /etc/profile.d/phytium_standalone_sdk.sh -``` +> Linux/KylinOS环境下可以用unzip命令解压 -- (3). 更新DEV目录,记录在环境变量`PHYTIUM_DEV_PATH`中,保存在SDK的Profile文件中 -```shell -# 指定sdk profle文件 -export sdk_profile=/etc/profile.d/phytium_standalone_sdk.sh -# 检查sdk profile文件是否存在 -ls $sdk_profile -l -# 删除profile文件可能存在的DEV目录 -sudo sed -i "/export PHYTIUM_DEV_PATH=/d" $sdk_profile -# 将PHYTIUM_DEV_PATH记录在Profile中 -echo "export PHYTIUM_DEV_PATH=/mnt/d/phytium-dev" >> $sdk_profile -# 检查DEV目录环境变量是否已定义 -cat $sdk_profile | grep PHYTIUM_DEV_PATH -# 在当前控制台窗口中生效PHYTIUM_DEV_PATH -source $sdk_profile -# 检查DEV目录 -echo $PHYTIUM_DEV_PATH -``` +### 2.2 配置SDK开发环境(DEV目录) -### 2.3 获取交叉编译工具链 +- 创建DEV目录,并将DEV目录记录在环境变量`$PHYTIUM_DEV_PATH`中,用于后续放置交叉编译链等工具, +- 具体步骤安装开发平台参考以下配置流程 -- 交叉编译链工具需要更加开发平台下载,放置在DEV目录下,后续由SDK安装脚本处理安装 +#### 2.2.1 Windows 10 DEV目录配置 -> 注意不要修改交叉编译工具压缩包的名字,名字包含了版本和平台信息 +- Windows10下使用SDK依赖Msys2, 推荐使用2.1章提供的开发环境, 也可以参考2.5章手动安装Msys2 +- (1). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),指向文件夹`D:\PHYTIUM-DEV`(可以自定义) -> 注意交叉编译工具压缩包需要放置在`PHYTIUM_DEV_PATH`目录下,否则SDK安装脚本无法处理 +![配置环境变量](https://images.gitee.com/uploads/images/2021/1013/164551_934da3d7_8736513.png "配置环境变量.png") -#### 2.3.1 Windows 10 Mingw64 交叉编译链 +- (2). 进入DEV目录,双击脚本`run_msys2.cmd`, 进入msys2控制台, 运行`source ./update_sdk_dev_path.sh`设置注册DEV目录 -[Mingw64交叉编译链](https://pan.baidu.com/s/1nSeePtYsj4xFPEhMKwt0cg) -> 提取码:MGW6 +![设置DEV环境](https://images.gitee.com/uploads/images/2021/1019/090857_befcab03_8736513.png "设置DEV环境.png") -#### 2.3.2 Linux x86_64 交叉编译链 +#### 2.2.2 Kylin OS/Ubuntu 20.04 DEV目录配置 -[Linux x86_64交叉编译链](https://pan.baidu.com/s/1K03OKOjHLq4ktBiaC5HVRw) -> 提取码:LX64 +- (1). 解压开发环境压缩包,形成DEV目录 -#### 2.3.3 Linux aarch64 交叉编译链 +- (2). 进入DEV目录,运行`source ./update_sdk_dev_path.sh`,注册DEV目录 -[Linux aarch64交叉编译链](https://pan.baidu.com/s/1rqfttxdv9yxKCSg5K2Yrsg) -> 提取码:LA64 +![注册DEV目录](https://images.gitee.com/uploads/images/2021/1019/100230_01b3ef6d_8736513.png "注册DEV目录.png") -### 2.4 获取SDK并完成安装 +### 2.3 获取并完成SDK安装(SDK目录) -- (1). 通过 Gitee 拉取 Standalone SDK 源代码到DEV目录下 -> 对于Windows 10平台,2.1.1章节的开发环境压缩包中通过Mingw64控制台提供了git工具 +- (1). 通过 git工具 拉取 Standalone SDK 源代码到DEV目录下 +> 对于Windows 10平台,2.1.1章节的开发环境压缩包中通过msys2控制台提供了git工具 > 对于Linux/KylinOS平台,可以通过`sudo apt-get install build-essential`安装git等工具 +![拉取SDK源码](https://images.gitee.com/uploads/images/2021/1019/091126_ccd0dc0c_8736513.png "拉取SDK源码.png") + ``` $ git clone https://gitee.com/phytium_embedded/phytium-standalone-sdk.git ./phytium-standalone-sdk @@ -112,7 +72,7 @@ $ cd ./phytium-standalone-sdk - (3). **安装完成后重启系统,生效 Standalone SDK 环境**, 检查SDK路径是否与环境变量`STANDALONE_SDK_ROOT`一致 -### 2.5 Windows 10安装Msys2 +### 2.4 Windows 10安装Msys2 - (1). 获取[Windows环境安装包](https://pan.baidu.com/s/17WX5hec7t8_ubAKzFCwQAA) @@ -176,11 +136,11 @@ $ pacman -S base-devel git python3 python3-pip $ pacman -Q make git wget python3 python3-pip ``` -### 2.6 卸载开发环境 +### 2.5 卸载开发环境 -- 在SDK目录`D:\phytium-dev\phytium-standalone-sdk`目录双击`run_mingw64.cmd`, 启动`Msys2`控制台,在控制台输入`./uninstall.py`完成SDK卸载 +- 在DEV目录下双击`run_msys2.cmd`, 启动`Msys2`控制台,在控制台输入`./uninstall.py`完成SDK卸载 -- 在`Msys2`控制台运行`sudo rm /etc/profile.d/phytium_standalone_sdk.sh`,删除SDK配置文件 +- 在`Msys2`控制台运行`rm /etc/profile.d/phytium_standalone_sdk.sh`,删除SDK配置文件 - 在DEV目录`D:\phytium-dev\tftp`下以**管理员权限**打开Windows命令行中断,运行`uninstall.cmd`完成Tftd卸载 -- Gitee From 6de5e7dcf2587431a9d0b28b1f2a5f646a7ee0df Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 02:12:07 +0000 Subject: [PATCH 07/21] update README.md. --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 94b301da0..0cfcf4595 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,19 @@ ## 2. 安装方法 -### 2.1 获取SDK的开发环境 +### 2.1 获取SDK的开发环境 (DEV压缩包) -- Windows10 +- [Windows10](https://pan.baidu.com/s/16d8NSPn2KY78G5KLwFDpxw) +>提取码:WIX6 -- Ubuntu 20.04 x86_64 +- [Ubuntu 20.04 x86_64](https://pan.baidu.com/s/1Hci3gttdCvNpKRc3oRTX3Q ) +>提取码:LX64 ![linux-x86_64](https://images.gitee.com/uploads/images/2021/1019/095533_a960e2a6_8736513.png "linux-x86_64.png") -- Ubuntu/Kylis OS aarch64 +- [Ubuntu/Kylis OS aarch64](https://pan.baidu.com/s/11zIN0Z6TyZG32h_3YpSARw ) +>提取码:LA64 +![linux-aarch64](https://images.gitee.com/uploads/images/2021/1019/101040_ff6c194e_8736513.png "linux-aarch64.png") Q:如何解压SDK开发环境压缩包 > Windows环境下可以用通用的unzip工具解压,如7zip和winrar @@ -36,7 +40,7 @@ Q:如何解压SDK开发环境压缩包 #### 2.2.1 Windows 10 DEV目录配置 -- Windows10下使用SDK依赖Msys2, 推荐使用2.1章提供的开发环境, 也可以参考2.5章手动安装Msys2 +- Windows10下使用SDK依赖Msys2, 推荐使用2.1章提供的开发环境, 也可以参考2.4章手动安装Msys2 - (1). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),指向文件夹`D:\PHYTIUM-DEV`(可以自定义) ![配置环境变量](https://images.gitee.com/uploads/images/2021/1013/164551_934da3d7_8736513.png "配置环境变量.png") @@ -68,11 +72,11 @@ $ git clone https://gitee.com/phytium_embedded/phytium-standalone-sdk.git $ cd ./phytium-standalone-sdk ``` -- (2). 运行`install.py`完成SDK安装 +- (2). 运行`install.py`完成SDK安装 - (3). **安装完成后重启系统,生效 Standalone SDK 环境**, 检查SDK路径是否与环境变量`STANDALONE_SDK_ROOT`一致 -### 2.4 Windows 10安装Msys2 +### 2.4 Windows 10安装Msys2(可选) - (1). 获取[Windows环境安装包](https://pan.baidu.com/s/17WX5hec7t8_ubAKzFCwQAA) -- Gitee From 02ca8fc8abae5c18d6609a9855b2a94509f02863 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 02:44:42 +0000 Subject: [PATCH 08/21] update README.md. --- README.md | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 0cfcf4595..863792cc1 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ ### 2.1 获取SDK的开发环境 (DEV压缩包) +- 按照不同开发平台获取DEV压缩包 + - [Windows10](https://pan.baidu.com/s/16d8NSPn2KY78G5KLwFDpxw) >提取码:WIX6 @@ -33,50 +35,28 @@ Q:如何解压SDK开发环境压缩包 > Linux/KylinOS环境下可以用unzip命令解压 -### 2.2 配置SDK开发环境(DEV目录) +### 2.2 安装SDK开发环境 -- 创建DEV目录,并将DEV目录记录在环境变量`$PHYTIUM_DEV_PATH`中,用于后续放置交叉编译链等工具, -- 具体步骤安装开发平台参考以下配置流程 +> 对于Windows 10平台,2.1.1章节的开发环境压缩包中通过msys2控制台提供了git工具 -#### 2.2.1 Windows 10 DEV目录配置 +> 对于Linux/KylinOS平台,可以通过`sudo apt-get install build-essential`安装git等工具 -- Windows10下使用SDK依赖Msys2, 推荐使用2.1章提供的开发环境, 也可以参考2.4章手动安装Msys2 +#### 2.2.1 Windows 10 + +- Windows10下使用SDK依赖Msys2, 推荐使用2.1章提供的开发环境, 也可以参考2.3章手动安装Msys2 - (1). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),指向文件夹`D:\PHYTIUM-DEV`(可以自定义) ![配置环境变量](https://images.gitee.com/uploads/images/2021/1013/164551_934da3d7_8736513.png "配置环境变量.png") -- (2). 进入DEV目录,双击脚本`run_msys2.cmd`, 进入msys2控制台, 运行`source ./update_sdk_dev_path.sh`设置注册DEV目录 - -![设置DEV环境](https://images.gitee.com/uploads/images/2021/1019/090857_befcab03_8736513.png "设置DEV环境.png") +- (2). 进入DEV目录,双击脚本`run_msys2.cmd`, 进入msys2控制台, 运行`source ./update_sdk_dev.sh`,安装开发环境 -#### 2.2.2 Kylin OS/Ubuntu 20.04 DEV目录配置 +#### 2.2.2 Kylin OS/Ubuntu 20.04 - (1). 解压开发环境压缩包,形成DEV目录 -- (2). 进入DEV目录,运行`source ./update_sdk_dev_path.sh`,注册DEV目录 - -![注册DEV目录](https://images.gitee.com/uploads/images/2021/1019/100230_01b3ef6d_8736513.png "注册DEV目录.png") - -### 2.3 获取并完成SDK安装(SDK目录) - -- (1). 通过 git工具 拉取 Standalone SDK 源代码到DEV目录下 -> 对于Windows 10平台,2.1.1章节的开发环境压缩包中通过msys2控制台提供了git工具 - -> 对于Linux/KylinOS平台,可以通过`sudo apt-get install build-essential`安装git等工具 - -![拉取SDK源码](https://images.gitee.com/uploads/images/2021/1019/091126_ccd0dc0c_8736513.png "拉取SDK源码.png") - -``` -$ git clone https://gitee.com/phytium_embedded/phytium-standalone-sdk.git - ./phytium-standalone-sdk -$ cd ./phytium-standalone-sdk -``` - -- (2). 运行`install.py`完成SDK安装 - -- (3). **安装完成后重启系统,生效 Standalone SDK 环境**, 检查SDK路径是否与环境变量`STANDALONE_SDK_ROOT`一致 +- (2). 进入DEV目录,运行`source ./update_sdk_dev.sh`,安装开发环境 -### 2.4 Windows 10安装Msys2(可选) +### 2.3 Windows 10安装Msys2(可选) - (1). 获取[Windows环境安装包](https://pan.baidu.com/s/17WX5hec7t8_ubAKzFCwQAA) -- Gitee From 4caa170c27e83da3fe43412ac233abef9f72007e Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 03:17:14 +0000 Subject: [PATCH 09/21] update README.md. --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 863792cc1..75118caec 100644 --- a/README.md +++ b/README.md @@ -44,18 +44,40 @@ Q:如何解压SDK开发环境压缩包 #### 2.2.1 Windows 10 - Windows10下使用SDK依赖Msys2, 推荐使用2.1章提供的开发环境, 也可以参考2.3章手动安装Msys2 -- (1). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),指向文件夹`D:\PHYTIUM-DEV`(可以自定义) +- (1). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),例如,指向文件夹`E:\phytium-dev-windows-nt`(可以自定义) -![配置环境变量](https://images.gitee.com/uploads/images/2021/1013/164551_934da3d7_8736513.png "配置环境变量.png") +![配置环境变量](https://images.gitee.com/uploads/images/2021/1019/105259_18e64169_8736513.png "配置环境变量.png") - (2). 进入DEV目录,双击脚本`run_msys2.cmd`, 进入msys2控制台, 运行`source ./update_sdk_dev.sh`,安装开发环境 +![安装开发环境](https://images.gitee.com/uploads/images/2021/1019/105848_f49f8f72_8736513.png "安装开发环境.png") + +![开发环境安装完成](https://images.gitee.com/uploads/images/2021/1019/110311_eeb15589_8736513.png "开发环境安装完成.png") + #### 2.2.2 Kylin OS/Ubuntu 20.04 - (1). 解压开发环境压缩包,形成DEV目录 +![解压DEV](https://images.gitee.com/uploads/images/2021/1019/110732_609695c3_8736513.png "解压DEV.png") + - (2). 进入DEV目录,运行`source ./update_sdk_dev.sh`,安装开发环境 +![安装开发环境](https://images.gitee.com/uploads/images/2021/1019/110951_4ce01ea1_8736513.png "安装开发环境.png") + +![安装完成](https://images.gitee.com/uploads/images/2021/1019/111228_e0c5ea48_8736513.png "安装完成.png") + +#### 2.2.3 检查安装是否成功 + +- 打印下列环境变量,观察各变量是否存在,指向的目录是否正确 +> `PHYTIUM_DEV_PATH`指向DEV目录 +> `STANDALONE_SDK_ROOT`指向SDK源文件目录 +> `AARCH32_CROSS_PATH`指向32位交叉编译链目录 +> `AARCH64_CROSS_PATH`指向64位交叉编译链目录 +``` +echo $PHYTIUM_DEV_PATH $STANDALONE_SDK_ROOT $AARCH32_CROSS_PATH $AARCH64_CROSS_PATH +``` +![检查环境变量](https://images.gitee.com/uploads/images/2021/1019/111414_f7639144_8736513.png "检查环境变量.png") + ### 2.3 Windows 10安装Msys2(可选) - (1). 获取[Windows环境安装包](https://pan.baidu.com/s/17WX5hec7t8_ubAKzFCwQAA) -- Gitee From af80fb204bbf0b3010a6999d19d500b2505aefcb Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 03:21:02 +0000 Subject: [PATCH 10/21] update README.md. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 75118caec..4e97abf59 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,13 @@ Q:如何解压SDK开发环境压缩包 - 打印下列环境变量,观察各变量是否存在,指向的目录是否正确 > `PHYTIUM_DEV_PATH`指向DEV目录 + > `STANDALONE_SDK_ROOT`指向SDK源文件目录 + > `AARCH32_CROSS_PATH`指向32位交叉编译链目录 + > `AARCH64_CROSS_PATH`指向64位交叉编译链目录 + ``` echo $PHYTIUM_DEV_PATH $STANDALONE_SDK_ROOT $AARCH32_CROSS_PATH $AARCH64_CROSS_PATH ``` -- Gitee From a628ab237c63e7343db5d5500e37aa461ff5ff25 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 11:23:14 +0800 Subject: [PATCH 11/21] windows path --- install.py | 1 + 1 file changed, 1 insertion(+) diff --git a/install.py b/install.py index f8c359612..e1296d2b1 100755 --- a/install.py +++ b/install.py @@ -85,6 +85,7 @@ else: # features for msys2 platform, windows platform do not support online phytium_dev_path = os.environ.get("PHYTIUM_DEV_PATH") +phytium_dev_path = '/'.join(phytium_dev_path.split('\\')) if (None == phytium_dev_path): print("[1]: Please set 'PHYTIUM_DEV_PATH' fisrt!!!") exit() -- Gitee From 7a701631ca9aad1d2561c2259bd04bfc65445b54 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 11:30:32 +0800 Subject: [PATCH 12/21] remove unused projects --- baremetal/example/libc_port/README.md | 53 ------ baremetal/example/libc_port/glibc.sh | 27 --- baremetal/example/libc_port/newlibc.sh | 38 ---- baremetal/example/libc_port/run.sh | 19 -- baremetal/example/libc_port/startup.s | 93 ---------- baremetal/example/libc_port/syscalls.c | 119 ------------ baremetal/example/libc_port/test.c | 59 ------ baremetal/example/libc_port/test.ld | 56 ------ baremetal/example/qemu_libc_test/build.sh | 28 --- baremetal/example/qemu_libc_test/clean.sh | 14 -- baremetal/example/qemu_libc_test/link.ld | 67 ------- baremetal/example/qemu_libc_test/main.c | 78 -------- baremetal/example/qemu_libc_test/run.sh | 19 -- baremetal/example/qemu_libc_test/start.S | 172 ------------------ baremetal/example/qemu_libc_test/syscalls.c | 119 ------------ baremetal/example/qemu_test/build.sh | 21 --- baremetal/example/qemu_test/clean.sh | 14 -- baremetal/example/qemu_test/link.ld | 61 ------- baremetal/example/qemu_test/main.c | 46 ----- baremetal/example/qemu_test/run.sh | 19 -- baremetal/example/qemu_test/start.S | 172 ------------------ baremetal/example/qemu_test/start.S.old | 192 -------------------- 22 files changed, 1486 deletions(-) delete mode 100644 baremetal/example/libc_port/README.md delete mode 100644 baremetal/example/libc_port/glibc.sh delete mode 100644 baremetal/example/libc_port/newlibc.sh delete mode 100644 baremetal/example/libc_port/run.sh delete mode 100644 baremetal/example/libc_port/startup.s delete mode 100644 baremetal/example/libc_port/syscalls.c delete mode 100644 baremetal/example/libc_port/test.c delete mode 100644 baremetal/example/libc_port/test.ld delete mode 100644 baremetal/example/qemu_libc_test/build.sh delete mode 100644 baremetal/example/qemu_libc_test/clean.sh delete mode 100644 baremetal/example/qemu_libc_test/link.ld delete mode 100644 baremetal/example/qemu_libc_test/main.c delete mode 100644 baremetal/example/qemu_libc_test/run.sh delete mode 100644 baremetal/example/qemu_libc_test/start.S delete mode 100644 baremetal/example/qemu_libc_test/syscalls.c delete mode 100644 baremetal/example/qemu_test/build.sh delete mode 100644 baremetal/example/qemu_test/clean.sh delete mode 100644 baremetal/example/qemu_test/link.ld delete mode 100644 baremetal/example/qemu_test/main.c delete mode 100644 baremetal/example/qemu_test/run.sh delete mode 100644 baremetal/example/qemu_test/start.S delete mode 100644 baremetal/example/qemu_test/start.S.old diff --git a/baremetal/example/libc_port/README.md b/baremetal/example/libc_port/README.md deleted file mode 100644 index 1056e6000..000000000 --- a/baremetal/example/libc_port/README.md +++ /dev/null @@ -1,53 +0,0 @@ - - -- https://sourceware.org/newlib/ftp/ -- get newlib source code -``` -wget ftp://sourceware.org/pub/newlib/newlib-4.1.0.tar.gz -tar xzf newlib-4.1.0.tar.gz -cd newlib-4.1.0/ -./configure --target arm-none-eabi --disable-newlib-supplied-syscalls -make -cd .. -``` - -``` -wget ftp://sourceware.org/pub/newlib/newlib-4.1.0.tar.gz -tar xzf newlib-4.1.0.tar.gz -cd newlib-4.1.0/ -./configure --target aarch64-none-elf --disable-newlib-supplied-syscalls -make -cd .. -``` - -- compile the program with the Glib -``` -arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o test.o test.c -arm-none-eabi-as -mcpu=cortex-a8 -o startup.o startup.s -arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o syscalls.o syscalls.c -arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o $AARCH32_CROSS_PATH/arm-none-eabi/lib/thumb/v7/nofp/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.3.1/libgcc.a -o test -arm-none-eabi-objcopy -O binary test test.bin -qemu-system-arm -M realview-pb-a8 -serial stdio -kernel test.bin -``` - -- compile the program with the Newlib -``` -arm-none-eabi-gcc -mcpu=cortex-a8 -I ./newlib-4.1.0/newlib/libc/include -c -o test.o test.c -arm-none-eabi-as -mcpu=cortex-a8 -o startup.o startup.s -arm-none-eabi-gcc -mcpu=cortex-a8 -I ./newlib-4.1.0/newlib/libc/include -c -o syscalls.o syscalls.c -arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o ./newlib-4.1.0/arm-none-eabi/newlib/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.3.1/libgcc.a -o test -arm-none-eabi-objcopy -O binary test test.bin -qemu-system-arm -M realview-pb-a8 -serial stdio -kernel test.bin -``` \ No newline at end of file diff --git a/baremetal/example/libc_port/glibc.sh b/baremetal/example/libc_port/glibc.sh deleted file mode 100644 index ef75f8b19..000000000 --- a/baremetal/example/libc_port/glibc.sh +++ /dev/null @@ -1,27 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-10-15 11:31:43 - # @LastEditTime: 2021-10-15 11:45:37 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### -echo "compiling test.c" -arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o test.o test.c -echo "compiling startup.s" -arm-none-eabi-as -mcpu=cortex-a8 -o startup.o startup.s -echo "compiling syscalls.s" -arm-none-eabi-gcc -mcpu=cortex-a8 -I $AARCH32_CROSS_PATH/arm-none-eabi/include -c -o syscalls.o syscalls.c -echo "linking" -arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o $AARCH32_CROSS_PATH/arm-none-eabi/lib/thumb/v7/nofp/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.3.1/libgcc.a -o test -echo "objcopying" -arm-none-eabi-objcopy -O binary test test.bin -echo "running" -#$PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -M realview-pb-a8 -serial stdio -kernel test.bin -$PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -machine vexpress-a9 -m 1024M \ - -serial stdio -kernel test.bin diff --git a/baremetal/example/libc_port/newlibc.sh b/baremetal/example/libc_port/newlibc.sh deleted file mode 100644 index a2db701c9..000000000 --- a/baremetal/example/libc_port/newlibc.sh +++ /dev/null @@ -1,38 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-10-15 11:31:43 - # @LastEditTime: 2021-10-15 14:44:38 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### -# echo "compiling test.c" -# arm-none-eabi-gcc -mcpu=cortex-a8 -I ./newlib-4.1.0/newlib/libc/include -c -o test.o test.c -# echo "compiling syscalls.s" -# arm-none-eabi-as -mcpu=cortex-a8 -o startup.o startup.s -# echo "compiling startup.s" -# arm-none-eabi-gcc -mcpu=cortex-a8 -I ./newlib-4.1.0/newlib/libc/include -c -o syscalls.o syscalls.c -# echo "linking" -# arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o ./newlib-4.1.0/arm-none-eabi/newlib/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.2.1/libgcc.a -o test -# echo "objcopying" -# arm-none-eabi-objcopy -O binary test test.bin - -echo "compiling startup.s" -arm-none-eabi-as -o startup.o startup.s - -echo "compiling test.c" -arm-none-eabi-gcc -I ./newlib-4.1.0/newlib/libc/include -c -nostdlib -nostartfiles -o test.o test.c - -echo "compiling syscalls.c" -arm-none-eabi-gcc -I ./newlib-4.1.0/newlib/libc/include -c -nostdlib -nostartfiles -o syscalls.o syscalls.c - -echo "linking" -arm-none-eabi-gcc -nostdlib -T test.ld test.o startup.o syscalls.o ./newlib-4.1.0/arm-none-eabi/newlib/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.2.1/libgcc.a -o test - -echo "objcopying" -arm-none-eabi-objcopy -O binary test test.bin \ No newline at end of file diff --git a/baremetal/example/libc_port/run.sh b/baremetal/example/libc_port/run.sh deleted file mode 100644 index 57c695048..000000000 --- a/baremetal/example/libc_port/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-10-15 14:13:51 - # @LastEditTime: 2021-10-15 15:10:14 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### -echo "running" -# $PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -machine vexpress-a9 -m 1024M \ -# -serial stdio -kernel test.bin - -qemu-system-arm -M vexpress-a9 -kernel test.bin -nographic -#qemu-system-arm -machine vexpress-a9 -m 1024M -serial stdio -kernel test.bin \ No newline at end of file diff --git a/baremetal/example/libc_port/startup.s b/baremetal/example/libc_port/startup.s deleted file mode 100644 index 0d6936758..000000000 --- a/baremetal/example/libc_port/startup.s +++ /dev/null @@ -1,93 +0,0 @@ -/* Some defines */ -.equ MODE_FIQ, 0x11 -.equ MODE_IRQ, 0x12 -.equ MODE_SVC, 0x13 - -.section .vector_table, "x" -.global _Reset -.global _start -_Reset: - b Reset_Handler - b Abort_Exception /* 0x4 Undefined Instruction */ - b . /* 0x8 Software Interrupt */ - b Abort_Exception /* 0xC Prefetch Abort */ - b Abort_Exception /* 0x10 Data Abort */ - b . /* 0x14 Reserved */ - b . /* 0x18 IRQ */ - b . /* 0x1C FIQ */ - -.section .text /* The code segment, RD, program’s executable code */ -Reset_Handler: - bl early_print - /* FIQ stack */ - /* Current Program Status Register, - change cpsr without affacting the - condition flags */ - msr cpsr_c, MODE_FIQ /* switch the processor to FIQ mode */ - ldr r1, =_fiq_stack_start /* load start address into R1 */ - ldr sp, =_fiq_stack_end /* load the end address of the FIQ stack into SP */ - movw r0, #0xFEFE - movt r0, #0xFEFE /* corresponds to loading x << 16 | y into r0 */ - -/* This is the loop that actually fills the stack with 0xFEFEFEFE */ -fiq_loop: - cmp r1, sp /* compares the value in R1 to the value in SP */ - strlt r0, [r1], #4 /* If R1 is less than SP, - the value in R0 will be written to the - address stored in R1, - and R1 gets increased by 4 */ - blt fiq_loop /* the loop continues as long as R1 is less than SP */ - - /* IRQ stack */ - msr cpsr_c, MODE_IRQ - ldr r1, =_irq_stack_start - ldr sp, =_irq_stack_end - -/* fill irq stack */ -irq_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt irq_loop - - /* Supervisor mode */ - msr cpsr_c, MODE_SVC - ldr r1, =_stack_start - ldr sp, =_stack_end - -/* fill the supervisor mode stack */ -stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt stack_loop - - /* Start copying data */ - ldr r0, =_text_end /* section address has been defined in ld script */ - ldr r1, =_data_start - ldr r2, =_data_end - -/* loop continues over the entirety of .data in ROM */ -data_loop: - cmp r1, r2 - ldrlt r3, [r0], #4 /* t load 4 bytes of data from ROM into R3 */ - strlt r3, [r1], #4 - blt data_loop - - /* Initialize .bss */ - mov r0, #0 - ldr r1, =_bss_start - ldr r2, =_bss_end - -/* loop over memory between the addresses _bss_start and _bss_end */ -/* there is no ROM address, and zeros just take up space */ -bss_loop: - cmp r1, r2 - strlt r0, [r1], #4 - blt bss_loop - - bl early_print - bl c_entry /* continue running in case the main function */ - b Abort_Exception /* indicate an error, never execute when main contains infinite loop */ - -Abort_Exception: - swi 0xFF - diff --git a/baremetal/example/libc_port/syscalls.c b/baremetal/example/libc_port/syscalls.c deleted file mode 100644 index 7d37a0d1c..000000000 --- a/baremetal/example/libc_port/syscalls.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. - * - * SPDX-License-Identifier: Apache-2.0. - * - * @Date: 2021-10-15 09:53:06 - * @LastEditTime: 2021-10-15 14:11:58 - * @Description:  This files is for - * - * @Modify History: - * Ver   Who        Date         Changes - * ----- ------     --------    -------------------------------------- - */ - -#include - -enum { - UART_FR_RXFE = 0x10, - UART_FR_TXFF = 0x20, - UART0_ADDR = 0x10009000, -}; - -#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr)) -#define UART_FR(baseaddr) (*(((unsigned int *)(baseaddr))+6)) - -int _close(int file) -{ - return -1; -} - -int _fstat(int file, struct stat* st) -{ - st->st_mode = S_IFCHR; - return 0; -} - -int _isatty(int file) -{ - return 1; -} - -int _lseek(int file, int ptr, int dir) -{ - return 0; -} - -int _open(const char* name, int flags, int mode) -{ - return -1; -} - -int _read(int file, char* ptr, int len) -{ - int todo; - - if (len == 0) { - return 0; - } - - while (UART_FR(UART0_ADDR) & UART_FR_RXFE); - - *ptr++ = UART_DR(UART0_ADDR); - - for (todo = 1; todo < len; todo++) { - if (UART_FR(UART0_ADDR) & UART_FR_RXFE) { - break; - } - - *ptr++ = UART_DR(UART0_ADDR); - } - - return todo; -} - -char* heap_end = 0; -caddr_t _sbrk(int incr) -{ - extern char heap_low; /* Defined by the linker */ - extern char heap_top; /* Defined by the linker */ - char* prev_heap_end; - - if (heap_end == 0) { - heap_end = &heap_low; - } - - prev_heap_end = heap_end; - - if (heap_end + incr > &heap_top) { - /* Heap and stack collision */ - return (caddr_t)0; - } - - heap_end += incr; - return (caddr_t) prev_heap_end; -} - -int _write(int file, char* ptr, int len) -{ - int todo; - - for (todo = 0; todo < len; todo++) { - UART_DR(UART0_ADDR) = *ptr++; - } - - return len; -} - -void _kill(int pid, int sig) { - return; -} - -int _getpid(void) { - return -1; -} - -void abort(void) -{ - return; -} \ No newline at end of file diff --git a/baremetal/example/libc_port/test.c b/baremetal/example/libc_port/test.c deleted file mode 100644 index 3485f6d84..000000000 --- a/baremetal/example/libc_port/test.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. - * - * SPDX-License-Identifier: Apache-2.0. - * - * @Date: 2021-10-15 09:42:15 - * @LastEditTime: 2021-10-15 14:38:04 - * @Description:  This files is for - * - * @Modify History: - * Ver   Who        Date         Changes - * ----- ------     --------    -------------------------------------- - */ -#include -#include -#include - -extern char* heap_end; /* Defined in syscalls.c */ - -volatile uint8_t* uart0 = (uint8_t*)0x10009000; /* ctrl register */ -/* writing a UART driver */ -void write(const char* str) -{ - while (*str) { - *uart0 = *str++; - } -} - -void early_print() -{ - write("zhugengyu something...\n"); -} - -void c_entry() -{ - char c; - char* ptr = NULL; - size_t alloc_size = 1; - - early_print(); - do - { - c = getchar(); - printf("%d: %c\n", c, c); - - ptr = realloc(ptr, alloc_size); - - if (ptr == NULL) { - puts("Out of memory!\nProgram halting."); - - for (;;); - } else { - printf("new alloc of %d bytes at address 0x%X\n", alloc_size, - (unsigned int)ptr); - alloc_size <<= 1; - printf("Heap end = 0x%X\n", (unsigned int)heap_end); - } - } while (1); -} \ No newline at end of file diff --git a/baremetal/example/libc_port/test.ld b/baremetal/example/libc_port/test.ld deleted file mode 100644 index 00d07578d..000000000 --- a/baremetal/example/libc_port/test.ld +++ /dev/null @@ -1,56 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(_Reset) - -/* pretend that 0x60000000 is ROM, 0x70000000 is RAM */ -/* because vexpress-qemu is not able to emulate flash memory as ROM */ -/* space is significant to avoid syntax error when linking */ -MEMORY -{ - ROM (rx) : ORIGIN = 0x60000000, LENGTH = 1M - RAM (rwx): ORIGIN = 0x70000000, LENGTH = 32M -} - -SECTIONS -{ - .text : { - startup.o (.vector_table) - *(.text*) - *(.rodata*) /* make life easier without rodata section */ - } > ROM /* .text should linked to ROM */ - _text_end = .; - /* data segment, contains data that can be modified by the program at run-time, - global and static variables that have a non-zero initial value will normally go here */ - .data : AT(ADDR(.text) + SIZEOF(.text)) /* AT specify the load address right after .text */ - { - _data_start = .; /* .data section will be redise at runtime */ - *(.data) - . = ALIGN(8); - _data_end = .; - } > RAM /* link it all to RAM */ - /* unitialized data segment, variables explicitly initialized with zero to BSS */ - .bss : { - _bss_start = .; - *(.bss) - . = ALIGN(8); - _bss_end = .; - } > RAM - - _fiq_stack_start = ADDR(.bss) + SIZEOF(.bss); - _fiq_stack_end = _fiq_stack_start + 0x1000; /* 64 KB */ - - _irq_stack_start = _fiq_stack_end; - _irq_stack_end = _irq_stack_start + 0x1000; /* 64 KB */ - - _stack_start = _irq_stack_end; - _stack_end = _stack_start + 0x1000; /* 64 KB */ - - _irq_stack_size = _irq_stack_end - _irq_stack_start; - _fiq_stack_size = _fiq_stack_end - _fiq_stack_start; - - . = ALIGN(8); - heap_low = .; /* for _sbrk */ - . = . + 0x10000; /* 64kB of heap memory */ - heap_top = .; /* for _sbrk */ - . = . + 0x10000; /* 64kB of stack memory */ -} \ No newline at end of file diff --git a/baremetal/example/qemu_libc_test/build.sh b/baremetal/example/qemu_libc_test/build.sh deleted file mode 100644 index d1a587d96..000000000 --- a/baremetal/example/qemu_libc_test/build.sh +++ /dev/null @@ -1,28 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-06-10 08:52:12 - # @LastEditTime: 2021-10-15 16:04:35 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### - -./clean.sh - -TARGET=qemu_aarch32 -echo "building "$TARGET -echo "compiling startup.s" -arm-none-eabi-as -o start.o start.S -echo "compiling syscalls.c" -arm-none-eabi-gcc -I ./newlib-4.1.0/newlib/libc/include -c -nostdlib -nostartfiles -o syscalls.o syscalls.c -echo "compiling main.s" -arm-none-eabi-gcc -I ./newlib-4.1.0/newlib/libc/include -c -nostdlib -nostartfiles -o main.o main.c -echo "linking" -arm-none-eabi-ld -T link.ld main.o start.o syscalls.o ./newlib-4.1.0/arm-none-eabi/newlib/libc.a $AARCH32_CROSS_PATH/lib/gcc/arm-none-eabi/10.2.1/libgcc.a -o $TARGET.elf -echo "objcopying" -arm-none-eabi-objcopy -O binary $TARGET.elf $TARGET.bin diff --git a/baremetal/example/qemu_libc_test/clean.sh b/baremetal/example/qemu_libc_test/clean.sh deleted file mode 100644 index 8da30fea0..000000000 --- a/baremetal/example/qemu_libc_test/clean.sh +++ /dev/null @@ -1,14 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-06-10 10:00:43 - # @LastEditTime: 2021-10-15 15:46:55 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### -rm *.o *.bin *.elf \ No newline at end of file diff --git a/baremetal/example/qemu_libc_test/link.ld b/baremetal/example/qemu_libc_test/link.ld deleted file mode 100644 index 9f4ee84e0..000000000 --- a/baremetal/example/qemu_libc_test/link.ld +++ /dev/null @@ -1,67 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(_start) - -MEMORY -{ - ROM (rx) : ORIGIN = 0x80100000, LENGTH = 1M - RAM (rwx): ORIGIN = 0x81000000, LENGTH = 32M -} - -SECTIONS -{ - .text : { - start.o (.vector_table) - *(.text*) - *(.rodata*) - } > ROM - _text_end = .; - .data : AT(ADDR(.text) + SIZEOF(.text)) - { - _data_start = .; - *(.data) - . = ALIGN(8); - _data_end = .; - } > RAM - .bss : { - _bss_start = .; - *(.bss) - . = ALIGN(8); - _bss_end = .; - } > RAM - - _fiq_stack_start = ADDR(.bss) + SIZEOF(.bss); - _fiq_stack_end = _fiq_stack_start + 0x1000; /* 64 KB */ - - _irq_stack_start = _fiq_stack_end; - _irq_stack_end = _irq_stack_start + 0x1000; /* 64 KB */ - - _svc_stack_start = _irq_stack_end; - _svc_stack_end = _svc_stack_start + 0x1000; /* 64 KB */ - - _sys_stack_start = _svc_stack_end; - _sys_stack_end = _sys_stack_start + 0x1000; /* 64 KB */ - - _abt_stack_start = _sys_stack_end; - _abt_stack_end = _abt_stack_start + 0x1000; /* 64 KB */ - - _udf_stack_start = _abt_stack_end; - _udf_stack_end = _udf_stack_start + 0x1000; /* 64 KB */ - - _usr_stack_start = _udf_stack_end; - _usr_stack_end = _usr_stack_start + 0x1000; /* 64 KB */ - - _irq_stack_size = _irq_stack_end - _irq_stack_start; - _fiq_stack_size = _fiq_stack_end - _fiq_stack_start; - _svc_stack_size = _svc_stack_end - _svc_stack_start; - _sys_stack_size = _sys_stack_end - _sys_stack_start; - _abt_stack_size = _abt_stack_end - _abt_stack_start; - _udf_stack_size = _udf_stack_end - _udf_stack_start; - _usr_stack_size = _usr_stack_end - _usr_stack_start; - - . = ALIGN(8); - heap_low = .; /* for _sbrk */ - . = . + 0x10000; /* 64kB of heap memory */ - heap_top = .; /* for _sbrk */ - . = . + 0x10000; /* 64kB of stack memory */ -} diff --git a/baremetal/example/qemu_libc_test/main.c b/baremetal/example/qemu_libc_test/main.c deleted file mode 100644 index 7cc7b47f5..000000000 --- a/baremetal/example/qemu_libc_test/main.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. - * - * SPDX-License-Identifier: Apache-2.0. - * - * @Date: 2021-05-24 14:20:10 - * @LastEditTime: 2021-10-15 16:05:54 - * @Description:  This files is for - * - * @Modify History: - * Ver   Who        Date         Changes - * ----- ------     --------    -------------------------------------- - */ -#include -#include -#include - -extern char* heap_end; /* Defined in syscalls.c */ - -volatile uint8_t *uart0 = (uint8_t *)0x10009000; - -/* writing a UART driver */ -void write(const char* str) -{ - while (*str) { - *uart0 = *str++; - } -} -void c_entry() -{ - char c; - char* ptr = NULL; - size_t alloc_size = 1; - - do - { - c = getchar(); - printf("%d: %c\n", c, c); - - ptr = realloc(ptr, alloc_size); - - if (ptr == NULL) { - puts("Out of memory!\nProgram halting."); - - for (;;); - } else { - printf("new alloc of %d bytes at address 0x%X\n", alloc_size, - (unsigned int)ptr); - alloc_size <<= 1; - printf("Heap end = 0x%X\n", (unsigned int)heap_end); - } - } while (1); -} - -int main() -{ - const char *s = "Hello world from aarch32 bare-metal!\n"; - uart0 = (uint8_t *)0x10009000; - write(s); - *uart0 = 'A'; - *uart0 = 'B'; - *uart0 = 'C'; - *uart0 = '\n'; - while (*s != '\0') - { - *uart0 = *s; - s++; - } - - *uart0 = 'C'; - *uart0 = 'E'; - *uart0 = 'N'; - *uart0 = '\n'; - c_entry(); - - return 0; -} - diff --git a/baremetal/example/qemu_libc_test/run.sh b/baremetal/example/qemu_libc_test/run.sh deleted file mode 100644 index 5b6510ea1..000000000 --- a/baremetal/example/qemu_libc_test/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-06-10 08:52:26 - # @LastEditTime: 2021-10-15 15:47:32 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### - -TARGET=qemu_aarch32 -# qemu-system-arm -machine vexpress-a9 -m 1024M \ -# -serial stdio -kernel $TARGET.elf -$PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -M vexpress-a9 -m 1024M \ - -serial stdio -kernel $TARGET.elf \ No newline at end of file diff --git a/baremetal/example/qemu_libc_test/start.S b/baremetal/example/qemu_libc_test/start.S deleted file mode 100644 index 7b3660e30..000000000 --- a/baremetal/example/qemu_libc_test/start.S +++ /dev/null @@ -1,172 +0,0 @@ -.equ MODE_USR, 0x10 @ PL0 -.equ MODE_FIQ, 0x11 @ PL1 -.equ MODE_IRQ, 0x12 @ PL1 -.equ MODE_SVC, 0x13 @ PL1 -@.equ MODE_MON, 0x16 @ PL1 Secure only -.equ MODE_ABT, 0x17 @ PL1 -.equ MODE_HYP, 0x1A @ PL2, Non-secure -.equ MODE_UDF, 0x1B @ PL1 -.equ MODE_SYS, 0X1F @ PL1 - -.global _start -_start: - b Reset_Handler @0x0 Reset - b Undefined_Handler @0x4 Undefined Instruction - b SVC_Handler @0x8 Supervisor Call - b PrefetchAbort_Handler @0xC Prefetch Abort - b DataAbort_Handler @0x10 Data Abort - NOP @0x14 Reserved - b IRQ_Handler @0x18 IRQ interrupt - b FIQ_Handler @0x1C FIQ interrupt - -Reset_Handler: - cpsid i /* 关闭全局中断 */ - - /* 关闭I,DCache和MMU - * 采取读-改-写的方式。 - */ - mrc p15, 0, r0, c1, c0, 0 /* 读取CP15的C1寄存器到R0中 */ - bic r0, r0, #(0x1 << 12) /* 清除C1寄存器的bit12位(I位),关闭I Cache */ - bic r0, r0, #(0x1 << 2) /* 清除C1寄存器的bit2(C位),关闭D Cache */ - bic r0, r0, #0x2 /* 清除C1寄存器的bit1(A位),关闭对齐 */ - bic r0, r0, #(0x1 << 11) /* 清除C1寄存器的bit11(Z位),关闭分支预测 */ - bic r0, r0, #0x1 /* 清除C1寄存器的bit0(M位),关闭MMU */ - mcr p15, 0, r0, c1, c0, 0 /* 将r0寄存器中的值写入到CP15的C1寄存器中 */ - -setup_stack_for_allmode: - cps MODE_FIQ @ change the processor mode - ldr r1, =_fiq_stack_start /* load start address into R1 */ - ldr sp, =_fiq_stack_end /* load the end address of the FIQ stack into SP */ - - movw r0, #0xFEFE - movt r0, #0xFEFE /* corresponds to loading x << 16 | y into r0 */ - -/* This is the loop that actually fills the stack with 0xFEFEFEFE */ -fiq_stack_loop: - cmp r1, sp /* compares the value in R1 to the value in SP */ - strlt r0, [r1], #4 /* If R1 is less than SP, - the value in R0 will be written to the - address stored in R1, - and R1 gets increased by 4 */ - blt fiq_stack_loop /* the loop continues as long as R1 is less than SP */ - - /* IRQ stack */ - @msr cpsr_c, MODE_IRQ - cps MODE_IRQ - ldr r1, =_irq_stack_start - ldr sp, =_irq_stack_end - -/* fill irq stack */ -irq_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt irq_stack_loop - - /* Supervisor mode */ - @msr cpsr_c, MODE_SVC - cps MODE_SVC - ldr r1, =_svc_stack_start - ldr sp, =_svc_stack_end - -/* fill the supervisor mode stack */ -svc_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt svc_stack_loop - - /* System mode */ - @msr cpsr_c, MODE_SYS - cps MODE_SYS - ldr r1, =_sys_stack_start - ldr sp, =_sys_stack_end - -/* fill the system mode stack */ -sys_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt sys_stack_loop - - /* Abort mode */ - @msr cpsr_c, MODE_ABT - cps MODE_ABT - ldr r1, =_abt_stack_start - ldr sp, =_abt_stack_end - -/* fill the Abort mode stack */ -abt_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt abt_stack_loop - - /* Undef mode */ - @msr cpsr_c, MODE_UDF - cps MODE_UDF - ldr r1, =_udf_stack_start - ldr sp, =_udf_stack_end - -/* fill the Undef mode stack */ -udf_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt udf_stack_loop - - /* Usr mode */ - @msr cpsr_c, MODE_USR - cps MODE_USR - ldr r1, =_usr_stack_start - ldr sp, =_usr_stack_end - -/* fill the Usr mode stack */ -usr_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt usr_stack_loop - - /* Start copying data */ - ldr r0, =_text_end /* section address has been defined in ld script */ - ldr r1, =_data_start - ldr r2, =_data_end - -/* loop continues over the entirety of .data in ROM */ -data_loop: - cmp r1, r2 - ldrlt r3, [r0], #4 /* t load 4 bytes of data from ROM into R3 */ - strlt r3, [r1], #4 - blt data_loop - - /* Initialize .bss */ - mov r0, #0 - ldr r1, =_bss_start - ldr r2, =_bss_end - -/* loop over memory between the addresses _bss_start and _bss_end */ -/* there is no ROM address, and zeros just take up space */ -bss_loop: - cmp r1, r2 - strlt r0, [r1], #4 - blt bss_loop - - cpsie i /* enable irq */ - bl main /* continue running in case the main function */ - b Abort_Exception /* indicate an error, never execute when main contains infinite loop */ - -Abort_Exception: - swi 0xFF - -Undefined_Handler: - b Abort_Exception - -SVC_Handler: - b Abort_Exception - -PrefetchAbort_Handler: - b Abort_Exception - -DataAbort_Handler: - b Abort_Exception - -IRQ_Handler: - b Abort_Exception - -FIQ_Handler: - b Abort_Exception diff --git a/baremetal/example/qemu_libc_test/syscalls.c b/baremetal/example/qemu_libc_test/syscalls.c deleted file mode 100644 index 7d37a0d1c..000000000 --- a/baremetal/example/qemu_libc_test/syscalls.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. - * - * SPDX-License-Identifier: Apache-2.0. - * - * @Date: 2021-10-15 09:53:06 - * @LastEditTime: 2021-10-15 14:11:58 - * @Description:  This files is for - * - * @Modify History: - * Ver   Who        Date         Changes - * ----- ------     --------    -------------------------------------- - */ - -#include - -enum { - UART_FR_RXFE = 0x10, - UART_FR_TXFF = 0x20, - UART0_ADDR = 0x10009000, -}; - -#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr)) -#define UART_FR(baseaddr) (*(((unsigned int *)(baseaddr))+6)) - -int _close(int file) -{ - return -1; -} - -int _fstat(int file, struct stat* st) -{ - st->st_mode = S_IFCHR; - return 0; -} - -int _isatty(int file) -{ - return 1; -} - -int _lseek(int file, int ptr, int dir) -{ - return 0; -} - -int _open(const char* name, int flags, int mode) -{ - return -1; -} - -int _read(int file, char* ptr, int len) -{ - int todo; - - if (len == 0) { - return 0; - } - - while (UART_FR(UART0_ADDR) & UART_FR_RXFE); - - *ptr++ = UART_DR(UART0_ADDR); - - for (todo = 1; todo < len; todo++) { - if (UART_FR(UART0_ADDR) & UART_FR_RXFE) { - break; - } - - *ptr++ = UART_DR(UART0_ADDR); - } - - return todo; -} - -char* heap_end = 0; -caddr_t _sbrk(int incr) -{ - extern char heap_low; /* Defined by the linker */ - extern char heap_top; /* Defined by the linker */ - char* prev_heap_end; - - if (heap_end == 0) { - heap_end = &heap_low; - } - - prev_heap_end = heap_end; - - if (heap_end + incr > &heap_top) { - /* Heap and stack collision */ - return (caddr_t)0; - } - - heap_end += incr; - return (caddr_t) prev_heap_end; -} - -int _write(int file, char* ptr, int len) -{ - int todo; - - for (todo = 0; todo < len; todo++) { - UART_DR(UART0_ADDR) = *ptr++; - } - - return len; -} - -void _kill(int pid, int sig) { - return; -} - -int _getpid(void) { - return -1; -} - -void abort(void) -{ - return; -} \ No newline at end of file diff --git a/baremetal/example/qemu_test/build.sh b/baremetal/example/qemu_test/build.sh deleted file mode 100644 index 16a4a9802..000000000 --- a/baremetal/example/qemu_test/build.sh +++ /dev/null @@ -1,21 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-06-10 08:52:12 - # @LastEditTime: 2021-06-10 11:11:40 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### - -./clean.sh - -TARGET=qemu_aarch32 -arm-none-eabi-as -o start.o start.S -arm-none-eabi-gcc -c -nostdlib -nostartfiles -c -g -o main.o main.c -arm-none-eabi-ld -T link.ld -o $TARGET.elf start.o main.o -arm-none-eabi-objcopy -O binary $TARGET.elf $TARGET.bin diff --git a/baremetal/example/qemu_test/clean.sh b/baremetal/example/qemu_test/clean.sh deleted file mode 100644 index 8da30fea0..000000000 --- a/baremetal/example/qemu_test/clean.sh +++ /dev/null @@ -1,14 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-06-10 10:00:43 - # @LastEditTime: 2021-10-15 15:46:55 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### -rm *.o *.bin *.elf \ No newline at end of file diff --git a/baremetal/example/qemu_test/link.ld b/baremetal/example/qemu_test/link.ld deleted file mode 100644 index 85d63048c..000000000 --- a/baremetal/example/qemu_test/link.ld +++ /dev/null @@ -1,61 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(_start) - -MEMORY -{ - ROM (rx) : ORIGIN = 0x80100000, LENGTH = 1M - RAM (rwx): ORIGIN = 0x81000000, LENGTH = 32M -} - -SECTIONS -{ - .text : { - start.o (.vector_table) - *(.text*) - *(.rodata*) - } > ROM - _text_end = .; - .data : AT(ADDR(.text) + SIZEOF(.text)) - { - _data_start = .; - *(.data) - . = ALIGN(8); - _data_end = .; - } > RAM - .bss : { - _bss_start = .; - *(.bss) - . = ALIGN(8); - _bss_end = .; - } > RAM - - _fiq_stack_start = ADDR(.bss) + SIZEOF(.bss); - _fiq_stack_end = _fiq_stack_start + 0x1000; /* 64 KB */ - - _irq_stack_start = _fiq_stack_end; - _irq_stack_end = _irq_stack_start + 0x1000; /* 64 KB */ - - _svc_stack_start = _irq_stack_end; - _svc_stack_end = _svc_stack_start + 0x1000; /* 64 KB */ - - _sys_stack_start = _svc_stack_end; - _sys_stack_end = _sys_stack_start + 0x1000; /* 64 KB */ - - _abt_stack_start = _sys_stack_end; - _abt_stack_end = _abt_stack_start + 0x1000; /* 64 KB */ - - _udf_stack_start = _abt_stack_end; - _udf_stack_end = _udf_stack_start + 0x1000; /* 64 KB */ - - _usr_stack_start = _udf_stack_end; - _usr_stack_end = _usr_stack_start + 0x1000; /* 64 KB */ - - _irq_stack_size = _irq_stack_end - _irq_stack_start; - _fiq_stack_size = _fiq_stack_end - _fiq_stack_start; - _svc_stack_size = _svc_stack_end - _svc_stack_start; - _sys_stack_size = _sys_stack_end - _sys_stack_start; - _abt_stack_size = _abt_stack_end - _abt_stack_start; - _udf_stack_size = _udf_stack_end - _udf_stack_start; - _usr_stack_size = _usr_stack_end - _usr_stack_start; -} diff --git a/baremetal/example/qemu_test/main.c b/baremetal/example/qemu_test/main.c deleted file mode 100644 index 6d1685a97..000000000 --- a/baremetal/example/qemu_test/main.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. - * - * SPDX-License-Identifier: Apache-2.0. - * - * @Date: 2021-05-24 14:20:10 - * @LastEditTime: 2021-06-10 08:51:32 - * @Description:  This files is for - * - * @Modify History: - * Ver   Who        Date         Changes - * ----- ------     --------    -------------------------------------- - */ -#include - -volatile uint8_t *uart0 = (uint8_t *)0x10009000; - -void write(const char *str) -{ - while (*str) - { - *uart0 = *str++; - } -} - -int main() -{ - const char *s = "Hello world from aarch32 bare-metal!\n"; - uart0 = (uint8_t *)0x10009000; - write(s); - *uart0 = 'A'; - *uart0 = 'B'; - *uart0 = 'C'; - *uart0 = '\n'; - while (*s != '\0') - { - *uart0 = *s; - s++; - } - while (1) - { - }; - - return 0; -} - diff --git a/baremetal/example/qemu_test/run.sh b/baremetal/example/qemu_test/run.sh deleted file mode 100644 index 5b6510ea1..000000000 --- a/baremetal/example/qemu_test/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-06-10 08:52:26 - # @LastEditTime: 2021-10-15 15:47:32 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### - -TARGET=qemu_aarch32 -# qemu-system-arm -machine vexpress-a9 -m 1024M \ -# -serial stdio -kernel $TARGET.elf -$PHYTIUM_DEV_PATH/qemu-tools/qemu-system-arm -M vexpress-a9 -m 1024M \ - -serial stdio -kernel $TARGET.elf \ No newline at end of file diff --git a/baremetal/example/qemu_test/start.S b/baremetal/example/qemu_test/start.S deleted file mode 100644 index 7b3660e30..000000000 --- a/baremetal/example/qemu_test/start.S +++ /dev/null @@ -1,172 +0,0 @@ -.equ MODE_USR, 0x10 @ PL0 -.equ MODE_FIQ, 0x11 @ PL1 -.equ MODE_IRQ, 0x12 @ PL1 -.equ MODE_SVC, 0x13 @ PL1 -@.equ MODE_MON, 0x16 @ PL1 Secure only -.equ MODE_ABT, 0x17 @ PL1 -.equ MODE_HYP, 0x1A @ PL2, Non-secure -.equ MODE_UDF, 0x1B @ PL1 -.equ MODE_SYS, 0X1F @ PL1 - -.global _start -_start: - b Reset_Handler @0x0 Reset - b Undefined_Handler @0x4 Undefined Instruction - b SVC_Handler @0x8 Supervisor Call - b PrefetchAbort_Handler @0xC Prefetch Abort - b DataAbort_Handler @0x10 Data Abort - NOP @0x14 Reserved - b IRQ_Handler @0x18 IRQ interrupt - b FIQ_Handler @0x1C FIQ interrupt - -Reset_Handler: - cpsid i /* 关闭全局中断 */ - - /* 关闭I,DCache和MMU - * 采取读-改-写的方式。 - */ - mrc p15, 0, r0, c1, c0, 0 /* 读取CP15的C1寄存器到R0中 */ - bic r0, r0, #(0x1 << 12) /* 清除C1寄存器的bit12位(I位),关闭I Cache */ - bic r0, r0, #(0x1 << 2) /* 清除C1寄存器的bit2(C位),关闭D Cache */ - bic r0, r0, #0x2 /* 清除C1寄存器的bit1(A位),关闭对齐 */ - bic r0, r0, #(0x1 << 11) /* 清除C1寄存器的bit11(Z位),关闭分支预测 */ - bic r0, r0, #0x1 /* 清除C1寄存器的bit0(M位),关闭MMU */ - mcr p15, 0, r0, c1, c0, 0 /* 将r0寄存器中的值写入到CP15的C1寄存器中 */ - -setup_stack_for_allmode: - cps MODE_FIQ @ change the processor mode - ldr r1, =_fiq_stack_start /* load start address into R1 */ - ldr sp, =_fiq_stack_end /* load the end address of the FIQ stack into SP */ - - movw r0, #0xFEFE - movt r0, #0xFEFE /* corresponds to loading x << 16 | y into r0 */ - -/* This is the loop that actually fills the stack with 0xFEFEFEFE */ -fiq_stack_loop: - cmp r1, sp /* compares the value in R1 to the value in SP */ - strlt r0, [r1], #4 /* If R1 is less than SP, - the value in R0 will be written to the - address stored in R1, - and R1 gets increased by 4 */ - blt fiq_stack_loop /* the loop continues as long as R1 is less than SP */ - - /* IRQ stack */ - @msr cpsr_c, MODE_IRQ - cps MODE_IRQ - ldr r1, =_irq_stack_start - ldr sp, =_irq_stack_end - -/* fill irq stack */ -irq_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt irq_stack_loop - - /* Supervisor mode */ - @msr cpsr_c, MODE_SVC - cps MODE_SVC - ldr r1, =_svc_stack_start - ldr sp, =_svc_stack_end - -/* fill the supervisor mode stack */ -svc_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt svc_stack_loop - - /* System mode */ - @msr cpsr_c, MODE_SYS - cps MODE_SYS - ldr r1, =_sys_stack_start - ldr sp, =_sys_stack_end - -/* fill the system mode stack */ -sys_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt sys_stack_loop - - /* Abort mode */ - @msr cpsr_c, MODE_ABT - cps MODE_ABT - ldr r1, =_abt_stack_start - ldr sp, =_abt_stack_end - -/* fill the Abort mode stack */ -abt_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt abt_stack_loop - - /* Undef mode */ - @msr cpsr_c, MODE_UDF - cps MODE_UDF - ldr r1, =_udf_stack_start - ldr sp, =_udf_stack_end - -/* fill the Undef mode stack */ -udf_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt udf_stack_loop - - /* Usr mode */ - @msr cpsr_c, MODE_USR - cps MODE_USR - ldr r1, =_usr_stack_start - ldr sp, =_usr_stack_end - -/* fill the Usr mode stack */ -usr_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt usr_stack_loop - - /* Start copying data */ - ldr r0, =_text_end /* section address has been defined in ld script */ - ldr r1, =_data_start - ldr r2, =_data_end - -/* loop continues over the entirety of .data in ROM */ -data_loop: - cmp r1, r2 - ldrlt r3, [r0], #4 /* t load 4 bytes of data from ROM into R3 */ - strlt r3, [r1], #4 - blt data_loop - - /* Initialize .bss */ - mov r0, #0 - ldr r1, =_bss_start - ldr r2, =_bss_end - -/* loop over memory between the addresses _bss_start and _bss_end */ -/* there is no ROM address, and zeros just take up space */ -bss_loop: - cmp r1, r2 - strlt r0, [r1], #4 - blt bss_loop - - cpsie i /* enable irq */ - bl main /* continue running in case the main function */ - b Abort_Exception /* indicate an error, never execute when main contains infinite loop */ - -Abort_Exception: - swi 0xFF - -Undefined_Handler: - b Abort_Exception - -SVC_Handler: - b Abort_Exception - -PrefetchAbort_Handler: - b Abort_Exception - -DataAbort_Handler: - b Abort_Exception - -IRQ_Handler: - b Abort_Exception - -FIQ_Handler: - b Abort_Exception diff --git a/baremetal/example/qemu_test/start.S.old b/baremetal/example/qemu_test/start.S.old deleted file mode 100644 index 5d86703af..000000000 --- a/baremetal/example/qemu_test/start.S.old +++ /dev/null @@ -1,192 +0,0 @@ -/* Some defines */ -.equ MODE_USR, 0x10 @ PL0 -.equ MODE_FIQ, 0x11 @ PL1 -.equ MODE_IRQ, 0x12 @ PL1 -.equ MODE_SVC, 0x13 @ PL1 -@.equ MODE_MON, 0x16 @ PL1 Secure only -.equ MODE_ABT, 0x17 @ PL1 -.equ MODE_HYP, 0x1A @ PL2, Non-secure -.equ MODE_UDF, 0x1B @ PL1 -.equ MODE_SYS, 0X1F @ PL1 - -.section .vector_table, "x" -.global _start -_start: - b Reset_Handler @0x0 Reset - b Undefined_Handler @0x4 Undefined Instruction - b SVC_Handler @0x8 Supervisor Call - b PrefetchAbort_Handler @0xC Prefetch Abort - b DataAbort_Handler @0x10 Data Abort - NOP @0x14 Reserved - b IRQ_Handler @0x18 IRQ interrupt - b FIQ_Handler @0x1C FIQ interrupt - -.section .text /* The code segment, RD, program’s executable code */ -Reset_Handler: - cpsid aif @ disable asynchronous abort, irq and fiq - - @ Disable MMU - MRC p15, 0, r1, c1, c0, 0 @ Read Control Register configuration data - BIC r1, r1, #0x1 - MCR p15, 0, r1, c1, c0, 0 @ Write Control Register configuration data - - @ Disable L1 Caches - MRC p15, 0, r1, c1, c0, 0 @ Read Control Register configuration data - BIC r1, r1, #(0x1 << 12) @ Disable I Cache - BIC r1, r1, #(0x1 << 2) @ Disable D Cache - MCR p15, 0, r1, c1, c0, 0 @ Write Control Register configuration data - - @ Invalidate L1 Caches - @ Invalidate Instruction cache - MOV r1, #0 - MCR p15, 0, r1, c7, c5, 0 - - @ Invalidate TLB - MCR p15, 0, r1, c8, c7, 0 - - @ Enable Branch Prediction - MOV r1, #0 - MRC p15, 0, r1, c1, c0, 0 @ Read Control Register configuration data - ORR r1, r1, #(0x1 << 11) @ Global BP Enable bit - MCR p15, 0, r1, c1, c0, 0 @ Write Control Register configuration data - - @ Enable D-side Prefetch - MRC p15, 0, r1, c1, c0, 1 @ Read Auxiliary Control Register - ORR r1, r1, #(0x1 <<2) @ Enable D-side prefetch - MCR p15, 0, r1, c1, c0, 1 ; @ Write Auxiliary Control Register - DSB - ISB - - @ @ Initialize MMU - @ MOV r1,#0x0 - @ MCR p15, 0, r1, c2, c0, 2 @ Write Translation Table Base Control Register - @ LDR r1, ttb_address - @ MCR p15, 0, r1, c2, c0, 0 @ Write Translation Table Base Register 0 - - @ @ Enable MMU - @ MRC p15, 0, r1, c1, c0, 0 @ Read Control Register configuration data - @ ORR r1, r1, #0x1 @ Bit 0 is the MMU enable - @ MCR p15, 0, r1, c1, c0, 0 @ Write Control Register configuration data - -@======================================================= -/* Processors are in Secure SVC mode after reset */ -/* FIQ stack */ -/* Current Program Status Register, - change cpsr without affacting the - condition flags */ - @msr cpsr_c, MODE_FIQ /* switch the processor to FIQ mode */ - cps MODE_FIQ @ change the processor mode - ldr r1, =_fiq_stack_start /* load start address into R1 */ - ldr sp, =_fiq_stack_end /* load the end address of the FIQ stack into SP */ - - movw r0, #0xFEFE - movt r0, #0xFEFE /* corresponds to loading x << 16 | y into r0 */ - -/* This is the loop that actually fills the stack with 0xFEFEFEFE */ -fiq_stack_loop: - cmp r1, sp /* compares the value in R1 to the value in SP */ - strlt r0, [r1], #4 /* If R1 is less than SP, - the value in R0 will be written to the - address stored in R1, - and R1 gets increased by 4 */ - blt fiq_stack_loop /* the loop continues as long as R1 is less than SP */ - - /* IRQ stack */ - @msr cpsr_c, MODE_IRQ - cps MODE_IRQ - ldr r1, =_irq_stack_start - ldr sp, =_irq_stack_end - -/* fill irq stack */ -irq_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt irq_stack_loop - - /* Supervisor mode */ - @msr cpsr_c, MODE_SVC - cps MODE_SVC - ldr r1, =_svc_stack_start - ldr sp, =_svc_stack_end - -/* fill the supervisor mode stack */ -svc_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt svc_stack_loop - - /* System mode */ - @msr cpsr_c, MODE_SYS - cps MODE_SYS - ldr r1, =_sys_stack_start - ldr sp, =_sys_stack_end - -/* fill the system mode stack */ -sys_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt sys_stack_loop - - /* Abort mode */ - @msr cpsr_c, MODE_ABT - cps MODE_ABT - ldr r1, =_abt_stack_start - ldr sp, =_abt_stack_end - -/* fill the Abort mode stack */ -abt_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt abt_stack_loop - - /* Undef mode */ - @msr cpsr_c, MODE_UDF - cps MODE_UDF - ldr r1, =_udf_stack_start - ldr sp, =_udf_stack_end - -/* fill the Undef mode stack */ -udf_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt udf_stack_loop - - /* Usr mode */ - @msr cpsr_c, MODE_USR - cps MODE_USR - ldr r1, =_usr_stack_start - ldr sp, =_usr_stack_end - -/* fill the Usr mode stack */ -usr_stack_loop: - cmp r1, sp - strlt r0, [r1], #4 - blt usr_stack_loop - -@================================================= - /* Start copying data */ - ldr r0, =_text_end /* section address has been defined in ld script */ - ldr r1, =_data_start - ldr r2, =_data_end - -/* loop continues over the entirety of .data in ROM */ -data_loop: - cmp r1, r2 - ldrlt r3, [r0], #4 /* t load 4 bytes of data from ROM into R3 */ - strlt r3, [r1], #4 - blt data_loop - - /* Initialize .bss */ - mov r0, #0 - ldr r1, =_bss_start - ldr r2, =_bss_end - -/* loop over memory between the addresses _bss_start and _bss_end */ -/* there is no ROM address, and zeros just take up space */ -bss_loop: - cmp r1, r2 - strlt r0, [r1], #4 - blt bss_loop - - bl main /* continue running in case the main function */ - b Abort_Exception /* indicate an error, never execute when main contains infinite loop */ \ No newline at end of file -- Gitee From 1665292a49e57e7c93ed76cde23fc449f05f5a8a Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 13:33:27 +0800 Subject: [PATCH 13/21] update --- install.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install.py b/install.py index e1296d2b1..d399ba9a0 100755 --- a/install.py +++ b/install.py @@ -152,13 +152,13 @@ os.system("sed -i '/export STANDALONE_SDK_ROOT=/d' " + old_profile_path) os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING END/d' "+ old_profile_path) # remove environment variables -os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING START/d' "+ sdk_profile_path) -os.system("sed -i '/export AARCH32_CROSS_PATH=/d' " + sdk_profile_path) -os.system("sed -i '/export PATH=\$PATH:\$AARCH32_CROSS_PATH/d' " + sdk_profile_path) -os.system("sed -i '/export AARCH64_CROSS_PATH=/d' " + sdk_profile_path) -os.system("sed -i '/export PATH=\$PATH:\$AARCH64_CROSS_PATH/d' " + sdk_profile_path) -os.system("sed -i '/export STANDALONE_SDK_ROOT=/d' " + sdk_profile_path) -os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING END/d' "+ sdk_profile_path) +# os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING START/d' "+ sdk_profile_path) +# os.system("sed -i '/export AARCH32_CROSS_PATH=/d' " + sdk_profile_path) +# os.system("sed -i '/export PATH=\$PATH:\$AARCH32_CROSS_PATH/d' " + sdk_profile_path) +# os.system("sed -i '/export AARCH64_CROSS_PATH=/d' " + sdk_profile_path) +# os.system("sed -i '/export PATH=\$PATH:\$AARCH64_CROSS_PATH/d' " + sdk_profile_path) +# os.system("sed -i '/export STANDALONE_SDK_ROOT=/d' " + sdk_profile_path) +# os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING END/d' "+ sdk_profile_path) print("[2]: Reset environment") -- Gitee From c1c44176ddc43588853f6d36a569c18be4674da0 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 13:44:36 +0800 Subject: [PATCH 14/21] update --- baremetal/example/newlibc_test/sdkconfig | 4 +- baremetal/example/newlibc_test/sdkconfig.h | 4 +- lib/lib.mk | 7 +- lib/newlibc/syscalls.c | 153 --------------------- 4 files changed, 5 insertions(+), 163 deletions(-) delete mode 100644 lib/newlibc/syscalls.c diff --git a/baremetal/example/newlibc_test/sdkconfig b/baremetal/example/newlibc_test/sdkconfig index 4681129e4..bb511cd8c 100644 --- a/baremetal/example/newlibc_test/sdkconfig +++ b/baremetal/example/newlibc_test/sdkconfig @@ -91,8 +91,8 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +# CONFIG_USE_G_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Library Configuration # diff --git a/baremetal/example/newlibc_test/sdkconfig.h b/baremetal/example/newlibc_test/sdkconfig.h index df40c87c9..889f69318 100644 --- a/baremetal/example/newlibc_test/sdkconfig.h +++ b/baremetal/example/newlibc_test/sdkconfig.h @@ -81,8 +81,8 @@ /* Library Configuration */ -#define CONFIG_USE_G_LIBC -/* CONFIG_USE_NEW_LIBC is not set */ +/* CONFIG_USE_G_LIBC is not set */ +#define CONFIG_USE_NEW_LIBC /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/lib/lib.mk b/lib/lib.mk index 5d9180b27..26f2dbb2f 100644 --- a/lib/lib.mk +++ b/lib/lib.mk @@ -3,7 +3,7 @@ LIB_CUR_DIR := $(STANDALONE_DIR)/lib -ifdef CONFIG_USE_G_LIBC +ifneq ($(CONFIG_USE_G_LIBC)_$(CONFIG_USE_NEW_LIBC), 0_0) SRC_DIR += $(LIB_CUR_DIR)/libc INC_DIR += $(LIB_CUR_DIR)/libc endif @@ -11,9 +11,4 @@ endif ifdef CONFIG_USE_NOSTD_LIBC SRC_DIR += $(LIB_CUR_DIR)/nostdlib INC_DIR += $(LIB_CUR_DIR)/nostdlib -endif - -ifdef CONFIG_USE_NEW_LIBC - SRC_DIR += $(LIB_CUR_DIR)/newlibc - INC_DIR += $(LIB_CUR_DIR)/newlibc endif \ No newline at end of file diff --git a/lib/newlibc/syscalls.c b/lib/newlibc/syscalls.c deleted file mode 100644 index 9e69c0b3f..000000000 --- a/lib/newlibc/syscalls.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. - * - * SPDX-License-Identifier: Apache-2.0. - * - * @Date: 2021-10-15 09:53:06 - * @LastEditTime: 2021-10-15 18:19:12 - * @Description:  This files is for - * - * @Modify History: - * Ver   Who        Date         Changes - * ----- ------     --------    -------------------------------------- - */ - -#include -#include -#include "early_uart.h" - -enum { - UART_FR_RXFE = EARLY_UART_RXFE, - UART_FR_TXFF = EARLY_UART_TXFF, - UART0_ADDR = EARLY_UART_BASE, -}; - -#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr)) -#define UART_FR(baseaddr) (*(((unsigned int *)(baseaddr))+6)) - -/* _exit - Simple implementation. Does not return. -*/ -void _exit(int return_value) -{ - (void)return_value; - asm("dsb sy"); - while (1) - { - asm("wfi"); - } -} - -int _close(int file) -{ - return -1; -} - -int _fstat(int file, struct stat* st) -{ - st->st_mode = S_IFCHR; - return 0; -} - -int _isatty(int file) -{ - return 1; -} - -int _lseek(int file, int ptr, int dir) -{ - return 0; -} - -int _open(const char* name, int flags, int mode) -{ - return -1; -} - -int _read(int file, char* ptr, int len) -{ - int todo; - - if (len == 0) { - return 0; - } - - while (UART_FR(UART0_ADDR) & UART_FR_RXFE); - - *ptr++ = UART_DR(UART0_ADDR); - - for (todo = 1; todo < len; todo++) { - if (UART_FR(UART0_ADDR) & UART_FR_RXFE) { - break; - } - - *ptr++ = UART_DR(UART0_ADDR); - } - - return todo; -} - -//char* heap_end = 0; - -extern u8 _heap_start[]; -extern u8 _heap_end[]; -extern char HeapBase[]; -extern char HeapLimit[]; - -caddr_t _sbrk(int nbytes) -{ - // extern char HeapBase; /* Defined by the linker */ - // extern char HeapLimit; /* Defined by the linker */ - // char* prev_heap_end; - - // if (heap_end == 0) { - // heap_end = &HeapBase; - // } - - // prev_heap_end = heap_end; - - // if (heap_end + incr > &HeapLimit) { - // /* Heap and stack collision */ - // return (caddr_t)0; - // } - - // heap_end += incr; - // return (caddr_t) prev_heap_end; - char *base; - static char *heap_ptr = HeapBase; - - base = heap_ptr; - if((heap_ptr != NULL) && (heap_ptr + nbytes <= (char *)&HeapLimit + 1)) { - heap_ptr += nbytes; - return base; - } else { - errno = ENOMEM; - return ((char *)-1); - } -} - -int _write(int file, char* ptr, int len) -{ - int todo; - - for (todo = 0; todo < len; todo++) { - UART_DR(UART0_ADDR) = *ptr++; - } - - return len; -} - -void _kill(int pid, int sig) { - if(pid == 1) { - _exit(sig); - } - return; -} - -int _getpid(void) { - return 1; -} - -void abort(void) -{ - _exit(1); -} \ No newline at end of file -- Gitee From 0695fdfec90812fdbba9334e21f7f45c17a2e3b4 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 05:48:37 +0000 Subject: [PATCH 15/21] update README.md. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e97abf59..62595f496 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,14 @@ - 按照不同开发平台获取DEV压缩包 -- [Windows10](https://pan.baidu.com/s/16d8NSPn2KY78G5KLwFDpxw) ->提取码:WIX6 +- [Windows10](https://pan.baidu.com/s/1i7rkUPzXwhbyasbhlUKPmQ) +>提取码:WX64 -- [Ubuntu 20.04 x86_64](https://pan.baidu.com/s/1Hci3gttdCvNpKRc3oRTX3Q ) +- [Ubuntu 20.04 x86_64](https://pan.baidu.com/s/1GrXHCygjcySKxARQ5UduTA ) >提取码:LX64 ![linux-x86_64](https://images.gitee.com/uploads/images/2021/1019/095533_a960e2a6_8736513.png "linux-x86_64.png") -- [Ubuntu/Kylis OS aarch64](https://pan.baidu.com/s/11zIN0Z6TyZG32h_3YpSARw ) +- [Ubuntu/Kylis OS aarch64](https://pan.baidu.com/s/1pDWZIdI-dRle4NOIsP-TQA ) >提取码:LA64 ![linux-aarch64](https://images.gitee.com/uploads/images/2021/1019/101040_ff6c194e_8736513.png "linux-aarch64.png") -- Gitee From c09e5a634dd0ff0a21653fb54d3e7cbb4f213a41 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 13:54:32 +0800 Subject: [PATCH 16/21] update --- README.md | 2 +- baremetal/example/newlibc_test/sdkconfig | 4 ++-- baremetal/example/newlibc_test/sdkconfig.h | 4 ++-- doc/ChangeLog.md | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 62595f496..a2f6b30f3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Phytium-Standalone-SDK -**v0.1.5** [ReleaseNote](./doc/ChangeLog.md) +**v0.1.6** [ReleaseNote](./doc/ChangeLog.md) --- diff --git a/baremetal/example/newlibc_test/sdkconfig b/baremetal/example/newlibc_test/sdkconfig index bb511cd8c..4681129e4 100644 --- a/baremetal/example/newlibc_test/sdkconfig +++ b/baremetal/example/newlibc_test/sdkconfig @@ -91,8 +91,8 @@ CONFIG_STACK_SIZE=0x1000 # # Library Configuration # -# CONFIG_USE_G_LIBC is not set -CONFIG_USE_NEW_LIBC=y +CONFIG_USE_G_LIBC=y +# CONFIG_USE_NEW_LIBC is not set # end of Library Configuration # diff --git a/baremetal/example/newlibc_test/sdkconfig.h b/baremetal/example/newlibc_test/sdkconfig.h index 889f69318..df40c87c9 100644 --- a/baremetal/example/newlibc_test/sdkconfig.h +++ b/baremetal/example/newlibc_test/sdkconfig.h @@ -81,8 +81,8 @@ /* Library Configuration */ -/* CONFIG_USE_G_LIBC is not set */ -#define CONFIG_USE_NEW_LIBC +#define CONFIG_USE_G_LIBC +/* CONFIG_USE_NEW_LIBC is not set */ /* end of Library Configuration */ /* Third-Party Configuration */ diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 416bc3b2e..f4eda99c6 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -1,3 +1,19 @@ +# Phytium Standalone SDK v0.1.6 ChangeLog + +Change Log since v0.1.5, 2021.10.19 + +## example + +- add project to demo usage of newlib + +## script + +- add `PHYTIUM_DEV_PATH` for all platforms +- install cross tool to `PHYTIUM_DEV_PATH` +- update GNU CC version to 10.3.1-2021.07 +- modify CC libc.a for printf issue +- merge newlib to CC tool + # Phytium Standalone SDK v0.1.5 ChangeLog Change Log since v0.1.4, 2021.10.14 -- Gitee From 17ca95b5bb8a4b8605570335e71e380727daf173 Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 13:59:18 +0800 Subject: [PATCH 17/21] update --- README.md | 55 ++++++++++++++++--------------------------------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index a2f6b30f3..a2c932c5f 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ $ pacman -S base-devel git python3 python3-pip $ pacman -Q make git wget python3 python3-pip ``` -### 2.5 卸载开发环境 +### 2.4 卸载开发环境 - 在DEV目录下双击`run_msys2.cmd`, 启动`Msys2`控制台,在控制台输入`./uninstall.py`完成SDK卸载 @@ -160,29 +160,6 @@ $ pacman -Q make git wget python3 python3-pip #### 3.1.1 选择工程模板 -##### 3.1.1.1 Window环境使用工程 - -- 复制`~/standalone-sdk/example/template-mingw64`目录,作为baremetal应用工程 - -> `*` 表示可选文件/目录 - -``` -Kconfig --> 应用工程配置menu文件 -makefile --> makefile -main.c --> 包含main函数 -sdkconfig --> 配置输出 -sdkconfig.h --> 配置输出 -run_mingw64.cmd --> 启动msys-mingw64控制台* -inc --> 用户头文件* -src --> 用户源文件* -``` - -![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/144914_9e06694b_8736513.png "屏幕截图.png") - -- 双击run_mingw64.cmd,在当前目录启动mingw64控制台 - -##### 3.1.1.2 Linux环境使用工程 - - 复制`~/standalone-sdk/example/template`目录,作为 baremetal 应用工程 > `*` 表示可选文件/目录 @@ -200,7 +177,7 @@ src --> 用户源文件* >请注意使用小写makefile,使用Makefile在部分平台不能被识别 -#### 2.4.2 选择目标平台 +#### 3.1.2 选择目标平台 - 切换目标平台, e.g `FT2000/4 AARCH32`, 加载默认配置 @@ -225,15 +202,15 @@ template.map --> 内存布局文件 ![输入图片说明](https://images.gitee.com/uploads/images/2021/0709/141655_f20b6d98_8736513.png "屏幕截图.png") -### 2.5 快速使用例程 +### 3.2 快速使用例程 > ~/standalone-sdk/example/aarch32_hello_world ![输入图片说明](https://images.gitee.com/uploads/images/2021/0709/145025_398f6501_8736513.png "屏幕截图.png") -### 2.6 下载镜像跳转启动 +### 3.3 下载镜像跳转启动 -#### 2.6.1 在 host 侧(Ubuntu 20.04)配置 tftp 服务 +#### 3.3.1 在 host 侧(Ubuntu 20.04)配置 tftp 服务 - 在开发环境`host`侧安装`tftp`服务 @@ -298,7 +275,7 @@ tftp> get test1234 tftp> q ``` -#### 2.6.2 在 host 侧(Windows)配置 tftp 服务 +#### 3.3.2 在 host 侧(Windows)配置 tftp 服务 - 将2.1.1章下载的`tftp.zip`解压到开发环境,如`D:\phytium-dev\tftp` - 以**管理员权限**打开Windows cmd,进入`D:\phytium-dev\tftp`,运行`.\reinstall.cmd`完成Tftpd服务安装 @@ -319,7 +296,7 @@ tftp> q > 在`template_mingw64`工程中,通过定义`USR_BOOT_DIR`可以将编译的镜像自动拷贝带tftp目录下 -#### 2.6.3 配置开发板 ip,连通 host 下载启动镜像 +#### 3.3.3 配置开发板 ip,连通 host 下载启动镜像 - 将`BIN`文件或者`ELF`文件复制到`tftpboot`目录 @@ -359,7 +336,7 @@ $ cp ./baremetal.elf /mnt/d/tftboot --- -## 3. SDK 源代码结构 +## 4. SDK 源代码结构 ``` . @@ -411,9 +388,9 @@ $ cp ./baremetal.elf /mnt/d/tftboot --- -## 4. 硬件平台 +## 5. 硬件平台 -### 4.1 FT2000-4 +### 5.1 FT2000-4 FT-2000/4 是一款面向桌面应用的高性能通用 4 核处理器。每 2 个核构成 1 个处理器核簇(Cluster),并共享 L2 Cache。主要技术特征如下: @@ -429,7 +406,7 @@ FT-2000/4 是一款面向桌面应用的高性能通用 4 核处理器。每 2 - 集成 4 个 UART,1 个 LPC,32 个 GPIO,4 个 I2C,1 个 QSPI,2 个通 用 SPI,2 个 WDT,16 个外部中断(和 GPIO 共用 IO) - 集成温度传感器 -### 4.2 D2000 +### 5.2 D2000 D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个核构成 1 个处理器核簇(Cluster),并共享 L2 Cache。存储系统包含 Cache 子系统和 DDR,I/O 系统包含 PCIe、高速 IO 子系统、千兆位以太网 GMAC 和低速 IO 子系统,主要技术特征如下, @@ -447,9 +424,9 @@ D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个 --- -## 5. 支持情况 +## 6. 支持情况 -### 5.1 外设驱动支持情况 +### 6.1 外设驱动支持情况 | Hardware Interface | Platform Supported | Platform Developing | Component | | ------------------------------ | -------------------------- | ------------------- | -------------------- | @@ -479,7 +456,7 @@ D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个 | Yaffs2 | | E2000 | | --- -## 6. 参考资源 +## 7. 参考资源 - ARM Architecture Reference Manual - ARM Cortex-A Series Programmer’s Guide @@ -495,7 +472,7 @@ D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个 --- -## 7. 贡献方法 +## 8. 贡献方法 请联系飞腾嵌入式软件部 @@ -507,6 +484,6 @@ wangxiaodong1030@phytium.com.cn --- -## 8. 许可协议 +## 9. 许可协议 Apache-2.0 -- Gitee From 195f453ab26104d95ee9984a43205d93e9bbd1bc Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 14:00:36 +0800 Subject: [PATCH 18/21] update --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2c932c5f..4362c7c37 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ## 2. 安装方法 -### 2.1 获取SDK的开发环境 (DEV压缩包) +### 2.1 获取SDK的开发环境 - 按照不同开发平台获取DEV压缩包 @@ -37,7 +37,7 @@ Q:如何解压SDK开发环境压缩包 ### 2.2 安装SDK开发环境 -> 对于Windows 10平台,2.1.1章节的开发环境压缩包中通过msys2控制台提供了git工具 +> 对于Windows 10平台,2.1章节的开发环境压缩包中通过msys2控制台提供了git工具 > 对于Linux/KylinOS平台,可以通过`sudo apt-get install build-essential`安装git等工具 -- Gitee From e7e8dff87efb62533614620a8c00d525bb9cfdaf Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 14:11:12 +0800 Subject: [PATCH 19/21] update README.md --- baremetal/example/newlibc_test/README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/baremetal/example/newlibc_test/README.md b/baremetal/example/newlibc_test/README.md index 8e575ed2a..1ba579af9 100644 --- a/baremetal/example/newlibc_test/README.md +++ b/baremetal/example/newlibc_test/README.md @@ -4,31 +4,40 @@ * SPDX-License-Identifier: Apache-2.0. * * @Date: 2021-08-27 10:37:27 - * @LastEditTime: 2021-10-18 19:22:06 + * @LastEditTime: 2021-10-19 14:10:07 * @Description:  This files is for * * @Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- --> -# XXX +# Newlib ## 1. 例程介绍 >介绍例程的用途,使用场景,相关基本概念,描述用户可以使用例程完成哪些工作
+Newlib是一个面向嵌入式系统的C运行库。最初是由Cygnus Solutions收集组装的一个源代码集合,取名为newlib,现在由Red Hat维护,本SDK中使用的是4.1.0版本,newlib可移植性强,具有可重入特性、功能完备等特点,已广泛应用于各种嵌入式系统中,相比于Glibc,newlib对嵌入式应用的支持更好 + ## 2. 如何使用例程 >描述开发平台准备,使用例程配置,构建和下载镜像的过程
+在Library Configuration中选择Use New Lib + ### 2.1 硬件配置方法 >哪些硬件平台是支持的,需要哪些外设,例程与开发板哪些IO口相关等(建议附录开发板照片,展示哪些IO口被引出)
+- FT2000/4 +- D2000 + ### 2.2 SDK配置方法 >依赖哪些驱动、库和第三方组件,如何完成配置(列出需要使能的关键配置项)
+- 依赖本SDK提供的交叉编译链 + ### 2.3 构建和下载 >描述构建、烧录下载镜像的过程,列出相关的命令
@@ -51,6 +60,14 @@ bootelf -p 0x90100000 >描述输入输出情况,列出存在哪些输出,对应的输出是什么(建议附录相关现象图片)
+- 通过u-boot启动,完成浮点打印 +``` +# bootelf -p 0x90100000 +## Starting application at 0x80100000 ... +hello baremetal phytium 3.141500 + +``` + ## 3. 如何解决问题 >主要记录使用例程中可能会遇到的问题,给出相应的解决方案
@@ -59,6 +76,6 @@ bootelf -p 0x90100000 >记录例程的重大修改记录,标明修改发生的版本号
- +- v0.1.6,2021/10/19 首次合入 -- Gitee From 72d147ec41e6c2e02855d4bdab37a4a7af1fb1bb Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 14:19:25 +0800 Subject: [PATCH 20/21] update --- README.md | 87 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 4362c7c37..6c21b5d17 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ $ pacman -Q make git wget python3 python3-pip - 在DEV目录`D:\phytium-dev\tftp`下以**管理员权限**打开Windows命令行中断,运行`uninstall.cmd`完成Tftd卸载 +--- ## 3. 使用方法 ### 3.1 新建一个 baremetal 应用工程 @@ -340,52 +341,52 @@ $ cp ./baremetal.elf /mnt/d/tftboot ``` . -├── Kconfig --> 配置定义 -├── LICENSE --> 版权声明 -├── README.md -├── standalone.mk +├── Kconfig --> 配置定义 +├── LICENSE --> 版权声明 +├── README.md --> 使用说明 +├── arch +│   └── armv8 --> 架构相关 ├── baremetal -│ └── example --> 裸机例程 -| ├── can_test -| └── i2c_eeprom -| └── sdci_test ... -├── arch --> 架构相关 -| ├── armv8 -| | ├── aarch32 -| | └── aarch64 -| └── common -├── common -├── drivers --> 外设驱动 -| ├── can -| └── eth -| └── gic ... -├── board --> 目标平台相关 -| ├── d2000 -| └── ft2004 -| └── e2000 -├── configs --> 各目标平台的默认配置 -│ ├── d2000_aarch32_defconfig -│ └── d2000_aarch64_defconfig -| └── e2000_aarch32_defconfig -| └── e2000_aarch64_defconfig -| └── ft2004_aarch32_defconfig -| └── ft2004_aarch64_defconfig +│   └── example --> 裸机例程 +├── board +│   ├── d2000 +│   ├── e2000 +│   └── ft2004 --> 平台相关 +├── common +│   ├── f_printf.c +│   ├── f_printf.h +│   ├── fsleep.c +│   └── fsleep.h --> 通用方法 +├── configs +│   ├── ft2004_aarch32_defconfig +│   └── ft2004_aarch64_defconfig --> 各平台默认配置 ├── doc -│ ├── ChangeLog.md -│ └── checklist.md -├── install.py --> 环境变量安装脚本 -├── lib --> 依赖库 -│ ├── Kconfiglib -│ ├── libc -│ └── nostdlib -├── make --> Makefile文件 -├── scripts --> 相关脚本 -├── third-party --> 第三方库 -└── tools --> 编译构建相关工具 - ├── README.md - ├── gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf +│   ├── ChangeLog.md +│   └── system.dio --> 文档和修改记录 +├── drivers +│   ├── can +│   ├── dma +│   └── watchdog --> 外设驱动 +├── install.py --> 安装脚本 +├── lib +│   ├── Kconfiglib +│   ├── lib.mk +│   ├── libc +│   └── nostdlib --> 依赖库 +├── make +│   ├── build_baremetal.mk +│   ├── buildinfo.mk +│   ├── complier.mk +│   └── preconfig.mk --> 编译脚本和链接脚本 +├── requirements.txt --> python环境依赖组件 +├── scripts +├── standalone.mk +├── third-party +│   ├── letter-shell-3.1 +│   └── yaffs2 --> 第三方库 +├── tools +└── uninstall.py --> 卸载脚本 ``` - --- ## 5. 硬件平台 -- Gitee From c22b2d7158a94e8158d21773c8d3cbbe8baf09eb Mon Sep 17 00:00:00 2001 From: zhugengyu Date: Tue, 19 Oct 2021 14:23:12 +0800 Subject: [PATCH 21/21] update --- install.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.py b/install.py index d399ba9a0..a2a78f6cb 100755 --- a/install.py +++ b/install.py @@ -61,6 +61,7 @@ def is_executable(path, user): return (((s[stat.ST_UID] == uid) and (mode & stat.S_IXUSR > 0)) or ((s[stat.ST_GID] == gid) and (mode & stat.S_IXGRP > 0)) or (mode & stat.S_IXOTH > 0)) def un_tar(src_path, dst_dir): + print("- untar {} in progress...".format(src_path)) tar = tarfile.open(name=src_path) for member_info in tar.getmembers(): @@ -85,9 +86,10 @@ else: # features for msys2 platform, windows platform do not support online phytium_dev_path = os.environ.get("PHYTIUM_DEV_PATH") +# to compatible with Windows path, replace \\ with / phytium_dev_path = '/'.join(phytium_dev_path.split('\\')) if (None == phytium_dev_path): - print("[1]: Please set 'PHYTIUM_DEV_PATH' fisrt!!!") + print("[1]: Please set 'PHYTIUM_DEV_PATH' first!!!") exit() # create '/etc/profile.d/phytium_standalone_sdk.sh' need sudo right, ask user to create it first -- Gitee