Embedded Linux: configuration of ubuntu development environment of dongshanpai No.1


Recently, I want to learn Embedded Linux. I checked it on the Internet and was scared to death by the price. Basically, it is four or five hundred or more. Finally, I found the board of Dongshan sect No. 1. The main board and the bottom board add up to more than 200. This paper mainly introduces the construction of the embedded Linux development environment of this board, including the link of related materials, cross compilation environment, and tftp uploading program to the board. When buying a board, it is recommended to buy both the motherboard and the backplane, because the network interface of the backplane is required when uploading programs.

(1) Links to related materials

  1. Dongshan Pai No. 1 official document: https://dongshanpi.com/DongshanPi-One/01-BoardIntroduction/
  2. MobaXterm can access the page https://mobaxterm.mobatek.net/ Get (recommended).
  3. Official document of cross compilation environment configuration https://dongshanpi.com/DongshanPi-One/05-GetSourceCode/

(2) Power on connection

1. Install MobaXterm

Before connecting the computer, you need to install MobaXterm serial port access software. You can go to https://mobaxterm.mobatek.net/ Download and install.

2. Use Type-C cable to connect the board to a computer

reference resources

3. Log in to the serial port with mobxterm

Open MobaXterm, click "Session" in the upper left corner, and select "Serial" in the pop-up interface. As shown in the following figure, select port number (port number COM21 shown in the device manager), baud rate (Speed 115200), Flow Control (Flow Control: none), and finally click "OK". The steps are shown in the following figure. Note: Flow Control must select none, otherwise you will not be able to input data connection to Serial port in MobaXterm

4. Success interface

(3) ubuntu cross environment configuration

Before the environment configuration, you need to have a ubuntu 18.04 system environment. You can use VMWARE to run dual systems, or you can install the ubuntu 18.04 subsystem under win10. I use the ubuntu subsystem of win10 here.
To configure win10 ubuntu subsystem, please refer to https://blog.csdn.net/liangzc1124/article/details/108952232
reference resources

1. Install the Lib & tool required for compilation

book@100ask:~$ sudo apt-get install libc6-dev-i386
book@100ask:~$ sudo apt-get install lib32z1 lib32ncurses5
book@100ask:~$ sudo apt-get install libuuid1:i386
book@100ask:~$ sudo apt-get install cmake
book@100ask:~$ sudo apt-get install libncurses5-dev libncursesw5-dev
book@100ask:~$ sudo apt install bc
book@100ask:~$ sudo apt-get install xz-utils
book@100ask:~$ sudo apt-get install automake
book@100ask:~$ sudo apt-get install libtool
book@100ask:~$ sudo apt-get install libevdev-dev
book@100ask:~$ sudo apt-get install pkg-config
book@100ask:~$ sudo apt-get install openssh-server
book@100ask:~$ sudo apt-get install repo
//Change sh to bash
book@100ask:~$  sudo rm /bin/sh
book@100ask:~$  sudo ln -s /bin/bash /bin/sh

2. Get the source code

book@100ask:~$ git clone https://e.coding.net/codebug8/repo.git
book@100ask:~$ mkdir DongshanPiOne-TAKOYAKI  && cd  DongshanPiOne-TAKOYAKI
book@100ask:~/DongshanPiOne-TAKOYAKI$ ../repo/repo init -u  https://gitee.com/weidongshan/manifests.git -b linux-sdk -m  SSD202D/dongshanpi-one_takoyaki_dlc00v030.xml --no-repo-verify
book@100ask:~/DongshanPiOne-TAKOYAKI$ ../repo/repo sync -j4

3. Add environment variables

//Open environment variable file
book@100ask:~$ vim  ~/.bashrc
//Add or modify the following lines at the end of the line:
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=$PATH:/home/book/DongshanPiOne-TAKOYAKI/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf/bin
//Execute source ~ / The bashrc command takes effect
source ~/.bashrc

4. Test compilation environment

