static int nor_device_init(nor_device_t *_dev) { nor_prepare(&_dev->mtd); SET_REG16(NOR + NOR_COMMAND, COMMAND_UNLOCK); SET_REG16(NOR + LOCK, LOCK_UNLOCK); SET_REG16(NOR + NOR_COMMAND, COMMAND_IDENTIFY); GET_REG16(NOR); GET_REG16(NOR); _dev->vendor = GET_REG16(NOR + VENDOR); _dev->device = GET_REG16(NOR + DEVICE); SET_REG16(NOR + NOR_COMMAND, COMMAND_LOCK); SET_REG16(NOR, DATA_MODE); GET_REG16(NOR); GET_REG16(NOR); if(_dev->vendor == 0) { bufferPrintf("NOR not detected.\n"); return -1; } nor_finish(&_dev->mtd); bufferPrintf("NOR vendor=%x, device=%x\r\n", _dev->vendor, _dev->device); return mtd_init(&_dev->mtd); }
static void swupdate_init(struct swupdate_cfg *sw) { /* Initialize internal tree to store configuration */ memset(sw, 0, sizeof(*sw)); LIST_INIT(&sw->images); LIST_INIT(&sw->hardware); LIST_INIT(&sw->scripts); LIST_INIT(&sw->bootscripts); LIST_INIT(&sw->bootloader); LIST_INIT(&sw->extprocs); sw->globals.cert_purpose = SSL_PURPOSE_DEFAULT; /* Create directories for scripts */ create_directory(SCRIPTS_DIR_SUFFIX); create_directory(DATADST_DIR_SUFFIX); if (atexit(swupdate_cleanup) != 0) { TRACE("Cannot setup SWUpdate cleanup on exit"); } #ifdef CONFIG_MTD mtd_init(); ubi_init(); #endif }
static int _mount(vfs_mount_t *mountp) { littlefs_desc_t *fs = mountp->private_data; mutex_init(&fs->lock); mutex_lock(&fs->lock); DEBUG("littlefs: mount: mountp=%p\n", (void *)mountp); if (!fs->config.block_count) { fs->config.block_count = fs->dev->sector_count - fs->base_addr; } if (!fs->config.block_size) { fs->config.block_size = fs->dev->page_size * fs->dev->pages_per_sector; } if (!fs->config.prog_size) { fs->config.prog_size = fs->dev->page_size; } if (!fs->config.read_size) { fs->config.read_size = fs->dev->page_size; } fs->config.lookahead = LITTLEFS_LOOKAHEAD_SIZE; fs->config.lookahead_buffer = fs->lookahead_buf; fs->config.context = fs; fs->config.read = _dev_read; fs->config.prog = _dev_write; fs->config.erase = _dev_erase; fs->config.sync = _dev_sync; #if LITTLEFS_FILE_BUFFER_SIZE fs->config.file_buffer = fs->file_buf; #endif #if LITTLEFS_READ_BUFFER_SIZE fs->config.read_buffer = fs->read_buf; #endif #if LITTLEFS_PROG_BUFFER_SIZE fs->config.prog_buffer = fs->prog_buf; #endif mtd_init(fs->dev); int ret = lfs_mount(&fs->fs, &fs->config); if (ret < 0) { DEBUG("littlefs: formatting\n"); ret = lfs_format(&fs->fs, &fs->config); if (ret >= 0) { DEBUG("littlefs: mounting\n"); ret = lfs_mount(&fs->fs, &fs->config); } } mutex_unlock(&fs->lock); return littlefs_err_to_errno(ret); }
int mulle_nor_init(void) { int res = mtd_init(mtd0); if (res >= 0) { /* Register DevFS node */ devfs_register(&mulle_nor_devfs); } return res; }
static void swupdate_init(struct swupdate_cfg *sw) { /* Initialize internal tree to store configuration */ memset(sw, 0, sizeof(*sw)); LIST_INIT(&sw->images); LIST_INIT(&sw->partitions); LIST_INIT(&sw->hardware); LIST_INIT(&sw->scripts); LIST_INIT(&sw->uboot); /* Create directories for scripts */ mkdir(SCRIPTS_DIR, 0777); mkdir(DATASRC_DIR, 0777); mkdir(DATADST_DIR, 0777); #ifdef CONFIG_MTD mtd_init(); ubi_init(); #endif }