mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-08-18 02:58:57 +08:00
Add picolib support to bsp/x86, default to newlib
- add i686-atxhua-picolib-elf-gcc toolchain
- add picolib option to bsp/x86
- add necessary picolib require library
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 变量
|
||||
|
||||
@@ -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')
|
||||
@@ -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;
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user