sidk_s5jt200: drop to support fota and crashdump
authorHeesub Shin <heesub.shin@samsung.com>
Sun, 19 Mar 2017 05:00:14 +0000 (14:00 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Mon, 17 Apr 2017 10:52:04 +0000 (19:52 +0900)
FOTA and crashdump is directly accessing to the S5J flash driver. This
is breaking the whole design and needs to be improved but, there is no
better way than to drop them all completely and redesign them from
scratch.

Change-Id: I228a22044a9be3ebf4911e06ebebd5ef9bde4a72
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
build/configs/sidk_s5jt200/kernel_sample/defconfig
build/configs/sidk_s5jt200/tc/defconfig
os/arch/arm/src/sidk_s5jt200/include/s5jt200_fota.h [deleted file]
os/arch/arm/src/sidk_s5jt200/src/Makefile
os/arch/arm/src/sidk_s5jt200/src/s5jt200_boot.c
os/arch/arm/src/sidk_s5jt200/src/s5jt200_crashdump.c [deleted file]
os/arch/arm/src/sidk_s5jt200/src/s5jt200_fota.c [deleted file]

index e53def9..1692022 100644 (file)
@@ -295,7 +295,7 @@ CONFIG_ARCH_HAVE_BUTTONS=y
 CONFIG_ARCH_BUTTONS=y
 CONFIG_ARCH_HAVE_IRQBUTTONS=y
 # CONFIG_ARCH_IRQBUTTONS is not set
-CONFIG_BOARD_CRASHDUMP=y
+# CONFIG_BOARD_CRASHDUMP is not set
 # CONFIG_BOARD_COREDUMP_FLASH is not set
 # CONFIG_BOARD_FOTA_SUPPORT is not set
 # CONFIG_BOARD_RAMDUMP_FLASH is not set
index afa4c12..ebdaacb 100644 (file)
@@ -295,7 +295,7 @@ CONFIG_ARCH_HAVE_BUTTONS=y
 CONFIG_ARCH_BUTTONS=y
 CONFIG_ARCH_HAVE_IRQBUTTONS=y
 # CONFIG_ARCH_IRQBUTTONS is not set
-CONFIG_BOARD_CRASHDUMP=y
+# CONFIG_BOARD_CRASHDUMP is not set
 # CONFIG_BOARD_COREDUMP_FLASH is not set
 # CONFIG_BOARD_FOTA_SUPPORT is not set
 # CONFIG_BOARD_RAMDUMP_FLASH is not set
diff --git a/os/arch/arm/src/sidk_s5jt200/include/s5jt200_fota.h b/os/arch/arm/src/sidk_s5jt200/include/s5jt200_fota.h
deleted file mode 100644 (file)
index a01633a..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed 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.
- *
- ****************************************************************************/
-
-#ifndef __ARCH_ARM_SRC_SIDK_S5JT200_INCLUDE_S5JT200_FOTA_H
-#define __ARCH_ARM_SRC_SIDK_S5JT200_INCLUDE_S5JT200_FOTA_H
-
-/******************************************************************************
- * Included Files
- *****************************************************************************/
-
-#include <tinyara/config.h>
-#include <arch/board/s5jt200_partitions.h>
-
-/******************************************************************************
- * Pre-processor Definitions
- *****************************************************************************/
-
-/****************************************************************************
-* Public Types
-****************************************************************************/
-#ifndef __ASSEMBLY__
-enum fota_partition_id_e {
-       FOTA_PARTITION_OTA0 = 0,
-       FOTA_PARTITION_OTA1,
-       FOTA_PARTITION_MAX,
-};
-
-typedef enum fota_partition_id_e fota_partition_id_t;
-
-enum fota_bin_id_e {
-       FOTA_BIN_ID_TINYARA = 0,
-       FOTA_BIN_ID_LEDFW,
-       FOTA_BIN_ID_SSSFW,
-       FOTA_BIN_ID_WLANFW,
-       FOTA_BIN_ID_SSSKEY,
-       FOTA_BIN_ID_MAX,
-};
-
-typedef enum fota_bin_id_e fota_bin_id_t;
-
-enum boot_mode_status_e {
-       BOOTMODE_NORMALBOOT = 0,
-       BOOTMODE_REBOOT,
-       BOOTMODE_WATCHDOG_RESET,
-       BOOTMODE_FOTA_UPDATE,
-       BOOTMODE_FOTA_RESET,
-       BOOTMODE_MAX,
-};
-
-typedef enum boot_mode_status_e boot_mode_status_t;
-
-enum fota_state_e {
-       FOTA_STATE_COMPLETED = 0,
-       FOTA_STATE_PROGRESSING,
-       FOTA_STATE_FAILED,
-       FOTA_STATE_MAX,
-};
-
-typedef enum fota_state_e fota_state_t;
-
-enum fota_binstate_e {
-       FOTA_BINSTATE_NORMAL = 0,
-       FOTA_BINSTATE_UPDATED,
-       FOTA_BINSTATE_COPYING,
-       FOTA_BINSTATE_COPIED,
-       FOTA_BINSTATE_MAX,
-};
-
-typedef enum fota_binstate_e fota_binstate_t;
-
-struct boot_param_s {
-       boot_mode_status_t boot_mode;
-       fota_state_t fota_state;
-       uint32_t cur_partition;
-       uint32_t fota_try_count;
-       uint32_t fota_max_try;
-       fota_binstate_t fota_bins_state[FOTA_BIN_ID_MAX];
-};
-
-typedef struct boot_param_s boot_param_t;
-
-/****************************************************************************
-* Public Data
-****************************************************************************/
-#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C" {
-#else
-#define EXTERN extern
-#endif
-/****************************************************************************
-* Inline Functions
-****************************************************************************/
-
-/****************************************************************************
-* Public Functions
-****************************************************************************/
-/****************************************************************************
- * Name: s5jt200_fota_init
- *
- * Description:
- *   Intialize FOTA for s5jt200
- *
- ****************************************************************************/
-int s5jt200_fota_init(void);
-
-/****************************************************************************
- * Name: s5jt200_fota_update_notify
- *
- * Description:
- *   Notify if fota update done in previous boot
- *
- ****************************************************************************/
-int s5jt200_fota_update_notify(void);
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-#endif
-
-#endif                                                 /* __ARCH_ARM_SRC_SIDK_S5JT200_INCLUDE_S5JT200_FOTA_H */
index 6c13d27..25ae3a2 100644 (file)
@@ -75,10 +75,6 @@ CSRCS += s5jt200_watchdog.c
 endif
 endif
 
-ifeq ($(CONFIG_BOARD_CRASHDUMP),y)
-CSRCS += s5jt200_crashdump.c
-endif
-
 ifeq ($(CONFIG_MTD_PROGMEM),y)
 CSRCS += s5jt200_progmem.c
 endif
index b137a0f..2812169 100644 (file)
@@ -66,7 +66,6 @@
 
 #include <tinyara/board.h>
 #include <arch/board/board.h>
-#include <arch/board/s5jt200_fota.h>
 #include <arch/board/s5jt200_partitions.h>
 
 #include <sys/mount.h>
 /****************************************************************************
  * Public Functions Prototypes
  ****************************************************************************/
-#if defined(CONFIG_BOARD_COREDUMP_FLASH) || defined(CONFIG_BOARD_RAMDUMP_FLASH)
-extern FAR struct spi_dev_s *up_spiflashinitialize(void);
-#endif
-
-#if defined(CONFIG_BOARD_COREDUMP_FLASH)
-extern void up_coredump_init(void);
-#endif
 
 /****************************************************************************
  * Private Data
@@ -443,13 +435,5 @@ void board_initialize(void)
        slldbg("Initialize SCSC driver\n");
        slsi_driver_initialize();
 #endif
-
-#if defined(CONFIG_BOARD_COREDUMP_FLASH) || defined(CONFIG_BOARD_RAMDUMP_FLASH)
-       up_spiflashinitialize();
-#endif
-
-#if defined(CONFIG_BOARD_COREDUMP_FLASH)
-       up_coredump_init();
-#endif
 }
 #endif /* CONFIG_BOARD_INITIALIZE */
diff --git a/os/arch/arm/src/sidk_s5jt200/src/s5jt200_crashdump.c b/os/arch/arm/src/sidk_s5jt200/src/s5jt200_crashdump.c
deleted file mode 100644 (file)
index 8434e7e..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed 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 <tinyara/config.h>
-#include <tinyara/board.h>
-#include <tinyara/arch.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <chip.h>
-#include <arch/board/board.h>
-#include "up_internal.h"
-#if defined(CONFIG_BOARD_COREDUMP_FLASH) || defined(CONFIG_BOARD_RAMDUMP_FLASH)
-#include <arch/board/s5jt200_partitions.h>
-#endif
-
-/****************************************************************************
- * Definitions
- ****************************************************************************/
-#if defined(CONFIG_BOARD_COREDUMP_FLASH) || defined(CONFIG_BOARD_RAMDUMP_FLASH)
-#define SFLASH_BLOCK_ERASE_LARGE_CMD    0xD8
-#define SFLASH_SECTOR_ERASE_CMD         0x20
-#endif
-
-#if defined(CONFIG_BOARD_COREDUMP_FLASH)
-#define COREDUMP_BUF_SIZE               (4096)
-#endif
-
-#define HANDSHAKE_STRING                "RAMDUMP"
-#define HANDSHAKE_STR_LEN_MAX           (7)
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-#if defined(CONFIG_BOARD_COREDUMP_FLASH) || defined(CONFIG_BOARD_RAMDUMP_FLASH)
-/* Prototypes for flash API's, just to keep compiler happy */
-extern int s5j_sflash_erase(void *dev, uint8_t cmd, uint32_t addr);
-extern int s5j_sflash_write(void *dev, uint32_t addr, uint8_t *buf, uint32_t size);
-extern int s5j_sflash_read(void *dev, uint32_t addr, uint8_t *buf, uint32_t size);
-#endif
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-#if defined(CONFIG_BOARD_COREDUMP_FLASH)
-static int coredump_open(FAR struct file *filep);
-static int coredump_close(FAR struct file *filep);
-static ssize_t coredump_read(FAR struct file *filep, FAR char *buffer, size_t buflen);
-static void coredump_seek_reset(void);
-static int read_coredump_from_flash(char *buffer, int size);
-#endif
-
-/****************************************************************************
- * External Variables
- ****************************************************************************/
-#if defined(CONFIG_BOARD_COREDUMP_FLASH) || defined(CONFIG_BOARD_RAMDUMP_FLASH)
-extern volatile bool g_sflash_nonsleep_mode;
-#endif
-
-/****************************************************************************
- * Private Variables
- ****************************************************************************/
-#if defined(CONFIG_BOARD_COREDUMP_FLASH)
-static sem_t coredump_readsem;
-static int32_t coredump_dev_opened;
-static int32_t read_flash_done;
-static int32_t size_transferred;
-static int32_t coredump_size = 0;
-static uint8_t coredump_buf[COREDUMP_BUF_SIZE];
-
-static const struct file_operations g_coredump_ops = {
-       coredump_open,                          /* open */
-       coredump_close,                         /* close */
-       coredump_read,                          /* read */
-};
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-static int coredump_open(FAR struct file *filep)
-{
-       if (coredump_dev_opened) {
-               dbg("coredump device busy\n");
-               return -1;
-       }
-
-       coredump_dev_opened = 1;
-
-       return OK;
-}
-
-static int coredump_close(FAR struct file *filep)
-{
-       if (!coredump_dev_opened) {
-               dbg("coredump device close failed\n");
-               return -1;
-       }
-
-       coredump_dev_opened = 0;
-
-       coredump_seek_reset();
-       return OK;
-}
-
-static ssize_t coredump_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
-{
-       int ret = 0;
-
-       if (!coredump_dev_opened) {
-               dbg("coredump device not opened\n");
-               return -1;
-       }
-
-       /* take read semaphore */
-       while (sem_wait(&coredump_readsem) != OK) ;
-
-       ret = read_coredump_from_flash(buffer, buflen);
-
-       /* give read semaphore */
-       sem_post(&coredump_readsem);
-       return ret;
-}
-
-static int read_coredump_from_flash(char *buffer, int size)
-{
-       int32_t len;
-       char *pbuf = (char *)coredump_buf;
-       uint32_t coredump_flash_base;
-
-       coredump_flash_base = MTD_BLK_COREDUMP_START;
-
-       if (!read_flash_done) {
-
-               len = COREDUMP_BUF_SIZE;
-
-               /* Maximum len allowed is MTD_BLK_COREDUMP_SIZE partition size */
-               len = (len < MTD_BLK_COREDUMP_SIZE) ? len : MTD_BLK_COREDUMP_SIZE;
-
-               /* clear coredump buffer */
-               memset(coredump_buf, 0, COREDUMP_BUF_SIZE);
-
-               s5j_sflash_read(NULL, coredump_flash_base, (uint8_t *)coredump_buf, len);
-
-               read_flash_done = 1;
-               coredump_size = strtol((char *)coredump_buf, NULL, 16);
-       }
-
-       /* seek after 10 byte header(size) field */
-       pbuf += 10;
-
-       if (coredump_size <= 0) {
-               return 0;
-       }
-
-       /* adjust size */
-       size = ((coredump_size - size) > 0) ? size : coredump_size;
-
-       /* copy to user buffer */
-       memcpy(buffer, pbuf + size_transferred, size);
-       size_transferred += size;
-       coredump_size -= size;
-
-       return size;
-}
-
-static void coredump_seek_reset(void)
-{
-       read_flash_done = 0;
-       size_transferred = 0;
-}
-
-static int coredump_to_flash(uint32_t cur_sp, void *tcb)
-{
-       int32_t i;
-       int32_t j;
-       int32_t len = 0;
-       uint32_t *ptr;
-       uint32_t stack;
-       char *pbuf = (char *)coredump_buf;
-       uint32_t coredump_flash_base;
-       struct tcb_s *rtcb = (struct tcb_s *)tcb;
-
-       /* MTD_BLK_DUMP partition is used for coredump(crashlog) */
-       coredump_flash_base = MTD_BLK_COREDUMP_START;
-
-       /* MTD_BLK_COREDUMP_SIZE */
-       if (MTD_BLK_COREDUMP_SIZE < MTD_SFLASH_ERASE_SIZE) {
-               lldbg("error :coredump partition is too less, exiting ...\n");
-               return -1;
-       }
-
-       /* Add dummy coredump_size at the beginning */
-       len += sprintf(pbuf + len, "%08x\n", coredump_size);
-
-       /* space for '\0' character added by sprintf */
-       len += 1;
-
-       /* Process and format the stack to readable format */
-       len += sprintf(pbuf + len, "up_dumpstate:   size: %08x\n", (rtcb->adj_stack_size));
-
-       for (stack = cur_sp & ~0x1f; stack < (uint32_t)rtcb->adj_stack_ptr; stack += 32) {
-               ptr = (uint32_t *)stack;
-               len += sprintf(pbuf + len, "up_stackdump: ");
-               len += sprintf(pbuf + len, "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", stack, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]);
-       }
-
-       ptr = (uint32_t *)current_regs;
-       for (i = 0; i < 2; i++) {
-               len += sprintf(pbuf + len, "up_registerdump: R%d:", (i * 8));
-               for (j = 0; j < 8; j++) {
-                       len += sprintf(pbuf + len, " %08x", ptr[j]);
-               }
-               len += sprintf(pbuf + len, "\n");
-               ptr += 8;
-       }
-
-       len += sprintf(pbuf + len, "up_registerdump: CPSR: %08x\n", current_regs[REG_CPSR]);
-
-       /* calculate total formated coredump_size, without size field(10) bytes */
-       coredump_size = len - 10;
-
-       /* Add the actual crashlog_size at the beginning */
-       sprintf(pbuf, "%08x", coredump_size);
-
-       /* Erase a block in sflash */
-       s5j_sflash_erase(NULL, SFLASH_BLOCK_ERASE_LARGE_CMD, coredump_flash_base);
-
-       /* Maximum len allowed is MTD_BLK_DUMP_SIZE partition size */
-       len = (len < MTD_BLK_COREDUMP_SIZE) ? len : MTD_BLK_COREDUMP_SIZE;
-
-       /* write formated crashlog to sflash */
-       s5j_sflash_write(NULL, coredump_flash_base, (uint8_t *)pbuf, len);
-
-       lldbg("core dump of %d bytes dumped to flash @ %08x\n", len, (MTD_SFLASH_ADDR + coredump_flash_base));
-
-       return OK;
-}
-#endif
-
-#if defined(CONFIG_BOARD_RAMDUMP_FLASH)
-static int ramdump_to_flash(uint32_t ram_address, uint32_t ram_size)
-{
-       uint32_t offset = 0;
-       uint32_t ramdump_flash_base;
-       uint32_t total_size = 0;
-       uint32_t size;
-
-       /* Maximum ramsize allowed is MTD_BLK_RAMDUMP_SIZE partition size */
-       size = (ram_size < MTD_BLK_RAMDUMP_SIZE) ? ram_size : MTD_BLK_RAMDUMP_SIZE;
-
-       lldbg("ramdump size(requested = %d, truncated = %d) bytes\n", ram_size, size);
-
-       /* ramdump base is MTD_BLK_RAMDUMP_START */
-       ramdump_flash_base = MTD_BLK_RAMDUMP_START;
-
-       /* validate MTD_BLK_RAMDUMP_SIZE */
-       if (MTD_BLK_RAMDUMP_SIZE < MTD_SFLASH_ERASE_SIZE) {
-               lldbg("ramdump partition is too less, exiting ...\n");
-               return -1;
-       }
-
-       while (size) {
-               if (size >= MTD_SFLASH_ERASE_SIZE) {
-                       s5j_sflash_erase(NULL, SFLASH_BLOCK_ERASE_LARGE_CMD, ramdump_flash_base + offset);
-                       s5j_sflash_write(NULL, ramdump_flash_base + offset, (uint8_t *)ram_address + offset, MTD_SFLASH_ERASE_SIZE);
-                       offset += MTD_SFLASH_ERASE_SIZE;
-                       size -= MTD_SFLASH_ERASE_SIZE;
-                       total_size += MTD_SFLASH_ERASE_SIZE;
-               } else {
-                       s5j_sflash_erase(NULL, SFLASH_BLOCK_ERASE_LARGE_CMD, ramdump_flash_base + offset);
-                       s5j_sflash_write(NULL, ramdump_flash_base + offset, (uint8_t *)ram_address + offset, size);
-                       offset += size;
-                       total_size += size;
-                       size -= size;
-               }
-
-               lldbg(" %d bytes dumped to flash\n", total_size);
-       }
-
-       lldbg(" total %d bytes dumped successfully\n", total_size);
-
-       return OK;
-}
-#endif
-
-#if defined(CONFIG_BOARD_RAMDUMP_UART)
-static int ramdump_via_uart(uint32_t address, uint32_t size)
-{
-       int i;
-       int ch;
-       uint8_t *ptr;
-       char *target_str = HANDSHAKE_STRING;
-       char host_buf[HANDSHAKE_STR_LEN_MAX] = "";
-
-#if !defined(CONFIG_ARCH_LOWPUTC)
-       /* If lowlevel serial is not available, ramdump is not possible */
-       return -1;
-#endif
-
-       /* Inform the terminal user */
-       up_puts("****************************************************\n");
-       up_puts("Disconnect this serial terminal and Run Ramdump Tool\n");
-       up_puts("****************************************************\n");
-
-       /* Receive hanshake string from HOST */
-       do {
-               host_buf[0] = up_getc();
-       } while (host_buf[0] != target_str[0]);
-
-       for (i = 1; i < strlen(target_str);) {
-               if ((ch = up_getc()) != -1) {
-                       host_buf[i] = ch;
-                       i++;
-               }
-       }
-
-       if (strncmp(host_buf, target_str, strlen(target_str)) != 0) {
-               /* Send NAK */
-               up_lowputc('N');
-       }
-
-       /* Send ACK */
-       up_lowputc('A');
-
-       /* Send RAM address */
-       ptr = (uint8_t *)&address;
-       for (i = 0; i < sizeof(address); i++) {
-               up_lowputc((uint8_t)*ptr);
-               ptr++;
-       }
-
-       /* Send RAM size */
-       ptr = (uint8_t *)&size;
-       for (i = 0; i < sizeof(size); i++) {
-               up_lowputc((uint8_t)*ptr);
-               ptr++;
-       }
-
-       /* Send RAMDUMP of ram_size bytes */
-       ptr = (uint8_t *)address;
-       while (size) {
-               up_lowputc((uint8_t)*ptr);
-               ptr++;
-               size--;
-       }
-
-       lldbg(" Successfull\n");
-
-       return OK;
-}
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: board_crashdump
- *
- * Description:
- *   If CONFIG_BOARD_CRASHDUMP is selected then up_asseert will call out to
- *   board_crashdump prior to calling exit in the case of an assertion failure.
- *   Or in the case of a hardfault looping indefinitely. board_crashdump then
- *   has a chance to save the state of the machine. The provided
- *   board_crashdump should save as much information as it can about the cause
- *   of the fault and then most likely reset the system.
- *
- *   N.B. There are limited system resources that can be used by the provided
- *   board_crashdump function. The tems from the fact that most critical/fatal
- *   crashes are because of a hard fault or during interrupt processing.
- *   In these cases, up_assert is running from the context of an interrupt
- *   handlerand it is impossible to use any device driver in this context.
- *
- *   Also consider the following: Who knows what state the system is in? Is
- *   memory trashed? Is the Heap intact? Therefore all we can expect to do in
- *   board_crashdump is save the "machine state" in a place where on the next
- *   reset we can write it to more sophisticated storage in a sane operating
- *   environment.
- *
- ****************************************************************************/
-
-void board_crashdump(uint32_t cur_sp, void *tcb, uint8_t *filename, int lineno)
-{
-       int ret = OK;
-
-#if defined(CONFIG_S5J_WATCHDOG) && defined(CONFIG_S5J_WATCHDOG_RESET)
-       /* system under panic and we are dumping system state.
-        * watchdog reset might stall the system, causing crashdump hang.
-        * Hence let's disable watchdog reset during crashdump process.
-        */
-       s5j_wdg_set_reset(WDT_CPUCL_BASE, 0);
-#endif
-
-#if defined(CONFIG_BOARD_COREDUMP_FLASH) || defined(CONFIG_BOARD_RAMDUMP_FLASH)
-       /* Enable flash non sleep mode, will be used in s5j_sflash.c */
-       g_sflash_nonsleep_mode = true;
-#endif
-
-#if defined(CONFIG_BOARD_COREDUMP_FLASH)
-       ret = coredump_to_flash(cur_sp, tcb);
-       if (ret != OK) {
-               lldbg("coredump to flash failed, ret = %d\n", ret);
-       }
-#endif
-
-#if defined(CONFIG_BOARD_RAMDUMP_FLASH)
-       ret = ramdump_to_flash(CONFIG_RAM_START, CONFIG_RAM_SIZE);
-       if (ret != OK) {
-               lldbg("ramdump to flash failed, ret = %d\n", ret);
-       }
-#endif
-
-#if defined(CONFIG_BOARD_RAMDUMP_UART)
-       ret = ramdump_via_uart(CONFIG_RAM_START, CONFIG_RAM_SIZE);
-       if (ret != OK) {
-               lldbg("ramdump via uart failed, ret = %d\n", ret);
-       }
-#endif
-
-#if defined(CONFIG_BOARD_COREDUMP_FLASH) || defined(CONFIG_BOARD_RAMDUMP_FLASH)
-       /* Disable flash non sleep mode */
-       g_sflash_nonsleep_mode = false;
-#endif
-
-#if defined(CONFIG_S5J_WATCHDOG) && defined(CONFIG_S5J_WATCHDOG_RESET)
-       /* we are done !!, let's enable the watchdog reset */
-       s5j_wdg_set_reset(WDT_CPUCL_BASE, 1);
-#endif
-       if (ret == OK) {
-               lldbg(" Successfull\n");
-       }
-}
-
-#if defined(CONFIG_BOARD_COREDUMP_FLASH)
-/****************************************************************************
- * Name: up_coredump_init
- *
- * Description:
- *       Initialize coredump
- ****************************************************************************/
-int up_coredump_init(void)
-{
-       char coredump_devname[20] = "/dev/coredump";
-
-       sem_init(&coredump_readsem, 0, 1);
-
-       if (register_driver(coredump_devname, &g_coredump_ops, 0444, NULL) != 0) {
-               dbg("coredump driver register failed\n");
-               return -1;
-       }
-
-       return OK;
-}
-#endif
diff --git a/os/arch/arm/src/sidk_s5jt200/src/s5jt200_fota.c b/os/arch/arm/src/sidk_s5jt200/src/s5jt200_fota.c
deleted file mode 100644 (file)
index 0c47840..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed 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 <tinyara/config.h>
-#include <tinyara/board.h>
-#include <tinyara/arch.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <debug.h>
-#include <arch/board/board.h>
-#include "up_internal.h"
-#include <tinyara/fota/fota.h>
-#include <arch/board/s5jt200_fota.h>
-#include <arch/board/s5jt200_partitions.h>
-
-/****************************************************************************
- * Definitions
- ****************************************************************************/
-#define SFLASH_ERASE_SECTOR_SIZE  (4 * 1024)   //4K
-#define SFLASH_ERASE_SECTOR_CMD   (0x20)               //4K Erase CMD
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-static uint32_t g_cur_part_id;
-static uint32_t g_cur_bin_id;
-static uint32_t g_cur_ota_part_offset;
-static uint32_t g_cur_bin_part_offset;
-static uint32_t g_cur_bin_write_offset;
-static uint32_t g_cur_bin_read_offset;
-static uint32_t g_sector_buf_index;
-static bool g_sector_buffered = false;
-static uint8_t sector_buf[SFLASH_ERASE_SECTOR_SIZE];
-
-/* Nearly 2608KB of partition size required */
-static uint32_t fota_binpart_offset_array[FOTA_BIN_ID_MAX] = {
-       /* [FOTA_BIN_ID_TINYARA] */ 0x00000000,
-       /* 1.5MB */
-       /* [FOTA_BIN_ID_LEDFW]   */ 0x00180000,
-       /* 32KB  */
-       /* [FOTA_BIN_ID_SSSFW]   */ 0x00188000,
-       /* 32KB  */
-       /* [FOTA_BIN_ID_WLANFW]  */ 0x00190000,
-       /* 752KB */
-       /* [FOTA_BIN_ID_SSSKEY]  */ 0x0024C000,
-       /* 256KB */
-};
-
-static uint32_t fota_otapart_offset_array[FOTA_PARTITION_MAX] = {
-       /* [FOTA_PARTITION_OTA0] */ MTD_BLK_OTA0_START,
-       /* [FOTA_PARTITION_OTA1] */ MTD_BLK_OTA1_START,
-};
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-static int s5jt200_read_bootparam(boot_param_t *bootparam)
-{
-       int ret = ERROR;
-       uint32_t boot_part_offset = MTD_BLK_BOOTPARAM_START;
-
-       if (!bootparam) {
-               return ret;
-       }
-
-       /* Read boot param */
-       ret = s5j_sflash_read(NULL, boot_part_offset, bootparam, sizeof(boot_param_t));
-
-       return ret;
-}
-
-static int s5jt200_fota_get_partition(void)
-{
-       boot_param_t bootparam;
-
-       if (s5jt200_read_bootparam(&bootparam) != OK) {
-               return ERROR;
-       }
-
-       if (bootparam.cur_partition < FOTA_PARTITION_OTA0 || bootparam.cur_partition >= FOTA_PARTITION_MAX) {
-               bootparam.cur_partition = ERROR;
-       }
-
-       return bootparam.cur_partition;
-}
-
-static int s5jt200_fota_set_partition(uint32_t part_id)
-{
-       /* validate part_id */
-       if ((part_id < FOTA_PARTITION_OTA0) || (part_id >= FOTA_PARTITION_MAX)) {
-               return ERROR;
-       }
-
-       g_cur_part_id = part_id;
-       g_cur_ota_part_offset = fota_otapart_offset_array[part_id];
-       return OK;
-}
-
-static int s5jt200_fota_set_binary(uint32_t bin_id)
-{
-       /* validate bin_id */
-       if ((bin_id < FOTA_BIN_ID_TINYARA) || (bin_id >= FOTA_BIN_ID_MAX)) {
-               return ERROR;
-       }
-
-       g_cur_bin_id = bin_id;
-       g_cur_bin_part_offset = fota_binpart_offset_array[bin_id];
-       g_cur_bin_write_offset = 0;
-       g_cur_bin_read_offset = 0;
-       g_sector_buf_index = 0;
-       g_sector_buffered = false;
-
-       return OK;
-}
-
-static int s5jt200_fota_read(FAR const char *buffer, size_t buflen)
-{
-       /*TODO: Implement if required */
-
-       return ERROR;
-}
-
-static int s5jt200_fota_write(FAR const char *buffer, size_t buflen)
-{
-       uint32_t len = 0;
-       uint32_t size = buflen;
-       uint8_t *p_sector_buf = (uint8_t *)buffer;
-       uint32_t sector_len = SFLASH_ERASE_SECTOR_SIZE;
-       uint32_t fota_part_offset = g_cur_ota_part_offset + g_cur_bin_part_offset;
-       uint32_t fota_part_write_offset;
-
-       /* validate the buffer */
-       if (!buffer) {
-               set_errno(EINVAL);
-               return ERROR;
-       }
-
-       while (size > 0) {
-               if ((size + g_sector_buf_index) != SFLASH_ERASE_SECTOR_SIZE) {
-                       while (g_sector_buf_index < SFLASH_ERASE_SECTOR_SIZE) {
-                               if (len >= buflen) {
-                                       return buflen;
-                               }
-                               sector_buf[g_sector_buf_index] = buffer[len];
-                               g_sector_buf_index++;
-                               len++;
-                       }
-                       g_sector_buffered = true;
-                       p_sector_buf = sector_buf;
-               } else {
-                       p_sector_buf = (uint8_t *)buffer + len;
-               }
-
-               fota_part_write_offset = fota_part_offset + g_cur_bin_write_offset;
-
-               s5j_sflash_erase(NULL, SFLASH_ERASE_SECTOR_CMD, fota_part_write_offset);
-               s5j_sflash_write(NULL, fota_part_write_offset, p_sector_buf, sector_len);
-
-               g_cur_bin_write_offset += sector_len;
-               g_sector_buf_index = 0;
-               g_sector_buffered = false;
-               size -= len;
-       }
-
-       return buflen;
-}
-
-static int s5jt200_fota_write_flush(void)
-{
-       uint32_t fota_part_offset = g_cur_ota_part_offset + g_cur_bin_part_offset;
-       uint32_t fota_part_write_offset = fota_part_offset + g_cur_bin_write_offset;
-
-       if (g_sector_buffered) {
-               s5j_sflash_erase(NULL, SFLASH_ERASE_SECTOR_CMD, fota_part_write_offset);
-               s5j_sflash_write(NULL, fota_part_write_offset, sector_buf, g_sector_buf_index);
-       }
-
-       g_sector_buffered = false;
-       return OK;
-}
-
-static int s5jt200_fota_set_bootparam(fota_bootparam_type_t bootparam_type)
-{
-       int ret = OK;
-       uint32_t boot_part_offset = MTD_BLK_BOOTPARAM_START;
-       boot_param_t bootparam;
-
-       switch (bootparam_type) {
-       case FOTA_BOOTPARAM_TYPE_BOOTMODE:
-               /* Read boot param */
-               s5j_sflash_read(NULL, boot_part_offset, &bootparam, sizeof(bootparam));
-
-               /* Modify boot param */
-               bootparam.boot_mode = BOOTMODE_FOTA_UPDATE;
-
-               /* Reset the fota_state */
-               bootparam.fota_state = FOTA_STATE_COMPLETED;
-
-               /* Erase */
-               /* One 4K Erase Area will be sufficient for Bootparam */
-               s5j_sflash_erase(NULL, SFLASH_ERASE_SECTOR_CMD, boot_part_offset);
-
-               /* Write boot param */
-               s5j_sflash_write(NULL, boot_part_offset, &bootparam, sizeof(bootparam));
-
-               break;
-       case FOTA_BOOTPARAM_TYPE_BINSTATE:
-               /* Read boot param */
-               s5j_sflash_read(NULL, boot_part_offset, &bootparam, sizeof(bootparam));
-
-               /* Modify boot param */
-               bootparam.fota_bins_state[g_cur_bin_id] = FOTA_BINSTATE_UPDATED;
-
-               /* Erase */
-               /* One 4K Erase Area will be sufficient for Bootparam */
-               s5j_sflash_erase(NULL, SFLASH_ERASE_SECTOR_CMD, boot_part_offset);
-
-               /* Write boot param */
-               s5j_sflash_write(NULL, boot_part_offset, &bootparam, sizeof(bootparam));
-
-               break;
-       default:
-               dbg(" unknown bootmode\n");
-               ret = ERROR;
-               break;
-       }
-
-       return ret;
-}
-
-static int s5jt200_fota_erase(void)
-{
-       /*TODO: Implement if required */
-
-       return ERROR;
-}
-
-/* platform hooks for fota driver */
-static fota_dev_t s5jt200_fota_dev = {
-       s5jt200_fota_get_partition,
-       s5jt200_fota_set_partition,
-       s5jt200_fota_set_binary,
-       s5jt200_fota_set_bootparam,
-       s5jt200_fota_read,
-       s5jt200_fota_write,
-       s5jt200_fota_write_flush,
-       s5jt200_fota_erase,
-};
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: s5jt200_fota_init
- *
- * Description:
- *   Intialize FOTA for s5jt200
- *
- ****************************************************************************/
-int s5jt200_fota_init(void)
-{
-       int ret = OK;
-
-       if (fota_register(&s5jt200_fota_dev) != OK) {
-               ret = ERROR;
-       }
-
-       return ret;
-}
-
-/****************************************************************************
- * Name: s5jt200_fota_update_notify
- *
- * Description:
- *   Notify if fota update done in previous boot
- *
- ****************************************************************************/
-int s5jt200_fota_update_notify(void)
-{
-       boot_param_t bootparam;
-       uint32_t boot_part_offset = MTD_BLK_BOOTPARAM_START;
-       uint32_t ota0_phy_start = MTD_SFLASH_ADDR + MTD_BLK_OTA0_START;
-       uint32_t ota1_phy_start = MTD_SFLASH_ADDR + MTD_BLK_OTA1_START;
-       uint32_t ota0_phy_end = ota0_phy_start + MTD_BLK_OTA0_SIZE;
-       uint32_t ota1_phy_end = ota1_phy_start + MTD_BLK_OTA1_SIZE;
-       uint32_t start_text = (uint32_t)&_stext;
-
-       /* Read boot param */
-       s5j_sflash_read(NULL, boot_part_offset, &bootparam, sizeof(bootparam));
-
-       /* FIX ME:
-        * Since bootloader has not modified boot_mode,
-        * temperarely using it to print fota status
-        * We should only use fota_state here
-        */
-       if (bootparam.boot_mode == BOOTMODE_FOTA_UPDATE) {
-               dbg("FOTA UPDATE SUCCESSFUL\n");
-
-       } else {
-               if (bootparam.fota_state == FOTA_STATE_FAILED) {
-                       dbg("FOTA UPDATE FAILED\n");
-               } else if (bootparam.fota_state == FOTA_STATE_PROGRESSING) {
-                       dbg("FOTA UPDATE SUCCESSFUL\n");
-               }
-       }
-
-       bootparam.fota_state = FOTA_STATE_COMPLETED;
-
-       /* update boot param to complete fota update sequence */
-       /* set boot_mode to normal */
-       bootparam.boot_mode = BOOTMODE_NORMALBOOT;
-       /* update fota state */
-       bootparam.fota_state = FOTA_STATE_COMPLETED;
-
-       /*FIXME:
-        * Get cur_partition(running partition)
-        * Below one might be crude way,
-        */
-
-       //dbg("start = %08x, end = %08x, text = %08x\n", ota0_phy_start, ota0_phy_end, start_text);
-       if (start_text >= ota0_phy_start && start_text <= ota0_phy_end) {
-               bootparam.cur_partition = FOTA_PARTITION_OTA0;
-       } else if (start_text >= ota1_phy_start && start_text <= ota1_phy_end) {
-               bootparam.cur_partition = FOTA_PARTITION_OTA1;
-       } else {
-               bootparam.cur_partition = 255;
-       }
-
-       dbg("booted from [ OTA%d ] partition\n", bootparam.cur_partition);
-
-       /* Erase */
-       /* One 4K Erase Area will be sufficient for Bootparam */
-       s5j_sflash_erase(NULL, SFLASH_ERASE_SECTOR_CMD, boot_part_offset);
-
-       /* Write boot param */
-       s5j_sflash_write(NULL, boot_part_offset, &bootparam, sizeof(bootparam));
-
-       return OK;
-}