Hi everyone, thanks for checking out this forum post!
I’m currently trying to fix the OTA update for the rtl8720dn chip. I’m using the update_ota_cloud(char* char*) function (inside update.h of the sdk) to update the OTA bank. Everything seems to work, the ftp server also sees an incoming socket.
The problem I’m facing is related to the hostname. The sdk (AmebaD 3.0.7) doesn’t provide the feature to set the hostname and password of the ftp. I’m also not able to set the hostname to anonymous. Is there a way to edit the hostname, or is it possible to see update.cpp to create a lib on my own?
Arduino platform uses pre-built binaries as static libraries used during linking stage, thus all source code are already compiled and not to be changed. There is however, no OTA example with 3.0.7 package nor update.cpp in this package. You may refer to the OTA related source code in our open source standard SDK located on the official github account, you may find the github link on the top right of this forum homepage, and should you desire, you may write your own update.cpp and contribute to the forum so that everyboday can benefit from your work
Also, after grasp the source code u found, you may like to take a look at Ameba RTL8195’s arduino OTA example and Arduino OTA API as follows, though RTL8720 is vastly different from RTL8195 but this example and cpp file should still be useful to you
Thanks for the references! I’ve got it working under the Arduino compiler. It’s pretty easy to compile the official sources from the sdk as library in the arduino project.
At the moment i’m stuck at the point of compiling the project into a binary or hex file (for ota). Could there be some export lines missing in the platform.txt (\realtek\hardware\AmebaD\3.0.7\platform.txt)? And if so, could you provide me the correct information to be able to compile the code into a binary which could be used for OTA updates.
I need more information about the issue you are facing.
Do you mean that you have compiled the OTA source code into library (.a) but could not link it into your arduino sketch code to output a usable firmware?
If my understanding is correct, then you should take a look of the platform.txt at
and add your static library (.a) into this line and to the same path as the rest of the .a libraries, then gcc will automatically search for the source code inside your .a and link it to your arduino sketch during linking stage and output the firmware at the end
I think this is not the case. Let me be more specific. The arduino IDE provides a feature to compile the sketch directly to a binary (.bin or .ino.hex if i remember correct). It’s under the ‘sketch’ tab in the arduino IDE. When I try to compile the code for the rtl8720dn (with or without the OTA lib addition, doesn’t matter in this case), it compiles fine. But in the sketch folder or temp arduino_build folder, it’s not showing the binary / firmware which could be used for the OTA.
Maybe I’m thinking completely wrong, but worth a shot.
You must have noticed that Arduino sketch (.ino) is actually a CPP file thus need to be compiled using a CPP compiler.
In order to use a source code written in C under Arduino IDE (in this case for RTL8720DN, the compiler is g++, a free compiler for C++ source code), there are 2 methods,
Convert the original C source code into a CPP file and place it into the sketch folder as a library.
This way the CPP will be compiled into object code and add to a temporary archive file (.a) for linking later
Compile the C source code from the SDK where you found it into a object code and archive it into an archive file (.a) and put it into the folder I mentioned in my last reply and also add the name to line 70 of the platform.txt
Note: Tools needed for all above procedures are alrady provided in the arduino package inside the toolchain folder, this will spare you the time needed to find and download the correct toolchain
Sorry if I’m bothering you with all the questions ! With your steps I was able to compile a working binary based for updates etc.
Currently the OTA runs, but breaks everytime on step 3 (as described in rtl8721d_ota.c). At this step it parse firmware file headers and gets the desired OTA headers (func: get_ota_target_header()). It keeps breaking in this part:
if (strncmp("OTA", (const char *)pTempAddr, 3) == 0)
index = 0;
What am I missing or doing wrong in this flow? Does the server has to specify some extra headers? Or is this a mistake in the code? To be more specific, I’ve changed nothing in the function as written in the sdk.
Currently I’ve a CPP project which compiles through Arduino. Since the arduino package did not include the full implementation of an ota, I’ve used rtl8721d_ota.c in my code as library. I’m sadly not able to share my code, but I can be more specific on this part to give you an idea. It’s basicly just added as library (extern c) to my cpp project. Since all dependancies of the arduino package and official sdk are the same, it works on copy pasting the source to your own project as lib.
When including it in my environment/ system, it works. All function calls are running without errors or linking errors. But the point is related to the OTA Headers. While parsing in the above code snippet, the code seems to break.
The problem could be on server side, where the expected OTA headers are not send while fetching from the rtl8720dn. But it could also be something on the rtl8721dn_ota.c side.
Hope this gives some context. If not, don’t hesitate to reach out.
Thanks for your time! Really appreciate it.
Now this will have to go back to code and OTA requirement described in the documentation, luckily I found what you need in the official website, simply register there and you can donwload this doc for free
Completely forgot to come back to this topic. Everything seems to work now. The OTA works, and the bank will be switched after updating. The only question left is, how do I select the bank to flash my ‘test’ code to with Arduino. When the OTA is completed, the bank is switched. But my software keeps being flashed (mannualy, not OTA) on the first bank. I’ve checked the documentation, but did not found a solution for this.
Thanks! When i fixed this last thing I’d love to end this post with a full explanation of how get it working. It’s not that hard, and the code is almost identical to the code from the sdk. I’ll ask If I’m allowed to share my work (physical) on here, but If I’m not allowed to, I’ll describe the proces from begin to end.
Hopefully the image below explains a bit more of the problem.