espressif / esp-serial-flasher

Library for flashing Espressif SoCs from other MCUs.
Apache License 2.0
369 stars 109 forks source link

Failed to program files larger than Hello World (ESF-128) #105

Open caiubistaffoker opened 6 months ago

caiubistaffoker commented 6 months ago

Port

ESP, NXP (LPC54628)

Target chip

ESP32-WROOM-32E

Hardware Configuration

NXP development kit board (OM13098 - LPCXpresso54628) to record the ESP32-WROOM-32E by UART communication.

Log output

Please look at the files I left attached.

More Information

Below I leave the log of the recording version, with the Hello World code, which was possible to record on the ESP32. Additionally, I added a photo of the ESP32 which indicates that there was no application recording. Tests that I have already carried out and still had no effect: 1) In the esp_loader.c file, I changed the default timeout values and the recording of this code, greater than Hello World, still does not happen. 2) Using the flash tool, the same code was written to the ESP32 normally. Therefore, the code is not corrupted. 3) I generated an MQTT example code from Espressif itself and it was not possible to record it on the ESP32. Would it be possible for someone to help me find out why my code is not being recorded? ESP32_error_msg_after_nxp_prog_failed Log_NXP_Prog_ESP32_with_HelloWorld.txt Log_NXP_Prog_ESP32_with_LargestArchive.txt

higaski commented 6 months ago

Have you tried flashing without MD5 enabled? I couldn't get MD5 working either, but haven't looked into it yet.

DNedic commented 6 months ago

Hello @caiubistaffoker , thank you for your submission. The error 2 means there was a timeout. Please try bumping the MD5_TIMEOUT_PER_MB variable in esp_loader.c. You could also break at timeout_per_mb when debugging to check if there is a problem with the timeout calculation and the actual timeout value for your binary.

caiubistaffoker commented 6 months ago

Have you tried flashing without MD5 enabled? I couldn't get MD5 working either, but haven't looked into it yet.

Thank you @higaski for your ideia. I did what you said but wasn't fixed my problem. I think this checksum isn't the main problem. The real problem is I can't programming bigger code than Hello World.

caiubistaffoker commented 6 months ago

Hello @caiubistaffoker , thank you for your submission. The error 2 means there was a timeout. Please try bumping the MD5_TIMEOUT_PER_MB variable in esp_loader.c. You could also break at timeout_per_mb when debugging to check if there is a problem with the timeout calculation and the actual timeout value for your binary.

Hello @DNedic!!! Like I said to Vincent, I think this MD5 error isn't the main problem here. Because I can program Hello World code with the same error, but when I try to program a bigger code appears this library doesn't accept.

But I put a breakpoint in the "timeout_per_mb" function like you said and obtained that, within the flash check (esp_loader_flash_verify), the values of s_image_size and MD5_timeout_PER_MB are 3073 and 8000 respectively.

Now I put comparative output and input for RX data in "send_cmd_md5", as I did into other send_cmd functions and received the following messages:

DEBUG: Error: MD5 checksum does not match: DEBUG: Expected: DEBUG: 9ae97978d5d763291116c1de5d5a7bbf DEBUG: Actual: DEBUG: 6db74dbaa3c00fe78069fab05bc557e1 MD5 does not match. err: 4

Here is the full log: Log_NXP_Prog_ESP32_MD5Failed.txt

DNedic commented 6 months ago

So if I understand this correctly, the error is no longer the timeout, but MD5 does not match for bigger binaries?

Let's then separate out those 2 issues and solve them one at a time. Please try bumping the MD5_TIMEOUT_PER_MB variable until you get MD5 does not match error 4 (MD5 was received in time and actually does not match) in all cases.

Can you provide the binary you're trying to flash?

caiubistaffoker commented 6 months ago

So if I understand this correctly, the error is no longer the timeout, but MD5 does not match for bigger binaries?

Let's then separate out those 2 issues and solve them one at a time. Please try bumping the MD5_TIMEOUT_PER_MB variable until you get MD5 does not match error 4 (MD5 was received in time and actually does not match) in all cases.

Can you provide the binary you're trying to flash?

@DNedic, Let me try to explain better, the error is that I can't program any other code bigger than a Hello World code. I think this MD5 error is not a problem now because I programmed a Hello World code with this error using the esp-serial-flasher tool. You are right. Let's break down these topics. I'm going to try to solve this MD5 issue and then I need to fix this problem of not programming any other code greater than a Hello World code. About this specific binary, I can't invite you here because it's a private project. But you can try with the MQTT example binary. I think it's the same size and I've tried programming with it but I wasn't successful.

caiubistaffoker commented 6 months ago

So if I understand this correctly, the error is no longer the timeout, but MD5 does not match for bigger binaries?

Let's then separate out those 2 issues and solve them one at a time. Please try bumping the MD5_TIMEOUT_PER_MB variable until you get MD5 does not match error 4 (MD5 was received in time and actually does not match) in all cases.

Can you provide the binary you're trying to flash?

@DNedic How can I fix this error 4 with checksum comparator? Porque aumentei a variável MD5_TIMEOUT_PER_MB mas não resolveu o meu problema.

DNedic commented 6 months ago

Ca you try performing the exact same flashing but with a port supported by us (e.g. ESP32)?

caiubistaffoker commented 5 months ago

Ca you try performing the exact same flashing but with a port supported by us (e.g. ESP32)?

@DNedic, I used the STM32 port because it is a microcontroller more similar to the NXP than using the ESP32 port. So my configuration looked like this: Nucleo-G0B1RE connected to the ESP32. This configuration gave me some trouble, as I had to do some tests that I had already done with NXP.

As for changing the values of the timeout variables, I noticed that values between 2000 and 5000 are efficient in recording. Above that, I didn't get to test it.

Disabling MD5 does not impact recording. However, error 4 regarding MD5 continued to occur even in this firmware version with the port to STM32 created by you.

As for recording files larger than a Hello World, due to the STM32G0B1's limited Flash memory, I was only able to record an i2c_oled example. Would it be possible for you to try recording the binary for the mqtt5 example?

Below I will leave some logs available for checking. I would like to add that, using the STM32 port, it was not possible to leave the SERIAL_FLASHER_DEBUG_TRACE variable enabled to view the log because I was not even able to make the connection with the target. The error that appeared was a timeout, but I changed the DEFAULT_TIMEOUT variable to 5000 and even so, error 2 continued.

To summarize, the MD5 error (error 4) continues even with the espressif STM32 port and, my main problem of recording code larger than a Hello World, also continues because I was unable to record my main code (similar size to the example mqtt5).

LOG_STM_Prog_ESP32_Error2_usingDebugTrace.txt LOG_STM_Prog_ESP32_IncreaseTimeout_Error2_usingDebugTrace.txt LOG_STM_Prog_ESP32_MD5err4.txt

ioviedodev commented 5 months ago

Hi, thank you for your support. I wonder where can I find the target code? because this repo is thought in loader device I mean the receiver code, i need to check how the process the pakages. I understand that code is embeeded on ESP32 CHip, writgh? but I need that repo to a custom implementation.