book@100ask:~$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
Target: arm-linux-gnueabihf
Configured with: /tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/gcc/configure --target=arm-linux-gnueabihf --prefix= --with-sysroot=/arm-linux-gnueabihf/libc --with-build-sysroot=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/install//arm-linux-gnueabihf/libc --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --disable-libsanitizer --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-mpfr=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-mpc=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-isl=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-arch=armv7-a --with-fpu=neon --with-float=hard --with-arch=armv7-a --with-pkgversion='GNU Toolchain for the A-profile Architecture 8.2-2018-08 (arm-rel-8.23)'
Thread model: posix
gcc version 8.2.1 20180802 (GNU Toolchain for the A-profile Architecture 8.2-2018-08 (arm-rel-8.23))

(4) Connect the board and the computer through the network cable

1. Wiring

If your computer has an RJ45 interface, you can connect the board with two RJ45 interfaces. If not, you can connect the computer with a USB to RJ45 interface.

2. Set windows routing IP


After physically connecting to the board, check the network connection on windows,
Right click, click status, and then set IP and mask according to the following sequence

3. Set the board routing IP

Connect the board through MobaXterm and set the IP through the following command

//set up
ifconfig eth0

4. Test network connectivity

Before testing, ensure that the firewall is closed

Enter the command on the board: ping

Enter the command on ubuntu: ping

(5) Installing TFTP

1.ubuntu end

//Install software 
sudo apt-get install tftp-hpa tftpd-hpa
//Then, create the TFTP server working directory and open the TFTP service configuration file, as follows:
mkdir -p /home/book/tftpboot
sudo chmod 777 /home/book/tftpboot
sudo vim /etc/default/tftpd-hpa
//In the configuration file / etc / default / tftpd HPA, add the following fields:
TFTP_OPTIONS="-l -c -s"
//Finally, restart the TFTP service:
sudo service tftpd-hpa restart
//Check whether the tftp service is running. Run the following command to check whether it is running in the background.
ps -aux | grep "tftp"

2. Upload and download board end files

//Embedded development board download ubuntu
tftp -g -r hello

//Embedded development board sending
tftp -p -l note.txt

(6) helloworld

1. Compile hello.c

/* Execute the command: / hello weidongshan
 * argc = 2
 * argv[0] = ./hello
 * argv[1] = weidongshan
#include <stdio.h>
int main(int argc, char **argv)
        if (argc >= 2)
                printf("Hello, %s!\n", argv[1]);
                printf("Hello, world!\n");
        return 0;

2.ubuntu test compilation

gcc hello.c -o hello
./hello lingcb

3. Cross compilation

//Cross compilation
arm-linux-gnueabihf-gcc hello.c -o hello
//Move to the root directory of ubuntu tftp server / home/book/tftpboot
cp hello /home/book/tftpboot
ls /home/book/tftpboot

4. The board obtains the compiled program through tftp

/home # tftp -g -r hello
hello                100% |*******************************| 12052   0:00:00 ETA
/home # chmod 777 ./hello
/home # ./hello
Hello, world!


Finally, I have finished the introduction. These materials mainly refer to the videos and documents of Mr. Wei Dongshan. If you can't understand them, you can go to station B to search for the embedded application of Wei Dongshan linux. Here are some information

[1] Complete manual for embedded Linux application development_ Weidongshan complete series of video documents V2.4 link: https://pan.baidu.com/s/1qS0Mo5YVS43wYGZdWq1MmA?pwd=w23p Extraction code: w23p
[2] Embedded Linux tutorial_ Wei Dongshan hands-on teaches you how to get started with embedded Linux and master it https://www.bilibili.com/video/BV1w4411B7a4?spm_id_from=333.337.search-card.all.click
[3] Dongshan Pi No. 1 - official document of development board https://dongshanpi.com/DongshanPi-One/01-BoardIntroduction/

Tags: Linux Operation & Maintenance Ubuntu

Posted by teng84 on Sun, 28 Aug 2022 03:15:05 +0300