summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/manual_dist.yml8
-rw-r--r--bsp/x86/.config14
-rw-r--r--bsp/x86/Kconfig20
-rw-r--r--bsp/x86/README.md55
-rw-r--r--bsp/x86/picolib/SConscript14
-rw-r--r--bsp/x86/picolib/picolib_stdio.c20
-rw-r--r--bsp/x86/rtconfig.h9
-rw-r--r--bsp/x86/rtconfig.py7
-rwxr-xr-xtools/ci/toolchain.sh1
9 files changed, 148 insertions, 0 deletions
diff --git a/.github/workflows/manual_dist.yml b/.github/workflows/manual_dist.yml
index 8bf46ed74c..b9145d165f 100644
--- a/.github/workflows/manual_dist.yml
+++ b/.github/workflows/manual_dist.yml
@@ -36,6 +36,7 @@ on:
- "gcc"
- "sourcery-riscv32-esp32"
- "i686-x86-newlib"
+ - "i686-x86-picolib"
bsp_config:
description: 'Type a config you want mannual test in .config, like: CONFIG_RT_USING_DEBUG=y,CONFIG_RT_DEBUGING_COLOR=y,CONFIG_RT_DEBUGING_CONTEXT=y'
required: false
@@ -135,6 +136,13 @@ jobs:
echo "RTT_EXEC_PATH=/opt/i686-atxhua-newlib-elf-gcc/bin" >> $GITHUB_ENV
echo "RTT_CC_PREFIX=i686-atxhua-newlib-elf-" >> $GITHUB_ENV
+ - name: Install i686 X86 Picolib ToolChains
+ if: ${{ github.event.inputs.bsp_tool_chain == 'i686-x86-picolib' && success() }}
+ run: |
+ source tools/ci/toolchain.sh i686-atxhua-picolib-elf-gcc
+ echo "RTT_EXEC_PATH=/opt/i686-atxhua-picolib-elf-gcc/bin" >> $GITHUB_ENV
+ echo "RTT_CC_PREFIX=i686-atxhua-picolib-elf-" >> $GITHUB_ENV
+
- name: Bsp Scons Compile
if: ${{ success() }}
shell: bash
diff --git a/bsp/x86/.config b/bsp/x86/.config
index 7de9ce3052..26097f775c 100644
--- a/bsp/x86/.config
+++ b/bsp/x86/.config
@@ -306,6 +306,7 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
# CONFIG_RT_USING_LCD is not set
# CONFIG_RT_USING_HWCRYPTO is not set
# CONFIG_RT_USING_WIFI is not set
+# CONFIG_RT_USING_RPMSG is not set
# CONFIG_RT_USING_BLK is not set
# CONFIG_RT_USING_REGULATOR is not set
# CONFIG_RT_USING_POWER_SUPPLY is not set
@@ -944,6 +945,12 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_FT32F4_STD_DRIVER is not set
# CONFIG_PKG_USING_FT32F4_CMSIS_DRIVER is not set
# end of FT32 HAL & SDK Drivers
+
+#
+# NOVOSNS Drivers
+#
+# CONFIG_PKG_USING_NOVOSNS_SERIES_DRIVER is not set
+# end of NOVOSNS Drivers
# end of HAL & SDK Drivers
#
@@ -1466,3 +1473,10 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# end of RT-Thread online packages
CONFIG_IA32=y
+
+#
+# X86 Features
+#
+CONFIG_X86_BSP_USING_LIBC=y
+# CONFIG_X86_BSP_USING_PICOLIBC_PORT is not set
+# end of X86 Features
diff --git a/bsp/x86/Kconfig b/bsp/x86/Kconfig
index 3a2016b1af..53c83e3aa7 100644
--- a/bsp/x86/Kconfig
+++ b/bsp/x86/Kconfig
@@ -15,3 +15,23 @@ config IA32
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
default y
+
+menu "X86 Features"
+
+choice
+ prompt "C Library type"
+ default X86_BSP_USING_LIBC
+
+config X86_BSP_USING_LIBC
+ bool "Newlib"
+ help
+ Use the standard Newlib implementation.
+
+config X86_BSP_USING_PICOLIBC_PORT
+ bool "Picolibc (tinystdio)"
+ select RT_USING_COMPONENTS_INIT
+ help
+ Use Picolibc with tinystdio for a smaller footprint.
+endchoice
+
+endmenu
diff --git a/bsp/x86/README.md b/bsp/x86/README.md
index bc649b5885..7365952b74 100644
--- a/bsp/x86/README.md
+++ b/bsp/x86/README.md
@@ -1,5 +1,59 @@
# RT-Thread for x86
+## Intro
+This x86 BSP support both newlib & picolib, with toolchain available
+ - **Newlib:** `i686-atxhua-newlib-elf-`
+ - **Picolibc:** `i686-atxhua-picolib-elf-`
+
+## Install Toolchain
+To install toolchain run the following command:
+ - **Newlib:** sudo ../../tools/ci/toolchain.sh i686-atxhua-newlib-elf-gcc
+ - **Picolibc:** sudo ../../tools/ci/toolchain.sh i686-atxhua-picolib-elf-gcc
+
+## Configuration
+Use `menuconfig` to select your preferred C library:
+ 1. Run `scons --menuconfig`
+ 2. Navigate to `X86 Features` -> `C Library type`
+ 3. Select either `Newlib`(default) or `Picolibc`
+
+## Building
+After select the correct library in `menuconfig`, set the toolchain path and prefix:
+### Newlib
+```bash
+export RTT_EXEC_PATH=/opt/i686-atxhua-newlib-elf-gcc/bin
+export RTT_CC_PREFIX=i686-atxhua-newlib-elf-
+scons
+```
+
+### Picolib
+```bash
+export RTT_EXEC_PATH=/opt/i686-atxhua-picolib-elf-gcc/bin
+export RTT_CC_PREFIX=i686-atxhua-picolib-elf-
+scons
+```
+
+## Result ELF
+### Newlib
+```
+Memory region Used Size Region Size %age Used
+i686-atxhua-newlib-elf-objcopy -O binary rtthread.elf rtthread.bin
+i686-atxhua-newlib-elf-size rtthread.elf
+ text data bss dec hex filename
+ 212900 3274 10844 227018 376ca rtthread.elf
+scons: done building targets.
+
+```
+
+### Picolib
+```
+Memory region Used Size Region Size %age Used
+i686-atxhua-picolib-elf-objcopy -O binary rtthread.elf rtthread.bin
+i686-atxhua-picolib-elf-size rtthread.elf
+ text data bss dec hex filename
+ 174122 2568 10528 187218 2db52 rtthread.elf
+scons: done building targets.
+```
+
这是一份基础的RT-Thread针对x86的版本、移植,主要是能够在qemu中执行。以下说明主要针对Linux的环境,如果是Windows环境,请使用Env工具,同时请自行处理生成iso的方法。
## 编译
@@ -8,6 +62,7 @@
* [i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2](http://117.143.63.254:9012/www/rt-smart/i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2)
* [ GCC 15.2.0 w/ Newlib 4.6.0.20260123: https://github.com/atxhua/i686-atxhua-newlib-elf/releases/download/15.2.0/i686-atxhua-newlib-elf-linux.tar.gz ](https://github.com/atxhua/i686-atxhua-newlib-elf/releases/download/15.2.0/i686-atxhua-newlib-elf-linux.tar.gz)
+* [ GCC 15.2.0 w/ Picolib 1.8.11: https://github.com/atxhua/i686-atxhua-picolib-elf/releases/download/15.2.0/i686-atxhua-picolib-elf-linux.tar.gz ](https://github.com/atxhua/i686-atxhua-picolib-elf/releases/download/15.2.0/i686-atxhua-picolib-elf-linux.tar.gz)
下载后解压,然后配置RTT_EXEC_PATH & RTT_CC_PREFIX 变量
diff --git a/bsp/x86/picolib/SConscript b/bsp/x86/picolib/SConscript
new file mode 100644
index 0000000000..74613745e0
--- /dev/null
+++ b/bsp/x86/picolib/SConscript
@@ -0,0 +1,14 @@
+Import('RTT_ROOT')
+Import('rtconfig')
+from building import *
+
+cwd = GetCurrentDir()
+
+src = Glob('*.c')
+
+CPPPATH = [cwd]
+CPPFLAGS = '-specs=picolibc.specs'
+
+group = DefineGroup('Picolib', src, depend = ['X86_BSP_USING_PICOLIBC_PORT'], CPPPATH = CPPPATH, CPPFLAGS = CPPFLAGS)
+
+Return('group')
diff --git a/bsp/x86/picolib/picolib_stdio.c b/bsp/x86/picolib/picolib_stdio.c
new file mode 100644
index 0000000000..2429a3870c
--- /dev/null
+++ b/bsp/x86/picolib/picolib_stdio.c
@@ -0,0 +1,20 @@
+#include <rtthread.h>
+#include <stdio.h>
+
+static int picolibc_putc(char c, FILE *file)
+{
+ (void)file;
+
+ if (c == '\n')
+ {
+ rt_hw_console_output("\r");
+ }
+
+ rt_hw_console_output((const char *)&c);
+ return c;
+}
+
+static FILE __stdio_out = FDEV_SETUP_STREAM(picolibc_putc, NULL, NULL, _FDEV_SETUP_WRITE);
+
+FILE *const stdout = &__stdio_out;
+FILE *const stderr = &__stdio_out;
diff --git a/bsp/x86/rtconfig.h b/bsp/x86/rtconfig.h
index 0aacb87ae0..3081c3dd25 100644
--- a/bsp/x86/rtconfig.h
+++ b/bsp/x86/rtconfig.h
@@ -351,6 +351,10 @@
/* FT32 HAL & SDK Drivers */
/* end of FT32 HAL & SDK Drivers */
+
+/* NOVOSNS Drivers */
+
+/* end of NOVOSNS Drivers */
/* end of HAL & SDK Drivers */
/* sensors drivers */
@@ -432,4 +436,9 @@
/* end of RT-Thread online packages */
#define IA32
+/* X86 Features */
+
+#define X86_BSP_USING_LIBC
+/* end of X86 Features */
+
#endif
diff --git a/bsp/x86/rtconfig.py b/bsp/x86/rtconfig.py
index b886b4d210..75e37e2ced 100644
--- a/bsp/x86/rtconfig.py
+++ b/bsp/x86/rtconfig.py
@@ -1,5 +1,9 @@
import os
+def check_config_key_enable(key):
+ if not os.path.isfile('.config'): return False
+ return (key + '=y') in open('.config').read()
+
# toolchains options
ARCH='ia32'
CPU=''
@@ -30,6 +34,9 @@ if PLATFORM == 'gcc':
OBJCPY = PREFIX + 'objcopy'
DEVICE = ' -mtune=generic'
+ if check_config_key_enable('CONFIG_X86_BSP_USING_PICOLIBC_PORT'):
+ DEVICE += ' -specs=picolibc.specs'
+
CFLAGS = DEVICE + ' -Wall'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T x86_ram.lds -nostartfiles'
diff --git a/tools/ci/toolchain.sh b/tools/ci/toolchain.sh
index 40c7badc57..c9040177ef 100755
--- a/tools/ci/toolchain.sh
+++ b/tools/ci/toolchain.sh
@@ -10,6 +10,7 @@ declare -A download_urls=(
["riscv32-esp-elf-gcc"]="https://github.com/espressif/crosstool-NG/releases/download/esp-2022r1-RC1/riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz"
["clang"]="https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-16.0.0/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz"
["i686-atxhua-newlib-elf-gcc"]="https://github.com/atxhua/i686-atxhua-newlib-elf/releases/download/15.2.0/i686-atxhua-newlib-elf-linux.tar.gz"
+["i686-atxhua-picolib-elf-gcc"]="https://github.com/atxhua/i686-atxhua-picolib-elf/releases/download/15.2.0/i686-atxhua-picolib-elf-linux.tar.gz"
)
show_help() {