Skip to main content
DWeie
Associate III
September 23, 2019
Question

External Loader Debug Printing

  • September 23, 2019
  • 25 replies
  • 4573 views

Hi all,

I'm developing a custom external loader to flash a QUADSPI memory as part of a TouchGFX project. I'm using an STM32F7 processor and developing using the STM32CubeIDE.

I’m struggling with a specific issue that I’m hoping I’ll be able to get help with. Since I’m unable to observe the state of the processor while the external loader is being called from the ST-LINK Utility I’m planning on redirecting stdio to an unused USART to get run time information.

When running in debug mode in the ST32CubeIDE this is working fine, but as soon as I switch to using the .stldr (generated from the same source) through the ST-LINK Utility the functionality goes away. A rundown of what I have done on this so far is below:

I’ve proven that the Init() function is being called and is running by toggling some other GPIO and observing them.

I’ve globally disabled interrupts in Debug mode to verify that interrupts are not needed for functionality of the UART in blocking mode.

I’ve tested removing the stdio redirect from consideration by writing directly to the UART instance’s data register.

I’ve made sure to call SystemInit() before other initialization code. Normally the assembly startup calls this function, but this (along with data initialization) would be skipped when Init() is called directly by the ST-LINK application.

I have not implemented the data (.bss and zero) initialization that would normally occur in the startup code because, if I understand correctly, the ST-LINK should be doing this based on the provided .stldr file. If it is not then I am unsure where to initialize the data from since there is no reference in flash memory as there would be for normal operation.

Despite this, I am getting no print statements. I'm wondering if anyone with more experience in this might have some suggestions for me to try since I'm not able to think of a next step beyond what I've already attempted.

Thank you,

Don

This topic has been closed for replies.

25 replies

Tesla DeLorean
Guru
September 23, 2019

I wouldn't assume the ST-LINK drivers initialize memory for you, both Keil and IAR external loader examples explicitly memset() stuff they use to zero.

My preference in Keil is to call the scatter loader from Init() to get the job done transparently, GNU obviously will be more of a hack.

USART should work. So issues there are Pin configurations and AF settings, clocks, the USART library with a clear grasp of the system/bus clocks to set the USART->BRR correctly. Would have Init() output a whole load of 'U' chars and scope those for appropriate bit timing.

Make standalone OutputString() type functions talking to USART ISR/TDR directly.

Consider not programming the RCC/PLL, and just run from the 16 MHz HSI, see if that works. ie comment out SystemClock_Config() call.

Watch for things dependent on Ticks. Watch for while(1) loops of death like ErrorHandler(), flag to a RED LED if you have one.

It is technically possible to get HardFault working, helpful at times.

Do not implement a Read() function, the ST-LINK does this reading directly from memory itself, so make sure the memory is mapped.

Mask memory address passed to QSPI chips via commands.

What memory part(s) are you using? What pins? What USART/Pins? What HSE source?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
DWeie
DWeieAuthor
Associate III
September 23, 2019

Thanks for the input Clive, I'll get to work trying some of these suggestions right away. I'll clarify in a couple of spots and answer the questions that I can already.

I have attempted writing to the TDR directly while observing the output with an oscilloscope. I was thinking along the same lines as you regarding in incorrect baud rate. In this test I did not see any edges at all which tells me that the error is something else. I'll dive into the HAL library and see if there's a path that the uart init can take where it'll skip initialization because it thinks the BR is impossible.

The memory part is an N25Q128A13ESF40F from Micron. The QUADSPI pinout is    

/**QUADSPI GPIO Configuration   

   PE2    ------> QUADSPI_BK1_IO2

   PF6    ------> QUADSPI_BK1_IO3

   PF8    ------> QUADSPI_BK1_IO0

   PF9    ------> QUADSPI_BK1_IO1

   PB2    ------> QUADSPI_CLK

   PB6    ------> QUADSPI_BK1_NCS

   */

I am using the USART1 on PA9 (TX) and PA10(RX is inited but the pin is unconnected).

HSE is sourced from a 16MHz oscillator. I'll try using HSI per your suggestion. I think that'll be a great way to remove some variables. I will also memset my variables to remove that potential for error.

Thank you,

Don

Tesla DeLorean
Guru
September 25, 2019

..

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..