forked from lancaster-university/microbit-dal
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Memory Map + Partial Flash Service * Moved Partial Flash Service to Management Mode * PF Service appears in YT Build not PXT * PF in PXT * Swapped DFU and PF Services * Fixing Flash Writew * write flash via bluetooth * Partial Flash - Fixed Address * Update module.json * Adjust flash pointer * Adjust flash start * Adjust Flash Pointer * Added offset to xfer * Writing to FLASH_END * Writing to FLASH_END * Modified PFS read callback * Reenable BLE Security * removed pf * Check diff * Check diff * Replaced ContextSwitch * PF * Test. Writing Hex File to 0x30000 * Writing to PXT empty space * Reversed byte order * Flash 16 bytes at once * Copy data from static var to local var * blocks -> bytes * Fixed offset * Fixed Offset * Flash to 0x30000 + offset * Bypass scratch page * Changed byte order * Write Without Response * Without Fast BLE * Added fast BLE * Updated Connection Parameters * Iterate through BLE data bytes * Get Hashes From PXT Build * Copy Hash from Flash * Testing FLASH_END * Read Hash From Flash * Read Hash from Flash * Reading correct hash from mem * Endianess * Modified MAGIC * Fix Start Address * Sequence # * Write 0xdeadbeef to 0x36000 on PF Seq # error * Group 4 packet blocks for writing * Added error case * Increased flash write size * Blocks * Fire event to write * Decreased flash time * Reformat * Reduced hash size in MemoryMap * Partial Flashing w/ Notifications * One Characteristic - WRITE/WRITE_WOUT_RESP/NOTIFY * Modified WRITE Notification * Tidied - Moved end of transfer logic * Removed VI Swap files * Added Pairing Mode Event ID * Modified Retransmit behaviour * updateFlash caused stack overflow * Removed flash write from memory map * Instantiate Memory Map where used * Word aligned. Added Status and Reset commands * Fixed: storage. becomes storage-> * Fixed warnings: switch case fall through * Fix Hash * Rebuild Map everytime * Hash Error * Edited animation. Hash testing * persistent memory map issues * Moved EOT * Modified BLE animation. Removed globals from PFS * Updated MM * Added incomplete flash flag * Re added CCS.s
- Loading branch information
1 parent
2cff906
commit 3413d54
Showing
12 changed files
with
877 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
The MIT License (MIT) | ||
Copyright (c) 2016 British Broadcasting Corporation. | ||
This software is provided by Lancaster University by arrangement with the BBC. | ||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef MICROBIT_PARTIAL_FLASH_SERVICE_H | ||
#define MICROBIT_PARTIAL_FLASH_SERVICE_H | ||
|
||
#include "MicroBitConfig.h" | ||
#include "MicroBitBLEManager.h" | ||
#include "ble/BLE.h" | ||
#include "MicroBitMemoryMap.h" | ||
|
||
#include "MicroBitFlash.h" | ||
#include "MicroBitStorage.h" | ||
|
||
#include "MicroBitComponent.h" | ||
#include "MicroBitEvent.h" | ||
#include "MicroBitListener.h" | ||
#include "EventModel.h" | ||
|
||
#define PARTIAL_FLASHING_VERSION 0x01 | ||
|
||
// UUIDs for our service and characteristics | ||
extern const uint8_t MicroBitPartialFlashingServiceUUID[]; | ||
extern const uint8_t MicroBitPartialFlashingServiceCharacteristicUUID[]; | ||
|
||
/** | ||
* Class definition for the custom MicroBit Partial Flash Service. | ||
* Provides a BLE service to remotely read the memory map and flash the PXT program. | ||
*/ | ||
class MicroBitPartialFlashingService | ||
{ | ||
public: | ||
/** | ||
* Constructor. | ||
* Create a representation of the Partial Flash Service | ||
* @param _ble The instance of a BLE device that we're running on. | ||
* @param _memoryMap An instance of MicroBiteMemoryMap to interface with. | ||
*/ | ||
MicroBitPartialFlashingService(BLEDevice &_ble, EventModel &_messageBus); | ||
|
||
/** | ||
* Callback. Invoked when any of our attributes are written via BLE. | ||
*/ | ||
void onDataWritten(const GattWriteCallbackParams *params); | ||
|
||
/** | ||
* Callback. Invoked when any of our attributes are read via BLE. | ||
*/ | ||
void onDataRead(GattReadAuthCallbackParams *params); | ||
|
||
private: | ||
// M:B Bluetooth stack and MessageBus | ||
BLEDevice &ble; | ||
EventModel &messageBus; | ||
|
||
/** | ||
* Writing to flash inside MicroBitEvent rather than in the ISR | ||
*/ | ||
void partialFlashingEvent(MicroBitEvent e); | ||
|
||
// The base address to write to. Bit masked: (0xFFFF0000 & region.endAddress) >> 16 | ||
uint8_t baseAddress = 0x3; | ||
|
||
// Handles to access each characteristic when they are held by Soft Device. | ||
GattAttribute::Handle_t partialFlashCharacteristicHandle; | ||
|
||
/** | ||
* Process a Partial Flashing data packet | ||
*/ | ||
void flashData(uint8_t *data); | ||
|
||
// Ensure packets are in order | ||
uint8_t packetCount = 0; | ||
uint8_t blockPacketCount = 0; | ||
|
||
// Keep track of blocks of data | ||
uint32_t block[16]; | ||
uint8_t blockNum = 0; | ||
uint16_t offset = 0; | ||
|
||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.