发帖
10 0 1

【BW20-12F开发板评测】1、统信UOS搭建开发环境

sujingliang
论坛元老

27

主题

17

回帖

8971

积分

论坛元老

积分
8971
BW系列 830 10 2025-11-5 13:57:57
[i=s] 本帖最后由 sujingliang 于 2025-11-6 08:43 编辑 [/i]

已经用上信创电脑,操作系统是统信UOS(1070),基于LINUX4.19.0版本,完全可以用来搭建开发环境。

一、资料收集

参考瑞昱官方文档:

https://aiot.realmcu.com/cn/latest/rst_rtos/rst_sdk/0_ameba_sdk_download/index.html

二、开发环境搭建

1、SDK下载

git clone https://github.com/Ameba-AIoT/ameba-rtos.git

或:

git clone https://gitee.com/ameba-aiot/ameba-rtos.git

2、安装Python

apt安装

sudo apt install python3 python3-pip python3-venv

由于统信UOS apt安装python只支持最高3.7版本,不满足要求。因此使用pyenv安装python

# 1.安装 pyenv
curl https://pyenv.run | bash
# 2. 重新配置 shell(根据你的 shell 选择)
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc

# 3. 安装依赖和 Python 3.12.0
sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
pyenv install 3.12.0
pyenv global 3.12.0

3、软件合集包下载

主要包括Cmake,ninja等,如果系统中已经安装了这些,可以不用下载

mkdir /opt/rtk-toolchain
cd /opt/rtk-toolchain
wget https://github.com/Ameba-AIoT/ameba-toolchain/releases/download/prebuilts-v1.0.3/prebuilts-linux-1.0.3.tar.gz
tar -xzf prebuilts-linux-1.0.3.tar.gz

也可以使用阿里地址:

wget https://rs-wn.oss-cn-shanghai.aliyuncs.com/prebuilts-linux-1.0.3.tar.gz

后面交叉编译工具也会下载到这个路径,可以修改下权限,避免下载失败:
chmod 777 /opt/rtk-toolchain

4、安装依赖库

sudo apt install libssl-dev libncurses5

5、配置环境

进入 SDK 根目录,运行 ameba.sh 脚本,自动配置环境变量:

source ameba.sh

截图_20251105131505.png

6、安装工具链

第一次编译项目时被自动安装到默认路径下: /opt/rtk-toolchain

cd amebadplus_gcc_project
build.py

截图_20251105132441.png

工具链压缩包默认托管在 GitHub 上,首次编译时会尝试从 GitHub 下载工具链压缩包。

如果不好访问Github,可以访问阿里云地址:

build.py -D USE_ALIYUN_URL=True

三、点灯

每次进入开发环境先需要输入:source ameba.sh

新建led_test目录:

截图_20251105133145.png

1、led.c


#include "ameba_soc.h"
#include "gpio_ext.h"
#include "os_wrapper.h"
#include <stdio.h>

void raw_gpio_demo(void)
{
	/* Enable GPIO function and clock */
	// RCC_PeriphClockCmd(APBPeriph_GPIO, APBPeriph_GPIO_CLOCK, ENABLE);
	printf("example_raw_gpio_light_weight\n");

	GPIO_InitTypeDef GPIO_InitStruct_LED;

	// init LED control pin
	GPIO_InitStruct_LED.GPIO_Pin = GPIO_LED_PIN1;
	GPIO_InitStruct_LED.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_Init(&GPIO_InitStruct_LED);
	GPIO_InitStruct_LED.GPIO_Pin = GPIO_LED_PIN2;
	GPIO_Init(&GPIO_InitStruct_LED);
	GPIO_InitStruct_LED.GPIO_Pin = GPIO_LED_PIN3;
	GPIO_Init(&GPIO_InitStruct_LED);
	GPIO_InitStruct_LED.GPIO_Pin = GPIO_LED_PIN4;
	GPIO_Init(&GPIO_InitStruct_LED);
	GPIO_InitStruct_LED.GPIO_Pin = GPIO_LED_PIN5;
	GPIO_Init(&GPIO_InitStruct_LED);


	while (1) {

	GPIO_WriteBit(GPIO_LED_PIN1, 1);
	GPIO_WriteBit(GPIO_LED_PIN5, 0);
	rtos_time_delay_ms(1000);
	GPIO_WriteBit(GPIO_LED_PIN1, 0);
	GPIO_WriteBit(GPIO_LED_PIN2, 1);
	rtos_time_delay_ms(1000);
	GPIO_WriteBit(GPIO_LED_PIN2, 0);
	GPIO_WriteBit(GPIO_LED_PIN3, 1);
	rtos_time_delay_ms(1000);
	GPIO_WriteBit(GPIO_LED_PIN3, 0);
	GPIO_WriteBit(GPIO_LED_PIN4, 1);
	rtos_time_delay_ms(1000);
	GPIO_WriteBit(GPIO_LED_PIN4, 0);
	GPIO_WriteBit(GPIO_LED_PIN5, 1);
	rtos_time_delay_ms(1000);
	}
}

