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

fix(Build): Allow Cordio to Build with Custom BSPs #1209

Merged
merged 5 commits into from
Oct 4, 2024

Conversation

EricB-ADI
Copy link
Contributor

Pull Request Template

Description

Cordio depends on led.h and led.c, which required board.h and board.c. If LIB_BOARD=0 cordio fails to build. This is an issue with custom boards not in the MSDK. cordio.mk now uses BOARD_DIR directly to allow this to override the LIB_BOARD switch.

@github-actions github-actions bot added the BLE Related to Bluetooth label Oct 3, 2024
@@ -92,11 +92,11 @@ ${CORDIO_BUILD_DIR}/${CORDIO_LIB}: ${CORDIO_C_FILES} ${PROJECTMK}
$(MAKE) -f ${CORDIO_DIR}/platform/targets/maxim/build/libCordio.mk lib MAXIM_PATH=${MAXIM_PATH} PROJECT=${CORDIO_LIB} \
CORDIO_LIB_VAR=${CORDIO_LIB_VAR} BUILD_DIR=${CORDIO_BUILD_DIR} MFLOAT_ABI=$(MFLOAT_ABI) \
DUAL_CORE=$(DUAL_CORE) RISCV_CORE=$(RISCV_CORE) TRACE=${TRACE} DEBUG=${DEBUG} RTOS=${RTOS} \
CFG_DEV="${CFG_DEV}" PROJECTMK=${PROJECTMK} BOARD=${BOARD} MXC_OPTIMIZE_CFLAGS=${CORDIO_OPTIMIZE_CFLAGS} \
CFG_DEV="${CFG_DEV}" PROJECTMK=${PROJECTMK} BOARD=${BOARD} BSP_SEARCH_DIR=$(BSP_SEARCH_DIR) BOARD_DIR=$(BOARD_DIR) MXC_OPTIMIZE_CFLAGS=${CORDIO_OPTIMIZE_CFLAGS} \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EricB-ADI @kevin-gillespie LIB_BOARD=0 isn't intended as the mechanism for implementing custom BSPs. It disables the BSP abstraction entirely (which Cordio is dependent on for the HAL).

Custom BSPs should use the existing options to provide a "board.h", so I think adding BSP_SEARCH_DIR to CFG_DEV here would be sufficient to get them working.

Supporting LIB_BOARD=0 would mean supporting a build without the concept of a BSP which implies no "board.h". We could check for the LIB_BOARD definition to wrap the inclusion. It gets added here:

PROJ_CFLAGS += -DLIB_BOARD

diff --git a/Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_uart.c b/Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_uart.c
index 16dd4dd44a..635dfb725d 100644
--- a/Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_uart.c
+++ b/Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_uart.c
@@ -35,7 +35,9 @@
 #include "pal_led.h"
 #include "pal_sys.h"
 
+#ifdef LIB_BOARD
 #include "board.h"
+#endif
 
 #include "uart.h"
 #include "sema.h"
diff --git a/Libraries/MiscDrivers/LED/led.h b/Libraries/MiscDrivers/LED/led.h
index 6ea14a3362..a3353123c9 100644
--- a/Libraries/MiscDrivers/LED/led.h
+++ b/Libraries/MiscDrivers/LED/led.h
@@ -27,7 +27,9 @@
 #define LIBRARIES_MISCDRIVERS_LED_LED_H_
 
 #include "mxc_assert.h"
+#ifdef LIB_BOARD
 #include "board.h"
+#endif
 #include "gpio.h"
 
 #ifdef __cplusplus

... but the build error moves to missing definitions on TERMINAL_UART, etc.

"board.h" seems the only mechanism for users to pass these in to the HAL, so this may not even be useful.

@EricB-ADI EricB-ADI changed the title fix(build): Allow Cordio to build without LIB_BOARD=1 fix(Build): Allow Cordio to build without LIB_BOARD=1 Oct 4, 2024
@EricB-ADI
Copy link
Contributor Author

@Jake-Carter I updated it and it seems to be working. You are good to review

Copy link
Contributor

@Jake-Carter Jake-Carter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @EricB-ADI

I caught a couple edge cases. It seems like the most consistent way to do this is to export BOARD and BSP_SEARCH_DIR. exports in general should be used sparingly but in this case I don't see a need to build a library with a different BSP than the app code.

Then, the recursive build call needs to include board.mk in its internals. I re-leveraged libs.mk again for this. In my testing this gets the Cordio lib and app code builds synced up and using the same custom BSP. It's also more consistent with the direction I'd like to move for libraries in general, like for what we did with TinyUSB (#1101).

@Jake-Carter Jake-Carter changed the title fix(Build): Allow Cordio to build without LIB_BOARD=1 fix(Build): Allow Cordio to Build with Custom BSPs Oct 4, 2024
@EricB-ADI EricB-ADI merged commit ffa42a7 into main Oct 4, 2024
12 checks passed
sihyung-maxim pushed a commit to analogdevicesinc/hal_adi that referenced this pull request Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLE Related to Bluetooth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants