I wasn't able to upload firmware to flash (and uploading to RAM was dependent on MAX_READ_WRITE_LEN value) until I made the following change to the initialization of m_tx_buf:
int8_t bhy2_spi_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr)
{
(void)intf_ptr;
uint8_t m_tx_buf[length + 1];
volatile uint32_t * p_spim_event_end = (uint32_t *) nrfx_spim_end_event_get(&m_spi);
// Initialize buffers
memset(m_tx_buf, 0xff, length + 1);
m_tx_buf[0] = reg_addr;
memcpy(m_tx_buf + 1, reg_data, length);
m_tx_buf[0] = reg_addr;
nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TX(m_tx_buf, length + 1);
int err_code = nrfx_spim_xfer(&m_spi, &xfer_desc, NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER);
APP_ERROR_CHECK(err_code);
if (err_code == NRF_SUCCESS)
{
while (*p_spim_event_end == 0)
{};
*p_spim_event_end = 0;
}
// The driver doesn't release the ss_pin
// So we need to do it ourselves here to tell the chip
// that this SPI transfer is finished.
nrf_gpio_pin_set(BSP_MEMS_CS);
return BHY2_INTF_RET_SUCCESS;
}