Welcome to RDK S600 Developer Kit repository
1. AI large model environment deployment
AI large model environment deployment
The SSD mounting and Ollam model download path changes are optional for users.
AI large model environment deployment1. Large Language Models (LLM)2. Ollam InstallationScript Installation3. Using Ollam4. Uninstalling Ollama5. Memory Allocation Adjustment1. Insufficient Available Memory at Factory Start2. Customers who need to adjust memory can continue reading6. SSD Mounting (Optional)The following are the mounting instructions for SSDs not included in the package:7. Changing the Ollama Model Download Path (Optional)8. Setting up the LargeModel Environment (Must Read!!!)References
Demo Environment
Development Board: RDK S600 Motherboard
Ollama is an open-source tool designed to simplify the deployment and operation of large language models, allowing users to use high-quality language models in their local environment.
1. Large Language Models (LLM)
Large Language Models (LLMs) are a class of advanced text generation systems based on artificial intelligence. Their main characteristic is their ability to learn and understand human language through large-scale training data and generate natural and fluent text.
2. Ollam Installation
Ollama is pre-installed in the YAHBOOM image.
Note: Ollam pull failures are normal. You can try multiple times, or try pulling using a proxy. You'll need to search online for instructions on using a proxy.
Script Installation
sudo apt install curl -ysudo curl -fsSL https://ollama.com/install.sh | sh

The entire installation process takes a relatively long time. Please be patient!
Once the installation is complete, a warning message will appear; ignore it:

Use ollama -v to check the Ollam version number:

3. Using Ollam
Type ollama in the terminal to see usage prompts:

| Command | Function |
|---|---|
| ollama serve | Start Ollam |
| ollama create | Create a model from a model file |
| ollama show | Display model information |
| ollama run | Run a model |
| ollama stop | Stop a running model |
| ollama pull | Pull a model from the registry |
| ollama push | Push a model to the registry |
| ollama list | List models |
| ollama ps | List running models |
| ollama cp | Copy a model |
| ollama rm | Delete a model |
| ollama help | Get help information for any command |
4. Uninstalling Ollama
- Delete service
xxxxxxxxxxsudo systemctl stop ollamasudo systemctl disable ollamasudo rm /etc/systemd/system/ollama.service
- Delete file
xxxxxxxxxxsudo rm $(which ollama)
- Delete model and service user and group
xxxxxxxxxxsudo rm -r /usr/share/ollamasudo userdel ollamasudo groupdel ollama
5. Memory Allocation Adjustment
1. Insufficient Available Memory at Factory Start
Newly manufactured RDK S600 motherboards may have very little available memory. You can run the following two commands to update and increase the available memory:
xxxxxxxxxxsudo apt updatesudo apt upgrade
After updating, restart. You can then use the free -h command to see that your memory has increased.
2. Customers who need to adjust memory can continue reading
RDK provides a flexible memory allocation adjustment scheme.
This scheme supports multiple memory strategies and can be quickly switched according to the application scenario (such as BPU priority, CPU priority, or balanced mode).
Since our factory-installed available memory is relatively small, some large models with large amounts of data cannot run, so we need to increase the available memory.
- Open a terminal and enter the following commands:
xxxxxxxxxxcd /usr/hobot/bin/
Script Name: hb_switch_ion.sh
The script location is shown in the figure.

