Skip to content

NRF5x: redirect NRF logging to mbed stdout #6889

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "softdevice",
"config": {
"nrf_enable_logging": {
"help": "When '1' NRF_LOG_* outputs will be sent to stdout.",
"value": "0",
"macro_name": "NRF_LOG_ENABLED"
}
},
"macros": [
"SOFTDEVICE_PRESENT=1",
"S130"
],
"target_overrides": {
"*": {
"target.features_add": ["BLE"],
"target.bootloader_img": "hex/s130_nrf51_2.0.0_softdevice.hex"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ uint32_t log_uart_init()
UART_TX_BUF_SIZE,
uart_error_cb,
#ifdef NRF51
APP_IRQ_PRIORITY_LOW
APP_IRQ_PRIORITY_LOW,
#elif defined(NRF52)
APP_IRQ_PRIORITY_LOWEST
APP_IRQ_PRIORITY_LOWEST,
#endif
err_code);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@
#include "nrf_ble.h"
#endif


#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
#define SD_HANDLER_LOG(...) NRF_LOG_PRINTF(__VA_ARGS__)
#else
#define SD_HANDLER_LOG(...)
#endif

#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
#define SD_HANDLER_LOG_INIT() NRF_LOG_INIT()
Expand Down Expand Up @@ -410,7 +405,8 @@ uint32_t softdevice_enable_get_default_config(uint8_t central_links_count,
}


#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
#if (defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1) || \
(defined(NRF_LOG_USES_UART) && NRF_LOG_USES_UART == 1)
static inline uint32_t ram_total_size_get(void)
{
#ifdef NRF51
Expand Down Expand Up @@ -453,15 +449,13 @@ uint32_t sd_check_ram_start(uint32_t sd_req_ram_start)
#endif//__CC_ARM
if (ram_start != sd_req_ram_start)
{
#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
uint32_t app_ram_size= ram_end_address_get();
SD_HANDLER_LOG("RAM START ADDR 0x%x should be adjusted to 0x%x\r\n",
ram_start,
sd_req_ram_start);
app_ram_size -= sd_req_ram_start;
SD_HANDLER_LOG("RAM SIZE should be adjusted to 0x%x \r\n",
app_ram_size);
#endif //NRF_LOG_USES_RTT
return NRF_SUCCESS;
}
#endif//defined(S130) || defined(S132) || defined(S332)
Expand Down Expand Up @@ -490,22 +484,18 @@ uint32_t softdevice_enable(ble_enable_params_t * p_ble_enable_params)
app_ram_base);
err_code = sd_ble_enable(p_ble_enable_params, &app_ram_base);

#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
// MODIFIED the rest of this function to match logging implementation in SDK13
if (app_ram_base != ram_start)
{
uint32_t app_ram_size= ram_end_address_get();
SD_HANDLER_LOG("sd_ble_enable: app_ram_base should be adjusted to 0x%x\r\n",
app_ram_base);
app_ram_size -= app_ram_base;
SD_HANDLER_LOG("ram size should be adjusted to 0x%x \r\n",
app_ram_size);
SD_HANDLER_LOG("sd_ble_enable: RAM start should be adjusted to 0x%x\r\n",
app_ram_base);
SD_HANDLER_LOG("RAM size should be adjusted to 0x%x \r\n",
ram_end_address_get() - app_ram_base);
}
else if (err_code != NRF_SUCCESS)
{
SD_HANDLER_LOG("sd_ble_enable: error 0x%x\r\n", err_code);
while(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Newer versions of the SDK don't hang here, but I guess it would also be more useful to redirect this to mbed_error()... though that would being in even more changes and dependencies so perhaps leaving it in place would be ok.

}
#endif // NRF_LOG_USES_RTT
return err_code;
#else
return NRF_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"name": "softdevice",
"config": {
"nrf_enable_logging": {
"help": "When '1' NRF_LOG_* outputs will be sent to stdout.",
"value": "0",
"macro_name": "NRF_LOG_ENABLED"
}
},
"macros": [
"SOFTDEVICE_PRESENT=1",
"S132",
Expand Down Expand Up @@ -34,7 +41,8 @@
"NRF_SDH_BLE_STACK_OBSERVER_PRIO=0",
"NRF_SDH_SOC_STACK_OBSERVER_PRIO=0",
"FDS_BACKEND=2",
"SWI_DISABLE1=1"
"SWI_DISABLE1=1",
"NRF_STRERROR_ENABLED=1"
],
"target_overrides": {
"*": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"name": "softdevice",
"config": {
"nrf_enable_logging": {
"help": "When '1' NRF_LOG_* outputs will be sent to stdout.",
"value": "0",
"macro_name": "NRF_LOG_ENABLED"
}
},
"macros": [
"SOFTDEVICE_PRESENT=1",
"S140",
Expand Down Expand Up @@ -34,7 +41,8 @@
"NRF_SDH_BLE_STACK_OBSERVER_PRIO=0",
"NRF_SDH_SOC_STACK_OBSERVER_PRIO=0",
"FDS_BACKEND=2",
"SWI_DISABLE1=1"
"SWI_DISABLE1=1",
"NRF_STRERROR_ENABLED=1"
],
"target_overrides": {
"*": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ components/libraries

Only essential folders have been copied over.

`experimental_log/nrf_log.h` has been removed and reimplemented in `TARGET_NRF5x/nrf_log.h` to
provide optional logging via mbed stdout. Only the minimum required headers have been left in
experimental_log folder.

Removed:
* block_dev/
* bootloader/
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading