pkarashchenko commented on a change in pull request #4908: URL: https://github.com/apache/incubator-nuttx/pull/4908#discussion_r757883021
########## File path: boards/arm/stm32h7/nucleo-h743zi/src/stm32_progmem.c ########## @@ -0,0 +1,284 @@ +/**************************************************************************** + * apps/examples/mtdpart/stm32_progmem.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/mount.h> + +#include <stdbool.h> +#include <stdlib.h> +#include <stdio.h> +#include <assert.h> +#include <errno.h> +#include <debug.h> + +#include <nuttx/progmem.h> +#include <nuttx/drivers/drivers.h> +#include <nuttx/fs/ioctl.h> +#include <nuttx/kmalloc.h> +#include <nuttx/mtd/mtd.h> +#ifdef CONFIG_BCH +#include <nuttx/drivers/drivers.h> +#endif + +#include <stm32.h> +#include <nucleo-h743zi.h> +#include <stm32_flash.h> + +#ifdef HAVE_PROGMEM_CHARDEV + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0])) + +/* Configuration ************************************************************/ + +/* Make sure that support for MTD partitions is enabled */ +#ifdef CONFIG_MTD + +#ifndef CONFIG_MTD_PARTITION +# error "CONFIG_MTD_PARTITION is required" +#endif + +#endif +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined(CONFIG_PROGMEM_OTA_PARTITION) + +struct ota_partition_s +{ + uint32_t offset; /* Partition offset from the beginning of MTD */ + uint32_t size; /* Partition size in bytes */ + const char *devpath; /* Partition device path */ +}; + +#endif + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#if defined(CONFIG_PROGMEM_OTA_PARTITION) +static struct mtd_dev_s *progmem_alloc_mtdpart(uint32_t mtd_offset, + uint32_t mtd_size); +static int init_ota_partitions(void); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static FAR struct mtd_dev_s *g_progmem_mtd; + +#if defined(CONFIG_PROGMEM_OTA_PARTITION) +static const struct ota_partition_s g_ota_partition_table[] = +{ + { + .offset = CONFIG_OTA_PRIMARY_SLOT_OFFSET, + .size = CONFIG_OTA_SLOT_SIZE, + .devpath = CONFIG_OTA_PRIMARY_SLOT_DEVPATH + }, + { + .offset = CONFIG_OTA_SECONDARY_SLOT_OFFSET, + .size = CONFIG_OTA_SLOT_SIZE, + .devpath = CONFIG_OTA_SECONDARY_SLOT_DEVPATH + }, + { + .offset = CONFIG_OTA_SCRATCH_OFFSET, + .size = CONFIG_OTA_SCRATCH_SIZE, + .devpath = CONFIG_OTA_SCRATCH_DEVPATH + } +}; +#endif + + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#if defined(CONFIG_PROGMEM_OTA_PARTITION) + +/**************************************************************************** + * Name: sam_progmem_alloc_mtdpart + * + * Description: + * Allocate an MTD partition from FLASH. + * + * Input Parameters: + * mtd_offset - MTD Partition offset from the base address in FLASH. + * mtd_size - Size for the MTD partition. + * + * Returned Value: + * MTD partition data pointer on success, NULL on failure. + * + ****************************************************************************/ + +static struct mtd_dev_s *progmem_alloc_mtdpart(uint32_t mtd_offset, + uint32_t mtd_size) Review comment: ```suggestion uint32_t mtd_size) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org