srsRAN_4G icon indicating copy to clipboard operation
srsRAN_4G copied to clipboard

Build failure on armv7 with bladeRF

Open fabianfreyer opened this issue 2 years ago • 2 comments

Issue Description

Building Raspberry Pi OS (armv7) fails.

Setup Details

Using raspios_lite_armhf-2023-05-03 (bullseye)

Expected Behavior

The build succeeds.

Actual Behaviour

The build fails with the following error message:

/home/pi/srsRAN_4G/lib/src/phy/rf/rf_blade_imp.c: In function ‘rf_blade_set_rx_freq’:
/home/pi/srsRAN_4G/lib/src/phy/rf/rf_blade_imp.c:375:33: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘bladerf_frequency’ {aka ‘long long unsigned int’} [-Werror=format=]                                                                         375 |   printf("set RX frequency to %lu\n", f_int);
      |                               ~~^     ~~~~~
      |                                 |     |
      |                                 |     bladerf_frequency {aka long long unsigned int}
      |                                 long unsigned int
      |                               %llu
/home/pi/srsRAN_4G/lib/src/phy/rf/rf_blade_imp.c: In function ‘rf_blade_set_tx_freq’:
/home/pi/srsRAN_4G/lib/src/phy/rf/rf_blade_imp.c:392:33: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘bladerf_frequency’ {aka ‘long long unsigned int’} [-Werror=format=]
  392 |   printf("set TX frequency to %lu\n", f_int);
      |                               ~~^     ~~~~~                                                                                                                                                                                                                                                 |                                 |     |                                                                                                                                                                                                                                                     |                                 |     bladerf_frequency {aka long long unsigned int}
      |                                 long unsigned int                                                                                                                                                                                                                                           |                               %llu

Steps to reproduce the problem

Clone current main branch on a Raspberry Pi or using qemu-arm with 32-bit Raspberry Pi OS, and run mkdir build; cd build; cmake ..; make, after building and installing bladeRF.

Additional Information

Build succeeds with cmake -DCMAKE_C_FLAGS="-Wno-error=format" ..

fabianfreyer avatar Jun 01 '23 00:06 fabianfreyer

The 32-bit long unsigned int vs 64-bit long long unsigned int type error is a hint...you really need to be running on a 64-bit RPi4 and OS as per the link in this doc

cloudwiser avatar Jun 01 '23 16:06 cloudwiser

I'm aware that document shows the setup for aarch64, and that the error is due to bladerf_frequency being a 64-bit number while the format string's %lu format specifier indicates a number that is at least 32 bits (per standard), but usually 64 bit large on 64-bit systems. In fact, the code guide notes that because of this reason, the long type should be avoided:

Avoid using the long type since it can be either 32 or 64-bits depending on the architecture. See the standard definition for more information.

This suggests that building for 32-bit targets is supported. OTOH, I have not seen any claims that running srsRAN_4G on armv7 is not supported -- and I'm not sure whether you're claiming that. If that's the case, it would be helpful for this fact to be documented, and for corresponding checks to be added to the CMakeLists.

fabianfreyer avatar Jun 07 '23 00:06 fabianfreyer