diff --git a/README.md b/README.md index 00b8ef7..f6f20ab 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The software is configurable to support different charge controller PCBs with ST | Board | Default revision | Older revisions | |-----------------------------------------------------|------------------|-----------------| -| [Libre Solar MPPT 2420 HC](https://github.com/LibreSolar/mppt-2420-hc) | 0.1 | | +| [Libre Solar MPPT 2420 HC](https://github.com/LibreSolar/mppt-2420-hc) | 0.2 | 0.1 | | [Libre Solar MPPT 2420 LC](https://github.com/LibreSolar/mppt-2420-lc) | 0.10 | | | [Libre Solar MPPT 1210 HUS](https://github.com/LibreSolar/mppt-1210-hus) | 0.7 | 0.4 | | [Libre Solar PWM 2420 LUS](https://github.com/LibreSolar/pwm-2420-lus) | 0.3 | 0.2 | diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc.dts b/boards/arm/mppt_2420_hc/mppt_2420_hc.dts index 1920fef..81a4aae 100644 --- a/boards/arm/mppt_2420_hc/mppt_2420_hc.dts +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc.dts @@ -16,8 +16,6 @@ compatible = "charge-controller"; type = "MPPT 2420 HC"; - version-str = "v0.1"; - version-num = <1>; hs-voltage-max = <80>; ls-voltage-max = <32>; @@ -31,23 +29,20 @@ zephyr,flash = &flash0; }; - /* temporary solution w/o using RGB LED */ + /* temporary solution only using green color LED */ leds { compatible = "charlieplexing-leds"; - gpios = <&gpiob 14 GPIO_ACTIVE_LOW>, /* red */ - <&gpiob 15 GPIO_ACTIVE_LOW>, /* green */ - <&gpiob 9 GPIO_ACTIVE_LOW>; /* blue */ + gpios = <&gpioa 6 GPIO_ACTIVE_LOW>, /* chg red */ + <&gpioc 14 GPIO_ACTIVE_LOW>, /* chg green */ + <&gpiob 9 GPIO_ACTIVE_LOW>, /* dis red */ + <&gpioc 15 GPIO_ACTIVE_LOW>; /* dis green */ pwr { - states = <1 0 0>; + states = <0 1 0 0>; }; load { - states = <0 1 0>; - }; - - rxtx { - states = <0 0 1>; + states = <0 0 0 1>; }; }; @@ -142,6 +137,7 @@ &i2c1 { pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>; + clock-frequency = ; status = "okay"; }; @@ -151,26 +147,12 @@ status = "okay"; }; -&usb { +&spi2 { + pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>; + cs-gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; status = "okay"; }; -&rtc { - status = "okay"; -}; - -&flash0 { - /* - * For more information, see: - * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions - */ - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - }; -}; - &iwdg { status = "okay"; }; @@ -180,7 +162,7 @@ halfbridge { compatible = "half-bridge"; - pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>; + pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pc13>; frequency = <70000>; deadtime = <300>; }; @@ -196,25 +178,6 @@ }; }; -&i2c1 { - status = "okay"; - clock-frequency = ; - eeprom@50 { - // Microchip 24AA32A - compatible = "atmel,at24"; - reg = <0x50>; - label = "EEPROM_0"; - size = <32768>; - pagesize = <32>; - address-width = <16>; - /* - * timeout of 5 ms as suggested in datasheet seems too optimistic - * (several write errors occured during testing) - */ - timeout = <7>; - }; -}; - &can1 { pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; bus-speed = <250000>; diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.conf b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.conf new file mode 100644 index 0000000..8ae5c6e --- /dev/null +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.conf @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_I2C=y +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.overlay b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.overlay new file mode 100644 index 0000000..9349f07 --- /dev/null +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.overlay @@ -0,0 +1,68 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2021 Martin Jäger / Libre Solar + */ + +/ { + pcb { + version-str = "v0.1"; + version-num = <1>; + }; + + /* temporary solution w/o using RGB LED */ + leds { + compatible = "charlieplexing-leds"; + gpios = <&gpiob 14 GPIO_ACTIVE_LOW>, /* red */ + <&gpiob 15 GPIO_ACTIVE_LOW>, /* green */ + <&gpiob 9 GPIO_ACTIVE_LOW>; /* blue */ + + pwr { + states = <1 0 0>; + }; + + load { + states = <0 1 0>; + }; + + rxtx { + states = <0 0 1>; + }; + }; +}; + +&i2c1 { + eeprom@50 { + // Microchip 24AA32A + compatible = "atmel,at24"; + reg = <0x50>; + label = "EEPROM_0"; + size = <32768>; + pagesize = <32>; + address-width = <16>; + /* + * timeout of 5 ms as suggested in datasheet seems too optimistic + * (several write errors occured during testing) + */ + timeout = <7>; + }; +}; + +&spi1 { + pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>; + cs-gpios = <&gpiob 6 GPIO_ACTIVE_LOW>; + status = "okay"; +}; + +&timers1 { + halfbridge { + pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>; + }; +}; + +&spi2 { + status = "disabled"; + + /delete-node/ pinctrl-0; + /delete-node/ cs-gpios; +}; diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc_0_2_0.conf b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_2_0.conf new file mode 100644 index 0000000..b85a808 --- /dev/null +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_2_0.conf @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_LOG_LEVEL_WRN=y +#CONFIG_MPU_ALLOW_FLASH_WRITE=y + +CONFIG_SPI=y +CONFIG_SPI_NOR=y +CONFIG_SPI_NOR_SFDP_RUNTIME=y +CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 + +CONFIG_NVS=y +CONFIG_NVS_LOG_LEVEL_WRN=y diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc_0_2_0.overlay b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_2_0.overlay new file mode 100644 index 0000000..1d54292 --- /dev/null +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_2_0.overlay @@ -0,0 +1,81 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2021 Martin Jäger / Libre Solar + */ + +/ { + pcb { + version-str = "v0.2"; + version-num = <2>; + }; + + chosen { + zephyr,code-partition = &slot0_partition; + }; +}; + +&spi2 { + w25q80dv: w25q80dv@0 { + compatible = "jedec,spi-nor"; + label = "W25Q80DV"; + reg = <0>; + spi-max-frequency = <4000000>; + size = <0x800000>; /* bits */ + has-dpd; + t-enter-dpd = <4000>; + t-exit-dpd = <25000>; + jedec-id = [ef 40 14]; + }; +}; + +/* + * Below partition layout allows to use MCUboot if CONFIG_BOOTLOADER_MCUBOOT is enabled. Otherwise, + * the code will just use the entire available flash of the MCU. + */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* bootloader slot: 32 KiB */ + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 0x8000>; + read-only; + }; + + /* application image slot: 96 KiB */ + slot0_partition: partition@8000 { + label = "image-0"; + reg = <0x00008000 0x18000>; + }; + }; +}; + +&w25q80dv { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* backup slot: 96 KiB */ + slot1_partition: partition@0 { + label = "image-1"; + reg = <0x00000000 0x18000>; + }; + + /* swap slot: 96 KiB */ + scratch_partition: partition@18000 { + label = "image-scratch"; + reg = <0x00018000 0x00018000>; + }; + + /* remaining 832 KiB of SPI flash used as storage */ + storage_partition: partition@30000 { + label = "storage"; + reg = <0x00030000 0x000D0000>; + }; + }; +}; diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig b/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig index 6132477..352a07d 100644 --- a/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig @@ -58,10 +58,6 @@ CONFIG_ARM_MPU=y CONFIG_PWM=y -CONFIG_I2C=y -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y - CONFIG_CAN=y CONFIG_THINGSET_CAN=y diff --git a/boards/arm/mppt_2420_hc/revision.cmake b/boards/arm/mppt_2420_hc/revision.cmake new file mode 100644 index 0000000..42afeb9 --- /dev/null +++ b/boards/arm/mppt_2420_hc/revision.cmake @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_check_revision(FORMAT MAJOR.MINOR.PATCH) diff --git a/boards/mppt_2420_hc.json b/boards/mppt_2420_hc@0.2.json similarity index 100% rename from boards/mppt_2420_hc.json rename to boards/mppt_2420_hc@0.2.json diff --git a/platformio.ini b/platformio.ini index d45851f..7f4001e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -71,7 +71,7 @@ board = mppt_2420_rc # https://github.com/LibreSolar/mppt-2420-hc [env:mppt_2420_hc] -board = mppt_2420_hc +board = mppt_2420_hc@0.2 # https://github.com/LibreSolar/mppt-1210-hus [env:mppt_1210_hus]