int example_raw_gpio_light_weight(void)
{
	if (RTK_SUCCESS != rtos_task_create(NULL, "RAW_GPIO_DEMO_TASK", (rtos_task_t)raw_gpio_demo, (void *)NULL, (128 * 16),
										(1))) {
		printf("Create RAW_GPIO_DEMO_TASK Err!!!\n");
	}

	// rtos_sched_start();
	return 0;
}

2、led_example.c

#include "gpio_ext.h"

void app_example(void)
{
	example_raw_gpio_light_weight();
}

3、gpio_ext.h

ifndef GPIO_EXT_H
#define GPIO_EXT_H
#include "platform_autoconf.h"

#if defined (CONFIG_AMEBADPLUS)
#define GPIO_LED_PIN1		_PB_17
#define GPIO_LED_PIN2		_PB_18
#define GPIO_LED_PIN3		_PB_19
#define GPIO_LED_PIN4		_PB_20
#define GPIO_LED_PIN5		_PB_21
#define GPIO_PUSHBT_PIN		_PA_12


extern int example_raw_gpio_light_weight(void);
#endif

4、CMakeLists.txt

##########################################################################################
## * This part defines public part of the component
## * Public part will be used as global build configures for all component

set(public_includes)                #public include directories, NOTE: relative path is OK
set(public_definitions)             #public definitions
set(public_libraries)               #public libraries(files), NOTE: linked with whole-archive options

#----------------------------------------#
# Component public part, user config begin

# Component public part, user config end
#----------------------------------------#

#WARNING: Fixed section, DO NOT change!
ameba_global_include(${public_includes})
ameba_global_define(${public_definitions})
ameba_global_library(${public_libraries}) #default: whole-archived

##########################################################################################
## * This part defines private part of the component
## * Private part is used to build target of current component
## * NOTE: The build API guarantees the global build configures(mentioned above)
## *       applied to the target automatically. So if any configure was already added
## *       to public above, it's unnecessary to add again below.

#NOTE: User defined section, add your private build configures here
# You may use if-else condition to set these predefined variable
# They are only for ameba_add_internal_library/ameba_add_external_app_library/ameba_add_external_soc_library
set(private_sources)                 #private source files, NOTE: relative path is OK
set(private_includes)                #private include directories, NOTE: relative path is OK
set(private_definitions)             #private definitions
set(private_compile_options)         #private compile_options

#------------------------------#
# Component private part, user config begin

ameba_list_append(private_sources
    led.c
    led_example.c
)

# Component private part, user config end
#------------------------------#

#WARNING: Select right API based on your component's release/not-release/standalone

###NOTE: For open-source component, always build from source
ameba_add_internal_library(led_test
    p_SOURCES
        ${private_sources}
    p_INCLUDES
        ${private_includes}
    p_DEFINITIONS
        ${private_definitions}
    p_COMPILE_OPTIONS
        ${private_compile_options}
)

##########################################################################################

5、编译

cd amebadplus_gcc_project

build.py -a ~/mcu/Ameba-rtos/my_project/led_test

截图_20251105134444.png

6、下载

flash.py -p /dev/ttyCH341USB0

截图_20251105134856.png

──── 0人觉得很赞 ────

使用道具 举报

学习学习
期待更多评测!
可以,国产系统也能搭建了。赞👍
2025-11-5 16:07:04
点赞
2025-11-5 16:35:00

错误.png

请教一下,我参照你的在debian12配置的环境,已经成功编译默认工程,照抄你的点灯代码,编译提示配置错误,帮忙指导一下,看看哪里的问题。感谢

2025-11-5 16:37:39
zzbinfo 发表于 2025-11-5 16:35
请教一下,我参照你的在debian12配置的环境,已经成功编译默认工程,照抄你的点灯代码,编译提示配置错误 ...

除了路径做了修改,其他都是照抄的,不知道哪里的配置项出错了。
2025-11-6 08:35:34
zzbinfo 发表于 2025-11-5 16:35
请教一下,我参照你的在debian12配置的环境,已经成功编译默认工程,照抄你的点灯代码,编译提示配置错误 ...

看着好像说led_test.c没有找到,是这个引起的报错吧可能。可以检查下那个路径下有这个文件吗。
2025-11-6 08:40:17
zzbinfo 发表于 2025-11-5 16:37
除了路径做了修改,其他都是照抄的,不知道哪里的配置项出错了。

有没有可能是 CMakeLists.txt 里面配置的 led_test.c 然后 文件名 起的是 led.c
2025-11-6 09:39:01
WT_0213 发表于 2025-11-6 08:40
有没有可能是 CMakeLists.txt 里面配置的 led_test.c 然后 文件名 起的是 led.c

是我搞错了路径,里面的大小写搞错了。
您需要登录后才可以回帖 立即登录
高级模式
12下一页
统计信息
  • 会员数: 30488 个
  • 话题数: 44655 篇