Sunday, June 12, 2022

MSP430 Bootloader over I2C on RaspberryPi and BeagleBone Black

MSP430 has a built-in bootloader (BSL), that communicates with a host through UART or I2C to update memory.  TI released the code described in "MSP430TM Firmware Updates Over I2C Using Linux®".  This code compiles without modification on Raspberry Pi.

First we try the hardware entry sequence on the TEST and RST pins to invoke the BSL.  "The BSL program execution starts when the TEST pin has received a minimum of two rising edges (low-to-high transitions) and if TEST is high while RST/NMI rises from low to high."  From the RaspberryPi 40-pin header, we connect RPi Pin-3 (SDA) and Pin-5 (SCL) to MSP430 P1.2 (SDA) and P1.3 (SCL) for I2C and Pin-13 and Pin-15 GPIO to RST/SBWTDIO and TEST/SBWTCK.   After applying the sequence using Python RPi.GPIO, we can probe the I2C bus with "i2cdetect -y 1" and see a response at the expected address 0x48.   Now we can try "msp430-i2cbsl-tool" to update the firmware.  The firmware file is generated using MSP430 Hex Utility hex430 with --ti_txt option.  Note that the BSL times out in 10 seconds.   When we run the command, we get an error message, "Attempting to unlocking device with password... Fail!".   It looks like ioctl I2C_RDWR failed, "Connection timed out".   The next troubleshooting step is to take a look the I2C traces on the scope.  

Before we do that, we'll do a test on BeagleBone Black that TI has tested on.  We connect Pin-19 (SCL2) and Pin-20 (SDA2) to P1.3 and P1.2, Pin-12 (GPIO_60) and Pin-15 (GPIO_48) to TEST and RST.  We control the GPIO pins using SysFs.  This works,

./msp430-i2cbsl-tool -f ~/BlinkLED_MSP-EXP430FR2355.txt -i /dev/i2c-1 -n
---------------------------------------------------------------
   TI MSP430 I2C Linux BootLoader 01.00.00.00                  
---------------------------------------------------------------
INFO: Firmware file /home/debian/BlinkLED_MSP-EXP430FR2355.txt specified
INFO: I2C BUS /dev/i2c-1 specified
INFO: Opening TI-TXT firmware file firmware.txt...  done!
INFO: Password file not found, defaulting to 0xFFs.
INFO: Skipped software invoke.
INFO: Attempting to unlocking device with password... Fail!
INFO: Device could not be unlocked. Resetting password and trying again.
INFO: Skipped software invoke.
INFO: Attempting to unlocking device with password... done!
INFO: Programming attempt number 0
INFO: Programming @0x8000 with 220 bytes of data... done!
INFO: Programming @0xff80 with 12 bytes of data... done!
INFO: Programming @0xffa0 with 2 bytes of data... done!
INFO: Programming @0xffce with 50 bytes of data... done!
INFO: Programmed all memory locations successfully.
INFO: New firmware successfully downloaded to device.
INFO: Reading the reset vector contents and setting the PC to this value.
INFO: This should cause the device to reset.
INFO: Reset vector read as 0x80c0
INFO: New program downloaded and reset successfuly!

Note that the default password is used, which is not the correct password the first time and triggers a mass erase that clears the password so the it succeeds in unlocking the second time.  If the proper password (32 bytes from address 0xffe0 - 0xffff) is used, it is unlocked the first time.



No comments:

Post a Comment