You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/10/24 11:41:08 UTC
[GitHub] adityaxavier commented on a change in pull request #1475: STM32F0
Support
adityaxavier commented on a change in pull request #1475: STM32F0 Support
URL: https://github.com/apache/mynewt-core/pull/1475#discussion_r227751632
##########
File path: hw/mcu/stm/stm32f0xx/src/hal_flash.c
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+
+#include <string.h>
+#include "stm32f0xx_hal_def.h"
+#include "stm32f0xx_hal_flash.h"
+#include "stm32f0xx_hal_flash_ex.h"
+#include "hal/hal_flash_int.h"
+
+/*
+ * Flash is organized in FLASH_PAGE_SIZE blocks, which for the
+ * STM32F0 family is 2KB.
+ * */
+#define HAL_FLASH_SECTOR_SIZE FLASH_PAGE_SIZE
+#define HAL_FLASH_SIZE (64 * 1024)
+
+
+static int stm32f0_flash_read(const struct hal_flash *dev, uint32_t address,
+ void *dst, uint32_t num_bytes);
+static int stm32f0_flash_write(const struct hal_flash *dev, uint32_t address,
+ const void *src, uint32_t num_bytes);
+static int stm32f0_flash_erase_sector(const struct hal_flash *dev,
+ uint32_t sector_address);
+static int stm32f0_flash_sector_info(const struct hal_flash *dev, int idx,
+ uint32_t *address, uint32_t *sz);
+static int stm32f0_flash_init(const struct hal_flash *dev);
+
+static const struct hal_flash_funcs stm32f0_flash_funcs = {
+ .hff_read = stm32f0_flash_read,
+ .hff_write = stm32f0_flash_write,
+ .hff_erase_sector = stm32f0_flash_erase_sector,
+ .hff_sector_info = stm32f0_flash_sector_info,
+ .hff_init = stm32f0_flash_init
+};
+
+struct hal_flash stm32f0_flash_dev_;
Review comment:
stm32f0_flash_dev is currently a function which is returning that struct.
As a constant :-
`Size of Application Image: app`
`FLASH RAM `
` 23 206 *fill*`
` 52 4 apps_blinky.a`
` 490 4 hw_bsp_nucleo-f030r8.a`
` 32 0 hw_cmsis-core.a`
` 124 0 hw_hal.a`
` 1580 36 hw_mcu_stm_stm32_common.a`
` 1740 32 hw_mcu_stm_stm32f0xx.a`
` 3601 1081 kernel_os.a`
` 50 0 libc_baselibc.a`
` 270 128 sys_flash_map.a`
` 340 12 sys_mfg.a`
` 30 5 sys_sysinit.a`
` 88 0 stm32_blinky-sysinit-app.a`
` 320 0 libgcc.a`
`objsize`
` text data bss dec hex filename`
` 8740 32 1476 10248 2808`
As a static struct being passed
`Size of Application Image: app`
` FLASH RAM `
` 27 206 *fill*`
` 52 4 apps_blinky.a`
` 490 4 hw_bsp_nucleo-f030r8.a`
` 32 0 hw_cmsis-core.a`
` 124 0 hw_hal.a`
` 1580 36 hw_mcu_stm_stm32_common.a`
` 1724 56 hw_mcu_stm_stm32f0xx.a`
` 3601 1081 kernel_os.a`
` 50 0 libc_baselibc.a`
` 270 128 sys_flash_map.a`
` 340 12 sys_mfg.a`
` 30 5 sys_sysinit.a`
` 88 0 stm32_blinky-sysinit-app.a`
` 320 0 libgcc.a`
`objsize`
` text data bss dec hex filename`
` 8728 56 1476 10260 2814`
Which method would you prefer.
BTW, I believe we should ideally do the same to other stm32fxx series as well for keeping them the similar.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services