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

Build failure on armv7 with bladeRF #1179

Open
fabianfreyer opened this issue Jun 1, 2023 · 2 comments · May be fixed by #1182
Open

Build failure on armv7 with bladeRF #1179

fabianfreyer opened this issue Jun 1, 2023 · 2 comments · May be fixed by #1182

Comments

@fabianfreyer
Copy link

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" ..

@cloudwiser
Copy link
Contributor

cloudwiser commented Jun 1, 2023

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

@fabianfreyer
Copy link
Author

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 added a commit to fabianfreyer/srsRAN_4G that referenced this issue Jun 7, 2023
bladerf_frequency is a 64-bit number. Change format strings to use %llu (long long unsigned int) as per the [code guide].

[code guide]: https://docs.srsran.com/projects/project/en/latest/dev_guide/source/code_guide/source/5_recommendations.html#fixed-width-integer-types

Fixes srsran#1179.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants