HOME
Shop
  • English
  • 简体中文
HOME
Shop
  • English
  • 简体中文
  • Product Series

    • FPGA+ARM

      • GM-3568JHF

        • 1. Introduction

          • GM-3568JHF Introduction
        • 2. Quick Start

          • 01 Environment Construction
          • 02 Compilation Instructions
          • 03 Burning Guide
          • 04 Debugging Tools
          • 05 Software Update
          • 06 View information
          • 07 Test Command
          • 08 Application Compilation
          • 09 Source code acquisition
        • 3. Peripherals and Interfaces

          • USB
          • Display and touch
          • Ethernet
          • WIFI
          • Bluetooth
          • TF-Card
          • Audio
          • Serial Port
          • CAN
          • RTC
        • 4. Application Development

          • 01 UART read and write case
          • 02 Key detection case
          • 03 LED light flashing case
          • 04 MIPI screen detection case
          • 05 Read USB device information example
          • 06 FAN Detection Case
          • 07 FPGA FSPI Communication Case
          • 08 FPGA DMA read and write case
          • 09 GPS debugging case
          • 10 Ethernet Test Cases
          • 11 RS485 reading and writing examples
          • 12 FPGA IIC read and write examples
          • 13 PN532 NFC card reader case
          • 14 TF card reading and writing case
        • 5. QT Development

          • 01 ARM64 cross compiler environment construction
          • 02 QT program added automatic startup service
        • 6. Others

          • 01 Modification of the root directory file system
          • 02 System auto-start service
    • ShimetaPi

      • M4-R1

        • Introduction

          • M4-R1 Introduction
        • Get started quickly

          • OpenHarmony概述
          • 镜像烧录
          • 开发环境准备
          • Hello World应用以及部署
        • Application Development

          • getting Started

            • 第一章 ArkTS语言简介
            • 第二章 UI组件介绍和实际应用(上)
            • 第三章 UI组件介绍和实际应用(中)
            • 第四章 UI组件介绍和实际应用(下)
          • Advanced

            • 第一章 入门指引
            • 第二章 三方库的引用和使用
            • 第三章 应用编译以及部署
            • 第四章 命令行恢复出厂设置
            • 第五章 系统调试--HDC调试
            • 第六章 APP 稳定性测试
            • 第七章 应用测试
        • Equipment Development

          • 第一章 环境搭建
          • 第二章 下载源码
          • 第三章 编译源码
        • Peripherals and interfaces

          • 树莓派接口
          • GPIO 接口
          • I2C 接口
          • SPI通信
          • PWM控制
          • 串口通讯
          • TF Card
          • 屏幕
          • 触摸
          • 音频
          • RTC
          • Ethernet
          • M.2
          • MINI-PCIE
          • Camera
          • WIFI&BT
          • 树莓派拓展板
        • Frequently asked questions

          • 资源下载
      • M5-R1

        • Introduction

          • Introduction to ShimetaPi M5-R1
    • OpenHarmony

      • SC-3568HA

        • Introduction

          • SC-3568HA Overview
        • Quick Start Guide

          • OpenHarmony Overview
          • Image Flashing
          • Setting Up the Development Environment
          • Hello World Application and Deployment
        • Application Development

          • ArkUI

            • Chapter 1 Introduction to ArkTS Language
            • Chapter 2 Introduction to UI Components and Practical Applications (Part 1)
            • Chapter 3 Introduction to UI Components and Practical Applications (Part 2)
            • Chapter 4 Introduction to UI Components and Practical Applications (Part 3)
          • Expand

            • Chapter 1 Getting Started Guide
            • Chapter 2 Referencing and Using Third-Party Libraries
            • Chapter 3: Application Compilation and Deployment
            • Chapter 4: Command-Line Factory Reset
            • Chapter 5: System Debugging -- HDC (Huawei Device Connector) Debugging
            • Chapter 6 APP Stability Testing
            • Chapter 7 Application Testing
        • Device Development

          • Chapter 1 Environment Setup
          • Chapter 2 Download Source Code
          • Chapter 3 Compiling Source Code
        • Peripheral And Iinterface

          • Raspberry Pi interface
          • GPIO Interface
          • I2C Interface
          • SPI communication
          • PWM (Pulse Width Modulation) control
          • Serial port communication
          • TF Card
          • Display Screen
          • Touch
          • Audio
          • RTC
          • Ethernet
          • M.2
          • MINI-PCIE
          • Camera
          • WIFI&BT
          • Raspberry Pi expansion board
        • Frequently Asked Questions

          • Resource Downloads
      • M-K1HSE

        • Introduction

          • M-K1HSE Introduction
        • Quick Start

          • Development environment construction
          • Source code acquisition
          • Compilation Notes
          • Burning Guide
        • Peripherals and interfaces

          • 01 Audio
          • 02 RS485
          • 03 Display
        • System customization development

          • System transplant
          • System customization
          • Driver Development
          • System Debugging
          • OTA Update
    • EVS-Camera

      • CF-NRS1

        • 1. Introduction

          • Event Camera Technical Documentation
        • 2. Quick Start

          • Host driver and software installation
        • 3. SDK application development

          • API Usage Instructions
      • CF-CRA2

        • Introduction

          • About CF-NRS1
    • AI-model

      • 1684XB-32T

        • Introduction

          • AIBOX-1684XB-32 Introduction
        • Get started quickly

          • First time use
          • Network Configuration
          • Disk usage
          • Memory allocation
          • Fan Strategy
          • Firmware Upgrade
        • Deployment Tutorial

          • Algorithm deployment
          • Deploy Llama3 Example
        • Application Development

          • Sophgo SDK Development
          • Sophon LLM_api_server development
          • Deploy MiniCPM-V-2_6
          • Qwen-2-5-VL Image and Video Recognition DEMO
          • Qwen3-chat-DEMO
          • Qwen3-Qwen Agent-MCP-Demo
          • Qwen3-langchain-AI Agent
      • 1684X-416T

        • Introduction

          • AIBOX-1684X-416 Introduction
        • Demo simple operation guide

          • Simple instructions for using shimeta smart monitoring demo
    • Core-Board

      • C-3568BQ

        • Introduction

          • C-3568BQ Overview
      • C-3588LQ

        • Introduction

          • C-3588LQ Introduction
      • GC-3568JBAF

        • Introduction

          • GC-3568JBAF Introduction
      • C-K1BA

        • Introduction

          • C-K1BA Introduction

