0

I'm trying to access the bootloader for a Nucleo L476RG "slave" board.

The "master" board is a Nucleo L496ZG board. In my program, I have a DigitalOut defined on the master board called extBoot0, extReset. These go off to the boot0 and NRST pins on the slave board. Additionally, I have a Serial instance called usart on the master, which is attached to UART2 on the slave board. Also, it appears that there BOOT1 is preset to run the bootloader, i.e. it's asserted low and cannot be changed to run whatever's in SRAM.

Currently, in resetToBootloader, I set BOOT0 high and drop NRST low for 0.1 seconds, and bring it back up high. I've observed that running this function indeed resets the device and prevents the program from running.

In initBootloader, I format the serial per AN2606: 8-bit, even parity, 1 stop bit. I then send 0x7F over that serial bus to the slave board. I'm not getting any response and using a logic analyzer, I've confirmed that the slave is getting it on the right pin and there is no changes in the slave's TX input. What else needs to be done to start the bootloader?

Here's my relevant code:

DigitalOut extBoot0(D7);
DigitalOut extBoot1(D6);
DigitalOut extReset(D5);

Serial usart(/* tx, rx */ D1, D0);


uint8_t rxBuffer[1];
event_callback_t serialEventCb;

void serialCb(int events) {
    printf("something happened!\n");
}

void initBootloader() {
    wait(5); // just in case?
    // Once initialized the USART1 configuration is: 8-bits, even parity and 1 Stop bit
    serialEventCb.attach(serialCb);
    usart.format(8, SerialBase::Even, 1);
    uint8_t buffer[1024];

    // write 0x7F
    buffer[0] = 0x7F;
    usart.write(buffer, 1, 0, 0);
    printf("sending cmd\n");
    // should ack 0x79
    usart.read(rxBuffer, 1, serialEventCb, SERIAL_EVENT_RX_ALL, 0x79);
}

If it helps at all, here's a picture of my board setup.

  • can you connect a logic analyzer to see what goes on the lines? if not - this might be a solution https://sysprogs.com/analyzer2go/boards/STM32L476RG-Nucleo – Shahar Hadas Jun 02 '19 at 19:43
  • On which lines? On a logic analyzer, I observed 0x7F is transmitted from the master to the slave, and there is nothing in response. –  Jun 02 '19 at 19:45
  • all the lines - do you see the RX constantly low or high? from a PC with a USB-UART adapter (TTL) you're able to initiate the boot loader? – Shahar Hadas Jun 02 '19 at 19:50
  • Both the slave's RX/TX are high, except when RX receives the 0x7F. Just tried it with a USB serial port and it does not respond to that either. [Here's a screenshot of the logic analyzer, order is TX, RX](https://imgur.com/YJVQAHI) –  Jun 03 '19 at 01:04

1 Answers1

0

I believed I solved this by using USART1 instead of USART2. The documentation states that both USART1 and USART2 can be used, but I only receive a 0x79 from USART1.

Additionally, I had to switch from Serial to UARTSerial. The slave first sends an incorrect packet, 0xC0 with an incorrect parity bit. Not really sure why it does that, but it causes the regular Serial instance to not handle the proceeding byte.