BusPirate / Bus_Pirate

Community driven firmware and hardware for Bus Pirate version 3 and 4
625 stars 130 forks source link

Compiler change UART transparent bridge behaviour #132

Open psolyca opened 5 years ago

psolyca commented 5 years ago

I do not know if this issue could be related to issue #124 but I had trouble with UART transparent bridge and live monitor so I tried to find the bug.

The trouble

To flash my ESP8266, I need an USB<->TTL converter. As I had a BusPirate v3b, I tried to use it with the UART Transparent bridge mode. First, I have flashed the community firmware (09032019_OPT1_UNSAFE.hex) and get the prompt of the ESP8266 (micropython), the UART works. The command : m 3 9 enter enter enter 2 W (1)y

To be able to flash, I close my terminal, put my ESP8266 in download mode and launch my ESP8266 flash tool with a test command (BusPirate always in transparent bridge) : esptool.py -p COM7 chip_id I have "A fatal error occurred: Failed to connect to Espressif device: Invalid head of packet (0xE0)" or "(0xD0)" Same error whatever the command.

To be sure my download mode works on my ESP8266, I have used a Raspberry and the flash has worked.

The test

So as mentionned in issue #124, I downgraded my BusPirate to different firmware, a.k.a

With these firmwares I had no trouble testing the ESP8266.

The find

I tried to bisect the git repository (thanks to git bisect command) but between the first good commit and the last bad one, there was a difference of compiler from C30 to XC16. So I tried some revision between 10f1ec16ff24ab050ec8d048f398dc4ef6a8514f and e45a5fa66aac7e8f38d827313b6814bcd860c8a7 where I can easily compile both version. I compiled them with C30 then XC16. Each time, C30 versions work as intended and not XC16 (same message each time).

How I proceed

Each time, I have imported the old MATLAB 8 configuration file from a clean repository and then select C30 then XC16 compiler. Each version have build fine without error with level 1 optimization. I then upload the firmware with pirate-loader. The behaviour of the firmware between the imported configuration in XC16 and the XC16 configuration is the same.

Finally

How does the compiler can change the behaviour of the firmware? Is there a specific parameter which change from one compiler to the other? Have I forgot something or done something wrong ?