Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some bugs for uploading code to MSP430G2553 #1

Open
weihsiangteng opened this issue May 29, 2020 · 1 comment
Open

Some bugs for uploading code to MSP430G2553 #1

weihsiangteng opened this issue May 29, 2020 · 1 comment

Comments

@weihsiangteng
Copy link

I found some bugs in protocol 1xx, 2xx and 4xx families using your console program. This will fail password checking also uploading code to msp430g2553. After I modified some codes then it worked.
Following are my modifications:

Main_priv.cs:
1.

case Command.Password:  // address: -   data: D1 ... D20
    {
        BSL_frame.Add(Const.BSL_CMD124__RX_PASSWORD);  // typo?
        BSL_frame.AddRange(Enumerable.Repeat(Const.BSL_DATA124__PW_L1_L2, 2).ToArray());
        BSL_frame.AddRange(Enumerable.Repeat(Const.BSL_DATA124__DUMMY, 4).ToArray());

        if ((data == null || data.Length != Const.BSL_SIZE124__PASSWORD))
        {
            message.status = Utils.StatusCreate(801);
            return message;
        }
        BSL_frame.AddRange(data);
    }
    break;
  1. RX data block BSL command should take n-4 bytes:
case Command.Upload:  // address: AL, AH   data: D1 ... Dn-4
    {
        BSL_frame.Add(Const.BSL_CMD124__RX_DATA_BLOCK);
        BSL_frame.AddRange(Enumerable.Repeat((byte)(data.Length + 4), 2).ToArray());

        if ((address == null) || (data == null || data.Length < 1))
        {
            message.status = Utils.StatusCreate(801);
            return message;
        }
        BSL_frame.AddRange(_address.ToArray());
        BSL_frame.Add((byte)(data.Length));
        BSL_frame.Add(0);
        BSL_frame.AddRange(data);
    }
    break;
case Command.Upload:
    {
        Debug.Assert(typeof(T) == typeof(Data_Void));
        //throw new BSL430Exception(460, "Result<Data_Void> res = msg(Command.*)");
        result.data = (T)(object)new Data_Void();
        ok = (answer.data.Length == 1 && answer.data[0] == Const.BSL_GENERAL124__ACK);   // another typo?
    }
    break;
  1. In ParseFirmware function, the variable fill_FF should be true for TI text format?

Constants.cs

// BSL RX SIZE - PROTOCOL 1xx 2xx 4xx
public const byte BSL_SIZE124__PASSWORD = 32;

Thank you for providing this awesome software so that I can flash my msp430g2553!

@parezj
Copy link
Owner

parezj commented May 30, 2020

Thank you very much for correcting this issue! fill_FF is usually not needed for Uploading code to MCU, because users dont enter valid BSL password, and therefore Mass Erase is executed prior to Upload. If you know BSL password and want to upload only INFO A code, also you dont need fill_FF. It is usefull for CRC calculation and other FirmwareTools specific stuff.

Warning: Password is optional for Download, but if wrong password is entered, MCU takes it as an attack and erase all memory, executing Mass Erase. If modern 5xx/6xx micro is used, code is just wiped, but if old 1xx/2xx/4xx one is used and LOCK A bit is not set, also Info A mem is wiped, with factory calibration data. So please be careful.

I will push your changes into main line, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants