This article shares from Huawei cloud community “Embedded Linux under the transplantation of Samba services –” based on beidou and 4G CAT1 module of intelligent logistics “development combat, author: Small orange.

Samba is a piece of free software that implements the SMB protocol on Linux and UNIX systems. It consists of server and client programs. Server Message Block (SMB) is a communication protocol for sharing files and printers on a LAN. SMB provides file and printer sharing services between different computers on a LAN.

Embedded development process, often need to transfer the file to the development board, after the transplantation of Samba service, the development board will be connected to the LOCAL area network, can directly access the development board through the IP address of the development board directly access the development board Samba shared folder, in the development board and the LOCAL area network file transfer is convenient and fast. This article focuses on porting Samba and the problems you may encounter during development.

Thanks to the STM32MP1 development board provided by Huawei Cloud IoT course “Intelligent Logistics Based on Beidou and 4G CAT1 module”, you can pay attention to Huawei cloud public account, Huawei cloud IoT Forum for more activities.

The development environment

System: Ubuntu 18.04 64-bit

Development board: STM32MP157

Samba version: 3.2.15

The preparatory work

The samba download links: download.samba.org/pub/samba/

Select Samba-3.2.15.tar. gz to download.

compile

After the download is complete, run the tar command in the folder to decompress the package. After the package is decompressed, go to the samba-3.2.15/source folder for configuration.

The tar - VXF samba - 3.2.15. Tar. GzCopy the code

Edit and modify the configure file after entering the folder. The modification contents are as follows. There are seven modifications in the whole text.

Original content:

echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2; } { (exit 1); exit 1; }; }Copy the code

Instead of

$as_echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2; } # { (exit 1); exit 1; }; }; }Copy the code

See the following figure after modification

Run the following command

echo SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=>arm-linux.cache
./configure CC=arm-none-linux-gnueabihf-gcc LD=arm-none-linux-gnueabihf-ld AR=arm-none-linux-gnueabihf-ar --target=arm-none-linux --host=arm-none-linux-gnueabihf samba_cv_CC_NEGATIVE_ENUM_VALUES=yes --cache-file=arm-linux.cache
Copy the code

The configuration is complete.

After configuration, execute make command to compile, as shown in the following figure:

After compiling, run make install to install. The default installation path is /usr/local/samba.

Install /usr/local/samba and copy it.

tar -vcf samba.tar.gz samba/
Copy the code

After the package is complete, copy the samba.tar.gz file to the /usr/local folder on the development board. Copy the SCP command to the development board (the development board has been connected to the LAN and can be pinged to each other by the Ubuntu system, the IP address of the development board is 192.168.124.11), and the command is as follows:

SCP samba - 3.2.15. Tar. Gz [email protected]: / usr/localCopy the code

After the package is sent, you can view it in /usr/local on the development board. Run the following command to decompress the package:

tar -vxf samba.tar.gz 
Copy the code

Go to the /usr/local/samba/lib folder and add the smb.conf file. The configuration file can be configured as required.

Add the following:

[global]

workgroup = WORKGROUP

server string = samba sever

netbios name =myarm

guest account=root

security =share

interfaces = eth0

[share]

component = share dir

path = /opt/

guest ok=yes

browseable=yes

public = yes

directory mask = 0777

create mask = 0777

available = yes
Copy the code

After adding the smb.conf file, go to the samba/bin file to test it and run the./findsmb file. You can search for the Samba server on the LAN.

Access the samba/sbin folder and run commands to enable the Samba service.

./smbd -D
./nmbd -D
Copy the code

At this point, samba service transplantation is complete, you can open “run” in Windows shortcut win+ R, input development board development board IP access development board shared folder, mom no longer need to worry about the file transfer problem!

An error occurred during compilation

Checking that the C Compiler recognizes negative enum values… configure: error

checking whether arm-none-linux-gnueabihf-gcc and cc understand -c and -o together... yes checking that the C compiler understands -Werror... cross checking that the C compiler understands -w2... cross checking that the C compiler understands -errwarn... cross checking that the C compiler understands volatile... yes checking that the C compiler understands negative enum values... Configure: error: ` in/home/fan/Downloads/samba - 3.2.15 / source ': configure: error: cannot run test program while cross compiling See `config.log' for more details.Copy the code

Solutions:

Run the following command and add parameters to the./configure command: –cache-file=arm-linux.cache

echo SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=>arm-linux.cache

Configure: error: Cannot run test program while cross compiling

checking for __open64... yes checking for creat64... yes checking for prctl... Yes the configure: error: ` in/home/fan/Downloads/samba - 3.2.15 / source ': configure: error: cannot run test program while cross compiling See `config.log' for more details.Copy the code

Solutions:

Edit And modify the contents of the configure file as follows. There are seven modifications in the whole document.

Original content:

echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2; } { (exit 1); exit 1; }; }Copy the code

Instead of

$as_echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2; } { (exit 1); exit 1; }; }; }Copy the code

The change is shown below

Click to follow, the first time to learn about Huawei cloud fresh technology ~