[PATCH] Fix several bugs in msp430.bsl5.uart
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-msp430-tools |
New
|
Undecided
|
Unassigned |
Bug Description
The bsl5.uart methods in HEAD (r.486) are broken. I tried to use
this module with a CC430F5137 device without any success.
Background:
I am right now developing a firmware upgrade solution to our
MSP430-based product (using the above device) using the BSL,
so that the device firmware is field upgradable with a single UART
connection and no special hardware (eg. FET430) is needed.
Results:
After fixing several bugs I was able to carry out the following
operations:
- unlock BSL
- get BSL version
- upload memory area to host
- erase specific segment
- mass erase
- program device
- change baudrate for faster programming (I used 57.6 kbaud)
The attached patch contains my fixes after which the above
operations - none of which previously worked - became usable.
Outline of fixes:
- CRC16 computation done only on BSL core command section, as
defined in slau319g.pdf section 3.2.2 (both when generating CRC
for sending and when verifying CRC of received data)
- When changing baudrate, don't expect core response after
receiving ACK (0x00) from BSL, as per the spec
- Expect correct number of response bytes
- A more robust way of entering the BSL (start pulse pattern).
The existing method sometimes worked, sometimes didn't. I found
that adding a further pair of edges to TEST made this always work.
- Use correct data types (string of length 1 vs. char vs. byte)
Additional information:
- python 2.7.4
- linux 3.8.0-25-generic x86_64
Hardware setup:
I'm using a FTDI C232HD UART cable which has 3.3V pin headers;
active low for signals RTS, CTS, DTR, DSR, DCD, RI. I am
connecting this cable directly to the CC430F5137 device (thru pin
headers on our custom PCB) according to this mapping (wire colors
are according to the standard FTDI cable coloring):
FTDI RXD (yellow) <-- CC430 UCA0TXD (P1.6)
FTDI TXD (orange) --> CC430 UCA0RXD (P1.5)
FTDI RTS (green) --> CC430 TEST/SBWTCK
FTDI DTR (grey) --> CC430 _RST/NMI
FTDI GND (black) <-> CC430 AVSS, VSS-EP
As shown above, RTS and DTR are used to drive TEST and RST (as
usual), but since TEST is acvite high and RST is active low, the
--invert-reset option must be used at all times.
Updated patch also fixes BSL_LOAD_PC operation.