Skip to content

BSL430.NET.Library

Jakub Parez edited this page Sep 17, 2019 · 18 revisions

BSL430.NET Library

BSL430.NET is Cross-Platform library serving as MSP430 Toolchain, to upload, download and erase MCU memory.

Note: This library is recommended to build as x86 or x64, rather than AnyCPU!
      It depends on unmanaged code, that needs to use correct pointer size.

Framework Support

  • .NET Framework 4.6.1
  • .NET Standard 2.0

Communication

Communication with MCU is handled by 4 different ways. FTDI (FT232) is Windows only approach and requires FT2XX drivers installed on target PC. Another approch is called Libftdi and this works on Windows and also Linux, because rather on FT2XX original FTDI drivers it depends on open-sourced alternative libftdfi. Both ways use unmanaged libraries for low-level communication, those libraris are provided in folder lib or just integrated into Win GUI App. Another simple approch is to use standard Serial port (COM) with RS232/UART converter, or the last one, USB with F5xx/F6xx USB enabled MCUs. These 2 ways use managed libraries so you dont need to worry about anything, plus they are also multiplatform.

It is required to connect RST/TEST pins to DTR/RTS according to Wiring Diagram and specific MCU family. These two signals provide special voltage sequence, that forces MCU to start execute BSL bootloader code. In most cases, when MCU has Shared JTAG pins, RST(MCU) is connected to DTR(PC) and TEST(MCU) to RTS(PC). In case of MCU has Dedicated JTAG pins,

Unmanaged comm libs need to be put in right location, to let CLR correctly loads them, please follow .NET P/Invoke guidelines (usually in same folder as executable).

Warning: Old 1xx/2xx/4xx bootloader protocol handle Erase or incorrectly entered password as complete 
         memory wipe including Info A (with calibration data), if LOCK A bit is not set! It is always 
         better to use modern MCUs with 5xx/6xx BSL protocol, but if there is no oher way, be careful.

Code Samples

Scan (FTDI)

public ScanResult<FTDI_Device> ScanFTDI()
{
    using (var dev = new BSL430NET(Mode.UART_FTD2XX))
    {
        var ret = dev.Scan<FTDI_Device>();

        Console.WriteLine(ret.Status);
        Console.WriteLine(ret.Devices);

        return ret;
    }
}

Scan (libftdi)

public ScanResult<Libftdi_Device> ScanFTDI()
{
    using (var dev = new BSL430NET(Mode.UART_libftdi))
    {
        var ret = dev.Scan<Libftdi_Device>();

        Console.WriteLine(ret.Status);
        Console.WriteLine(ret.Devices);

        return ret;
    }
}

Scan (USB)

public ScanResult<USB_HID_Device> ScanFTDI()
{
    using (var dev = new BSL430NET(Mode.USB_HID))
    {
        var ret = dev.Scan<USB_HID_Device>();

        Console.WriteLine(ret.Status);
        Console.WriteLine(ret.Devices);

        return ret;
    }
}

Scan (Serial COM)

public ScanResult<Serial_Device> ScanFTDI()
{
    using (var dev = new BSL430NET(Mode.UART_Serial))
    {
        var ret = dev.Scan<Serial_Device>();

        Console.WriteLine(ret.Status);
        Console.WriteLine(ret.Devices);

        return ret;
    }
}

Scan All Devices

public ScanAllResult ScanAll()
{
    using (var dev = new BSL430NET())
    {
        var ret = dev.ScanAllEx<FTDI_Device>();

        Console.WriteLine(ret.FtdiDevices.Status);
        Console.WriteLine(ret.LibftdiDevices.Status);
        Console.WriteLine(ret.UsbDevices.Status);
        Console.WriteLine(ret.SerialDevices.Status);

        Console.WriteLine(ret.FtdiDevices.Devices);
        Console.WriteLine(ret.LibftdiDevices.Devices);
        Console.WriteLine(ret.UsbDevices.Devices);
        Console.WriteLine(ret.SerialDevices.Devices);

        return ret;
    }
}

Upload to MCU

public void Upload(string FirmwarePath)
{

}

Download from MCU

public List<byteeeee> Download(string FirmwasssssssrePath)
{

}

Erase MCU

public void Erase()
{

}

Clone this wiki locally