feat: store git version in fw and show in web ui
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 4m41s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 4s
Run unit tests on host / Run-Unit-Tests (push) Successful in 7s
Run pytests / Check-Pytest (push) Successful in 11s
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 4m41s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 4s
Run unit tests on host / Run-Unit-Tests (push) Successful in 7s
Run pytests / Check-Pytest (push) Successful in 11s
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
29
software/boards/RPI_PICO_W/board.c
Normal file
29
software/boards/RPI_PICO_W/board.c
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// Copyright (c) 2025 Matthias Blankertz <matthias@blankertz.org>
|
||||||
|
|
||||||
|
#include "py/obj.h"
|
||||||
|
#include "py/runtime.h"
|
||||||
|
#include "py/objstr.h"
|
||||||
|
|
||||||
|
#ifndef TONBERRY_GIT_REVISION
|
||||||
|
#define TONBERRY_GIT_REVISION "unknown"
|
||||||
|
#endif
|
||||||
|
#ifndef TONBERRY_VERSION
|
||||||
|
#define TONBERRY_VERSION "unknown"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const MP_DEFINE_STR_OBJ(tonberry_git_revision_obj, TONBERRY_GIT_REVISION);
|
||||||
|
static const MP_DEFINE_STR_OBJ(tonberry_version_obj, TONBERRY_VERSION);
|
||||||
|
|
||||||
|
static const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||||
|
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_board)},
|
||||||
|
{MP_ROM_QSTR(MP_QSTR_revision), MP_ROM_PTR(&tonberry_git_revision_obj)},
|
||||||
|
{MP_ROM_QSTR(MP_QSTR_version), MP_ROM_PTR(&tonberry_version_obj)},
|
||||||
|
};
|
||||||
|
static MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
||||||
|
|
||||||
|
const mp_obj_module_t board_cmodule = {
|
||||||
|
.base = {&mp_type_module},
|
||||||
|
.globals = (mp_obj_dict_t *)&board_module_globals,
|
||||||
|
};
|
||||||
|
MP_REGISTER_MODULE(MP_QSTR_board, board_cmodule);
|
||||||
@@ -20,3 +20,22 @@ set(GEN_PINS_CSV_ARG --board-csv "${GEN_PINS_BOARD_CSV}")
|
|||||||
|
|
||||||
add_link_options("-Wl,--print-memory-usage")
|
add_link_options("-Wl,--print-memory-usage")
|
||||||
set(PICO_USE_FASTEST_SUPPORTED_CLOCK 1)
|
set(PICO_USE_FASTEST_SUPPORTED_CLOCK 1)
|
||||||
|
|
||||||
|
find_program(GIT git)
|
||||||
|
|
||||||
|
execute_process(COMMAND ${GIT} rev-parse HEAD
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
|
||||||
|
OUTPUT_VARIABLE TONBERRY_GIT_REVISION
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(COMMAND ${GIT} describe --match 'v*' --always
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
|
||||||
|
OUTPUT_VARIABLE TONBERRY_VERSION
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
set(MICROPY_SOURCE_BOARD "${CMAKE_CURRENT_LIST_DIR}/board.c")
|
||||||
|
set(MICROPY_DEF_BOARD
|
||||||
|
TONBERRY_GIT_REVISION="${TONBERRY_GIT_REVISION}"
|
||||||
|
TONBERRY_VERSION="${TONBERRY_VERSION}")
|
||||||
|
|||||||
@@ -131,6 +131,12 @@
|
|||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
font-size: x-small;
|
||||||
|
color: gray;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -257,7 +263,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<hr>
|
||||||
|
<div class="flex-horizontal">
|
||||||
|
<div>
|
||||||
|
<a href="https://git.ka.blankertz.org/TonBERRY/tonberry-pico">TonBERRY pico</a>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Version: <span id="footer-version">unknown</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
const Screens = {};
|
const Screens = {};
|
||||||
let activeScreen = null;
|
let activeScreen = null;
|
||||||
@@ -981,6 +997,13 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
showScreen("menu");
|
showScreen("menu");
|
||||||
|
|
||||||
|
fetch('/api/v1/info')
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then((info) => {
|
||||||
|
const version = document.getElementById('footer-version');
|
||||||
|
version.innerText = info.version;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -4,11 +4,14 @@ Copyright (c) 2024-2025 Stefan Kratochwil <Kratochwil-LA@gmx.de>
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import board
|
||||||
import hwconfig
|
import hwconfig
|
||||||
import json
|
import json
|
||||||
import machine
|
import machine
|
||||||
|
import network
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import ubinascii
|
||||||
|
|
||||||
from array import array
|
from array import array
|
||||||
from microdot import Microdot, redirect, send_file, Request
|
from microdot import Microdot, redirect, send_file, Request
|
||||||
@@ -270,3 +273,10 @@ async def reboot(request, method):
|
|||||||
else:
|
else:
|
||||||
return 'method not supported', 400
|
return 'method not supported', 400
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
|
|
||||||
|
@webapp.route('/api/v1/info', methods=['GET'])
|
||||||
|
async def get_info(request):
|
||||||
|
mac = ubinascii.hexlify(network.WLAN().config('mac'), ':').decode()
|
||||||
|
return {'version': board.version,
|
||||||
|
'mac': mac}
|
||||||
|
|||||||
Reference in New Issue
Block a user