第一章 环境搭建

安装Ubuntu,推荐使用20.04版本。用户名不能包含中文。

  • 参考1:https://laval.csdn.net/648aaf800fa9cc227b4def20.html
  • 参考2:https://forums.openharmony.cn/forum.php?mod=viewthread&tid=897&extra=page%3D1&login=from_csdn

1. 安装docker

  • 参考:https://blog.csdn.net/yohnyang/article/details/138435593?fromshare=blogdetail&sharetype=blogdetail&sharerId=138435593&sharerefer=PC&sharesource=qq_29160731&sharefrom=from_link

2. 创建以下三个文件,文件名分别为dockerfile、build-container、entrycontainer

2.1 dockerfile

2.1.1 作用

  dockerfile 是一个文本文件,包含了一系列用于构建 Docker 镜像的指令。

2.1.2 创建方法

(1)cd ~
(2)mkdir proj
(3)cd ./proj
(4)vim dockerfile
(5)将以下文本粘贴进来后保存。

FROM ubuntu:18.04

ARG TARGETPLATFORM
ARG DEBIAN_FRONTEND=noninteractive
ARG userid
ARG groupid
ARG username

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8


RUN cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
RUN sed -i 's@http://.*ubuntu.com@http://repo.huaweicloud.com@g' /etc/apt/sources.list

RUN dpkg --add-architecture i386 && \
    apt-get update && \
    apt-get install -y locales && \
    localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV LANG en_US.UTF-8

