Hi Harry,
As Rohit pointed out, SystemInit sets up the clock. As you can see in the mbed SDK, the selected clock source depends on the target passed as macro parameters:
mbed_sdk/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/system_nrf51.c
#if defined(TARGET_DELTA_DFCM_NNN40) || defined(TARGET_HRM1017)
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
#else
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
#endif
Hopefully, your platform is one of those two. Otherwise, it should be added to the SDK.
In order to build the current DFU bootloader for HRM1017, I needed to add the -DTARGET_HRM1017
flag to add_definitions in CMakeLists.txt
The following change was also needed in main.c:
diff --git a/main.c b/main.c
index 5c20e46..5e10d17 100644
--- a/main.c
+++ b/main.c
@@ -155,7 +155,12 @@ static void ble_stack_init(bool init_softdevice)
err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START);
APP_ERROR_CHECK(err_code);
+#if defined(TARGET_DELTA_DFCM_NNN40) || defined(TARGET_HRM1017)
+ /* Those targets don't use an external source */
+ SOFTDEVICE_HANDLER_APPSH_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, true);
+#else
SOFTDEVICE_HANDLER_APPSH_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, true);
+#endif
// Enable BLE stack
ble_enable_params_t ble_enable_params;
I will soon send a pull request to add this to the repo. In the meantime, I can provide you with an image that should work on an nRF51822 platform without external oscillator: s130_defaultapp_boot_hrm1017.hex
Cheers
Hi, Jean-Philippe.
I've had a problem with FOTA with nRF51-DK, own board which includes nRF51822 and own board which includes nRF51822
without external oscillator.
I succeeded FOTA with nRF51-DK with rohit's boot loader hex file,
and I succeeded FOTA with own board which includes nRF51822 chip with redbearlab's boot loader hex file.
but I failed with last board which includes nRF51822 without external oscillator.
To FOTA, I think I need 2 hex file. first one is boot load hex file like you upload. Another thing is the hex file which I want to upload
through FOTA and second hex file should be complied "xxx FOTA" platform, such as "nRF51822 FOTA", "nRF51-DK FOTA".
I got "dfuTarg" on nRF master control panel android app by hex file you upload, but I can't upload through FOTA beacause there is
no "HRM 1017 FOAT" platform. How can I do DFU without "HRM 1017 FOTA" platform?
Thanks Rohit, very much appreciated