Can we put the IC into UART DOWNLOAD mode via command?

Hi all,

RTL8721
sdk-amebad_v6.2b_rc

Can we put the IC into UART DOWNLOAD mode via command? I wish to upgrade the firmware but I don’t have a button to toggle UART_DOWNLOAD pin to low.

Hi, it is not possible as of now because the UART_DOWNLOAD pin must go low in order to enter the UART Download mode, to do this, you might need to connect a button to your Ameba.

@JeroenT Yes, you can:

#include "rtl8721d.h"

(...)

BKUP_Set(0, BIT_UARTBURN_BOOT);
NVIC_SystemReset();

This is also what the factory firmware does when you issue the reboot uartburn command in the LOGUART terminal.

1 Like

Hi @basteagow , thanks for sharing! This is very interesting, may I know where I can find more details about setting my chip to UART DOWNLOAD mode using command?

Sure! This feature is largely undocumented. Section 8.3.1.2 of the application notes (AN0400 v13) does casually mention the factory firmware CLI’s reboot uartburn command, but that’s about it. The code in my previous post shows what that command does internally [1], so that you can implement the functionality in your own firmware.

[1] component/soc/realtek/amebad/app/monitor/ram/monitor_hp.c::cmd_reboot()

2 Likes

Very cool! Thanks! I am gonna try this and let you know how it goes~ :smile:

Hi @basteagow

I have tried this in Arduino environment and the code doesn’t seem to work as intended, NVIC_SystemRest will hang the CPU and thus nothing happens.

Does it have to use

as you previously mentioned? or must it be compiled under the Realtek standard C SDK for this command to work?

The code I posted is for the standard SDK, yes. Since all it does is write to a register before a reset, you can likely accomplish the same thing in Arduino, but I don’t use that SDK so I can’t tell you how. If you make it work, please share!

using standard SDK ok, and how do you upload image into ameba then? imagetool? or JLINK?

Either; ImageTool uses UART_DOWNLOAD like the Arduino toolchain.

Would you mind sharing a bit more about this part of the code? Must these 2 lines be situated in main or in a callback function? Any other setup/configuration needed before or after these 2 lines?

Thanks a lot!