9 years, 5 months ago.

F401RE serial port printf doesn't work

I just bought an Nucleo F104RE board and upgraded STLINK firmware to V2.J23.M6. Also upgraded the V2 driver on windows 7.

I can see the Nucleo drive. /media/uploads/mrunmoy/nucleo_drive.png

I built a simple Hello, World code from mbed.org online compiler. /media/uploads/mrunmoy/code.png

Saved the bin file in a directory. Copied the bin file into the Nucleo drive. When I go out of the drive and come back in, the file is gone! This happens everytime.

When I disconnect the USB cable and then reconnect it. I can't see the file.

Whatever code I downloaded into the drive, does not execute.

Although the Nucleo drive shows 512KB of 528KB full and the file I was copying was of 14KB. /media/uploads/mrunmoy/drivesize.png

I deleted all the files and then I pasted the binary. This time it executed the code but no output on the virtual com port. only led blinks. I added a printf("Hello, world!\n"); to the above code though.

Now I uplug the nucleo board from the usb port and plug it back in. I dont see the file any more and I see all the files I deleted back in there!

What am I doing wrong? Doesn't Nucleo work like other mbed platforms? I have a LPC1768 and I just build and copy the bin file into the mbed drive. reset the board and it executes the binary! easy!

A simple code

  1. include "mbed.h"

Serial pc(SERIAL_TX, SERIAL_RX);

DigitalOut myled(LED1); int main() { int i = 1; pc.printf("Hello World !\n"); while(1) { wait_ms(1000); pc.printf("This program runs since %d seconds.\n", i++); myled = !myled; } }

doesn't print anything on the serial port, no matter how many times I upgrade the mbed library.

Please help!

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F401RET6 microcontroller.

I can see the LED blink but nothing on the USB serial port. or the D0/D1

posted by mrunmoy samal 05 Nov 2014

Finally!!!!! Serial pc(USBTX, USBRX); made it work!

But Serial dev(PA_2, PA_3); still doesnt work

posted by mrunmoy samal 05 Nov 2014

Well, got it working. My fault! both the USBTX /RX as well as PA_2/3 were printing on the USB virtual com port. Once I followed instruction (2) above corresponding to GPRS Shield V2 i.e. remove SB13/14 and mount SB62/63 I got printf working on D0/D1 pin of arduino connector.

posted by mrunmoy samal 06 Nov 2014

I still have one question. when the program uses just "printf" instead of "pc.printf" where pc is a Serial device defined as Serial pc(TX_Pin, RX_Pin) where does the output get directed to? Please note this is w.r.t. F401RE

posted by mrunmoy samal 06 Nov 2014

printf by default goes via USBTX/USBRX pins. However it is possible to redirect this, some LCD libraries for example have a function which implements this, so printf shows up on the LCD.

posted by Erik - 06 Nov 2014

Thanks you very much once again.

posted by mrunmoy samal 06 Nov 2014

1 Answer

9 years, 5 months ago.

What you are describing is how all mbeds after the LPC1768 and LPC11u24 work, they don't have storage for the bin files, so they immediatly program the target and do not actually store it. So when it refreshes your bin file is gone, this is completely working as intended.

Accepted Answer

Sorry about not being aware of this. Thanks for your reply Erik.

posted by mrunmoy samal 06 Nov 2014