fix(CI): Prerequisites for nuttx update (#27509)

* src/drivers/cdcacm_autostart: Include posix.h for px4_close

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* platforms/nuttx/CMakeLists.txt: Fix linking of nuttx libaries for memalign

This fixes memalign not found in linking step for some boards

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* Add "flock" to macos.sh setup script

"flock" is not standard on macOS, and a dependency was missing from the
macOS setup path.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* Fix clang-tidy errors in Bitset.hpp and in src/lib/matrix

Fix the "bugprone-dynamic-static-initializers" linter errors.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* systemlib/hardfault_log: Fix clang-diagnostics error

Fix for
"[error] clang-diagnostic-error [error]
 use of undeclared identifier XCPTCONTEXT_REGS".

XCPTCONTEXT_REGS is defined in nuttx irq.h, so include that.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* uORB: Fix clang-tidy error "bugprone-dynamic-static-initializers"

Fix the clang-tidy error appearing on uORBManager _Instance variable by
adding a getter for the reference to the _Instance and using that instead.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* CI: Add default ubuntu mirrors as fallback

In case of specified aws mirror doesn't have the package idicated by the
metadata, a the default ubuntu mirror as a backup.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

---------

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This commit is contained in:
Jukka Laitinen
2026-06-02 11:27:50 -06:00
committed by GitHub
parent fe077b6c58
commit 839b7a470f
13 changed files with 79 additions and 37 deletions
+33
View File
@@ -40,3 +40,36 @@ if [ -f /etc/apt/sources.list ]; then
-e "s|http://security.ubuntu.com/ubuntu|${MIRROR}|g" \
/etc/apt/sources.list
fi
# Add standard Ubuntu mirrors as fallback entries so apt can still resolve
# packages if regional mirror metadata lags briefly for specific revisions.
if [ -r /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
fi
CODENAME="${VERSION_CODENAME:-}"
if [ -z "${CODENAME}" ]; then
echo "use_aws_apt_mirror: unable to determine distro codename, skipping fallback source generation"
else
# Prefer the same mirror family the image already uses.
# This avoids keeping a hardcoded architecture map here.
if grep -Rqs "ubuntu-ports" /etc/apt/sources.list /etc/apt/sources.list.d 2>/dev/null; then
FALLBACK_MAIN="http://ports.ubuntu.com/ubuntu-ports"
FALLBACK_SECURITY="http://ports.ubuntu.com/ubuntu-ports"
else
FALLBACK_MAIN="http://archive.ubuntu.com/ubuntu"
FALLBACK_SECURITY="http://security.ubuntu.com/ubuntu"
fi
FALLBACK_FILE="/etc/apt/sources.list.d/px4-ubuntu-fallback.list"
cat <<EOF > "${FALLBACK_FILE}"
# Generated by Tools/ci/use_aws_apt_mirror.sh
deb ${FALLBACK_MAIN} ${CODENAME} main restricted universe multiverse
deb ${FALLBACK_MAIN} ${CODENAME}-updates main restricted universe multiverse
deb ${FALLBACK_MAIN} ${CODENAME}-backports main restricted universe multiverse
deb ${FALLBACK_SECURITY} ${CODENAME}-security main restricted universe multiverse
EOF
echo "use_aws_apt_mirror: wrote fallback sources to ${FALLBACK_FILE}"
fi
+3
View File
@@ -46,8 +46,10 @@ fi
#
# - osx-cross/arm: arm-gcc-bin@13 (ARM cross-compiler)
# - PX4/px4: fastdds, genromfs, kconfig-frontends (PX4-specific)
# - discoteq/discoteq: flock (required by NuttX apps archive step)
brew tap osx-cross/arm
brew tap PX4/px4
brew tap discoteq/discoteq
# Package list. This replaces the px4-dev meta-formula, which is kept
# as a deprecated no-op upstream. See PX4/homebrew-px4 for history.
@@ -63,6 +65,7 @@ PX4_BREW_PACKAGES=(
ncurses
ninja
osx-cross/arm/arm-gcc-bin@13
flock
python
python-tk
)
+6 -8
View File
@@ -52,25 +52,23 @@
pthread_mutex_t uORB::Manager::_communicator_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
uORB::Manager *uORB::Manager::_Instance = nullptr;
bool uORB::Manager::initialize()
{
if (_Instance == nullptr) {
_Instance = new uORB::Manager();
if (instance_ref() == nullptr) {
instance_ref() = new uORB::Manager();
}
#if defined(__PX4_NUTTX) && !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
px4_register_boardct_ioctl(_ORBIOCDEVBASE, orb_ioctl);
#endif
return _Instance != nullptr;
return instance_ref() != nullptr;
}
bool uORB::Manager::terminate()
{
if (_Instance != nullptr) {
delete _Instance;
_Instance = nullptr;
if (instance_ref() != nullptr) {
delete instance_ref();
instance_ref() = nullptr;
return true;
}
+4 -1
View File
@@ -482,6 +482,9 @@ public:
private: // class methods
/** Internal method to get a reference to the instance pointer */
static uORB::Manager *&instance_ref() { return _Instance; }
/**
* Common implementation for orb_advertise and orb_subscribe.
*
@@ -491,7 +494,7 @@ private: // class methods
int node_open(const struct orb_metadata *meta, bool advertiser, int *instance = nullptr);
private: // data members
static Manager *_Instance;
static inline Manager *_Instance = nullptr;
#ifdef CONFIG_ORB_COMMUNICATOR
// the communicator channel instance.
-2
View File
@@ -46,8 +46,6 @@
#include "uORBUtils.hpp"
#include "uORBManager.hpp"
uORB::Manager *uORB::Manager::_Instance = nullptr;
bool uORB::Manager::initialize()
{
if (_Instance == nullptr) {
+1 -1
View File
@@ -360,7 +360,7 @@ else()
target_link_libraries(nuttx_c INTERFACE nuttx_drivers)
target_link_libraries(nuttx_drivers INTERFACE nuttx_c)
target_link_libraries(nuttx_xx INTERFACE nuttx_c)
target_link_libraries(nuttx_fs INTERFACE nuttx_c)
target_link_libraries(nuttx_fs INTERFACE nuttx_c nuttx_mm)
target_link_libraries(px4 PRIVATE
@@ -44,6 +44,7 @@ extern int serdis_main(int c, char **argv);
__END_DECLS
#include <px4_platform_common/shutdown.h>
#include <px4_platform_common/posix.h>
ModuleBase::Descriptor CdcAcmAutostart::desc{task_spawn, custom_command, print_usage};
+5 -3
View File
@@ -86,9 +86,11 @@ public:
}
private:
static constexpr uint8_t BITS_PER_ELEMENT = 8;
static constexpr size_t ARRAY_SIZE = (N % BITS_PER_ELEMENT == 0) ? N / BITS_PER_ELEMENT : N / BITS_PER_ELEMENT + 1;
static constexpr size_t ALLOCATED_BITS = ARRAY_SIZE * BITS_PER_ELEMENT;
enum : size_t {
BITS_PER_ELEMENT = 8,
ARRAY_SIZE = (N % BITS_PER_ELEMENT == 0) ? N / BITS_PER_ELEMENT : N / BITS_PER_ELEMENT + 1,
ALLOCATED_BITS = ARRAY_SIZE * BITS_PER_ELEMENT
};
size_t array_index(size_t position) const { return position / BITS_PER_ELEMENT; }
uint8_t element_mask(size_t position) const { return (1 << position % BITS_PER_ELEMENT); }
+1 -1
View File
@@ -23,7 +23,7 @@ namespace matrix
template <typename Scalar, size_t N>
struct Dual {
static constexpr size_t WIDTH = N;
enum : size_t { WIDTH = N };
Scalar value {};
Vector<Scalar, N> derivative;
+1 -1
View File
@@ -891,7 +891,7 @@ OStream &operator<<(OStream &os, const matrix::Matrix<Type, M, N> &matrix)
{
os << "\n";
// element: tab, point, 8 digits, 4 scientific notation chars; row: newline; string: \0 end
static const size_t n = 15 * N * M + M + 1;
constexpr size_t n = 15 * N * M + M + 1;
char string[n];
matrix.write_string(string, n);
os << string;
+22 -19
View File
@@ -14,24 +14,21 @@
namespace matrix
{
template<int N> struct force_constexpr_eval {
static const int value = N;
};
// Vector that only store nonzero elements,
// which indices are specified as parameter pack
template<typename Type, size_t M, size_t... Idxs>
class SparseVector
{
private:
static constexpr size_t N = sizeof...(Idxs);
static constexpr size_t _indices[N] {Idxs...};
enum : size_t { N = sizeof...(Idxs) };
static constexpr bool duplicateIndices()
{
constexpr size_t indicies[] {Idxs...};
for (size_t i = 0; i < N; i++) {
for (size_t j = 0; j < i; j++) {
if (_indices[i] == _indices[j]) {
if (indicies[i] == indicies[j]) {
return true;
}
}
@@ -39,19 +36,27 @@ private:
return false;
}
static constexpr size_t findMaxIndex()
{
constexpr size_t indicies[] {Idxs...};
size_t maxIndex = 0;
for (size_t i = 0; i < N; i++) {
if (maxIndex < _indices[i]) {
maxIndex = _indices[i];
if (maxIndex < indicies[i]) {
maxIndex = indicies[i];
}
}
return maxIndex;
}
static constexpr size_t indexAt(size_t i)
{
constexpr size_t indicies[] {Idxs...};
return indicies[i];
}
static_assert(!duplicateIndices(), "Duplicate indices");
static_assert(N < M, "More entries than elements, use a dense vector");
static_assert(N > 0, "A sparse vector needs at least one element");
@@ -61,10 +66,11 @@ private:
static constexpr int findCompressedIndex(size_t index)
{
constexpr size_t indicies[] {Idxs...};
int compressedIndex = -1;
for (size_t i = 0; i < N; i++) {
if (index == _indices[i]) {
if (index == indicies[i]) {
compressedIndex = static_cast<int>(i);
}
}
@@ -80,7 +86,7 @@ public:
constexpr size_t index(size_t i) const
{
return SparseVector::_indices[i];
return indexAt(i);
}
SparseVector() = default;
@@ -88,7 +94,7 @@ public:
SparseVector(const matrix::Vector<Type, M> &data)
{
for (size_t i = 0; i < N; i++) {
_data[i] = data(_indices[i]);
_data[i] = data(indexAt(i));
}
}
@@ -100,7 +106,7 @@ public:
template <size_t i>
inline Type at() const
{
static constexpr int compressed_index = force_constexpr_eval<findCompressedIndex(i)>::value;
constexpr int compressed_index = findCompressedIndex(i);
static_assert(compressed_index >= 0, "cannot access unpopulated indices");
return _data[compressed_index];
}
@@ -108,7 +114,7 @@ public:
template <size_t i>
inline Type &at()
{
static constexpr int compressed_index = force_constexpr_eval<findCompressedIndex(i)>::value;
constexpr int compressed_index = findCompressedIndex(i);
static_assert(compressed_index >= 0, "cannot access unpopulated indices");
return _data[compressed_index];
}
@@ -137,7 +143,7 @@ public:
Type accum(0);
for (size_t i = 0; i < N; i++) {
accum += _data[i] * other(_indices[i]);
accum += _data[i] * other(indexAt(i));
}
return accum;
@@ -148,7 +154,7 @@ public:
matrix::Vector<Type, M> vec = other;
for (size_t i = 0; i < N; i++) {
vec(_indices[i]) += _data[i];
vec(indexAt(i)) += _data[i];
}
return vec;
@@ -218,9 +224,6 @@ Type quadraticForm(const matrix::SquareMatrix<Type, M> &A, const matrix::SparseV
return res;
}
template<typename Type, size_t M, size_t... Idxs>
constexpr size_t SparseVector<Type, M, Idxs...>::_indices[SparseVector<Type, M, Idxs...>::N];
template<size_t M, size_t ... Idxs>
using SparseVectorf = SparseVector<float, M, Idxs...>;
+1 -1
View File
@@ -178,7 +178,7 @@ OStream &operator<<(OStream &os, const matrix::Vector<Type, M> &vector)
{
os << "\n";
// element: tab, point, 8 digits, 4 scientific notation chars; row: newline; string: \0 end
static const size_t n = 15 * M * 1 + 1 + 1;
constexpr size_t n = 15 * M * 1 + 1 + 1;
char string[n];
vector.transpose().write_string(string, n);
os << string;
+1
View File
@@ -38,6 +38,7 @@
#include <px4_platform_common/px4_config.h>
#include <px4_arch/micro_hal.h>
#include <systemlib/px4_macros.h>
#include <nuttx/irq.h>
/****************************************************************************
* Pre-processor Definitions