2. Python Installation

APT Installation:

sudo apt install python3 python3-pip python3-venv

Since UnionTech OS (UOS) APT installation only supports up to Python 3.7, which does not meet the requirements. Therefore, use pyenv to install Python.

# 1. Install pyenv

curl https://pyenv.run | bash

 

# 2. Reconfigure shell (choose according to your 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. Install dependencies and 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. Software Suite Download

Mainly includes CMake, ninja, etc. If these are already installed on your system, you can skip this step.

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

You can also use the Aliyun address:

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

The cross-compilation toolchain will also be downloaded to this path later. You can modify the permissions to avoid download failures:

chmod 777 /opt/rtk-toolchain

4. Install Dependency Libraries

sudo apt install libssl-dev libncurses5

5. Configure Environment

Enter the SDK root directory and run the ameba.sh script to automatically configure environment variables:

source ameba.sh

 

6. Install Toolchain

The toolchain is automatically installed to the default path  /opt/rtk-toolchain during the first project compilation:

cd amebadplus_gcc_project

build.py

 

The toolchain package is hosted on GitHub by default, and the system will attempt to download it from GitHub during the first compilation. If you have difficulty accessing GitHub, you can use the Aliyun URL:

build.py -D USE_ALIYUN_URL=True

III. LED Blinking Test

Every time you enter the development environment, you must first run: source ameba.sh

Create a new led_test directory:

 

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;

}

 

3、gpio_ext.h

ifndef...
Read more »