Skip to content
Snippets Groups Projects

First implementation of file IO via libff in epicardium & pycarddium

Merged swym requested to merge swym/firmware:fat into master
4 unresolved threads

NYI: ioctls

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 /*
  • Author Maintainer

    ugh, totally overlooked that license. Being based on micropython's file.c from their unix port, should I just add a copyright note and leave the license header intact?

  • Please register or sign in to reply
  • swym added 1 commit

    added 1 commit

    Compare with previous version

  • 206 {
    207 struct FatObject *o = NULL;
    208 const char *mode_s = modeString;
    209 int i;
    210 int mode = 0;
    211
    212 //find free object to use
    213 for (i = 0; i < EPIC_FAT_MAX_OPENED; ++i) {
    214 if (s_openedObjects[i].type == FO_Nil) {
    215 break;
    216 }
    217 }
    218 if (i == EPIC_FAT_MAX_OPENED) {
    219 return -fresult_to_errno_table[FR_TOO_MANY_OPEN_FILES];
    220 }
    221
  • 164 case 'b':
    165 type = &mp_type_fat_fileio;
    166 break;
    167 #endif
    168 case 't':
    169 type = &mp_type_fat_textio;
    170 break;
    171 }
    172 }
    173
    174 pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t);
    175 o->base.type = type;
    176
    177 const char *fname = mp_obj_str_get_str(args[0].u_obj);
    178 int res = epic_open(fname, modeString);
    179 if (1 || res < 0) {
  • schneider
  • close() is not implemented yet, so it will run out of fds after 16 open() calls.

    • As close() and flush() are NOPs at the moment, writing to a file will likely fail as the buffer is not flushed to the flash.

      The internal flash has a page size of 4k while fatfs assumes a 512 byte sector. I'm not sure if it wise to change that, but it means that ff13 needs to emit a CTRL_SYNC ioctrl, which it does when closing a file, I guess.

      Edited by schneider
    • Author Maintainer

      it does, see diskio.c:219

    • Please register or sign in to reply
  • I tried to get an import working and tried this:

    • Stubbed mp_import_stat() to always return MP_IMPORT_STAT_FILE
    • Removed mp_lexer_new_from_file
    • Set MICROPY_VFS and MICROPY_READER_VFS
    • Added extmod/vfs_reader.c and extmod/vfs.c

    Result:

    >>> import foo.py
    Traceback (most recent call last):
      File "<stdin>", in <module>
    OSError: 1

    Yeah, does not work that way ;)

  • @swym showed me what is necessary for getting import working, IIRC it is actually not too difficult; the necessary parts can be ripped out of the VFS implementation for the most part. I guess we'll take a look this evening. I'm excited :)

  • swym added 1 commit

    added 1 commit

    • 79704a51 - First implementation of file IO via libff in epicardium & pycarddium

    Compare with previous version

  • swym added 1 commit

    added 1 commit

    • d6d0ef31 - First implementation of file IO via libff in epicardium & pycarddium

    Compare with previous version

  • swym added 9 commits

    added 9 commits

    • d6d0ef31...f54e3c0e - 8 commits from branch card10:master
    • 287ae82e - First implementation of file IO via libff in epicardium & pycarddium

    Compare with previous version

  • merged

  • Please register or sign in to reply
    Loading