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

Implement AccessMemory function #198

Merged
merged 2 commits into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/CLR/WireProtocol/WireProtocol_MonitorCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ typedef enum Monitor_Reboot_Options
Monitor_Reboot_c_ClrStopDebugger = 4
}Monitor_Reboot_Options;

// structure for Access Memory operations
typedef enum AccessMemory_Operations
{
// check if memory space is erased
AccessMemory_Check = 0x00,

// read block of data starting at a given address
AccessMemory_Read = 0x01,

// write block of data starting at a given address
AccessMemory_Write = 0x02,

// erase sector/block/page at a given address
AccessMemory_Erase = 0x03,


AccessMemory_Mask = 0x0F

}AccessMemory_Operations;

//////////////////////////////////////////
// typedefs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

// Enables the ChibiOS community overlay.
#if !defined(HAL_USE_COMMUNITY)
#define HAL_USE_COMMUNITY FALSE
#define HAL_USE_COMMUNITY TRUE
#endif

// enables STM32 Flash driver
#if !defined(HAL_USE_STM32_FLASH)
#define HAL_USE_STM32_FLASH FALSE
#define HAL_USE_STM32_FLASH TRUE
#endif

#endif // _HALCONF_NF_H_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ static const CommandHandlerLookup c_Lookup_Request[] =
// //
// DEFINE_CMD(ReadMemory ),
DEFINE_CMD(WriteMemory),
// DEFINE_CMD(CheckMemory),
// DEFINE_CMD(EraseMemory),
//DEFINE_CMD(CheckMemory),
DEFINE_CMD(EraseMemory),
// //
// DEFINE_CMD(Execute ),
// DEFINE_CMD(MemoryMap ),
Expand Down
32 changes: 24 additions & 8 deletions targets/CMSIS-OS/ChibiOS/nanoBooter/WireProtocol_MonitorCommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
#include <WireProtocol_MonitorCommands.h>
#include <target_board.h>

static const int AccessMemory_Check = 0x00;
static const int AccessMemory_Read = 0x01;
static const int AccessMemory_Write = 0x02;
static const int AccessMemory_Erase = 0x03;
static const int AccessMemory_Mask = 0x0F;

//////////////////////////////////////////////////////////////////////
// helper functions

Expand All @@ -33,8 +27,30 @@ bool NanoBooter_GetReleaseInfo(ReleaseInfo* releaseInfo)

static bool AccessMemory(uint32_t location, uint32_t lengthInBytes, uint8_t* buffer, int mode)
{

return true;
switch(mode)
{
case AccessMemory_Write:
// use FLASH driver to perform write operation
// this requires that HAL_USE_STM32_FLASH is set to TRUE on halconf_nf.h
return stm32FlashWrite(location, lengthInBytes, buffer);

case AccessMemory_Erase:
// erase using FLASH driver
// this requires that HAL_USE_STM32_FLASH is set to TRUE on halconf_nf.h
return stm32FlashErase(location);

case AccessMemory_Check:
// use FLASH driver to check is FLASH segment is erased
// this requires that HAL_USE_STM32_FLASH is set to TRUE on halconf_nf.h
return stm32FlashIsErased(location, lengthInBytes);

///////////////////////////////////
// modes NOT supported
case AccessMemory_Read:
default:
// default return is FALSE
return false;
}
}

////////////////////////////////////////////////////
Expand Down