mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-06 16:03:58 -04:00
AP_Logger: fix logging on 256Mbit flash chips
This commit is contained in:
parent
9456fe4d70
commit
dec5b97275
@ -11,7 +11,7 @@ extern AP_HAL::HAL& hal;
|
|||||||
|
|
||||||
// the last page holds the log format in first 4 bytes. Please change
|
// the last page holds the log format in first 4 bytes. Please change
|
||||||
// this if (and only if!) the low level format changes
|
// this if (and only if!) the low level format changes
|
||||||
#define DF_LOGGING_FORMAT 0x19012019
|
#define DF_LOGGING_FORMAT 0x1901201A
|
||||||
|
|
||||||
AP_Logger_Block::AP_Logger_Block(AP_Logger &front, LoggerMessageWriter_DFLogStart *writer) :
|
AP_Logger_Block::AP_Logger_Block(AP_Logger &front, LoggerMessageWriter_DFLogStart *writer) :
|
||||||
writebuf(0),
|
writebuf(0),
|
||||||
@ -464,20 +464,20 @@ uint32_t AP_Logger_Block::find_last_page(void)
|
|||||||
uint32_t look;
|
uint32_t look;
|
||||||
uint32_t bottom = 1;
|
uint32_t bottom = 1;
|
||||||
uint32_t top = df_NumPages;
|
uint32_t top = df_NumPages;
|
||||||
uint32_t look_hash;
|
uint64_t look_hash;
|
||||||
uint32_t bottom_hash;
|
uint64_t bottom_hash;
|
||||||
uint32_t top_hash;
|
uint64_t top_hash;
|
||||||
|
|
||||||
WITH_SEMAPHORE(sem);
|
WITH_SEMAPHORE(sem);
|
||||||
|
|
||||||
StartRead(bottom);
|
StartRead(bottom);
|
||||||
bottom_hash = ((int32_t)GetFileNumber()<<16) | df_FilePage;
|
bottom_hash = ((int64_t)GetFileNumber()<<32) | df_FilePage;
|
||||||
|
|
||||||
while (top-bottom > 1) {
|
while (top-bottom > 1) {
|
||||||
look = (top+bottom)/2;
|
look = (top+bottom)/2;
|
||||||
StartRead(look);
|
StartRead(look);
|
||||||
look_hash = (int32_t)GetFileNumber()<<16 | df_FilePage;
|
look_hash = (int64_t)GetFileNumber()<<32 | df_FilePage;
|
||||||
if (look_hash >= 0xFFFF0000) {
|
if (look_hash >= 0xFFFF00000000) {
|
||||||
look_hash = 0;
|
look_hash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -492,8 +492,8 @@ uint32_t AP_Logger_Block::find_last_page(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StartRead(top);
|
StartRead(top);
|
||||||
top_hash = ((int32_t)GetFileNumber()<<16) | df_FilePage;
|
top_hash = ((int64_t)GetFileNumber()<<32) | df_FilePage;
|
||||||
if (top_hash >= 0xFFFF0000) {
|
if (top_hash >= 0xFFFF00000000) {
|
||||||
top_hash = 0;
|
top_hash = 0;
|
||||||
}
|
}
|
||||||
if (top_hash > bottom_hash) {
|
if (top_hash > bottom_hash) {
|
||||||
@ -509,8 +509,8 @@ uint32_t AP_Logger_Block::find_last_page_of_log(uint16_t log_number)
|
|||||||
uint32_t look;
|
uint32_t look;
|
||||||
uint32_t bottom;
|
uint32_t bottom;
|
||||||
uint32_t top;
|
uint32_t top;
|
||||||
uint32_t look_hash;
|
uint64_t look_hash;
|
||||||
uint32_t check_hash;
|
uint64_t check_hash;
|
||||||
|
|
||||||
WITH_SEMAPHORE(sem);
|
WITH_SEMAPHORE(sem);
|
||||||
|
|
||||||
@ -529,13 +529,13 @@ uint32_t AP_Logger_Block::find_last_page_of_log(uint16_t log_number)
|
|||||||
top = find_last_page();
|
top = find_last_page();
|
||||||
}
|
}
|
||||||
|
|
||||||
check_hash = (int32_t)log_number<<16 | 0xFFFF;
|
check_hash = (int64_t)log_number<<32 | 0xFFFFFFFF;
|
||||||
|
|
||||||
while (top-bottom > 1) {
|
while (top-bottom > 1) {
|
||||||
look = (top+bottom)/2;
|
look = (top+bottom)/2;
|
||||||
StartRead(look);
|
StartRead(look);
|
||||||
look_hash = (int32_t)GetFileNumber()<<16 | df_FilePage;
|
look_hash = (int64_t)GetFileNumber()<<32 | df_FilePage;
|
||||||
if (look_hash >= 0xFFFF0000) {
|
if (look_hash >= 0xFFFF00000000) {
|
||||||
look_hash = 0;
|
look_hash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +46,9 @@ private:
|
|||||||
virtual void StartErase() = 0;
|
virtual void StartErase() = 0;
|
||||||
virtual bool InErase() = 0;
|
virtual bool InErase() = 0;
|
||||||
|
|
||||||
struct PageHeader {
|
struct PACKED PageHeader {
|
||||||
|
uint32_t FilePage;
|
||||||
uint16_t FileNumber;
|
uint16_t FileNumber;
|
||||||
uint16_t FilePage;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
HAL_Semaphore_Recursive sem;
|
HAL_Semaphore_Recursive sem;
|
||||||
|
@ -68,6 +68,10 @@ void AP_Logger_DataFlash::Init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use_32bit_address) {
|
||||||
|
Enter4ByteAddressMode();
|
||||||
|
}
|
||||||
|
|
||||||
flash_died = false;
|
flash_died = false;
|
||||||
|
|
||||||
AP_Logger_Block::Init();
|
AP_Logger_Block::Init();
|
||||||
@ -174,6 +178,13 @@ bool AP_Logger_DataFlash::Busy()
|
|||||||
return (status & JEDEC_STATUS_BUSY) != 0;
|
return (status & JEDEC_STATUS_BUSY) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AP_Logger_DataFlash::Enter4ByteAddressMode(void)
|
||||||
|
{
|
||||||
|
WITH_SEMAPHORE(dev_sem);
|
||||||
|
|
||||||
|
const uint8_t cmd = 0xB7;
|
||||||
|
dev->transfer(&cmd, 1, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
send a command with an address
|
send a command with an address
|
||||||
|
@ -27,6 +27,7 @@ private:
|
|||||||
void WaitReady();
|
void WaitReady();
|
||||||
bool Busy();
|
bool Busy();
|
||||||
uint8_t ReadStatusReg();
|
uint8_t ReadStatusReg();
|
||||||
|
void Enter4ByteAddressMode(void);
|
||||||
|
|
||||||
void WriteEnable();
|
void WriteEnable();
|
||||||
bool getSectorCount(void);
|
bool getSectorCount(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user