Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Adamg/flashdrivertest #90

wants to merge 9 commits into from

Conversation

b-atteryacid
Copy link

Flash Driver Improvements
Documentation

… 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
Copy link
Member

@cjchanx cjchanx left a 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.

@@ -58,6 +58,7 @@ bool Queue::SendToFront(Command& command)
if (xQueueSendToFront(rtQueueHandle, &command, DEFAULT_QUEUE_SEND_WAIT_TICKS) == pdPASS)
return true;


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup empty lines

@@ -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);
Copy link
Member

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

@@ -4,7 +4,7 @@
* Description : Flash interface task. Used for logging, writing to system
* state, and flash maintenance operations for the system.
******************************************************************************
*/
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup random spaces

@@ -15,173 +15,745 @@
#include "Data.h"
#include <cstring>


#define min(a,b) ((a)>(b) ? (b):(a))
Copy link
Member

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

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;
Copy link
Member

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

@@ -58,6 +58,7 @@ bool Queue::SendToFront(Command& command)
if (xQueueSendToFront(rtQueueHandle, &command, DEFAULT_QUEUE_SEND_WAIT_TICKS) == pdPASS)
return true;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this white space

Comment on lines 86 to 87


Copy link
Contributor

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;
}

Copy link
Contributor

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

@@ -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);
Copy link
Contributor

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

};

enum FLASH_LOG_TYPE { // at most 8 types
LTYPE_INVAL,
Copy link
Contributor

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

Comment on lines 26 to 35
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
Copy link
Contributor

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
};

Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants