Author Topic: Proposed correction/improvement - user file system and file protection  (Read 8449 times)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Hi All

I believe that I identified an error in the demo configuration as follows:

In config.h (processors not using sub-file operation) the definition of the final FLASH sector in the file system is:

    #define LAST_FILE_BLOCK    (unsigned short)((FILE_SYSTEM_SIZE)/FILE_GRANULARITY) // last block in our file system

However, when the internal file system is using multiple FLASH sectors for files (configuration dependent but can be used) this results in an invalid check, which means that trying to access a file which is beyond the end of the file system can result in an exception being generated (attempt to read from outside of the file system/FLASH area). Therefore I am proposing the following correction which has worked correctly in this test case:

    #define LAST_FILE_BLOCK    (unsigned short)((FILE_SYSTEM_SIZE)/SINGLE_FILE_SIZE) // last file block in our file system



Secondly I noticed that the favicon.ico was not being returned if the web browser requested it and the board was in the 'validation' phase. This was in fact the reason for the identification of the first problem, which would otherwise certainly have not been noticed (the browser will display the last one returned anyway). To solve this I removed the user file initialisation (code below) out of the fnValidatedInit() routine to the main initialisation code. This seems more logical to me.

#if defined INTERNAL_USER_FILES                                          // {37}{55}
    #if defined EMBEDDED_USER_FILES
        if (fnActivateEmbeddedUserFiles("1", USER_FILE_IN_INTERNAL_FLASH) == 0) { // if valid embedded user file space is found activate it, else use code embedded version
            fnEnterUserFiles((USER_FILE *)user_files);                   // user_files defined in app_user_files.h
        }
    #else
        fnEnterUserFiles((USER_FILE *)user_files);                       // user_files defined in app_user_files.h
    #endif
#endif



Regards

Mark


Offline alager

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Quote
out of the fnValidatedInit() routine to the main initialisation code.
  Can you give more details on the "main initialisation" location?

Thanks,
Aaron

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Hi Aaron

Originally the call to fnEnterUserFiles() was in the subroutine fnValidatedInit() and so was only called when the board was not in the validating state.

This is in the initialisation part of the application task which looked approximately like this:

if (fnGetOurParameters(0) == TEMPORARY_PARAM_SET) {
// in validation state
}
else {
    fnValidatedInit();
}
.. do more initialisation


Now it looks like this:

if (fnGetOurParameters(0) == TEMPORARY_PARAM_SET) {
// in validation state
}
else {
    fnValidatedInit();
}
fnEnterUserFiles();
.. do more initialisation


fnEnterUserFiles() is now always called during initialisation, irrespective of the validation phase.

regards

Mark