Code Monkey home page Code Monkey logo

Comments (25)

muhambykar avatar muhambykar commented on May 26, 2024

Is there anyone got same error?

from ota_update_stm32_using_esp32.

laukik-hase avatar laukik-hase commented on May 26, 2024

Hello, @muhambykar

Can you check the GPIOs that you are using as Rx and Tx?

from ota_update_stm32_using_esp32.

muhambykar avatar muhambykar commented on May 26, 2024

I have checked rx tx pins, I can write and erase with these pins on FlashLoaderDemo.exe but I couldnt it with esp32. I have tried directly Boot0 to HIGH, and I have also tried with #define BOOT0_PIN (GPIO_NUM_21) But got some error log. Is there anything that I can check?

from ota_update_stm32_using_esp32.

muhambykar avatar muhambykar commented on May 26, 2024

Is there anybody got same error?

from ota_update_stm32_using_esp32.

laukik-hase avatar laukik-hase commented on May 26, 2024

Hello, @muhambykar
Sorry for the late reply.

  1. Test this example for UART - UART Async Tasks
  2. Verify whether your STM32 is in BOOT mode before flashing.
  3. Try resetting your STM32 using the RESET switch on your board, and then running the example. (Time it appropriately)

from ota_update_stm32_using_esp32.

LetsControltheController avatar LetsControltheController commented on May 26, 2024

Hello there, I found the solution. on ESP-IDF v4.0.x ,
uart_set_rts(UART_CONTROLLER, 1);
this function changes the uart configs, and got trouble about it. After make comment it, problem is solved. This line is on components/stm_pro_mode/stm_pro_mode.c Line: 19

I have listened the received packets from UART, then I figure out it and it works. I recommend it.

from ota_update_stm32_using_esp32.

laukik-hase avatar laukik-hase commented on May 26, 2024

Hello there, I found the solution. on ESP-IDF v4.0.x ,
uart_set_rts(UART_CONTROLLER, 1);
this function changes the uart configs, and got trouble about it. After make comment it, problem is solved. This line is on components/stm_pro_mode/stm_pro_mode.c Line: 19

I have listened the received packets from UART, then I figure out it and it works. I recommend it.

This function was inserted as the STM32 flashing protocol works on USART, not UART. We have tested with two different versions of the chip (STM32F103 and STM32F072) and got successful results. Can you guys tell which STM32 chip are you using?

from ota_update_stm32_using_esp32.

LetsControltheController avatar LetsControltheController commented on May 26, 2024

Its not about STM32, its about ESP32. When we configure RTS manually iwth this function, ESP32 could not read data on Rx pin. So if we leave it with automatic configuration, it works.

from ota_update_stm32_using_esp32.

laukik-hase avatar laukik-hase commented on May 26, 2024

@muhambykar I am closing the issue for now. Reopen it if you have any updates regarding the problem.

from ota_update_stm32_using_esp32.

madhavee77 avatar madhavee77 commented on May 26, 2024

Hey I am getting the same error and tried everything mentioned above. Was someone able to solve it?

from ota_update_stm32_using_esp32.

akym avatar akym commented on May 26, 2024

I have the same issue, i tried all the solutions mentioned in this issue and then some more. Cant seem to point out why esp32 cant receive anything, even tried the uart_set_rts solution mentioned by @LetsControltheController . The UART example works but only when talking with STM it doesn't work. Any thoughts on the problem?

from ota_update_stm32_using_esp32.

laukik-hase avatar laukik-hase commented on May 26, 2024

Hello,

Sorry for the late response. I will try reproducing this on my side and revert back to you.

@akym and @madhavee77 Could you guys specify the following:

  1. ESP-IDF Version (use git describe --tags to find out)
  2. STM32 MCU (e.g. STM32F103, STM32F401, STM32F072, etc.)

from ota_update_stm32_using_esp32.

akym avatar akym commented on May 26, 2024

Hi,
Thank you for the quick response. Here are the things you requested:
1.ESP-IDF 4.3
2. STM32F407 from DISC1 board

I probed Tx,Rx of the STM32 with oscilloscope and it is transmitting some data on the Tx but ESP32 doesnt read any of that data. I have tried running the UART example as you suggested and that one works fine on UART0 and UART2. For my implementation I am using UART2 to push firmware to the STM.
here the red channel is Tx and yellow is Rx
IMG_1037

Any help will be appreciated.

My code for reference:

stmOTA.zip

from ota_update_stm32_using_esp32.

laukik-hase avatar laukik-hase commented on May 26, 2024

Hello there, I found the solution. on ESP-IDF v4.0.x , uart_set_rts(UART_CONTROLLER, 1); this function changes the uart configs, and got trouble about it. After make comment it, problem is solved. This line is on components/stm_pro_mode/stm_pro_mode.c Line: 19

I have listened the received packets from UART, then I figure out it and it works. I recommend it.

Hello, @akym

Sorry for the late update. I was able to reproduce this issue on ESP-IDF branch release/v4.3 with an STM32F103. But, the above fix (suggested by @LetsControltheController) solved the issue for me. I will try reproducing with some other STM32 boards and revert back to you.

Are you resetting the board before flashing? (if you are using the on-board RESET button, you will need to time it appropriately)

from ota_update_stm32_using_esp32.

akym avatar akym commented on May 26, 2024

Thank you for the effort.

I tried the set_rts but it did not work.

I am resetting the board with flipping ESP's GPIO pin to NRST of STM32F4, not manually. My code is attached in the original question, but it is almost the same as this repo.

from ota_update_stm32_using_esp32.

laukik-hase avatar laukik-hase commented on May 26, 2024

Hello, @akym

I tried the example again on an STM32F103C8 with uart_set_rts(...) disabled and the connections mentioned in the README, but it executed successfully.

I also had an STM32F401xC lying around so I gave it a try on that, but the example failed with the Serial Timeout error.

  1. Could you try the connections as mentioned in this article? As you are working with a Discovery board, you could be needed to change the pins (PA9 and PA10) for USART communication.
  2. My STM32F401xC board went straight into the DFU Bootloader mode on setting the BOOT0, BOOT1 and nRST pins as required and was able to flash through the USB mode with STM32CubeProgrammer after that. I am still investigating how to enter the USART Bootloader mode on these boards, will revert back to you if I find out more.

from ota_update_stm32_using_esp32.

akym avatar akym commented on May 26, 2024

Hello @laukik-hase ,
Happy new year and sorry for the late reply.

  1. I did try the connection suggested in the link you sent and other ports from the post as well.
  2. I tried flashing STM32 over USART with and external FTDI, it works flawlessly with 'STM Flash Loader Demonstrator'

I also tried following the AN3155 ('USART protocol used in the STM32 bootloader') from STM to see where things might not be working. maybe you can try having a look. That is when I probed the TX & RX pins with osci to see if there is anything.

from ota_update_stm32_using_esp32.

madhavee77 avatar madhavee77 commented on May 26, 2024

Hey everyone, sorry for the late reply.

I was able to resolve this issue on my end. I first tested if the STM32 is working or not by putting it in bootloader mode and started sending the setup bytes manually to it at 115200 baud rate, even parity, using FTDI. Whenever I sent something, I was receiving the Acknowledgement byte which is 0x79. Which proved there was nothing wrong with STM32.

Then I tried testing a basic UART example of ESP32 with the same settings as in this code (even including uart_set_rts(UART_CONTROLLER, 1);). That's when I found that the issue was because of this function in the stm_pro_mode.c line 244.

waitForSerialData();

Most probably the function uart_get_buffered_data_len() is the issue and is not reading anything on the receiving line whenever STM32 sends something back.

This function is not able to read the incoming data, maybe its supporting libraries are not available on the latest version or whatever is the reason I don't know but this was the issue on my end. I removed it and made it dynamic.

This is how I edited the function which was using the waitForSerialData() at line 206:

int sendBytes(const char *bytes, int count, int resp)
{
sendData(TAG_STM_PRO, bytes, count);

uint8_t* data = (uint8_t*)malloc(resp * sizeof(uint8_t*));

int rxBytes = uart_read_bytes(UART_CONTROLLER, data, UART_BUF_SIZE, 1000 / portTICK_RATE_MS);

if (rxBytes > 0 )
{
if(rxBytes == resp && data[0] == ACK)
{
data[rxBytes] = 0;
logI(TAG_STM_PRO, "%s", "Sync Success");
// ESP_LOG_BUFFER_HEXDUMP(TAG_STM_PRO, data, rxBytes, ESP_LOG_INFO);
return 1;
}
else
{
logE(TAG_STM_PRO, "%s", "Sync Failure");
return 0;
}
}
else
{
logE(TAG_STM_PRO, "%s", "Serial Timeout");
return 0;
}
free(data);
return 0;
}
`

Similar changes you may need to make wherever this function is being used.

I hope this information helps you.

Thank you

from ota_update_stm32_using_esp32.

rickie95 avatar rickie95 commented on May 26, 2024

Just a tip, my 2 cents: I've encountered this issue on a NUCLEO STM32G431. In my case the ESP board could not reset the STM and this led to a SYNC error just as described in this thread. Even manually grounding the NRST pin the STM refused to reset. I ended up turning off and on the NUCLEO prior to the flash procedure, and then successfully flashed the firmware.

from ota_update_stm32_using_esp32.

adirsingh96 avatar adirsingh96 commented on May 26, 2024

Do we have to install some bootloader in STM32 MCU(I am using F103RB) to flash bin file using UART? I have tried every solution mentioned in the comments and still getting sync error / serial Timeout Error

from ota_update_stm32_using_esp32.

adirsingh96 avatar adirsingh96 commented on May 26, 2024

Do we have to install some bootloader in STM32 MCU(I am using F103RB) to flash bin file using UART? I have tried every solution mentioned in the comments and still getting sync error / serial Timeout Error

Solved this, I was using the wrong UART port of STM32 and boot configuration was not right

from ota_update_stm32_using_esp32.

bjesuslopezg avatar bjesuslopezg commented on May 26, 2024

I made it work by redefining the macro of SERIAL_TIMEOUT located in the stm_pro_mode.h to an extremely large value:
#define SERIAL_TIMEOUT 150000000

It was previously defined as 5000. My hypothesis was that since the problem is the timing out of the request, then let's extend the maximum time of it and see what happens. The result was that it works, but it takes like 10 seconds to upload the code to the STM32.

I'm using STM32F407 and ESP32-WROVER-B

from ota_update_stm32_using_esp32.

pinkymaxou avatar pinkymaxou commented on May 26, 2024

I made it work by redefining the macro of SERIAL_TIMEOUT located in the stm_pro_mode.h to an extremely large value: #define SERIAL_TIMEOUT 150000000

It was previously defined as 5000. My hypothesis was that since the problem is the timing out of the request, then let's extend the maximum time of it and see what happens. The result was that it works, but it takes like 10 seconds to upload the code to the STM32.

I'm using STM32F407 and ESP32-WROVER-B

That's because the SerialWait function doesn't work on current master, put a gigantic number make the while() run longer despite the not working delay. My fix should improve your situation.

#16

from ota_update_stm32_using_esp32.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.