Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/manual_dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions bsp/x86/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

#
Expand Down Expand Up @@ -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
20 changes: 20 additions & 0 deletions bsp/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
55 changes: 55 additions & 0 deletions bsp/x86/README.md
Original file line number Diff line number Diff line change
@@ -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的方法。

## 编译
Expand All @@ -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 变量
Expand Down
14 changes: 14 additions & 0 deletions bsp/x86/picolib/SConscript
Original file line number Diff line number Diff line change
@@ -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')
20 changes: 20 additions & 0 deletions bsp/x86/picolib/picolib_stdio.c
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 9 additions & 0 deletions bsp/x86/rtconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -432,4 +436,9 @@
/* end of RT-Thread online packages */
#define IA32

/* X86 Features */

#define X86_BSP_USING_LIBC
/* end of X86 Features */

#endif
7 changes: 7 additions & 0 deletions bsp/x86/rtconfig.py
Original file line number Diff line number Diff line change
@@ -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=''
Expand Down Expand Up @@ -30,6 +34,9 @@
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'
Expand Down
1 change: 1 addition & 0 deletions tools/ci/toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading