-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adamg/flashdrivertest #90
base: master
Are you sure you want to change the base?
Conversation
… speed and decrease flash usage. Pressure transducer samples and logs to flash at 1kHz, but only currently transmits every 50 pressure transducer logs. Other sensors log to flash every 40ms. Added debug logs to change logging rate, debug timing messages, etc. New page offset flash recovery for hardfaults.
… for PTC, baro, gps, and imu. Not every PTC log results in a telemetry send.
- Flash Task secondary queue for priority messages - Stops logging when flash full - Recovers and resumes from last written flash page on reset - Command "rstflsh <num>" to erase num sectors and start at beginning of log space
- Fixed bug where rstflsh would not reset flash page offset storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor the flash logging functionality into a new class / object that initializes at a specific sector offset for a specific size (probably in sectors) as parameters. As a rough example make it an object somewhat similar to SimpleDualSectorStorage in how it wraps flash functionality (in FlashTask you create one object of this new FlashLogStorage and interface with it using that object).
This would help contain all the functionality in one class, make it easier to move to other boards, and use.
Components/Core/Queue.cpp
Outdated
@@ -58,6 +58,7 @@ bool Queue::SendToFront(Command& command) | |||
if (xQueueSendToFront(rtQueueHandle, &command, DEFAULT_QUEUE_SEND_WAIT_TICKS) == pdPASS) | |||
return true; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup empty lines
Components/Flash/Driver/w25qxx.hpp
Outdated
@@ -96,6 +96,7 @@ extern "C" | |||
void W25qxx_WritePage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_PageSize); | |||
void W25qxx_WriteSector(uint8_t *pBuffer, uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_SectorSize); | |||
void W25qxx_WriteBlock(uint8_t *pBuffer, uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_BlockSize); | |||
void W25qxx_WritePageScary(uint8_t *pBuffer, uint32_t Page_Address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change IDE to 4-space tabs, get rid of this function declaration unless it's used somewhere
Components/Flash/FlashTask.cpp
Outdated
@@ -4,7 +4,7 @@ | |||
* Description : Flash interface task. Used for logging, writing to system | |||
* state, and flash maintenance operations for the system. | |||
****************************************************************************** | |||
*/ | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup random spaces
Components/Flash/FlashTask.cpp
Outdated
@@ -15,173 +15,745 @@ | |||
#include "Data.h" | |||
#include <cstring> | |||
|
|||
|
|||
#define min(a,b) ((a)>(b) ? (b):(a)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Macros should be all caps
Components/Flash/FlashTask.cpp
Outdated
FlashTask::FlashTask() : Task(FLASH_TASK_QUEUE_DEPTH_OBJS) { | ||
logbufA = (uint8_t*) soar_malloc(FLASH_HEAP_BUF_SIZE); | ||
logbufB = (uint8_t*) soar_malloc(FLASH_HEAP_BUF_SIZE); | ||
currbuf = logbufA; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert from tabs to 4-spaces
Components/Core/Queue.cpp
Outdated
@@ -58,6 +58,7 @@ bool Queue::SendToFront(Command& command) | |||
if (xQueueSendToFront(rtQueueHandle, &command, DEFAULT_QUEUE_SEND_WAIT_TICKS) == pdPASS) | |||
return true; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this white space
Components/Flash/Driver/SPIFlash.hpp
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this white space
@@ -640,6 +640,8 @@ void W25qxx_WriteByte(uint8_t pBuffer, uint32_t WriteAddr_inBytes) | |||
#endif | |||
w25qxx.Lock = 0; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove one line from this whitespace
Components/Flash/Driver/w25qxx.hpp
Outdated
@@ -96,6 +96,7 @@ extern "C" | |||
void W25qxx_WritePage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_PageSize); | |||
void W25qxx_WriteSector(uint8_t *pBuffer, uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_SectorSize); | |||
void W25qxx_WriteBlock(uint8_t *pBuffer, uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_BlockSize); | |||
void W25qxx_WritePageScary(uint8_t *pBuffer, uint32_t Page_Address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the name. Dont have it as Write scary page, unless it means something
Components/Flash/Inc/FlashTask.hpp
Outdated
}; | ||
|
||
enum FLASH_LOG_TYPE { // at most 8 types | ||
LTYPE_INVAL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the first one explicitly equals to 0
Components/Flash/Inc/FlashTask.hpp
Outdated
WRITE_DATA_TO_FLASH = 0x01, // The top 3 bits of this contain the ID of the log type to be logged | ||
DUMP_FLASH_DATA = 0x02, | ||
ERASE_ALL_FLASH = 0x03, | ||
GET_FLASH_OFFSET = 0x04, | ||
FLASH_DUMP_AT = 0x05, | ||
FLASH_RESET_AND_ERASE = 0x06, | ||
GET_LOGS_PAST_SECOND = 0x07, | ||
GET_PAGE_OFFSET = 0x08, | ||
FLASH_READ_FIRST_LOGS = 0x09, | ||
TOG_BUFLOGS = 0x0A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you dont have to specify the number after the first one. Might make the code look cleaner.
GET_LOGS_PAST_SECOND = 0x07, | ||
GET_PAGE_OFFSET = 0x08, | ||
FLASH_READ_FIRST_LOGS = 0x09, | ||
TOG_BUFLOGS = 0x0A | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write a comment here saying these are the different log types
Cleaned up whitespace and switched to 4-space tabs Removed unused function declaration Cleaned up values of some flash enums
Flash Driver Improvements
Documentation