Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolchain fixes #3451

Merged
merged 23 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d70bcfd
toolchain: v29 preparations
hedger Feb 14, 2024
d72c449
scripts: better error handling in update process
hedger Feb 14, 2024
887083b
scripts: toolchain: only unlink symlink if exists
hedger Feb 14, 2024
890bb98
toolchain: bump to v30
hedger Feb 15, 2024
11a34e5
debug: updated udev rules & added docs on rules installation
hedger Feb 15, 2024
8e4c366
toolchain: bump to v31
hedger Feb 15, 2024
d19f8f5
Merge branch 'dev' into hedger/toochain_29
hedger Feb 15, 2024
01d937c
Merge branch 'dev' into hedger/toochain_29
hedger Feb 16, 2024
b38d2e8
Merge remote-tracking branch 'remotes/origin/dev' into hedger/toochai…
hedger Feb 18, 2024
b157870
toolchain: v32
hedger Feb 18, 2024
02a827d
libs: added callback-connector to SDK
hedger Feb 19, 2024
71e763d
fbt: bumped c&cpp standard versions
hedger Feb 20, 2024
ee11aca
accessor: unvolatiled stuff according to c++20
hedger Feb 20, 2024
e143833
battery_test_app: signature fixes
hedger Feb 20, 2024
d731918
linter fixes
hedger Feb 20, 2024
bc98c78
fbt: moved FBT_NOEVN check to env setup script for *nix
hedger Feb 20, 2024
10d2911
toolchain: bumped to v33
hedger Feb 21, 2024
d4433fa
fbt: fixed behavior on Win and fbtenv
hedger Feb 21, 2024
b1ebb14
ft: removed debug logging
hedger Feb 21, 2024
90a8009
libs: moved callback-connector to accessor app
hedger Feb 21, 2024
65b0aa8
accessor: naming fix
hedger Feb 21, 2024
1c56a30
fbt: added "USERPROFILE" to forwarded vars
hedger Feb 22, 2024
cffaf53
fbt: added "LOCALAPPDATA" to forwarded vars
hedger Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion applications/debug/accessor/accessor_view_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "accessor_view_manager.h"
#include "accessor_event.h"
#include <callback-connector.h>
#include "callback_connector.h"

