From a9f0b31a15b36e1fd184a318f4d0320df31de54d Mon Sep 17 00:00:00 2001 From: "Limor \"Ladyada\" Fried" Date: Wed, 19 Dec 2018 13:25:18 -0500 Subject: [PATCH 1/3] Update README.rst https://github.com/adafruit/circuitpython/issues/1410 --- ports/atmel-samd/README.rst | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ports/atmel-samd/README.rst b/ports/atmel-samd/README.rst index 1ff2a0e80b..6037c7d3b1 100644 --- a/ports/atmel-samd/README.rst +++ b/ports/atmel-samd/README.rst @@ -170,13 +170,7 @@ These commands should be executed from the root directory of the repository Build commands are run from the ``circuitpython/ports/atmel-samd`` directory. -To build for the Arduino Zero: - -.. code-block:: shell - - make - -To build for other boards you must change it by setting ``BOARD``. For example: +To build for a given board you must specify it by setting ``BOARD``. For example: .. code-block:: shell From bce6d124af6531f2d6ad6835546eaa471d0657a0 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 20 Dec 2018 21:28:36 -0500 Subject: [PATCH 2/3] Don't check for corrupt heap too early; Fix QSPI timing --- ports/nrf/supervisor/qspi_flash.c | 20 +++++++++++--------- supervisor/shared/stack.c | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index 048db06f20..4738607bff 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -40,15 +40,13 @@ bool spi_flash_command(uint8_t command) { nrf_qspi_cinstr_conf_t cinstr_cfg = { - .opcode = 0, - .length = 0, + .opcode = command, + .length = 1, .io2_level = true, .io3_level = true, .wipwait = false, .wren = false }; - cinstr_cfg.opcode = command; - cinstr_cfg.length = 1; nrfx_qspi_cinstr_xfer(&cinstr_cfg, NULL, NULL); return true; } @@ -91,8 +89,7 @@ bool spi_flash_write_data(uint32_t address, uint8_t* data, uint32_t length) { } bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t length) { - nrfx_qspi_read(data, length, address); - return true; + return nrfx_qspi_read(data, length, address) == NRFX_SUCCESS; } void spi_flash_init(void) { @@ -115,7 +112,7 @@ void spi_flash_init(void) { .dpmconfig = false }, .phy_if = { - .sck_freq = NRF_QSPI_FREQ_32MDIV16, // Start at a slow 2mhz and speed up once we know what we're talking to. + .sck_freq = NRF_QSPI_FREQ_32MDIV16, // Start at a slow 2MHz and speed up once we know what we're talking to. .sck_delay = 10, // min time CS must stay high before going low again. in unit of 62.5 ns .spi_mode = NRF_QSPI_MODE_0, .dpmen = false @@ -145,7 +142,7 @@ void spi_flash_init_device(const external_flash_device* device) { // Switch to single output line if the device doesn't support quad programs. if (!device->supports_qspi_writes) { NRF_QSPI->IFCONFIG0 &= ~QSPI_IFCONFIG0_WRITEOC_Msk; - NRF_QSPI->IFCONFIG0 |= QSPI_IFCONFIG0_WRITEOC_PP; + NRF_QSPI->IFCONFIG0 |= QSPI_IFCONFIG0_WRITEOC_PP << QSPI_IFCONFIG0_WRITEOC_Pos; } // Speed up as much as we can. @@ -153,6 +150,11 @@ void spi_flash_init_device(const external_flash_device* device) { while (32000000 / (sckfreq + 1) > device->max_clock_speed_mhz * 1000000 && sckfreq < 16) { sckfreq += 1; } + // No more than 16 MHz. At 32 MHz GD25Q16C doesn't work reliably on Feather 52840, even though + // it should work up to 104 MHz. + // sckfreq = 0 is 32 Mhz + // sckfreq = 1 is 16 MHz, etc. + sckfreq = MAX(1, sckfreq); NRF_QSPI->IFCONFIG1 &= ~QSPI_IFCONFIG1_SCKFREQ_Msk; - NRF_QSPI->IFCONFIG1 |= sckfreq << QSPI_IFCONFIG1_SCKDELAY_Pos; + NRF_QSPI->IFCONFIG1 |= sckfreq << QSPI_IFCONFIG1_SCKFREQ_Pos; } diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index 71e239c0a1..311fa31b22 100755 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -56,7 +56,7 @@ void allocate_stack(void) { } inline bool stack_ok(void) { - return *stack_alloc->ptr == STACK_CANARY_VALUE; + return stack_alloc == NULL || *stack_alloc->ptr == STACK_CANARY_VALUE; } inline void assert_heap_ok(void) { From 0dfe2dbff02dd3d8b6392f74df3717c362174e27 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 21 Dec 2018 12:30:54 -0500 Subject: [PATCH 3/3] return error status on more routines; minor simplification of freq setting --- ports/nrf/supervisor/qspi_flash.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index 4738607bff..51a9ec0329 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -60,8 +60,8 @@ bool spi_flash_read_command(uint8_t command, uint8_t* response, uint32_t length) .wipwait = false, .wren = false }; - nrfx_qspi_cinstr_xfer(&cinstr_cfg, NULL, response); - return true; + return nrfx_qspi_cinstr_xfer(&cinstr_cfg, NULL, response) == NRFX_SUCCESS; + } bool spi_flash_write_command(uint8_t command, uint8_t* data, uint32_t length) { @@ -73,8 +73,7 @@ bool spi_flash_write_command(uint8_t command, uint8_t* data, uint32_t length) { .wipwait = false, .wren = false // We do this manually. }; - nrfx_qspi_cinstr_xfer(&cinstr_cfg, data, NULL); - return true; + return nrfx_qspi_cinstr_xfer(&cinstr_cfg, data, NULL) == NRFX_SUCCESS; } bool spi_flash_sector_command(uint8_t command, uint32_t address) { @@ -146,15 +145,14 @@ void spi_flash_init_device(const external_flash_device* device) { } // Speed up as much as we can. - uint8_t sckfreq = 0; + // Start at 16 MHz and go down. + // At 32 MHz GD25Q16C doesn't work reliably on Feather 52840, even though it should work up to 104 MHz. + // sckfreq = 0 is 32 Mhz + // sckfreq = 1 is 16 MHz, etc. + uint8_t sckfreq = 1; while (32000000 / (sckfreq + 1) > device->max_clock_speed_mhz * 1000000 && sckfreq < 16) { sckfreq += 1; } - // No more than 16 MHz. At 32 MHz GD25Q16C doesn't work reliably on Feather 52840, even though - // it should work up to 104 MHz. - // sckfreq = 0 is 32 Mhz - // sckfreq = 1 is 16 MHz, etc. - sckfreq = MAX(1, sckfreq); NRF_QSPI->IFCONFIG1 &= ~QSPI_IFCONFIG1_SCKFREQ_Msk; NRF_QSPI->IFCONFIG1 |= sckfreq << QSPI_IFCONFIG1_SCKFREQ_Pos; }