/**************************************************************************** * boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_bringup.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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include "gd32f450z_eval.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: gd32_bringup * * Description: * Perform architecture-specific initialization * * CONFIG_BOARD_LATE_INITIALIZE=y : * Called from board_late_initialize(). * * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : * Called from the NSH library via boardctl() * ****************************************************************************/ int gd32_bringup(void) { #ifdef CONFIG_RAMMTD uint8_t *ramstart; #endif int ret = OK; #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ ret = nx_mount(NULL, GD32_PROCFS_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n", GD32_PROCFS_MOUNTPOINT, ret); } #endif #ifdef CONFIG_RAMMTD /* Create a RAM MTD device if configured */ ramstart = (uint8_t *)kmm_malloc(64 * 1024); if (ramstart == NULL) { syslog(LOG_ERR, "ERROR: Allocation for RAM MTD failed\n"); } else { /* Initialized the RAM MTD */ struct mtd_dev_s *mtd = rammtd_initialize(ramstart, 64 * 1024); if (mtd == NULL) { syslog(LOG_ERR, "ERROR: rammtd_initialize failed\n"); kmm_free(ramstart); } else { /* Erase the RAM MTD */ ret = mtd->ioctl(mtd, MTDIOC_BULKERASE, 0); if (ret < 0) { syslog(LOG_ERR, "ERROR: IOCTL MTDIOC_BULKERASE failed\n"); } #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) /* Initialize a SMART Flash block device and bind it to the MTD * device. */ smart_initialize(0, mtd, NULL); #elif defined(CONFIG_FS_SPIFFS) /* Register the MTD driver so that it can be accessed from the * VFS. */ ret = register_mtddriver("/dev/rammtd", mtd, 0755, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to register MTD driver: %d\n", ret); } /* Mount the SPIFFS file system */ ret = nx_mount("/dev/rammtd", "/mnt/spiffs", "spiffs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount SPIFFS at /mnt/spiffs: %d\n", ret); } #elif defined(CONFIG_FS_LITTLEFS) /* Register the MTD driver so that it can be accessed from the * VFS. */ ret = register_mtddriver("/dev/rammtd", mtd, 0755, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to register MTD driver: %d\n", ret); } /* Mount the LittleFS file system */ ret = nx_mount("/dev/rammtd", "/mnt/lfs", "littlefs", 0, "forceformat"); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount LittleFS at /mnt/lfs: %d\n", ret); } #elif defined(CONFIG_FS_NXFFS) /* Initialize to provide NXFFS on the MTD interface */ ret = nxffs_initialize(mtd); if (ret < 0) { syslog(LOG_ERR, "ERROR: NXFFS initialization failed: %d\n", ret); } #endif } } #endif #if defined(CONFIG_INPUT_BUTTONS_LOWER) ret = btn_lower_initialize("/dev/buttons"); if (ret < 0) { syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); } #endif return ret; }