AccessorAppViewManager::AccessorAppViewManager() {
event_queue = furi_message_queue_alloc(10, sizeof(AccessorEvent));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#ifndef CALLBACKCONNECTOR_H
#define CALLBACKCONNECTOR_H

#ifdef __cplusplus
#include <functional>
namespace cbc {
namespace Details {

template <std::size_t Tag, typename T, typename Ret, typename... Args> class FuncMemberWrapper {
template <std::size_t Tag, typename T, typename Ret, typename... Args>
class FuncMemberWrapper {
public:
FuncMemberWrapper() = delete;
using member_fun_t = Ret (T::*)(Args...);
Expand Down Expand Up @@ -43,7 +46,8 @@ template <std::size_t Tag, typename T, typename Ret, typename... Args>
typename FuncMemberWrapper<Tag, T, Ret, Args...>::const_member_fun_t
FuncMemberWrapper<Tag, T, Ret, Args...>::const_member{};

template <typename Functor, typename Ret, typename... Args> struct FunctorWrapper {
template <typename Functor, typename Ret, typename... Args>
struct FunctorWrapper {
public:
static std::function<Ret(Args...)> functor;
static auto instatiate(Functor fn) {
Expand Down Expand Up @@ -75,7 +79,8 @@ auto const_instantiate(T* t, Ret (T::*ptr)(Args...) const) {
return FuncMemberWrapper<tag, T, Ret, Args...>::instantiate(t, ptr);
}

template <std::size_t tag, typename T, typename Func> auto const_instantiate(T* t, Func ptr) {
template <std::size_t tag, typename T, typename Func>
auto const_instantiate(T* t, Func ptr) {
return const_instantiate(t, ptr);
}

Expand All @@ -91,9 +96,11 @@ auto obtain_connector(T* t, Ret (T::*ptr)(Args...) const) {
return Details::FuncMemberWrapper<tag, T, Ret, Args...>::instantiate(t, ptr);
}

template <typename Functor> auto obtain_connector(Functor functor) {
template <typename Functor>
auto obtain_connector(Functor functor) {
return Details::deducer(std::move(functor), &Functor::operator());
}
} //end of cbc scope

#endif // __cplusplus
#endif // CALLBACKCONNECTOR_H
13 changes: 5 additions & 8 deletions applications/debug/accessor/helpers/wiegand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#include <furi.h>
#include <furi_hal.h>

volatile unsigned long WIEGAND::_cardTempHigh = 0;
volatile unsigned long WIEGAND::_cardTemp = 0;
volatile unsigned long WIEGAND::_lastWiegand = 0;
unsigned long WIEGAND::_cardTempHigh = 0;
unsigned long WIEGAND::_cardTemp = 0;
unsigned long WIEGAND::_lastWiegand = 0;
unsigned long WIEGAND::_code = 0;
unsigned long WIEGAND::_codeHigh = 0;
volatile int WIEGAND::_bitCount = 0;
int WIEGAND::_bitCount = 0;
int WIEGAND::_wiegandType = 0;

constexpr uint32_t clocks_in_ms = 64 * 1000;
Expand Down Expand Up @@ -98,10 +98,7 @@ void WIEGAND::ReadD1() {
_lastWiegand = DWT->CYCCNT; // Keep track of last wiegand bit received
}

unsigned long WIEGAND::GetCardId(
volatile unsigned long* codehigh,
volatile unsigned long* codelow,
char bitlength) {
unsigned long WIEGAND::GetCardId(unsigned long* codehigh, unsigned long* codelow, char bitlength) {
if(bitlength == 26) // EM tag
return (*codelow & 0x1FFFFFE) >> 1;

Expand Down
14 changes: 6 additions & 8 deletions applications/debug/accessor/helpers/wiegand.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ class WIEGAND {

private:
static bool DoWiegandConversion();
static unsigned long GetCardId(
volatile unsigned long* codehigh,
volatile unsigned long* codelow,
char bitlength);
static unsigned long
GetCardId(unsigned long* codehigh, unsigned long* codelow, char bitlength);

static volatile unsigned long _cardTempHigh;
static volatile unsigned long _cardTemp;
static volatile unsigned long _lastWiegand;
static volatile int _bitCount;
static unsigned long _cardTempHigh;
static unsigned long _cardTemp;
static unsigned long _lastWiegand;
static int _bitCount;
static int _wiegandType;
static unsigned long _code;
static unsigned long _codeHigh;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../accessor_app.h"
#include "../accessor_view_manager.h"
#include "../accessor_event.h"
#include <callback-connector.h>
#include "callback_connector.h"
#include "accessor_scene_start.h"

void AccessorSceneStart::on_enter(AccessorApp* app) {
Expand Down
3 changes: 2 additions & 1 deletion applications/debug/battery_test_app/battery_test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ void battery_test_dialog_callback(DialogExResult result, void* context) {
}
}

uint32_t battery_test_exit_confirm_view() {
uint32_t battery_test_exit_confirm_view(void* context) {
UNUSED(context);
return BatteryTestAppViewExitDialog;
}

Expand Down
6 changes: 4 additions & 2 deletions applications/drivers/subghz/cc1101_ext/cc1101_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ static bool subghz_device_cc1101_ext_stop_debug() {
return ret;
}

static void subghz_device_cc1101_ext_capture_ISR() {
static void subghz_device_cc1101_ext_capture_ISR(void* context) {
UNUSED(context);
if(!furi_hal_gpio_read(subghz_device_cc1101_ext->g0_pin)) {
if(subghz_device_cc1101_ext->async_rx.capture_callback) {
if(subghz_device_cc1101_ext->async_mirror_pin != NULL)
Expand Down Expand Up @@ -674,7 +675,8 @@ static void subghz_device_cc1101_ext_async_tx_refill(uint32_t* buffer, size_t sa
}
}

static void subghz_device_cc1101_ext_async_tx_dma_isr() {
static void subghz_device_cc1101_ext_async_tx_dma_isr(void* context) {
UNUSED(context);
furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateAsyncTx);

#if SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_CHANNEL == LL_DMA_CHANNEL_3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ constexpr HashtableApiInterface applicaton_hashtable_api_interface{
.resolver_callback = &elf_resolve_from_hashtable,
},
/* pointers to application's API table boundaries */
.table_cbegin = app_api_table.cbegin(),
.table_cend = app_api_table.cend(),
app_api_table.cbegin(),
app_api_table.cend(),
};

/* Casting to generic resolver to use in Composite API resolver */
Expand Down
4 changes: 2 additions & 2 deletions applications/main/nfc/api/nfc_app_api_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ constexpr HashtableApiInterface nfc_application_hashtable_api_interface{
.resolver_callback = &elf_resolve_from_hashtable,
},
/* pointers to application's API table boundaries */
.table_cbegin = nfc_app_api_table.cbegin(),
.table_cend = nfc_app_api_table.cend(),
nfc_app_api_table.cbegin(),
nfc_app_api_table.cend(),
};

/* Casting to generic resolver to use in Composite API resolver */
Expand Down
8 changes: 4 additions & 4 deletions applications/services/loader/firmware_api/firmware_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ constexpr HashtableApiInterface mock_elf_api_interface{
.api_version_minor = 0,
.resolver_callback = &elf_resolve_from_hashtable,
},
.table_cbegin = nullptr,
.table_cend = nullptr,
nullptr,
nullptr,
};

const ElfApiInterface* const firmware_api_interface = &mock_elf_api_interface;
Expand All @@ -29,8 +29,8 @@ constexpr HashtableApiInterface elf_api_interface{
.api_version_minor = (elf_api_version & 0xFFFF),
.resolver_callback = &elf_resolve_from_hashtable,
},
.table_cbegin = elf_api_table.cbegin(),
.table_cend = elf_api_table.cend(),
elf_api_table.cbegin(),
elf_api_table.cend(),
};
const ElfApiInterface* const firmware_api_interface = &elf_api_interface;
#endif
Expand Down
4 changes: 2 additions & 2 deletions applications/system/js_app/plugin_api/app_api_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ constexpr HashtableApiInterface applicaton_hashtable_api_interface{
.resolver_callback = &elf_resolve_from_hashtable,
},
/* pointers to application's API table boundaries */
.table_cbegin = app_api_table.cbegin(),
.table_cend = app_api_table.cend(),
app_api_table.cbegin(),
app_api_table.cend(),
};

/* Casting to generic resolver to use in Composite API resolver */
Expand Down
5 changes: 1 addition & 4 deletions fbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ SCONS_DEFAULT_FLAGS="--warn=target-not-built";
SCONS_EP="python3 -m SCons";

# public variables
FBT_NOENV="${FBT_NOENV:-""}";
FBT_NO_SYNC="${FBT_NO_SYNC:-""}";
FBT_TOOLCHAIN_PATH="${FBT_TOOLCHAIN_PATH:-$SCRIPT_PATH}";
FBT_VERBOSE="${FBT_VERBOSE:-""}";
FBT_GIT_SUBMODULE_SHALLOW="${FBT_GIT_SUBMODULE_SHALLOW:-""}";

if [ -z "$FBT_NOENV" ]; then
FBT_VERBOSE="$FBT_VERBOSE" . "$SCRIPT_PATH/scripts/toolchain/fbtenv.sh";
fi
FBT_VERBOSE="$FBT_VERBOSE" . "$SCRIPT_PATH/scripts/toolchain/fbtenv.sh";

if [ -z "$FBT_VERBOSE" ]; then
SCONS_DEFAULT_FLAGS="$SCONS_DEFAULT_FLAGS -Q";
Expand Down
2 changes: 1 addition & 1 deletion fbt.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
call "%~dp0scripts\toolchain\fbtenv.cmd" env
call "%~dp0scripts\toolchain\fbtenv.cmd" env || exit /b

set SCONS_EP=python -m SCons

Expand Down
17 changes: 12 additions & 5 deletions scripts/debug/41-udev.rules → scripts/debug/41-flipper.rules
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#Flipper Zero serial port
# Flipper Zero serial port
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", ATTRS{manufacturer}=="Flipper Devices Inc.", TAG+="uaccess", GROUP="dialout"
#Flipper Zero DFU

# Flipper Zero DFU
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", ATTRS{manufacturer}=="STMicroelectronics", TAG+="uaccess", GROUP="dialout"
#Flipper ESP32s2 BlackMagic

# Flipper ESP32s2 BlackMagic
SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="40??", ATTRS{manufacturer}=="Flipper Devices Inc.", TAG+="uaccess", GROUP="dialout"
#Flipper U2F

# Flipper ESP32s2 in DAP mode
SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="40??", ATTRS{manufacturer}=="CMSIS-DAP", TAG+="uaccess", GROUP="dialout"

# Flipper U2F
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5741", ATTRS{manufacturer}=="Flipper Devices Inc.", ENV{ID_SECURITY_TOKEN}="1"
#ST-Link-V3

# ST-Link-V3
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="37??", ATTRS{manufacturer}=="STMicroelectronics", TAG+="uaccess", GROUP="dialout"
19 changes: 19 additions & 0 deletions scripts/debug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Installing udev rules

On Linux, unprivileged users need to be in the `dialout` group to access serial ports and other USB devices.

To add your user to the `dialout` group, run the following command:

```bash
sudo usermod -a -G dialout $USER
```

To install the udev rules needed for debugging & CLI access to Flipper, run the following command:

```bash
sudo cp 41-flipper.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
```

Note that not all possible debug interfaces are listed the `41-flipper.rules` file. If your interface is not supported out of the box, you may need to add a a rule for it. You can do so by adding a new line to the file according to udev rules syntax. Use `lsusb -v` to find the vendor and product IDs of your device.
2 changes: 2 additions & 0 deletions scripts/fbt/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"PYTHONNOUSERSITE",
"TMP",
"TEMP",
"USERPROFILE",
"LOCALAPPDATA",
# ccache
"CCACHE_DISABLE",
# Colors for tools
Expand Down
4 changes: 3 additions & 1 deletion scripts/toolchain/fbtenv.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if not ["%FBT_NOENV%"] == [""] (
exit /b 0
)

set "FLIPPER_TOOLCHAIN_VERSION=28"
set "FLIPPER_TOOLCHAIN_VERSION=33"

if ["%FBT_TOOLCHAIN_PATH%"] == [""] (
set "FBT_TOOLCHAIN_PATH=%FBT_ROOT%"
Expand Down Expand Up @@ -58,3 +58,5 @@ if not "%1" == "env" (
cd "%FBT_ROOT%"
cmd /k
)

exit /b 0
17 changes: 15 additions & 2 deletions scripts/toolchain/fbtenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# public variables
DEFAULT_SCRIPT_PATH="$(pwd -P)";
FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"28"}";
FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"33"}";

if [ -z ${FBT_TOOLCHAIN_PATH+x} ] ; then
FBT_TOOLCHAIN_PATH_WAS_SET=0;
Expand Down Expand Up @@ -76,6 +76,14 @@ fbtenv_restore_env()
unset FBT_TOOLCHAIN_PATH;
}

fbtenv_check_if_noenv_set()
{
if [ -n "${FBT_NOENV:-""}" ]; then
return 1;
fi
return 0;
}

fbtenv_check_sourced()
{
if [ -n "${FBT_SKIP_CHECK_SOURCED:-""}" ]; then
Expand Down Expand Up @@ -203,7 +211,9 @@ fbtenv_show_unpack_percentage()
fbtenv_unpack_toolchain()
{
echo "Unpacking toolchain to '$FBT_TOOLCHAIN_PATH/toolchain':";
rm "$FBT_TOOLCHAIN_PATH/toolchain/current" || true;
if [ -L "$FBT_TOOLCHAIN_PATH/toolchain/current" ]; then
rm "$FBT_TOOLCHAIN_PATH/toolchain/current";
fi
tar -xvf "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_TAR" -C "$FBT_TOOLCHAIN_PATH/toolchain" 2>&1 | fbtenv_show_unpack_percentage;
mkdir -p "$FBT_TOOLCHAIN_PATH/toolchain" || return 1;
mv "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_DIR" "$TOOLCHAIN_ARCH_DIR" || return 1;
Expand Down Expand Up @@ -296,6 +306,9 @@ fbtenv_print_config()

fbtenv_main()
{
if ! fbtenv_check_if_noenv_set; then
return 0;
fi
fbtenv_check_sourced || return 1;
fbtenv_get_kernel_type || return 1;
if [ "$1" = "--restore" ]; then
Expand Down
14 changes: 11 additions & 3 deletions scripts/toolchain/windows-toolchain-download.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ $toolchain_zip = "$toolchain_dist_folder-$toolchain_version.zip"
$toolchain_zip_temp_path = "$download_dir\$toolchain_zip"
$toolchain_dist_temp_path = "$download_dir\$toolchain_dist_folder"

try {

if (Test-Path -LiteralPath "$toolchain_target_path") {
Write-Host -NoNewline "Removing old Windows toolchain.."
Remove-Item -LiteralPath "$toolchain_target_path" -Force -Recurse
Write-Host "done!"
}

if (Test-path -Path "$toolchain_target_path\..\current") {
if (Test-path -LiteralPath "$toolchain_target_path\..\current") {
Write-Host -NoNewline "Unlinking 'current'.."
Remove-Item -LiteralPath "$toolchain_target_path\..\current" -Force
Write-Host "done!"
}

if (!(Test-Path -Path "$toolchain_zip_temp_path" -PathType Leaf)) {
if (!(Test-Path -LiteralPath "$toolchain_zip_temp_path" -PathType Leaf)) {
Write-Host -NoNewline "Downloading Windows toolchain.."
$wc = New-Object net.webclient
$wc.Downloadfile("$toolchain_url", "$toolchain_zip_temp_path")
Expand Down Expand Up @@ -57,4 +59,10 @@ Write-Host -NoNewline "Cleaning up temporary files.."
Remove-Item -LiteralPath "$toolchain_zip_temp_path" -Force
Write-Host "done!"

# dasdasd
} catch {
Write-Host "An error occurred"
Write-Host $_
Write-Host "Please close VSCode and any other programs that may be using the toolchain and try again."
$host.SetShouldExit(1)
Exit 1
}
4 changes: 2 additions & 2 deletions site_scons/cc.scons
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Import("ENV")

ENV.AppendUnique(
CFLAGS=[
"-std=gnu17",
"-std=gnu2x",
],
CXXFLAGS=[
"-std=c++17",
"-std=c++20",
"-fno-rtti",
"-fno-use-cxa-atexit",
"-fno-exceptions",
Expand Down
3 changes: 2 additions & 1 deletion targets/f7/furi_hal/furi_hal_ibutton.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ typedef struct {

FuriHalIbutton* furi_hal_ibutton = NULL;

static void furi_hal_ibutton_emulate_isr() {
static void furi_hal_ibutton_emulate_isr(void* context) {
UNUSED(context);
if(LL_TIM_IsActiveFlag_UPDATE(FURI_HAL_IBUTTON_TIMER)) {
LL_TIM_ClearFlag_UPDATE(FURI_HAL_IBUTTON_TIMER);
furi_hal_ibutton->callback(furi_hal_ibutton->context);
Expand Down
Loading
Loading