int nsh_archinitialize(void) { #if defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) int ret; #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { message("nsh_archinitialize: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { message("nsh_archinitialize: Start USB monitor: %d\n", ret); } #endif return OK; }
int board_app_initialize(uintptr_t arg) { int ret; /* Register I2C drivers on behalf of the I2C tool */ stm32_i2ctool(); #ifdef CONFIG_CAN /* Initialize CAN and register the CAN driver. */ ret = stm32_can_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret); } #endif #ifdef CONFIG_ADC /* Initialize ADC and register the ADC driver. */ ret = stm32_adc_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: stm32_adc_setup failed: %d\n", ret); } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); } #endif UNUSED(ret); return OK; }
int board_app_initialize(void) { #if defined(CONFIG_CAN) || defined(CONFIG_ADC) int ret; #endif #ifdef CONFIG_CAN /* Configure on-board CAN if CAN support has been selected. */ ret = stm32_can_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize CAN: %d\n", ret); } #endif #ifdef CONFIG_ADC /* Configure on-board ADCs if ADC support has been selected. */ ret = stm32_adc_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize ADC: %d\n", ret); } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); } #endif return OK; }
int nsh_archinitialize(void) { #ifdef HAVE_USBMONITOR int ret; /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); } #endif return OK; }
int board_app_initialize(void) { #if defined(HAVE_MMCSD) || defined(HAVE_USBHOST) int ret; #endif #ifdef HAVE_MMCSD /* Create the SDIO-based MMC/SD device */ syslog(LOG_INFO, "Create the MMC/SD device\n"); ret = lpc31_mmcsd_initialize(CONFIG_NSH_MMCSDSLOTNO); if (!sdio) { syslog(LOG_ERR, "ERROR: Failed to initialize SDIO slot %d\n", CONFIG_NSH_MMCSDSLOTNO, CONFIG_NSH_MMCSDMINOR); return -ENODEV; } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. lpc31_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ syslog(LOG_INFO, "Start USB host services\n"); ret = lpc31_usbhost_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB host services: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ syslog(LOG_ERR, "ERROR: Failed to start the USB monitor\n"); ret = usbmonitor_start(0, NULL); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); } #endif return OK; }
int nsh_archinitialize(void) { int ret; /* Initialize the LCD1602 and register the device as /dev/lcd1602 */ #ifdef CONFIG_LCD_LCD1602 ret = up_lcd1602_initialize(); if (ret == OK) #endif { /* Initialize SPI-based microSD */ ret = nsh_sdinitialize(); } if (ret == OK) { /* Initialize USB host */ ret = nsh_usbhostinitialize(); } if (ret == OK) { /* Initialize USB device */ ret = nsh_usbdevinitialize(); } #ifdef NSH_HAVE_USBMONITOR if (ret == OK) { /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); } #endif return ret; }
int board_app_initialize(uintptr_t arg) { int ret = OK; #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); } #endif #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ ret = stm32_pwm_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: stm32_pwm_setup() failed: %d\n", ret); } #endif #ifdef CONFIG_QENCODER /* Initialize and register the qencoder driver */ ret = stm32_qencoder_initialize("/dev/qe0", CONFIG_STM32F3DISCO_QETIMER); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the qencoder: %d\n", ret); return ret; } #endif return ret; }
int sam_bringup(void) { int ret; /* Register I2C drivers on behalf of the I2C tool */ sam_i2ctool(); #ifdef HAVE_NAND /* Initialize the NAND driver */ ret = sam_nand_automount(NAND_MINOR); if (ret < 0) { _err("ERROR: sam_nand_automount failed: %d\n", ret); } #endif #ifdef HAVE_AT25 /* Initialize the AT25 driver */ ret = sam_at25_automount(AT25_MINOR); if (ret < 0) { _err("ERROR: sam_at25_automount failed: %d\n", ret); } #endif #ifdef HAVE_HSMCI #ifdef CONFIG_SAMA5_HSMCI0 /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR); if (ret < 0) { _err("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, HSMCI0_MINOR, ret); } #ifdef CONFIG_SAMA5D4EK_HSMCI0_MOUNT else { /* REVISIT: A delay seems to be required here or the mount will fail. */ /* Mount the volume on HSMCI0 */ ret = mount(CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV, CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE, 0, NULL); if (ret < 0) { _err("ERROR: Failed to mount %s: %d\n", CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, errno); } } #endif #endif #ifdef CONFIG_SAMA5_HSMCI1 /* Initialize the HSMCI1 driver */ ret = sam_hsmci_initialize(HSMCI1_SLOTNO, HSMCI1_MINOR); if (ret < 0) { _err("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI1_SLOTNO, HSMCI1_MINOR, ret); } #ifdef CONFIG_SAMA5D4EK_HSMCI1_MOUNT else { /* REVISIT: A delay seems to be required here or the mount will fail. */ /* Mount the volume on HSMCI1 */ ret = mount(CONFIG_SAMA5D4EK_HSMCI1_MOUNT_BLKDEV, CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, CONFIG_SAMA5D4EK_HSMCI1_MOUNT_FSTYPE, 0, NULL); if (ret < 0) { _err("ERROR: Failed to mount %s: %d\n", CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, errno); } } #endif #endif #endif #ifdef HAVE_AUTOMOUNTER /* Initialize the auto-mounter */ sam_automount_initialize(); #endif #ifdef HAVE_ROMFS /* Create a ROM disk for the /etc filesystem */ ret = romdisk_register(CONFIG_SAMA5D4EK_ROMFS_ROMDISK_MINOR, romfs_img, NSECTORS(romfs_img_len), CONFIG_SAMA5D4EK_ROMFS_ROMDISK_SECTSIZE); if (ret < 0) { _err("ERROR: romdisk_register failed: %d\n", -ret); } else { /* Mount the file system */ ret = mount(CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME, CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT, "romfs", MS_RDONLY, NULL); if (ret < 0) { _err("ERROR: mount(%s,%s,romfs) failed: %d\n", CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME, CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT, errno); } } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = sam_usbhost_initialize(); if (ret != OK) { _err("ERROR: Failed to initialize USB host: %d\n", ret); } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(); if (ret != OK) { _err("ERROR: Failed to start the USB monitor: %d\n", ret); } #endif #ifdef HAVE_MAXTOUCH /* Initialize the touchscreen */ ret = sam_tsc_setup(0); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); } #endif #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ ret = sam_pwm_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_pwm_setup() failed: %d\n", ret); } #endif #ifdef CONFIG_ADC /* Initialize ADC and register the ADC driver. */ ret = sam_adc_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_adc_setup failed: %d\n", ret); } #endif #ifdef HAVE_WM8904 /* Configure WM8904 audio */ ret = sam_wm8904_initialize(0); if (ret != OK) { _err("ERROR: Failed to initialize WM8904 audio: %d\n", ret); } #endif #ifdef HAVE_AUDIO_NULL /* Configure the NULL audio device */ ret = sam_audio_null_initialize(0); if (ret != OK) { _err("ERROR: Failed to initialize the NULL audio device: %d\n", ret); } #endif #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ ret = mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { _err("ERROR: Failed to mount procfs at %s: %d\n", SAMA5_PROCFS_MOUNTPOINT, ret); } #endif /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities. */ UNUSED(ret); return OK; }
int stm32_bringup(void) { #ifdef HAVE_RTC_DRIVER FAR struct rtc_lowerhalf_s *lower; #endif int ret = OK; #ifdef CONFIG_ZEROCROSS /* Configure the zero-crossing driver */ stm32_zerocross_initialize(); #endif #ifdef CONFIG_RGBLED /* Configure the RGB LED driver */ stm32_rgbled_setup(); #endif #if defined(CONFIG_PCA9635PW) /* Initialize the PCA9635 chip */ ret = stm32_pca9635_initialize(); if (ret < 0) { sdbg("ERROR: stm32_pca9635_initialize failed: %d\n", ret); } #endif #ifdef HAVE_SDIO /* Initialize the SDIO block driver */ ret = stm32_sdio_initialize(); if (ret != OK) { fdbg("ERROR: Failed to initialize MMC/SD driver: %d\n", ret); return ret; } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { udbg("ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { udbg("ERROR: Failed to start USB monitor: %d\n", ret); return ret; } #endif #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32 lower-half RTC driver */ lower = stm32_rtc_lowerhalf(); if (!lower) { sdbg("ERROR: Failed to instantiate the RTC lower-half driver\n"); return -ENOMEM; } else { /* Bind the lower half driver and register the combined RTC driver * as /dev/rtc0 */ ret = rtc_initialize(0, lower); if (ret < 0) { sdbg("ERROR: Failed to bind/register the RTC driver: %d\n", ret); return ret; } } #endif #ifdef HAVE_ELF /* Initialize the ELF binary loader */ ret = elf_initialize(); if (ret < 0) { sdbg("ERROR: Initialization of the ELF loader failed: %d\n", ret); } #endif #ifdef CONFIG_MAX31855 ret = stm32_max31855initialize("/dev/temp0"); #endif #ifdef CONFIG_MAX6675 ret = stm32_max6675initialize("/dev/temp0"); #endif #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { sdbg("ERROR: Failed to mount procfs at %s: %d\n", STM32_PROCFS_MOUNTPOINT, ret); } #endif return ret; }
int sam_bringup(void) { #ifdef HAVE_S25FL1 FAR struct qspi_dev_s *qspi; #endif #if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV) FAR struct mtd_dev_s *mtd; #endif #if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263) FAR struct i2c_master_s *i2c; #endif #if defined(HAVE_S25FL1_CHARDEV) || defined(HAVE_PROGMEM_CHARDEV) char blockdev[18]; char chardev[12]; #endif int ret; /* Register I2C drivers on behalf of the I2C tool */ sam_i2ctool(); #if defined(HAVE_RTC_PCF85263) /* Get an instance of the TWIHS0 I2C interface */ i2c = sam_i2cbus_initialize(PCF85263_TWI_BUS); if (i2c == NULL) { SYSLOG("ERROR: sam_i2cbus_initialize(%d) failed\n", PCF85263_TWI_BUS); } else { /* Use the I2C interface to initialize the PCF2863 timer */ ret = pcf85263_rtc_initialize(i2c); if (ret < 0) { SYSLOG("ERROR: pcf85263_rtc_initialize() failed: %d\n", ret); } else { /* Synchronize the system time to the RTC time */ clock_synchronize(); } } #elif defined(HAVE_RTC_DSXXXX) /* Get an instance of the TWIHS0 I2C interface */ i2c = sam_i2cbus_initialize(DSXXXX_TWI_BUS); if (i2c == NULL) { SYSLOG("ERROR: sam_i2cbus_initialize(%d) failed\n", DSXXXX_TWI_BUS); } else { /* Use the I2C interface to initialize the DSXXXX timer */ ret = dsxxxx_rtc_initialize(i2c); if (ret < 0) { SYSLOG("ERROR: dsxxxx_rtc_initialize() failed: %d\n", ret); } else { /* Synchronize the system time to the RTC time */ clock_synchronize(); } } #endif #ifdef HAVE_MACADDR /* Read the Ethernet MAC address from the AT24 FLASH and configure the * Ethernet driver with that address. */ ret = sam_emac0_setmac(); if (ret < 0) { SYSLOG("ERROR: sam_emac0_setmac() failed: %d\n", ret); } #endif #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ ret = mount(NULL, SAMV71_PROCFS_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { SYSLOG("ERROR: Failed to mount procfs at %s: %d\n", SAMV71_PROCFS_MOUNTPOINT, ret); } #endif #ifdef HAVE_MTDCONFIG /* Create an AT24xx-based MTD configuration device for storage device * configuration information. */ ret = sam_at24config(); if (ret < 0) { SYSLOG("ERROR: sam_at24config() failed: %d\n", ret); } #endif #ifdef HAVE_HSMCI /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR); if (ret < 0) { SYSLOG("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, HSMCI0_MINOR, ret); } #ifdef CONFIG_SAMV71XULT_HSMCI0_MOUNT else { /* REVISIT: A delay seems to be required here or the mount will fail. */ /* Mount the volume on HSMCI0 */ ret = mount(CONFIG_SAMV71XULT_HSMCI0_MOUNT_BLKDEV, CONFIG_SAMV71XULT_HSMCI0_MOUNT_MOUNTPOINT, CONFIG_SAMV71XULT_HSMCI0_MOUNT_FSTYPE, 0, NULL); if (ret < 0) { SYSLOG("ERROR: Failed to mount %s: %d\n", CONFIG_SAMV71XULT_HSMCI0_MOUNT_MOUNTPOINT, errno); } } #endif /* CONFIG_SAMV71XULT_HSMCI0_MOUNT */ #endif /* HAVE_HSMCI */ #ifdef HAVE_AUTOMOUNTER /* Initialize the auto-mounter */ sam_automount_initialize(); #endif #ifdef HAVE_ROMFS /* Create a ROM disk for the /etc filesystem */ ret = romdisk_register(CONFIG_SAMV71XULT_ROMFS_ROMDISK_MINOR, romfs_img, NSECTORS(romfs_img_len), CONFIG_SAMV71XULT_ROMFS_ROMDISK_SECTSIZE); if (ret < 0) { SYSLOG("ERROR: romdisk_register failed: %d\n", -ret); } else { /* Mount the file system */ ret = mount(CONFIG_SAMV71XULT_ROMFS_ROMDISK_DEVNAME, CONFIG_SAMV71XULT_ROMFS_MOUNT_MOUNTPOINT, "romfs", MS_RDONLY, NULL); if (ret < 0) { SYSLOG("ERROR: mount(%s,%s,romfs) failed: %d\n", CONFIG_SAMV71XULT_ROMFS_ROMDISK_DEVNAME, CONFIG_SAMV71XULT_ROMFS_MOUNT_MOUNTPOINT, errno); } } #endif #ifdef HAVE_S25FL1 /* Create an instance of the SAMV71 QSPI device driver */ qspi = sam_qspi_initialize(0); if (!qspi) { SYSLOG("ERROR: sam_qspi_initialize failed\n"); } else { /* Use the QSPI device instance to initialize the * S25FL1 device. */ mtd = s25fl1_initialize(qspi, true); if (!mtd) { SYSLOG("ERROR: s25fl1_initialize failed\n"); } #ifdef HAVE_S25FL1_SMARTFS /* Configure the device with no partition support */ ret = smart_initialize(S25FL1_SMART_MINOR, mtd, NULL); if (ret != OK) { SYSLOG("ERROR: Failed to initialize SmartFS: %d\n", ret); } #elif defined(HAVE_S25FL1_NXFFS) /* Initialize to provide NXFFS on the S25FL1 MTD interface */ ret = nxffs_initialize(mtd); if (ret < 0) { SYSLOG("ERROR: NXFFS initialization failed: %d\n", ret); } /* Mount the file system at /mnt/s25fl1 */ ret = mount(NULL, "/mnt/s25fl1", "nxffs", 0, NULL); if (ret < 0) { SYSLOG("ERROR: Failed to mount the NXFFS volume: %d\n", errno); return ret; } #else /* if defined(HAVE_S25FL1_CHARDEV) */ /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(S25FL1_MTD_MINOR, mtd); if (ret < 0) { SYSLOG("ERROR: Failed to initialize the FTL layer: %d\n", ret); return ret; } /* Use the minor number to create device paths */ snprintf(blockdev, 18, "/dev/mtdblock%d", S25FL1_MTD_MINOR); snprintf(chardev, 12, "/dev/mtd%d", S25FL1_MTD_MINOR); /* Now create a character device on the block device */ ret = bchdev_register(blockdev, chardev, false); if (ret < 0) { SYSLOG("ERROR: bchdev_register %s failed: %d\n", chardev, ret); return ret; } #endif } #endif #ifdef HAVE_PROGMEM_CHARDEV /* Initialize the SAMV71 FLASH programming memory library */ sam_progmem_initialize(); /* Create an instance of the SAMV71 FLASH program memory device driver */ mtd = progmem_initialize(); if (!mtd) { SYSLOG("ERROR: progmem_initialize failed\n"); } /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(PROGMEM_MTD_MINOR, mtd); if (ret < 0) { SYSLOG("ERROR: Failed to initialize the FTL layer: %d\n", ret); return ret; } /* Use the minor number to create device paths */ snprintf(blockdev, 18, "/dev/mtdblock%d", PROGMEM_MTD_MINOR); snprintf(chardev, 12, "/dev/mtd%d", PROGMEM_MTD_MINOR); /* Now create a character device on the block device */ ret = bchdev_register(blockdev, chardev, false); if (ret < 0) { SYSLOG("ERROR: bchdev_register %s failed: %d\n", chardev, ret); return ret; } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = sam_usbhost_initialize(); if (ret != OK) { SYSLOG("ERROR: Failed to initialize USB host: %d\n", ret); } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { SYSLOG("ERROR: Failed to start the USB monitor: %d\n", ret); } #endif #ifdef HAVE_WM8904 /* Configure WM8904 audio */ ret = sam_wm8904_initialize(0); if (ret != OK) { SYSLOG("ERROR: Failed to initialize WM8904 audio: %d\n", ret); } #endif #ifdef HAVE_AUDIO_NULL /* Configure the NULL audio device */ ret = sam_audio_null_initialize(0); if (ret != OK) { SYSLOG("ERROR: Failed to initialize the NULL audio device: %d\n", ret); } #endif #ifdef HAVE_ELF /* Initialize the ELF binary loader */ SYSLOG("Initializing the ELF binary loader\n"); ret = elf_initialize(); if (ret < 0) { SYSLOG("ERROR: Initialization of the ELF loader failed: %d\n", ret); } #endif /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities. */ UNUSED(ret); return OK; }
int board_app_initialize(void) { #ifdef HAVE_SST25 FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; int ret; /* Configure SPI-based devices */ /* Get the SPI port */ syslog(LOG_INFO, "Initializing SPI port %d\n", CONFIG_SPARK_FLASH_SPI); spi = stm32_spibus_initialize(CONFIG_SPARK_FLASH_SPI); if (!spi) { syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n", CONFIG_SPARK_FLASH_SPI); return -ENODEV; } syslog(LOG_INFO, "Successfully initialized SPI port %d\n", CONFIG_SPARK_FLASH_SPI); /* Now bind the SPI interface to the SST25 SPI FLASH driver */ syslog(LOG_INFO, "Bind SPI to the SPI flash driver\n"); mtd = sst25_initialize(spi); if (!mtd) { syslog(LOG_ERR, "ERROR: Failed to bind SPI port %d to the SPI FLASH driver\n", CONFIG_SPARK_FLASH_SPI); } else { syslog(LOG_INFO, "Successfully bound SPI port %d to the SPI FLASH driver\n", CONFIG_SPARK_FLASH_SPI); } #ifndef CONFIG_SPARK_FLASH_PART /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(CONFIG_SPARK_FLASH_MINOR, mtd); if (ret < 0) { fdbg("ERROR: Initialize the FTL layer\n"); return ret; } #ifdef CONFIG_SPARK_MOUNT_FLASH char partname[16]; char mntpoint[16]; /* mount -t vfat /dev/mtdblock0 /mnt/p0 */ snprintf(partname, sizeof(partname), "/dev/mtdblock%d", CONFIG_SPARK_FLASH_MINOR); snprintf(mntpoint, sizeof(mntpoint)-1, CONFIG_SPARK_FLASH_MOUNT_POINT, CONFIG_SPARK_FLASH_MINOR); /* Mount the file system at /mnt/pn */ ret = mount(partname, mntpoint, "vfat", 0, NULL); if (ret < 0) { fdbg("ERROR: Failed to mount the FAT volume: %d\n", errno); return ret; } #endif #else { int partno; int partsize; int partoffset; const char *partstring = CONFIG_SPARK_FLASH_PART_LIST; const char *ptr; FAR struct mtd_dev_s *mtd_part; char partname[16]; char mntpoint[16]; /* Now create a partition on the FLASH device */ partno = CONFIG_SPARK_FLASH_MINOR; ptr = partstring; partoffset = 0; while (*ptr != '\0') { /* Get the partition size */ partsize = atoi(ptr); mtd_part = mtd_partition(mtd, partoffset, (partsize >> 2) * 16); partoffset += (partsize >> 2) * 16; /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(partno, mtd_part); if (ret < 0) { fdbg("ERROR: Initialize the FTL layer\n"); return ret; } snprintf(partname,sizeof(partname), "/dev/mtdblock%d", partno); snprintf(mntpoint,sizeof(mntpoint)-1, CONFIG_SPARK_FLASH_MOUNT_POINT, partno); /* Mount the file system at /mnt/pn */ ret = mount(partname, mntpoint, "vfat", 0, NULL); if (ret < 0) { fdbg("ERROR: Failed to mount the FAT volume: %d\n", errno); return ret; } /* Update the pointer to point to the next size in the list */ while ((*ptr >= '0') && (*ptr <= '9')) { ptr++; } if (*ptr == ',') { ptr++; } /* Increment the part number */ partno++; } } #endif /* CONFIG_SPARK_FLASH_PART */ #endif /* HAVE_SST25 */ #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); } #endif return OK; }
int board_app_initialize(void) { #if defined(HAVE_NAND) || defined(HAVE_AT25) || defined(HAVE_AT24) || \ defined(HAVE_HSMCI) || defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) ||\ defined(HAVE_WM8904) int ret; #endif #ifdef HAVE_NAND /* Initialize the NAND driver */ ret = sam_nand_automount(NAND_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_nand_automount failed: %d\n", ret); return ret; } #endif #ifdef HAVE_AT25 /* Initialize the AT25 driver */ ret = sam_at25_automount(AT25_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_at25_automount failed: %d\n", ret); return ret; } #endif #ifdef HAVE_AT24 /* Initialize the AT24 driver */ ret = sam_at24_automount(AT24_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_at24_automount failed: %d\n", ret); return ret; } #endif #ifdef HAVE_HSMCI #ifdef CONFIG_SAMA5_HSMCI0 /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, HSMCI0_MINOR, ret); return ret; } #endif #ifdef CONFIG_SAMA5_HSMCI1 /* Initialize the HSMCI1 driver */ ret = sam_hsmci_initialize(HSMCI1_SLOTNO, HSMCI1_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI1_SLOTNO, HSMCI1_MINOR, ret); return ret; } #endif #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = sam_usbhost_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { syslog(LOG_ERR, "ERROR: Start USB monitor: %d\n", ret); } #endif #ifdef HAVE_WM8904 /* Configure WM8904 audio */ ret = sam_wm8904_initialize(0); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize WM8904 audio: %d\n", ret); } #endif return OK; }
int nsh_archinitialize(void) { #if defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) int ret; #endif #if defined(CONFIG_STM32_SPI5) || defined(CONFIG_STM32_SPI4) FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; #endif #if defined(CONFIG_MTD_PARTITION_NAMES) FAR const char *partname = CONFIG_STM32F429I_DISCO_FLASH_PART_NAMES; #endif /* Configure SPI-based devices */ #ifdef CONFIG_STM32_SPI4 /* Get the SPI port */ message("nsh_archinitialize: Initializing SPI port 4\n"); spi = up_spiinitialize(4); if (!spi) { message("nsh_archinitialize: Failed to initialize SPI port 4\n"); return -ENODEV; } message("nsh_archinitialize: Successfully initialized SPI port 4\n"); /* Now bind the SPI interface to the SST25F064 SPI FLASH driver. This * is a FLASH device that has been added external to the board (i.e. * the board does not ship from STM with any on-board FLASH. */ #if defined(CONFIG_MTD) && defined(CONFIG_MTD_SST25XX) message("nsh_archinitialize: Bind SPI to the SPI flash driver\n"); mtd = sst25xx_initialize(spi); if (!mtd) { message("nsh_archinitialize: Failed to bind SPI port 4 to the SPI FLASH driver\n"); } else { message("nsh_archinitialize: Successfully bound SPI port 4 to the SPI FLASH driver\n"); #ifdef CONFIG_STM32F429I_DISCO_FLASH_PART { int partno; int partsize; int partoffset; const char *partstring = CONFIG_STM32F429I_DISCO_FLASH_PART_LIST; const char *ptr; FAR struct mtd_dev_s *mtd_part; char partref[4]; /* Now create a partition on the FLASH device */ partno = 0; ptr = partstring; partoffset = 0; while (*ptr != '\0') { /* Get the partition size */ partsize = atoi(ptr); mtd_part = mtd_partition(mtd, partoffset, (partsize>>2) * 16); partoffset += (partsize >> 2) * 16; #ifdef CONFIG_STM32F429I_DISCO_FLASH_CONFIG_PART /* Test if this is the config partition */ if (CONFIG_STM32F429I_DISCO_FLASH_CONFIG_PART_NUMBER == partno) { /* Register the partition as the config device */ mtdconfig_register(mtd_part); } else #endif { /* Now initialize a SMART Flash block device and bind it * to the MTD device. */ #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) sprintf(partref, "p%d", partno); smart_initialize(CONFIG_STM32F429I_DISCO_FLASH_MINOR, mtd_part, partref); #endif } /* Set the partition name */ #if defined(CONFIG_MTD_PARTITION_NAMES) mtd_setpartitionname(mtd_part, partname); /* Now skip to next name. We don't need to split the string here * because the MTD partition logic will only display names up to * the comma, thus allowing us to use a single static name * in the code. */ while (*partname != ',' && *partname != '\0') { /* Skip to next ',' */ partname++; } if (*partname == ',') { partname++; } #endif /* Update the pointer to point to the next size in the list */ while ((*ptr >= '0') && (*ptr <= '9')) { ptr++; } if (*ptr == ',') { ptr++; } /* Increment the part number */ partno++; } } #else /* CONFIG_STM32F429I_DISCO_FLASH_PART */ /* Configure the device with no partition support */ smart_initialize(CONFIG_STM32F429I_DISCO_FLASH_MINOR, mtd, NULL); #endif /* CONFIG_STM32F429I_DISCO_FLASH_PART */ } #endif /* CONFIG_MTD */ #endif /* CONFIG_STM32_SPI4 */ /* Create a RAM MTD device if configured */ #if defined(CONFIG_RAMMTD) && defined(CONFIG_STM32F429I_DISCO_RAMMTD) { uint8_t *start = (uint8_t *) kmalloc(CONFIG_STM32F429I_DISCO_RAMMTD_SIZE * 1024); mtd = rammtd_initialize(start, CONFIG_STM32F429I_DISCO_RAMMTD_SIZE * 1024); mtd->ioctl(mtd, MTDIOC_BULKERASE, 0); /* Now initialize a SMART Flash block device and bind it to the MTD device */ #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) smart_initialize(CONFIG_STM32F429I_DISCO_RAMMTD_MINOR, mtd, NULL); #endif } #endif /* CONFIG_RAMMTD && CONFIG_STM32F429I_DISCO_RAMMTD */ #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { message("nsh_archinitialize: Failed to initialize USB host: %d\n", ret); return ret; } #ifdef CONFIG_USBHOST_MSC /* Initialize the USB storage class */ ret = usbhost_storageinit(); if (ret != OK) { message("nsh_archinitialize: Failed to initialize USB host storage: %d\n", ret); return ret; } #endif #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { message("nsh_archinitialize: Start USB monitor: %d\n", ret); } #endif return OK; }
int nsh_archinitialize(void) { #if defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) int ret; #endif #ifdef CONFIG_STM32_SPI3 FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; #endif int ret; /* Configure SPI-based devices */ #ifdef CONFIG_STM32_SPI3 /* Get the SPI port */ message("nsh_archinitialize: Initializing SPI port 3\n"); spi = up_spiinitialize(3); if (!spi) { message("nsh_archinitialize: Failed to initialize SPI port 3\n"); return -ENODEV; } message("nsh_archinitialize: Successfully initialized SPI port 3\n"); /* Now bind the SPI interface to the M25P8 SPI FLASH driver */ #if defined(CONFIG_MTD) && defined(CONFIG_MIKROE_FLASH) message("nsh_archinitialize: Bind SPI to the SPI flash driver\n"); mtd = m25p_initialize(spi); if (!mtd) { message("nsh_archinitialize: Failed to bind SPI port 3 to the SPI FLASH driver\n"); } else { message("nsh_archinitialize: Successfully bound SPI port 3 to the SPI FLASH driver\n"); #ifdef CONFIG_MIKROE_FLASH_PART { int partno; int partsize; int partoffset; const char *partstring = CONFIG_MIKROE_FLASH_PART_LIST; const char *ptr; FAR struct mtd_dev_s *mtd_part; char partname[4]; /* Now create a partition on the FLASH device */ partno = 0; ptr = partstring; partoffset = 0; while (*ptr != '\0') { /* Get the partition size */ partsize = atoi(ptr); mtd_part = mtd_partition(mtd, partoffset, (partsize>>2)*16); partoffset += (partsize >> 2) * 16; #ifdef CONFIG_MIKROE_FLASH_CONFIG_PART /* Test if this is the config partition */ if (CONFIG_MIKROE_FLASH_CONFIG_PART_NUMBER == partno) { /* Register the partition as the config device */ mtdconfig_register(mtd_part); } else #endif { /* Now initialize a SMART Flash block device and bind it * to the MTD device. */ #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) sprintf(partname, "p%d", partno); smart_initialize(CONFIG_MIKROE_FLASH_MINOR, mtd_part, partname); #endif } /* Update the pointer to point to the next size in the list */ while ((*ptr >= '0') && (*ptr <= '9')) { ptr++; } if (*ptr == ',') { ptr++; } /* Increment the part number */ partno++; } #else /* CONFIG_MIKROE_FLASH_PART */ /* Configure the device with no partition support */ smart_initialize(CONFIG_MIKROE_FLASH_MINOR, mtd, NULL); #endif /* CONFIG_MIKROE_FLASH_PART */ } } /* Create a RAM MTD device if configured */ #if defined(CONFIG_RAMMTD) && defined(CONFIG_MIKROE_RAMMTD) { uint8_t *start = (uint8_t *) kmalloc(CONFIG_MIKROE_RAMMTD_SIZE * 1024); mtd = rammtd_initialize(start, CONFIG_MIKROE_RAMMTD_SIZE * 1024); mtd->ioctl(mtd, MTDIOC_BULKERASE, 0); /* Now initialize a SMART Flash block device and bind it to the MTD device */ #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) smart_initialize(CONFIG_MIKROE_RAMMTD_MINOR, mtd, NULL); #endif } #endif /* CONFIG_RAMMTD && CONFIG_MIKROE_RAMMTD */ #endif /* CONFIG_MTD */ #endif /* CONFIG_STM32_SPI3 */ /* Create the SPI FLASH MTD instance */ /* The M25Pxx is not a good media to implement a file system.. * its block sizes are too large */ /* Mount the SDIO-based MMC/SD block driver */ #ifdef NSH_HAVEMMCSD /* Bind the spi interface to the MMC/SD driver */ message("nsh_archinitialize: Bind SDIO to the MMC/SD driver, minor=%d\n", CONFIG_NSH_MMCSDMINOR); ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, spi); if (ret != OK) { message("nsh_archinitialize: Failed to bind SPI to the MMC/SD driver: %d\n", ret); } else { message("nsh_archinitialize: Successfully bound SPI to the MMC/SD driver\n"); } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { message("nsh_archinitialize: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { message("nsh_archinitialize: Start USB monitor: %d\n", ret); } #endif #ifdef CONFIG_LCD_MIO283QT2 /* Configure the TFT LCD module */ message("nsh_archinitialize: Initializing TFT LCD module\n"); ret = up_lcdinitialize(); if (ret != OK) { message("nsh_archinitialize: Failed to initialize TFT LCD module\n"); } #endif /* Configure the Audio sub-system if enabled and bind it to SPI 3 */ #ifdef CONFIG_AUDIO up_vs1053initialize(spi); #endif return OK; }
int board_app_initialize(uintptr_t arg) { #if defined(HAVE_NAND) || defined(HAVE_AT25) || defined(HAVE_HSMCI) || \ defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) || \\ defined(CONFIG_AJOYSTICK) || defined(CONFIG_FS_PROCFS) int ret; #endif #ifdef HAVE_NAND /* Initialize the NAND driver */ ret = sam_nand_automount(NAND_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_nand_automount failed: %d\n", ret); return ret; } #endif #ifdef HAVE_AT25 /* Initialize the AT25 driver */ ret = sam_at25_automount(AT25_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_at25_automount failed: %d\n", ret); return ret; } #endif #ifdef HAVE_HSMCI #ifdef CONFIG_SAMA5_HSMCI0 /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, HSMCI0_MINOR, ret); return ret; } #endif #ifdef CONFIG_SAMA5_HSMCI1 /* Initialize the HSMCI1 driver */ ret = sam_hsmci_initialize(HSMCI1_SLOTNO, HSMCI1_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI1_SLOTNO, HSMCI1_MINOR, ret); return ret; } #endif #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = sam_usbhost_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); } #endif #ifdef CONFIG_AJOYSTICK /* Initialize and register the joystick driver */ ret = sam_ajoy_initialization(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the joystick driver: %d\n", ret); return ret; } #endif #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ ret = mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n", SAMA5_PROCFS_MOUNTPOINT, ret); } #endif return OK; }
int nsh_archinitialize(void) { #if defined(HAVE_NAND) || defined(HAVE_AT25) || defined(HAVE_HSMCI) || \ defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) || defined(HAVE_WM8904) || \ defined(HAVE_AUTOMOUNTER) int ret; #endif #ifdef HAVE_NAND /* Initialize the NAND driver */ ret = sam_nand_automount(NAND_MINOR); if (ret < 0) { message("ERROR: sam_nand_automount failed: %d\n", ret); } #endif #ifdef HAVE_AT25 /* Initialize the AT25 driver */ ret = sam_at25_automount(AT25_MINOR); if (ret < 0) { message("ERROR: sam_at25_automount failed: %d\n", ret); } #endif #ifdef HAVE_HSMCI #ifdef CONFIG_SAMA5_HSMCI0 /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR); if (ret < 0) { message("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, HSMCI0_MINOR, ret); } #endif #ifdef CONFIG_SAMA5_HSMCI1 /* Initialize the HSMCI1 driver */ ret = sam_hsmci_initialize(HSMCI1_SLOTNO, HSMCI1_MINOR); if (ret < 0) { message("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI1_SLOTNO, HSMCI1_MINOR, ret); } #endif #endif #ifdef HAVE_AUTOMOUNTER /* Initialize the auto-mounter */ sam_automount_initialize(); #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = sam_usbhost_initialize(); if (ret != OK) { message("ERROR: Failed to initialize USB host: %d\n", ret); } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { message("ERROR: Failed to start the USB monitor: %d\n", ret); } #endif #ifdef HAVE_WM8904 /* Configure WM8904 audio */ ret = sam_wm8904_initialize(0); if (ret != OK) { message("ERROR: Failed to initialize WM8904 audio: %d\n", ret); } #endif #ifdef HAVE_AUDIO_NULL /* Configure the NULL audio device */ ret = sam_audio_null_initialize(0); if (ret != OK) { message("ERROR: Failed to initialize the NULL audio device: %d\n", ret); } #endif /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities. */ return OK; }
int board_app_initialize(uintptr_t arg) { #ifdef HAVE_RTC_DRIVER FAR struct rtc_lowerhalf_s *rtclower; #endif #if defined(HAVE_N25QXXX) FAR struct mtd_dev_s *mtd_temp; #endif #if defined(HAVE_N25QXXX_CHARDEV) char blockdev[18]; char chardev[12]; #endif int ret; (void)ret; #ifdef HAVE_PROC /* mount the proc filesystem */ syslog(LOG_INFO, "Mounting procfs to /proc\n"); ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d (%d)\n", ret, errno); return ret; } #endif #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32 lower-half RTC driver */ rtclower = stm32l4_rtc_lowerhalf(); if (!rtclower) { serr("ERROR: Failed to instantiate the RTC lower-half driver\n"); return -ENOMEM; } else { /* Bind the lower half driver and register the combined RTC driver * as /dev/rtc0 */ ret = rtc_initialize(0, rtclower); if (ret < 0) { serr("ERROR: Failed to bind/register the RTC driver: %d\n", ret); return ret; } } #endif #ifdef HAVE_N25QXXX /* Create an instance of the STM32L4 QSPI device driver */ g_qspi = stm32l4_qspi_initialize(0); if (!g_qspi) { _err("ERROR: stm32l4_qspi_initialize failed\n"); return ret; } else { /* Use the QSPI device instance to initialize the * N25QXXX device. */ mtd_temp = n25qxxx_initialize(g_qspi, true); if (!mtd_temp) { _err("ERROR: n25qxxx_initialize failed\n"); return ret; } g_mtd_fs = mtd_temp; #ifdef CONFIG_MTD_PARTITION { FAR struct mtd_geometry_s geo; off_t nblocks; /* Setup a partition of 256KiB for our file system. */ ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY, (unsigned long)(uintptr_t)&geo); if (ret < 0) { _err("ERROR: MTDIOC_GEOMETRY failed\n"); return ret; } nblocks = (256*1024) / geo.blocksize; mtd_temp = mtd_partition(g_mtd_fs, 0, nblocks); if (!mtd_temp) { _err("ERROR: mtd_partition failed\n"); return ret; } g_mtd_fs = mtd_temp; } #endif #ifdef HAVE_N25QXXX_SMARTFS /* Configure the device with no partition support */ ret = smart_initialize(N25QXXX_SMART_MINOR, g_mtd_fs, NULL); if (ret != OK) { _err("ERROR: Failed to initialize SmartFS: %d\n", ret); } #elif defined(HAVE_N25QXXX_NXFFS) /* Initialize to provide NXFFS on the N25QXXX MTD interface */ ret = nxffs_initialize(g_mtd_fs); if (ret < 0) { _err("ERROR: NXFFS initialization failed: %d\n", ret); } /* Mount the file system at /mnt/nxffs */ ret = mount(NULL, "/mnt/nxffs", "nxffs", 0, NULL); if (ret < 0) { _err("ERROR: Failed to mount the NXFFS volume: %d\n", errno); return ret; } #else /* if defined(HAVE_N25QXXX_CHARDEV) */ /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(N25QXXX_MTD_MINOR, g_mtd_fs); if (ret < 0) { _err("ERROR: Failed to initialize the FTL layer: %d\n", ret); return ret; } /* Use the minor number to create device paths */ snprintf(blockdev, 18, "/dev/mtdblock%d", N25QXXX_MTD_MINOR); snprintf(chardev, 12, "/dev/mtd%d", N25QXXX_MTD_MINOR); /* Now create a character device on the block device */ /* NOTE: for this to work, you will need to make sure that * CONFIG_FS_WRITABLE is set in the config. It's not a user- * visible setting, but you can make it set by selecting an * arbitrary writable file system (you don't have to actually * use it, just select it so that the block device created via * ftl_initialize() will be writable). */ ret = bchdev_register(blockdev, chardev, false); if (ret < 0) { _err("ERROR: bchdev_register %s failed: %d\n", chardev, ret); return ret; } #endif } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32l4_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32l4_usbhost_initialize(); if (ret != OK) { udbg("ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { udbg("ERROR: Failed to start USB monitor: %d\n", ret); return ret; } #endif return OK; }
int board_app_initialize(void) { #if defined(CONFIG_STM32_SPI4) FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; FAR struct mtd_geometry_s geo; #endif #if defined(CONFIG_MTD_PARTITION_NAMES) FAR const char *partname = CONFIG_STM32F429I_DISCO_FLASH_PART_NAMES; #endif #if defined(CONFIG_MTD) && defined(CONFIG_MTD_SST25XX) int ret; #elif defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) int ret; #endif /* Configure SPI-based devices */ #ifdef CONFIG_STM32_SPI4 /* Get the SPI port */ syslog(LOG_INFO, "Initializing SPI port 4\n"); spi = stm32_spibus_initialize(4); if (!spi) { syslog(LOG_ERR, "ERROR: Failed to initialize SPI port 4\n"); return -ENODEV; } syslog(LOG_INFO, "Successfully initialized SPI port 4\n"); /* Now bind the SPI interface to the SST25F064 SPI FLASH driver. This * is a FLASH device that has been added external to the board (i.e. * the board does not ship from STM with any on-board FLASH. */ #if defined(CONFIG_MTD) && defined(CONFIG_MTD_SST25XX) syslog(LOG_INFO, "Bind SPI to the SPI flash driver\n"); mtd = sst25xx_initialize(spi); if (!mtd) { syslog(LOG_ERR, "ERROR: Failed to bind SPI port 4 to the SPI FLASH driver\n"); } else { syslog(LOG_INFO, "Successfully bound SPI port 4 to the SPI FLASH driver\n"); /* Get the geometry of the FLASH device */ ret = mtd->ioctl(mtd, MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&geo)); if (ret < 0) { fdbg("ERROR: mtd->ioctl failed: %d\n", ret); return ret; } #ifdef CONFIG_STM32F429I_DISCO_FLASH_PART { int partno; int partsize; int partoffset; int partszbytes; int erasesize; const char *partstring = CONFIG_STM32F429I_DISCO_FLASH_PART_LIST; const char *ptr; FAR struct mtd_dev_s *mtd_part; char partref[4]; /* Now create a partition on the FLASH device */ partno = 0; ptr = partstring; partoffset = 0; /* Get the Flash erase size */ erasesize = geo.erasesize; while (*ptr != '\0') { /* Get the partition size */ partsize = atoi(ptr); partszbytes = (partsize << 10); /* partsize is defined in KB */ /* Check if partition size is bigger then erase block */ if (partszbytes < erasesize) { fdbg("ERROR: Partition size is lesser than erasesize!\n"); return -1; } /* Check if partition size is multiple of erase block */ if ((partszbytes % erasesize) != 0) { fdbg("ERROR: Partition size is not multiple of erasesize!\n"); return -1; } mtd_part = mtd_partition(mtd, partoffset, partszbytes / erasesize); partoffset += partszbytes / erasesize; #ifdef CONFIG_STM32F429I_DISCO_FLASH_CONFIG_PART /* Test if this is the config partition */ if (CONFIG_STM32F429I_DISCO_FLASH_CONFIG_PART_NUMBER == partno) { /* Register the partition as the config device */ mtdconfig_register(mtd_part); } else #endif { /* Now initialize a SMART Flash block device and bind it * to the MTD device. */ #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) sprintf(partref, "p%d", partno); smart_initialize(CONFIG_STM32F429I_DISCO_FLASH_MINOR, mtd_part, partref); #endif } #if defined(CONFIG_MTD_PARTITION_NAMES) /* Set the partition name */ if (mtd_part == NULL) { dbg("Error: failed to create partition %s\n", partname); return -1; } mtd_setpartitionname(mtd_part, partname); /* Now skip to next name. We don't need to split the string here * because the MTD partition logic will only display names up to * the comma, thus allowing us to use a single static name * in the code. */ while (*partname != ',' && *partname != '\0') { /* Skip to next ',' */ partname++; } if (*partname == ',') { partname++; } #endif /* Update the pointer to point to the next size in the list */ while ((*ptr >= '0') && (*ptr <= '9')) { ptr++; } if (*ptr == ',') { ptr++; } /* Increment the part number */ partno++; } } #else /* CONFIG_STM32F429I_DISCO_FLASH_PART */ /* Configure the device with no partition support */ smart_initialize(CONFIG_STM32F429I_DISCO_FLASH_MINOR, mtd, NULL); #endif /* CONFIG_STM32F429I_DISCO_FLASH_PART */ } #endif /* CONFIG_MTD */ #endif /* CONFIG_STM32_SPI4 */ /* Create a RAM MTD device if configured */ #if defined(CONFIG_RAMMTD) && defined(CONFIG_STM32F429I_DISCO_RAMMTD) { uint8_t *start = (uint8_t *) kmm_malloc(CONFIG_STM32F429I_DISCO_RAMMTD_SIZE * 1024); mtd = rammtd_initialize(start, CONFIG_STM32F429I_DISCO_RAMMTD_SIZE * 1024); mtd->ioctl(mtd, MTDIOC_BULKERASE, 0); /* Now initialize a SMART Flash block device and bind it to the MTD device */ #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) smart_initialize(CONFIG_STM32F429I_DISCO_RAMMTD_MINOR, mtd, NULL); #endif } #endif /* CONFIG_RAMMTD && CONFIG_STM32F429I_DISCO_RAMMTD */ #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); } #endif return OK; }
int board_app_initialize(uintptr_t arg) { #if defined (HAVE_USBDEV) || defined(HAVE_HSMCI) || defined (HAVE_PROC) || \ defined(HAVE_USBMONITOR) int ret; #endif #ifdef HAVE_USBDEV syslog(LOG_INFO, "Registering CDC/ACM serial driver\n"); ret = cdcacm_initialize(CONFIG_SAM4S_XPLAINED_PRO_CDCACM_DEVMINOR, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to create the CDC/ACM serial device: %d (%d)\n", ret, errno); return ret; } #endif #ifdef HAVE_HSMCI /* Initialize the HSMCI driver */ syslog(LOG_INFO, "initializing HSMCI\n"); ret = sam_hsmci_initialize(); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize() failed: %d (%d)\n", ret, errno); return ret; } #endif #ifdef HAVE_PROC /* mount the proc filesystem */ syslog(LOG_INFO, "Mounting procfs to /proc\n"); ret = mount(NULL, "/proc", "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d (%d)\n", ret, errno); return ret; } #endif #if HAVE_HSMCI syslog(LOG_INFO, "Mounting /dev/mmcsd0 to /fat\n"); ret = mount("/dev/mmcsd0", "/fat", "vfat", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount the FAT filesystem: %d (%d)\n", ret, errno); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ syslog(LOG_INFO, "Starting USB Monitor\n"); ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d (%d)\n", ret, errno); return ret; } #endif return OK; }
int sam_bringup(void) { #ifdef HAVE_PROGMEM_CHARDEV FAR struct mtd_dev_s *mtd; char blockdev[18]; char chardev[12]; #endif int ret; /* Register I2C drivers on behalf of the I2C tool */ sam_i2ctool(); #ifdef HAVE_MACADDR /* Read the Ethernet MAC address from the AT24 FLASH and configure the * Ethernet driver with that address. */ ret = sam_emac0_setmac(); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_emac0_setmac() failed: %d\n", ret); } #endif #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ ret = mount(NULL, SAME70_PROCFS_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n", SAME70_PROCFS_MOUNTPOINT, ret); } #endif #ifdef HAVE_MTDCONFIG /* Create an AT24xx-based MTD configuration device for storage device * configuration information. */ ret = sam_at24config(); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_at24config() failed: %d\n", ret); } #endif #ifdef HAVE_HSMCI /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, HSMCI0_MINOR, ret); } #ifdef CONFIG_SAME70XPLAINED_HSMCI0_MOUNT else { /* REVISIT: A delay seems to be required here or the mount will fail. */ /* Mount the volume on HSMCI0 */ ret = mount(CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_BLKDEV, CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_MOUNTPOINT, CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_FSTYPE, 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n", CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_MOUNTPOINT, errno); } } #endif /* CONFIG_SAME70XPLAINED_HSMCI0_MOUNT */ #endif /* HAVE_HSMCI */ #ifdef HAVE_AUTOMOUNTER /* Initialize the auto-mounter */ sam_automount_initialize(); #endif #ifdef HAVE_ROMFS /* Create a ROM disk for the /etc filesystem */ ret = romdisk_register(CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_MINOR, romfs_img, NSECTORS(romfs_img_len), CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_SECTSIZE); if (ret < 0) { syslog(LOG_ERR, "ERROR: romdisk_register failed: %d\n", -ret); } else { /* Mount the file system */ ret = mount(CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_DEVNAME, CONFIG_SAME70XPLAINED_ROMFS_MOUNT_MOUNTPOINT, "romfs", MS_RDONLY, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: mount(%s,%s,romfs) failed: %d\n", CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_DEVNAME, CONFIG_SAME70XPLAINED_ROMFS_MOUNT_MOUNTPOINT, errno); } } #endif #ifdef HAVE_PROGMEM_CHARDEV /* Initialize the SAME70 FLASH programming memory library */ sam_progmem_initialize(); /* Create an instance of the SAME70 FLASH program memory device driver */ mtd = progmem_initialize(); if (!mtd) { syslog(LOG_ERR, "ERROR: progmem_initialize failed\n"); } /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(PROGMEM_MTD_MINOR, mtd); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", ret); return ret; } /* Use the minor number to create device paths */ snprintf(blockdev, 18, "/dev/mtdblock%d", PROGMEM_MTD_MINOR); snprintf(chardev, 12, "/dev/mtd%d", PROGMEM_MTD_MINOR); /* Now create a character device on the block device */ ret = bchdev_register(blockdev, chardev, false); if (ret < 0) { syslog(LOG_ERR, "ERROR: bchdev_register %s failed: %d\n", chardev, ret); return ret; } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = sam_usbhost_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start the USB monitor: %d\n", ret); } #endif #ifdef CONFIG_SAMV7_MCAN /* Initialize CAN and register the CAN driver. */ ret = sam_can_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_can_setup failed: %d\n", ret); } #endif #ifdef HAVE_ELF /* Initialize the ELF binary loader */ syslog(LOG_ERR, "Initializing the ELF binary loader\n"); ret = elf_initialize(); if (ret < 0) { syslog(LOG_ERR, "ERROR: Initialization of the ELF loader failed: %d\n", ret); } #endif #if defined(CONFIG_SAMV7_DAC0) || defined(CONFIG_SAMV7_DAC1) ret = sam_dacdev_initialize(); if (ret < 0) { syslog(LOG_ERR, "ERROR: Initialization of the DAC module failed: %d\n", ret); } #endif /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities. */ UNUSED(ret); return OK; }
int sam_bringup(void) { int ret; #ifdef HAVE_MACADDR /* Read the Ethernet MAC address from the AT24 FLASH and configure the * Ethernet driver with that address. */ ret = sam_emac0_setmac(); if (ret < 0) { SYSLOG("ERROR: sam_emac0_setmac() failed: %d\n", ret); } #endif #ifdef HAVE_MTDCONFIG /* Create an AT24xx-based MTD configuration device for storage device * configuration information. */ ret = sam_at24config(); if (ret < 0) { SYSLOG("ERROR: sam_at24config() failed: %d\n", ret); } #endif #ifdef HAVE_HSMCI /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR); if (ret < 0) { SYSLOG("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, HSMCI0_MINOR, ret); } #ifdef CONFIG_SAMV71XULT_HSMCI0_MOUNT else { /* REVISIT: A delay seems to be required here or the mount will fail. */ /* Mount the volume on HSMCI0 */ ret = mount(CONFIG_SAMV71XULT_HSMCI0_MOUNT_BLKDEV, CONFIG_SAMV71XULT_HSMCI0_MOUNT_MOUNTPOINT, CONFIG_SAMV71XULT_HSMCI0_MOUNT_FSTYPE, 0, NULL); if (ret < 0) { SYSLOG("ERROR: Failed to mount %s: %d\n", CONFIG_SAMV71XULT_HSMCI0_MOUNT_MOUNTPOINT, errno); } } #endif /* CONFIG_SAMV71XULT_HSMCI0_MOUNT */ #endif /* HAVE_HSMCI */ #ifdef HAVE_AUTOMOUNTER /* Initialize the auto-mounter */ sam_automount_initialize(); #endif #ifdef HAVE_ROMFS /* Create a ROM disk for the /etc filesystem */ ret = romdisk_register(CONFIG_SAMV71XULT_ROMFS_ROMDISK_MINOR, romfs_img, NSECTORS(romfs_img_len), CONFIG_SAMV71XULT_ROMFS_ROMDISK_SECTSIZE); if (ret < 0) { SYSLOG("ERROR: romdisk_register failed: %d\n", -ret); } else { /* Mount the file system */ ret = mount(CONFIG_SAMV71XULT_ROMFS_ROMDISK_DEVNAME, CONFIG_SAMV71XULT_ROMFS_MOUNT_MOUNTPOINT, "romfs", MS_RDONLY, NULL); if (ret < 0) { SYSLOG("ERROR: mount(%s,%s,romfs) failed: %d\n", CONFIG_SAMV71XULT_ROMFS_ROMDISK_DEVNAME, CONFIG_SAMV71XULT_ROMFS_MOUNT_MOUNTPOINT, errno); } } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = sam_usbhost_initialize(); if (ret != OK) { SYSLOG("ERROR: Failed to initialize USB host: %d\n", ret); } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { SYSLOG("ERROR: Failed to start the USB monitor: %d\n", ret); } #endif #ifdef HAVE_WM8904 /* Configure WM8904 audio */ ret = sam_wm8904_initialize(0); if (ret != OK) { SYSLOG("ERROR: Failed to initialize WM8904 audio: %d\n", ret); } #endif #ifdef HAVE_AUDIO_NULL /* Configure the NULL audio device */ ret = sam_audio_null_initialize(0); if (ret != OK) { SYSLOG("ERROR: Failed to initialize the NULL audio device: %d\n", ret); } #endif #ifdef HAVE_ELF /* Initialize the ELF binary loader */ SYSLOG("Initializing the ELF binary loader\n"); ret = elf_initialize(); if (ret < 0) { SYSLOG("ERROR: Initialization of the ELF loader failed: %d\n", ret); } #endif /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities. */ UNUSED(ret); return OK; }