mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-26 12:14:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bb40e6ec9 | ||
|
|
94efcc83a1 | ||
|
|
03402cf359 | ||
|
|
a473cf99b5 | ||
|
|
c26bd2ffe8 | ||
|
|
9dc3d09981 | ||
|
|
76b4c9a6ff | ||
|
|
41add69294 | ||
|
|
c911c9ad19 | ||
|
|
dd883c0563 | ||
|
|
16a0c89d5f | ||
|
|
ac0e6f3377 | ||
|
|
68f7be7a1a | ||
|
|
b796e33ede | ||
|
|
1051ba77c0 | ||
|
|
cb5b6b972a | ||
|
|
925f21aca4 | ||
|
|
dc09851ac8 | ||
|
|
323ba9d90c | ||
|
|
c6ff8ab6dc | ||
|
|
b5443f10c5 | ||
|
|
3ae1a0f82a | ||
|
|
81f0f8a7c2 | ||
|
|
50963df42f | ||
|
|
b316989378 | ||
|
|
23c68e2677 | ||
|
|
b46bee0540 | ||
|
|
4c6c27d8f6 | ||
|
|
3c531897b6 | ||
|
|
6c7672f4af | ||
|
|
2def6e867d | ||
|
|
573f13c1ed | ||
|
|
b7f9e5c947 | ||
|
|
da85affe5c | ||
|
|
3168a2aca0 | ||
|
|
1f5feaa103 | ||
|
|
4be3dfd52b | ||
|
|
1e26983263 | ||
|
|
a620419b59 | ||
|
|
ffdc9b0d3a | ||
|
|
379e047289 | ||
|
|
8e420406b9 | ||
|
|
fc0364b321 | ||
|
|
ea4986dec5 | ||
|
|
2be30a3193 | ||
|
|
81f90c7b51 | ||
|
|
205a564482 | ||
|
|
497df68de1 | ||
|
|
eaf8e24d4c | ||
|
|
1721fb0484 | ||
|
|
fe0b144b84 | ||
|
|
d391bca2d3 | ||
|
|
a0b6e70ff8 | ||
|
|
4f15392440 | ||
|
|
959fcfdf1d | ||
|
|
57f90d200d | ||
|
|
663c645cf1 | ||
|
|
972b255a48 | ||
|
|
8c5dfa4227 | ||
|
|
290d48e1aa | ||
|
|
4eb3a1c978 | ||
|
|
b4a36a8303 | ||
|
|
d08ee4e63a | ||
|
|
42f5802e47 | ||
|
|
120ffb0b1f | ||
|
|
d3a3ba0a32 | ||
|
|
79eebc14bb | ||
|
|
6fc41e2a3c | ||
|
|
4843323f87 | ||
|
|
04c6f3e6ef | ||
|
|
5345c7260e | ||
|
|
71a48ccde0 | ||
|
|
41e24d7733 | ||
|
|
f888b30863 | ||
|
|
10029d6a8d | ||
|
|
6697a2cfaa | ||
|
|
59020e0d5d | ||
|
|
70abd1f98d | ||
|
|
312ca8e978 | ||
|
|
e1ccdc0570 | ||
|
|
c7f9fe4a03 | ||
|
|
89aaf1c30c | ||
|
|
601af780c9 | ||
|
|
93477c8db4 | ||
|
|
ec5531dbf4 | ||
|
|
157f87f01a | ||
|
|
0f4ca8d010 | ||
|
|
0a168b6791 | ||
|
|
a025577b30 | ||
|
|
ef61d6ea48 | ||
|
|
e6bf658271 | ||
|
|
9cccb9839b | ||
|
|
2bd188f3d6 | ||
|
|
9fa840c1c7 | ||
|
|
e0e599ffa1 | ||
|
|
e93d18d200 | ||
|
|
34150f3f71 | ||
|
|
db6730c8a3 | ||
|
|
08cac802a4 | ||
|
|
af6a52e060 | ||
|
|
1c63645254 | ||
|
|
be5d8b1d4f | ||
|
|
2ac3552e6e | ||
|
|
3c3c775213 | ||
|
|
a24b7043ed | ||
|
|
7b621d7b5b | ||
|
|
8a335a8cea | ||
|
|
355c292dbf | ||
|
|
2511d747ae | ||
|
|
03c326a04e | ||
|
|
b3312f3761 | ||
|
|
2e250ee7aa | ||
|
|
924984dde1 | ||
|
|
33b7bb91d9 | ||
|
|
f68fe0fb5c | ||
|
|
e6663ec186 | ||
|
|
6ff0f9ccd8 | ||
|
|
48830aa9a9 | ||
|
|
9276f764e0 | ||
|
|
7876d464f2 | ||
|
|
5d0d01c2c1 | ||
|
|
393418d50d | ||
|
|
23bb912eb5 | ||
|
|
1d5b5296da | ||
|
|
655f5db996 | ||
|
|
c20cc4ae09 | ||
|
|
7581229bbf | ||
|
|
d094e090ff | ||
|
|
c7a13025e4 | ||
|
|
e4cd6bd824 | ||
|
|
f3ad0572e2 | ||
|
|
406d6cc305 | ||
|
|
d042697b10 | ||
|
|
ba678b9ad1 | ||
|
|
7a5cf118e9 | ||
|
|
e9a2da61ef | ||
|
|
d3fe1ef681 | ||
|
|
9725bca966 | ||
|
|
1f627e4263 | ||
|
|
7ac0c5fc2a | ||
|
|
091ebd8a98 | ||
|
|
d9a6e85b65 | ||
|
|
7cc3d89980 | ||
|
|
f58b90f7ea | ||
|
|
fd84109c1d | ||
|
|
626f605835 | ||
|
|
943a8a2708 | ||
|
|
d7b2b3f42e | ||
|
|
fafc5c8348 | ||
|
|
15bd8b4fe9 | ||
|
|
928aed4342 | ||
|
|
98782e44c2 | ||
|
|
65b23777b2 | ||
|
|
c8fd3d6d25 | ||
|
|
01e7cd5f13 | ||
|
|
3ac9bd0468 | ||
|
|
9f498d2eea | ||
|
|
2d2d9ad277 | ||
|
|
2cc18a8ea3 | ||
|
|
25036d5f48 | ||
|
|
defee39ef9 | ||
|
|
c78afb12a3 | ||
|
|
f72b0b5056 | ||
|
|
d46e505a80 | ||
|
|
4027bcf7ea | ||
|
|
2905392665 | ||
|
|
98db3360df | ||
|
|
f26c713482 | ||
|
|
05e55334fc | ||
|
|
01fe61276e | ||
|
|
219253ad71 | ||
|
|
7b125558cb | ||
|
|
02120e24b6 | ||
|
|
91bc79c14c | ||
|
|
5ca552cf1c | ||
|
|
2066304b14 | ||
|
|
1c6f8b95eb | ||
|
|
5384591f5b | ||
|
|
309668ccbc | ||
|
|
06a9fb3f53 | ||
|
|
00db56f7d7 | ||
|
|
cec06eb25c | ||
|
|
73a3897e1b | ||
|
|
100c4c15ce | ||
|
|
c59bf6613a | ||
|
|
ac435bcb91 | ||
|
|
5d0bfccbc7 | ||
|
|
813489dc2f | ||
|
|
828f31d5e6 | ||
|
|
8130f7f25f | ||
|
|
943e1c5f77 | ||
|
|
ecb3301bcb | ||
|
|
a0f33aebf7 | ||
|
|
6862981640 | ||
|
|
f61f2d2e9f | ||
|
|
1743e175cd | ||
|
|
a027f58744 | ||
|
|
c98886402b | ||
|
|
112a1e908a | ||
|
|
01ae80ecd1 | ||
|
|
1c114a279e |
No files matched your search
@@ -9,7 +9,7 @@ jobs:
|
|||||||
Fuzzing:
|
Fuzzing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^src/' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^src/' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- name: Build Fuzzers
|
- name: Build Fuzzers
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
languages: cpp
|
languages: cpp
|
||||||
- run: |
|
- run: |
|
||||||
make test CC=gcc ASAN= ASAN_OPTIONS=
|
make -C test test CC=gcc ASAN= ASAN_OPTIONS=
|
||||||
./test/setup_ga_network.sh && make mip_test CC=gcc ASAN= ASAN_OPTIONS=
|
./test/setup_ga_network.sh && make -C test mip_test CC=gcc ASAN= ASAN_OPTIONS=
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v2
|
||||||
+224
-56
@@ -14,7 +14,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
cc: [gcc, clang, g++, clang++]
|
cc: [gcc, clang, g++, clang++]
|
||||||
target: [test, mip_test]
|
target: [test, mip_test]
|
||||||
ssl: ["", MBEDTLS, OPENSSL]
|
ssl: ["", BUILTIN, MBEDTLS, OPENSSL, WOLFSSL]
|
||||||
select: ["-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0", "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0", "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=1"]
|
select: ["-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0", "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0", "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=1"]
|
||||||
exclude:
|
exclude:
|
||||||
- ssl: MBEDTLS
|
- ssl: MBEDTLS
|
||||||
@@ -25,118 +25,263 @@ jobs:
|
|||||||
select: "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0"
|
select: "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0"
|
||||||
- ssl: OPENSSL
|
- ssl: OPENSSL
|
||||||
select: "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0"
|
select: "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0"
|
||||||
|
- ssl: WOLFSSL
|
||||||
|
select: "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0"
|
||||||
|
- ssl: WOLFSSL
|
||||||
|
select: "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0"
|
||||||
name: linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }}
|
name: linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }}
|
||||||
env:
|
env:
|
||||||
CC: ${{ matrix.cc }}
|
CC: ${{ matrix.cc }}
|
||||||
SSL: ${{ matrix.ssl }}
|
SSL: ${{ matrix.ssl }}
|
||||||
TFLAGS: ${{ matrix.select }}
|
TFLAGS: ${{ matrix.select }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: ./test/setup_ga_network.sh && sudo apt -y update ; sudo apt -y install libmbedtls-dev && make ${{ matrix.target }}
|
- run: ./test/setup_ga_network.sh && sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev && make -C test ${{ matrix.target }}
|
||||||
s390:
|
s390:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", BUILTIN]
|
||||||
|
name: S390 SSL=${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make s390
|
- run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test s390 SSL=${{ matrix.ssl }}
|
||||||
armhf:
|
armhf:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", BUILTIN]
|
||||||
|
name: ArmHF SSL=${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make armhf
|
- run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test armhf SSL=${{ matrix.ssl }}
|
||||||
linux2:
|
unamalgamated-mg_prefix:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", BUILTIN, MBEDTLS, OPENSSL, WOLFSSL]
|
||||||
|
name: unamalgamated-mg_prefix SSL=${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: sudo apt -y update ; sudo apt -y install libmbedtls-dev valgrind
|
- run: sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev
|
||||||
- run: make unamalgamated && make valgrind && make mg_prefix
|
- run: make -C test unamalgamated && make -C test mg_prefix
|
||||||
|
valgrind:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", BUILTIN, MBEDTLS, OPENSSL, WOLFSSL]
|
||||||
|
name: Valgrind SSL=${{ matrix.ssl }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with: { fetch-depth: 2 }
|
||||||
|
- run: sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev valgrind
|
||||||
|
- run: make -C test valgrind SSL=${{ matrix.ssl }}
|
||||||
macos:
|
macos:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
ssl: ["", MBEDTLS, OPENSSL]
|
ssl: ["", BUILTIN, MBEDTLS, OPENSSL, WOLFSSL]
|
||||||
select: [-DMG_ENABLE_POLL=0, -DMG_ENABLE_POLL=1]
|
select: [-DMG_ENABLE_POLL=0, -DMG_ENABLE_POLL=1]
|
||||||
exclude:
|
exclude:
|
||||||
- ssl: MBEDTLS
|
- ssl: MBEDTLS
|
||||||
select: -DMG_ENABLE_POLL=0
|
select: -DMG_ENABLE_POLL=0
|
||||||
- ssl: OPENSSL
|
- ssl: OPENSSL
|
||||||
select: -DMG_ENABLE_POLL=0
|
select: -DMG_ENABLE_POLL=0
|
||||||
|
- ssl: WOLFSSL
|
||||||
|
select: -DMG_ENABLE_POLL=0
|
||||||
name: macos SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }}
|
name: macos SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }}
|
||||||
env:
|
env:
|
||||||
SSL: ${{ matrix.ssl }}
|
SSL: ${{ matrix.ssl }}
|
||||||
TFLAGS: ${{ matrix.select }} -DNO_SNTP_CHECK -Wno-sign-conversion # Workaround for MbedTLS 3.5.0
|
TFLAGS: ${{ matrix.select }} -DNO_SNTP_CHECK -Wno-sign-conversion # Workaround for MbedTLS 3.5.0
|
||||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: brew install jq mbedtls openssl
|
- run: brew install mbedtls wolfssl # jq openssl already pre-installed
|
||||||
- run: make test ASAN_OPTIONS= MBEDTLS=`echo /usr/local/Cellar/mbedtls*/*` OPENSSL=`echo /usr/local/Cellar/openssl*/*`
|
- run: make -C test test ASAN_OPTIONS= MBEDTLS=$(echo $(brew --cellar)/mbedtls*/*) OPENSSL=$(echo $(brew --cellar)/openssl*/*) WOLFSSL=$(echo $(brew --cellar)/wolfssl*/*)
|
||||||
- run: make mg_prefix
|
|
||||||
windows:
|
windows:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
max-parallel: 1 # no parallel runs, to minimize MQTT errors
|
||||||
matrix:
|
matrix:
|
||||||
target: [vc98, vc17, vc22, mingw, mingw++]
|
target: [vc98, vc17, vc22, mingw, mingw++]
|
||||||
|
ssl: ["", BUILTIN]
|
||||||
select: [-DMG_ENABLE_POLL=0, -DMG_ENABLE_POLL=1]
|
select: [-DMG_ENABLE_POLL=0, -DMG_ENABLE_POLL=1]
|
||||||
exclude:
|
exclude:
|
||||||
- target: vc98
|
- target: vc98
|
||||||
select: -DMG_ENABLE_POLL=1
|
select: -DMG_ENABLE_POLL=1
|
||||||
name: windows ${{ matrix.target }} TFLAGS=${{ matrix.select }}
|
name: windows ${{ matrix.target }} SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }}
|
||||||
env:
|
env:
|
||||||
|
SSL: SSL=${{ matrix.ssl }}
|
||||||
TFLAGS: ${{ matrix.select }}
|
TFLAGS: ${{ matrix.select }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: make ${{ matrix.target }}
|
- run: make -C test ${{ matrix.target }}
|
||||||
arm:
|
arm:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", BUILTIN]
|
||||||
|
name: Arm SSL=${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: make arm
|
- run: make -C test arm SSL=${{ matrix.ssl }}
|
||||||
riscv:
|
riscv:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", BUILTIN]
|
||||||
|
name: RISC-V SSL=${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: make riscv
|
- run: make -C test riscv SSL=${{ matrix.ssl }}
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: examples ${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: sudo apt -y install libmbedtls-dev libpcap-dev
|
- run: sudo apt -y install libpcap-dev
|
||||||
- run: make examples
|
- run: make -C test examples CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
- run: make clean
|
- run: make -C test clean_examples
|
||||||
examples_win:
|
examples_win:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: examples_win ${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
# - uses: egor-tensin/setup-mingw@v2
|
# - uses: egor-tensin/setup-mingw@v2
|
||||||
# with:
|
# with:
|
||||||
# platform: x64
|
# platform: x64
|
||||||
- name: test they build
|
- name: test they build
|
||||||
run: make examples_win
|
run: make -C test examples_win CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
shell: cmd
|
shell: cmd
|
||||||
- name: test they clean
|
- name: test they clean
|
||||||
run: make clean_examples_win
|
run: make -C test clean_examples_win
|
||||||
shell: cmd
|
shell: cmd
|
||||||
examples_mac:
|
examples_mac:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
|
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: examples_mac ${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: make examples_mac
|
- run: make -C test examples_mac CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
- run: make clean_examples_mac
|
- run: make -C test clean_examples_mac
|
||||||
|
|
||||||
|
refprojs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: reference-projects ${{ matrix.ssl }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: make -C test refprojs CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
|
- run: make -C test clean_refprojs
|
||||||
|
refprojs_win:
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: reference-projects_win ${{ matrix.ssl }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
# - uses: egor-tensin/setup-mingw@v2
|
||||||
|
# with:
|
||||||
|
# platform: x64
|
||||||
|
- name: test they build
|
||||||
|
run: make -C test refprojs_win CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
|
shell: cmd
|
||||||
|
- name: test they clean
|
||||||
|
run: make -C test clean_refprojs_win
|
||||||
|
shell: cmd
|
||||||
|
refprojs_mac:
|
||||||
|
runs-on: macos-latest
|
||||||
|
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: reference-projects_mac ${{ matrix.ssl }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: make -C test refprojs CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
|
- run: make -C test clean_refprojs
|
||||||
|
|
||||||
|
tutorials:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: tutorials ${{ matrix.ssl }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: sudo apt -y install libpcap-dev
|
||||||
|
- run: make -C test tutorials CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
|
- run: make -C test clean_tutorials
|
||||||
|
tutorials_win:
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: tutorials_win ${{ matrix.ssl }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
# - uses: egor-tensin/setup-mingw@v2
|
||||||
|
# with:
|
||||||
|
# platform: x64
|
||||||
|
- name: test they build
|
||||||
|
run: make -C test tutorials_win CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
|
shell: cmd
|
||||||
|
- name: test they clean
|
||||||
|
run: make -C test clean_tutorials_win
|
||||||
|
shell: cmd
|
||||||
|
tutorials_mac:
|
||||||
|
runs-on: macos-latest
|
||||||
|
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
|
name: tutorials_mac ${{ matrix.ssl }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: make -C test tutorials_mac CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
|
- run: make -C test clean_tutorials_mac
|
||||||
|
|
||||||
|
|
||||||
arduino:
|
arduino:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: echo # nothing specific to install or do
|
- run: echo # nothing specific to install or do
|
||||||
- run: make -C examples/arduino arduino-xiao
|
- run: make -C examples/arduino arduino-xiao
|
||||||
@@ -157,7 +302,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- run: echo # nothing specific to install or do
|
- run: echo # nothing specific to install or do
|
||||||
@@ -198,7 +343,7 @@ jobs:
|
|||||||
- path: ti/ek-tm4c1294xl-make-baremetal-builtin-rndis
|
- path: ti/ek-tm4c1294xl-make-baremetal-builtin-rndis
|
||||||
name: ${{ matrix.example.path }}
|
name: ${{ matrix.example.path }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
- run: make -C examples/${{ matrix.example.path }} build
|
- run: make -C examples/${{ matrix.example.path }} build
|
||||||
@@ -212,7 +357,7 @@ jobs:
|
|||||||
- path: esp32/device-dashboard
|
- path: esp32/device-dashboard
|
||||||
name: ${{ matrix.example.path }}
|
name: ${{ matrix.example.path }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: echo # nothing specific to install or do
|
- run: echo # nothing specific to install or do
|
||||||
- run: make -C examples/${{ matrix.example.path }} build
|
- run: make -C examples/${{ matrix.example.path }} build
|
||||||
@@ -222,12 +367,15 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
|
||||||
example:
|
example:
|
||||||
- path: microchip/same54-xpro/device-dashboard
|
- path: microchip/same54-xpro/device-dashboard
|
||||||
- path: nxp/rt1020-evk-make-baremetal-builtin
|
- path: nxp/rt1020-evk-make-baremetal-builtin
|
||||||
- path: nxp/rt1020-evk-make-freertos-builtin
|
- path: nxp/rt1020-evk-make-freertos-builtin
|
||||||
- path: nxp/rt1060-evk-make-baremetal-builtin
|
- path: nxp/rt1060-evk-make-baremetal-builtin
|
||||||
- path: nxp/rt1060-evk-make-freertos-builtin
|
- path: nxp/rt1060-evk-make-freertos-builtin
|
||||||
|
- path: nxp/rt1170-evk-make-baremetal-builtin
|
||||||
|
- path: renesas/ek-ra6m4-make-baremetal-builtin
|
||||||
- path: rp2040/pico-rndis-dashboard
|
- path: rp2040/pico-rndis-dashboard
|
||||||
- path: rp2040/pico-w
|
- path: rp2040/pico-w
|
||||||
- path: rp2040/pico-w5500
|
- path: rp2040/pico-w5500
|
||||||
@@ -246,12 +394,12 @@ jobs:
|
|||||||
- path: stm32/stm32h573i-dk-make-freertos-builtin
|
- path: stm32/stm32h573i-dk-make-freertos-builtin
|
||||||
- path: ti/ek-tm4c1294xl-make-baremetal-builtin
|
- path: ti/ek-tm4c1294xl-make-baremetal-builtin
|
||||||
- path: ti/ek-tm4c1294xl-make-freertos-builtin
|
- path: ti/ek-tm4c1294xl-make-freertos-builtin
|
||||||
name: ${{ matrix.example.path }}
|
name: ${{ matrix.example.path }} ${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
- run: make -C examples/${{ matrix.example.path }} build
|
- run: make -C examples/${{ matrix.example.path }} build CFLAGS_EXTRA="${{ matrix.ssl }}"
|
||||||
|
|
||||||
# mqtt_dashboard_examples:
|
# mqtt_dashboard_examples:
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
@@ -262,7 +410,7 @@ jobs:
|
|||||||
# - path:
|
# - path:
|
||||||
# name: ${{ matrix.example.path }}
|
# name: ${{ matrix.example.path }}
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v3
|
# - uses: actions/checkout@v4
|
||||||
# with: { fetch-depth: 2 }
|
# with: { fetch-depth: 2 }
|
||||||
# - run: echo # nothing specific to install or do
|
# - run: echo # nothing specific to install or do
|
||||||
# - run: make -C examples/${{ matrix.example.path }} build
|
# - run: make -C examples/${{ matrix.example.path }} build
|
||||||
@@ -276,7 +424,7 @@ jobs:
|
|||||||
- path: rp2040/pico-rndis-device
|
- path: rp2040/pico-rndis-device
|
||||||
name: ${{ matrix.example.path }}
|
name: ${{ matrix.example.path }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
- run: make -C examples/${{ matrix.example.path }} build
|
- run: make -C examples/${{ matrix.example.path }} build
|
||||||
@@ -290,7 +438,7 @@ jobs:
|
|||||||
# - path:
|
# - path:
|
||||||
# name: ${{ matrix.example.path }}
|
# name: ${{ matrix.example.path }}
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v3
|
# - uses: actions/checkout@v4
|
||||||
# with: { fetch-depth: 2 }
|
# with: { fetch-depth: 2 }
|
||||||
# - run: echo # nothing specific to install or do
|
# - run: echo # nothing specific to install or do
|
||||||
# - run: make -C examples/${{ matrix.example.path }} device_dashboard
|
# - run: make -C examples/${{ matrix.example.path }} device_dashboard
|
||||||
@@ -305,7 +453,7 @@ jobs:
|
|||||||
- path: stm32/nucleo-h723zg-make-baremetal-builtin
|
- path: stm32/nucleo-h723zg-make-baremetal-builtin
|
||||||
name: ${{ matrix.example.path }}
|
name: ${{ matrix.example.path }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
- run: make -C examples/${{ matrix.example.path }} device_dashboard
|
- run: make -C examples/${{ matrix.example.path }} device_dashboard
|
||||||
@@ -314,7 +462,7 @@ jobs:
|
|||||||
cube_examples:
|
cube_examples:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: echo # nothing specific to install or do
|
- run: echo # nothing specific to install or do
|
||||||
- run: cd test/cube && make
|
- run: cd test/cube && make
|
||||||
@@ -322,7 +470,7 @@ jobs:
|
|||||||
zephyr_examples:
|
zephyr_examples:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
- run: make -C examples/zephyr init
|
- run: make -C examples/zephyr init
|
||||||
@@ -340,7 +488,7 @@ jobs:
|
|||||||
test_f7:
|
test_f7:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
@@ -356,7 +504,7 @@ jobs:
|
|||||||
test_f4:
|
test_f4:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
@@ -371,7 +519,7 @@ jobs:
|
|||||||
test_h743:
|
test_h743:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
@@ -385,7 +533,7 @@ jobs:
|
|||||||
test_h723:
|
test_h723:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
@@ -395,7 +543,7 @@ jobs:
|
|||||||
test_h5:
|
test_h5:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
@@ -405,7 +553,7 @@ jobs:
|
|||||||
test_rt1020:
|
test_rt1020:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
@@ -415,17 +563,37 @@ jobs:
|
|||||||
test_rt1060:
|
test_rt1060:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
- run: make -C examples/nxp/rt1060-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
- run: make -C examples/nxp/rt1060-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
- run: make -C examples/nxp/rt1060-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
- run: make -C examples/nxp/rt1060-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
|
||||||
|
test_rt1170:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with: { fetch-depth: 3 }
|
||||||
|
- name: baremetal
|
||||||
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
|
- run: make -C examples/nxp/rt1170-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
# - run: make -C examples/nxp/rt1170-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
|
||||||
|
test_ra6m4:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with: { fetch-depth: 3 }
|
||||||
|
- name: baremetal
|
||||||
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
|
- run: make -C examples/renesas/ek-ra6m4-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
# - run: make -C examples/renesas/ek-ra6m4-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
|
||||||
test_tm4c:
|
test_tm4c:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
@@ -435,7 +603,7 @@ jobs:
|
|||||||
test_same54:
|
test_same54:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
@@ -445,7 +613,7 @@ jobs:
|
|||||||
test_pico_w5500:
|
test_pico_w5500:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: SDK
|
- name: SDK
|
||||||
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
|
|||||||
+159
-79
@@ -15,64 +15,58 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
cc: [gcc, clang++]
|
cc: [gcc, clang++]
|
||||||
target: [test, mip_test]
|
target: [test, mip_test]
|
||||||
ssl: ["", MBEDTLS]
|
ssl: ["", BUILTIN]
|
||||||
name: linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }}}
|
name: linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }}
|
||||||
env:
|
env:
|
||||||
CC: ${{ matrix.cc }}
|
CC: ${{ matrix.cc }}
|
||||||
SSL: ${{ matrix.ssl }}
|
SSL: ${{ matrix.ssl }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: ./test/setup_ga_network.sh && sudo apt -y update ; sudo apt -y install libmbedtls-dev && make ${{ matrix.target }}
|
run: ./test/setup_ga_network.sh && make -C test ${{ matrix.target }}
|
||||||
s390:
|
s390:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make s390
|
run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test s390
|
||||||
armhf:
|
armhf:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make armhf
|
run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test armhf
|
||||||
linux2:
|
unamalgamated-mg_prefix:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: sudo apt -y update ; sudo apt -y install libmbedtls-dev valgrind
|
run: make -C test unamalgamated && make -C test mg_prefix
|
||||||
- if: ${{ env.GO == 1 }}
|
|
||||||
run: make unamalgamated && make valgrind && make mg_prefix
|
|
||||||
macos:
|
macos:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
ssl: ["", MBEDTLS]
|
ssl: ["", BUILTIN]
|
||||||
name: macos SSL=${{ matrix.ssl }}
|
name: macos SSL=${{ matrix.ssl }}
|
||||||
env:
|
env:
|
||||||
SSL: ${{ matrix.ssl }}
|
SSL: ${{ matrix.ssl }}
|
||||||
TFLAGS: -DNO_SNTP_CHECK -Wno-sign-conversion # Workaround for MbedTLS 3.5.0
|
TFLAGS: -DNO_SNTP_CHECK
|
||||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: brew install jq mbedtls openssl
|
run: make -C test test ASAN_OPTIONS=
|
||||||
- if: ${{ env.GO == 1 }}
|
|
||||||
run: make test ASAN_OPTIONS= MBEDTLS=`echo /usr/local/Cellar/mbedtls*/*` OPENSSL=`echo /usr/local/Cellar/openssl*/*`
|
|
||||||
- if: ${{ env.GO == 1 }}
|
|
||||||
run: make mg_prefix
|
|
||||||
windows:
|
windows:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
@@ -81,75 +75,102 @@ jobs:
|
|||||||
target: [vc98, vc22, mingw++]
|
target: [vc98, vc22, mingw++]
|
||||||
name: windows ${{ matrix.target }}
|
name: windows ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: make ${{ matrix.target }}
|
run: make -C test ${{ matrix.target }}
|
||||||
arm:
|
arm:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: make arm
|
- run: make -C test arm
|
||||||
riscv:
|
riscv:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: make riscv
|
- run: make -C test riscv
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: sudo apt -y install libmbedtls-dev libpcap-dev
|
- run: make -C test examples_essential
|
||||||
- run: make examples
|
- run: make -C test clean_examples_essential
|
||||||
- run: make clean
|
|
||||||
examples_win:
|
examples_win:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
# - uses: egor-tensin/setup-mingw@v2
|
# - uses: egor-tensin/setup-mingw@v2
|
||||||
# with:
|
# with:
|
||||||
# platform: x64
|
# platform: x64
|
||||||
- name: test they build
|
- name: test they build
|
||||||
run: make examples_win
|
run: make -C test examples_win
|
||||||
shell: cmd
|
shell: cmd
|
||||||
- name: test they clean
|
- name: test they clean
|
||||||
run: make clean_examples_win
|
run: make -C test clean_examples_win
|
||||||
shell: cmd
|
shell: cmd
|
||||||
examples_mac:
|
examples_mac:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
|
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: make examples_mac
|
- run: make -C test examples_mac
|
||||||
- run: make clean_examples_mac
|
- run: make -C test clean_examples_mac
|
||||||
|
|
||||||
|
refprojs:
|
||||||
arduino:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
GO: 0
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
- run: make -C test refprojs
|
||||||
- run: |
|
- run: make -C test clean_refprojs
|
||||||
if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/arduino" ; then
|
refprojs_win:
|
||||||
echo GO=1 >> $GITHUB_ENV
|
runs-on: windows-latest
|
||||||
# nothing specific to install or do
|
steps:
|
||||||
fi
|
- uses: actions/checkout@v4
|
||||||
- if: ${{ env.GO == 1 }}
|
# - uses: egor-tensin/setup-mingw@v2
|
||||||
run: |
|
# with:
|
||||||
if ./test/match_changed_files.sh '^src|examples/arduino'; then
|
# platform: x64
|
||||||
make -C examples/arduino arduino-xiao
|
- name: test they build
|
||||||
fi
|
run: make -C test refprojs_win
|
||||||
# - if: ${{ env.GO == 1 }}
|
shell: cmd
|
||||||
# run: |
|
- name: test they clean
|
||||||
# if ./test/match_changed_files.sh '^src|examples/arduino'; then
|
run: make -C test clean_refprojs_win
|
||||||
# make -C examples/arduino arduino-nano
|
shell: cmd
|
||||||
# fi
|
refprojs_mac:
|
||||||
- if: ${{ env.GO == 1 }}
|
runs-on: macos-latest
|
||||||
run: make -C examples/arduino clean
|
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: make -C test refprojs
|
||||||
|
- run: make -C test clean_refprojs
|
||||||
|
|
||||||
|
tutorials:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: make -C test tutorials_essential
|
||||||
|
- run: make -C test clean_tutorials_essential
|
||||||
|
tutorials_win:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
# - uses: egor-tensin/setup-mingw@v2
|
||||||
|
# with:
|
||||||
|
# platform: x64
|
||||||
|
- name: test they build
|
||||||
|
run: make -C test tutorials_win
|
||||||
|
shell: cmd
|
||||||
|
- name: test they clean
|
||||||
|
run: make -C test clean_tutorials_win
|
||||||
|
shell: cmd
|
||||||
|
tutorials_mac:
|
||||||
|
runs-on: macos-latest
|
||||||
|
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: make -C test tutorials_mac
|
||||||
|
- run: make -C test clean_tutorials_mac
|
||||||
|
|
||||||
|
|
||||||
generic_examples:
|
generic_examples:
|
||||||
@@ -164,7 +185,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
@@ -185,7 +206,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
@@ -204,7 +225,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: |
|
- run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|^examples/${{ matrix.example.path }}'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|^examples/${{ matrix.example.path }}'; then
|
||||||
@@ -225,6 +246,8 @@ jobs:
|
|||||||
- path: nxp/rt1020-evk-make-freertos-builtin
|
- path: nxp/rt1020-evk-make-freertos-builtin
|
||||||
- path: nxp/rt1060-evk-make-baremetal-builtin
|
- path: nxp/rt1060-evk-make-baremetal-builtin
|
||||||
- path: nxp/rt1060-evk-make-freertos-builtin
|
- path: nxp/rt1060-evk-make-freertos-builtin
|
||||||
|
- path: nxp/rt1170-evk-make-baremetal-builtin
|
||||||
|
- path: renesas/ek-ra6m4-make-baremetal-builtin
|
||||||
- path: rp2040/pico-rndis-dashboard
|
- path: rp2040/pico-rndis-dashboard
|
||||||
- path: rp2040/pico-w
|
- path: rp2040/pico-w
|
||||||
- path: rp2040/pico-w5500
|
- path: rp2040/pico-w5500
|
||||||
@@ -247,7 +270,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: |
|
- run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|^examples/${{ matrix.example.path }}'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|^examples/${{ matrix.example.path }}'; then
|
||||||
@@ -268,7 +291,7 @@ jobs:
|
|||||||
# env:
|
# env:
|
||||||
# GO: 0
|
# GO: 0
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v3
|
# - uses: actions/checkout@v4
|
||||||
# with: { fetch-depth: 2 }
|
# with: { fetch-depth: 2 }
|
||||||
# - run: |
|
# - run: |
|
||||||
# if ./test/match_changed_files.sh '^src|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
|
# if ./test/match_changed_files.sh '^src|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
|
||||||
@@ -289,7 +312,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: |
|
- run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
|
if ./test/match_changed_files.sh '^src|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
|
||||||
@@ -310,7 +333,7 @@ jobs:
|
|||||||
# env:
|
# env:
|
||||||
# GO: 0
|
# GO: 0
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v3
|
# - uses: actions/checkout@v4
|
||||||
# with: { fetch-depth: 2 }
|
# with: { fetch-depth: 2 }
|
||||||
# - run: |
|
# - run: |
|
||||||
# if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
|
# if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
|
||||||
@@ -339,7 +362,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: |
|
- run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
|
||||||
@@ -362,7 +385,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: |
|
- run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-*-cube-*'; then
|
if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-*-cube-*'; then
|
||||||
@@ -377,7 +400,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -387,6 +410,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
# always run baremetal on core or dashboard or specific example changes; other examples only on specific example changes
|
# always run baremetal on core or dashboard or specific example changes; other examples only on specific example changes
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true # continue so next test has a chance to re-flash and exit from collisions and flash failures
|
||||||
run: |
|
run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-f746zg-make-baremetal-builtin'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-f746zg-make-baremetal-builtin'; then
|
||||||
make -C examples/stm32/nucleo-f746zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
make -C examples/stm32/nucleo-f746zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
@@ -430,7 +454,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -439,6 +463,7 @@ jobs:
|
|||||||
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
fi
|
fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-f429zi-make-baremetal-builtin'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-f429zi-make-baremetal-builtin'; then
|
||||||
make -C examples/stm32/nucleo-f429zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
make -C examples/stm32/nucleo-f429zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
@@ -476,7 +501,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -485,6 +510,7 @@ jobs:
|
|||||||
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
fi
|
fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h743zi-make-baremetal-builtin'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h743zi-make-baremetal-builtin'; then
|
||||||
make -C examples/stm32/nucleo-h743zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
make -C examples/stm32/nucleo-h743zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
@@ -517,7 +543,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -526,6 +552,7 @@ jobs:
|
|||||||
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
fi
|
fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h723zg-make-baremetal-builtin'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h723zg-make-baremetal-builtin'; then
|
||||||
make -C examples/stm32/nucleo-h723zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
make -C examples/stm32/nucleo-h723zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
@@ -541,7 +568,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -550,6 +577,7 @@ jobs:
|
|||||||
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
fi
|
fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h563zi-make-baremetal-builtin'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h563zi-make-baremetal-builtin'; then
|
||||||
make -C examples/stm32/nucleo-h563zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
make -C examples/stm32/nucleo-h563zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
@@ -565,7 +593,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -574,6 +602,7 @@ jobs:
|
|||||||
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
fi
|
fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1020-evk-make-baremetal-builtin'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1020-evk-make-baremetal-builtin'; then
|
||||||
make -C examples/nxp/rt1020-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
make -C examples/nxp/rt1020-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
@@ -589,7 +618,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -598,6 +627,7 @@ jobs:
|
|||||||
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
fi
|
fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1060-evk-make-baremetal-builtin'; then
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1060-evk-make-baremetal-builtin'; then
|
||||||
make -C examples/nxp/rt1060-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
make -C examples/nxp/rt1060-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
@@ -608,12 +638,62 @@ jobs:
|
|||||||
make -C examples/nxp/rt1060-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
make -C examples/nxp/rt1060-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
test_rt1170:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GO: 0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with: { fetch-depth: 3 }
|
||||||
|
- name: baremetal
|
||||||
|
run: |
|
||||||
|
if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/nxp/rt1170.*-make-" ; then
|
||||||
|
echo GO=1 >> $GITHUB_ENV
|
||||||
|
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
|
fi
|
||||||
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1170-evk-make-baremetal-builtin'; then
|
||||||
|
make -C examples/nxp/rt1170-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
fi
|
||||||
|
# - if: ${{ env.GO == 1 }}
|
||||||
|
# run: |
|
||||||
|
# if ./test/match_changed_files.sh 'examples/nxp/rt1170-evk-make-freertos-builtin'; then
|
||||||
|
# make -C examples/nxp/rt1170-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
# fi
|
||||||
|
|
||||||
|
test_ra6m4:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GO: 0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with: { fetch-depth: 3 }
|
||||||
|
- name: baremetal
|
||||||
|
run: |
|
||||||
|
if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/renesas/ek-ra6m4.*-make-" ; then
|
||||||
|
echo GO=1 >> $GITHUB_ENV
|
||||||
|
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||||
|
fi
|
||||||
|
- if: ${{ env.GO == 1 }}
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/renesas/ek-ra6m4-make-baremetal-builtin'; then
|
||||||
|
make -C examples/renesas/ek-ra6m4-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
fi
|
||||||
|
# - if: ${{ env.GO == 1 }}
|
||||||
|
# run: |
|
||||||
|
# if ./test/match_changed_files.sh 'examples/renesas/ek-ra6m4-make-freertos-builtin'; then
|
||||||
|
# make -C examples/renesas/ek-ra6m4-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
|
# fi
|
||||||
|
|
||||||
test_tm4c:
|
test_tm4c:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -637,7 +717,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: baremetal
|
- name: baremetal
|
||||||
run: |
|
run: |
|
||||||
@@ -661,7 +741,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GO: 0
|
GO: 0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- name: SDK
|
- name: SDK
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: original workflow, updated
|
name: original workflow, outdated # *** YES, OUTDATED *** kept for hystorical/reference purposes, attachment, etc.
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Copyright (c) 2004-2013 Sergey Lyubka
|
Copyright (c) 2004-2013 Sergey Lyubka
|
||||||
Copyright (c) 2013-2023 Cesanta Software Limited
|
Copyright (c) 2013-2024 Cesanta Software Limited
|
||||||
All rights reserved
|
All rights reserved
|
||||||
|
|
||||||
This software is dual-licensed: you can redistribute it and/or modify
|
This software is dual-licensed: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,196 +0,0 @@
|
|||||||
SRCS = mongoose.c test/unit_test.c test/packed_fs.c
|
|
||||||
HDRS = $(wildcard src/*.h) $(wildcard src/drivers/*.h)
|
|
||||||
DEFS ?= -DMG_MAX_HTTP_HEADERS=7 -DMG_ENABLE_LINES -DMG_ENABLE_PACKED_FS=1 -DMG_ENABLE_SSI=1 -DMG_ENABLE_ASSERT=1
|
|
||||||
WARN ?= -pedantic -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wundef
|
|
||||||
OPTS ?= -O3 -g3
|
|
||||||
INCS ?= -Isrc -I.
|
|
||||||
SSL ?=
|
|
||||||
CWD ?= $(realpath $(CURDIR))
|
|
||||||
ENV ?= -e Tmp=. -e WINEDEBUG=-all
|
|
||||||
DOCKER_BIN ?= docker
|
|
||||||
DOCKER ?= $(DOCKER_BIN) run --platform linux/amd64 --rm $(ENV) -v $(CWD):$(CWD) -w $(CWD)
|
|
||||||
VCFLAGS = /nologo /W3 /O2 /MD /I. $(DEFS) $(TFLAGS)
|
|
||||||
IPV6 ?= 1
|
|
||||||
ASAN ?= -fsanitize=address,undefined,alignment -fno-sanitize-recover=all -fno-omit-frame-pointer -fno-common
|
|
||||||
ASAN_OPTIONS ?= detect_leaks=1
|
|
||||||
EXAMPLES := $(dir $(wildcard examples/*/Makefile))
|
|
||||||
EXAMPLES_MAC := $(filter-out examples/mip-pcap/ examples/mip-tap/ examples/micropython/, $(EXAMPLES))
|
|
||||||
EXAMPLES_WIN := $(dir $(wildcard examples/device-dashboard/Makefile) $(wildcard examples/file-*/Makefile) $(wildcard examples/http-*/Makefile) $(wildcard examples/mqtt-*/Makefile) $(wildcard examples/websocket-*/Makefile) $(wildcard examples/webui-*/Makefile))
|
|
||||||
EXAMPLES_EMBEDDED := $(filter-out $(wildcard examples/zephyr/*/), $(dir $(wildcard examples/*/*/Makefile)))
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
LIBDIR ?= $(PREFIX)/lib
|
|
||||||
INCLUDEDIR ?= $(PREFIX)/include
|
|
||||||
VERSION ?= $(shell cut -d'"' -f2 src/version.h)
|
|
||||||
COMMON_CFLAGS ?= $(C_WARN) $(WARN) $(INCS) $(DEFS) -DMG_ENABLE_IPV6=$(IPV6) $(TFLAGS) -pthread
|
|
||||||
CFLAGS ?= $(OPTS) $(ASAN) $(COMMON_CFLAGS)
|
|
||||||
VALGRIND_CFLAGS ?= $(OPTS) $(COMMON_CFLAGS)
|
|
||||||
VALGRIND_RUN ?= valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --show-leak-kinds=all --leak-resolution=high --track-origins=yes --error-exitcode=1 --exit-on-first-error=yes --fair-sched=yes
|
|
||||||
.PHONY: clean_examples examples mip_test test valgrind
|
|
||||||
|
|
||||||
ifeq "$(findstring ++,$(CC))" ""
|
|
||||||
# $(CC) does not end with ++, i.e. we're using C. Apply C flags
|
|
||||||
C_WARN ?= -Wmissing-prototypes -Wstrict-prototypes
|
|
||||||
else
|
|
||||||
# $(CC) ends with ++, i.e. we're using C++. Apply C++ flags
|
|
||||||
C_WARN ?= -Wno-deprecated
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(SSL)" "MBEDTLS"
|
|
||||||
MBEDTLS ?= /usr/local
|
|
||||||
CFLAGS += -DMG_TLS=MG_TLS_MBED -I$(MBEDTLS)/include -I/usr/include
|
|
||||||
LDFLAGS += -L$(MBEDTLS)/lib -lmbedtls -lmbedcrypto -lmbedx509
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(SSL)" "OPENSSL"
|
|
||||||
OPENSSL ?= /usr/local
|
|
||||||
CFLAGS += -DMG_TLS=MG_TLS_OPENSSL -I$(OPENSSL)/include
|
|
||||||
LDFLAGS += -L$(OPENSSL)/lib -lssl -lcrypto
|
|
||||||
endif
|
|
||||||
|
|
||||||
all:
|
|
||||||
$(MAKE) -C examples/http-server
|
|
||||||
|
|
||||||
tall: mg_prefix unamalgamated test mip_test arm examples vc98 vc17 vc22 mingw mingw++ fuzz
|
|
||||||
|
|
||||||
mip_test: test/mip_test.c mongoose.c mongoose.h Makefile mip_tap_test
|
|
||||||
$(CC) test/mip_test.c $(INCS) $(WARN) $(OPTS) $(C_WARN) $(ASAN) -o $@
|
|
||||||
ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./$@
|
|
||||||
|
|
||||||
mip_tap_test: test/mip_tap_test.c mongoose.c mongoose.h Makefile
|
|
||||||
$(CC) test/mip_tap_test.c $(INCS) $(WARN) $(OPTS) $(C_WARN) $(ASAN) -o $@
|
|
||||||
ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./$@
|
|
||||||
|
|
||||||
examples:
|
|
||||||
@for X in $(EXAMPLES); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done
|
|
||||||
clean_examples:
|
|
||||||
for X in $(EXAMPLES); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done
|
|
||||||
|
|
||||||
examples_mac:
|
|
||||||
for X in $(EXAMPLES_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done
|
|
||||||
clean_examples_mac:
|
|
||||||
for X in $(EXAMPLES_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done
|
|
||||||
|
|
||||||
examples_win:
|
|
||||||
$(foreach X, $(EXAMPLES_WIN), $(MAKE) -C $(X) example &)
|
|
||||||
clean_examples_win:
|
|
||||||
$(foreach X, $(EXAMPLES_WIN), $(MAKE) -C $(X) clean &)
|
|
||||||
|
|
||||||
test/packed_fs.c: Makefile src/ssi.h test/fuzz.c test/data/a.txt test/data/ca.pem
|
|
||||||
$(CC) $(CFLAGS) test/pack.c -o pack
|
|
||||||
$(RUN) ./pack Makefile src/ssi.h test/fuzz.c test/data/a.txt test/data/range.txt test/data/ca.pem > $@
|
|
||||||
|
|
||||||
# Check that all external (exported) symbols have "mg_" prefix
|
|
||||||
mg_prefix: mongoose.c mongoose.h
|
|
||||||
$(CC) mongoose.c $(CFLAGS) -c -o /tmp/x.o && nm /tmp/x.o | grep ' T ' | grep -v 'mg_' ; test $$? = 1
|
|
||||||
|
|
||||||
musl: test
|
|
||||||
musl: ASAN =
|
|
||||||
musl: WARN += -Wno-sign-conversion
|
|
||||||
musl: CC = $(DOCKER) mdashnet/cc1 gcc
|
|
||||||
musl: RUN = $(DOCKER) mdashnet/cc1
|
|
||||||
|
|
||||||
# Make sure we can build from unamalgamated sources.
|
|
||||||
unamalgamated: CFLAGS += -DMG_ENABLE_MD5=1
|
|
||||||
unamalgamated: $(HDRS) Makefile test/packed_fs.c
|
|
||||||
$(CC) src/*.c test/packed_fs.c test/unit_test.c $(CFLAGS) $(LDFLAGS) -g -o unit_test
|
|
||||||
|
|
||||||
fuzz: ASAN = -fsanitize=fuzzer,signed-integer-overflow,address,undefined
|
|
||||||
fuzz: mongoose.c mongoose.h Makefile test/fuzz.c
|
|
||||||
$(CC) test/fuzz.c $(OPTS) $(WARN) $(INCS) $(TFLAGS) $(ASAN) -o fuzzer
|
|
||||||
$(RUN) ./fuzzer
|
|
||||||
|
|
||||||
FUZZDATA ?= /tmp/fuzzdata
|
|
||||||
fuzz2: mongoose.c mongoose.h Makefile test/fuzz.c
|
|
||||||
$(CC) test/fuzz.c -DMAIN $(OPTS) $(WARN) $(ASAN) $(INCS) -o fuzzer
|
|
||||||
$(RUN) ./fuzzer $(FUZZDATA)
|
|
||||||
|
|
||||||
test: Makefile mongoose.h $(SRCS)
|
|
||||||
$(CC) $(SRCS) $(CFLAGS) $(LDFLAGS) -o unit_test
|
|
||||||
ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./unit_test
|
|
||||||
|
|
||||||
coverage: CFLAGS += -coverage
|
|
||||||
coverage: test
|
|
||||||
gcov -l -n *.gcno | sed '/^$$/d' | sed 'N;s/\n/ /'
|
|
||||||
gcov -t mongoose.c > mongoose.gcov
|
|
||||||
|
|
||||||
upload-coverage: coverage
|
|
||||||
curl -s https://codecov.io/bash | /bin/bash
|
|
||||||
|
|
||||||
valgrind: Makefile mongoose.h mongoose.c
|
|
||||||
$(CC) $(SRCS) $(VALGRIND_CFLAGS) $(LDFLAGS) -g -o unit_test
|
|
||||||
$(VALGRIND_RUN) ./unit_test
|
|
||||||
|
|
||||||
misra:
|
|
||||||
cppcheck --addon=misra -DMG_ARCH=MG_ARCH_UNIX -DMG_ENABLE_PACKED_FS=1 -DMG_ENABLE_SSI=1 mongoose.c >/tmp/x 2>&1
|
|
||||||
cppcheck --addon=misra -DMG_ARCH=MG_ARCH_CUSTOM -DMG_ENABLE_LINES=1 -DTLS=MG_TLS_BUILTIN -DMG_ENABLE_TCPIP=1 mongoose.c >>/tmp/x 2>&1
|
|
||||||
cppcheck --addon=misra --clang -DMG_ENABLE_LINES=1 -DTLS=MG_TLS_BUILTIN -DMG_ENABLE_TCPIP=1 mongoose.c >>/tmp/x 2>&1
|
|
||||||
cppcheck --addon=misra --clang -DMG_ENABLE_LINES=1 -DMG_ENABLE_SSI=1 mongoose.c >>/tmp/x 2>&1
|
|
||||||
less /tmp/x
|
|
||||||
|
|
||||||
armhf: ASAN=
|
|
||||||
armhf: IPV6=0
|
|
||||||
armhf: CC = $(DOCKER) mdashnet/armhf cc
|
|
||||||
armhf: RUN = $(DOCKER) mdashnet/armhf
|
|
||||||
armhf: test
|
|
||||||
|
|
||||||
s390: ASAN=
|
|
||||||
s390: IPV6=0
|
|
||||||
s390: CC = $(DOCKER) mdashnet/s390 cc
|
|
||||||
s390: RUN = $(DOCKER) mdashnet/s390
|
|
||||||
s390: test
|
|
||||||
|
|
||||||
arm: DEFS += -DMG_ENABLE_POSIX_FS=0 -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB
|
|
||||||
arm: mongoose.h $(SRCS)
|
|
||||||
$(DOCKER) mdashnet/armgcc arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb $(SRCS) $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) -o unit_test -nostartfiles --specs nosys.specs -e 0
|
|
||||||
|
|
||||||
riscv: DEFS += -DMG_ENABLE_POSIX_FS=0 -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB
|
|
||||||
riscv: mongoose.h $(SRCS)
|
|
||||||
$(DOCKER) mdashnet/riscv riscv-none-elf-gcc -march=rv32imc -mabi=ilp32 $(SRCS) $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) -o unit_test
|
|
||||||
|
|
||||||
vc98: Makefile mongoose.h $(SRCS)
|
|
||||||
$(DOCKER) mdashnet/vc98 wine cl $(SRCS) $(VCFLAGS) ws2_32.lib /Fe$@.exe
|
|
||||||
$(DOCKER) mdashnet/vc98 wine $@.exe
|
|
||||||
|
|
||||||
vc17: Makefile mongoose.h $(SRCS)
|
|
||||||
$(DOCKER) mdashnet/vc17 wine64 cl $(SRCS) $(VCFLAGS) ws2_32.lib /Fe$@.exe
|
|
||||||
$(DOCKER) mdashnet/vc17 wine64 $@.exe
|
|
||||||
|
|
||||||
vc22: Makefile mongoose.h $(SRCS)
|
|
||||||
$(DOCKER) mdashnet/vc22 wine64 cl $(SRCS) $(VCFLAGS) ws2_32.lib /Fe$@.exe
|
|
||||||
$(DOCKER) mdashnet/vc22 wine64 $@.exe
|
|
||||||
|
|
||||||
mingw: Makefile mongoose.h $(SRCS)
|
|
||||||
$(DOCKER) mdashnet/mingw x86_64-w64-mingw32-gcc $(SRCS) -W -Wall -Werror -I. $(DEFS) -lwsock32 -o $@.exe
|
|
||||||
$(DOCKER) mdashnet/mingw wine64 $@.exe
|
|
||||||
|
|
||||||
mingw++: Makefile mongoose.h $(SRCS)
|
|
||||||
$(DOCKER) mdashnet/mingw x86_64-w64-mingw32-g++ $(SRCS) -W -Wall -Werror -I. $(DEFS) -lwsock32 -o $@.exe
|
|
||||||
|
|
||||||
linux-libs: CFLAGS += -fPIC
|
|
||||||
linux-libs: LDFLAGS += -Wl,-soname,libmongoose.so.$(VERSION)
|
|
||||||
linux-libs: mongoose.o
|
|
||||||
$(CC) mongoose.o $(LDFLAGS) -shared -o libmongoose.so.$(VERSION)
|
|
||||||
$(AR) rcs libmongoose.a mongoose.o
|
|
||||||
|
|
||||||
install: linux-libs
|
|
||||||
install -Dm644 libmongoose.a libmongoose.so.$(VERSION) $(DESTDIR)$(LIBDIR)
|
|
||||||
ln -s libmongoose.so.$(VERSION) $(DESTDIR)$(LIBDIR)/libmongoose.so
|
|
||||||
install -Dm644 mongoose.h $(DESTDIR)$(INCLUDEDIR)/mongoose.h
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
rm -rf $(DESTDIR)$(LIBDIR)/libmongoose.a $(DESTDIR)$(LIBDIR)/libmongoose.so.$(VERSION) $(DESTDIR)$(INCLUDEDIR)/mongoose.h $(DESTDIR)$(LIBDIR)/libmongoose.so
|
|
||||||
|
|
||||||
mongoose.c: Makefile $(wildcard src/*.c) $(wildcard src/drivers/*.c)
|
|
||||||
(export LC_ALL=C ; cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/*.c src/drivers/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@
|
|
||||||
|
|
||||||
mongoose.h: $(HDRS) Makefile
|
|
||||||
(cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/arch.h src/arch_*.h src/net_ft.h src/net_lwip.h src/net_rl.h src/config.h src/str.h src/queue.h src/fmt.h src/printf.h src/log.h src/timer.h src/fs.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/sha256.h src/tls_aes128.h src/tls_uecc.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/tls_mbed.h src/tls_openssl.h src/ws.h src/sntp.h src/mqtt.h src/dns.h src/json.h src/rpc.h src/ota.h src/device.h src/net_builtin.h src/profile.h src/drivers/*.h | sed -e '/keep/! s,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@
|
|
||||||
|
|
||||||
|
|
||||||
clean: clean_examples clean_embedded
|
|
||||||
rm -rf $(PROG) *.exe *.o *.dSYM *_test* ut fuzzer *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb slow-unit* _CL_* infer-out data.txt crash-* test/packed_fs.c pack
|
|
||||||
#find examples -maxdepth 3 -name zephyr -prune -o -name Makefile -print | xargs dirname | xargs -n1 make clean -C
|
|
||||||
|
|
||||||
clean_embedded:
|
|
||||||
for X in $(EXAMPLES_EMBEDDED); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done
|
|
||||||
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
# Mongoose - Embedded Web Server / Embedded Networking Library
|
# Mongoose - Embedded Web Server / Embedded Network Library
|
||||||
|
|
||||||
[](https://opensource.org/licenses/gpl-2.0.php)
|
[](https://opensource.org/licenses/gpl-2.0.php)
|
||||||
[](https://github.com/cesanta/mongoose/actions)
|
[](https://github.com/cesanta/mongoose/actions)
|
||||||
[](https://codecov.io/gh/cesanta/mongoose)
|
[](https://codecov.io/gh/cesanta/mongoose)
|
||||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:mongoose)
|
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:mongoose)
|
||||||
|
|
||||||
Mongoose is a network library for C/C++.
|
Mongoose is a network library for C/C++. It provides event-driven non-blocking
|
||||||
It implements event-driven
|
APIs for TCP, UDP, HTTP, WebSocket, MQTT, and other protocols. It is designed
|
||||||
non-blocking APIs for TCP, UDP, HTTP, WebSocket, MQTT. It is designed for
|
for connecting devices and bringing them online. On the market since 2004, used
|
||||||
connecting devices and bringing them online. On the market since 2004, used by
|
by vast number of open source and commercial products - it even runs on the
|
||||||
vast number of open source and commercial products - it even runs on the
|
|
||||||
International Space Station! Mongoose makes embedded network programming fast,
|
International Space Station! Mongoose makes embedded network programming fast,
|
||||||
robust, and easy. Features include:
|
robust, and easy. Features include:
|
||||||
|
|
||||||
@@ -18,55 +17,57 @@ robust, and easy. Features include:
|
|||||||
- works on STM32, NXP, ESP32, NRF52, TI, Microchip, and other
|
- works on STM32, NXP, ESP32, NRF52, TI, Microchip, and other
|
||||||
- write code once - and it'll work everywhere
|
- write code once - and it'll work everywhere
|
||||||
- ideal for the unification of the network infrastructure code across company
|
- ideal for the unification of the network infrastructure code across company
|
||||||
- Built-in protocols: plain TCP/UDP, SNTP, HTTP, MQTT, Websocket
|
- Built-in protocols: plain TCP/UDP, SNTP, HTTP, MQTT, Websocket, and other
|
||||||
- SSL/TLS support for mbedTLS and OpenSSL
|
|
||||||
- Asynchronous DNS resolver
|
- Asynchronous DNS resolver
|
||||||
- Tiny static and run-time footprint
|
- Tiny static and run-time footprint
|
||||||
- Source code is both ISO C and ISO C++ compliant
|
- Source code is both ISO C and ISO C++ compliant
|
||||||
- Very easy to integrate: just copy `mongoose.c` and `mongoose.h` files to your source tree. See
|
- Easy to integrate: just copy [mongoose.c](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.c)
|
||||||
[exact steps](https://mongoose.ws/documentation/#2-minute-integration-guide)
|
and [mongoose.h](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.h) files to your source tree
|
||||||
- Works in any environment with socket API, like LwIP, Zephyr, Azure
|
|
||||||
- Built-in TCP/IP stack with drivers for bare metal or RTOS systems
|
- Built-in TCP/IP stack with drivers for bare metal or RTOS systems
|
||||||
- Available drivers: STM32F, STM32H; NXP RT1xxx; TI TM4C; Microchip SAME54; Wiznet W5500
|
- Available drivers: STM32F, STM32H; NXP RT1xxx; TI TM4C; Microchip SAME54; Wiznet W5500
|
||||||
- A complete Web device dashboard on bare metal
|
- A complete Web device dashboard on bare metal ST Nucleo boards is only 6 files
|
||||||
[Nucleo-F429ZI](examples/stm32/nucleo-f429zi-baremetal) is only 6 files
|
|
||||||
- For comparison, a CubeIDE generated HTTP example is 400+ files
|
- For comparison, a CubeIDE generated HTTP example is 400+ files
|
||||||
- Built-in TLS 1.3 server-side support
|
- Can run on top of an existing TCP/IP stack with BSD API, e.g. lwIP, Zephyr, Azure, etc
|
||||||
|
- Built-in TLS 1.3 ECC stack. Also can use external TLS libraries - mbedTLS, OpenSSL, or other
|
||||||
- Does not depend on any other software to implement networking
|
- Does not depend on any other software to implement networking
|
||||||
- Built-in firmware updates for STM32H5, STM32H7, and more coming
|
- Built-in firmware updates for STM32 H5, STM32 H7
|
||||||
- Detailed [user guide, API reference and tons of tutorials](https://mongoose.ws/documentation/)
|
|
||||||
|
|
||||||
## Usage
|
See https://mongoose.ws/ for complete documentation, videos, case studies, etc.
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
Below are quick snippets that should give an idea how simple the API is and
|
||||||
|
how easy it is to create applications with it.
|
||||||
|
|
||||||
Create a simple web server that serves a directory. The behavior of the
|
Create a simple web server that serves a directory. The behavior of the
|
||||||
HTTP server is specified by its event handler function:
|
HTTP server is specified by its event handler function:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
#include "mongoose.h"
|
#include "mongoose.h" // To build, run: cc main.c mongoose.c
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
struct mg_mgr mgr; // Declare event manager
|
|
||||||
mg_mgr_init(&mgr); // Initialise event manager
|
|
||||||
mg_http_listen(&mgr, "http://0.0.0.0:8000", fn, NULL); // Setup listener
|
|
||||||
for (;;) {
|
|
||||||
mg_mgr_poll(&mgr, 1000); // Run an infinite event loop
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTP server event handler function
|
// HTTP server event handler function
|
||||||
void fn(struct mg_connection *c, int ev, void *ev_data) {
|
void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
|
||||||
if (ev == MG_EV_HTTP_MSG) {
|
if (ev == MG_EV_HTTP_MSG) {
|
||||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
struct mg_http_serve_opts opts = { .root_dir = "./web_root/" };
|
struct mg_http_serve_opts opts = { .root_dir = "./web_root/" };
|
||||||
mg_http_serve_dir(c, hm, &opts);
|
mg_http_serve_dir(c, hm, &opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
struct mg_mgr mgr; // Declare event manager
|
||||||
|
mg_mgr_init(&mgr); // Initialise event manager
|
||||||
|
mg_http_listen(&mgr, "http://0.0.0.0:8000", ev_handler, NULL); // Setup listener
|
||||||
|
for (;;) { // Run an infinite event loop
|
||||||
|
mg_mgr_poll(&mgr, 1000);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
HTTP server implements a REST API that returns current time. JSON formatting:
|
HTTP server implements a REST API that returns current time. JSON formatting:
|
||||||
```c
|
```c
|
||||||
static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
|
||||||
if (ev == MG_EV_HTTP_MSG) {
|
if (ev == MG_EV_HTTP_MSG) {
|
||||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
if (mg_http_match_uri(hm, "/api/time/get")) {
|
if (mg_http_match_uri(hm, "/api/time/get")) {
|
||||||
@@ -78,20 +79,55 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
MQTT client that subscribes to a topic `aa/bb` and prints all incoming messages:
|
MQTT client that subscribes to a topic `device1/rx` and
|
||||||
|
echoes incoming messages to `device1/tx`:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
#include "mongoose.h"
|
||||||
if (ev == MG_EV_MQTT_OPEN) {
|
|
||||||
struct mg_mqtt_opts opts = {.qos = 1, .topic = mg_str("aa/bb")};
|
static const char *s_mqtt_url = "mqtt://broker.hivemq.com:1883";
|
||||||
|
static struct mg_connection *s_mqtt_conn = NULL;
|
||||||
|
|
||||||
|
// MQTT connection event handler function
|
||||||
|
static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
|
||||||
|
if (ev == MG_EV_OPEN) {
|
||||||
|
MG_INFO(("%lu created, connecting to %s ...", c->id, s_mqtt_url));
|
||||||
|
} else if (ev == MG_EV_MQTT_OPEN) {
|
||||||
|
struct mg_mqtt_opts opts = {.qos = 1, .topic = mg_str("device1/rx")};
|
||||||
mg_mqtt_sub(c, &opts);
|
mg_mqtt_sub(c, &opts);
|
||||||
|
MG_INFO(("%lu connected, subscribing to %s", c->id, opts.topic.buf));
|
||||||
} else if (ev == MG_EV_MQTT_MSG) {
|
} else if (ev == MG_EV_MQTT_MSG) {
|
||||||
|
char response[100];
|
||||||
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
|
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
|
||||||
printf("Topic: %.*s, Message: %.*s",
|
struct mg_mqtt_opts opts = {.qos = 1, .topic = mg_str("device1/tx")};
|
||||||
mm->topic.len, mm->topic.ptr,
|
mg_snprintf(response, sizeof(response), "Received [%.*s] / [%.*s]",
|
||||||
mm->data.len, mm->data.ptr);
|
mm->topic.len, mm->topic.buf, mm->data.len, mm->data.buf);
|
||||||
|
opts.message = mg_str(response);
|
||||||
|
mg_mqtt_pub(c, &opts);
|
||||||
|
} else if (ev == MG_EV_CLOSE) {
|
||||||
|
MG_INFO(("%u closing", c->id));
|
||||||
|
s_mqtt_conn = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reconnection timer function. If we get disconnected, reconnect again
|
||||||
|
static void timer_fn(void *arg) {
|
||||||
|
struct mg_mgr *mgr = (struct mg_mgr *) arg;
|
||||||
|
if (s_mqtt_conn == NULL) {
|
||||||
|
struct mg_mqtt_opts opts = {.clean = true};
|
||||||
|
s_mqtt_conn = mg_mqtt_connect(mgr, s_mqtt_url, &opts, ev_handler, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
struct mg_mgr mgr; // Mongoose event manager. Holds all connections
|
||||||
|
mg_mgr_init(&mgr); // Initialise event manager
|
||||||
|
mg_timer_add(&mgr, 3000, MG_TIMER_REPEAT | MG_TIMER_RUN_NOW, timer_fn, &mgr);
|
||||||
|
for (;;) {
|
||||||
|
mg_mgr_poll(&mgr, 1000); // Infinite event loop
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Commercial use
|
## Commercial use
|
||||||
|
|||||||
File renamed without changes.
@@ -32,13 +32,13 @@ static void simple_http_listener(struct mg_connection *c, int ev, void *ev_data)
|
|||||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
|
|
||||||
// If the requested URI is "/api/hi", send a simple JSON response back
|
// If the requested URI is "/api/hi", send a simple JSON response back
|
||||||
if (mg_http_match_uri(hm, "/api/hi")) {
|
if (mg_match(hm->uri, mg_str("/api/hi"), NULL)) {
|
||||||
// Use mg_http_reply() API function to generate JSON response. It adds a
|
// Use mg_http_reply() API function to generate JSON response. It adds a
|
||||||
// Content-Length header automatically. In the response, we show
|
// Content-Length header automatically. In the response, we show
|
||||||
// the requested URI and HTTP body:
|
// the requested URI and HTTP body:
|
||||||
mg_http_reply(c, 200, "", "{%m:%m,%m:%m}\n", // See mg_snprintf doc
|
mg_http_reply(c, 200, "", "{%m:%m,%m:%m}\n", // See mg_snprintf doc
|
||||||
MG_ESC("uri"), mg_print_esc, hm->uri.len, hm->uri.ptr,
|
MG_ESC("uri"), mg_print_esc, hm->uri.len, hm->uri.buf,
|
||||||
MG_ESC("body"), mg_print_esc, hm->body.len, hm->body.ptr);
|
MG_ESC("body"), mg_print_esc, hm->body.len, hm->body.buf);
|
||||||
} else {
|
} else {
|
||||||
// For all other URIs, serve some static content
|
// For all other URIs, serve some static content
|
||||||
mg_http_reply(c, 200, "", "<html>millis: %lu</html>", millis());
|
mg_http_reply(c, 200, "", "<html>millis: %lu</html>", millis());
|
||||||
|
|||||||
+1
@@ -10,6 +10,7 @@
|
|||||||
#define MG_ARCH MG_ARCH_CUSTOM
|
#define MG_ARCH MG_ARCH_CUSTOM
|
||||||
#define MG_ENABLE_SOCKET 0
|
#define MG_ENABLE_SOCKET 0
|
||||||
#define MG_ENABLE_TCPIP 1
|
#define MG_ENABLE_TCPIP 1
|
||||||
|
#define MG_ENABLE_DRIVER_W5500 1
|
||||||
#define mkdir(a, b) (-1)
|
#define mkdir(a, b) (-1)
|
||||||
#define MG_IO_SIZE 128
|
#define MG_IO_SIZE 128
|
||||||
//#define MG_ENABLE_LOG 0
|
//#define MG_ENABLE_LOG 0
|
||||||
+1
@@ -10,6 +10,7 @@
|
|||||||
#define MG_ARCH MG_ARCH_CUSTOM
|
#define MG_ARCH MG_ARCH_CUSTOM
|
||||||
#define MG_ENABLE_SOCKET 0
|
#define MG_ENABLE_SOCKET 0
|
||||||
#define MG_ENABLE_TCPIP 1
|
#define MG_ENABLE_TCPIP 1
|
||||||
|
#define MG_ENABLE_DRIVER_W5500 1
|
||||||
#define mkdir(a, b) (-1)
|
#define mkdir(a, b) (-1)
|
||||||
#define MG_IO_SIZE 512
|
#define MG_IO_SIZE 512
|
||||||
//#define MG_ENABLE_LOG 0
|
//#define MG_ENABLE_LOG 0
|
||||||
@@ -26,8 +26,8 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
// Received MQTT message
|
// Received MQTT message
|
||||||
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
|
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
|
||||||
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
|
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
|
||||||
mm->data.ptr, (int) mm->topic.len, mm->topic.ptr));
|
mm->data.buf, (int) mm->topic.len, mm->topic.buf));
|
||||||
exec_command(mm->data.ptr, mm->data.len);
|
exec_command(mm->data.buf, mm->data.len);
|
||||||
} else if (ev == MG_EV_CLOSE) {
|
} else if (ev == MG_EV_CLOSE) {
|
||||||
MG_INFO(("%lu CLOSED", c->id));
|
MG_INFO(("%lu CLOSED", c->id));
|
||||||
mqtt_connection = NULL;
|
mqtt_connection = NULL;
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/captive-dns-server/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -10,17 +10,4 @@ following features:
|
|||||||
needing a filesystem to serve it; so being resilient to FS problems
|
needing a filesystem to serve it; so being resilient to FS problems
|
||||||
- All changes are propagated to all connected clients
|
- All changes are propagated to all connected clients
|
||||||
|
|
||||||
## Screenshots
|
|
||||||
|
|
||||||
This is a login screen that prompts for user/password
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Main dashboard
|
|
||||||
|
|
||||||
The main dashboard page shows the interactive console
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/
|
See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/
|
||||||
@@ -210,7 +210,7 @@ static void handle_firmware_upload(struct mg_connection *c,
|
|||||||
mg_http_reply(c, 500, "", "offset and total not set\n");
|
mg_http_reply(c, 500, "", "offset and total not set\n");
|
||||||
} else if (ofs == 0 && mg_ota_begin((size_t) tot) == false) {
|
} else if (ofs == 0 && mg_ota_begin((size_t) tot) == false) {
|
||||||
mg_http_reply(c, 500, "", "mg_ota_begin(%ld) failed\n", tot);
|
mg_http_reply(c, 500, "", "mg_ota_begin(%ld) failed\n", tot);
|
||||||
} else if (data.len > 0 && mg_ota_write(data.ptr, data.len) == false) {
|
} else if (data.len > 0 && mg_ota_write(data.buf, data.len) == false) {
|
||||||
mg_http_reply(c, 500, "", "mg_ota_write(%lu) @%ld failed\n", data.len, ofs);
|
mg_http_reply(c, 500, "", "mg_ota_write(%lu) @%ld failed\n", data.len, ofs);
|
||||||
mg_ota_end();
|
mg_ota_end();
|
||||||
} else if (data.len == 0 && mg_ota_end() == false) {
|
} else if (data.len == 0 && mg_ota_end() == false) {
|
||||||
@@ -273,33 +273,33 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
struct user *u = authenticate(hm);
|
struct user *u = authenticate(hm);
|
||||||
|
|
||||||
if (mg_http_match_uri(hm, "/api/#") && u == NULL) {
|
if (mg_match(hm->uri, mg_str("/api/#"), NULL) && u == NULL) {
|
||||||
mg_http_reply(c, 403, "", "Not Authorised\n");
|
mg_http_reply(c, 403, "", "Not Authorised\n");
|
||||||
} else if (mg_http_match_uri(hm, "/api/login")) {
|
} else if (mg_match(hm->uri, mg_str("/api/login"), NULL)) {
|
||||||
handle_login(c, u);
|
handle_login(c, u);
|
||||||
} else if (mg_http_match_uri(hm, "/api/logout")) {
|
} else if (mg_match(hm->uri, mg_str("/api/logout"), NULL)) {
|
||||||
handle_logout(c);
|
handle_logout(c);
|
||||||
} else if (mg_http_match_uri(hm, "/api/debug")) {
|
} else if (mg_match(hm->uri, mg_str("/api/debug"), NULL)) {
|
||||||
handle_debug(c, hm);
|
handle_debug(c, hm);
|
||||||
} else if (mg_http_match_uri(hm, "/api/stats/get")) {
|
} else if (mg_match(hm->uri, mg_str("/api/stats/get"), NULL)) {
|
||||||
handle_stats_get(c);
|
handle_stats_get(c);
|
||||||
} else if (mg_http_match_uri(hm, "/api/events/get")) {
|
} else if (mg_match(hm->uri, mg_str("/api/events/get"), NULL)) {
|
||||||
handle_events_get(c, hm);
|
handle_events_get(c, hm);
|
||||||
} else if (mg_http_match_uri(hm, "/api/settings/get")) {
|
} else if (mg_match(hm->uri, mg_str("/api/settings/get"), NULL)) {
|
||||||
handle_settings_get(c);
|
handle_settings_get(c);
|
||||||
} else if (mg_http_match_uri(hm, "/api/settings/set")) {
|
} else if (mg_match(hm->uri, mg_str("/api/settings/set"), NULL)) {
|
||||||
handle_settings_set(c, hm->body);
|
handle_settings_set(c, hm->body);
|
||||||
} else if (mg_http_match_uri(hm, "/api/firmware/upload")) {
|
} else if (mg_match(hm->uri, mg_str("/api/firmware/upload"), NULL)) {
|
||||||
handle_firmware_upload(c, hm);
|
handle_firmware_upload(c, hm);
|
||||||
} else if (mg_http_match_uri(hm, "/api/firmware/commit")) {
|
} else if (mg_match(hm->uri, mg_str("/api/firmware/commit"), NULL)) {
|
||||||
handle_firmware_commit(c);
|
handle_firmware_commit(c);
|
||||||
} else if (mg_http_match_uri(hm, "/api/firmware/rollback")) {
|
} else if (mg_match(hm->uri, mg_str("/api/firmware/rollback"), NULL)) {
|
||||||
handle_firmware_rollback(c);
|
handle_firmware_rollback(c);
|
||||||
} else if (mg_http_match_uri(hm, "/api/firmware/status")) {
|
} else if (mg_match(hm->uri, mg_str("/api/firmware/status"), NULL)) {
|
||||||
handle_firmware_status(c);
|
handle_firmware_status(c);
|
||||||
} else if (mg_http_match_uri(hm, "/api/device/reset")) {
|
} else if (mg_match(hm->uri, mg_str("/api/device/reset"), NULL)) {
|
||||||
handle_device_reset(c);
|
handle_device_reset(c);
|
||||||
} else if (mg_http_match_uri(hm, "/api/device/eraselast")) {
|
} else if (mg_match(hm->uri, mg_str("/api/device/eraselast"), NULL)) {
|
||||||
handle_device_eraselast(c);
|
handle_device_eraselast(c);
|
||||||
} else {
|
} else {
|
||||||
struct mg_http_serve_opts opts;
|
struct mg_http_serve_opts opts;
|
||||||
@@ -313,7 +313,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
mg_http_serve_dir(c, ev_data, &opts);
|
mg_http_serve_dir(c, ev_data, &opts);
|
||||||
}
|
}
|
||||||
MG_DEBUG(("%lu %.*s %.*s -> %.*s", c->id, (int) hm->method.len,
|
MG_DEBUG(("%lu %.*s %.*s -> %.*s", c->id, (int) hm->method.len,
|
||||||
hm->method.ptr, (int) hm->uri.len, hm->uri.ptr, (int) 3,
|
hm->method.buf, (int) hm->uri.len, hm->uri.buf, (int) 3,
|
||||||
&c->send.buf[9]));
|
&c->send.buf[9]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/embedded-filesystem/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -3,8 +3,5 @@ idf_component_register(SRCS "main.c"
|
|||||||
"net.c"
|
"net.c"
|
||||||
"packed_fs.c"
|
"packed_fs.c"
|
||||||
"mongoose.c")
|
"mongoose.c")
|
||||||
component_compile_options(-DMG_ENABLE_LINES)
|
|
||||||
component_compile_options(-DMG_ENABLE_PACKED_FS)
|
|
||||||
component_compile_options(-DHTTP_URL="http://0.0.0.0:80")
|
component_compile_options(-DHTTP_URL="http://0.0.0.0:80")
|
||||||
component_compile_options(-DHTTPS_URL="https://0.0.0.0:443")
|
component_compile_options(-DHTTPS_URL="https://0.0.0.0:443")
|
||||||
component_compile_options(-DMG_TLS=MG_TLS_NONE) # change to 'MG_TLS_MBED' to enable TLS
|
|
||||||
@@ -1,22 +1,13 @@
|
|||||||
// Copyright (c) 2020 Cesanta Software Limited
|
// Copyright (c) 2020 Cesanta Software Limited
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
#include "esp_spiffs.h"
|
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
#define WIFI_SSID "YOUR_WIFI_NETWORK_NAME" // SET THIS!
|
#define WIFI_SSID "YOUR_WIFI_NETWORK_NAME" // SET THIS!
|
||||||
#define WIFI_PASS "YOUR_WIFI_PASSWORD" // SET THIS!
|
#define WIFI_PASS "YOUR_WIFI_PASSWORD" // SET THIS!
|
||||||
#define FS_ROOT "/spiffs"
|
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
// Mount filesystem
|
|
||||||
esp_vfs_spiffs_conf_t conf = {
|
|
||||||
.base_path = FS_ROOT, .max_files = 20, .format_if_mount_failed = true};
|
|
||||||
int res = esp_vfs_spiffs_register(&conf);
|
|
||||||
MG_INFO(("FS %s, %d", conf.base_path, res));
|
|
||||||
mg_file_printf(&mg_fs_posix, FS_ROOT "/hello.txt", "%s", "hello from ESP");
|
|
||||||
|
|
||||||
// Setup wifi. This function is implemented in wifi.c
|
// Setup wifi. This function is implemented in wifi.c
|
||||||
// It blocks until connected to the configured WiFi network
|
// It blocks until connected to the configured WiFi network
|
||||||
void wifi_init(const char *ssid, const char *pass);
|
void wifi_init(const char *ssid, const char *pass);
|
||||||
@@ -35,3 +26,240 @@ void app_main(void) {
|
|||||||
web_init(&mgr);
|
web_init(&mgr);
|
||||||
for (;;) mg_mgr_poll(&mgr, 1000); // Infinite event loop
|
for (;;) mg_mgr_poll(&mgr, 1000); // Infinite event loop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MG_DEVICE == MG_DEVICE_CUSTOM
|
||||||
|
void *mg_flash_start(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
size_t mg_flash_size(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
size_t mg_flash_sector_size(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
size_t mg_flash_write_align(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int mg_flash_bank(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
bool mg_flash_erase(void *location) {
|
||||||
|
(void) location;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool mg_flash_swap_bank(void) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool mg_flash_write(void *addr, const void *buf, size_t len) {
|
||||||
|
(void) addr, (void) buf, (void) len;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void mg_device_reset(void) {
|
||||||
|
esp_restart();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MG_OTA == MG_OTA_CUSTOM
|
||||||
|
#include "esp_app_format.h"
|
||||||
|
#include "esp_ota_ops.h"
|
||||||
|
|
||||||
|
static size_t s_size = 0; // Firmware size to flash. In-progress indicator
|
||||||
|
static bool rx_checked = false; // Whether firmware being received has been checked as valid
|
||||||
|
const esp_partition_t * update_partition = NULL; // The partition the update is being applied to
|
||||||
|
esp_ota_handle_t update_handle = 0; // Handle of the current update process
|
||||||
|
|
||||||
|
const esp_partition_t * get_partition_from_fw(int fw) {
|
||||||
|
if (MG_FIRMWARE_CURRENT == fw) {
|
||||||
|
return esp_ota_get_running_partition();
|
||||||
|
}
|
||||||
|
const esp_partition_t * p = esp_ota_get_last_invalid_partition();
|
||||||
|
if (NULL == p) {
|
||||||
|
p = esp_ota_get_next_update_partition(NULL);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if the data buffer contains the header of a valid firmware
|
||||||
|
const size_t fw_size_required = sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t);
|
||||||
|
bool check_fw_header(const void* buf, size_t len) {
|
||||||
|
// Ensure we have received enough data to do the check
|
||||||
|
if (len < fw_size_required) {
|
||||||
|
MG_ERROR(("Insufficient data to check firmware header - %d bytes, require %d bytes", len, fw_size_required));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the magic word of the received firmare
|
||||||
|
esp_app_desc_t* rx_app_info = (esp_app_desc_t*)(((char*)buf) + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t));
|
||||||
|
if (ESP_APP_DESC_MAGIC_WORD != rx_app_info->magic_word) {
|
||||||
|
MG_ERROR(("Invalid app - invalid magic word"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MG_INFO(("Received firmware: %s %s", rx_app_info->project_name, rx_app_info->version));
|
||||||
|
|
||||||
|
// Get the name/version of the running firmware
|
||||||
|
const esp_partition_t *current = esp_ota_get_running_partition();
|
||||||
|
esp_app_desc_t curr_app_info;
|
||||||
|
esp_err_t res = esp_ota_get_partition_description(current, &curr_app_info);
|
||||||
|
if (ESP_OK != res) {
|
||||||
|
MG_ERROR(("Unable to get name/version of running firmware"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MG_INFO(("Running firmware: %s %s", curr_app_info.project_name, curr_app_info.version));
|
||||||
|
|
||||||
|
// Check the name of the new firmware is the same as the old firmware
|
||||||
|
if (memcmp(curr_app_info.project_name, rx_app_info->project_name, sizeof(curr_app_info.project_name)) != 0) {
|
||||||
|
MG_ERROR(("Firmware name is different. Wrong firmware uploaded! Current %s Uploaded %s", curr_app_info.project_name, rx_app_info->project_name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the version of the new firmware is different from the old firmware
|
||||||
|
if (memcmp(curr_app_info.version, rx_app_info->version, sizeof(curr_app_info.version)) == 0) {
|
||||||
|
MG_ERROR(("Firmware version is the same. Wrong firmware uploaded! Current %s, Uploaded %s", curr_app_info.version, rx_app_info->version));
|
||||||
|
//return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mg_ota_begin(size_t new_firmware_size) {
|
||||||
|
rx_checked = false;
|
||||||
|
if (s_size) {
|
||||||
|
MG_ERROR(("OTA already in progress. Call mg_ota_end()"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int partition_size = mg_ota_size(MG_FIRMWARE_PREVIOUS);
|
||||||
|
if (new_firmware_size > partition_size) {
|
||||||
|
MG_ERROR(("Firmware %lu bytes, max %lu", new_firmware_size, partition_size));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
update_partition = esp_ota_get_next_update_partition(NULL);
|
||||||
|
if (NULL == update_partition) {
|
||||||
|
MG_ERROR(("esp_ota_get_next_update_partition returned NULL"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
esp_err_t res = esp_ota_begin(update_partition, OTA_WITH_SEQUENTIAL_WRITES, &update_handle);
|
||||||
|
if (res != ESP_OK) {
|
||||||
|
esp_ota_abort(update_handle);
|
||||||
|
MG_ERROR(("esp_ota_begin failed (%s)", esp_err_to_name(res)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s_size = new_firmware_size;
|
||||||
|
MG_INFO(("Starting OTA, firmware size %lu", s_size));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mg_ota_write(const void *buf, size_t len) {
|
||||||
|
if (s_size == 0) {
|
||||||
|
MG_ERROR(("OTA is not started, call mg_ota_begin()"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!rx_checked) {
|
||||||
|
if (!check_fw_header(buf, len)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
rx_checked = true;
|
||||||
|
}
|
||||||
|
esp_err_t res = esp_ota_write(update_handle, buf, len);
|
||||||
|
if (res != ESP_OK) {
|
||||||
|
esp_ota_abort(update_handle);
|
||||||
|
MG_ERROR(("esp_ota_write FAILED (%s)", esp_err_to_name(res)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mg_ota_end(void) {
|
||||||
|
if (0 == s_size) {
|
||||||
|
MG_INFO(("Finishing OTA: fail"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s_size = 0;
|
||||||
|
esp_err_t err = esp_ota_end(update_handle);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
MG_ERROR(("esp_ota_end failed (%s)!", esp_err_to_name(err)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
err = esp_ota_set_boot_partition(update_partition);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
MG_ERROR(("esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mg_ota_commit(void) {
|
||||||
|
esp_ota_mark_app_valid_cancel_rollback();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mg_ota_rollback(void) {
|
||||||
|
if(esp_ota_check_rollback_is_possible()) {
|
||||||
|
esp_ota_mark_app_invalid_rollback_and_reboot();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
MG_ERROR(("Rollback NOT possible"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mg_ota_status(int fw) {
|
||||||
|
const esp_partition_t *p = get_partition_from_fw(fw);
|
||||||
|
if (NULL == p) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int status = MG_OTA_UNAVAILABLE;
|
||||||
|
|
||||||
|
esp_ota_img_states_t img_state = ESP_OTA_IMG_UNDEFINED;
|
||||||
|
esp_err_t res = esp_ota_get_state_partition(p, &img_state);
|
||||||
|
if (ESP_OK == res) {
|
||||||
|
if (ESP_OTA_IMG_VALID == img_state) {
|
||||||
|
status = MG_OTA_COMMITTED;
|
||||||
|
} else if (ESP_OTA_IMG_UNDEFINED == img_state) {
|
||||||
|
status = MG_OTA_UNCOMMITTED;
|
||||||
|
} else if (ESP_OTA_IMG_INVALID == img_state) {
|
||||||
|
status = MG_OTA_UNAVAILABLE;
|
||||||
|
} else if (ESP_OTA_IMG_ABORTED == img_state) {
|
||||||
|
status = MG_OTA_UNAVAILABLE;
|
||||||
|
} else if (ESP_OTA_IMG_NEW == img_state) {
|
||||||
|
status = MG_OTA_FIRST_BOOT;
|
||||||
|
} else if (ESP_OTA_IMG_PENDING_VERIFY == img_state) {
|
||||||
|
status = MG_OTA_UNCOMMITTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t mg_ota_crc32(int fw) {
|
||||||
|
(void) fw;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t mg_ota_timestamp(int fw) {
|
||||||
|
const esp_partition_t *p = get_partition_from_fw(fw);
|
||||||
|
|
||||||
|
esp_app_desc_t app;
|
||||||
|
esp_err_t res = esp_ota_get_partition_description(p, &app);
|
||||||
|
if (ESP_OK != res)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm datetime = {};
|
||||||
|
if (NULL == strptime(app.date, "%b %d %Y", &datetime))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (NULL == strptime(app.time, "%H:%M:%S", &datetime))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return mktime(&datetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t mg_ota_size(int fw) {
|
||||||
|
const esp_partition_t *p = get_partition_from_fw(fw);
|
||||||
|
if (NULL == p) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return p->size;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#define MG_ARCH MG_ARCH_ESP32
|
||||||
|
|
||||||
|
#define MG_ENABLE_PACKED_FS 1
|
||||||
|
#define MG_TLS MG_TLS_NONE // change to 'MG_TLS_MBED' to enable TLS
|
||||||
|
#define MG_OTA MG_OTA_CUSTOM
|
||||||
|
#define MG_DEVICE MG_DEVICE_CUSTOM
|
||||||
@@ -32,7 +32,7 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
|||||||
esp_wifi_connect();
|
esp_wifi_connect();
|
||||||
} else if (event_base == WIFI_EVENT &&
|
} else if (event_base == WIFI_EVENT &&
|
||||||
event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||||
if (s_retry_num < 3) {
|
if (s_retry_num < 10) {
|
||||||
esp_wifi_connect();
|
esp_wifi_connect();
|
||||||
s_retry_num++;
|
s_retry_num++;
|
||||||
MG_INFO(("retry to connect to the AP"));
|
MG_INFO(("retry to connect to the AP"));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# Name, Type, SubType, Offset, Size, Flags
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
nvs, data, nvs, 0x9000, 0x6000,
|
nvs, data, nvs, , 0x6000
|
||||||
phy_init, data, phy, 0xf000, 0x1000,
|
otadata, data, ota, , 0x2000,
|
||||||
storage, data, spiffs, 0x10000, 0x10000,
|
phy_init, data, phy, , 0x1000,
|
||||||
factory, app, factory, 0x100000, 1M,
|
ota_0, app, ota_0, , 948K,
|
||||||
|
ota_1, app, ota_1, , 948K,
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||||
|
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||||
#CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
|
#CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
|
||||||
@@ -15,7 +15,7 @@ build: micropython
|
|||||||
$(DOCKER) $(CMD)
|
$(DOCKER) $(CMD)
|
||||||
|
|
||||||
micropython:
|
micropython:
|
||||||
$(DOCKER) git clone https://github.com/micropython/micropython.git
|
$(DOCKER) git clone --depth 1 -b v1.22.2 https://github.com/micropython/micropython.git
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
test -d micropython && $(DOCKER) rm -rf micropython || true
|
test -d micropython && $(DOCKER) rm -rf micropython || true
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
#define MG_ARCH MG_ARCH_ESP32
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
// For some reason, IDF detection at build time does not work here
|
|
||||||
#define MG_ARCH MG_ARCH_ESP32
|
|
||||||
@@ -5,6 +5,4 @@ idf_component_register(SRCS "main.c"
|
|||||||
"net.c"
|
"net.c"
|
||||||
"packed_fs.c"
|
"packed_fs.c"
|
||||||
"mongoose.c")
|
"mongoose.c")
|
||||||
component_compile_options(-DMG_ENABLE_LINES=1)
|
|
||||||
component_compile_options(-DMG_ENABLE_PACKED_FS=1)
|
|
||||||
component_compile_options(-DUART_API_IMPLEMENTED=1)
|
component_compile_options(-DUART_API_IMPLEMENTED=1)
|
||||||
@@ -5,14 +5,12 @@
|
|||||||
|
|
||||||
const char *s_listening_url = "http://0.0.0.0:80";
|
const char *s_listening_url = "http://0.0.0.0:80";
|
||||||
|
|
||||||
#if 0
|
struct mg_str config_read(void) {
|
||||||
char *config_read(void) {
|
return mg_file_read(&mg_fs_posix, FS_ROOT "/config.json");
|
||||||
return mg_file_read(&mg_fs_posix, FS_ROOT "/config.json", NULL);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void config_write(struct mg_str config) {
|
void config_write(struct mg_str config) {
|
||||||
mg_file_write(&mg_fs_posix, FS_ROOT "/config.json", config.ptr, config.len);
|
mg_file_write(&mg_fs_posix, FS_ROOT "/config.json", config.buf, config.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
@@ -24,13 +22,13 @@ void app_main(void) {
|
|||||||
|
|
||||||
// Try to connect to wifi by using saved WiFi credentials
|
// Try to connect to wifi by using saved WiFi credentials
|
||||||
struct mg_str json = mg_file_read(&mg_fs_posix, WIFI_FILE);
|
struct mg_str json = mg_file_read(&mg_fs_posix, WIFI_FILE);
|
||||||
if (json.ptr != NULL) {
|
if (json.buf != NULL) {
|
||||||
char *ssid = mg_json_get_str(json, "$.ssid");
|
char *ssid = mg_json_get_str(json, "$.ssid");
|
||||||
char *pass = mg_json_get_str(json, "$.pass");
|
char *pass = mg_json_get_str(json, "$.pass");
|
||||||
while (!wifi_init(ssid, pass)) (void) 0;
|
while (!wifi_init(ssid, pass)) (void) 0;
|
||||||
free(ssid);
|
free(ssid);
|
||||||
free(pass);
|
free(pass);
|
||||||
free((void *) json.ptr);
|
free((void *) json.buf);
|
||||||
} else {
|
} else {
|
||||||
// If WiFi is not configured, run CLI until configured
|
// If WiFi is not configured, run CLI until configured
|
||||||
MG_INFO(("WiFi is not configured, running CLI. Press enter"));
|
MG_INFO(("WiFi is not configured, running CLI. Press enter"));
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#define MG_ARCH MG_ARCH_ESP32
|
||||||
|
|
||||||
|
#define MG_ENABLE_PACKED_FS 1
|
||||||
@@ -7,4 +7,3 @@
|
|||||||
# please read the ESP-IDF documents if you need to do this.
|
# please read the ESP-IDF documents if you need to do this.
|
||||||
#
|
#
|
||||||
|
|
||||||
COMPONENT_INCLUDES += ../../../../../..
|
|
||||||
@@ -23,10 +23,10 @@ static void cb(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
static void cb2(struct mg_connection *c, int ev, void *ev_data) {
|
static void cb2(struct mg_connection *c, int ev, void *ev_data) {
|
||||||
if (ev == MG_EV_CONNECT) {
|
if (ev == MG_EV_CONNECT) {
|
||||||
struct mg_str s = mg_url_host(CLIENT_URL);
|
struct mg_str s = mg_url_host(CLIENT_URL);
|
||||||
mg_printf(c, "GET / HTTP/1.0\r\nHost: %.*s\r\n\r\n", (int) s.len, s.ptr);
|
mg_printf(c, "GET / HTTP/1.0\r\nHost: %.*s\r\n\r\n", (int) s.len, s.buf);
|
||||||
} else if (ev == MG_EV_HTTP_MSG) {
|
} else if (ev == MG_EV_HTTP_MSG) {
|
||||||
struct mg_http_message *hm = ev_data; // Print HTTP response
|
struct mg_http_message *hm = ev_data; // Print HTTP response
|
||||||
MG_INFO(("Fetched:\n%.*s", (int) hm->message.len, hm->message.ptr));
|
MG_INFO(("Fetched:\n%.*s", (int) hm->message.len, hm->message.buf));
|
||||||
c->is_draining = 1;
|
c->is_draining = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../../../mongoose.h
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#define MG_ARCH MG_ARCH_ESP8266
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
"Host: %.*s\r\n"
|
"Host: %.*s\r\n"
|
||||||
"Content-Type: octet-stream\r\n"
|
"Content-Type: octet-stream\r\n"
|
||||||
"Content-Length: %d\r\n",
|
"Content-Length: %d\r\n",
|
||||||
mg_url_uri(s_url), (int) host.len, host.ptr, fsize);
|
mg_url_uri(s_url), (int) host.len, host.buf, fsize);
|
||||||
mg_http_bauth(c, s_user, s_pass); // Add Basic auth header
|
mg_http_bauth(c, s_user, s_pass); // Add Basic auth header
|
||||||
mg_printf(c, "%s", "\r\n"); // End HTTP headers
|
mg_printf(c, "%s", "\r\n"); // End HTTP headers
|
||||||
} else if (ev == MG_EV_WRITE && c->send.len < MG_IO_SIZE) {
|
} else if (ev == MG_EV_WRITE && c->send.len < MG_IO_SIZE) {
|
||||||
@@ -53,7 +53,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
MG_DEBUG(("MSG"));
|
MG_DEBUG(("MSG"));
|
||||||
// Response is received. Print it
|
// Response is received. Print it
|
||||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
printf("%.*s", (int) hm->body.len, hm->body.ptr);
|
printf("%.*s", (int) hm->body.len, hm->body.buf);
|
||||||
c->is_draining = 1; // Tell mongoose to close this connection
|
c->is_draining = 1; // Tell mongoose to close this connection
|
||||||
mg_fs_close(fd);
|
mg_fs_close(fd);
|
||||||
*(bool *) c->fn_data = true; // Tell event loop to stop
|
*(bool *) c->fn_data = true; // Tell event loop to stop
|
||||||
|
|||||||
@@ -25,79 +25,89 @@ static bool authuser(struct mg_http_message *hm) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Streaming upload example. Demonstrates how to use MG_EV_READ events
|
struct upload_state {
|
||||||
// to get large payload in smaller chunks. To test, use curl utility:
|
size_t expected; // POST data length, bytes
|
||||||
static void cb(struct mg_connection *c, int ev, void *ev_data) {
|
size_t received; // Already received bytes
|
||||||
if (ev == MG_EV_READ) {
|
void *fp; // Opened uploaded file
|
||||||
// Parse the incoming data ourselves. If we can parse the request,
|
};
|
||||||
// store two size_t variables in c->data: expected len and recv len.
|
|
||||||
size_t *data = (size_t *) c->data;
|
static void handle_uploads(struct mg_connection *c, int ev, void *ev_data) {
|
||||||
struct mg_fd *fd = (struct mg_fd *) c->fn_data; // get file descriptor
|
struct upload_state *us = (struct upload_state *) c->data;
|
||||||
if (data[0]) { // Already parsed, receiving body
|
struct mg_fs *fs = &mg_fs_posix;
|
||||||
data[1] += c->recv.len;
|
|
||||||
MG_DEBUG(("Got chunk len %lu, %lu total", c->recv.len, data[1]));
|
// Catch /upload requests early, without buffering whole body
|
||||||
fd->fs->wr(fd->fd, c->recv.buf, c->recv.len);
|
// When we receive MG_EV_HTTP_HDRS event, that means we've received all
|
||||||
c->recv.len = 0; // And cleanup the receive buffer. Streaming!
|
// HTTP headers but not necessarily full HTTP body
|
||||||
if (data[1] >= data[0]) {
|
if (ev == MG_EV_HTTP_HDRS) {
|
||||||
mg_fs_close(fd);
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
mg_http_reply(c, 200, "", "ok\n");
|
if (mg_match(hm->uri, mg_str("/upload/#"), NULL)) {
|
||||||
}
|
c->pfn = NULL; // Silence HTTP protocol handler, we'll take over
|
||||||
} else if (c->is_resp == 0) {
|
if (!authuser(hm)) {
|
||||||
struct mg_http_message hm;
|
mg_http_reply(c, 403, "", "Denied\n");
|
||||||
int n = mg_http_parse((char *) c->recv.buf, c->recv.len, &hm);
|
c->is_draining = 1; // Tell mongoose to close this connection
|
||||||
if (n < 0) mg_error(c, "Bad response");
|
} else if (hm->body.len > (size_t) s_max_size) {
|
||||||
if (n > 0) {
|
mg_http_reply(c, 400, "", "Too long\n");
|
||||||
if (mg_http_match_uri(&hm, "/upload/#")) {
|
c->is_draining = 1; // Tell mongoose to close this connection
|
||||||
if (!authuser(&hm)) {
|
} else if (hm->uri.len == 8) { // 8: /upload/
|
||||||
mg_http_reply(c, 403, "", "Denied\n");
|
mg_http_reply(c, 400, "", "Name required\n");
|
||||||
c->is_draining = 1; // Tell mongoose to close this connection
|
c->is_draining = 1; // Tell mongoose to close this connection
|
||||||
} else if (hm.body.len > (size_t) s_max_size) {
|
} else if (strlen(s_upld_dir) + (hm->uri.len - 8) + 2 >
|
||||||
mg_http_reply(c, 400, "", "Too long\n");
|
MG_PATH_MAX) { // 2: MG_DIRSEP + NUL
|
||||||
c->is_draining = 1; // Tell mongoose to close this connection
|
mg_http_reply(c, 400, "", "Path is too long\n");
|
||||||
} else if (hm.uri.len == 8) { // 8: /upload/
|
c->is_draining = 1; // Tell mongoose to close this connection
|
||||||
mg_http_reply(c, 400, "", "Name required\n");
|
} else {
|
||||||
c->is_draining = 1; // Tell mongoose to close this connection
|
char fpath[MG_PATH_MAX];
|
||||||
} else if (strlen(s_upld_dir) + (hm.uri.len - 8) + 2 >
|
snprintf(fpath, MG_PATH_MAX, "%s%c", s_upld_dir, MG_DIRSEP);
|
||||||
MG_PATH_MAX) { // 2: MG_DIRSEP + NUL
|
strncat(fpath, hm->uri.buf + 8, hm->uri.len - 8);
|
||||||
mg_http_reply(c, 400, "", "Path is too long\n");
|
if (!mg_path_is_sane(mg_str(fpath))) {
|
||||||
|
mg_http_reply(c, 400, "", "Invalid path\n");
|
||||||
|
c->is_draining = 1; // Tell mongoose to close this connection
|
||||||
|
} else {
|
||||||
|
struct mg_fd *fd;
|
||||||
|
MG_DEBUG(("Got request"));
|
||||||
|
fs->rm(fpath); // Delete file if it exists
|
||||||
|
if ((fd = fs->op(fpath, MG_FS_WRITE)) == NULL) {
|
||||||
|
mg_http_reply(c, 400, "", "open failed: %d\n", errno);
|
||||||
c->is_draining = 1; // Tell mongoose to close this connection
|
c->is_draining = 1; // Tell mongoose to close this connection
|
||||||
} else {
|
} else {
|
||||||
char fpath[MG_PATH_MAX];
|
us->fp = fd;
|
||||||
snprintf(fpath, MG_PATH_MAX, "%s%c", s_upld_dir, MG_DIRSEP);
|
us->expected = hm->body.len; // Store number of bytes we expect
|
||||||
strncat(fpath, hm.uri.ptr + 8, hm.uri.len - 8);
|
mg_iobuf_del(&c->recv, 0, hm->head.len); // Delete HTTP headers
|
||||||
if (!mg_path_is_sane(fpath)) {
|
|
||||||
mg_http_reply(c, 400, "", "Invalid path\n");
|
|
||||||
c->is_draining = 1; // Tell mongoose to close this connection
|
|
||||||
} else {
|
|
||||||
MG_DEBUG(("Got request, chunk len %lu", c->recv.len - n));
|
|
||||||
if ((fd = mg_fs_open(&mg_fs_posix, fpath, MG_FS_WRITE)) == NULL) {
|
|
||||||
mg_http_reply(c, 400, "", "open failed: %d\n", errno);
|
|
||||||
c->is_draining = 1; // Tell mongoose to close this connection
|
|
||||||
} else {
|
|
||||||
c->fn_data = fd;
|
|
||||||
c->recv.len -= n; // remove headers
|
|
||||||
data[0] = hm.body.len;
|
|
||||||
data[1] = c->recv.len;
|
|
||||||
if (c->recv.len)
|
|
||||||
fd->fs->wr(fd->fd, c->recv.buf + n, c->recv.len);
|
|
||||||
c->recv.len = 0; // consume data
|
|
||||||
if (data[1] >= data[0]) {
|
|
||||||
mg_fs_close(fd);
|
|
||||||
mg_http_reply(c, 200, "", "ok\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c->is_resp = 1; // ignore the rest of the body
|
|
||||||
} else {
|
|
||||||
struct mg_http_serve_opts opts = {0};
|
|
||||||
opts.root_dir = s_root_dir;
|
|
||||||
mg_http_serve_dir(c, &hm, &opts);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void) ev_data;
|
|
||||||
|
// Catch uploaded file data for both MG_EV_READ and MG_EV_HTTP_HDRS
|
||||||
|
if (us->expected > 0 && c->recv.len > 0) {
|
||||||
|
us->received += c->recv.len;
|
||||||
|
MG_DEBUG(("Got chunk: %lu bytes, %lu so far, %lu total", c->recv.len,
|
||||||
|
us->received, us->expected));
|
||||||
|
if (us->fp) fs->wr(us->fp, c->recv.buf, c->recv.len); // Write to file
|
||||||
|
c->recv.len = 0; // Delete received data
|
||||||
|
if (us->received >= us->expected) {
|
||||||
|
// Uploaded everything. Send response back
|
||||||
|
MG_INFO(("Uploaded %lu bytes", us->received));
|
||||||
|
mg_http_reply(c, 200, NULL, "%lu ok\n", us->received);
|
||||||
|
if (us->fp) fs->cl(us->fp); // Close file
|
||||||
|
memset(us, 0, sizeof(*us)); // Cleanup upload state
|
||||||
|
c->is_draining = 1; // Close connection when response gets sent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cb(struct mg_connection *c, int ev, void *ev_data) {
|
||||||
|
if (ev == MG_EV_READ || ev == MG_EV_HTTP_HDRS) {
|
||||||
|
handle_uploads(c, ev, ev_data);
|
||||||
|
} else if (ev == MG_EV_HTTP_MSG && c->pfn != NULL) {
|
||||||
|
// Non-upload requests, we serve normally
|
||||||
|
// NOTE: handle_uploads() may delete request and reset c->pfn
|
||||||
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
|
struct mg_http_serve_opts opts = {0};
|
||||||
|
opts.root_dir = s_root_dir;
|
||||||
|
mg_http_serve_dir(c, hm, &opts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(const char *prog) {
|
static void usage(const char *prog) {
|
||||||
@@ -159,9 +169,7 @@ int main(int argc, char *argv[]) {
|
|||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
mg_log_set(s_debug_level);
|
mg_log_set(s_debug_level);
|
||||||
mg_mgr_init(&mgr);
|
mg_mgr_init(&mgr);
|
||||||
// use mg_listen instead of mg_http_listen to be able to override the parser
|
if (mg_http_listen(&mgr, s_listening_address, cb, NULL) == NULL) {
|
||||||
// and shape buffering
|
|
||||||
if (mg_listen(&mgr, s_listening_address, cb, NULL) == NULL) {
|
|
||||||
MG_ERROR(("Cannot listen on %s.", s_listening_address));
|
MG_ERROR(("Cannot listen on %s.", s_listening_address));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/file-uploads/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/file-uploads/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/file-uploads/
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
// Copyright (c) 2020-2024 Cesanta Software Limited
|
|
||||||
// All rights reserved
|
|
||||||
//
|
|
||||||
// Streaming upload example. Demonstrates how to use MG_EV_READ events
|
|
||||||
// to get large payload in smaller chunks. To test, use curl utility:
|
|
||||||
//
|
|
||||||
// curl http://localhost:8000/upload?name=a.txt --data-binary @large_file.txt
|
|
||||||
|
|
||||||
#include "mongoose.h"
|
|
||||||
|
|
||||||
// HTTP request handler function. It implements the following endpoints:
|
|
||||||
// /upload - Saves the next file chunk
|
|
||||||
// all other URI - serves web_root/ directory
|
|
||||||
static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|
||||||
if (ev == MG_EV_READ) {
|
|
||||||
// Parse the incoming data ourselves. If we can parse the request,
|
|
||||||
// store two size_t variables in the c->data: expected len and recv len.
|
|
||||||
size_t *data = (size_t *) c->data;
|
|
||||||
if (data[0]) { // Already parsed, simply print received data
|
|
||||||
data[1] += c->recv.len;
|
|
||||||
MG_INFO(("Got chunk len %lu, %lu total", c->recv.len, data[1]));
|
|
||||||
c->recv.len = 0; // And cleanup the receive buffer. Streaming!
|
|
||||||
if (data[1] >= data[0]) mg_http_reply(c, 200, "", "ok\n");
|
|
||||||
} else {
|
|
||||||
struct mg_http_message hm;
|
|
||||||
int n = mg_http_parse((char *) c->recv.buf, c->recv.len, &hm);
|
|
||||||
if (n < 0) mg_error(c, "Bad response");
|
|
||||||
if (n > 0) {
|
|
||||||
if (mg_http_match_uri(&hm, "/upload")) {
|
|
||||||
MG_INFO(("Got chunk len %lu", c->recv.len - n));
|
|
||||||
data[0] = hm.body.len;
|
|
||||||
data[1] = c->recv.len - n;
|
|
||||||
if (data[1] >= data[0]) mg_http_reply(c, 200, "", "ok\n");
|
|
||||||
} else {
|
|
||||||
struct mg_http_serve_opts opts = {.root_dir = "web_root"};
|
|
||||||
mg_http_serve_dir(c, &hm, &opts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(void) ev_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
struct mg_mgr mgr;
|
|
||||||
|
|
||||||
mg_mgr_init(&mgr);
|
|
||||||
mg_log_set(MG_LL_DEBUG); // Set debug log level
|
|
||||||
mg_listen(&mgr, "http://localhost:8000", fn, NULL);
|
|
||||||
|
|
||||||
for (;;) mg_mgr_poll(&mgr, 50);
|
|
||||||
mg_mgr_free(&mgr);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/http-client/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../test/data/ca.pem
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/http-proxy-client/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/http-server/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/http-reverse-proxy/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/http-server/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/huge-response/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
CFLAGS = -W -Wall -Werror -Wextra -Wundef -Wshadow -Wdouble-promotion
|
||||||
|
CFLAGS += -Wformat-truncation -fno-common # -Wconversion is not SDK-friendly
|
||||||
|
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
|
||||||
|
CFLAGS += -I. -Icmsis_core/CMSIS/Core/Include -Icmsis_xmc7/devices/COMPONENT_CAT1C/include/
|
||||||
|
CFLAGS += -Icmsis_xmc7/devices/COMPONENT_CAT1C/include/ip/
|
||||||
|
CFLAGS += -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 $(CFLAGS_EXTRA)
|
||||||
|
LDSCRIPT = link.ld
|
||||||
|
LDFLAGS ?= -T$(LDSCRIPT) -nostdlib -nostartfiles --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map
|
||||||
|
|
||||||
|
SOURCES = main.c hal.c startup.c
|
||||||
|
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS # Make startup code work as expected
|
||||||
|
|
||||||
|
# Mongoose options are defined in mongoose_custom.h
|
||||||
|
SOURCES += mongoose.c net.c packed_fs.c
|
||||||
|
|
||||||
|
# Example specific build options. See README.md
|
||||||
|
CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" -DHTTPS_URL=\"https://0.0.0.0/\"
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
RM = cmd /C del /Q /F /S
|
||||||
|
else
|
||||||
|
RM = rm -rf
|
||||||
|
endif
|
||||||
|
|
||||||
|
all build example: firmware.bin
|
||||||
|
|
||||||
|
firmware.bin: firmware.elf
|
||||||
|
arm-none-eabi-objcopy -O binary $< $@
|
||||||
|
|
||||||
|
firmware.elf: cmsis_core cmsis_xmc7 $(SOURCES) hal.h link.ld Makefile
|
||||||
|
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) -o $@
|
||||||
|
arm-none-eabi-size $@
|
||||||
|
|
||||||
|
cmsis_core: # ARM CMSIS core headers
|
||||||
|
git clone -q --depth 1 -b 5.9.0 https://github.com/ARM-software/CMSIS_5 $@
|
||||||
|
cmsis_xmc7:
|
||||||
|
git clone https://github.com/Infineon/mtb-pdl-cat1.git $@
|
||||||
|
echo "" > cmsis_xmc7/devices/COMPONENT_CAT1C/include/ip/system_cat1c.h
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) firmware.* *.su cmsis_core cmsis_xmc7 *.zip
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
// Copyright (c) 2024 Cesanta Software Limited
|
||||||
|
// All rights reserved
|
||||||
|
|
||||||
|
#include "hal.h"
|
||||||
|
|
||||||
|
static volatile uint64_t s_ticks; // Milliseconds since boot
|
||||||
|
void SysTick_Handler(void) { // SyStick IRQ handler, triggered every 1ms
|
||||||
|
s_ticks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
||||||
|
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
|
||||||
|
uint32_t r = rng_read();
|
||||||
|
memcpy((char *) buf + n, &r, n + sizeof(r) > len ? len - n : sizeof(r));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t mg_millis(void) { // Let Mongoose use our uptime function
|
||||||
|
return s_ticks; // Return number of milliseconds since boot
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_init(void) {
|
||||||
|
clock_init(); // Set system clock to SYS_FREQUENCY
|
||||||
|
SystemCoreClock = SYS_FREQUENCY; // Update SystemCoreClock global var
|
||||||
|
SysTick_Config(SystemCoreClock / 1000); // Sys tick every 1ms
|
||||||
|
rng_init(); // Initialise random number generator
|
||||||
|
|
||||||
|
uart_init(UART_DEBUG, 115200); // Initialise UART
|
||||||
|
gpio_output(LED1); // Initialise LED1
|
||||||
|
gpio_output(LED2); // Initialise LED2
|
||||||
|
gpio_output(LED3); // Initialise LED3
|
||||||
|
ethernet_init(); // Initialise Ethernet pins
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__ARMCC_VERSION)
|
||||||
|
// Keil specific - implement IO printf redirection
|
||||||
|
int fputc(int c, FILE *stream) {
|
||||||
|
if (stream == stdout || stream == stderr) uart_write_byte(UART_DEBUG, c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
// ARM GCC specific. ARM GCC is shipped with Newlib C library.
|
||||||
|
// Implement newlib syscalls:
|
||||||
|
// _sbrk() for malloc
|
||||||
|
// _write() for printf redirection
|
||||||
|
// the rest are just stubs
|
||||||
|
#include <sys/stat.h> // For _fstat()
|
||||||
|
|
||||||
|
uint32_t SystemCoreClock;
|
||||||
|
void SystemInit(void) { // Called automatically by startup code
|
||||||
|
}
|
||||||
|
|
||||||
|
int _fstat(int fd, struct stat *st) {
|
||||||
|
(void) fd, (void) st;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern unsigned char _end[]; // End of data section, start of heap. See link.ld
|
||||||
|
static unsigned char *s_current_heap_end = _end;
|
||||||
|
|
||||||
|
size_t hal_ram_used(void) {
|
||||||
|
return (size_t) (s_current_heap_end - _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t hal_ram_free(void) {
|
||||||
|
unsigned char endofstack;
|
||||||
|
return (size_t) (&endofstack - s_current_heap_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_sbrk(int incr) {
|
||||||
|
unsigned char *prev_heap;
|
||||||
|
unsigned char *heap_end = (unsigned char *) ((size_t) &heap_end - 256);
|
||||||
|
prev_heap = s_current_heap_end;
|
||||||
|
// Check how much space we got from the heap end to the stack end
|
||||||
|
if (s_current_heap_end + incr > heap_end) return (void *) -1;
|
||||||
|
s_current_heap_end += incr;
|
||||||
|
return prev_heap;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _open(const char *path) {
|
||||||
|
(void) path;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _close(int fd) {
|
||||||
|
(void) fd;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _isatty(int fd) {
|
||||||
|
(void) fd;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _lseek(int fd, int ptr, int dir) {
|
||||||
|
(void) fd, (void) ptr, (void) dir;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _exit(int status) {
|
||||||
|
(void) status;
|
||||||
|
for (;;) asm volatile("BKPT #0");
|
||||||
|
}
|
||||||
|
|
||||||
|
void _kill(int pid, int sig) {
|
||||||
|
(void) pid, (void) sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _getpid(void) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _write(int fd, char *ptr, int len) {
|
||||||
|
(void) fd, (void) ptr, (void) len;
|
||||||
|
if (fd == 1) uart_write_buf(UART_DEBUG, ptr, (size_t) len);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _read(int fd, char *ptr, int len) {
|
||||||
|
(void) fd, (void) ptr, (void) len;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _link(const char *a, const char *b) {
|
||||||
|
(void) a, (void) b;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _unlink(const char *a) {
|
||||||
|
(void) a;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _stat(const char *path, struct stat *st) {
|
||||||
|
(void) path, (void) st;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mkdir(const char *path, mode_t mode) {
|
||||||
|
(void) path, (void) mode;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _init(void) {
|
||||||
|
}
|
||||||
|
#endif // __GNUC__
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
// Copyright (c) 2023 Cesanta Software Limited
|
||||||
|
// All rights reserved
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define LED1 PIN(16, 1)
|
||||||
|
#define LED2 PIN(16, 2)
|
||||||
|
#define LED3 PIN(16, 3)
|
||||||
|
|
||||||
|
#include "xmc7200d_e272k8384.h"
|
||||||
|
|
||||||
|
#define BIT(x) (1UL << (x))
|
||||||
|
#define CLRSET(reg, clear, set) ((reg) = ((reg) & ~(clear)) | (set))
|
||||||
|
#define PIN(bank, num) ((bank << 8) | (num))
|
||||||
|
#define PINNO(pin) (pin & 255)
|
||||||
|
#define PINBANK(pin) (pin >> 8)
|
||||||
|
|
||||||
|
void hal_init(void);
|
||||||
|
size_t hal_ram_free(void);
|
||||||
|
size_t hal_ram_used(void);
|
||||||
|
|
||||||
|
static inline void spin(volatile uint32_t count) {
|
||||||
|
while (count--) (void) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern uint32_t SystemCoreClock;
|
||||||
|
|
||||||
|
enum {PLL_FEEDBACK = 50, PLL_REF = 1, PLL_OUT = 4};
|
||||||
|
#define CLK_IMO 8000000UL
|
||||||
|
#define SYS_FREQUENCY ((CLK_IMO * PLL_FEEDBACK) / (PLL_REF * PLL_OUT))
|
||||||
|
|
||||||
|
#ifndef UART_DEBUG
|
||||||
|
#define UART_DEBUG SCB3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum { GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, GPIO_MODE_AF, GPIO_MODE_ANALOG };
|
||||||
|
enum { GPIO_HIGHZ = 0, GPIO_PULLUP = 2, GPIO_PULLDOWN = 3, GPIO_OPENDRAIN_LOW = 4,
|
||||||
|
GPIO_OPENDRAIN_HIGH = 5, GPIO_STRONG = 6, GPIO_PULLUP_DOWN = 7};
|
||||||
|
enum { GPIO_SPEED_LOW = 3, GPIO_SPEED_MEDIUM = 2, GPIO_SPEED_HIGH = 0};
|
||||||
|
#undef GPIO
|
||||||
|
#define GPIO_TypeDef GPIO_PRT_Type
|
||||||
|
#define GPIO(N) ((GPIO_TypeDef *) (GPIO_BASE + 0x80 * (N)))
|
||||||
|
|
||||||
|
static GPIO_TypeDef *gpio_bank(uint16_t pin) { return GPIO(PINBANK(pin)); }
|
||||||
|
|
||||||
|
static inline void gpio_init(uint16_t pin, uint8_t mode, uint8_t type,
|
||||||
|
uint8_t speed, uint8_t pull, uint8_t af) {
|
||||||
|
(void) pin, (void) mode, (void) type, (void) speed, (void) pull, (void) af;
|
||||||
|
GPIO_TypeDef *gpio = gpio_bank(pin);
|
||||||
|
uint8_t pinno = PINNO(pin);
|
||||||
|
uint32_t msk, pos;
|
||||||
|
|
||||||
|
// configure input / output direction
|
||||||
|
if (mode == GPIO_MODE_INPUT) {
|
||||||
|
gpio->CFG |= 1 << (4 * pinno + 3); // enable input buffer (IN_ENx)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (af || (mode == GPIO_MODE_AF && af)) {
|
||||||
|
// configure alternate function
|
||||||
|
HSIOM_PRT_Type* hsiom = ((HSIOM_PRT_Type*) HSIOM) + PINBANK(pin);
|
||||||
|
volatile uint32_t *port_sel = pinno < 4 ? &hsiom->PORT_SEL0 : &hsiom->PORT_SEL1;
|
||||||
|
pos = 8 * (pinno % 4), msk = 0x1f << pos;
|
||||||
|
*port_sel &= ~msk, *port_sel |= af << pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// configure driver mode
|
||||||
|
msk = 7, pos = 4 * pinno;
|
||||||
|
CLRSET(gpio->CFG, msk << pos, type << pos);
|
||||||
|
|
||||||
|
// configure speed
|
||||||
|
msk = 3, pos = 2 * pinno + 16;
|
||||||
|
CLRSET(gpio->CFG_OUT, msk << pos, speed << pos);
|
||||||
|
|
||||||
|
if (mode == GPIO_MODE_OUTPUT /*&& af == 0*/) {
|
||||||
|
gpio->OUT_SET = (1 << pinno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void gpio_input(uint16_t pin) {
|
||||||
|
gpio_init(pin, GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH,
|
||||||
|
0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void gpio_output(uint16_t pin) {
|
||||||
|
gpio_init(pin, GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_MEDIUM,
|
||||||
|
0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool gpio_read(uint16_t pin) {
|
||||||
|
GPIO_TypeDef *gpio = gpio_bank(pin);
|
||||||
|
uint8_t pinno = PINNO(pin);
|
||||||
|
if (gpio->CFG & (1 << (4 * pinno + 3))) {
|
||||||
|
// pin mode is input, reading from GPIO_PRT_IN
|
||||||
|
return gpio->IN & (1 << pinno);
|
||||||
|
} else {
|
||||||
|
// pin mode is output, reading from GPIO_PRT_OUT
|
||||||
|
return gpio->OUT & (1 << pinno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void gpio_write(uint16_t pin, bool value) {
|
||||||
|
GPIO_TypeDef *gpio = gpio_bank(pin);
|
||||||
|
uint8_t pinno = PINNO(pin);
|
||||||
|
if (value) {
|
||||||
|
gpio->OUT_SET = 1 << pinno;
|
||||||
|
} else {
|
||||||
|
gpio->OUT_CLR = 1 << pinno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void gpio_toggle(uint16_t pin) {
|
||||||
|
gpio_write(pin, !gpio_read(pin));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void uart_init(volatile CySCB_Type *uart, unsigned long baud) {
|
||||||
|
(void) uart, (void) baud;
|
||||||
|
uint16_t rx = 0, tx = 0;
|
||||||
|
if (uart == SCB3) {
|
||||||
|
rx = PIN(13, 0), tx = PIN(13, 1);
|
||||||
|
} else {
|
||||||
|
return; // unsupported uart
|
||||||
|
}
|
||||||
|
|
||||||
|
// set pins
|
||||||
|
gpio_init(rx, GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 17);
|
||||||
|
gpio_init(tx, GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 17);
|
||||||
|
|
||||||
|
// enable peripheral clock (18.6.2)
|
||||||
|
// compute divider first (we choose 24 bit divider 0)
|
||||||
|
unsigned long div = 0, frac = 0, ovs = 16;
|
||||||
|
div = SYS_FREQUENCY / (baud * ovs);
|
||||||
|
if (div == 0) div = 1;
|
||||||
|
frac = SYS_FREQUENCY % (baud * ovs);
|
||||||
|
frac = (frac * 100) / (baud * ovs);
|
||||||
|
PERI_PCLK->GR[1].DIV_CMD = (3 << PERI_PCLK_GR_DIV_CMD_TYPE_SEL_Pos) |
|
||||||
|
PERI_PCLK_GR_DIV_CMD_PA_DIV_SEL_Msk |
|
||||||
|
PERI_PCLK_GR_DIV_CMD_PA_TYPE_SEL_Msk;
|
||||||
|
PERI_PCLK->GR[1].DIV_CMD |= PERI_PCLK_GR_DIV_CMD_DISABLE_Msk; // disable divider
|
||||||
|
PERI_PCLK->GR[1].DIV_24_5_CTL[0] = (((uint8_t) (div - 1)) << PERI_PCLK_GR_DIV_24_5_CTL_INT24_DIV_Pos) |
|
||||||
|
(frac << PERI_PCLK_GR_DIV_24_5_CTL_FRAC5_DIV_Pos);
|
||||||
|
PERI_PCLK->GR[1].DIV_CMD = (3 << PERI_PCLK_GR_DIV_CMD_TYPE_SEL_Pos) |
|
||||||
|
PERI_PCLK_GR_DIV_CMD_PA_DIV_SEL_Msk |
|
||||||
|
PERI_PCLK_GR_DIV_CMD_PA_TYPE_SEL_Msk;;
|
||||||
|
PERI_PCLK->GR[1].DIV_CMD |= PERI_PCLK_GR_DIV_CMD_ENABLE_Msk; // enable divider
|
||||||
|
PERI_PCLK->GR[1].CLOCK_CTL[PCLK_SCB3_CLOCK & 0xff] = 3 << PERI_PCLK_GR_CLOCK_CTL_TYPE_SEL_Pos; // connect SCB3 to div_24_5_ctl[0]
|
||||||
|
|
||||||
|
// configure UART interface
|
||||||
|
uart->CTRL = ((ovs - 1) << SCB_CTRL_OVS_Pos) | (2 << SCB_CTRL_MODE_Pos);
|
||||||
|
uart->UART_CTRL = 0;
|
||||||
|
uart->UART_RX_CTRL = 1 << SCB_UART_RX_CTRL_STOP_BITS_Pos;
|
||||||
|
uart->RX_CTRL = 7 << SCB_RX_CTRL_DATA_WIDTH_Pos;
|
||||||
|
uart->UART_TX_CTRL = 1 << SCB_UART_TX_CTRL_STOP_BITS_Pos;
|
||||||
|
uart->TX_CTRL = 7 << SCB_TX_CTRL_DATA_WIDTH_Pos;
|
||||||
|
uart->TX_FIFO_CTRL = 1 << 16;
|
||||||
|
uart->TX_FIFO_CTRL = 0;
|
||||||
|
uart->CTRL |= 1 << SCB_CTRL_ENABLED_Pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void uart_write_byte(volatile CySCB_Type *uart, uint8_t byte) {
|
||||||
|
(void) byte; (void) uart;
|
||||||
|
while((uart->INTR_TX & SCB_INTR_TX_EMPTY_Msk) == 0) spin(1);
|
||||||
|
uart->TX_FIFO_WR = byte;
|
||||||
|
uart->INTR_TX |= ~SCB_INTR_TX_EMPTY_Msk;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void uart_write_buf(volatile CySCB_Type *uart, char *buf, size_t len) {
|
||||||
|
while (len-- > 0) uart_write_byte(uart, *(uint8_t *) buf++);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void rng_init(void) {
|
||||||
|
}
|
||||||
|
static inline uint32_t rng_read(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void ethernet_init(void) {
|
||||||
|
gpio_init(PIN(26, 0), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_REF_CLK
|
||||||
|
gpio_init(PIN(26, 1), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TX_CTL
|
||||||
|
gpio_init(PIN(26, 2), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TX_CLK
|
||||||
|
gpio_init(PIN(26, 3), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TXD_0
|
||||||
|
gpio_init(PIN(26, 4), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TXD_1
|
||||||
|
gpio_init(PIN(26, 5), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TXD_2
|
||||||
|
gpio_init(PIN(26, 6), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TXD_3
|
||||||
|
gpio_init(PIN(26, 7), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RXD_0
|
||||||
|
|
||||||
|
gpio_init(PIN(27, 0), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RXD_1
|
||||||
|
gpio_init(PIN(27, 1), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RXD_2
|
||||||
|
gpio_init(PIN(27, 2), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RXD_3
|
||||||
|
gpio_init(PIN(27, 3), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RX_CTL
|
||||||
|
gpio_init(PIN(27, 4), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RX_CLK
|
||||||
|
gpio_init(PIN(27, 5), GPIO_MODE_INPUT, GPIO_STRONG, GPIO_SPEED_LOW, 0, 27); // ETH1_MDIO
|
||||||
|
gpio_init(PIN(27, 6), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_LOW, 0, 27); // ETH1_MDC
|
||||||
|
//gpio_init(PIN(27, 7), GPIO_MODE_OUTPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 0); // ETH1_RST
|
||||||
|
|
||||||
|
CPUSS->CM7_0_SYSTEM_INT_CTL[eth_1_interrupt_eth_0_IRQn] = 0x80000003; // assign CPU interrupt #3
|
||||||
|
NVIC->ISER[0] = 1 << 3;
|
||||||
|
|
||||||
|
spin(10000000); // artificial delay to wait for PHY init
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void clock_init(void) {
|
||||||
|
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); // Enable FPU
|
||||||
|
asm("DSB");
|
||||||
|
asm("ISB");
|
||||||
|
|
||||||
|
// configure PLL
|
||||||
|
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_BYPASS_SEL_Msk, BIT(29)); // First bypass PLL
|
||||||
|
spin(10);
|
||||||
|
SRSS->CLK_PLL400M[0].CONFIG &= ~CLK_PLL400M_CONFIG_ENABLE_Msk; // disable the PLL itself
|
||||||
|
|
||||||
|
// IMO source generates a frequency of 8MHz. The final frequency will be
|
||||||
|
// calculated as (CLK_IMO * feedback) / (reference * output_div)
|
||||||
|
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_FEEDBACK_DIV_Msk, PLL_FEEDBACK << CLK_PLL400M_CONFIG_FEEDBACK_DIV_Pos);
|
||||||
|
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_REFERENCE_DIV_Msk, PLL_REF << CLK_PLL400M_CONFIG_REFERENCE_DIV_Pos);
|
||||||
|
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_OUTPUT_DIV_Msk, PLL_OUT << CLK_PLL400M_CONFIG_OUTPUT_DIV_Pos);
|
||||||
|
CLRSET(SRSS->CLK_PLL400M[0].CONFIG2, CLK_PLL400M_CONFIG2_FRAC_DIV_Msk, 0);
|
||||||
|
CLRSET(SRSS->CLK_PLL400M[0].CONFIG2, CLK_PLL400M_CONFIG2_FRAC_DITHER_EN_Msk, 0);
|
||||||
|
CLRSET(SRSS->CLK_PLL400M[0].CONFIG2, CLK_PLL400M_CONFIG2_FRAC_EN_Msk, 1 << CLK_PLL400M_CONFIG2_FRAC_EN_Pos);
|
||||||
|
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_BYPASS_SEL_Msk, 0);
|
||||||
|
spin(10);
|
||||||
|
SRSS->CLK_PLL400M[0].CONFIG |= CLK_PLL400M_CONFIG_ENABLE_Msk; // enable the PLL
|
||||||
|
while (SRSS->CLK_PLL400M[0].CONFIG & 1) spin(1);
|
||||||
|
|
||||||
|
// configure PATH1 with source set to IMO
|
||||||
|
SRSS->CLK_PATH_SELECT[1] = 0;
|
||||||
|
|
||||||
|
// enable CLK_HFx
|
||||||
|
uint8_t clocks[] = {0, 1, 2, 3, 4, 5, 6};
|
||||||
|
for (size_t i = 0; i < sizeof(clocks) / sizeof(uint8_t); i++) {
|
||||||
|
CLRSET(SRSS->CLK_ROOT_SELECT[clocks[i]], SRSS_CLK_ROOT_SELECT_ROOT_MUX_Msk, 1); // choose PATH1
|
||||||
|
CLRSET(SRSS->CLK_ROOT_SELECT[clocks[i]], SRSS_CLK_ROOT_SELECT_DIRECT_MUX_Msk, 1 << SRSS_CLK_ROOT_SELECT_DIRECT_MUX_Pos);
|
||||||
|
if (clocks[i] != 0) // CLF_HF0 is already enabled
|
||||||
|
SRSS->CLK_ROOT_SELECT[clocks[i]] |= SRSS_CLK_ROOT_SELECT_ENABLE_Msk; // enable clock root
|
||||||
|
}
|
||||||
|
|
||||||
|
// set systick frequency
|
||||||
|
uint32_t tenms = SYS_FREQUENCY / 100 - 1; // number of cycles executed in 10ms
|
||||||
|
CPUSS->SYSTICK_CTL = tenms | (3 << CPUSS_SYSTICK_CTL_CLOCK_SOURCE_Pos); // select CLK_HF as source
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
OUTPUT_FORMAT("elf32-littlearm")
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
flash(RX) : ORIGIN = 0x10080000, LENGTH = 0x80000
|
||||||
|
sram(!RX) : ORIGIN = 0x28000800, LENGTH = 510K
|
||||||
|
}
|
||||||
|
|
||||||
|
_estack = ORIGIN(sram) + LENGTH(sram);
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.vectors : { . = ALIGN(4); KEEP(*(.vectors)); . = ALIGN(4); } > flash
|
||||||
|
.text : { *(.text*) } > flash
|
||||||
|
.rodata : { *(.rodata*) } > flash
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
_sdata = .;
|
||||||
|
*(.first_data)
|
||||||
|
*(.data SORT(.data.*))
|
||||||
|
_edata = .;
|
||||||
|
} > sram AT > flash
|
||||||
|
_sidata = LOADADDR(.data);
|
||||||
|
|
||||||
|
.bss : { _sbss = .; *(.bss SORT(.bss.*) COMMON) _ebss = .; } > sram
|
||||||
|
|
||||||
|
. = ALIGN(8);
|
||||||
|
_end = .;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2024 Cesanta Software Limited
|
||||||
|
// All rights reserved
|
||||||
|
|
||||||
|
#include "hal.h"
|
||||||
|
#include "mongoose.h"
|
||||||
|
#include "net.h"
|
||||||
|
|
||||||
|
#define BLINK_PERIOD_MS 1000
|
||||||
|
|
||||||
|
static void timer_fn(void *arg) {
|
||||||
|
gpio_toggle(LED1); // Blink LED
|
||||||
|
(void) arg; // Unused
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
struct mg_mgr mgr; // Mongoose event manager
|
||||||
|
|
||||||
|
hal_init(); // Cross-platform hardware init
|
||||||
|
|
||||||
|
mg_mgr_init(&mgr); // Initialise it
|
||||||
|
mg_log_set(MG_LL_DEBUG); // Set log level to debug
|
||||||
|
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mgr);
|
||||||
|
|
||||||
|
MG_INFO(("Initialising application..."));
|
||||||
|
web_init(&mgr);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
mg_mgr_poll(&mgr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../mongoose.c
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../mongoose.h
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// See https://mongoose.ws/documentation/#build-options
|
||||||
|
#define MG_ARCH MG_ARCH_NEWLIB
|
||||||
|
|
||||||
|
#define MG_ENABLE_TCPIP 1
|
||||||
|
#define MG_ENABLE_DRIVER_XMC7 1
|
||||||
|
#define MG_IO_SIZE 256
|
||||||
|
#define MG_ENABLE_CUSTOM_MILLIS 1
|
||||||
|
#define MG_ENABLE_CUSTOM_RANDOM 1
|
||||||
|
#define MG_ENABLE_PACKED_FS 1
|
||||||
|
|
||||||
|
// For static IP configuration, define MG_TCPIP_{IP,MASK,GW}
|
||||||
|
// By default, those are set to zero, meaning that DHCP is used
|
||||||
|
//
|
||||||
|
// #define MG_TCPIP_IP MG_IPV4(192, 168, 1, 10)
|
||||||
|
// #define MG_TCPIP_GW MG_IPV4(192, 168, 1, 1)
|
||||||
|
// #define MG_TCPIP_MASK MG_IPV4(255, 255, 255, 0)
|
||||||
|
|
||||||
|
// Set custom MAC address. By default, it is randomly generated
|
||||||
|
// Using a build-time constant:
|
||||||
|
// #define MG_SET_MAC_ADDRESS(mac) do { uint8_t buf_[6] = {2,3,4,5,6,7}; memmove(mac, buf_, sizeof(buf_)); } while (0)
|
||||||
|
//
|
||||||
|
// Using custom function:
|
||||||
|
// extern void my_function(unsigned char *mac);
|
||||||
|
// #define MG_SET_MAC_ADDRESS(mac) my_function(mac)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../device-dashboard/net.c
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../device-dashboard/net.h
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../device-dashboard/packed_fs.c
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
#include "xmc7200d_e272k8384.h"
|
||||||
|
|
||||||
|
void Reset_Handler(void); // Defined below
|
||||||
|
void Dummy_Handler(void); // Defined below
|
||||||
|
void SysTick_Handler(void); // Defined in main.c
|
||||||
|
void SystemInit(void); // Defined in main.c, called by reset handler
|
||||||
|
void _estack(void); // Defined in link.ld
|
||||||
|
|
||||||
|
#define WEAK_ALIAS __attribute__((weak, alias("Default_Handler")))
|
||||||
|
|
||||||
|
WEAK_ALIAS void NMI_Handler(void);
|
||||||
|
WEAK_ALIAS void HardFault_Handler(void);
|
||||||
|
WEAK_ALIAS void SVCall_Handler(void);
|
||||||
|
WEAK_ALIAS void PendSV_Handler(void);
|
||||||
|
WEAK_ALIAS void SysTick_Handler(void);
|
||||||
|
|
||||||
|
WEAK_ALIAS void Default_Intr_Handler(void);
|
||||||
|
WEAK_ALIAS void CM0P_CpuIntr0_Handler(void);
|
||||||
|
WEAK_ALIAS void CM0P_CpuIntr1_Handler(void);
|
||||||
|
WEAK_ALIAS void CM0P_CpuIntr2_Handler(void);
|
||||||
|
WEAK_ALIAS void CM0P_CpuIntr4_Handler(void);
|
||||||
|
WEAK_ALIAS void CM0P_CpuIntr5_Handler(void);
|
||||||
|
WEAK_ALIAS void CM0P_CpuIntr6_Handler(void);
|
||||||
|
WEAK_ALIAS void CM0P_CpuIntr7_Handler(void);
|
||||||
|
WEAK_ALIAS void ETH_IRQHandler(void);
|
||||||
|
|
||||||
|
void CM0P_CpuIntr3_Handler(void) {
|
||||||
|
ETH_IRQHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((section(".vectors"))) void (*const tab[16 + 16])(void) = {
|
||||||
|
_estack,
|
||||||
|
Reset_Handler,
|
||||||
|
NMI_Handler,
|
||||||
|
HardFault_Handler,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
SVCall_Handler,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
PendSV_Handler,
|
||||||
|
SysTick_Handler,
|
||||||
|
CM0P_CpuIntr0_Handler,
|
||||||
|
CM0P_CpuIntr1_Handler,
|
||||||
|
CM0P_CpuIntr2_Handler,
|
||||||
|
CM0P_CpuIntr3_Handler,
|
||||||
|
CM0P_CpuIntr4_Handler,
|
||||||
|
CM0P_CpuIntr5_Handler,
|
||||||
|
CM0P_CpuIntr6_Handler,
|
||||||
|
CM0P_CpuIntr7_Handler,
|
||||||
|
Default_Intr_Handler,
|
||||||
|
Default_Intr_Handler,
|
||||||
|
Default_Intr_Handler,
|
||||||
|
Default_Intr_Handler,
|
||||||
|
Default_Intr_Handler,
|
||||||
|
Default_Intr_Handler,
|
||||||
|
Default_Intr_Handler,
|
||||||
|
Default_Intr_Handler
|
||||||
|
};
|
||||||
|
|
||||||
|
__attribute__((naked, noreturn)) void Reset_Handler(void) {
|
||||||
|
// Clear BSS section, and copy data section from flash to RAM
|
||||||
|
extern long _sbss, _ebss, _sdata, _edata, _sidata;
|
||||||
|
for (long *src = &_sbss; src < &_ebss; src++) *src = 0;
|
||||||
|
for (long *src = &_sdata, *dst = &_sidata; src < &_edata;) *src++ = *dst++;
|
||||||
|
|
||||||
|
SCB->VTOR = (uint32_t) &tab;
|
||||||
|
SystemInit();
|
||||||
|
|
||||||
|
// Call main()
|
||||||
|
extern void main(void);
|
||||||
|
main();
|
||||||
|
for (;;) (void) 0; // Infinite loop
|
||||||
|
}
|
||||||
|
|
||||||
|
void Default_Handler(void) {
|
||||||
|
for (;;) (void) 0;
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/json-rpc-over-websocket/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
See detailed tutorial at https://mongoose.ws/tutorials/webui-push/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -48,20 +48,20 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
sub_opts.topic = subt;
|
sub_opts.topic = subt;
|
||||||
sub_opts.qos = s_qos;
|
sub_opts.qos = s_qos;
|
||||||
mg_mqtt_sub(c, &sub_opts);
|
mg_mqtt_sub(c, &sub_opts);
|
||||||
MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.ptr));
|
MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.buf));
|
||||||
struct mg_mqtt_opts pub_opts;
|
struct mg_mqtt_opts pub_opts;
|
||||||
memset(&pub_opts, 0, sizeof(pub_opts));
|
memset(&pub_opts, 0, sizeof(pub_opts));
|
||||||
pub_opts.topic = pubt;
|
pub_opts.topic = pubt;
|
||||||
pub_opts.message = data;
|
pub_opts.message = data;
|
||||||
pub_opts.qos = s_qos, pub_opts.retain = false;
|
pub_opts.qos = s_qos, pub_opts.retain = false;
|
||||||
mg_mqtt_pub(c, &pub_opts);
|
mg_mqtt_pub(c, &pub_opts);
|
||||||
MG_INFO(("%lu PUBLISHED %.*s -> %.*s", c->id, (int) data.len, data.ptr,
|
MG_INFO(("%lu PUBLISHED %.*s -> %.*s", c->id, (int) data.len, data.buf,
|
||||||
(int) pubt.len, pubt.ptr));
|
(int) pubt.len, pubt.buf));
|
||||||
} else if (ev == MG_EV_MQTT_MSG) {
|
} else if (ev == MG_EV_MQTT_MSG) {
|
||||||
// When we get echo response, print it
|
// When we get echo response, print it
|
||||||
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
|
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
|
||||||
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
|
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
|
||||||
mm->data.ptr, (int) mm->topic.len, mm->topic.ptr));
|
mm->data.buf, (int) mm->topic.len, mm->topic.buf));
|
||||||
} else if (ev == MG_EV_CLOSE) {
|
} else if (ev == MG_EV_CLOSE) {
|
||||||
MG_INFO(("%lu CLOSED", c->id));
|
MG_INFO(("%lu CLOSED", c->id));
|
||||||
s_conn = NULL; // Mark that we're closed
|
s_conn = NULL; // Mark that we're closed
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ example: micropython
|
|||||||
$(MAKE) -C micropython/ports/unix USER_C_MODULES=../../..
|
$(MAKE) -C micropython/ports/unix USER_C_MODULES=../../..
|
||||||
|
|
||||||
micropython:
|
micropython:
|
||||||
git clone https://github.com/micropython/micropython.git
|
git clone --depth 1 -b v1.22.2 https://github.com/micropython/micropython.git
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf micropython
|
rm -rf micropython
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../mongoose.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../device-dashboard/net.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../device-dashboard/net.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../device-dashboard/packed_fs.c
|
|
||||||
@@ -10,17 +10,4 @@ following features:
|
|||||||
needing a filesystem to serve it; so being resilient to FS problems
|
needing a filesystem to serve it; so being resilient to FS problems
|
||||||
- All changes are propagated to all connected clients
|
- All changes are propagated to all connected clients
|
||||||
|
|
||||||
## Screenshots
|
|
||||||
|
|
||||||
This is a login screen that prompts for user/password
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Main dashboard
|
|
||||||
|
|
||||||
The main dashboard page shows the interactive console
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/
|
See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/
|
||||||
Loaded 100 of 708 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user