Skip to content

Commit

Permalink
correct boot configurations. (#7)
Browse files Browse the repository at this point in the history
* add boot debugging-related configurations.

* correct boot pin configuration.

* correct firmware configuration parameters
  • Loading branch information
lihuanhuan authored Nov 23, 2023
1 parent f98d5fb commit be8c4aa
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 18 deletions.
8 changes: 4 additions & 4 deletions ble-firmware/components/boards/my_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ extern "C" {

#define USB_INS_PIN 7
//TWI
#define TWI_STATUS_GPIO 13
#define MASTER_TWI_INST 1 //!< TWI interface used as a master accessing EEPROM memory.
#define TWI_STATUS_GPIO 25
#define MASTER_TWI_INST 0 //!< TWI interface used as a master accessing EEPROM memory.
#define TWI_SCL_M 27 //!< Master SCL pin.
#define TWI_SDA_M 26 //!< Master SDA pin.
#define SLAVE_ADDR 0x48
Expand All @@ -113,8 +113,8 @@ extern "C" {

//end HaoBTC

#define RX_PIN_NUMBER 11
#define TX_PIN_NUMBER 12
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER UART_PIN_DISCONNECTED
#define RTS_PIN_NUMBER UART_PIN_DISCONNECTED
#define HWFC false
Expand Down
8 changes: 4 additions & 4 deletions ble-firmware/components/boards/pca10040.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ extern "C" {
#define BSP_BUTTON_2 BUTTON_3
#define BSP_BUTTON_3 BUTTON_4

#define RX_PIN_NUMBER 11
#define TX_PIN_NUMBER 12
#define CTS_PIN_NUMBER NRF_UART_PSEL_DISCONNECTED
#define RTS_PIN_NUMBER NRF_UART_PSEL_DISCONNECTED
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 5
#define HWFC false

#define SPIS_MISO_PIN 28 // SPI MISO signal.
Expand Down
6 changes: 3 additions & 3 deletions ble-firmware/components/libraries/bootloader/nrf_bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ static void loop_forever(void)
static void dfu_enter_button_init(void)
{
nrf_gpio_cfg_sense_input(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN,
NRF_GPIO_PIN_PULLUP,
GPIO_PIN_CNF_SENSE_Low);
NRF_GPIO_PIN_PULLDOWN,
NRF_GPIO_PIN_SENSE_HIGH);
}


Expand Down Expand Up @@ -361,7 +361,7 @@ static bool dfu_enter_check(void)
}

if (NRF_BL_DFU_ENTER_METHOD_BUTTON &&
(nrf_gpio_pin_read(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN) == 0))
(nrf_gpio_pin_read(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN) == 1))
{
NRF_LOG_DEBUG("DFU mode requested via button.");
button_dfu_flag = 1;
Expand Down
4 changes: 2 additions & 2 deletions ble-firmware/integration/nrfx/legacy/apply_old_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@
#undef NRFX_TWI1_ENABLED
#define NRFX_TWI1_ENABLED TWI1_ENABLED
#undef NRFX_TWIM1_ENABLED
#define NRFX_TWIM1_ENABLED 1
#define NRFX_TWIM1_ENABLED 0

#elif !defined(TWI_PRESENT) && defined(TWIM_PRESENT)

Expand All @@ -1140,7 +1140,7 @@
#define NRFX_TWIM0_ENABLED TWI0_ENABLED

#undef NRFX_TWI1_ENABLED
#define NRFX_TWI1_ENABLED 1
#define NRFX_TWI1_ENABLED 0
#undef NRFX_TWIM1_ENABLED
#define NRFX_TWIM1_ENABLED TWI1_ENABLED

Expand Down
9 changes: 9 additions & 0 deletions dfu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ SRC_FILES += \
$(SDK_ROOT)/components/libraries/fstorage/nrf_fstorage_sd.c \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_default_backends.c \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \
$(SDK_ROOT)/components/libraries/mem_manager/mem_manager.c \
$(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \
$(SDK_ROOT)/components/libraries/queue/nrf_queue.c \
Expand All @@ -88,6 +93,9 @@ SRC_FILES += \
$(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \
$(SDK_ROOT)/external/nano-pb/pb_common.c \
$(SDK_ROOT)/external/nano-pb/pb_decode.c \
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
$(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_uart.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \
Expand Down Expand Up @@ -154,6 +162,7 @@ INC_FOLDERS += \
$(SDK_ROOT)/modules/nrfx/drivers/include \
$(SDK_ROOT)/modules/nrfx/hal \
$(SDK_ROOT)/modules/nrfx/mdk \
$(SDK_ROOT)/external/segger_rtt \

# Libraries common to all targets
LIB_FILES += \
Expand Down
89 changes: 86 additions & 3 deletions dfu/sdk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,39 @@
// <h> nRF_Log

//==========================================================
// <e> NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend
//==========================================================
#ifndef NRF_LOG_BACKEND_RTT_ENABLED
#define NRF_LOG_BACKEND_RTT_ENABLED 1
#endif
// <o> NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings.
// <i> Size of the buffer is a trade-off between RAM usage and processing.
// <i> if buffer is smaller then strings will often be fragmented.
// <i> It is recommended to use size which will fit typical log and only the
// <i> longer one will be fragmented.

#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE
#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64
#endif

// <o> NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT
#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS
#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1
#endif

// <o> NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries.
// <i> If RTT fails to accept any new data after retries
// <i> module assumes that host is not active and on next
// <i> request it will perform only one write attempt.
// <i> On successful writing, module assumes that host is active
// <i> and scheme with retry is applied again.

#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT
#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3
#endif

// </e>

// <e> NRF_LOG_ENABLED - nrf_log - Logger
//==========================================================
#ifndef NRF_LOG_ENABLED
Expand Down Expand Up @@ -2225,7 +2258,7 @@
// <16384=> 16384

#ifndef NRF_LOG_BUFSIZE
#define NRF_LOG_BUFSIZE 1024
#define NRF_LOG_BUFSIZE 4096
#endif

// <q> NRF_LOG_CLI_CMDS - Enable CLI commands for the module.
Expand All @@ -2244,7 +2277,7 @@
// <4=> Debug

#ifndef NRF_LOG_DEFAULT_LEVEL
#define NRF_LOG_DEFAULT_LEVEL 3
#define NRF_LOG_DEFAULT_LEVEL 4
#endif

// <q> NRF_LOG_DEFERRED - Enable deffered logger.
Expand Down Expand Up @@ -5123,9 +5156,59 @@


#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED
#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 0
#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1
#endif

// </h>
//==========================================================

// <h> nRF_Segger_RTT

//==========================================================
// <h> segger_rtt - SEGGER RTT

//==========================================================
// <o> SEGGER_RTT_CONFIG_BUFFER_SIZE_UP - Size of upstream buffer.
// <i> Note that either @ref NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE
// <i> or this value is actually used. It depends on which one is bigger.

#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_UP
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 4096
#endif

// <o> SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers.
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS
#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2
#endif

// <o> SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer.
#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16
#endif

// <o> SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers.
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS
#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2
#endif

// <o> SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full.


// <i> The following modes are supported:
// <i> - SKIP - Do not block, output nothing.
// <i> - TRIM - Do not block, output as much as fits.
// <i> - BLOCK - Wait until there is space in the buffer.
// <0=> SKIP
// <1=> TRIM
// <2=> BLOCK_IF_FIFO_FULL

#ifndef SEGGER_RTT_CONFIG_DEFAULT_MODE
#define SEGGER_RTT_CONFIG_DEFAULT_MODE 0
#endif

// </h>
//==========================================================

// </h>
//==========================================================

Expand Down
4 changes: 2 additions & 2 deletions make_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ unset BT_SIG_PK
##### FACTORY #####

# gen hex
$PATH_UTILS/nrfutil settings generate --family NRF52 --application $PATH_APP --application-version 3 --bootloader-version 2 --bl-settings-version 2 $PATH_BL_CONFIG
$PATH_UTILS/nrfutil settings generate --family NRF52 --application $PATH_APP --application-version 3 --bootloader-version 2 --bl-settings-version 2 --app-boot-validation VALIDATE_ECDSA_P256_SHA256 --key-file $PATH_KEY $PATH_BL_CONFIG
$PATH_UTILS/mergehex --merge $PATH_BOOTLOADER $PATH_BL_CONFIG $PATH_SD $PATH_APP --output $PATH_OUTPUT_FACTORY_HEX
rm $PATH_BL_CONFIG

Expand All @@ -39,6 +39,6 @@ rm $PATH_OUTPUT_FACTORY_BIN.tmp
##### OTA #####

# sign app
$PATH_UTILS/nrfutil pkg generate --application $PATH_APP --application-version 3 --hw-version 52 --sd-req 0xCB --key-file $PATH_KEY $PATH_OUTPUT_ZIP
$PATH_UTILS/nrfutil pkg generate --application $PATH_APP --application-version 3 --hw-version 52 --sd-req 0xCB --app-boot-validation VALIDATE_ECDSA_P256_SHA256 --key-file $PATH_KEY $PATH_OUTPUT_ZIP
rm $PATH_KEY
$PATH_UTILS/ota_to_onekey_bin.py $PATH_OUTPUT_ZIP $PATH_OUTPUT_OTA_BIN

0 comments on commit be8c4aa

Please sign in to comment.