This is an automated email from the ASF dual-hosted git repository. utzig pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 91b54ee661d52bac09eb66bbb58ff08fb440276a Author: Casper Meijn <cas...@meijn.net> AuthorDate: Sun Aug 2 16:17:40 2020 +0200 hw/bsp/pinetime: Use spi flash for the second image This makes it possible to double the size of the image. To be compatible with other community firmwares the bootloader size is increased. This causes the reboot log to shrink. An extra SPI flash area is assigned for bootloader assets (for example a boot logo). The image could be increased by another 12kB, but I want to wait for other firmwares to do that as well. --- hw/bsp/pinetime/boot-pinetime.ld | 2 +- hw/bsp/pinetime/bsp.yml | 29 ++++++++++++++++++----------- hw/bsp/pinetime/pinetime.ld | 2 +- hw/bsp/pinetime/pkg.yml | 1 + hw/bsp/pinetime/src/hal_bsp.c | 21 ++++++++++++++------- hw/bsp/pinetime/syscfg.yml | 26 ++++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 20 deletions(-) diff --git a/hw/bsp/pinetime/boot-pinetime.ld b/hw/bsp/pinetime/boot-pinetime.ld index d1f1b99..85cd035 100644 --- a/hw/bsp/pinetime/boot-pinetime.ld +++ b/hw/bsp/pinetime/boot-pinetime.ld @@ -17,7 +17,7 @@ */ MEMORY { - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x4000 + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x6000 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 } diff --git a/hw/bsp/pinetime/bsp.yml b/hw/bsp/pinetime/bsp.yml index c89953d..ed9ccee 100644 --- a/hw/bsp/pinetime/bsp.yml +++ b/hw/bsp/pinetime/bsp.yml @@ -29,34 +29,41 @@ bsp.part2linkerscript: "hw/bsp/pinetime/split-pinetime.ld" bsp.downloadscript: "hw/bsp/pinetime/pinetime_download.sh" bsp.debugscript: "hw/bsp/pinetime/pinetime_debug.sh" +# This flash layout is compatible with other community firmwares. It is based on: https://lupyuen.github.io/pinetime-rust-mynewt/articles/mcuboot +#TODO: The image size could be increased by 12kB. This space is already reserved, but not yet used. This is to be compatible with other firmwares that use the image size of 464kB. bsp.flash_map: areas: # System areas. FLASH_AREA_BOOTLOADER: device: 0 offset: 0x00000000 - size: 16kB + size: 24kB FLASH_AREA_IMAGE_0: device: 0 offset: 0x00008000 - size: 232kB + size: 464kB FLASH_AREA_IMAGE_1: - device: 0 - offset: 0x00042000 - size: 232kB + device: 1 + offset: 0x00040000 + size: 464kB FLASH_AREA_IMAGE_SCRATCH: device: 0 - offset: 0x0007c000 + offset: 0x0007f000 size: 4kB # User areas. FLASH_AREA_REBOOT_LOG: user_id: 0 device: 0 - offset: 0x00004000 - size: 16kB + offset: 0x00006000 + size: 8kB FLASH_AREA_NFFS: user_id: 1 - device: 0 - offset: 0x0007d000 - size: 12kB + device: 1 + offset: 0x000b7000 + size: 3364kB + FLASH_AREA_BOOTLOADER_ASSETS: + user_id: 2 + device: 1 + offset: 0x00000000 + size: 256kB diff --git a/hw/bsp/pinetime/pinetime.ld b/hw/bsp/pinetime/pinetime.ld index 53baaed..b82bfcb 100644 --- a/hw/bsp/pinetime/pinetime.ld +++ b/hw/bsp/pinetime/pinetime.ld @@ -19,7 +19,7 @@ MEMORY { - FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 0x3a000 + FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 0x74000 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 } diff --git a/hw/bsp/pinetime/pkg.yml b/hw/bsp/pinetime/pkg.yml index f119444..1423b61 100644 --- a/hw/bsp/pinetime/pkg.yml +++ b/hw/bsp/pinetime/pkg.yml @@ -35,6 +35,7 @@ pkg.deps: - '@apache-mynewt-core/hw/mcu/nordic/nrf52xxx' - '@apache-mynewt-core/kernel/os' - '@apache-mynewt-core/libc/baselibc' + - "@apache-mynewt-core/hw/drivers/flash/spiflash" pkg.deps.BSP_CHARGER: - '@apache-mynewt-core/hw/drivers/chg_ctrl/sgm4056' diff --git a/hw/bsp/pinetime/src/hal_bsp.c b/hw/bsp/pinetime/src/hal_bsp.c index 0ff8c68..307282d 100644 --- a/hw/bsp/pinetime/src/hal_bsp.c +++ b/hw/bsp/pinetime/src/hal_bsp.c @@ -37,6 +37,9 @@ #include "adc_nrf52/adc_nrf52.h" #include <nrf_saadc.h> #endif +#if MYNEWT_VAL(SPIFLASH) +#include <spiflash/spiflash.h> +#endif /** What memory to include in coredump. */ static const struct hal_bsp_mem_dump dump_cfg[] = { @@ -53,6 +56,15 @@ hal_bsp_core_dump(int *area_cnt) return dump_cfg; } +static const struct hal_flash *flash_devs[] = { + /* MCU internal flash. */ + [0] = &nrf52k_flash_dev, +#if MYNEWT_VAL(SPIFLASH) + /* External SPI Flash. */ + [1] = &spiflash_dev.hal, +#endif +}; + /** * Retrieves the flash device with the specified ID. Returns NULL if no such * device exists. @@ -60,15 +72,10 @@ hal_bsp_core_dump(int *area_cnt) const struct hal_flash * hal_bsp_flash_dev(uint8_t id) { - switch (id) { - case 0: - /* MCU internal flash. */ - return &nrf52k_flash_dev; - - default: - /* External flash. Assume not present in this BSP. */ + if (id >= ARRAY_SIZE(flash_devs)) { return NULL; } + return flash_devs[id]; } /** diff --git a/hw/bsp/pinetime/syscfg.yml b/hw/bsp/pinetime/syscfg.yml index f274677..bcb6e8d 100644 --- a/hw/bsp/pinetime/syscfg.yml +++ b/hw/bsp/pinetime/syscfg.yml @@ -48,6 +48,7 @@ syscfg.vals: # Default Pins for Peripherals # SPI port 0 connected to ST7789 display + SPI_0_MASTER: 1 SPI_0_MASTER_PIN_SCK: 2 # P0.02: SPI-SCK, LCD_SCK SPI_0_MASTER_PIN_MOSI: 3 # P0.03: SPI-MOSI, LCD_SDI SPI_0_MASTER_PIN_MISO: 4 # P0.04: SPI-MISO @@ -72,6 +73,31 @@ syscfg.vals: NFFS_FLASH_AREA: FLASH_AREA_NFFS COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1 + # SPI Flash + SPIFLASH: 1 + SPIFLASH_SPI_NUM: 0 + SPIFLASH_SPI_CS_PIN: 5 # P0.05 SPI-CE#(SPI-NOR) + SPIFLASH_BAUDRATE: 8000 + SPIFLASH_MANUFACTURER: 0x0B + SPIFLASH_MEMORY_TYPE: 0x40 + SPIFLASH_MEMORY_CAPACITY: 0x16 + SPIFLASH_SECTOR_COUNT: 1024 + SPIFLASH_SECTOR_SIZE: 4096 + SPIFLASH_PAGE_SIZE: 256 + + SPIFLASH_TBP1_TYPICAL: 20 # Byte program time (first byte) (us) + SPIFLASH_TBP1_MAXIMUM: 50 # Maximum byte program time (first byte) (us) + SPIFLASH_TPP_TYPICAL: 700 # Page program time (us) + SPIFLASH_TPP_MAXIMUM: 3000 # Maximum page program time (us) + SPIFLASH_TSE_TYPICAL: 30000 # Sector erase time (4KB) (us) + SPIFLASH_TSE_MAXIMUM: 400000 # Maximum sector erase time (us) + SPIFLASH_TBE1_TYPICAL: 120000 # Block erase time (32KB) (us) + SPIFLASH_TBE1_MAXIMUM: 800000 # Maximum block erase time (32KB) (us) + SPIFLASH_TBE2_TYPICAL: 150000 # Block erase time (64KB) (us) + SPIFLASH_TBE2_MAXIMUM: 1000000 # Maximum block erase time (64KB) (us) + SPIFLASH_TCE_TYPICAL: 3000000 # Chip erase time (us) + SPIFLASH_TCE_MAXIMUM: 10000000 # Maximum chip erase time (us) + syscfg.vals.BSP_BATTERY: # ADC needed for battery voltage ADC_0: 1