mirror of
https://github.com/gusmanb/logicanalyzer.git
synced 2025-03-13 00:34:53 +00:00
Added bootloader reset.
This commit is contained in:
parent
78e313e25e
commit
337f725f48
Firmware/LogicAnalyzer_V2
Software/LogicAnalyzer
@ -15,6 +15,8 @@
|
||||
#include "hardware/structs/syscfg.h"
|
||||
#include "hardware/structs/systick.h"
|
||||
#include "tusb.h"
|
||||
#include "pico/unique_id.h"
|
||||
#include "pico/bootrom.h"
|
||||
|
||||
#ifdef WS2812_LED
|
||||
#include "LogicAnalyzer_W2812.h"
|
||||
@ -359,6 +361,13 @@ void processData(uint8_t* data, uint length, bool fromWiFi)
|
||||
|
||||
#endif
|
||||
|
||||
case 4:
|
||||
|
||||
sendResponse("RESTARTING_BOOTLOADER\n", fromWiFi);
|
||||
sleep_ms(1000);
|
||||
reset_usb_boot(0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
sendResponse("ERR_UNKNOWN_MSG\n", fromWiFi); //Unknown message
|
||||
@ -540,6 +549,18 @@ int main()
|
||||
//Enable systick using CPU clock
|
||||
systick_hw->csr = 0x05;
|
||||
|
||||
pico_unique_board_id_t id;
|
||||
pico_get_unique_board_id(&id);
|
||||
|
||||
uint16_t delay = 0;
|
||||
|
||||
for(int buc = 0; buc < PICO_UNIQUE_BOARD_ID_SIZE_BYTES; buc++)
|
||||
delay += id.id[buc];
|
||||
|
||||
delay = (delay & 0x3ff) + ((delay & 0xFC00) >> 6);
|
||||
|
||||
sleep_ms(delay);
|
||||
|
||||
//Initialize USB stdio
|
||||
stdio_init_all();
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
<TextBlock VerticalAlignment="Center" Margin="10,0,10,0">Current device:</TextBlock>
|
||||
<TextBlock VerticalAlignment="Center" Name="lblConnectedDevice">< None ></TextBlock>
|
||||
<TextBlock Name="lblInfo" VerticalAlignment="Center" FontFamily="avares://LogicAnalyzer/Assets/Fonts#Font Awesome 6 Free" Margin="10,0,0,0"></TextBlock>
|
||||
<TextBlock Name="lblBootloader" VerticalAlignment="Center" FontFamily="avares://LogicAnalyzer/Assets/Fonts#Font Awesome 6 Free" Margin="10,0,0,0"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Stretch" Grid.Column="1" Margin="0,0,10,0">
|
||||
<Button Name="btnRepeat" IsEnabled="False" Margin="10,0,10,0">Repeat last capture</Button>
|
||||
|
@ -85,7 +85,7 @@ namespace LogicAnalyzer
|
||||
samplePreviewer.PointerWheelChanged += ScrSamplePos_PointerWheelChanged;
|
||||
|
||||
lblInfo.PointerPressed += LblInfo_PointerPressed;
|
||||
|
||||
lblBootloader.PointerPressed += LblBootloader_PointerPressed;
|
||||
channelViewer.ChannelClick += ChannelViewer_ChannelClick;
|
||||
channelViewer.ChannelVisibilityChanged += ChannelViewer_ChannelVisibilityChanged;
|
||||
tkInScreen.PropertyChanged += tkInScreen_ValueChanged;
|
||||
@ -150,6 +150,37 @@ namespace LogicAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
private async void LblBootloader_PointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (driver != null && !driver.IsCapturing)
|
||||
{
|
||||
|
||||
if (await this.ShowConfirm("Bootloader", "Are you sure you want to put the device in bootloader mode?"))
|
||||
{
|
||||
|
||||
if (driver.EnterBootloader())
|
||||
{
|
||||
driver.Dispose();
|
||||
driver = null;
|
||||
lblConnectedDevice.Text = "< None >";
|
||||
ddPorts.IsEnabled = true;
|
||||
btnRefresh.IsEnabled = true;
|
||||
btnOpenClose.Content = "Open device";
|
||||
RefreshPorts();
|
||||
btnCapture.IsEnabled = false;
|
||||
btnRepeat.IsEnabled = false;
|
||||
mnuSettings.IsEnabled = false;
|
||||
tmrPower.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
await this.ShowInfo("Bootloader", "Device entered bootloader mode.");
|
||||
}
|
||||
else
|
||||
{
|
||||
await this.ShowError("Bootloader", "Error entering bootloader mode. Device may need to be disconnected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void LblInfo_PointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if(driver != null)
|
||||
|
@ -62,3 +62,35 @@
|
||||
24/11/2024 11:46 -> Stablished path: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
24/11/2024 11:46 -> Initializing decoders...
|
||||
24/11/2024 11:46 -> Python initialization completed.
|
||||
26/11/2024 6:42 -> Initializing python system...
|
||||
26/11/2024 6:42 -> Initializing python installation detection...
|
||||
26/11/2024 6:42 -> Target Interpreter: python, Initializing Python Installation Detection...
|
||||
26/11/2024 6:42 -> Target Interpreter: python, Python version found: 312
|
||||
26/11/2024 6:42 -> Target Interpreter: python, Python version parsed: 3.12
|
||||
26/11/2024 6:42 -> Target Interpreter: python, Finding python library on Windows...
|
||||
26/11/2024 6:42 -> Target Interpreter: python, Script output: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
26/11/2024 6:42 -> Target Interpreter: python, Final python path: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
26/11/2024 6:42 -> Target Interpreter: python, Python path found: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
26/11/2024 6:42 -> Target Interpreter: python3, Initializing Python Installation Detection...
|
||||
26/11/2024 6:42 -> Target Interpreter: python3, Python version not found, aborting.
|
||||
26/11/2024 6:42 -> Valid installations found: 1
|
||||
26/11/2024 6:42 -> Selected version: 3.12
|
||||
26/11/2024 6:42 -> Stablished path: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
26/11/2024 6:42 -> Initializing decoders...
|
||||
26/11/2024 6:42 -> Python initialization completed.
|
||||
26/11/2024 6:44 -> Initializing python system...
|
||||
26/11/2024 6:44 -> Initializing python installation detection...
|
||||
26/11/2024 6:44 -> Target Interpreter: python, Initializing Python Installation Detection...
|
||||
26/11/2024 6:44 -> Target Interpreter: python, Python version found: 312
|
||||
26/11/2024 6:44 -> Target Interpreter: python, Python version parsed: 3.12
|
||||
26/11/2024 6:44 -> Target Interpreter: python, Finding python library on Windows...
|
||||
26/11/2024 6:44 -> Target Interpreter: python, Script output: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
26/11/2024 6:44 -> Target Interpreter: python, Final python path: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
26/11/2024 6:44 -> Target Interpreter: python, Python path found: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
26/11/2024 6:44 -> Target Interpreter: python3, Initializing Python Installation Detection...
|
||||
26/11/2024 6:44 -> Target Interpreter: python3, Python version not found, aborting.
|
||||
26/11/2024 6:44 -> Valid installations found: 1
|
||||
26/11/2024 6:44 -> Selected version: 3.12
|
||||
26/11/2024 6:44 -> Stablished path: C:\Users\geniw\AppData\Local\Programs\Python\Python312\Python312.dll
|
||||
26/11/2024 6:44 -> Initializing decoders...
|
||||
26/11/2024 6:44 -> Python initialization completed.
|
||||
|
@ -29,6 +29,7 @@ namespace SharedDriver
|
||||
#region Capture Methods
|
||||
public abstract CaptureError StartCapture(CaptureSession Session, Action<CaptureEventArgs>? CaptureCompletedHandler = null);
|
||||
public abstract bool StopCapture();
|
||||
public abstract bool EnterBootloader();
|
||||
#endregion
|
||||
|
||||
#region Device info
|
||||
|
@ -54,7 +54,10 @@ namespace SharedDriver
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public override bool EnterBootloader()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override CaptureMode GetCaptureMode(int[] Channels)
|
||||
{
|
||||
var split = SplitChannelsPerDevice(Channels);
|
||||
|
@ -270,7 +270,6 @@ namespace SharedDriver
|
||||
|
||||
#region Capture code
|
||||
|
||||
|
||||
public override CaptureError StartCapture(CaptureSession Session, Action<CaptureEventArgs>? CaptureCompletedHandler = null)
|
||||
{
|
||||
try
|
||||
@ -669,6 +668,28 @@ namespace SharedDriver
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bootloader-related functions
|
||||
public override bool EnterBootloader()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (capturing || baseStream == null || readResponse == null)
|
||||
return false;
|
||||
|
||||
OutputPacket pack = new OutputPacket();
|
||||
pack.AddByte(4);
|
||||
baseStream.Write(pack.Serialize());
|
||||
baseStream.Flush();
|
||||
|
||||
baseStream.ReadTimeout = 10000;
|
||||
var result = readResponse.ReadLine();
|
||||
|
||||
return result == "RESTARTING_BOOTLOADER";
|
||||
}
|
||||
catch { return false; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Network-related functions
|
||||
public override unsafe bool SendNetworkConfig(string AccesPointName, string Password, string IPAddress, ushort Port)
|
||||
{
|
||||
|
@ -315,6 +315,20 @@ namespace SharedDriver
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bootloader-related functions
|
||||
public override bool EnterBootloader()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (capturing)
|
||||
return false;
|
||||
|
||||
return connectedDevices.All(d => d.EnterBootloader());
|
||||
}
|
||||
catch { return false; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Device information functions
|
||||
public override CaptureMode GetCaptureMode(int[] Channels)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$packageName
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user