The script code is as follows:
x#!/bin/bashRED='\033[0;31m'GREEN='\033[0;32m'YELLOW='\033[0;33m'NC='\033[0m'log_error() {echo -e "${RED}[ERROR] $1${NC}" >&2}log_warn() {echo -e "${YELLOW}[WARN] $1${NC}" >&2}log_info() {echo -e "${GREEN}[INFO]${NC} $1"}help_msg(){log_info "Usage: $0 <bpu_first | cpu_first | balanced | default>"log_info "Example: $0 bpu_first"exit 1}if [ $# -ne 1 ]; thenhelp_msgfitarget=$1# Check if dtc command existsif ! command -v fdtput &> /dev/null; thenapt updateapt install device-tree-compiler -yfifunction get_dtb(){boardid_sys_path="/sys/class/boardinfo/adc_boardid"if [ -f "$boardid_sys_path" ]; thenboardid="$(cat $boardid_sys_path)"# get chipif [[ "$boardid" =~ ^0x(51)[1234567][01234567][1234567][1234567].$ ]]; then# S600echo "rdk-s600-mcb-v0p1.dtb"else# S100case $boardid in*"64"*) ;&*"65"*)chip_str="s100p";;*"6A"*) ;&*"6B"*)chip_str="s100";;esaccase $boardid in*"60")hw_str="v1-21";;*"70")hw_str="v1-20";;*"84")hw_str="v0p5";;*"85")hw_str="v0p6";;*"86")hw_str="v1p0";;esacecho "rdk-${chip_str}-${hw_str}.dtb"fielseecho "Invalid"fi}dtb_name=$(get_dtb)if [ "$dtb_name" = "Invalid" ];thenlog_error "Cannot find valid dtb for current board!"exit 1fiINPUT_DTB="/boot/hobot/${dtb_name}"ORIG_INPUT_DTB="${INPUT_DTB}.bak"OUTPUT_DTB="${INPUT_DTB}"function reset_dtb(){log_info "Restoring to default..."if [ -f "${ORIG_INPUT_DTB}" ];thencp "${ORIG_INPUT_DTB}" "${OUTPUT_DTB}"rm "${ORIG_INPUT_DTB}"fi}case $target in"balanced")if [[ "${INPUT_DTB}" = *"-s600-"* ]];then #total size 16GiB# ion-pool 2048MiBion_pool_reg_val=(0x40 0xC0000000 0x0 0x80000000)# ion-carveout 10480MiBion_carveout_reg_val=(0x41 0x40000000 0x2 0x80000000)# ion-cam 2048MiBion_cma_reg_val=(0x43 0xC0000000 0x0 0x80000000)# ion-uncache 2048MiBion_uncache_reg_val=(0x44 0x40000000 0x0 0x80000000)elif [[ "${INPUT_DTB}" = *"-s100p-"* ]];then# ion-pool 7680MiBion_pool_reg_val=(0x4 0x00000000 0x1 0xe0000000)# ion-carveout 128MiBion_carveout_reg_val=(0x8 0x00000000 0x0 0x08000000)# ion-cam 128MiBion_cma_reg_val=(0xc 0x80000000 0x0 0x08000000)else# ion-pool 3840MiBion_pool_reg_val=(0x4 0x00000000 0x0 0xF0000000)# ion-carveout 1280MiBion_carveout_reg_val=(0x8 0x00000000 0x0 0x50000000)# ion-cam 1GiBion_cma_reg_val=(0xc 0x80000000 0x0 0x40000000)fi;;"bpu_first")if [[ "${INPUT_DTB}" = *"-s600-"* ]];then #total size 28GiB# ion-pool 5120MiBion_pool_reg_val=(0x40 0xC0000000 0x1 0x40000000)# ion-carveout 13312MiBion_carveout_reg_val=(0x42 0x00000000 0x3 0x40000000)# ion-cma 5120MiBion_cma_reg_val=(0x45 0x40000000 0x1 0x40000000)# ion-uncache 5120MiBion_uncache_reg_val=(0x46 0x80000000 0x1 0x40000000)elif [[ "${INPUT_DTB}" = *"-s100p-"* ]];then# ion-pool 5120MiBion_pool_reg_val=(0x4 0x00000000 0x1 0x40000000)# ion-carveout 5120MiBion_carveout_reg_val=(0x8 0x00000000 0x1 0x40000000)# ion-cma 5120MiBion_cma_reg_val=(0xc 0x80000000 0x1 0x40000000)else# ion-pool 3840MiBion_pool_reg_val=(0x4 0x00000000 0x0 0xF0000000)# ion-carveout 3840MiBion_carveout_reg_val=(0x8 0x00000000 0x0 0xF0000000)# ion-cma 1GiBion_cma_reg_val=(0xc 0x80000000 0x0 0x40000000)log_warn "CAUTION! Setting bpu_first on S100 might introduce random performance issue due to limited memory!"fi;;"cpu_first")if [[ "${INPUT_DTB}" = *"-s600-"* ]];then #total size 7GiB# ion-pool 2048MiBion_pool_reg_val=(0x40 0xC0000000 0x0 0x80000000)# ion-carveout 2048MiBion_carveout_reg_val=(0x41 0x40000000 0x0 0x80000000)# ion-cma 1024MiBion_cma_reg_val=(0x41 0xC0000000 0x0 0x40000000)# ion-uncache 2048MiBion_uncache_reg_val=(0x42 0x00000000 0x0 0x80000000)else# ion-pool 1GiBion_pool_reg_val=(0x4 0x00000000 0x0 0x40000000)# ion-carveout 512MiBion_carveout_reg_val=(0x8 0x00000000 0x0 0x20000000)# ion-cma 512MiBion_cma_reg_val=(0xc 0x80000000 0x0 0x20000000)fi;;"default")reset_dtbexit 0;;*)log_error "Invalid option $target"help_msg;;esac# Set ion region sizes according to inputusage=$(df -h /boot | awk 'NR==2 {print $5}' | sed 's/%//')if [ "$usage" -ge 95 ]; thenlog_error "/boot partition is full(${usage} used), cannot update dtb!"log_info "Maybe you should run the following command to resize the filesystem:"log_info " sudo resize2fs /dev/block/platform/by-name/boot_cur"exit 1fiif [ ! -f "${ORIG_INPUT_DTB}" ];thencp "${INPUT_DTB}" "${ORIG_INPUT_DTB}"log_info "Backup created:${ORIG_INPUT_DTB}"elselog_info "Backup(${ORIG_INPUT_DTB}) already exists, skip backup..."fifdtput -t x "$INPUT_DTB" /reserved-memory/ion_reserved reg \"${ion_pool_reg_val[@]}" || {log_error "Update ion-pool reg failed!"reset_dtbexit 1}fdtput -t x "$INPUT_DTB" /reserved-memory/ion_carveout reg \"${ion_carveout_reg_val[@]}" || {log_error "Update ion_carveout reg failed!"reset_dtbexit 1;}fdtput -t x "$INPUT_DTB" /reserved-memory/ion_cma reg \"${ion_cma_reg_val[@]}" || {log_error "Update ion_cma reg failed!"reset_dtbexit 1}if [[ "${INPUT_DTB}" = *"-s600-"* ]];thenfdtput -t x "$INPUT_DTB" /reserved-memory/ion_uncache reg \"${ion_uncache_reg_val[@]}" || {log_error "Update ion_uncache reg failed!"reset_dtbexit 1}filog_info "ion_reserved reg = <$(fdtget -t x "$INPUT_DTB" /reserved-memory/ion_reserved reg)>"log_info "ion_carveout reg = <$(fdtget -t x "$INPUT_DTB" /reserved-memory/ion_carveout reg)>"log_info "ion_cma reg = <$(fdtget -t x "$INPUT_DTB" /reserved-memory/ion_cma reg)>"if [[ "${INPUT_DTB}" = *"-s600-"* ]];thenlog_info "ion_uncache reg = <$(fdtget -t x "$INPUT_DTB" /reserved-memory/ion_uncache reg)>"filog_info "Update ${INPUT_DTB} for $target Done!"log_info "The change will take effect AFTER reboot!"
2.Next, run the following in the terminal:
xxxxxxxxxxsudo ./hb_switch_ion.sh cpu_first

