Skip to content

m5stack/M5Stack_Linux_Libs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

M5Stack_Linux_Libs

M5Stack_Linux_Libs A open-source and lightweight Linux C/C++ application development framework that offers an extensive library and programming examples, serving as a minimal dependency framework. It supports compiling C/C++ projects for both native and embedded platforms within the Unix environment.

Project Directory Overview

M5Stack_Linux_Libs/
├── components # The component library root directory is an essential component of the project, offering the flexibility to selectively compile the library into the project. This approach aims to achieve minimal dependencies and reduce the executable file size.
    ├── component1  # Component library template, which allows for rapid addition of the component library following this template.
    ├── hv          # libhv Component
    ├── lvgl_component  # lvgl_component Component
    ├── deprecated  # Unfinished, components to be added
    └── DeviceDriver   # DeviceDriver Component
        ├── include # include directory
        ├── party
            ├── framebuffer # linux framebuffer Simple library
            ├── linux_i2c   # linux i2c Simple library
            ├── linux_spi   # linux spi Simple library
            ├── linux_uart  # linux uart Simple library
            ├── ptmx        # linux pts Virtual terminal library
    ...
├── doc
├── examples    # The source code repository for the project.
│   ├── hello_world   # A project template that can be duplicated to quickly set up a development project.
    ...
├── github_source # github Location for Source Code
│   ├── source-list.sh # GitHub source code repository index, files need to be manually downloaded to this directory. Except for the "source-list.sh" file, other files will not be included in the repository's version history.
│   ├── libhv   # libhv source
└── tools   # Directory for Storing Scripts and Tools

Start compiling a "Hello, World!" program as our beginning.
Framework relies on the following software packages: make, cmake, python3, and expect. Please ensure that the aforementioned packages are installed.

# Assuming your current terminal is in the "dianjixz-lib" directory.
# Install Dependencies (Only Needs to be Done Once)
# The version of Python3 should be greater than or equal to 3.8.
sudo apt update
sudo apt install python3 python3-pip libffi-dev
pip3 install parse scons requests 
# if windows
# pip3 install windows-curses
pip3 install setuptools-rust paramiko scp

wget https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/linaro/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
sudo tar Jxvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz -C /opt

# Navigate to the "examples/hello_world" directory.
cd examples/hello_world

# Start the compilation. Sometimes, compilation failures might occur. You can use `make distclean` to thoroughly clean the project's build files.
scons

# Clean up compilation files.
scons -c

# Thoroughly clean compilation files, including the compilation options generated by `make menuconfig`.
scons distclean
  • step 1:
    Download and install Python3.
  • step 2:
    Install basic compilation dependencies parse, Scons, and requests using pip. pip install parse scons requests.
    Please install the menuconfig configuration dependency windows-curses using pip. pip install windows-curses.
    Please install the dependencies paramiko and scp for SSH push using pip. pip install paramiko scp.
  • step 3:
    Download Windows cross-compilation toolchain:gcc-linaro-7.5.0-2019.12-i686-mingw32_arm-linux-gnueabihf
  • step 4:
    Open PowerShell, set the environment variables for the cross-compiler. You can configure using scons menuconfig or directly define them in the environment variables.:$env:CONFIG_TOOLCHAIN_PATH="..\\gcc-linaro-7.5.0-2019.12-i686-mingw32_arm-linux-gnueabihf\\bin",$env:CONFIG_TOOLCHAIN_PREFIX="arm-linux-gnueabihf-".
  • step 5: Enter the project directory in the "example" folder, and start compiling with scons. cd example/hello_world; scons .

Features

  • Integrate multiple C/C++ software libraries such as libhv, stb, CImg, and more, which enable you to quickly utilize these libraries.
  • Comes with usage examples for various libraries, sparing you the effort of searching, downloading, installing, and then seeking out the usage methods for libraries online. Simple libraries provide code and documentation, while complex ones offer direct usage examples.
  • Examples of TCP/UDP server/client and more.
  • Reliable UDP support: Example with KCP.
  • WebSocket server/client examples.
  • MQTT client example.
  • C/C++ Hybrid Development.
  • Minimal dependencies. Automatic packaging of dependencies for framework components within, with the option for dynamic and static dependencies. Say goodbye to the complexities of dependencies.
  • Configuration for minimal executable size. Enabling the "release" compilation mode generates the smallest executable file size possible.

More examples

In the project's "examples" directory, there are numerous examples including multi-threading, multi-thread synchronization locks, daemon processes, dynamic library invocation, Linux hardware bus development, LVGL GUI, U8g2 driver for SH1107, and many more. You can readily copy code from other repositories and add it to your own project as needed.

Compile native program

# Enter the working directory
cd examples/hello_world
# Compile
scons

More commands

# Clean up compilation files.
scons clean
# Thoroughly clean compilation files.
scons distclean
# Compile optimized version of the program (may result in runtime anomalies).
scons release
# Output detailed compilation process.
scons verbose
# Enable or disable built-in libraries.
scons menuconfig

More Info

Please review the documentation files located in the 'doc' directory.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published