Realtek_switch_hacking icon indicating copy to clipboard operation
Realtek_switch_hacking copied to clipboard

How to compile Realtek_Unmanaged_Switch_API_V1.3.12_20171124

Open Firemanpl opened this issue 1 year ago • 8 comments

the attached files do not talk about the general configuration and compilation of these libraries. These are only details. How to connect the interface and how to compile and create a file. I didn't read that. Is there something wrong with me? :( I trying compile firmware ASIC driver for RTL8730MB and i don't know how to do it.

Firemanpl avatar Apr 22 '24 12:04 Firemanpl

Thank you in advance for your help

Firemanpl avatar Apr 22 '24 12:04 Firemanpl

@Firemanpl

Is there something wrong with me? :(

No. You're doing well, but it's the holy crab, Realtek, hides everything inside its shell.

The RTL8370 series supports multiple "modes" by configuring several pins, including SMI slave, I2C host (reading config from external EEPROM), or running some firmware from external SPI NOR flash in its internal 8051 core. If you're gonna use "Realtek_Unmanaged_Switch_API_V1.3.12_20171124", then you don't need any firmware running on RTL8370. Instead, it's working as an SMI slave.

The API is running on other SoCs (e.g. ESP32, RP2040, or whatever you love) which should be connected to RTL8370 via SMI. The hardware connection is similar to I2C. The APIs should be ported to the SoC (by implementing smi_write and smi_read, maybe you can use this as the SMI porting reference), then call the APIs on the top. The document is mainly about explaining those top APIs.

I don't know if this helps.

libc0607 avatar Apr 22 '24 17:04 libc0607

So just design a PC board with separators and without uploading additional firmware should be used? But I want program several functions. For this purpose I would like to use the internal CPU processor to use the GPIO pins.

Firemanpl avatar Apr 29 '24 09:04 Firemanpl

So I used SDDM on platformio. And after I make basic configuration loop. I getting this:

`Processing Generic8051 (platform: intel_mcs51; board: Generic8051)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/intel_mcs51/Generic8051.html PLATFORM: Intel MCS-51 (8051) (2.2.0) > Generic 8051 HARDWARE: 8051 11MHz, 128B RAM, 4KB Flash PACKAGES:

  • toolchain-sdcc @ 1.40100.12072 (4.1.0) LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Found 1 compatible libraries Scanning dependencies... Dependency Graph |-- API_Source Building in release mode Warning! Unknown upload protocol Compiling .pio/build/Generic8051/src/main.rel lib/API_Source/svlan.h:663: error 97: SDCC cannot pass structure '_mac' as function argument lib/API_Source/svlan.h:663: error 97: SDCC cannot pass structure '_macMsk' as function argument lib/API_Source/svlan.h:663: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_add_PARM_1' as function argument lib/API_Source/svlan.h:663: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_add_PARM_2' as function argument lib/API_Source/svlan.h:683: error 97: SDCC cannot pass structure '_mac' as function argument lib/API_Source/svlan.h:683: error 97: SDCC cannot pass structure '_macMsk' as function argument lib/API_Source/svlan.h:683: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_del_PARM_1' as function argument lib/API_Source/svlan.h:683: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_del_PARM_2' as function argument lib/API_Source/svlan.h:703: error 97: SDCC cannot pass structure '_mac' as function argument lib/API_Source/svlan.h:703: error 97: SDCC cannot pass structure '_macMsk' as function argument lib/API_Source/svlan.h:703: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_get_PARM_1' as function argument lib/API_Source/svlan.h:703: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_get_PARM_2' as function argument Compiling .pio/build/Generic8051/lib875/API_Source/acl.rel *** [.pio/build/Generic8051/src/main.rel] Error 1 lib/API_Source/svlan.h:663: error 97: SDCC cannot pass structure '_mac' as function argument lib/API_Source/svlan.h:663: error 97: SDCC cannot pass structure '_macMsk' as function argument lib/API_Source/svlan.h:663: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_add_PARM_1' as function argument lib/API_Source/svlan.h:663: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_add_PARM_2' as function argument lib/API_Source/svlan.h:683: error 97: SDCC cannot pass structure '_mac' as function argument lib/API_Source/svlan.h:683: error 97: SDCC cannot pass structure '_macMsk' as function argument lib/API_Source/svlan.h:683: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_del_PARM_1' as function argument lib/API_Source/svlan.h:683: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_del_PARM_2' as function argument lib/API_Source/svlan.h:703: error 97: SDCC cannot pass structure '_mac' as function argument lib/API_Source/svlan.h:703: error 97: SDCC cannot pass structure '_macMsk' as function argument lib/API_Source/svlan.h:703: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_get_PARM_1' as function argument lib/API_Source/svlan.h:703: error 97: SDCC cannot pass structure '_rtk_svlan_l2mc2s_get_PARM_2' as function argument lib/API_Source/acl.c:1620: warning 94: comparison is always false due to limited range of data type lib/API_Source/acl.c:1623: warning 94: comparison is always false due to limited range of data type *** [.pio/build/Generic8051/lib875/API_Source/acl.rel] Error 1example of basic file:#include <stdio.h> #include <rtk_switch.h> #include <svlan.h>

int main() { //rtk_switch_init();

return 0; } `

Firemanpl avatar Apr 29 '24 09:04 Firemanpl

aaaaa so this 8051 is only for use instructions from SPI or SMI interface from another MCU like ESP8266 or ESP32 or external EEPROM ?

Firemanpl avatar Apr 29 '24 09:04 Firemanpl

so RTL8370MB does not have build-in memory ?

Firemanpl avatar Apr 29 '24 09:04 Firemanpl

only RAM. And RTL8370MB reading from only external EEPROM flash or another MCU like RP2040 or ESP32 or ESP8266 ?

Firemanpl avatar Apr 29 '24 09:04 Firemanpl

@Firemanpl

As far as I know, there are at least two different SDKs for these chips. They are completely different.

One is that we all have, "Realtek_Unmanaged_Switch_API", for external SoCs utilizing the L2 functions. In that situation, the internal 8051 core is disabled by strapping pins, what the external SoCs exactly do is set the register via the SMI interface, which is most likely an HDL-hard-coded SMI slave interface. The L2 functions are implemented in hardware, and those "Unmanaged APIs" are actually wrappings of register sets & resets.

The other is called "LWS (Light Web Smart) SDK", which might be what you're looking for, is about running codes in the DW8051 core inside the RTL8370. In that case, a bootrom should be programmed into the internal 8051's ROM, then the 8051 boot from this ROM, and load the firmware (or 2nd bootloader) with web from SPI flash.

Compiling the "Realtek_Unmanaged_Switch_API" for a generic 8051 target does not make sense -- as I described above, it's not designed for it and I don't think anyone can build a minimal SDCC environment without the help from Realtek. We don't have any register-level documents. Even the LWS SDK contains a lot of pre-compiled static libraries used to operate the registers, the only thing developers in companies like TP-LINK can do with this SDK is tweak the HTTP pages (mainly CSS) and change the company logo to theirs.

Sadly, I don't know how can share the LWS SDK, and someone still selling the bootrom code for a living (see https://github.com/libc0607/Realtek_switch_hacking/issues/1#issuecomment-396489993. note that "几万" means several thousand of USD, means China’s median income for dozens of months).

What a weird business model.

But IMO you can still control the LED GPIOs on RTL8370, by using the LED APIs. See the "Modules led.h" section in the Unmanaged Switch API document.

libc0607 avatar Apr 29 '24 10:04 libc0607