Skip to content

Commit

Permalink
v2.0 relese
Browse files Browse the repository at this point in the history
  • Loading branch information
import-tiago committed Aug 17, 2023
1 parent e2dbd9b commit 33d2d0e
Show file tree
Hide file tree
Showing 20 changed files with 560 additions and 760 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
418 changes: 418 additions & 0 deletions Example/lib/MSP430/MSP430.cpp

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions Example/lib/MSP430/MSP430.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#pragma once
#define DRIZZLING_BYTES_VERSION "2.0"

/*
* v1.0 - Initial release.
* v1.1 - Flush RX UART buffer (MSP430 received bytes) before each transmission to allow multiple sequential OTA updates.
* v2.0 - Improvements in memory usage
*/

#include <Arduino.h>
#include <HardwareSerial.h>
#include <FS.h>
#include <SPIFFS.h>

#define SERIAL_DEBUG 0

#if SERIAL_DEBUG
#define print_debug(x); Serial.print(x);
#define println_debug(x); Serial.println(x);
#define print_debug_hex(x, base); Serial.print(x, HEX);
#define printf_debug_1arg(x, y); Serial.printf(x, y);
#define printf_debug_2arg(x, y, z); Serial.printf(x, y, z);
#else
#define print_debug(x);
#define println_debug(x);
#define print_debug_hex(x, base);
#define printf_debug_1arg(x, y);
#define printf_debug_2arg(x, y, z);
#endif

#define MAX_MSP430_MEMORY_SECTIONS 30

/**
* @brief Construct a new BSL object to control the Bootstrap Loader programming of the target MCU.
*
* @param RESET_PIN Any GPIO with output mode capability to be connected to the RESET pin of the target MSP430.
* @param TEST_PIN Any GPIO with output mode capability to be connected to the TEST pin of the target MSP430.
* @param Serial_Port HardwareSerial object (TX and RX UART) from Arduino Framework (Serial, Serial1, Serial2...).
* @param SPIFFS_Firmware_Address The local SPI Flash File System address where the BSL object must look for the firmware file in TI-TXT format.
*/
class MSP {

private:
byte TEST_PIN;
byte RESET_PIN;
HardwareSerial BSL_UART;
String SPIFFS_Firmware_Address;

uint16_t calc_checksum(char* data, uint16_t length);
bool send_large_data(uint32_t startAddress, uint32_t length, unsigned char* data);
bool write_memory(uint32_t startAddress, char lenght, unsigned char* data);
char ctoh(char data);
void flush_bsl_uart_buffer();

public:
MSP(byte RESET_PIN, byte TEST_PIN, HardwareSerial& Serial_Port, String SPIFFS_Firmware_Address) : BSL_UART(Serial_Port) {

this->TEST_PIN = TEST_PIN;
this->RESET_PIN = RESET_PIN;
this->SPIFFS_Firmware_Address = SPIFFS_Firmware_Address;

BSL_UART.begin(9600, SERIAL_8E1);
BSL_UART.setTimeout(500);

pinMode(TEST_PIN, OUTPUT);
pinMode(RESET_PIN, OUTPUT);

digitalWrite(TEST_PIN, LOW);
digitalWrite(RESET_PIN, HIGH);
}
~MSP() {}

void invoke_target_normal_mode_operation();
void invoke_target_bsl_mode_operation();
bool write_default_password();
bool write_firmware();
void load_firmware_from_spiffs();
};
4 changes: 2 additions & 2 deletions Examples/Firebase/platformio.ini → Example/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
platform = espressif32
board = esp32dev
framework = arduino

upload_port = COM7
monitor_port = COM7
monitor_speed = 9600
lib_deps = mobizt/Firebase Arduino Client Library for ESP8266 and ESP32@^4.0.0
monitor_speed = 9600
62 changes: 62 additions & 0 deletions Example/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <Arduino.h>
#include <SPIFFS.h>
#include "MSP430.h"

//You need to ensure that the MSP430 firmware is on SPIFFS as TI-TXT format (exactly as compiled).
#define SPIFFS_FIRMWARE_ADDRESS "/txt/firmware.txt"

MSP BSL(2, 4, Serial2, SPIFFS_FIRMWARE_ADDRESS);

void setup() {

Serial.begin(9600);

if (!SPIFFS.begin()) {
Serial.println("SPIFFS initialization failed.");
return;
}

Serial.println("\r\n---START---");
}

void loop() {

int16_t attempts = 3;

BSL.load_firmware_from_spiffs();

do {

BSL.invoke_target_bsl_mode_operation();

if (!BSL.write_default_password()) {
attempts--;

if (!attempts)
break;

continue;
}

delay(5);

if (!BSL.write_firmware()) {
Serial.print("\r\nMSP430 programming failed\r\n");
attempts--;
continue;
}

Serial.print("\r\nMSP430 programmed successfully\r\n");
attempts = 0;

BSL.invoke_target_normal_mode_operation();

Serial.print("Device is reset\r\n");

} while (attempts > 0);


while (1) {
;
}
}
File renamed without changes.
14 changes: 0 additions & 14 deletions Examples/Firebase/lib/Auth_Secrets/Firebase_Secrets.h.example

This file was deleted.

8 changes: 0 additions & 8 deletions Examples/Firebase/lib/Auth_Secrets/WiFi_Secrets.h.example

This file was deleted.

65 changes: 0 additions & 65 deletions Examples/Firebase/lib/Cloud/Cloud.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions Examples/Firebase/lib/Cloud/Cloud.h

This file was deleted.

Loading

0 comments on commit 33d2d0e

Please sign in to comment.