Finally, restart the motherboard, and then use the free -h command to see the changes in your memory allocation.
This script supports modification of the following four modes:
| Mode Name | Description |
|---|---|
| bpu_first | Prioritizes memory allocation for BPUs, suitable for AI algorithm inference scenarios |
| cpu_first | Prioritizes memory allocation for CPUs, suitable for traditional computing load scenarios |
| balanced | Balances memory allocation between BPUs and CPUs, suitable for general scenarios |
| default | Restores factory default memory allocation (restores to .bak backup) |
Our Ollama system relies entirely on CPU computation for running large models, so we use the cpu_first option.
6. SSD Mounting (Optional)
For UFS-booted systems only; skip this section if booting from NVMe.
Models pulled by Ollama are stored in UFS by default, consuming onboard storage space. You can expand storage with a solid-state drive and store large models on it. Simply follow the guide to change the model path used by Ollama or fastsdcpu to the SSD, so that existing models on the SSD can be accessed directly.
Ollama Model Specification: Skip to point 4 of 7. Changing the Ollama Model Download Path (Optional) in this tutorial and modify ollama.service to begin.
FastSD CPU Model Specification: Before starting the FastSD CPU web UI, enter export HF_HOME=/media/ssd/HF_Model and then start it. If you find it troublesome to type this every time you start the computer, you can directly add it to your .bashrc file.
The default mount path for the SSD included in the package is: /media/ssd
The following are the mounting instructions for SSDs not included in the package:
- Open a terminal and enter the command to open Disks:
xxxxxxxxxxsudo gnome-disks
- In the left sidebar of Disks, select the SSD you connected, and then click the three dots in the upper right corner of the interface. Then click Format DIsk

- The default selection is fine; no changes are needed. Just click Format.

- Click Format.

- Click the plus sign to create a new partition.

