Skip to content

Commit

Permalink
we have a plan now
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelleLee committed Oct 31, 2024
1 parent b0a0065 commit 4515cb3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 30 deletions.
19 changes: 6 additions & 13 deletions projects/bootloader/inc/can_datagram.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ typedef enum {
CAN_ARBITRATION_ACK_ID,
CAN_ARBITRATION_START_ID,
CAN_ARBITRATION_JUMP_BOOTLOADER,
CAN_ARBITRATION_METADATA,
CAN_ARBITRATION_PING,
CAN_PING_NODE_ID,
CAN_PING_PROJECT,
CAN_PING_BRANCH,
} BootloaderCanID;

typedef struct {
Expand All @@ -46,15 +42,12 @@ typedef struct {
uint16_t bootloader_error;
} ack;
struct {
//metadata
uint8_t metadata;
//project / Git branch
uint8_t* branchproject;
//node_id
uint8_t node_id;
//isGitorProject
uint8_t isBranch;

// node_id
uint16_t node_ids;
// Request
uint8_t req;
// Length of data being sent
uint32_t data_len;
} ping;
} payload;
} BootloaderDatagram_t;
Expand Down
6 changes: 2 additions & 4 deletions projects/bootloader/scripts/bootloader_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
ACK = 33
START = 34
JUMP_BOOTLOADER = 35
PING_METADATA = 37
NODE_ID = 38
PROJECT = 39
BRANCH = 40
PING_START = 36
PING_DATA = 37
STANDARD_CRC32_POLY = 0x04C11DB7
33 changes: 32 additions & 1 deletion projects/bootloader/src/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,40 @@ static BootloaderError bootloader_fault() {
return BOOTLOADER_INTERNAL_ERR;
};

volatile uint32_t bootloader_timer = 0;
#define BOOTLOADER_TIMEOUT_MS 15000

static void ping_run(Boot_CanMessage *msg) {
//branch out into the three ID
}

static BootloaderError bootloader_ping() {
BootloaderError error = BOOTLOADER_ERROR_NONE;
//
/* Start handling each req
1 - Git
2 - Proj
3 - Node_ID
*/

Boot_CanMessage msg = { 0 };

while (true) {
if(boot_can_receive(&msg) == BOOTLOADER_ERROR_NONE){
bootloader_timer = 0;
//bootloader_run(&msg);
ping_run(&msg);
}

if (bootloader_timer > BOOTLOADER_TIMEOUT_MS) {
bootloader_timer = 0;
if (boot_verify_flash_memory() == BOOTLOADER_ERROR_NONE) {
send_ack_datagram(NACK, BOOTLOADER_TIMEOUT);
bootloader_jump_app();
}
send_ack_datagram(NACK, BOOTLOADER_FLASH_MEMORY_VERIFY_FAILED);
}

}
}

static BootloaderError bootloader_run_state() {
Expand Down
16 changes: 4 additions & 12 deletions projects/bootloader/src/can_datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,11 @@ BootloaderDatagram_t unpack_datagram(Boot_CanMessage *msg, uint16_t *target_node
*target_nodes = msg->data_u16[0];
break;
case CAN_ARBITRATION_PING:
ret_datagram.payload.ping.metadata = msg->data_u8;
break;
case CAN_PING_NODE_ID:
ret_datagram.payload.ping.node_id = msg->data_u8;
break;
case CAN_PING_BRANCH:
ret_datagram.payload.ping.branchproject = msg->data_u8;
ret_datagram.payload.ping.isBranch = 1;
break;
case CAN_PING_PROJECT:
ret_datagram.payload.ping.branchproject = msg->data_u8;
ret_datagram.payload.ping.isBranch = 0;

ret_datagram.payload.jump_app.node_ids = msg->data_u16[0];
ret_datagram.payload.
break;

default:
break;
}
Expand Down

0 comments on commit 4515cb3

Please sign in to comment.