Skip to content

Commit 95d5577

Browse files
authored
Merge pull request #4 from eerimoq/develop
Simba framework for Nano32 board.
2 parents e7d7c08 + f5f5710 commit 95d5577

File tree

11 files changed

+272
-1
lines changed

11 files changed

+272
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ env:
66
- PLATFORMIO_PROJECT_DIR=examples/arduino-blink
77
- PLATFORMIO_PROJECT_DIR=examples/arduino-wifiscan
88
- PLATFORMIO_PROJECT_DIR=examples/espidf-http-request
9+
- PLATFORMIO_PROJECT_DIR=examples/simba-blink
910

1011
install:
1112
- pip install -U https://github.com/platformio/platformio/archive/develop.zip

boards/nano32.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"frameworks": [
1313
"arduino",
14-
"espidf"
14+
"espidf",
15+
"simba"
1516
],
1617
"name": "MakerAsia Nano32",
1718
"upload": {

builder/frameworks/simba.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright 2014-present PlatformIO <[email protected]>
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Simba
16+
17+
Simba is an RTOS and build framework. It aims to make embedded
18+
programming easy and portable.
19+
20+
http://simba-os.readthedocs.org
21+
22+
"""
23+
24+
from os.path import join, sep
25+
26+
from SCons.Script import DefaultEnvironment, SConscript
27+
28+
from platformio.builder.tools import platformio as platformio_tool
29+
30+
#
31+
# Backward compatibility with PlatformIO 2.0
32+
#
33+
platformio_tool.SRC_DEFAULT_FILTER = " ".join([
34+
"+<*>", "-<.git%s>" % sep, "-<svn%s>" % sep,
35+
"-<example%s>" % sep, "-<examples%s>" % sep,
36+
"-<test%s>" % sep, "-<tests%s>" % sep
37+
])
38+
39+
40+
def LookupSources(env, variant_dir, src_dir, duplicate=True, src_filter=None):
41+
return env.CollectBuildFiles(variant_dir, src_dir, src_filter, duplicate)
42+
43+
44+
def VariantDirWrap(env, variant_dir, src_dir, duplicate=False):
45+
env.VariantDir(variant_dir, src_dir, duplicate)
46+
47+
48+
env = DefaultEnvironment()
49+
50+
env.AddMethod(LookupSources)
51+
env.AddMethod(VariantDirWrap)
52+
53+
env.Replace(
54+
PLATFORMFW_DIR=env.PioPlatform().get_package_dir("framework-simba")
55+
)
56+
57+
SConscript(
58+
[env.subst(join("$PLATFORMFW_DIR", "make", "platformio.sconscript"))])

builder/main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def _get_board_f_flash(env):
8787
FRAMEWORK_ARDUINOESP32_DIR=platform.get_package_dir(
8888
"framework-arduinoespressif32"),
8989
ESPIDF_DIR=platform.get_package_dir("framework-espidf"),
90+
FRAMEWORK_SIMBA_DIR=platform.get_package_dir("framework-simba"),
9091

9192
#
9293
# Upload
@@ -128,6 +129,16 @@ def _get_board_f_flash(env):
128129
"0x10000"
129130
]
130131
)
132+
if env.subst("$PIOFRAMEWORK") == "simba":
133+
env.Append(
134+
UPLOADERFLAGS=[
135+
"0x1000", join("$FRAMEWORK_SIMBA_DIR", "3pp", "esp32",
136+
"bin", "bootloader.bin"),
137+
"0x4000", join("$FRAMEWORK_SIMBA_DIR", "3pp", "esp32",
138+
"bin", "partitions_singleapp.bin"),
139+
"0x10000"
140+
]
141+
)
131142

132143

133144
env.Append(

examples/simba-blink/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pioenvs
2+
.clang_complete
3+
.gcc-flags.json

examples/simba-blink/.travis.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Continuous Integration (CI) is the practice, in software
2+
# engineering, of merging all developer working copies with a shared mainline
3+
# several times a day < http://docs.platformio.org/en/stable/ci/index.html >
4+
#
5+
# Documentation:
6+
#
7+
# * Travis CI Embedded Builds with PlatformIO
8+
# < https://docs.travis-ci.com/user/integration/platformio/ >
9+
#
10+
# * PlatformIO integration with Travis CI
11+
# < http://docs.platformio.org/en/stable/ci/travis.html >
12+
#
13+
# * User Guide for `platformio ci` command
14+
# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html >
15+
#
16+
#
17+
# Please choice one of the following templates (proposed below) and uncomment
18+
# it (remove "# " before each line) or use own configuration according to the
19+
# Travis CI documentation (see above).
20+
#
21+
22+
23+
#
24+
# Template #1: General project. Test it using existing `platformio.ini`.
25+
#
26+
27+
# language: python
28+
# python:
29+
# - "2.7"
30+
#
31+
# sudo: false
32+
# cache:
33+
# directories:
34+
# - "~/.platformio"
35+
#
36+
# install:
37+
# - pip install -U platformio
38+
#
39+
# script:
40+
# - platformio run
41+
42+
43+
#
44+
# Template #2: The project is intended to by used as a library with examples
45+
#
46+
47+
# language: python
48+
# python:
49+
# - "2.7"
50+
#
51+
# sudo: false
52+
# cache:
53+
# directories:
54+
# - "~/.platformio"
55+
#
56+
# env:
57+
# - PLATFORMIO_CI_SRC=path/to/test/file.c
58+
# - PLATFORMIO_CI_SRC=examples/file.ino
59+
# - PLATFORMIO_CI_SRC=path/to/test/directory
60+
#
61+
# install:
62+
# - pip install -U platformio
63+
#
64+
# script:
65+
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

examples/simba-blink/README.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.. Copyright 2014-present PlatformIO <[email protected]>
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
http://www.apache.org/licenses/LICENSE-2.0
6+
Unless required by applicable law or agreed to in writing, software
7+
distributed under the License is distributed on an "AS IS" BASIS,
8+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
See the License for the specific language governing permissions and
10+
limitations under the License.
11+
12+
How to build PlatformIO based project
13+
=====================================
14+
15+
1. `Install PlatformIO <http://docs.platformio.org/en/stable/installation.html>`_
16+
2. Download `development platform with examples <https://github.com/platformio/platform-espressif32/archive/develop.zip>`_
17+
3. Extract ZIP archive
18+
4. Run these commands:
19+
20+
.. code-block:: bash
21+
22+
# Change directory to example
23+
> cd platform-espressif32/examples/simba-blink
24+
25+
# Process example project
26+
> platformio run
27+
28+
# Upload firmware
29+
> platformio run --target upload
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
This directory is intended for the project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link to executable file.
4+
5+
The source code of each library should be placed in separate directory, like
6+
"lib/private_lib/[here are source files]".
7+
8+
For example, see how can be organised `Foo` and `Bar` libraries:
9+
10+
|--lib
11+
| |--Bar
12+
| | |--docs
13+
| | |--examples
14+
| | |--src
15+
| | |- Bar.c
16+
| | |- Bar.h
17+
| |--Foo
18+
| | |- Foo.c
19+
| | |- Foo.h
20+
| |- readme.txt --> THIS FILE
21+
|- platformio.ini
22+
|--src
23+
|- main.c
24+
25+
Then in `src/main.c` you should use:
26+
27+
#include <Foo.h>
28+
#include <Bar.h>
29+
30+
// rest H/C/CPP code
31+
32+
PlatformIO will find your libraries automatically, configure preprocessor's
33+
include paths and build them.
34+
35+
See additional options for PlatformIO Library Dependency Finder `lib_*`:
36+
37+
http://docs.platformio.org/en/stable/projectconf.html#lib-install
38+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter, extra scripting
4+
; Upload options: custom port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
;
7+
; Please visit documentation for the other options and examples
8+
; http://docs.platformio.org/en/stable/projectconf.html
9+
10+
[env:nano32]
11+
platform = espressif32
12+
framework = simba
13+
board = nano32

examples/simba-blink/src/main.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @file main.c
3+
* @version 4.1.0
4+
*
5+
* @section License
6+
* Copyright (C) 2015-2016, Erik Moqvist
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; either
11+
* version 2.1 of the License, or (at your option) any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Lesser General Public License for more details.
17+
*
18+
* This file is part of the Simba project.
19+
*/
20+
21+
#include "simba.h"
22+
23+
int main()
24+
{
25+
struct pin_driver_t led;
26+
27+
/* Start the system. */
28+
sys_start();
29+
30+
/* Initialize the LED pin as output and set its value to 1. */
31+
pin_init(&led, &pin_led_dev, PIN_OUTPUT);
32+
pin_write(&led, 1);
33+
34+
while (1) {
35+
/* Wait half a second. */
36+
thrd_sleep_us(500000);
37+
38+
/* Toggle the LED on/off. */
39+
pin_toggle(&led);
40+
}
41+
42+
return (0);
43+
}

0 commit comments

Comments
 (0)