How to use MM SDK

MM SDK

The mm-sdk contains everything you need to build a MadMachine project, either a library or an executable.
A MadMachine project is structured the same as a Swift package.
Download the latest release depending on your OS on the Releases page.
The latest features would be added to this SDK first and then integrated into the MadMachine IDE.

What is inside the SDK

    1.
    Boards
      Board abstraction libraries based on Zephyr​
    2.
    mm
      Python script which is used to help to build the project
    3.
    usr (This directory is only contained in the release package, not in the git repo)
      Clang, Swift compilier, SwiftPM tools etc.
      Standard library and arch related libraries
      Compiled Python build tool

Usage (Take macOS and Linux for example)

Install required dependencies:

macOS

Install XCode and open it so it could install any components that needed.

Ubuntu 18.04

1
sudo apt-get install \
2
binutils \
3
git \
4
libc6-dev \
5
libcurl4 \
6
libedit2 \
7
libgcc-5-dev \
8
libpython2.7 \
9
libsqlite3-0 \
10
libstdc++-5-dev \
11
libxml2 \
12
pkg-config \
13
tzdata \
14
zlib1g-dev
Copied!

Ubuntu 20.04

1
sudo apt-get install \
2
binutils \
3
git \
4
gnupg2 \
5
libc6-dev \
6
libcurl4 \
7
libedit2 \
8
libgcc-9-dev \
9
libpython2.7 \
10
libsqlite3-0 \
11
libstdc++-9-dev \
12
libxml2 \
13
libz3-dev \
14
pkg-config \
15
tzdata \
16
zlib1g-dev \
17
libncurses5
Copied!

Download the mm-sdk

Download and unzip the sdk to the directory ~
~/mm-sdk/usr/mm/mm -h command for quick help.
~/mm-sdk/usr/mm/mm init -h command for quick help about initializing a project.
~/mm-sdk/usr/mm build -h command for quick help about building a project.

Initialize an executable DemoProgram in ~/Documents

1
cd ~/Documents
2
mkdir DemoProgram
3
cd DemoProgram
4
~/mm-sdk/usr/mm/mm init
Copied!
The Package.swift should look like below
1
// swift-tools-version:5.3
2
// The swift-tools-version declares the minimum version of Swift required to build this package.
3
​
4
import PackageDescription
5
​
6
let package = Package(
7
name: "DemoProgram",
8
dependencies: [
9
// Dependencies declare other packages that this package depends on.
10
.package(url: "https://github.com/madmachineio/SwiftIO.git", .branch("main")),
11
.package(url: "https://github.com/madmachineio/MadBoards.git", .branch("main")),
12
],
13
targets: [
14
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
15
// Targets can depend on other targets in this package, and on products in packages this package depends on.
16
.target(
17
name: "DemoProgram",
18
dependencies: ["SwiftIO", "MadBoards"]),
19
.testTarget(
20
name: "DemoProgramTests",
21
dependencies: ["DemoProgram"]),
22
]
23
)
Copied!

Build an executable

1
cd ~/Documents/DemoProgram
2
~/mm-sdk/usr/mm/mm build -b SwiftIOBoard
Copied!

Download an executable to the board

After a successful building, there would be .build/release/swiftio.bin in your project directory. Note that the .build directory is hidden by default.
Follow those steps to download the executable:
    1.
    Insert SD card to the board and connect it to your computer through a USB cable
    2.
    Press the Download button and wait for the onboard RGB LED to turn to static green)
    3.
    A USB disk drive should be mounted on your computer
    4.
    Copy the swiftio.bin to the SD card root directory
    5.
    Eject the USB drive and the program would run automatically

Download an executable to the board using command (Only on macOS now)

After mounting the SD card:
1
cd ~/Documents/DemoProgram
2
~/mm-sdk/usr/mm/mm download -b SwiftIOBoard
Copied!
This command would find the corresponding bin file, copy it to the SD card and eject the SD card automatically

Usage (Take Windows 10 for example)

Download and unzip the sdk to the directory D:\
Press Win + R keys on your keyboard, then type cmd, and press Enter on your keyboard or click OK to run a Command Prompt.
D:\mm-sdk\usr\mm\mm -h command for quick help.
D:\mm-sdk\usr\mm\mm init -h command for quick help about initializing a project.
D:\mm-sdk\usr\mm build -h command for quick help about building a project.

Initialize an executable DemoProgram in D:\

1
D:
2
mkdir DemoProgram
3
cd DemoProgram
4
D:\mm-sdk\usr\mm\mm init
Copied!
The Package.swift should look like below
1
// swift-tools-version:5.3
2
// The swift-tools-version declares the minimum version of Swift required to build this package.
3
​
4
import PackageDescription
5
​
6
let package = Package(
7
name: "DemoProgram",
8
dependencies: [
9
// Dependencies declare other packages that this package depends on.
10
.package(url: "https://github.com/madmachineio/SwiftIO.git", .branch("main")),
11
.package(url: "https://github.com/madmachineio/MadBoards.git", .branch("main")),
12
],
13
targets: [
14
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
15
// Targets can depend on other targets in this package, and on products in packages this package depends on.
16
.target(
17
name: "DemoProgram",
18
dependencies: ["SwiftIO", "MadBoards"]),
19
.testTarget(
20
name: "DemoProgramTests",
21
dependencies: ["DemoProgram"]),
22
]
23
)
Copied!

Build an executable

1
cd D:\DemoProgram
2
D:\mm-sdk\usr\mm\mm build -b SwiftIOBoard
Copied!

Download an executable to the board

After a successful building, there would be .build\release\swiftio.bin in your project directory.
Follow those steps to download the executable:
    1.
    Insert SD card to the board and connect it to your computer through a USB cable
    2.
    Press the Download button and wait for the onboard RGB LED to turn to static green
    3.
    A USB disk drive should be mounted on your computer
    4.
    Copy the swiftio.bin to the SD card root directory
    5.
    Eject the USB drive and the program would run automatically
Last modified 4mo ago