Skip to content
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
4 changes: 2 additions & 2 deletions firmware/net/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
set(SOURCE ./src/net.cc ./src/peripherals.cc)
set(SOURCE ./src/net.cc ./src/peripherals.cc ./src/efuse_burner.cc)

#idf_component_register(SRCS ${SOURCE}
# INCLUDE_DIRS inc ../../shared_inc/
# REQUIRES driver serial_esp net_manager logger quicr wifi)

idf_component_register(SRCS ${SOURCE}
INCLUDE_DIRS inc ../../shared_inc/
REQUIRES driver serial logger quicr storage wifi net_manager nlohmann_json pthread)
REQUIRES driver serial logger quicr storage wifi net_manager nlohmann_json pthread efuse)
3 changes: 3 additions & 0 deletions firmware/net/core/inc/efuse_burner.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

bool BurnDisableUSBJTagEFuse();
42 changes: 42 additions & 0 deletions firmware/net/core/src/efuse_burner.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "efuse_burner.hh"
#include "esp_efuse.h"
#include "esp_efuse_table.h"
#include "esp_err.h"
#include "logger.hh"

bool BurnDisableUSBJTagEFuse()
{
if (esp_efuse_read_field_bit(ESP_EFUSE_DIS_USB_JTAG))
{
NET_LOG_INFO("Efuse for DIS_USB_JTAG is already burned");
return true;
}

NET_LOG_INFO("Starting efuse burning process to disable usb jtag debugger");

esp_err_t err = esp_efuse_batch_write_begin();
if (err != ESP_OK)
{
NET_LOG_ERROR("Failed to start batch write %s", esp_err_to_name(err));
return false;
}

err = esp_efuse_write_field_bit(ESP_EFUSE_DIS_USB_JTAG);
if (err != ESP_OK)
{
NET_LOG_ERROR("Failed to write efuse field %s", esp_err_to_name(err));
esp_efuse_batch_write_cancel();
return false;
}

err = esp_efuse_batch_write_commit();
if (err != ESP_OK)
{
NET_LOG_ERROR("Failed to commit efuse changes %s", esp_err_to_name(err));
return false;
}

NET_LOG_INFO("Successfully burned efuse to disable usb jtag and enable extern jtag debugging");

return true;
}
21 changes: 18 additions & 3 deletions firmware/net/core/src/net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
#include "driver/gpio.h"
#include "driver/ledc.h"
#include "driver/uart.h"
#include "efuse_burner.hh"
#include "esp_event.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "esp_mac.h"
#include "esp_pthread.h"
#include "freertos/FreeRTOS.h"
#include "freertos/projdefs.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "logger.hh"
Expand Down Expand Up @@ -455,6 +457,19 @@ static void MgmtLinkPacketTask(void* args)
mgmt_layer.ReplyAck();
break;
}
case Configuration::Burn_Disable_USB_JTag_Efuse:
{
const bool res = BurnDisableUSBJTagEFuse();
if (res)
{
mgmt_layer.ReplyAck();
}
else
{
mgmt_layer.ReplyNack();
}
break;
}
default:
{
NET_LOG_ERROR("Unknown packet type from mgmt");
Expand Down Expand Up @@ -604,13 +619,13 @@ extern "C" void app_main(void)
IntitializeLEDs();
InitializeUIReadyISR(GpioIsrRisingHandler);

NET_LOG_INFO("Starting Net Main");

CreateMgmtLinkPacketTask();
mgmt_layer.BeginEventTask();

CreateUILinkPacketTask();

NET_LOG_INFO("Starting Net Main");

wifi.Begin();

wifi.Connect("quicr.io", "noPassword");
Expand Down Expand Up @@ -904,4 +919,4 @@ void RestartMoqSession(std::shared_ptr<moq::Session>& session,
{
StopMoqSession(session, readers, writers);
moq_session.reset(new moq::Session(config, readers, writers));
}
}
3 changes: 2 additions & 1 deletion firmware/shared_inc/net_mgmt_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ enum Configuration
Disable_Loopback,
Enable_Loopback,
Set_Frontline_Config,
};
Burn_Disable_USB_JTag_Efuse,
};
23 changes: 13 additions & 10 deletions software/hactar-cli/monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@
readline = None

import serial
from hactar_commands import (
bypass_map,
command_map,
hactar_command_completer,
hactar_command_print_matches,
net_command_map,
ui_command_map,
)
from hactar_commands import (bypass_map, command_map, hactar_command_completer,
hactar_command_print_matches, net_command_map,
ui_command_map)
from hactar_scanning import HactarScanning, ResetDevice, SelectHactarPort


Expand Down Expand Up @@ -49,6 +44,10 @@ def GetLine(self):
while self.uart.in_waiting:
char = self.uart.read()
if char == b"\x82":
# print("Got an ack!")
return ""
if char == b"\x83":
# print("Got a nack!")
return ""

data += char
Expand Down Expand Up @@ -121,11 +120,15 @@ def ProcessBypassCommand(self, split):
command_id = chip_commands[command]["id"]

if len(split) - 2 < num_params:
print(f"[ERROR] Not enough parameters for command{command} expected {num_params} got {len(split)-2}")
print(
f"[ERROR] Not enough parameters for command{command} expected {num_params} got {len(split)-2}"
)
return

if len(split) - 2 > num_params:
print(f"[ERROR] Too many parameters for command {command} expected {num_params} got {len(split)-2}")
print(
f"[ERROR] Too many parameters for command {command} expected {num_params} got {len(split)-2}"
)
return

Header_Bytes = 5 # 1 type, 4 length
Expand Down
1 change: 1 addition & 0 deletions software/hactar-cli/utility/hactar_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"disable_loopback": {"id": 11, "num_params": 0},
"enable_loopback": {"id": 12, "num_params": 0},
"set_fl_config": {"id": 13, "num_params": 2},
"burn_efuse": {"id": 14, "num_params": 0},
}

ST_Ack = 0x79
Expand Down