- You can freely modify the partition size according to your needs. Here, I've defaulted to creating a 128GB partition. Click Next to proceed.

- Enter the disk name. The disk format must be Ext4; do not change it. Then click Create to create the partition.

- After successful creation, click the play button to mount the SSD.

- After successful mounting, you can see the SSD's mount path. In my case, it's located under /media/ssd.

- Then we can see an SSD icon in the left sidebar of the desktop. We can click to enter the disk's folder, but we'll find that we don't have read or write permissions. At this point, we need to open a terminal and execute the command to use the disk normally:
xxxxxxxxxxsudo chmod 777 /media/ssd #Here, /media/ssd needs to be modified according to your SSD's mount path.

- Finally, we need to set the hard drive to be automatically mounted at boot. First, enter the following command to query the SSD's UUID:
xxxxxxxxxxlsblk -f

- Open fstab
xxxxxxxxxxsudo vim /etc/fstab
Add the following text to the end, save and exit:
xxxxxxxxxxUUID=6ccb37c8-2db7-4b66-ab03-bce4bc78e825 /media/ssd ext4 defaults 0 2#The content after UUID needs to be modified to your own value, which can be found in the lsblk -f command above.

7. Changing the Ollama Model Download Path (Optional)
Model download path modification applies only to systems booting from UFS.
On Linux systems, the default download path for Ollama models is:
xxxxxxxxxx/usr/share/ollama/.ollama/models
- First, stop the Ollama service:
xxxxxxxxxxsystemctl stop ollama.service
- Create a new folder on your SSD to store the models using the following commands:
xxxxxxxxxxsudo mkdir -p /media/ssd/ollama/models # The /media/ssd here needs to be modified according to your SSD mount path
- Then, add permissions to the model folder:
xxxxxxxxxxsudo chown -R sunrise:sunrise /media/ssd/ollama/modelssudo chmod -R 777 /media/ssd/ollama/models
- Next, we open ollama.service
xxxxxxxxxxsudo vim /etc/systemd/system/ollama.service
Add a new line under [Service]: Environment, then save and exit:
xxxxxxxxxxEnvironment="OLLAMA_MODELS=/media/ssd/ollama/models" # Remember to change the path!!!

- Execute the following command to refresh the configuration:
xxxxxxxxxxsudo systemctl daemon-reload
- Restart the ollama service and check its status:
xxxxxxxxxxsudo systemctl restart ollama.servicesudo systemctl status ollama
At this point, the ollama model download path has been modified. New models pulled using ollama will be downloaded to the ollama/models folder on the SSD, reducing the space occupied by the eMMC.
8. Setting up the LargeModel Environment (Must Read!!!)
Largemodel is pre-installed in the YAHBOOM image.
The AI large-model multimodal applications in later chapters of this tutorial all require the LargeModel package to function properly.
- Locate the largemodel.zip compressed file in the source code folder of your cloud drive. You can use a transfer tool like WinSCP to place the compressed file in your home directory, which is your ~ directory. Then run the command to decompress it:
xxxxxxxxxxunzip largemodel.zip
- Run the installation script:
After decompression, first navigate to the LargeModel package:
xxxxxxxxxxcd ~/yahboom_ws/src/largemodel/
Then run the installation script:
xxxxxxxxxxchmod +x temp_install_script.sh #Add script execution permissions./temp_install_script.sh
When running the script, it will ask if you are using a mainland China network. If so, enter 'Y' to switch to the Alibaba Cloud mirror source, which will speed up the environment download.

- Install the colcon tool
xxxxxxxxxxsudo apt updatesudo apt install python3-colcon-common-extensions- Add environment variables Enter the following commands:
xxxxxxxxxxecho 'source /opt/ros/jazzy/setup.bash' >> ~/.bashrcecho 'source ~/yahboom_ws/install/setup.bash' >> ~/.bashrc
The file ~/yahboom_ws/install/setup.bash is generated only after running colcon build. You may ignore the file-not-found warning here.
Then enter:
xxxxxxxxxxsource ~/.bashrc
- Enter the workspace to compile
xxxxxxxxxxcd ~/yahboom_wscolcon build && source ~/yahboom_ws/install/setup.bash
- Start the program:
xxxxxxxxxxros2 launch largemodel largemodel_control.launch.py
This command is in voice mode and requires the AI large model voice module of the Yaboom RDK S600 to be connected. It detects the ttyUSB0 port number by default. For text input mode, please refer to subsequent tutorials.
References
Ollama
Official Website: https://ollama.com/
GitHub: https://github.com/ollama/ollama