RUN apt-get install --no-install-recommends --no-install-suggests --yes \
        binutils git git-lfs gnupg flex bison gperf build-essential zip \
        curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev \
        x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils \
        xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby openjdk-8-jdk \
        python3-distutils dosfstools mtools libssl-dev libelf-dev sudo vim openssh-client wget libfl-dev liblz4-tool scons  mtd-utils  u-boot-tools default-jdk cpio genext2fs gcc-arm-none-eabi && \
    apt-get clean && \
    rm -rf /var/lib/apt/* /var/cache/apt/* /tmp/* /var/tmp/*

RUN pip3 install setuptools kconfiglib

RUN pip3 install scons ecdsa pycryptodome
RUN pip3 install --upgrade --ignore-installed six
RUN rm -f /usr/bin/python
RUN ln -s /usr/bin/python3.8 python

RUN groupadd -g $groupid $username \
 && useradd -m -u $userid -g $groupid $username \
 && echo "$username:123456" | chpasswd \
 && echo $username >/root/username


RUN sed -i -e '/\%sudo/ c \%sudo ALL=(ALL) NOPASSWD: ALL' /etc/sudoers
RUN usermod -a -G sudo $username

RUN echo "root:123456" | chpasswd


ENV HOME=/home/$username
ENV USER=$username

WORKDIR $HOME

ENV HOME=/home/$username
ENV USER=$username
ENV WORKFOLDER=/home/$username/proj
ENV GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
ENV PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home'

RUN mkdir -p $WORKFOLDER


ENTRYPOINT chroot --userspec=$(cat /root/username):$(cat /root/username) / /bin/bash -c "cd $WORKFOLDER && exec /bin/bash -i"

  在第39行,使用传入的 groupid 创建组;
  在第40行,使用传入的 userid 创建用户;
  在第41行,修改用户密码为123456,可在此处将用户的默认密码自行修改为自身常用的密码;
  在第48行,将root的密码设置为123456,此处可将其修改为自身常用的密码。

2.2 build-container

2.2.1 作用

  该脚本用于:根据dockerfile创建出所需的镜像(image)。

2.2.2 创建方法

(1)cd ~/proj
(2)vim build-container
(3)将以下文本粘贴进来后保存。

#!/bin/bash

USER_ID=$(id -u)
GROUP_ID=$(id -g)
USERNAME=$(whoami)


docker build --build-arg userid=$USER_ID  --build-arg groupid=$GROUP_ID  --build-arg username=$USERNAME --tag sc3568ha2:latest .

   第3、4、5行将主机当前用户的组ID、用户ID、用户名称传递给dockerfile,在2.1所创建的dockerfile中,会根据传入的这三个参数创建一个新用户。
   第8行末尾的 " . " 用于指定dockerfile所处位置,通常我们将dockerfile、build-container、entrycontainer这三个文件都放在同一路径下,因此此处就使用 " . " ,表示dockerfile处于当前目录下。
   第8行的"sc3568ha2:latest"用于指定创建出的镜像的名称及其版本号,可自行修改,格式为"镜像名称:版本号"。
(4)chmod +x ./build-container

2.3 entrycontainer

2.3.1 作用

  该脚本用于:根据镜像创建并进入容器。

2.3.2 创建方法

(1)cd ~/proj
(2)vim entrycontainer
(3)将以下文本粘贴进来后保存。

#!/bin/bash

set -e

HOME_DIR="/home/xxx/proj"
BUILD_DIR="/home/xxx/proj"


docker run --privileged  --volume ${BUILD_DIR}:${HOME_DIR}:rw --volume /tmp:/tmp \
  --workdir=${HOME_DIR} \
  --env TERM=xterm-256color --env SHELL=/bin/bash \
  --rm --init --tty --interactive \
  --hostname docker_OP \
  sc3568ha2:latest

  使用docker的一个便利之处在于可以将主机文件夹映射到容器中,我们进入到容器中后,仿佛是在使用一台新的电脑的同时,还可以访问主机的指定文件夹。
  第9行的"--volume ${BUILD_DIR}:${HOME_DIR}:rw"是实现这一映射功能的语句,其将主机文件夹BUILD_DIR映射到容器的路径HOME_DIR下面,当我们进入容器中后,可以在路径HOME_DIR下面访问主机文件夹BUILD_DIR下面的所有文件。
  第6行的路径通常也是"/home/xxx/proj",与容器内路径一致,以避免混淆。其中,xxx是当前用户的用户名称。
(4)chmod +x ./entrycontainer

3. 创建镜像

cd ~/proj
bash ./build-container

4. 进入容器

cd ~/proj
bash ./entrycontainer

5. 配置默认命令行解释器为bash

ls -l /bin/sh                   #如果显示为“/bin/sh -> bash”则为正常,否则请以以下方式修改:
sudo dpkg-reconfigure dash      #然后选择no
Edit this page on GitHub
Last Updated:
Contributors: zwhuang
Next
第二章 下载源码