diff options
-rw-r--r-- | Makefile | 68 | ||||
-rw-r--r-- | dfu_gcc_nrf51.ld | 2 | ||||
-rw-r--r-- | main.c | 50 | ||||
m--------- | sdk-9.0.0 | 0 | ||||
-rw-r--r-- | sdk-config/sdk/libraries/bootloader_dfu/dfu_transport_ble.c | 5 |
5 files changed, 98 insertions, 27 deletions
@@ -11,7 +11,8 @@ DEFINES += -DS130 DEFINES += -DBLE_STACK_SUPPORT_REQD DEFINES += -DBSP_DEFINES_ONLY -CFLAGS=-Os -g +OPT=-Os -g +CFLAGS= LDFLAGS= ASFLAGS= INCLUDES= @@ -22,35 +23,42 @@ BDADDR=FD:F9:62:4A:8A:C8 SDKCSRCS= \ - libraries/util/app_error.c \ + ble/common/ble_advdata.c \ + ble/common/ble_conn_params.c \ + ble/common/ble_srv_common.c \ + drivers_nrf/common/nrf_drv_common.c \ + drivers_nrf/gpiote/nrf_drv_gpiote.c \ + drivers_nrf/hal/nrf_delay.c \ + drivers_nrf/pstorage/pstorage_raw.c \ + drivers_nrf/uart/app_uart.c \ + libraries/bootloader_dfu/dfu_init_template.c \ + libraries/crc16/crc16.c \ + libraries/hci/hci_mem_pool.c \ libraries/scheduler/app_scheduler.c \ libraries/timer/app_timer.c \ libraries/timer/app_timer_appsh.c \ - libraries/bootloader_dfu/bootloader.c \ - libraries/bootloader_dfu/bootloader_settings.c \ - libraries/bootloader_dfu/bootloader_util.c \ - libraries/bootloader_dfu/dfu_single_bank.c \ - libraries/crc16/crc16.c \ - libraries/bootloader_dfu/dfu_init_template.c \ - libraries/hci/hci_mem_pool.c \ + libraries/util/app_error.c \ libraries/util/nrf_assert.c \ - drivers_nrf/hal/nrf_delay.c \ - drivers_nrf/pstorage/pstorage_raw.c \ - ble/common/ble_advdata.c \ - ble/common/ble_conn_params.c \ - ble/ble_services/ble_dfu/ble_dfu.c \ - ble/common/ble_srv_common.c \ - toolchain/system_nrf51.c \ softdevice/common/softdevice_handler/softdevice_handler.c \ - softdevice/common/softdevice_handler/softdevice_handler_appsh.c \ + softdevice/common/softdevice_handler/softdevice_handler_appsh.c \ + libraries/bootloader_dfu/bootloader_util.c \ + toolchain/system_nrf51.c SDKSSRCS = toolchain/gcc/gcc_startup_nrf51.s +FOO= \ + libraries/bootloader_dfu/dfu_single_bank.c \ + libraries/bootloader_dfu/bootloader.c \ + libraries/bootloader_dfu/bootloader_settings.c \ + ble/ble_services/ble_dfu/ble_dfu.c \ + libraries/bootloader_dfu/dfu_transport_ble.c + CSRCS = \ dfu_ble_svc.c \ - main.c \ - sdk-config/sdk/libraries/bootloader_dfu/dfu_transport_ble.c \ + main.c + +# sdk-config/sdk/libraries/bootloader_dfu/dfu_transport_ble.c # sdk-config/sdk/libraries/bootloader_dfu/dfu_single_bank.c \ # sdk-config/sdk/libraries/bootloader_dfu/dfu_transport_ble.c \ @@ -89,7 +97,7 @@ NRFDFU := nrfdfu CFLAGS += -mcpu=cortex-m0 CFLAGS += -mthumb -mabi=aapcs --std=gnu99 -CFLAGS += -Wall -Werror -Os +CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=soft # keep every function in separate section. This will allow linker to dump unused functions CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing @@ -110,13 +118,16 @@ ASFLAGS += -x assembler-with-cpp CPPFLAGS=$(DEFINES) $(INCLUDES) +FOOOBJ=${FOO:%.c=${SDK}/sdk/%.o} +FOOS=${FOO:%.c=${SDK}/sdk/%.s} +FOOSS=${FOO:%.c=${SDK}/sdk/%.ss} -OBJS=${CSRCS:%.c=%.o} ${SDKCSRCS:%.c=${SDK}/sdk/%.o} ${SDKSSRCS:%.s=${SDK}/sdk/%.o} +OBJS=${CSRCS:%.c=%.o} ${SDKCSRCS:%.c=${SDK}/sdk/%.o} ${SDKSSRCS:%.s=${SDK}/sdk/%.o} ${FOOOBJ} -default: ${PROG}.bin ${PROG}.hex +default: ${PROG}.bin ${PROG}.hex ${FOOSS} clean: - /bin/rm -f ${OBJS} ${PROG} ${PROG}.bin ${PROG}.hex + /bin/rm -f ${OBJS} ${PROG} ${PROG}.bin ${PROG}.hex ${FOOS} ${FOOSS} ${PROG}:${OBJS} $(CC) $(LDFLAGS) $(CFLAGS) $(OBJS) $(LIBS) -o $@ @@ -131,8 +142,17 @@ ${PROG}:${OBJS} twongle.o:twongle.c $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< +${FOOOBJ}: %.o:%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -g -c -Wa,-ahl=${@:%.o=%.s} -o $@ $< + +%.ss:%.o + ${OBJDUMP} -d -S $< > $@ || /bin/rm -f $@ + +#${FOOS}: %.s:%.c +# $(CC) $(CPPFLAGS) $(CFLAGS) -g -S -o $@ $< + %.o:%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) $(OPT) -c -o $@ $< %.o:%.s $(CC) $(CPPFLAGS) $(ASFLAGS) -c -o $@ $< diff --git a/dfu_gcc_nrf51.ld b/dfu_gcc_nrf51.ld index cc067dd..7744022 100644 --- a/dfu_gcc_nrf51.ld +++ b/dfu_gcc_nrf51.ld @@ -11,7 +11,7 @@ MEMORY * those values do not match. The check is performed in main.c, see
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
*/
- FLASH (rx) : ORIGIN = 0x3C000, LENGTH = 0x3C00
+ FLASH (rx) : ORIGIN = 0x38000, LENGTH = 0x7C00
/** RAM Region for bootloader. This setting is suitable when used with s110, s120, s130, s310. */
RAM (rwx) : ORIGIN = 0x20002C00, LENGTH = 0x5380
@@ -38,6 +38,7 @@ #include <sdk/softdevice/s130/headers/nrf_soc.h>
#include <sdk/libraries/util/app_error.h>
#include <sdk/drivers_nrf/hal/nrf_gpio.h>
+#include <sdk/drivers_nrf/uart/app_uart.h>
#include <sdk/device/nrf51_bitfields.h>
#include <sdk/softdevice/s130/headers/ble.h>
#include <sdk/device/nrf51.h>
@@ -71,6 +72,8 @@ #define SCHED_QUEUE_SIZE 20 /**< Maximum number of events in the scheduler queue. */
+uint16_t m_uart_id; /** UART id returned from the UART module when calling app_uart_init, this id is kept, as it must be provided to the UART module when calling app_uart_close. */
+
/**@brief Callback function for asserts in the SoftDevice.
*
@@ -180,6 +183,49 @@ static void scheduler_init(void) }
+static void uart_eventhandler(app_uart_evt_t * uart_event)
+{
+}
+
+void blart(char c)
+{
+if (c=='\n')
+ while (app_uart_put((uint8_t) '\r')==NRF_ERROR_NO_MEM);
+while (app_uart_put((uint8_t) c)==NRF_ERROR_NO_MEM);
+}
+
+void blarts(char *c)
+{
+while (*c)
+blart(*(c++));
+}
+
+
+static uint32_t uart_init(void)
+{
+ uint32_t err_code;
+
+ app_uart_comm_params_t comm_params =
+ {
+ RX_PIN_NUMBER,
+ TX_PIN_NUMBER,
+ RTS_PIN_NUMBER,
+ CTS_PIN_NUMBER,
+ APP_UART_FLOW_CONTROL_DISABLED,
+ false,
+ UART_BAUDRATE_BAUDRATE_Baud115200
+ };
+
+ err_code = app_uart_init(&comm_params,
+ NULL,
+ uart_eventhandler,
+ APP_IRQ_PRIORITY_LOW,
+ &m_uart_id);
+ return err_code;
+}
+
+
+
/**@brief Function for bootloader main entry.
*/
int main(void)
@@ -194,6 +240,10 @@ int main(void) }
leds_init();
+ uart_init();
+
+ blarts("Hello world\n");
+
// This check ensures that the defined fields in the bootloader corresponds with actual
// setting in the nRF51 chip.
diff --git a/sdk-9.0.0 b/sdk-9.0.0 -Subproject d96e8db9d9a551fb861ca53c3a3ada99dd19c57 +Subproject 187958b88d1ecdc2715e210a04a04c4648c0bcc diff --git a/sdk-config/sdk/libraries/bootloader_dfu/dfu_transport_ble.c b/sdk-config/sdk/libraries/bootloader_dfu/dfu_transport_ble.c index f17e936..9ede19d 100644 --- a/sdk-config/sdk/libraries/bootloader_dfu/dfu_transport_ble.c +++ b/sdk-config/sdk/libraries/bootloader_dfu/dfu_transport_ble.c @@ -575,18 +575,19 @@ static void on_dfu_evt(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt) case BLE_DFU_VALIDATE: err_code = dfu_image_validate(); + ble_dfu_response_send(p_dfu, 0x55, err_code+0x80); + // Translate the err_code returned by the above function to DFU Response Value. resp_val = nrf_err_code_translate(err_code, BLE_DFU_VALIDATE_PROCEDURE); err_code = ble_dfu_response_send(p_dfu, BLE_DFU_VALIDATE_PROCEDURE, resp_val); APP_ERROR_CHECK(err_code); + break; case BLE_DFU_ACTIVATE_N_RESET: -#if 0 err_code = dfu_transport_close(); APP_ERROR_CHECK(err_code); -#endif // With the S110 Flash API it is safe to initiate the activate before connection is // fully closed. |